@rizom/ops 0.2.0-alpha.671 → 0.2.0-alpha.673

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/index.js CHANGED
@@ -99,7 +99,7 @@ IFS=',' read -ra HOSTS <<< "$KAMAL_HOSTS"
99
99
  for host in "\${HOSTS[@]}"; do
100
100
  scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$BRAIN_FILE" "\${SSH_USER}@\${host}:/opt/brain.yaml"
101
101
  done
102
- `}import{appendFileSync as vme,readFileSync as X5}from"fs";function nb(e,t){let r=[],o=new Set,n=t?.skipSections??new Set,i=!1,s=!1,a=!1;for(let c of e.split(/\r?\n/)){let u=c.trim();if(e8.test(u)){i=n.has(u),s=!1,a=!1;continue}if(i)continue;if(u.startsWith("#")){if(u.includes("@required"))s=!0;if(u.includes("@sensitive"))a=!0;continue}let d=u.match(/^([A-Z][A-Z0-9_]*)=/);if(!d?.[1]){s=!1,a=!1;continue}let f=d[1];if(!o.has(f))o.add(f),r.push({key:f,required:s,sensitive:a});s=!1,a=!1}return r}function ob(e,t){return nb(X5(e,"utf8"),t)}var e8;var wR=w(()=>{e8=/^# ---- .+ ----$/});import{existsSync as t8,readFileSync as r8}from"fs";import{homedir as n8}from"os";import{isAbsolute as o8,join as ib,resolve as i8}from"path";function on(e){let t={};for(let r of[ib(e,".env"),ib(e,".env.local")]){if(!t8(r))continue;let o=s8(r8(r,"utf8"));for(let[n,i]of Object.entries(o))t[n]=i}return t}function Dt(e,t,r){return t[e]??r[e]}function Jo(e,t){if(e.startsWith("~/"))return ib(process.env.HOME??n8(),e.slice(2));if(o8(e))return e;return i8(t,e)}function s8(e){let t={};for(let r of e.split(/\r?\n/)){let o=r.trim();if(o.length===0||o.startsWith("#"))continue;let n=r.match(/^\s*(?:export\s+)?([A-Z][A-Z0-9_]*)\s*=\s*(.*)\s*$/),i=n?.[1],s=n?.[2];if(!i||s===void 0)continue;t[i]=a8(s)}return t}function a8(e){if(e.length>=2&&e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e.length>=2&&e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/\\n/g,`
102
+ `}import{appendFileSync as wme,readFileSync as X5}from"fs";function nb(e,t){let r=[],o=new Set,n=t?.skipSections??new Set,i=!1,s=!1,a=!1;for(let c of e.split(/\r?\n/)){let u=c.trim();if(e8.test(u)){i=n.has(u),s=!1,a=!1;continue}if(i)continue;if(u.startsWith("#")){if(u.includes("@required"))s=!0;if(u.includes("@sensitive"))a=!0;continue}let d=u.match(/^([A-Z][A-Z0-9_]*)=/);if(!d?.[1]){s=!1,a=!1;continue}let f=d[1];if(!o.has(f))o.add(f),r.push({key:f,required:s,sensitive:a});s=!1,a=!1}return r}function ob(e,t){return nb(X5(e,"utf8"),t)}var e8;var wR=w(()=>{e8=/^# ---- .+ ----$/});import{existsSync as t8,readFileSync as r8}from"fs";import{homedir as n8}from"os";import{isAbsolute as o8,join as ib,resolve as i8}from"path";function on(e){let t={};for(let r of[ib(e,".env"),ib(e,".env.local")]){if(!t8(r))continue;let o=s8(r8(r,"utf8"));for(let[n,i]of Object.entries(o))t[n]=i}return t}function Dt(e,t,r){return t[e]??r[e]}function Jo(e,t){if(e.startsWith("~/"))return ib(process.env.HOME??n8(),e.slice(2));if(o8(e))return e;return i8(t,e)}function s8(e){let t={};for(let r of e.split(/\r?\n/)){let o=r.trim();if(o.length===0||o.startsWith("#"))continue;let n=r.match(/^\s*(?:export\s+)?([A-Z][A-Z0-9_]*)\s*=\s*(.*)\s*$/),i=n?.[1],s=n?.[2];if(!i||s===void 0)continue;t[i]=a8(s)}return t}function a8(e){if(e.length>=2&&e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e.length>=2&&e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/\\n/g,`
103
103
  `).replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\"/g,'"').replace(/\\\\/g,"\\");return e}var sb=()=>{};function IR(e,t,r){if(t===r)return!1;return t.includes(f8[e])}function kR(){return Uf}function AR(e){if(e.includes('LABEL ai.rizom.brain.watchdog="true"')&&e.includes("http://127.0.0.1:8080/health/live")&&e.includes('ENTRYPOINT ["/usr/bin/tini", "--"]')&&e.includes("BUN_CHROME_PATH=/usr/bin/chromium-headless-shell")&&e.includes('CMD ["bun", "--no-orphans", "./node_modules/@rizom/brain/dist/brain.js", "start"]')){let i=Uf.indexOf("# --- fleet:");return e===Uf.slice(0,i)+`# --- fleet: install published brain at pinned version (ops deploy) ---
104
104
  FROM runtime AS fleet
105
105
  ARG BRAIN_VERSION
@@ -209,8 +209,8 @@ volumes:
209
209
 
210
210
  `)}h.write("payload.value = newResult;"),h.write("return payload;");let _=h.compile();return(A,O)=>_(m,A,O)},i,s=cs,a=!is.jitless,u=a&&Db.value,d=t.catchall,f;e._zod.parse=(m,h)=>{f??(f=o.value);let b=m.value;if(!s(b))return m.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),m;if(a&&u&&h?.async===!1&&h.jitless!==!0){if(!i)i=n(t.shape);if(m=i(m,h),!d)return m;return WO([],b,m,h,f,e)}return r(m,h)}});Hl=Z("$ZodUnion",(e,t)=>{Ne.init(e,t),Ze(e._zod,"optin",()=>t.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),Ze(e._zod,"optout",()=>t.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),Ze(e._zod,"values",()=>{if(t.options.every((o)=>o._zod.values))return new Set(t.options.flatMap((o)=>Array.from(o._zod.values)));return}),Ze(e._zod,"pattern",()=>{if(t.options.every((o)=>o._zod.pattern)){let o=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${o.map((n)=>Dl(n.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return PO(s,o,e,n);return Promise.all(s).then((a)=>PO(a,o,e,n))}});$v=Z("$ZodXor",(e,t)=>{Hl.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else s.push(c)}if(!i)return zO(s,o,e,n);return Promise.all(s).then((a)=>zO(a,o,e,n))}}),Rv=Z("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Hl.init(e,t);let r=e._zod.parse;Ze(e._zod,"propValues",()=>{let n={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[a,c]of Object.entries(s)){if(!n[a])n[a]=new Set;for(let u of c)n[a].add(u)}}return n});let o=va(()=>{let n=t.options,i=new Map;for(let s of n){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let c of a){if(i.has(c))throw Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!cs(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let a=o.value.get(s?.[t.discriminator]);if(a)return a._zod.run(n,i);if(t.unionFallback||i.direction==="backward")return r(n,i);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:s,path:[t.discriminator],inst:e}),n}}),Ov=Z("$ZodIntersection",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,i=t.left._zod.run({value:n,issues:[]},o),s=t.right._zod.run({value:n,issues:[]},o);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>NO(r,c,u));return NO(r,i,s)}});hp=Z("$ZodTuple",(e,t)=>{Ne.init(e,t);let r=t.items;e._zod.parse=(o,n)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];let s=[],a=DO(r,"optin"),c=DO(r,"optout");if(!t.rest){if(i.length<a)return o.issues.push({code:"too_small",minimum:a,inclusive:!0,input:i,inst:e,origin:"array"}),o;if(i.length>r.length)o.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:i,inst:e,origin:"array"})}let u=Array(r.length);for(let d=0;d<r.length;d++){let f=r[d]._zod.run({value:i[d],issues:[]},n);if(f instanceof Promise)s.push(f.then((m)=>{u[d]=m}));else u[d]=f}if(t.rest){let d=r.length-1,f=i.slice(r.length);for(let m of f){d++;let h=t.rest._zod.run({value:m,issues:[]},n);if(h instanceof Promise)s.push(h.then((b)=>LO(b,o,d)));else LO(h,o,d)}}if(s.length)return Promise.all(s).then(()=>BO(u,o,r,i,c));return BO(u,o,r,i,c)}});Cv=Z("$ZodRecord",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!Wo(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let a=new Set;for(let u of s)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){a.add(typeof u==="number"?u.toString():u);let d=t.keyType._zod.run({value:u,issues:[]},o);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((h)=>ur(h,o,ht())),input:u,path:[u],inst:e});continue}let f=d.value,m=t.valueType._zod.run({value:n[u],issues:[]},o);if(m instanceof Promise)i.push(m.then((h)=>{if(h.issues.length)r.issues.push(...vr(u,h.issues));r.value[f]=h.value}));else{if(m.issues.length)r.issues.push(...vr(u,m.issues));r.value[f]=m.value}}let c;for(let u in n)if(!a.has(u))c=c??[],c.push(u);if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof a==="string"&&Ml.test(a)&&c.issues.length){let f=t.keyType._zod.run({value:Number(a),issues:[]},o);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)c=f}if(c.issues.length){if(t.mode==="loose")r.value[a]=n[a];else r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map((f)=>ur(f,o,ht())),input:a,path:[a],inst:e});continue}let d=t.valueType._zod.run({value:n[a],issues:[]},o);if(d instanceof Promise)i.push(d.then((f)=>{if(f.issues.length)r.issues.push(...vr(a,f.issues));r.value[c.value]=f.value}));else{if(d.issues.length)r.issues.push(...vr(a,d.issues));r.value[c.value]=d.value}}}if(i.length)return Promise.all(i).then(()=>r);return r}}),Pv=Z("$ZodMap",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;let i=[];r.value=new Map;for(let[s,a]of n){let c=t.keyType._zod.run({value:s,issues:[]},o),u=t.valueType._zod.run({value:a,issues:[]},o);if(c instanceof Promise||u instanceof Promise)i.push(Promise.all([c,u]).then(([d,f])=>{jO(d,f,r,s,n,e,o)}));else jO(c,u,r,s,n,e,o)}if(i.length)return Promise.all(i).then(()=>r);return r}});zv=Z("$ZodSet",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;let i=[];r.value=new Set;for(let s of n){let a=t.valueType._zod.run({value:s,issues:[]},o);if(a instanceof Promise)i.push(a.then((c)=>ZO(c,r)));else ZO(a,r)}if(i.length)return Promise.all(i).then(()=>r);return r}});Nv=Z("$ZodEnum",(e,t)=>{Ne.init(e,t);let r=Nl(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter((n)=>Ll.has(typeof n)).map((n)=>typeof n==="string"?Ur(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let s=n.value;if(o.has(s))return n;return n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),Dv=Z("$ZodLiteral",(e,t)=>{if(Ne.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map((o)=>typeof o==="string"?Ur(o):o?Ur(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{let i=o.value;if(r.has(i))return o;return o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),Lv=Z("$ZodFile",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(n instanceof File)return r;return r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),Bv=Z("$ZodTransform",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new ss(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then((s)=>(r.value=s,r.fallback=!0,r));if(n instanceof Promise)throw new Tn;return r.value=n,r.fallback=!0,r}});gp=Z("$ZodOptional",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ze(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Dl(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,i=t.innerType._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>UO(s,n));return UO(i,n)}if(r.value===void 0)return r;return t.innerType._zod.run(r,o)}}),jv=Z("$ZodExactOptional",(e,t)=>{gp.init(e,t),Ze(e._zod,"values",()=>t.innerType._zod.values),Ze(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),Zv=Z("$ZodNullable",(e,t)=>{Ne.init(e,t),Ze(e._zod,"optin",()=>t.innerType._zod.optin),Ze(e._zod,"optout",()=>t.innerType._zod.optout),Ze(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Dl(r.source)}|null)$`):void 0}),Ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),Uv=Z("$ZodDefault",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",Ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>qO(i,t));return qO(n,t)}});qv=Z("$ZodPrefault",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",Ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,o)}}),Mv=Z("$ZodNonOptional",(e,t)=>{Ne.init(e,t),Ze(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>MO(i,e));return MO(n,e)}});Fv=Z("$ZodSuccess",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new ss("ZodSuccess");let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>(r.value=i.issues.length===0,r));return r.value=n.issues.length===0,r}}),Jv=Z("$ZodCatch",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",Ze(e._zod,"optout",()=>t.innerType._zod.optout),Ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>{if(r.value=i.value,i.issues.length)r.value=t.catchValue({...r,error:{issues:i.issues.map((s)=>ur(s,o,ht()))},input:r.value}),r.issues=[],r.fallback=!0;return r});if(r.value=n.value,n.issues.length)r.value=t.catchValue({...r,error:{issues:n.issues.map((i)=>ur(i,o,ht()))},input:r.value}),r.issues=[],r.fallback=!0;return r}}),Kv=Z("$ZodNaN",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{if(typeof r.value!=="number"||!Number.isNaN(r.value))return r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r;return r}}),yp=Z("$ZodPipe",(e,t)=>{Ne.init(e,t),Ze(e._zod,"values",()=>t.in._zod.values),Ze(e._zod,"optin",()=>t.in._zod.optin),Ze(e._zod,"optout",()=>t.out._zod.optout),Ze(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>lp(s,t.in,o));return lp(i,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>lp(i,t.out,o));return lp(n,t.out,o)}});Vl=Z("$ZodCodec",(e,t)=>{Ne.init(e,t),Ze(e._zod,"values",()=>t.in._zod.values),Ze(e._zod,"optin",()=>t.in._zod.optin),Ze(e._zod,"optout",()=>t.out._zod.optout),Ze(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if((o.direction||"forward")==="forward"){let i=t.in._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>up(s,t,o));return up(i,t,o)}else{let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>up(s,t,o));return up(i,t,o)}}});Hv=Z("$ZodPreprocess",(e,t)=>{yp.init(e,t)}),Vv=Z("$ZodReadonly",(e,t)=>{Ne.init(e,t),Ze(e._zod,"propValues",()=>t.innerType._zod.propValues),Ze(e._zod,"values",()=>t.innerType._zod.values),Ze(e._zod,"optin",()=>t.innerType?._zod?.optin),Ze(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then(FO);return FO(n)}});Wv=Z("$ZodTemplateLiteral",(e,t)=>{Ne.init(e,t);let r=[];for(let o of t.parts)if(typeof o==="object"&&o!==null){if(!o._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);let n=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!n)throw Error(`Invalid template literal part: ${o._zod.traits}`);let i=n.startsWith("^")?1:0,s=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(i,s))}else if(o===null||Bb.has(typeof o))r.push(Ur(`${o}`));else throw Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(o,n)=>{if(typeof o.value!=="string")return o.issues.push({input:o.value,inst:e,expected:"string",code:"invalid_type"}),o;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(o.value))return o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o;return o}}),Gv=Z("$ZodFunction",(e,t)=>(Ne.init(e,t),e._def=t,e._zod.def=t,e.implement=(r)=>{if(typeof r!=="function")throw Error("implement() must be called with a function");return function(...o){let n=e._def.input?Hf(e._def.input,o):o,i=Reflect.apply(r,this,n);if(e._def.output)return Hf(e._def.output,i);return i}},e.implementAsync=(r)=>{if(typeof r!=="function")throw Error("implementAsync() must be called with a function");return async function(...o){let n=e._def.input?await Vf(e._def.input,o):o,i=await Reflect.apply(r,this,n);if(e._def.output)return await Vf(e._def.output,i);return i}},e._zod.parse=(r,o)=>{if(typeof r.value!=="function")return r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r;if(e._def.output&&e._def.output._zod.def.type==="promise")r.value=e.implementAsync(r.value);else r.value=e.implement(r.value);return r},e.input=(...r)=>{let o=e.constructor;if(Array.isArray(r[0]))return new o({type:"function",input:new hp({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output});return new o({type:"function",input:r[0],output:e._def.output})},e.output=(r)=>new e.constructor({type:"function",input:e._def.input,output:r}),e)),Qv=Z("$ZodPromise",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>Promise.resolve(r.value).then((n)=>t.innerType._zod.run({value:n,issues:[]},o))}),Yv=Z("$ZodLazy",(e,t)=>{Ne.init(e,t),Ze(e._zod,"innerType",()=>{let r=t;if(!r._cachedInner)r._cachedInner=t.getter();return r._cachedInner}),Ze(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Ze(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Ze(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Ze(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,o)=>e._zod.innerType._zod.run(r,o)}),Xv=Z("$ZodCustom",(e,t)=>{rt.init(e,t),Ne.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=(r)=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then((i)=>JO(i,r,o,e));JO(n,r,o,e);return}})});function tw(){return{localeError:jJ()}}var jJ=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${n.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`;return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${i}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`}case"invalid_value":if(n.values.length===1)return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${ce(n.values[0])}`;return`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${i} ${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"}`;return`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${i} ${n.minimum.toString()} ${s.unit}`;return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${n.prefix}"`;if(i.format==="ends_with")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${i.suffix}"`;if(i.format==="includes")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${i.includes}"`;if(i.format==="regex")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${i.pattern}`;return`${r[i.format]??n.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${n.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${n.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${n.keys.length>1?"\u0629":""}: ${Q(n.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};var QO=w(()=>{Ee()});function rw(){return{localeError:ZJ()}}var ZJ=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${n.expected}, daxil olan ${a}`;return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${i}, daxil olan ${a}`}case"invalid_value":if(n.values.length===1)return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${ce(n.values[0])}`;return`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${i}${n.maximum.toString()} ${s.unit??"element"}`;return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${i}${n.minimum.toString()} ${s.unit}`;return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Yanl\u0131\u015F m\u0259tn: "${i.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`;if(i.format==="ends_with")return`Yanl\u0131\u015F m\u0259tn: "${i.suffix}" il\u0259 bitm\u0259lidir`;if(i.format==="includes")return`Yanl\u0131\u015F m\u0259tn: "${i.includes}" daxil olmal\u0131d\u0131r`;if(i.format==="regex")return`Yanl\u0131\u015F m\u0259tn: ${i.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`;return`Yanl\u0131\u015F ${r[i.format]??n.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${n.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${n.keys.length>1?"lar":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${n.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};var YO=w(()=>{Ee()});function XO(e,t,r,o){let n=Math.abs(e),i=n%10,s=n%100;if(s>=11&&s<=19)return o;if(i===1)return t;if(i>=2&&i<=4)return r;return o}function nw(){return{localeError:UJ()}}var UJ=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},o={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${n.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${i}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`}case"invalid_value":if(n.values.length===1)return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${ce(n.values[0])}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s){let a=Number(n.maximum),c=XO(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${i}${n.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s){let a=Number(n.minimum),c=XO(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${i}${n.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${i.suffix}"`;if(i.format==="includes")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${i.includes}"`;if(i.format==="regex")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${n.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${n.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};var e1=w(()=>{Ee()});function ow(){return{localeError:qJ()}}var qJ=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},o={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`;return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${i}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`}case"invalid_value":if(n.values.length===1)return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${ce(n.values[0])}`;return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${i}${n.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`;return`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${i}${n.minimum.toString()} ${s.unit}`;return`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${i.suffix}"`;if(i.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${i.includes}"`;if(i.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${i.pattern}`;let s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";if(i.format==="emoji")s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E";if(i.format==="datetime")s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E";if(i.format==="date")s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430";if(i.format==="time")s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E";if(i.format==="duration")s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430";return`${s} ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${n.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u043E\u0432\u0435":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};var t1=w(()=>{Ee()});function iw(){return{localeError:MJ()}}var MJ=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Tipus inv\xE0lid: s'esperava instanceof ${n.expected}, s'ha rebut ${a}`;return`Tipus inv\xE0lid: s'esperava ${i}, s'ha rebut ${a}`}case"invalid_value":if(n.values.length===1)return`Valor inv\xE0lid: s'esperava ${ce(n.values[0])}`;return`Opci\xF3 inv\xE0lida: s'esperava una de ${Q(n.values," o ")}`;case"too_big":{let i=n.inclusive?"com a m\xE0xim":"menys de",s=t(n.origin);if(s)return`Massa gran: s'esperava que ${n.origin??"el valor"} contingu\xE9s ${i} ${n.maximum.toString()} ${s.unit??"elements"}`;return`Massa gran: s'esperava que ${n.origin??"el valor"} fos ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?"com a m\xEDnim":"m\xE9s de",s=t(n.origin);if(s)return`Massa petit: s'esperava que ${n.origin} contingu\xE9s ${i} ${n.minimum.toString()} ${s.unit}`;return`Massa petit: s'esperava que ${n.origin} fos ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Format inv\xE0lid: ha de comen\xE7ar amb "${i.prefix}"`;if(i.format==="ends_with")return`Format inv\xE0lid: ha d'acabar amb "${i.suffix}"`;if(i.format==="includes")return`Format inv\xE0lid: ha d'incloure "${i.includes}"`;if(i.format==="regex")return`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${i.pattern}`;return`Format inv\xE0lid per a ${r[i.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${n.divisor}`;case"unrecognized_keys":return`Clau${n.keys.length>1?"s":""} no reconeguda${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${n.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${n.origin}`;default:return"Entrada inv\xE0lida"}}};var r1=w(()=>{Ee()});function sw(){return{localeError:FJ()}}var FJ=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(n){return e[n]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},o={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${n.expected}, obdr\u017Eeno ${a}`;return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${i}, obdr\u017Eeno ${a}`}case"invalid_value":if(n.values.length===1)return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${ce(n.values[0])}`;return`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${i}${n.maximum.toString()} ${s.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${i}${n.minimum.toString()} ${s.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${i.prefix}"`;if(i.format==="ends_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${i.suffix}"`;if(i.format==="includes")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${i.includes}"`;if(i.format==="regex")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${i.pattern}`;return`Neplatn\xFD form\xE1t ${r[i.format]??n.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${n.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${Q(n.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${n.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${n.origin}`;default:return"Neplatn\xFD vstup"}}};var n1=w(()=>{Ee()});function aw(){return{localeError:JJ()}}var JJ=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},o={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ugyldigt input: forventede instanceof ${n.expected}, fik ${a}`;return`Ugyldigt input: forventede ${i}, fik ${a}`}case"invalid_value":if(n.values.length===1)return`Ugyldig v\xE6rdi: forventede ${ce(n.values[0])}`;return`Ugyldigt valg: forventede en af f\xF8lgende ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`For stor: forventede ${a??"value"} ${s.verb} ${i} ${n.maximum.toString()} ${s.unit??"elementer"}`;return`For stor: forventede ${a??"value"} havde ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`For lille: forventede ${a} ${s.verb} ${i} ${n.minimum.toString()} ${s.unit}`;return`For lille: forventede ${a} havde ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ugyldig streng: skal starte med "${i.prefix}"`;if(i.format==="ends_with")return`Ugyldig streng: skal ende med "${i.suffix}"`;if(i.format==="includes")return`Ugyldig streng: skal indeholde "${i.includes}"`;if(i.format==="regex")return`Ugyldig streng: skal matche m\xF8nsteret ${i.pattern}`;return`Ugyldig ${r[i.format]??n.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${n.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${n.origin}`;default:return"Ugyldigt input"}}};var o1=w(()=>{Ee()});function cw(){return{localeError:KJ()}}var KJ=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(n){return e[n]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},o={nan:"NaN",number:"Zahl",array:"Array"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ung\xFCltige Eingabe: erwartet instanceof ${n.expected}, erhalten ${a}`;return`Ung\xFCltige Eingabe: erwartet ${i}, erhalten ${a}`}case"invalid_value":if(n.values.length===1)return`Ung\xFCltige Eingabe: erwartet ${ce(n.values[0])}`;return`Ung\xFCltige Option: erwartet eine von ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ${s.unit??"Elemente"} hat`;return`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ist`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ${s.unit} hat`;return`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ist`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ung\xFCltiger String: muss mit "${i.prefix}" beginnen`;if(i.format==="ends_with")return`Ung\xFCltiger String: muss mit "${i.suffix}" enden`;if(i.format==="includes")return`Ung\xFCltiger String: muss "${i.includes}" enthalten`;if(i.format==="regex")return`Ung\xFCltiger String: muss dem Muster ${i.pattern} entsprechen`;return`Ung\xFCltig: ${r[i.format]??n.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${n.divisor} sein`;case"unrecognized_keys":return`${n.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${n.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${n.origin}`;default:return"Ung\xFCltige Eingabe"}}};var i1=w(()=>{Ee()});function lw(){return{localeError:HJ()}}var HJ=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(n){return e[n]??null}let r={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(typeof n.expected==="string"&&/^[A-Z]/.test(n.expected))return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${n.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`;return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`}case"invalid_value":if(n.values.length===1)return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${ce(n.values[0])}`;return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${i}${n.maximum.toString()} ${s.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`;return`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${i}${n.minimum.toString()} ${s.unit}`;return`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${i.prefix}"`;if(i.format==="ends_with")return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${i.suffix}"`;if(i.format==="includes")return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${i.includes}"`;if(i.format==="regex")return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${i.pattern}`;return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[i.format]??n.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${n.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${n.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${n.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${n.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${n.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};var s1=w(()=>{Ee()});function Wl(){return{localeError:VJ()}}var VJ=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${ce(n.values[0])}`;return`Invalid option: expected one of ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${s.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${s.unit}`;return`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0)return`Invalid discriminator value. Expected ${n.options.map((s)=>`'${s}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};var uw=w(()=>{Ee()});function dw(){return{localeError:WJ()}}var WJ=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(n){return e[n]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},o={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Nevalida enigo: atendi\u011Dis instanceof ${n.expected}, ricevi\u011Dis ${a}`;return`Nevalida enigo: atendi\u011Dis ${i}, ricevi\u011Dis ${a}`}case"invalid_value":if(n.values.length===1)return`Nevalida enigo: atendi\u011Dis ${ce(n.values[0])}`;return`Nevalida opcio: atendi\u011Dis unu el ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${i}${n.maximum.toString()} ${s.unit??"elementojn"}`;return`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Tro malgranda: atendi\u011Dis ke ${n.origin} havu ${i}${n.minimum.toString()} ${s.unit}`;return`Tro malgranda: atendi\u011Dis ke ${n.origin} estu ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Nevalida karaktraro: devas komenci\u011Di per "${i.prefix}"`;if(i.format==="ends_with")return`Nevalida karaktraro: devas fini\u011Di per "${i.suffix}"`;if(i.format==="includes")return`Nevalida karaktraro: devas inkluzivi "${i.includes}"`;if(i.format==="regex")return`Nevalida karaktraro: devas kongrui kun la modelo ${i.pattern}`;return`Nevalida ${r[i.format]??n.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${n.divisor}`;case"unrecognized_keys":return`Nekonata${n.keys.length>1?"j":""} \u015Dlosilo${n.keys.length>1?"j":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${n.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${n.origin}`;default:return"Nevalida enigo"}}};var a1=w(()=>{Ee()});function fw(){return{localeError:GJ()}}var GJ=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},o={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Entrada inv\xE1lida: se esperaba instanceof ${n.expected}, recibido ${a}`;return`Entrada inv\xE1lida: se esperaba ${i}, recibido ${a}`}case"invalid_value":if(n.values.length===1)return`Entrada inv\xE1lida: se esperaba ${ce(n.values[0])}`;return`Opci\xF3n inv\xE1lida: se esperaba una de ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`Demasiado grande: se esperaba que ${a??"valor"} tuviera ${i}${n.maximum.toString()} ${s.unit??"elementos"}`;return`Demasiado grande: se esperaba que ${a??"valor"} fuera ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`Demasiado peque\xF1o: se esperaba que ${a} tuviera ${i}${n.minimum.toString()} ${s.unit}`;return`Demasiado peque\xF1o: se esperaba que ${a} fuera ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Cadena inv\xE1lida: debe comenzar con "${i.prefix}"`;if(i.format==="ends_with")return`Cadena inv\xE1lida: debe terminar en "${i.suffix}"`;if(i.format==="includes")return`Cadena inv\xE1lida: debe incluir "${i.includes}"`;if(i.format==="regex")return`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${i.pattern}`;return`Inv\xE1lido ${r[i.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Llave${n.keys.length>1?"s":""} desconocida${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${o[n.origin]??n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${o[n.origin]??n.origin}`;default:return"Entrada inv\xE1lida"}}};var c1=w(()=>{Ee()});function pw(){return{localeError:QJ()}}var QJ=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},o={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${n.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`;return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${i} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":if(n.values.length===1)return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${ce(n.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`;return`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${Q(n.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} ${s.unit} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${i.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`;if(i.format==="ends_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${i.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`;if(i.format==="includes")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${i.includes}" \u0628\u0627\u0634\u062F`;if(i.format==="regex")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${i.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`;return`${r[i.format]??n.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${n.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${n.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${Q(n.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${n.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${n.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};var l1=w(()=>{Ee()});function mw(){return{localeError:YJ()}}var YJ=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(n){return e[n]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Virheellinen tyyppi: odotettiin instanceof ${n.expected}, oli ${a}`;return`Virheellinen tyyppi: odotettiin ${i}, oli ${a}`}case"invalid_value":if(n.values.length===1)return`Virheellinen sy\xF6te: t\xE4ytyy olla ${ce(n.values[0])}`;return`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Liian suuri: ${s.subject} t\xE4ytyy olla ${i}${n.maximum.toString()} ${s.unit}`.trim();return`Liian suuri: arvon t\xE4ytyy olla ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Liian pieni: ${s.subject} t\xE4ytyy olla ${i}${n.minimum.toString()} ${s.unit}`.trim();return`Liian pieni: arvon t\xE4ytyy olla ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${i.prefix}"`;if(i.format==="ends_with")return`Virheellinen sy\xF6te: t\xE4ytyy loppua "${i.suffix}"`;if(i.format==="includes")return`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${i.includes}"`;if(i.format==="regex")return`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${i.pattern}`;return`Virheellinen ${r[i.format]??n.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${n.divisor} monikerta`;case"unrecognized_keys":return`${n.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${Q(n.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};var u1=w(()=>{Ee()});function hw(){return{localeError:XJ()}}var XJ=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},o={string:"cha\xEEne",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"enregistrement",map:"carte",set:"ensemble",file:"fichier",nonoptional:"non-optionnel",nan:"NaN",function:"fonction"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Entr\xE9e invalide : instanceof ${n.expected} attendu, ${a} re\xE7u`;return`Entr\xE9e invalide : ${i} attendu, ${a} re\xE7u`}case"invalid_value":if(n.values.length===1)return`Entr\xE9e invalide : ${ce(n.values[0])} attendu`;return`Option invalide : une valeur parmi ${Q(n.values,"|")} attendue`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Trop grand : ${o[n.origin]??"valeur"} doit ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"\xE9l\xE9ment(s)"}`;return`Trop grand : ${o[n.origin]??"valeur"} doit \xEAtre ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Trop petit : ${o[n.origin]??"valeur"} doit ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`Trop petit : ${o[n.origin]??"valeur"} doit \xEAtre ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${i.prefix}"`;if(i.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${i.suffix}"`;if(i.format==="includes")return`Cha\xEEne invalide : doit inclure "${i.includes}"`;if(i.format==="regex")return`Cha\xEEne invalide : doit correspondre au mod\xE8le ${i.pattern}`;return`${r[i.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${Q(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};var d1=w(()=>{Ee()});function gw(){return{localeError:eK()}}var eK=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Entr\xE9e invalide : attendu instanceof ${n.expected}, re\xE7u ${a}`;return`Entr\xE9e invalide : attendu ${i}, re\xE7u ${a}`}case"invalid_value":if(n.values.length===1)return`Entr\xE9e invalide : attendu ${ce(n.values[0])}`;return`Option invalide : attendu l'une des valeurs suivantes ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"\u2264":"<",s=t(n.origin);if(s)return`Trop grand : attendu que ${n.origin??"la valeur"} ait ${i}${n.maximum.toString()} ${s.unit}`;return`Trop grand : attendu que ${n.origin??"la valeur"} soit ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?"\u2265":">",s=t(n.origin);if(s)return`Trop petit : attendu que ${n.origin} ait ${i}${n.minimum.toString()} ${s.unit}`;return`Trop petit : attendu que ${n.origin} soit ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${i.prefix}"`;if(i.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${i.suffix}"`;if(i.format==="includes")return`Cha\xEEne invalide : doit inclure "${i.includes}"`;if(i.format==="regex")return`Cha\xEEne invalide : doit correspondre au motif ${i.pattern}`;return`${r[i.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${Q(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};var f1=w(()=>{Ee()});function yw(){return{localeError:tK()}}var tK=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=(u)=>u?e[u]:void 0,o=(u)=>{let d=r(u);if(d)return d.label;return u??e.unknown.label},n=(u)=>`\u05D4${o(u)}`,i=(u)=>(r(u)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",s=(u)=>{if(!u)return null;return t[u]??null},a={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return(u)=>{switch(u.code){case"invalid_type":{let d=u.expected,f=c[d??""]??o(d),m=le(u.input),h=c[m]??e[m]?.label??m;if(/^[A-Z]/.test(u.expected))return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${u.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${h}`;return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${f}, \u05D4\u05EA\u05E7\u05D1\u05DC ${h}`}case"invalid_value":{if(u.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${ce(u.values[0])}`;let d=u.values.map((h)=>ce(h));if(u.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${d[0]} \u05D0\u05D5 ${d[1]}`;let f=d[d.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${d.slice(0,-1).join(", ")} \u05D0\u05D5 ${f}`}case"too_big":{let d=s(u.origin),f=n(u.origin??"value");if(u.origin==="string")return`${d?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.maximum.toString()} ${d?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(u.origin==="number"){let b=u.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${u.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${b}`}if(u.origin==="array"||u.origin==="set"){let b=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",y=u.inclusive?`${u.maximum} ${d?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${u.maximum} ${d?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${f} ${b} \u05DC\u05D4\u05DB\u05D9\u05DC ${y}`.trim()}let m=u.inclusive?"<=":"<",h=i(u.origin??"value");if(d?.unit)return`${d.longLabel} \u05DE\u05D3\u05D9: ${f} ${h} ${m}${u.maximum.toString()} ${d.unit}`;return`${d?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${f} ${h} ${m}${u.maximum.toString()}`}case"too_small":{let d=s(u.origin),f=n(u.origin??"value");if(u.origin==="string")return`${d?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.minimum.toString()} ${d?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(u.origin==="number"){let b=u.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${u.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${b}`}if(u.origin==="array"||u.origin==="set"){let b=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(u.minimum===1&&u.inclusive){let S=u.origin==="set"?"\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3":"\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3";return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} ${b} \u05DC\u05D4\u05DB\u05D9\u05DC ${S}`}let y=u.inclusive?`${u.minimum} ${d?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${u.minimum} ${d?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} ${b} \u05DC\u05D4\u05DB\u05D9\u05DC ${y}`.trim()}let m=u.inclusive?">=":">",h=i(u.origin??"value");if(d?.unit)return`${d.shortLabel} \u05DE\u05D3\u05D9: ${f} ${h} ${m}${u.minimum.toString()} ${d.unit}`;return`${d?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${f} ${h} ${m}${u.minimum.toString()}`}case"invalid_format":{let d=u;if(d.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${d.prefix}"`;if(d.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${d.suffix}"`;if(d.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${d.includes}"`;if(d.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${d.pattern}`;let f=a[d.format],m=f?.label??d.format,b=(f?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${m} \u05DC\u05D0 ${b}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${u.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${u.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${u.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${Q(u.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${n(u.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};var p1=w(()=>{Ee()});function bw(){return{localeError:rK()}}var rK=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(n){return e[n]??null}let r={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",jwt:"JWT",template_literal:"unos"},o={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Neispravan unos: o\u010Dekuje se instanceof ${n.expected}, a primljeno je ${a}`;return`Neispravan unos: o\u010Dekuje se ${i}, a primljeno je ${a}`}case"invalid_value":if(n.values.length===1)return`Neispravna vrijednost: o\u010Dekivano ${ce(n.values[0])}`;return`Neispravna opcija: o\u010Dekivano jedno od ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`Preveliko: o\u010Dekivano da ${a??"vrijednost"} ima ${i}${n.maximum.toString()} ${s.unit??"elemenata"}`;return`Preveliko: o\u010Dekivano da ${a??"vrijednost"} bude ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`Premalo: o\u010Dekivano da ${a} ima ${i}${n.minimum.toString()} ${s.unit}`;return`Premalo: o\u010Dekivano da ${a} bude ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Neispravan tekst: mora zapo\u010Dinjati s "${i.prefix}"`;if(i.format==="ends_with")return`Neispravan tekst: mora zavr\u0161avati s "${i.suffix}"`;if(i.format==="includes")return`Neispravan tekst: mora sadr\u017Eavati "${i.includes}"`;if(i.format==="regex")return`Neispravan tekst: mora odgovarati uzorku ${i.pattern}`;return`Neispravna ${r[i.format]??n.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${n.divisor}`;case"unrecognized_keys":return`Neprepoznat${n.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${o[n.origin]??n.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${o[n.origin]??n.origin}`;default:return"Neispravan unos"}}};var m1=w(()=>{Ee()});function Sw(){return{localeError:nK()}}var nK=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(n){return e[n]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},o={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${n.expected}, a kapott \xE9rt\xE9k ${a}`;return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${i}, a kapott \xE9rt\xE9k ${a}`}case"invalid_value":if(n.values.length===1)return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${ce(n.values[0])}`;return`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`T\xFAl nagy: ${n.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${i}${n.maximum.toString()} ${s.unit??"elem"}`;return`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${n.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} m\xE9rete t\xFAl kicsi ${i}${n.minimum.toString()} ${s.unit}`;return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} t\xFAl kicsi ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\xC9rv\xE9nytelen string: "${i.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`;if(i.format==="ends_with")return`\xC9rv\xE9nytelen string: "${i.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`;if(i.format==="includes")return`\xC9rv\xE9nytelen string: "${i.includes}" \xE9rt\xE9ket kell tartalmaznia`;if(i.format==="regex")return`\xC9rv\xE9nytelen string: ${i.pattern} mint\xE1nak kell megfelelnie`;return`\xC9rv\xE9nytelen ${r[i.format]??n.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${n.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${n.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${n.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};var h1=w(()=>{Ee()});function g1(e,t,r){return Math.abs(e)===1?t:r}function Aa(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=e[e.length-1];return e+(t.includes(r)?"\u0576":"\u0568")}function vw(){return{localeError:oK()}}var oK=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(n){return e[n]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},o={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${n.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`;return`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${i}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`}case"invalid_value":if(n.values.length===1)return`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${ce(n.values[1])}`;return`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s){let a=Number(n.maximum),c=g1(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Aa(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${i}${n.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Aa(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s){let a=Number(n.minimum),c=g1(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Aa(n.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${i}${n.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Aa(n.origin)} \u056C\u056B\u0576\u056B ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${i.prefix}"-\u0578\u057E`;if(i.format==="ends_with")return`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${i.suffix}"-\u0578\u057E`;if(i.format==="includes")return`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${i.includes}"`;if(i.format==="regex")return`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${i.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`;return`\u054D\u056D\u0561\u056C ${r[i.format]??n.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${n.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${n.keys.length>1?"\u0576\u0565\u0580":""}. ${Q(n.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${Aa(n.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${Aa(n.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};var y1=w(()=>{Ee()});function ww(){return{localeError:iK()}}var iK=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Input tidak valid: diharapkan instanceof ${n.expected}, diterima ${a}`;return`Input tidak valid: diharapkan ${i}, diterima ${a}`}case"invalid_value":if(n.values.length===1)return`Input tidak valid: diharapkan ${ce(n.values[0])}`;return`Pilihan tidak valid: diharapkan salah satu dari ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Terlalu besar: diharapkan ${n.origin??"value"} memiliki ${i}${n.maximum.toString()} ${s.unit??"elemen"}`;return`Terlalu besar: diharapkan ${n.origin??"value"} menjadi ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Terlalu kecil: diharapkan ${n.origin} memiliki ${i}${n.minimum.toString()} ${s.unit}`;return`Terlalu kecil: diharapkan ${n.origin} menjadi ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`String tidak valid: harus dimulai dengan "${i.prefix}"`;if(i.format==="ends_with")return`String tidak valid: harus berakhir dengan "${i.suffix}"`;if(i.format==="includes")return`String tidak valid: harus menyertakan "${i.includes}"`;if(i.format==="regex")return`String tidak valid: harus sesuai pola ${i.pattern}`;return`${r[i.format]??n.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${n.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${n.origin}`;default:return"Input tidak valid"}}};var b1=w(()=>{Ee()});function xw(){return{localeError:sK()}}var sK=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(n){return e[n]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},o={nan:"NaN",number:"n\xFAmer",array:"fylki"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera instanceof ${n.expected}`;return`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera ${i}`}case"invalid_value":if(n.values.length===1)return`Rangt gildi: gert r\xE1\xF0 fyrir ${ce(n.values[0])}`;return`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} hafi ${i}${n.maximum.toString()} ${s.unit??"hluti"}`;return`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} s\xE9 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} hafi ${i}${n.minimum.toString()} ${s.unit}`;return`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} s\xE9 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${i.prefix}"`;if(i.format==="ends_with")return`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${i.suffix}"`;if(i.format==="includes")return`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${i.includes}"`;if(i.format==="regex")return`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${i.pattern}`;return`Rangt ${r[i.format]??n.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${n.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${n.keys.length>1?"ir lyklar":"ur lykill"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${n.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${n.origin}`;default:return"Rangt gildi"}}};var S1=w(()=>{Ee()});function _w(){return{localeError:aK()}}var aK=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(n){return e[n]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"numero",array:"vettore"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Input non valido: atteso instanceof ${n.expected}, ricevuto ${a}`;return`Input non valido: atteso ${i}, ricevuto ${a}`}case"invalid_value":if(n.values.length===1)return`Input non valido: atteso ${ce(n.values[0])}`;return`Opzione non valida: atteso uno tra ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Troppo grande: ${n.origin??"valore"} deve avere ${i}${n.maximum.toString()} ${s.unit??"elementi"}`;return`Troppo grande: ${n.origin??"valore"} deve essere ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Troppo piccolo: ${n.origin} deve avere ${i}${n.minimum.toString()} ${s.unit}`;return`Troppo piccolo: ${n.origin} deve essere ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Stringa non valida: deve iniziare con "${i.prefix}"`;if(i.format==="ends_with")return`Stringa non valida: deve terminare con "${i.suffix}"`;if(i.format==="includes")return`Stringa non valida: deve includere "${i.includes}"`;if(i.format==="regex")return`Stringa non valida: deve corrispondere al pattern ${i.pattern}`;return`Input non valido: ${r[i.format]??n.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${n.divisor}`;case"unrecognized_keys":return`Chiav${n.keys.length>1?"i":"e"} non riconosciut${n.keys.length>1?"e":"a"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${n.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${n.origin}`;default:return"Input non valido"}}};var v1=w(()=>{Ee()});function Ew(){return{localeError:cK()}}var cK=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(n){return e[n]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},o={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u7121\u52B9\u306A\u5165\u529B: instanceof ${n.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`;return`\u7121\u52B9\u306A\u5165\u529B: ${i}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":if(n.values.length===1)return`\u7121\u52B9\u306A\u5165\u529B: ${ce(n.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`;return`\u7121\u52B9\u306A\u9078\u629E: ${Q(n.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let i=n.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",s=t(n.origin);if(s)return`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${s.unit??"\u8981\u7D20"}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let i=n.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",s=t(n.origin);if(s)return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${s.unit}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(i.format==="ends_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(i.format==="includes")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(i.format==="regex")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${i.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u7121\u52B9\u306A${r[i.format]??n.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${n.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${n.keys.length>1?"\u7FA4":""}: ${Q(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};var w1=w(()=>{Ee()});function Iw(){return{localeError:lK()}}var lK=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(n){return e[n]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},o={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${n.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`;return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`}case"invalid_value":if(n.values.length===1)return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${ce(n.values[0])}`;return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${Q(n.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit}`;return`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} \u10D8\u10E7\u10DD\u10E1 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${i.prefix}"-\u10D8\u10D7`;if(i.format==="ends_with")return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${i.suffix}"-\u10D8\u10D7`;if(i.format==="includes")return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${i.includes}"-\u10E1`;if(i.format==="regex")return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${i.pattern}`;return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${n.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${n.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${n.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${n.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};var x1=w(()=>{Ee()});function Gl(){return{localeError:uK()}}var uK=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(n){return e[n]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},o={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${n.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`;return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`}case"invalid_value":if(n.values.length===1)return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${ce(n.values[0])}`;return`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${i} ${n.maximum.toString()} ${s.unit??"\u1792\u17B6\u178F\u17BB"}`;return`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${i} ${n.minimum.toString()} ${s.unit}`;return`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${i.prefix}"`;if(i.format==="ends_with")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${i.suffix}"`;if(i.format==="includes")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${i.includes}"`;if(i.format==="regex")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${i.pattern}`;return`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${n.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${Q(n.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};var kw=w(()=>{Ee()});function Aw(){return Gl()}var _1=w(()=>{kw()});function Tw(){return{localeError:dK()}}var dK=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${n.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${i}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`}case"invalid_value":if(n.values.length===1)return`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${ce(n.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C \uC635\uC158: ${Q(n.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let i=n.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",s=i==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(n.origin),c=a?.unit??"\uC694\uC18C";if(a)return`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()}${c} ${i}${s}`;return`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()} ${i}${s}`}case"too_small":{let i=n.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",s=i==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(n.origin),c=a?.unit??"\uC694\uC18C";if(a)return`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()}${c} ${i}${s}`;return`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()} ${i}${s}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`;if(i.format==="ends_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`;if(i.format==="includes")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`;if(i.format==="regex")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${i.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C ${r[i.format]??n.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${n.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${Q(n.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${n.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${n.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};var E1=w(()=>{Ee()});function I1(e){let t=Math.abs(e),r=t%10,o=t%100;if(o>=11&&o<=19||r===0)return"many";if(r===1)return"one";return"few"}function $w(){return{localeError:fK()}}var Ql=(e)=>e.charAt(0).toUpperCase()+e.slice(1),fK=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(n,i,s,a){let c=e[n]??null;if(c===null)return c;return{unit:c.unit[i],verb:c.verb[a][s?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},o={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Gautas tipas ${a}, o tik\u0117tasi - instanceof ${n.expected}`;return`Gautas tipas ${a}, o tik\u0117tasi - ${i}`}case"invalid_value":if(n.values.length===1)return`Privalo b\u016Bti ${ce(n.values[0])}`;return`Privalo b\u016Bti vienas i\u0161 ${Q(n.values,"|")} pasirinkim\u0173`;case"too_big":{let i=o[n.origin]??n.origin,s=t(n.origin,I1(Number(n.maximum)),n.inclusive??!1,"smaller");if(s?.verb)return`${Ql(i??n.origin??"reik\u0161m\u0117")} ${s.verb} ${n.maximum.toString()} ${s.unit??"element\u0173"}`;let a=n.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${Ql(i??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${n.maximum.toString()} ${s?.unit}`}case"too_small":{let i=o[n.origin]??n.origin,s=t(n.origin,I1(Number(n.minimum)),n.inclusive??!1,"bigger");if(s?.verb)return`${Ql(i??n.origin??"reik\u0161m\u0117")} ${s.verb} ${n.minimum.toString()} ${s.unit??"element\u0173"}`;let a=n.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${Ql(i??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${n.minimum.toString()} ${s?.unit}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Eilut\u0117 privalo prasid\u0117ti "${i.prefix}"`;if(i.format==="ends_with")return`Eilut\u0117 privalo pasibaigti "${i.suffix}"`;if(i.format==="includes")return`Eilut\u0117 privalo \u012Ftraukti "${i.includes}"`;if(i.format==="regex")return`Eilut\u0117 privalo atitikti ${i.pattern}`;return`Neteisingas ${r[i.format]??n.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${n.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${n.keys.length>1?"i":"as"} rakt${n.keys.length>1?"ai":"as"}: ${Q(n.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let i=o[n.origin]??n.origin;return`${Ql(i??n.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};var k1=w(()=>{Ee()});function Rw(){return{localeError:pK()}}var pK=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(n){return e[n]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},o={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${n.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`;return`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${ce(n.values[0])}`;return`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${i}${n.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`;return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0438\u043C\u0430 ${i}${n.minimum.toString()} ${s.unit}`;return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${i.suffix}"`;if(i.format==="includes")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${i.includes}"`;if(i.format==="regex")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${i.pattern}`;return`Invalid ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${n.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${n.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};var A1=w(()=>{Ee()});function Ow(){return{localeError:mK()}}var mK=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"nombor"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Input tidak sah: dijangka instanceof ${n.expected}, diterima ${a}`;return`Input tidak sah: dijangka ${i}, diterima ${a}`}case"invalid_value":if(n.values.length===1)return`Input tidak sah: dijangka ${ce(n.values[0])}`;return`Pilihan tidak sah: dijangka salah satu daripada ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Terlalu besar: dijangka ${n.origin??"nilai"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"elemen"}`;return`Terlalu besar: dijangka ${n.origin??"nilai"} adalah ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Terlalu kecil: dijangka ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`Terlalu kecil: dijangka ${n.origin} adalah ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`String tidak sah: mesti bermula dengan "${i.prefix}"`;if(i.format==="ends_with")return`String tidak sah: mesti berakhir dengan "${i.suffix}"`;if(i.format==="includes")return`String tidak sah: mesti mengandungi "${i.includes}"`;if(i.format==="regex")return`String tidak sah: mesti sepadan dengan corak ${i.pattern}`;return`${r[i.format]??n.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${Q(n.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${n.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${n.origin}`;default:return"Input tidak sah"}}};var T1=w(()=>{Ee()});function Cw(){return{localeError:hK()}}var hK=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(n){return e[n]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},o={nan:"NaN",number:"getal"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ongeldige invoer: verwacht instanceof ${n.expected}, ontving ${a}`;return`Ongeldige invoer: verwacht ${i}, ontving ${a}`}case"invalid_value":if(n.values.length===1)return`Ongeldige invoer: verwacht ${ce(n.values[0])}`;return`Ongeldige optie: verwacht \xE9\xE9n van ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=n.origin==="date"?"laat":n.origin==="string"?"lang":"groot";if(s)return`Te ${a}: verwacht dat ${n.origin??"waarde"} ${i}${n.maximum.toString()} ${s.unit??"elementen"} ${s.verb}`;return`Te ${a}: verwacht dat ${n.origin??"waarde"} ${i}${n.maximum.toString()} is`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=n.origin==="date"?"vroeg":n.origin==="string"?"kort":"klein";if(s)return`Te ${a}: verwacht dat ${n.origin} ${i}${n.minimum.toString()} ${s.unit} ${s.verb}`;return`Te ${a}: verwacht dat ${n.origin} ${i}${n.minimum.toString()} is`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ongeldige tekst: moet met "${i.prefix}" beginnen`;if(i.format==="ends_with")return`Ongeldige tekst: moet op "${i.suffix}" eindigen`;if(i.format==="includes")return`Ongeldige tekst: moet "${i.includes}" bevatten`;if(i.format==="regex")return`Ongeldige tekst: moet overeenkomen met patroon ${i.pattern}`;return`Ongeldig: ${r[i.format]??n.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${n.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${n.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${n.origin}`;default:return"Ongeldige invoer"}}};var $1=w(()=>{Ee()});function Pw(){return{localeError:gK()}}var gK=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"tall",array:"liste"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ugyldig input: forventet instanceof ${n.expected}, fikk ${a}`;return`Ugyldig input: forventet ${i}, fikk ${a}`}case"invalid_value":if(n.values.length===1)return`Ugyldig verdi: forventet ${ce(n.values[0])}`;return`Ugyldig valg: forventet en av ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${i}${n.maximum.toString()} ${s.unit??"elementer"}`;return`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`For lite(n): forventet ${n.origin} til \xE5 ha ${i}${n.minimum.toString()} ${s.unit}`;return`For lite(n): forventet ${n.origin} til \xE5 ha ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ugyldig streng: m\xE5 starte med "${i.prefix}"`;if(i.format==="ends_with")return`Ugyldig streng: m\xE5 ende med "${i.suffix}"`;if(i.format==="includes")return`Ugyldig streng: m\xE5 inneholde "${i.includes}"`;if(i.format==="regex")return`Ugyldig streng: m\xE5 matche m\xF8nsteret ${i.pattern}`;return`Ugyldig ${r[i.format]??n.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};var R1=w(()=>{Ee()});function zw(){return{localeError:yK()}}var yK=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},o={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`F\xE2sit giren: umulan instanceof ${n.expected}, al\u0131nan ${a}`;return`F\xE2sit giren: umulan ${i}, al\u0131nan ${a}`}case"invalid_value":if(n.values.length===1)return`F\xE2sit giren: umulan ${ce(n.values[0])}`;return`F\xE2sit tercih: m\xFBteberler ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${i}${n.maximum.toString()} ${s.unit??"elements"} sahip olmal\u0131yd\u0131.`;return`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${i}${n.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${i}${n.minimum.toString()} ${s.unit} sahip olmal\u0131yd\u0131.`;return`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${i}${n.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`F\xE2sit metin: "${i.prefix}" ile ba\u015Flamal\u0131.`;if(i.format==="ends_with")return`F\xE2sit metin: "${i.suffix}" ile bitmeli.`;if(i.format==="includes")return`F\xE2sit metin: "${i.includes}" ihtiv\xE2 etmeli.`;if(i.format==="regex")return`F\xE2sit metin: ${i.pattern} nak\u015F\u0131na uymal\u0131.`;return`F\xE2sit ${r[i.format]??n.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${n.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${n.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};var O1=w(()=>{Ee()});function Nw(){return{localeError:bK()}}var bK=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},o={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${n.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`;return`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${i} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":if(n.values.length===1)return`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${ce(n.values[0])} \u0648\u0627\u06CC`;return`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${Q(n.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`;return`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} \u0648\u064A`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} ${s.unit} \u0648\u0644\u0631\u064A`;return`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} \u0648\u064A`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${i.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`;if(i.format==="ends_with")return`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${i.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`;if(i.format==="includes")return`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${i.includes}" \u0648\u0644\u0631\u064A`;if(i.format==="regex")return`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${i.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`;return`${r[i.format]??n.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${n.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${n.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${n.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${n.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};var C1=w(()=>{Ee()});function Dw(){return{localeError:SK()}}var SK=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(n){return e[n]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},o={nan:"NaN",number:"liczba",array:"tablica"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${n.expected}, otrzymano ${a}`;return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${i}, otrzymano ${a}`}case"invalid_value":if(n.values.length===1)return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${ce(n.values[0])}`;return`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${i}${n.maximum.toString()} ${s.unit??"element\xF3w"}`;return`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${i}${n.minimum.toString()} ${s.unit??"element\xF3w"}`;return`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${i.prefix}"`;if(i.format==="ends_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${i.suffix}"`;if(i.format==="includes")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${i.includes}"`;if(i.format==="regex")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${i.pattern}`;return`Nieprawid\u0142ow(y/a/e) ${r[i.format]??n.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${n.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${n.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${n.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};var P1=w(()=>{Ee()});function Lw(){return{localeError:vK()}}var vK=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(n){return e[n]??null}let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},o={nan:"NaN",number:"n\xFAmero",null:"nulo"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Tipo inv\xE1lido: esperado instanceof ${n.expected}, recebido ${a}`;return`Tipo inv\xE1lido: esperado ${i}, recebido ${a}`}case"invalid_value":if(n.values.length===1)return`Entrada inv\xE1lida: esperado ${ce(n.values[0])}`;return`Op\xE7\xE3o inv\xE1lida: esperada uma das ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Muito grande: esperado que ${n.origin??"valor"} tivesse ${i}${n.maximum.toString()} ${s.unit??"elementos"}`;return`Muito grande: esperado que ${n.origin??"valor"} fosse ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Muito pequeno: esperado que ${n.origin} tivesse ${i}${n.minimum.toString()} ${s.unit}`;return`Muito pequeno: esperado que ${n.origin} fosse ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Texto inv\xE1lido: deve come\xE7ar com "${i.prefix}"`;if(i.format==="ends_with")return`Texto inv\xE1lido: deve terminar com "${i.suffix}"`;if(i.format==="includes")return`Texto inv\xE1lido: deve incluir "${i.includes}"`;if(i.format==="regex")return`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${i.pattern}`;return`${r[i.format]??n.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Chave${n.keys.length>1?"s":""} desconhecida${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${n.origin}`;default:return"Campo inv\xE1lido"}}};var z1=w(()=>{Ee()});function Bw(){return{localeError:wK()}}var wK=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(n){return e[n]??null}let r={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",jwt:"JWT",template_literal:"intrare"},o={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;return`Intrare invalid\u0103: a\u0219teptat ${i}, primit ${a}`}case"invalid_value":if(n.values.length===1)return`Intrare invalid\u0103: a\u0219teptat ${ce(n.values[0])}`;return`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"elemente"}`;return`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} s\u0103 fie ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Prea mic: a\u0219teptat ca ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`Prea mic: a\u0219teptat ca ${n.origin} s\u0103 fie ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${i.prefix}"`;if(i.format==="ends_with")return`\u0218ir invalid: trebuie s\u0103 se termine cu "${i.suffix}"`;if(i.format==="includes")return`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${i.includes}"`;if(i.format==="regex")return`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${i.pattern}`;return`Format invalid: ${r[i.format]??n.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${n.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${Q(n.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${n.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${n.origin}`;default:return"Intrare invalid\u0103"}}};var N1=w(()=>{Ee()});function D1(e,t,r,o){let n=Math.abs(e),i=n%10,s=n%100;if(s>=11&&s<=19)return o;if(i===1)return t;if(i>=2&&i<=4)return r;return o}function jw(){return{localeError:xK()}}var xK=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},o={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${i}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`}case"invalid_value":if(n.values.length===1)return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${ce(n.values[0])}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s){let a=Number(n.maximum),c=D1(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${i}${n.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s){let a=Number(n.minimum),c=D1(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${i}${n.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${i.suffix}"`;if(i.format==="includes")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${i.includes}"`;if(i.format==="regex")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${n.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0438":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};var L1=w(()=>{Ee()});function Zw(){return{localeError:_K()}}var _K=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(n){return e[n]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},o={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Neveljaven vnos: pri\u010Dakovano instanceof ${n.expected}, prejeto ${a}`;return`Neveljaven vnos: pri\u010Dakovano ${i}, prejeto ${a}`}case"invalid_value":if(n.values.length===1)return`Neveljaven vnos: pri\u010Dakovano ${ce(n.values[0])}`;return`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} imelo ${i}${n.maximum.toString()} ${s.unit??"elementov"}`;return`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Premajhno: pri\u010Dakovano, da bo ${n.origin} imelo ${i}${n.minimum.toString()} ${s.unit}`;return`Premajhno: pri\u010Dakovano, da bo ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Neveljaven niz: mora se za\u010Deti z "${i.prefix}"`;if(i.format==="ends_with")return`Neveljaven niz: mora se kon\u010Dati z "${i.suffix}"`;if(i.format==="includes")return`Neveljaven niz: mora vsebovati "${i.includes}"`;if(i.format==="regex")return`Neveljaven niz: mora ustrezati vzorcu ${i.pattern}`;return`Neveljaven ${r[i.format]??n.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${n.divisor}`;case"unrecognized_keys":return`Neprepoznan${n.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${n.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${n.origin}`;default:return"Neveljaven vnos"}}};var B1=w(()=>{Ee()});function Uw(){return{localeError:EK()}}var EK=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(n){return e[n]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},o={nan:"NaN",number:"antal",array:"lista"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${n.expected}, fick ${a}`;return`Ogiltig inmatning: f\xF6rv\xE4ntat ${i}, fick ${a}`}case"invalid_value":if(n.values.length===1)return`Ogiltig inmatning: f\xF6rv\xE4ntat ${ce(n.values[0])}`;return`Ogiltigt val: f\xF6rv\xE4ntade en av ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`F\xF6r stor(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${i}${n.maximum.toString()} ${s.unit??"element"}`;return`F\xF6r stor(t): f\xF6rv\xE4ntat ${n.origin??"v\xE4rdet"} att ha ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${i}${n.minimum.toString()} ${s.unit}`;return`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${i.prefix}"`;if(i.format==="ends_with")return`Ogiltig str\xE4ng: m\xE5ste sluta med "${i.suffix}"`;if(i.format==="includes")return`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${i.includes}"`;if(i.format==="regex")return`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${i.pattern}"`;return`Ogiltig(t) ${r[i.format]??n.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${n.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${n.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};var j1=w(()=>{Ee()});function qw(){return{localeError:IK()}}var IK=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(n){return e[n]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${n.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`;return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`}case"invalid_value":if(n.values.length===1)return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${ce(n.values[0])}`;return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${Q(n.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${i}${n.maximum.toString()} ${s.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${i}${n.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${i}${n.minimum.toString()} ${s.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${i}${n.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(i.format==="ends_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(i.format==="includes")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(i.format==="regex")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${i.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${n.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${n.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};var Z1=w(()=>{Ee()});function Mw(){return{localeError:kK()}}var kK=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(n){return e[n]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},o={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${n.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`;return`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${i} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`}case"invalid_value":if(n.values.length===1)return`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${ce(n.values[0])}`;return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",s=t(n.origin);if(s)return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.maximum.toString()} ${s.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`;return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",s=t(n.origin);if(s)return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.minimum.toString()} ${s.unit}`;return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${i.prefix}"`;if(i.format==="ends_with")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${i.suffix}"`;if(i.format==="includes")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${i.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`;if(i.format==="regex")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${i.pattern}`;return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${n.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${Q(n.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};var U1=w(()=>{Ee()});function Fw(){return{localeError:AK()}}var AK=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(n){return e[n]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${n.expected}, al\u0131nan ${a}`;return`Ge\xE7ersiz de\u011Fer: beklenen ${i}, al\u0131nan ${a}`}case"invalid_value":if(n.values.length===1)return`Ge\xE7ersiz de\u011Fer: beklenen ${ce(n.values[0])}`;return`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${i}${n.maximum.toString()} ${s.unit??"\xF6\u011Fe"}`;return`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${i}${n.minimum.toString()} ${s.unit}`;return`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ge\xE7ersiz metin: "${i.prefix}" ile ba\u015Flamal\u0131`;if(i.format==="ends_with")return`Ge\xE7ersiz metin: "${i.suffix}" ile bitmeli`;if(i.format==="includes")return`Ge\xE7ersiz metin: "${i.includes}" i\xE7ermeli`;if(i.format==="regex")return`Ge\xE7ersiz metin: ${i.pattern} desenine uymal\u0131`;return`Ge\xE7ersiz ${r[i.format]??n.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${n.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${n.keys.length>1?"lar":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${n.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};var q1=w(()=>{Ee()});function Yl(){return{localeError:TK()}}var TK=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},o={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${n.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${i}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`}case"invalid_value":if(n.values.length===1)return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${ce(n.values[0])}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`;return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} \u0431\u0443\u0434\u0435 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${i.suffix}"`;if(i.format==="includes")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${i.includes}"`;if(i.format==="regex")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0456":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${n.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};var Jw=w(()=>{Ee()});function Kw(){return Yl()}var M1=w(()=>{Jw()});function Hw(){return{localeError:$K()}}var $K=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(n){return e[n]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},o={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${n.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`;return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${i} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":if(n.values.length===1)return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${ce(n.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;return`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${Q(n.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${i}${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`;return`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${i}${n.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u06D2 ${i}${n.minimum.toString()} ${s.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`;return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u0627 ${i}${n.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(i.format==="ends_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(i.format==="includes")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(i.format==="regex")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${i.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;return`\u063A\u0644\u0637 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${n.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${n.keys.length>1?"\u0632":""}: ${Q(n.keys,"\u060C ")}`;case"invalid_key":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};var F1=w(()=>{Ee()});function Vw(){return{localeError:RK()}}var RK=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(n){return e[n]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},o={nan:"NaN",number:"raqam",array:"massiv"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${n.expected}, qabul qilingan ${a}`;return`Noto\u2018g\u2018ri kirish: kutilgan ${i}, qabul qilingan ${a}`}case"invalid_value":if(n.values.length===1)return`Noto\u2018g\u2018ri kirish: kutilgan ${ce(n.values[0])}`;return`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Juda katta: kutilgan ${n.origin??"qiymat"} ${i}${n.maximum.toString()} ${s.unit} ${s.verb}`;return`Juda katta: kutilgan ${n.origin??"qiymat"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Juda kichik: kutilgan ${n.origin} ${i}${n.minimum.toString()} ${s.unit} ${s.verb}`;return`Juda kichik: kutilgan ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Noto\u2018g\u2018ri satr: "${i.prefix}" bilan boshlanishi kerak`;if(i.format==="ends_with")return`Noto\u2018g\u2018ri satr: "${i.suffix}" bilan tugashi kerak`;if(i.format==="includes")return`Noto\u2018g\u2018ri satr: "${i.includes}" ni o\u2018z ichiga olishi kerak`;if(i.format==="regex")return`Noto\u2018g\u2018ri satr: ${i.pattern} shabloniga mos kelishi kerak`;return`Noto\u2018g\u2018ri ${r[i.format]??n.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${n.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${n.keys.length>1?"lar":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${n.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};var J1=w(()=>{Ee()});function Ww(){return{localeError:OK()}}var OK=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(n){return e[n]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},o={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${n.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`;return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${i}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`}case"invalid_value":if(n.values.length===1)return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${ce(n.values[0])}`;return`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"ph\u1EA7n t\u1EED"}`;return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${i.prefix}"`;if(i.format==="ends_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${i.suffix}"`;if(i.format==="includes")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${i.includes}"`;if(i.format==="regex")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${i.pattern}`;return`${r[i.format]??n.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${n.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${Q(n.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};var K1=w(()=>{Ee()});function Gw(){return{localeError:CK()}}var CK=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(n){return e[n]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},o={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${n.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`;return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${i}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`}case"invalid_value":if(n.values.length===1)return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${ce(n.values[0])}`;return`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${i}${n.maximum.toString()} ${s.unit??"\u4E2A\u5143\u7D20"}`;return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${i}${n.minimum.toString()} ${s.unit}`;return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${i.prefix}" \u5F00\u5934`;if(i.format==="ends_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${i.suffix}" \u7ED3\u5C3E`;if(i.format==="includes")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${i.includes}"`;if(i.format==="regex")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${i.pattern}`;return`\u65E0\u6548${r[i.format]??n.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${n.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${n.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};var H1=w(()=>{Ee()});function Qw(){return{localeError:PK()}}var PK=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(n){return e[n]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${n.expected}\uFF0C\u4F46\u6536\u5230 ${a}`;return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${i}\uFF0C\u4F46\u6536\u5230 ${a}`}case"invalid_value":if(n.values.length===1)return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${ce(n.values[0])}`;return`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${i}${n.maximum.toString()} ${s.unit??"\u500B\u5143\u7D20"}`;return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${i}${n.minimum.toString()} ${s.unit}`;return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${i.prefix}" \u958B\u982D`;if(i.format==="ends_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${i.suffix}" \u7D50\u5C3E`;if(i.format==="includes")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${i.includes}"`;if(i.format==="regex")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${i.pattern}`;return`\u7121\u6548\u7684 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${n.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${n.keys.length>1?"\u5011":""}\uFF1A${Q(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};var V1=w(()=>{Ee()});function Yw(){return{localeError:zK()}}var zK=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function t(n){return e[n]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},o={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${n.expected}, \xE0m\u1ECD\u0300 a r\xED ${a}`;return`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${i}, \xE0m\u1ECD\u0300 a r\xED ${a}`}case"invalid_value":if(n.values.length===1)return`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${ce(n.values[0])}`;return`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin??"iye"} ${s.verb} ${i}${n.maximum} ${s.unit}`;return`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${i}${n.maximum}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin} ${s.verb} ${i}${n.minimum} ${s.unit}`;return`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${i}${n.minimum}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${i.prefix}"`;if(i.format==="ends_with")return`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${i.suffix}"`;if(i.format==="includes")return`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${i.includes}"`;if(i.format==="regex")return`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${i.pattern}`;return`A\u1E63\xEC\u1E63e: ${r[i.format]??n.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${n.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${Q(n.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};var W1=w(()=>{Ee()});var Xl={};Ut(Xl,{ar:()=>tw,az:()=>rw,be:()=>nw,bg:()=>ow,ca:()=>iw,cs:()=>sw,da:()=>aw,de:()=>cw,el:()=>lw,en:()=>Wl,eo:()=>dw,es:()=>fw,fa:()=>pw,fi:()=>mw,fr:()=>hw,frCA:()=>gw,he:()=>yw,hr:()=>bw,hu:()=>Sw,hy:()=>vw,id:()=>ww,is:()=>xw,it:()=>_w,ja:()=>Ew,ka:()=>Iw,kh:()=>Aw,km:()=>Gl,ko:()=>Tw,lt:()=>$w,mk:()=>Rw,ms:()=>Ow,nl:()=>Cw,no:()=>Pw,ota:()=>zw,pl:()=>Dw,ps:()=>Nw,pt:()=>Lw,ro:()=>Bw,ru:()=>jw,sl:()=>Zw,sv:()=>Uw,ta:()=>qw,th:()=>Mw,tr:()=>Fw,ua:()=>Kw,uk:()=>Yl,ur:()=>Hw,uz:()=>Vw,vi:()=>Ww,yo:()=>Yw,zhCN:()=>Gw,zhTW:()=>Qw});var Xw=w(()=>{QO();YO();e1();t1();r1();n1();o1();i1();s1();uw();a1();c1();l1();u1();d1();f1();p1();m1();h1();y1();b1();S1();v1();w1();x1();_1();kw();E1();k1();A1();T1();$1();R1();O1();C1();P1();z1();N1();L1();B1();j1();Z1();U1();q1();M1();Jw();F1();J1();K1();H1();V1();W1()});class rx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function bp(){return new rx}var G1,ex,tx,qt;var eu=w(()=>{ex=Symbol("ZodOutput"),tx=Symbol("ZodInput");(G1=globalThis).__zod_globalRegistry??(G1.__zod_globalRegistry=bp());qt=globalThis.__zod_globalRegistry});function nx(e,t){return new e({type:"string",...de(t)})}function ox(e,t){return new e({type:"string",coerce:!0,...de(t)})}function Sp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...de(t)})}function tu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...de(t)})}function vp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...de(t)})}function wp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...de(t)})}function xp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...de(t)})}function _p(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...de(t)})}function ru(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...de(t)})}function Ep(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...de(t)})}function Ip(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...de(t)})}function kp(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...de(t)})}function Ap(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...de(t)})}function Tp(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...de(t)})}function $p(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...de(t)})}function Rp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...de(t)})}function Op(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...de(t)})}function Cp(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...de(t)})}function ix(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...de(t)})}function Pp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...de(t)})}function zp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...de(t)})}function Np(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...de(t)})}function Dp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...de(t)})}function Lp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...de(t)})}function Bp(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...de(t)})}function ax(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...de(t)})}function cx(e,t){return new e({type:"string",format:"date",check:"string_format",...de(t)})}function lx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...de(t)})}function ux(e,t){return new e({type:"string",format:"duration",check:"string_format",...de(t)})}function dx(e,t){return new e({type:"number",checks:[],...de(t)})}function fx(e,t){return new e({type:"number",coerce:!0,checks:[],...de(t)})}function px(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...de(t)})}function mx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...de(t)})}function hx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...de(t)})}function gx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...de(t)})}function yx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...de(t)})}function bx(e,t){return new e({type:"boolean",...de(t)})}function Sx(e,t){return new e({type:"boolean",coerce:!0,...de(t)})}function vx(e,t){return new e({type:"bigint",...de(t)})}function wx(e,t){return new e({type:"bigint",coerce:!0,...de(t)})}function xx(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...de(t)})}function _x(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...de(t)})}function Ex(e,t){return new e({type:"symbol",...de(t)})}function Ix(e,t){return new e({type:"undefined",...de(t)})}function kx(e,t){return new e({type:"null",...de(t)})}function Ax(e){return new e({type:"any"})}function Tx(e){return new e({type:"unknown"})}function $x(e,t){return new e({type:"never",...de(t)})}function Rx(e,t){return new e({type:"void",...de(t)})}function Ox(e,t){return new e({type:"date",...de(t)})}function Cx(e,t){return new e({type:"date",coerce:!0,...de(t)})}function Px(e,t){return new e({type:"nan",...de(t)})}function $n(e,t){return new ip({check:"less_than",...de(t),value:e,inclusive:!1})}function Or(e,t){return new ip({check:"less_than",...de(t),value:e,inclusive:!0})}function Rn(e,t){return new sp({check:"greater_than",...de(t),value:e,inclusive:!1})}function dr(e,t){return new sp({check:"greater_than",...de(t),value:e,inclusive:!0})}function jp(e){return Rn(0,e)}function Zp(e){return $n(0,e)}function Up(e){return Or(0,e)}function qp(e){return dr(0,e)}function Qo(e,t){return new ES({check:"multiple_of",...de(t),value:e})}function Yo(e,t){return new AS({check:"max_size",...de(t),maximum:e})}function On(e,t){return new TS({check:"min_size",...de(t),minimum:e})}function ds(e,t){return new $S({check:"size_equals",...de(t),size:e})}function fs(e,t){return new RS({check:"max_length",...de(t),maximum:e})}function io(e,t){return new OS({check:"min_length",...de(t),minimum:e})}function ps(e,t){return new CS({check:"length_equals",...de(t),length:e})}function Ta(e,t){return new PS({check:"string_format",format:"regex",...de(t),pattern:e})}function $a(e){return new zS({check:"string_format",format:"lowercase",...de(e)})}function Ra(e){return new NS({check:"string_format",format:"uppercase",...de(e)})}function Oa(e,t){return new DS({check:"string_format",format:"includes",...de(t),includes:e})}function Ca(e,t){return new LS({check:"string_format",format:"starts_with",...de(t),prefix:e})}function Pa(e,t){return new BS({check:"string_format",format:"ends_with",...de(t),suffix:e})}function Mp(e,t,r){return new jS({check:"property",property:e,schema:t,...de(r)})}function za(e,t){return new ZS({check:"mime_type",mime:e,...de(t)})}function an(e){return new US({check:"overwrite",tx:e})}function Na(e){return an((t)=>t.normalize(e))}function Da(){return an((e)=>e.trim())}function La(){return an((e)=>e.toLowerCase())}function Ba(){return an((e)=>e.toUpperCase())}function ja(){return an((e)=>Nb(e))}function zx(e,t,r){return new e({type:"array",element:t,...de(r)})}function DK(e,t,r){return new e({type:"union",options:t,...de(r)})}function LK(e,t,r){return new e({type:"union",options:t,inclusive:!1,...de(r)})}function BK(e,t,r,o){return new e({type:"union",options:r,discriminator:t,...de(o)})}function jK(e,t,r){return new e({type:"intersection",left:t,right:r})}function ZK(e,t,r,o){let n=r instanceof Ne;return new e({type:"tuple",items:t,rest:n?r:null,...de(n?o:r)})}function UK(e,t,r,o){return new e({type:"record",keyType:t,valueType:r,...de(o)})}function qK(e,t,r,o){return new e({type:"map",keyType:t,valueType:r,...de(o)})}function MK(e,t,r){return new e({type:"set",valueType:t,...de(r)})}function FK(e,t,r){let o=Array.isArray(t)?Object.fromEntries(t.map((n)=>[n,n])):t;return new e({type:"enum",entries:o,...de(r)})}function JK(e,t,r){return new e({type:"enum",entries:t,...de(r)})}function KK(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...de(r)})}function Nx(e,t){return new e({type:"file",...de(t)})}function HK(e,t){return new e({type:"transform",transform:t})}function VK(e,t){return new e({type:"optional",innerType:t})}function WK(e,t){return new e({type:"nullable",innerType:t})}function GK(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r==="function"?r():Lb(r)}})}function QK(e,t,r){return new e({type:"nonoptional",innerType:t,...de(r)})}function YK(e,t){return new e({type:"success",innerType:t})}function XK(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r==="function"?r:()=>r})}function eH(e,t,r){return new e({type:"pipe",in:t,out:r})}function tH(e,t){return new e({type:"readonly",innerType:t})}function rH(e,t,r){return new e({type:"template_literal",parts:t,...de(r)})}function nH(e,t){return new e({type:"lazy",getter:t})}function oH(e,t){return new e({type:"promise",innerType:t})}function Dx(e,t,r){let o=de(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Lx(e,t,r){return new e({type:"custom",check:"custom",fn:t,...de(r)})}function Bx(e,t){let r=Q1((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push(wa(n,o.value,r._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(wa(i))}},e(o.value,o)),t);return r}function Q1(e,t){let r=new rt({check:"custom",...de(t)});return r._zod.check=e,r}function jx(e){let t=new rt({check:"describe"});return t._zod.onattach=[(r)=>{let o=qt.get(r)??{};qt.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function Zx(e){let t=new rt({check:"meta"});return t._zod.onattach=[(r)=>{let o=qt.get(r)??{};qt.add(r,{...o,...e})}],t._zod.check=()=>{},t}function Ux(e,t){let r=de(t),o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];if(r.case!=="sensitive")o=o.map((h)=>typeof h==="string"?h.toLowerCase():h),n=n.map((h)=>typeof h==="string"?h.toLowerCase():h);let i=new Set(o),s=new Set(n),a=e.Codec??Vl,c=e.Boolean??Kl,d=new(e.String??us)({type:"string",error:r.error}),f=new c({type:"boolean",error:r.error}),m=new a({type:"pipe",in:d,out:f,transform:(h,b)=>{let y=h;if(r.case!=="sensitive")y=y.toLowerCase();if(i.has(y))return!0;else if(s.has(y))return!1;else return b.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:b.value,inst:m,continue:!1}),{}},reverseTransform:(h,b)=>{if(h===!0)return o[0]||"true";else return n[0]||"false"},error:r.error});return m}function Za(e,t,r,o={}){let n=de(o),i={...de(o),check:"string_format",type:"string",format:t,fn:typeof r==="function"?r:(a)=>r.test(a),...n};if(r instanceof RegExp)i.pattern=r;return new e(i)}var sx;var Y1=w(()=>{ap();eu();ew();Ee();sx={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6}});function Xo(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??qt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Ve(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,d);else{let m=s.schema,h=t.processors[n.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);h(e,t,m,d)}let f=e._zod.parent;if(f){if(!s.ref)s.ref=f;Ve(f,t,d),t.seen.get(f).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(s.schema,c);if(t.io==="input"&&fr(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(o=s.schema).default??(o.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function ei(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=o.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,s[0])}}let n=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(s[0])?.id,m=e.external.uri??((b)=>b);if(f)return{ref:m(f)};let h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${m("__shared")}#/${a}/${h}`}}if(s[1]===r)return{ref:"#"};let u=`${"#"}/${a}/`,d=s[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=n(s);if(a.def={...a.schema},u)a.defId=u;let d=a.schema;for(let f in d)delete d[f];d.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
211
211
 
212
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref"){i(s);continue}}}}function ti(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,d={...u},f=c.ref;if(c.ref=null,f){o(f);let h=e.seen.get(f),b=h.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(b);else Object.assign(u,b);if(Object.assign(u,d),a._zod.parent===f)for(let S in u){if(S==="$ref"||S==="allOf")continue;if(!(S in d))delete u[S]}if(b.$ref&&h.def)for(let S in u){if(S==="$ref"||S==="allOf")continue;if(S in h.def&&JSON.stringify(u[S])===JSON.stringify(h.def[S]))delete u[S]}}let m=a._zod.parent;if(m&&m!==f){o(m);let h=e.seen.get(m);if(h?.schema.$ref){if(u.$ref=h.schema.$ref,h.def)for(let b in u){if(b==="$ref"||b==="allOf")continue;if(b in h.def&&JSON.stringify(u[b])===JSON.stringify(h.def[b]))delete u[b]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())o(a[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;s[c.defId]=c.def}}if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")n.$defs=s;else n.definitions=s;try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ua(t,"input",e.processors),output:Ua(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function fr(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return fr(o.element,r);if(o.type==="set")return fr(o.valueType,r);if(o.type==="lazy")return fr(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return fr(o.innerType,r);if(o.type==="intersection")return fr(o.left,r)||fr(o.right,r);if(o.type==="record"||o.type==="map")return fr(o.keyType,r)||fr(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return fr(o.in,r)||fr(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(fr(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(fr(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(fr(n,r))return!0;if(o.rest&&fr(o.rest,r))return!0;return!1}return!1}var qx=(e,t={})=>(r)=>{let o=Xo({...r,processors:t});return Ve(e,o),ei(o,e),ti(o,e)},Ua=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:i}=o??{},s=Xo({...n??{},target:i,io:t,processors:r});return Ve(e,s),ei(s,e),ti(s,e)};var nu=w(()=>{eu()});function Hp(e,t){if("_idmap"in e){let o=e,n=Xo({...t,processors:Fp}),i={};for(let c of o._idmap.entries()){let[u,d]=c;Ve(d,n)}let s={},a={registry:o,uri:t?.uri,defs:i};n.external=a;for(let c of o._idmap.entries()){let[u,d]=c;ei(n,d),s[u]=ti(n,d)}if(Object.keys(i).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let r=Xo({...t,processors:Fp});return Ve(e,r),ei(r,e),ti(r,e)}var iH,Mx=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(a){if(n.format=iH[a]??a,n.format==="")delete n.format;if(a==="time")delete n.format}if(u)n.contentEncoding=u;if(c&&c.size>0){let d=[...c];if(d.length===1)n.pattern=d[0].source;else if(d.length>1)n.allOf=[...d.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Fx=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;if(typeof a==="string"&&a.includes("int"))n.type="integer";else n.type="number";let f=typeof d==="number"&&d>=(i??Number.NEGATIVE_INFINITY),m=typeof u==="number"&&u<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(h)n.minimum=d,n.exclusiveMinimum=!0;else n.exclusiveMinimum=d;else if(typeof i==="number")n.minimum=i;if(m)if(h)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s==="number")n.maximum=s;if(typeof c==="number")n.multipleOf=c},Jx=(e,t,r,o)=>{r.type="boolean"},Kx=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Hx=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},Vx=(e,t,r,o)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},Wx=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},Gx=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},Qx=(e,t,r,o)=>{r.not={}},Yx=(e,t,r,o)=>{},Xx=(e,t,r,o)=>{},e0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},t0=(e,t,r,o)=>{let n=e._zod.def,i=Nl(n.entries);if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i},r0=(e,t,r,o)=>{let n=e._zod.def,i=[];for(let s of n.values)if(s===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[s];else r.const=s}else{if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";if(i.every((s)=>typeof s==="boolean"))r.type="boolean";if(i.every((s)=>s===null))r.type="null";r.enum=i}},n0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},o0=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},i0=(e,t,r,o)=>{let n=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=e._zod.bag;if(s!==void 0)i.minLength=s;if(a!==void 0)i.maxLength=a;if(c)if(c.length===1)i.contentMediaType=c[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=c.map((u)=>({contentMediaType:u}));else Object.assign(n,i)},s0=(e,t,r,o)=>{r.type="boolean"},a0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},c0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},l0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},u0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},d0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},f0=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s==="number")n.minItems=s;if(typeof a==="number")n.maxItems=a;n.type="array",n.items=Ve(i.element,t,{...o,path:[...o.path,"items"]})},p0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object",n.properties={};let s=i.shape;for(let u in s)n.properties[u]=Ve(s[u],t,{...o,path:[...o.path,"properties",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((u)=>{let d=i.shape[u]._zod;if(t.io==="input")return d.optin===void 0;else return d.optout===void 0}));if(c.size>0)n.required=Array.from(c);if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=Ve(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},Jp=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,c)=>Ve(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));if(i)r.oneOf=s;else r.anyOf=s},m0=(e,t,r,o)=>{let n=e._zod.def,i=Ve(n.left,t,{...o,path:[...o.path,"allOf",0]}),s=Ve(n.right,t,{...o,path:[...o.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c},h0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((m,h)=>Ve(m,t,{...o,path:[...o.path,s,h]})),u=i.rest?Ve(i.rest,t,{...o,path:[...o.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=c,u)n.items=u}else if(t.target==="openapi-3.0"){if(n.items={anyOf:c},u)n.items.anyOf.push(u);if(n.minItems=c.length,!u)n.maxItems=c.length}else if(n.items=c,u)n.additionalItems=u;let{minimum:d,maximum:f}=e._zod.bag;if(typeof d==="number")n.minItems=d;if(typeof f==="number")n.maxItems=f},g0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let d=Ve(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let f of c)n.patternProperties[f.source]=d}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=Ve(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});n.additionalProperties=Ve(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=s._zod.values;if(u){let d=[...u].filter((f)=>typeof f==="string"||typeof f==="number");if(d.length>0)n.required=d}},y0=(e,t,r,o)=>{let n=e._zod.def,i=Ve(n.innerType,t,o),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=n.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},b0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},S0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},v0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io==="input")r._prefault=JSON.parse(JSON.stringify(n.defaultValue))},w0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},x0=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;Ve(s,t,o);let a=t.seen.get(e);a.ref=s},_0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},E0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Kp=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},I0=(e,t,r,o)=>{let n=e._zod.innerType;Ve(n,t,o);let i=t.seen.get(e);i.ref=n},Fp;var ou=w(()=>{nu();Ee();iH={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Fp={string:Mx,number:Fx,boolean:Jx,bigint:Kx,symbol:Hx,null:Vx,undefined:Wx,void:Gx,never:Qx,any:Yx,unknown:Xx,date:e0,enum:t0,literal:r0,nan:n0,template_literal:o0,file:i0,success:s0,custom:a0,function:c0,transform:l0,map:u0,set:d0,array:f0,object:p0,union:Jp,intersection:m0,tuple:h0,record:g0,nullable:y0,nonoptional:b0,default:S0,prefault:v0,catch:w0,pipe:x0,readonly:_0,promise:E0,optional:Kp,lazy:I0}});class k0{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(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";this.ctx=Xo({processors:Fp,target:t,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,t={path:[],schemaPath:[]}){return Ve(e,this.ctx,t)}emit(e,t){if(t){if(t.cycles)this.ctx.cycles=t.cycles;if(t.reused)this.ctx.reused=t.reused;if(t.external)this.ctx.external=t.external}ei(this.ctx,e);let r=ti(this.ctx,e),{"~standard":o,...n}=r;return n}}var X1=w(()=>{ou();nu()});var eC={};var tC=()=>{};var so={};Ut(so,{$ZodAny:()=>xv,$ZodArray:()=>Av,$ZodAsyncError:()=>Tn,$ZodBase64:()=>fv,$ZodBase64URL:()=>pv,$ZodBigInt:()=>mp,$ZodBigIntFormat:()=>bv,$ZodBoolean:()=>Kl,$ZodCIDRv4:()=>lv,$ZodCIDRv6:()=>uv,$ZodCUID:()=>QS,$ZodCUID2:()=>YS,$ZodCatch:()=>Jv,$ZodCheck:()=>rt,$ZodCheckBigIntFormat:()=>kS,$ZodCheckEndsWith:()=>BS,$ZodCheckGreaterThan:()=>sp,$ZodCheckIncludes:()=>DS,$ZodCheckLengthEquals:()=>CS,$ZodCheckLessThan:()=>ip,$ZodCheckLowerCase:()=>zS,$ZodCheckMaxLength:()=>RS,$ZodCheckMaxSize:()=>AS,$ZodCheckMimeType:()=>ZS,$ZodCheckMinLength:()=>OS,$ZodCheckMinSize:()=>TS,$ZodCheckMultipleOf:()=>ES,$ZodCheckNumberFormat:()=>IS,$ZodCheckOverwrite:()=>US,$ZodCheckProperty:()=>jS,$ZodCheckRegex:()=>PS,$ZodCheckSizeEquals:()=>$S,$ZodCheckStartsWith:()=>LS,$ZodCheckStringFormat:()=>ka,$ZodCheckUpperCase:()=>NS,$ZodCodec:()=>Vl,$ZodCustom:()=>Xv,$ZodCustomStringFormat:()=>gv,$ZodDate:()=>kv,$ZodDefault:()=>Uv,$ZodDiscriminatedUnion:()=>Rv,$ZodE164:()=>mv,$ZodEmail:()=>HS,$ZodEmoji:()=>WS,$ZodEncodeError:()=>ss,$ZodEnum:()=>Nv,$ZodError:()=>Zl,$ZodExactOptional:()=>jv,$ZodFile:()=>Lv,$ZodFunction:()=>Gv,$ZodGUID:()=>JS,$ZodIPv4:()=>sv,$ZodIPv6:()=>av,$ZodISODate:()=>nv,$ZodISODateTime:()=>rv,$ZodISODuration:()=>iv,$ZodISOTime:()=>ov,$ZodIntersection:()=>Ov,$ZodJWT:()=>hv,$ZodKSUID:()=>tv,$ZodLazy:()=>Yv,$ZodLiteral:()=>Dv,$ZodMAC:()=>cv,$ZodMap:()=>Pv,$ZodNaN:()=>Kv,$ZodNanoID:()=>GS,$ZodNever:()=>Ev,$ZodNonOptional:()=>Mv,$ZodNull:()=>wv,$ZodNullable:()=>Zv,$ZodNumber:()=>pp,$ZodNumberFormat:()=>yv,$ZodObject:()=>GO,$ZodObjectJIT:()=>Tv,$ZodOptional:()=>gp,$ZodPipe:()=>yp,$ZodPrefault:()=>qv,$ZodPreprocess:()=>Hv,$ZodPromise:()=>Qv,$ZodReadonly:()=>Vv,$ZodRealError:()=>wr,$ZodRecord:()=>Cv,$ZodRegistry:()=>rx,$ZodSet:()=>zv,$ZodString:()=>us,$ZodStringFormat:()=>Ye,$ZodSuccess:()=>Fv,$ZodSymbol:()=>Sv,$ZodTemplateLiteral:()=>Wv,$ZodTransform:()=>Bv,$ZodTuple:()=>hp,$ZodType:()=>Ne,$ZodULID:()=>XS,$ZodURL:()=>VS,$ZodUUID:()=>KS,$ZodUndefined:()=>vv,$ZodUnion:()=>Hl,$ZodUnknown:()=>_v,$ZodVoid:()=>Iv,$ZodXID:()=>ev,$ZodXor:()=>$v,$brand:()=>Cb,$constructor:()=>Z,$input:()=>tx,$output:()=>ex,Doc:()=>cp,JSONSchema:()=>eC,JSONSchemaGenerator:()=>k0,NEVER:()=>Ob,TimePrecision:()=>sx,_any:()=>Ax,_array:()=>zx,_base64:()=>Np,_base64url:()=>Dp,_bigint:()=>vx,_boolean:()=>bx,_catch:()=>XK,_check:()=>Q1,_cidrv4:()=>Pp,_cidrv6:()=>zp,_coercedBigint:()=>wx,_coercedBoolean:()=>Sx,_coercedDate:()=>Cx,_coercedNumber:()=>fx,_coercedString:()=>ox,_cuid:()=>kp,_cuid2:()=>Ap,_custom:()=>Dx,_date:()=>Ox,_decode:()=>Gf,_decodeAsync:()=>Yf,_default:()=>GK,_discriminatedUnion:()=>BK,_e164:()=>Lp,_email:()=>Sp,_emoji:()=>Ep,_encode:()=>Wf,_encodeAsync:()=>Qf,_endsWith:()=>Pa,_enum:()=>FK,_file:()=>Nx,_float32:()=>mx,_float64:()=>hx,_gt:()=>Rn,_gte:()=>dr,_guid:()=>tu,_includes:()=>Oa,_int:()=>px,_int32:()=>gx,_int64:()=>xx,_intersection:()=>jK,_ipv4:()=>Op,_ipv6:()=>Cp,_isoDate:()=>cx,_isoDateTime:()=>ax,_isoDuration:()=>ux,_isoTime:()=>lx,_jwt:()=>Bp,_ksuid:()=>Rp,_lazy:()=>nH,_length:()=>ps,_literal:()=>KK,_lowercase:()=>$a,_lt:()=>$n,_lte:()=>Or,_mac:()=>ix,_map:()=>qK,_max:()=>Or,_maxLength:()=>fs,_maxSize:()=>Yo,_mime:()=>za,_min:()=>dr,_minLength:()=>io,_minSize:()=>On,_multipleOf:()=>Qo,_nan:()=>Px,_nanoid:()=>Ip,_nativeEnum:()=>JK,_negative:()=>Zp,_never:()=>$x,_nonnegative:()=>qp,_nonoptional:()=>QK,_nonpositive:()=>Up,_normalize:()=>Na,_null:()=>kx,_nullable:()=>WK,_number:()=>dx,_optional:()=>VK,_overwrite:()=>an,_parse:()=>xa,_parseAsync:()=>_a,_pipe:()=>eH,_positive:()=>jp,_promise:()=>oH,_property:()=>Mp,_readonly:()=>tH,_record:()=>UK,_refine:()=>Lx,_regex:()=>Ta,_safeDecode:()=>ep,_safeDecodeAsync:()=>rp,_safeEncode:()=>Xf,_safeEncodeAsync:()=>tp,_safeParse:()=>Ea,_safeParseAsync:()=>Ia,_set:()=>MK,_size:()=>ds,_slugify:()=>ja,_startsWith:()=>Ca,_string:()=>nx,_stringFormat:()=>Za,_stringbool:()=>Ux,_success:()=>YK,_superRefine:()=>Bx,_symbol:()=>Ex,_templateLiteral:()=>rH,_toLowerCase:()=>La,_toUpperCase:()=>Ba,_transform:()=>HK,_trim:()=>Da,_tuple:()=>ZK,_uint32:()=>yx,_uint64:()=>_x,_ulid:()=>Tp,_undefined:()=>Ix,_union:()=>DK,_unknown:()=>Tx,_uppercase:()=>Ra,_url:()=>ru,_uuid:()=>vp,_uuidv4:()=>wp,_uuidv6:()=>xp,_uuidv7:()=>_p,_void:()=>Rx,_xid:()=>$p,_xor:()=>LK,clone:()=>lr,config:()=>ht,createStandardJSONSchemaMethod:()=>Ua,createToJSONSchemaMethod:()=>qx,decode:()=>oJ,decodeAsync:()=>sJ,describe:()=>jx,encode:()=>nJ,encodeAsync:()=>iJ,extractDefs:()=>ei,finalize:()=>ti,flattenError:()=>Ul,formatError:()=>ql,globalConfig:()=>is,globalRegistry:()=>qt,initializeContext:()=>Xo,isValidBase64:()=>dv,isValidBase64URL:()=>KO,isValidJWT:()=>HO,locales:()=>Xl,meta:()=>Zx,parse:()=>Hf,parseAsync:()=>Vf,prettifyError:()=>Fb,process:()=>Ve,regexes:()=>Rr,registry:()=>bp,safeDecode:()=>cJ,safeDecodeAsync:()=>uJ,safeEncode:()=>aJ,safeEncodeAsync:()=>lJ,safeParse:()=>Kb,safeParseAsync:()=>Hb,toDotPath:()=>IO,toJSONSchema:()=>Hp,treeifyError:()=>Mb,util:()=>ue,version:()=>qS});var Cr=w(()=>{Ee();op();Xw();ou();X1();tC();as();Vb();Jb();ew();ap();MS();eu();Y1();nu()});var Vp={};Ut(Vp,{endsWith:()=>Pa,gt:()=>Rn,gte:()=>dr,includes:()=>Oa,length:()=>ps,lowercase:()=>$a,lt:()=>$n,lte:()=>Or,maxLength:()=>fs,maxSize:()=>Yo,mime:()=>za,minLength:()=>io,minSize:()=>On,multipleOf:()=>Qo,negative:()=>Zp,nonnegative:()=>qp,nonpositive:()=>Up,normalize:()=>Na,overwrite:()=>an,positive:()=>jp,property:()=>Mp,regex:()=>Ta,size:()=>ds,slugify:()=>ja,startsWith:()=>Ca,toLowerCase:()=>La,toUpperCase:()=>Ba,trim:()=>Da,uppercase:()=>Ra});var Wp=w(()=>{Cr()});var qa={};Ut(qa,{ZodISODate:()=>Qp,ZodISODateTime:()=>Gp,ZodISODuration:()=>Xp,ZodISOTime:()=>Yp,date:()=>T0,datetime:()=>A0,duration:()=>R0,time:()=>$0});function A0(e){return ax(Gp,e)}function T0(e){return cx(Qp,e)}function $0(e){return lx(Yp,e)}function R0(e){return ux(Xp,e)}var Gp,Qp,Yp,Xp;var iu=w(()=>{Cr();au();Gp=Z("ZodISODateTime",(e,t)=>{rv.init(e,t),Xe.init(e,t)});Qp=Z("ZodISODate",(e,t)=>{nv.init(e,t),Xe.init(e,t)});Yp=Z("ZodISOTime",(e,t)=>{ov.init(e,t),Xe.init(e,t)});Xp=Z("ZodISODuration",(e,t)=>{iv.init(e,t),Xe.init(e,t)})});var rC=(e,t)=>{Zl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>ql(e,r)},flatten:{value:(r)=>Ul(e,r)},addIssue:{value:(r)=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Sa,2)}},addIssues:{value:(r)=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Sa,2)}},isEmpty:{get(){return e.issues.length===0}}})},nC,xr;var O0=w(()=>{Cr();Cr();Ee();nC=Z("ZodError",rC),xr=Z("ZodError",rC,{Parent:Error})});var C0,P0,z0,N0,D0,L0,B0,j0,Z0,U0,q0,M0;var F0=w(()=>{Cr();O0();C0=xa(xr),P0=_a(xr),z0=Ea(xr),N0=Ia(xr),D0=Wf(xr),L0=Gf(xr),B0=Qf(xr),j0=Yf(xr),Z0=Xf(xr),U0=ep(xr),q0=tp(xr),M0=rp(xr)});var su={};Ut(su,{ZodAny:()=>Y0,ZodArray:()=>r_,ZodBase64:()=>hm,ZodBase64URL:()=>gm,ZodBigInt:()=>Wa,ZodBigIntFormat:()=>Sm,ZodBoolean:()=>Va,ZodCIDRv4:()=>pm,ZodCIDRv6:()=>mm,ZodCUID:()=>sm,ZodCUID2:()=>am,ZodCatch:()=>E_,ZodCodec:()=>Su,ZodCustom:()=>vu,ZodCustomStringFormat:()=>Ka,ZodDate:()=>mu,ZodDefault:()=>b_,ZodDiscriminatedUnion:()=>o_,ZodE164:()=>ym,ZodEmail:()=>nm,ZodEmoji:()=>om,ZodEnum:()=>Fa,ZodExactOptional:()=>h_,ZodFile:()=>p_,ZodFunction:()=>z_,ZodGUID:()=>lu,ZodIPv4:()=>dm,ZodIPv6:()=>fm,ZodIntersection:()=>i_,ZodJWT:()=>bm,ZodKSUID:()=>um,ZodLazy:()=>O_,ZodLiteral:()=>f_,ZodMAC:()=>J0,ZodMap:()=>u_,ZodNaN:()=>k_,ZodNanoID:()=>im,ZodNever:()=>e_,ZodNonOptional:()=>Im,ZodNull:()=>G0,ZodNullable:()=>y_,ZodNumber:()=>Ha,ZodNumberFormat:()=>hs,ZodObject:()=>gu,ZodOptional:()=>Em,ZodPipe:()=>bu,ZodPrefault:()=>v_,ZodPreprocess:()=>A_,ZodPromise:()=>P_,ZodReadonly:()=>T_,ZodRecord:()=>Ma,ZodSet:()=>d_,ZodString:()=>Ja,ZodStringFormat:()=>Xe,ZodSuccess:()=>__,ZodSymbol:()=>V0,ZodTemplateLiteral:()=>R_,ZodTransform:()=>m_,ZodTuple:()=>a_,ZodType:()=>Be,ZodULID:()=>cm,ZodURL:()=>pu,ZodUUID:()=>Cn,ZodUndefined:()=>W0,ZodUnion:()=>yu,ZodUnknown:()=>X0,ZodVoid:()=>t_,ZodXID:()=>lm,ZodXor:()=>n_,_ZodString:()=>rm,_default:()=>S_,_function:()=>dP,any:()=>qC,array:()=>hu,base64:()=>IC,base64url:()=>kC,bigint:()=>LC,boolean:()=>H0,catch:()=>I_,check:()=>fP,cidrv4:()=>_C,cidrv6:()=>EC,codec:()=>aP,cuid:()=>hC,cuid2:()=>gC,custom:()=>pP,date:()=>FC,describe:()=>mP,discriminatedUnion:()=>GC,e164:()=>AC,email:()=>iC,emoji:()=>pC,enum:()=>xm,exactOptional:()=>g_,file:()=>nP,float32:()=>PC,float64:()=>zC,function:()=>dP,guid:()=>sC,hash:()=>CC,hex:()=>OC,hostname:()=>RC,httpUrl:()=>fC,instanceof:()=>gP,int:()=>em,int32:()=>NC,int64:()=>BC,intersection:()=>s_,invertCodec:()=>cP,ipv4:()=>vC,ipv6:()=>xC,json:()=>bP,jwt:()=>TC,keyof:()=>JC,ksuid:()=>SC,lazy:()=>C_,literal:()=>rP,looseObject:()=>VC,looseRecord:()=>YC,mac:()=>wC,map:()=>XC,meta:()=>hP,nan:()=>sP,nanoid:()=>mC,nativeEnum:()=>tP,never:()=>vm,nonoptional:()=>x_,null:()=>Q0,nullable:()=>du,nullish:()=>oP,number:()=>K0,object:()=>KC,optional:()=>uu,partialRecord:()=>QC,pipe:()=>tm,prefault:()=>w_,preprocess:()=>SP,promise:()=>uP,readonly:()=>$_,record:()=>l_,refine:()=>N_,set:()=>eP,strictObject:()=>HC,string:()=>cu,stringFormat:()=>$C,stringbool:()=>yP,success:()=>iP,superRefine:()=>D_,symbol:()=>ZC,templateLiteral:()=>lP,transform:()=>_m,tuple:()=>c_,uint32:()=>DC,uint64:()=>jC,ulid:()=>yC,undefined:()=>UC,union:()=>wm,unknown:()=>ms,url:()=>dC,uuid:()=>aC,uuidv4:()=>cC,uuidv6:()=>lC,uuidv7:()=>uC,void:()=>MC,xid:()=>bC,xor:()=>WC});function fu(e,t,r){let o=Object.getPrototypeOf(e),n=oC.get(o);if(!n)n=new Set,oC.set(o,n);if(n.has(t))return;n.add(t);for(let i in r){let s=r[i];Object.defineProperty(o,i,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}function cu(e){return nx(Ja,e)}function iC(e){return Sp(nm,e)}function sC(e){return tu(lu,e)}function aC(e){return vp(Cn,e)}function cC(e){return wp(Cn,e)}function lC(e){return xp(Cn,e)}function uC(e){return _p(Cn,e)}function dC(e){return ru(pu,e)}function fC(e){return ru(pu,{protocol:Rr.httpProtocol,hostname:Rr.domain,...ue.normalizeParams(e)})}function pC(e){return Ep(om,e)}function mC(e){return Ip(im,e)}function hC(e){return kp(sm,e)}function gC(e){return Ap(am,e)}function yC(e){return Tp(cm,e)}function bC(e){return $p(lm,e)}function SC(e){return Rp(um,e)}function vC(e){return Op(dm,e)}function wC(e){return ix(J0,e)}function xC(e){return Cp(fm,e)}function _C(e){return Pp(pm,e)}function EC(e){return zp(mm,e)}function IC(e){return Np(hm,e)}function kC(e){return Dp(gm,e)}function AC(e){return Lp(ym,e)}function TC(e){return Bp(bm,e)}function $C(e,t,r={}){return Za(Ka,e,t,r)}function RC(e){return Za(Ka,"hostname",Rr.hostname,e)}function OC(e){return Za(Ka,"hex",Rr.hex,e)}function CC(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Rr[o];if(!n)throw Error(`Unrecognized hash format: ${o}`);return Za(Ka,o,n,t)}function K0(e){return dx(Ha,e)}function em(e){return px(hs,e)}function PC(e){return mx(hs,e)}function zC(e){return hx(hs,e)}function NC(e){return gx(hs,e)}function DC(e){return yx(hs,e)}function H0(e){return bx(Va,e)}function LC(e){return vx(Wa,e)}function BC(e){return xx(Sm,e)}function jC(e){return _x(Sm,e)}function ZC(e){return Ex(V0,e)}function UC(e){return Ix(W0,e)}function Q0(e){return kx(G0,e)}function qC(){return Ax(Y0)}function ms(){return Tx(X0)}function vm(e){return $x(e_,e)}function MC(e){return Rx(t_,e)}function FC(e){return Ox(mu,e)}function hu(e,t){return zx(r_,e,t)}function JC(e){let t=e._zod.def.shape;return xm(Object.keys(t))}function KC(e,t){let r={type:"object",shape:e??{},...ue.normalizeParams(t)};return new gu(r)}function HC(e,t){return new gu({type:"object",shape:e,catchall:vm(),...ue.normalizeParams(t)})}function VC(e,t){return new gu({type:"object",shape:e,catchall:ms(),...ue.normalizeParams(t)})}function wm(e,t){return new yu({type:"union",options:e,...ue.normalizeParams(t)})}function WC(e,t){return new n_({type:"union",options:e,inclusive:!1,...ue.normalizeParams(t)})}function GC(e,t,r){return new o_({type:"union",options:t,discriminator:e,...ue.normalizeParams(r)})}function s_(e,t){return new i_({type:"intersection",left:e,right:t})}function c_(e,t,r){let o=t instanceof Ne,n=o?r:t;return new a_({type:"tuple",items:e,rest:o?t:null,...ue.normalizeParams(n)})}function l_(e,t,r){if(!t||!t._zod)return new Ma({type:"record",keyType:cu(),valueType:e,...ue.normalizeParams(t)});return new Ma({type:"record",keyType:e,valueType:t,...ue.normalizeParams(r)})}function QC(e,t,r){let o=lr(e);return o._zod.values=void 0,new Ma({type:"record",keyType:o,valueType:t,...ue.normalizeParams(r)})}function YC(e,t,r){return new Ma({type:"record",keyType:e,valueType:t,mode:"loose",...ue.normalizeParams(r)})}function XC(e,t,r){return new u_({type:"map",keyType:e,valueType:t,...ue.normalizeParams(r)})}function eP(e,t){return new d_({type:"set",valueType:e,...ue.normalizeParams(t)})}function xm(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new Fa({type:"enum",entries:r,...ue.normalizeParams(t)})}function tP(e,t){return new Fa({type:"enum",entries:e,...ue.normalizeParams(t)})}function rP(e,t){return new f_({type:"literal",values:Array.isArray(e)?e:[e],...ue.normalizeParams(t)})}function nP(e){return Nx(p_,e)}function _m(e){return new m_({type:"transform",transform:e})}function uu(e){return new Em({type:"optional",innerType:e})}function g_(e){return new h_({type:"optional",innerType:e})}function du(e){return new y_({type:"nullable",innerType:e})}function oP(e){return uu(du(e))}function S_(e,t){return new b_({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ue.shallowClone(t)}})}function w_(e,t){return new v_({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ue.shallowClone(t)}})}function x_(e,t){return new Im({type:"nonoptional",innerType:e,...ue.normalizeParams(t)})}function iP(e){return new __({type:"success",innerType:e})}function I_(e,t){return new E_({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}function sP(e){return Px(k_,e)}function tm(e,t){return new bu({type:"pipe",in:e,out:t})}function aP(e,t,r){return new Su({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function cP(e){let t=e._zod.def;return new Su({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function $_(e){return new T_({type:"readonly",innerType:e})}function lP(e,t){return new R_({type:"template_literal",parts:e,...ue.normalizeParams(t)})}function C_(e){return new O_({type:"lazy",getter:e})}function uP(e){return new P_({type:"promise",innerType:e})}function dP(e){return new z_({type:"function",input:Array.isArray(e?.input)?c_(e?.input):e?.input??hu(ms()),output:e?.output??ms()})}function fP(e){let t=new rt({check:"custom"});return t._zod.check=e,t}function pP(e,t){return Dx(vu,e??(()=>!0),t)}function N_(e,t={}){return Lx(vu,e,t)}function D_(e,t){return Bx(e,t)}function gP(e,t={}){let r=new vu({type:"custom",check:"custom",fn:(o)=>o instanceof e,abort:!0,...ue.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=(o)=>{if(!(o.value instanceof e))o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}function bP(e){let t=C_(()=>wm([cu(e),K0(),H0(),Q0(),hu(t),l_(cu(),t)]));return t}function SP(e,t){return new A_({type:"pipe",in:_m(e),out:t})}var oC,Be,rm,Ja,Xe,nm,lu,Cn,pu,om,im,sm,am,cm,lm,um,dm,J0,fm,pm,mm,hm,gm,ym,bm,Ka,Ha,hs,Va,Wa,Sm,V0,W0,G0,Y0,X0,e_,t_,mu,r_,gu,yu,n_,o_,i_,a_,Ma,u_,d_,Fa,f_,p_,m_,Em,h_,y_,b_,v_,Im,__,E_,k_,bu,Su,A_,T_,R_,O_,P_,z_,vu,mP,hP,yP=(...e)=>Ux({Codec:Su,Boolean:Va,String:Ja},...e);var au=w(()=>{Cr();Cr();ou();nu();Wp();iu();F0();oC=new WeakMap;Be=Z("ZodType",(e,t)=>(Ne.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ua(e,"input"),output:Ua(e,"output")}}),e.toJSONSchema=qx(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,o)=>C0(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>z0(e,r,o),e.parseAsync=async(r,o)=>P0(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>N0(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>D0(e,r,o),e.decode=(r,o)=>L0(e,r,o),e.encodeAsync=async(r,o)=>B0(e,r,o),e.decodeAsync=async(r,o)=>j0(e,r,o),e.safeEncode=(r,o)=>Z0(e,r,o),e.safeDecode=(r,o)=>U0(e,r,o),e.safeEncodeAsync=async(r,o)=>q0(e,r,o),e.safeDecodeAsync=async(r,o)=>M0(e,r,o),fu(e,"ZodType",{check(...r){let o=this.def;return this.clone(ue.mergeDefs(o,{checks:[...o.checks??[],...r.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,o){return lr(this,r,o)},brand(){return this},register(r,o){return r.add(this,o),this},refine(r,o){return this.check(N_(r,o))},superRefine(r,o){return this.check(D_(r,o))},overwrite(r){return this.check(an(r))},optional(){return uu(this)},exactOptional(){return g_(this)},nullable(){return du(this)},nullish(){return uu(du(this))},nonoptional(r){return x_(this,r)},array(){return hu(this)},or(r){return wm([this,r])},and(r){return s_(this,r)},transform(r){return tm(this,_m(r))},default(r){return S_(this,r)},prefault(r){return w_(this,r)},catch(r){return I_(this,r)},pipe(r){return tm(this,r)},readonly(){return $_(this)},describe(r){let o=this.clone();return qt.add(o,{description:r}),o},meta(...r){if(r.length===0)return qt.get(this);let o=this.clone();return qt.add(o,r[0]),o},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return qt.get(e)?.description},configurable:!0}),e)),rm=Z("_ZodString",(e,t)=>{us.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Mx(e,o,n,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,fu(e,"_ZodString",{regex(...o){return this.check(Ta(...o))},includes(...o){return this.check(Oa(...o))},startsWith(...o){return this.check(Ca(...o))},endsWith(...o){return this.check(Pa(...o))},min(...o){return this.check(io(...o))},max(...o){return this.check(fs(...o))},length(...o){return this.check(ps(...o))},nonempty(...o){return this.check(io(1,...o))},lowercase(o){return this.check($a(o))},uppercase(o){return this.check(Ra(o))},trim(){return this.check(Da())},normalize(...o){return this.check(Na(...o))},toLowerCase(){return this.check(La())},toUpperCase(){return this.check(Ba())},slugify(){return this.check(ja())}})}),Ja=Z("ZodString",(e,t)=>{us.init(e,t),rm.init(e,t),e.email=(r)=>e.check(Sp(nm,r)),e.url=(r)=>e.check(ru(pu,r)),e.jwt=(r)=>e.check(Bp(bm,r)),e.emoji=(r)=>e.check(Ep(om,r)),e.guid=(r)=>e.check(tu(lu,r)),e.uuid=(r)=>e.check(vp(Cn,r)),e.uuidv4=(r)=>e.check(wp(Cn,r)),e.uuidv6=(r)=>e.check(xp(Cn,r)),e.uuidv7=(r)=>e.check(_p(Cn,r)),e.nanoid=(r)=>e.check(Ip(im,r)),e.guid=(r)=>e.check(tu(lu,r)),e.cuid=(r)=>e.check(kp(sm,r)),e.cuid2=(r)=>e.check(Ap(am,r)),e.ulid=(r)=>e.check(Tp(cm,r)),e.base64=(r)=>e.check(Np(hm,r)),e.base64url=(r)=>e.check(Dp(gm,r)),e.xid=(r)=>e.check($p(lm,r)),e.ksuid=(r)=>e.check(Rp(um,r)),e.ipv4=(r)=>e.check(Op(dm,r)),e.ipv6=(r)=>e.check(Cp(fm,r)),e.cidrv4=(r)=>e.check(Pp(pm,r)),e.cidrv6=(r)=>e.check(zp(mm,r)),e.e164=(r)=>e.check(Lp(ym,r)),e.datetime=(r)=>e.check(A0(r)),e.date=(r)=>e.check(T0(r)),e.time=(r)=>e.check($0(r)),e.duration=(r)=>e.check(R0(r))});Xe=Z("ZodStringFormat",(e,t)=>{Ye.init(e,t),rm.init(e,t)}),nm=Z("ZodEmail",(e,t)=>{HS.init(e,t),Xe.init(e,t)});lu=Z("ZodGUID",(e,t)=>{JS.init(e,t),Xe.init(e,t)});Cn=Z("ZodUUID",(e,t)=>{KS.init(e,t),Xe.init(e,t)});pu=Z("ZodURL",(e,t)=>{VS.init(e,t),Xe.init(e,t)});om=Z("ZodEmoji",(e,t)=>{WS.init(e,t),Xe.init(e,t)});im=Z("ZodNanoID",(e,t)=>{GS.init(e,t),Xe.init(e,t)});sm=Z("ZodCUID",(e,t)=>{QS.init(e,t),Xe.init(e,t)});am=Z("ZodCUID2",(e,t)=>{YS.init(e,t),Xe.init(e,t)});cm=Z("ZodULID",(e,t)=>{XS.init(e,t),Xe.init(e,t)});lm=Z("ZodXID",(e,t)=>{ev.init(e,t),Xe.init(e,t)});um=Z("ZodKSUID",(e,t)=>{tv.init(e,t),Xe.init(e,t)});dm=Z("ZodIPv4",(e,t)=>{sv.init(e,t),Xe.init(e,t)});J0=Z("ZodMAC",(e,t)=>{cv.init(e,t),Xe.init(e,t)});fm=Z("ZodIPv6",(e,t)=>{av.init(e,t),Xe.init(e,t)});pm=Z("ZodCIDRv4",(e,t)=>{lv.init(e,t),Xe.init(e,t)});mm=Z("ZodCIDRv6",(e,t)=>{uv.init(e,t),Xe.init(e,t)});hm=Z("ZodBase64",(e,t)=>{fv.init(e,t),Xe.init(e,t)});gm=Z("ZodBase64URL",(e,t)=>{pv.init(e,t),Xe.init(e,t)});ym=Z("ZodE164",(e,t)=>{mv.init(e,t),Xe.init(e,t)});bm=Z("ZodJWT",(e,t)=>{hv.init(e,t),Xe.init(e,t)});Ka=Z("ZodCustomStringFormat",(e,t)=>{gv.init(e,t),Xe.init(e,t)});Ha=Z("ZodNumber",(e,t)=>{pp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Fx(e,o,n,i),fu(e,"ZodNumber",{gt(o,n){return this.check(Rn(o,n))},gte(o,n){return this.check(dr(o,n))},min(o,n){return this.check(dr(o,n))},lt(o,n){return this.check($n(o,n))},lte(o,n){return this.check(Or(o,n))},max(o,n){return this.check(Or(o,n))},int(o){return this.check(em(o))},safe(o){return this.check(em(o))},positive(o){return this.check(Rn(0,o))},nonnegative(o){return this.check(dr(0,o))},negative(o){return this.check($n(0,o))},nonpositive(o){return this.check(Or(0,o))},multipleOf(o,n){return this.check(Qo(o,n))},step(o,n){return this.check(Qo(o,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});hs=Z("ZodNumberFormat",(e,t)=>{yv.init(e,t),Ha.init(e,t)});Va=Z("ZodBoolean",(e,t)=>{Kl.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jx(e,r,o,n)});Wa=Z("ZodBigInt",(e,t)=>{mp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Kx(e,o,n,i),e.gte=(o,n)=>e.check(dr(o,n)),e.min=(o,n)=>e.check(dr(o,n)),e.gt=(o,n)=>e.check(Rn(o,n)),e.gte=(o,n)=>e.check(dr(o,n)),e.min=(o,n)=>e.check(dr(o,n)),e.lt=(o,n)=>e.check($n(o,n)),e.lte=(o,n)=>e.check(Or(o,n)),e.max=(o,n)=>e.check(Or(o,n)),e.positive=(o)=>e.check(Rn(BigInt(0),o)),e.negative=(o)=>e.check($n(BigInt(0),o)),e.nonpositive=(o)=>e.check(Or(BigInt(0),o)),e.nonnegative=(o)=>e.check(dr(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(Qo(o,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});Sm=Z("ZodBigIntFormat",(e,t)=>{bv.init(e,t),Wa.init(e,t)});V0=Z("ZodSymbol",(e,t)=>{Sv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hx(e,r,o,n)});W0=Z("ZodUndefined",(e,t)=>{vv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wx(e,r,o,n)});G0=Z("ZodNull",(e,t)=>{wv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vx(e,r,o,n)});Y0=Z("ZodAny",(e,t)=>{xv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yx(e,r,o,n)});X0=Z("ZodUnknown",(e,t)=>{_v.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xx(e,r,o,n)});e_=Z("ZodNever",(e,t)=>{Ev.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Qx(e,r,o,n)});t_=Z("ZodVoid",(e,t)=>{Iv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gx(e,r,o,n)});mu=Z("ZodDate",(e,t)=>{kv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>e0(e,o,n,i),e.min=(o,n)=>e.check(dr(o,n)),e.max=(o,n)=>e.check(Or(o,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});r_=Z("ZodArray",(e,t)=>{Av.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>f0(e,r,o,n),e.element=t.element,fu(e,"ZodArray",{min(r,o){return this.check(io(r,o))},nonempty(r){return this.check(io(1,r))},max(r,o){return this.check(fs(r,o))},length(r,o){return this.check(ps(r,o))},unwrap(){return this.element}})});gu=Z("ZodObject",(e,t)=>{Tv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>p0(e,r,o,n),ue.defineLazy(e,"shape",()=>t.shape),fu(e,"ZodObject",{keyof(){return xm(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:ms()})},loose(){return this.clone({...this._zod.def,catchall:ms()})},strict(){return this.clone({...this._zod.def,catchall:vm()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return ue.extend(this,r)},safeExtend(r){return ue.safeExtend(this,r)},merge(r){return ue.merge(this,r)},pick(r){return ue.pick(this,r)},omit(r){return ue.omit(this,r)},partial(...r){return ue.partial(Em,this,r[0])},required(...r){return ue.required(Im,this,r[0])}})});yu=Z("ZodUnion",(e,t)=>{Hl.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jp(e,r,o,n),e.options=t.options});n_=Z("ZodXor",(e,t)=>{yu.init(e,t),$v.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jp(e,r,o,n),e.options=t.options});o_=Z("ZodDiscriminatedUnion",(e,t)=>{yu.init(e,t),Rv.init(e,t)});i_=Z("ZodIntersection",(e,t)=>{Ov.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>m0(e,r,o,n)});a_=Z("ZodTuple",(e,t)=>{hp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>h0(e,r,o,n),e.rest=(r)=>e.clone({...e._zod.def,rest:r})});Ma=Z("ZodRecord",(e,t)=>{Cv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>g0(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});u_=Z("ZodMap",(e,t)=>{Pv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>u0(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(On(...r)),e.nonempty=(r)=>e.check(On(1,r)),e.max=(...r)=>e.check(Yo(...r)),e.size=(...r)=>e.check(ds(...r))});d_=Z("ZodSet",(e,t)=>{zv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>d0(e,r,o,n),e.min=(...r)=>e.check(On(...r)),e.nonempty=(r)=>e.check(On(1,r)),e.max=(...r)=>e.check(Yo(...r)),e.size=(...r)=>e.check(ds(...r))});Fa=Z("ZodEnum",(e,t)=>{Nv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>t0(e,o,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let s of o)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Fa({...t,checks:[],...ue.normalizeParams(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let s of o)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Fa({...t,checks:[],...ue.normalizeParams(n),entries:i})}});f_=Z("ZodLiteral",(e,t)=>{Dv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>r0(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});p_=Z("ZodFile",(e,t)=>{Lv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>i0(e,r,o,n),e.min=(r,o)=>e.check(On(r,o)),e.max=(r,o)=>e.check(Yo(r,o)),e.mime=(r,o)=>e.check(za(Array.isArray(r)?r:[r],o))});m_=Z("ZodTransform",(e,t)=>{Bv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>l0(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new ss(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(ue.issue(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(ue.issue(s))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((i)=>(r.value=i,r.fallback=!0,r));return r.value=n,r.fallback=!0,r}});Em=Z("ZodOptional",(e,t)=>{gp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});h_=Z("ZodExactOptional",(e,t)=>{jv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});y_=Z("ZodNullable",(e,t)=>{Zv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>y0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});b_=Z("ZodDefault",(e,t)=>{Uv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>S0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});v_=Z("ZodPrefault",(e,t)=>{qv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>v0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Im=Z("ZodNonOptional",(e,t)=>{Mv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>b0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});__=Z("ZodSuccess",(e,t)=>{Fv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>s0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});E_=Z("ZodCatch",(e,t)=>{Jv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>w0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});k_=Z("ZodNaN",(e,t)=>{Kv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>n0(e,r,o,n)});bu=Z("ZodPipe",(e,t)=>{yp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>x0(e,r,o,n),e.in=t.in,e.out=t.out});Su=Z("ZodCodec",(e,t)=>{bu.init(e,t),Vl.init(e,t)});A_=Z("ZodPreprocess",(e,t)=>{bu.init(e,t),Hv.init(e,t)}),T_=Z("ZodReadonly",(e,t)=>{Vv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>_0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});R_=Z("ZodTemplateLiteral",(e,t)=>{Wv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>o0(e,r,o,n)});O_=Z("ZodLazy",(e,t)=>{Yv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>I0(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});P_=Z("ZodPromise",(e,t)=>{Qv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>E0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});z_=Z("ZodFunction",(e,t)=>{Gv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>c0(e,r,o,n)});vu=Z("ZodCustom",(e,t)=>{Xv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>a0(e,r,o,n)});mP=jx,hP=Zx});function lH(e){ht({customError:e})}function uH(){return ht().customError}var cH,L_;var vP=w(()=>{Cr();cH={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(e){})(L_||(L_={}))});function fH(e,t){let r=e.$schema;if(r==="https://json-schema.org/draft/2020-12/schema")return"draft-2020-12";if(r==="http://json-schema.org/draft-07/schema#")return"draft-7";if(r==="http://json-schema.org/draft-04/schema#")return"draft-4";return t??"draft-2020-12"}function pH(e,t){if(!e.startsWith("#"))throw Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1];if(!n||!t.defs[n])throw Error(`Reference not found: ${e}`);return t.defs[n]}throw Error(`Reference not found: ${e}`)}function wP(e,t){if(e.not!==void 0){if(typeof e.not==="object"&&Object.keys(e.not).length===0)return Se.never();throw Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw 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 Se.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=pH(n,t),s=er(i,t);return t.refs.set(n,s),t.processing.delete(n),s}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 Se.null();if(n.length===0)return Se.never();if(n.length===1)return Se.literal(n[0]);if(n.every((s)=>typeof s==="string"))return Se.enum(n);let i=n.map((s)=>Se.literal(s));if(i.length<2)return i[0];return Se.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return Se.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map((i)=>{let s={...e,type:i};return wP(s,t)});if(n.length===0)return Se.never();if(n.length===1)return n[0];return Se.union(n)}if(!r)return Se.any();let o;switch(r){case"string":{let n=Se.string();if(e.format){let i=e.format;if(i==="email")n=n.check(Se.email());else if(i==="uri"||i==="uri-reference")n=n.check(Se.url());else if(i==="uuid"||i==="guid")n=n.check(Se.uuid());else if(i==="date-time")n=n.check(Se.iso.datetime());else if(i==="date")n=n.check(Se.iso.date());else if(i==="time")n=n.check(Se.iso.time());else if(i==="duration")n=n.check(Se.iso.duration());else if(i==="ipv4")n=n.check(Se.ipv4());else if(i==="ipv6")n=n.check(Se.ipv6());else if(i==="mac")n=n.check(Se.mac());else if(i==="cidr")n=n.check(Se.cidrv4());else if(i==="cidr-v6")n=n.check(Se.cidrv6());else if(i==="base64")n=n.check(Se.base64());else if(i==="base64url")n=n.check(Se.base64url());else if(i==="e164")n=n.check(Se.e164());else if(i==="jwt")n=n.check(Se.jwt());else if(i==="emoji")n=n.check(Se.emoji());else if(i==="nanoid")n=n.check(Se.nanoid());else if(i==="cuid")n=n.check(Se.cuid());else if(i==="cuid2")n=n.check(Se.cuid2());else if(i==="ulid")n=n.check(Se.ulid());else if(i==="xid")n=n.check(Se.xid());else if(i==="ksuid")n=n.check(Se.ksuid())}if(typeof e.minLength==="number")n=n.min(e.minLength);if(typeof e.maxLength==="number")n=n.max(e.maxLength);if(e.pattern)n=n.regex(new RegExp(e.pattern));o=n;break}case"number":case"integer":{let n=r==="integer"?Se.number().int():Se.number();if(typeof e.minimum==="number")n=n.min(e.minimum);if(typeof e.maximum==="number")n=n.max(e.maximum);if(typeof e.exclusiveMinimum==="number")n=n.gt(e.exclusiveMinimum);else if(e.exclusiveMinimum===!0&&typeof e.minimum==="number")n=n.gt(e.minimum);if(typeof e.exclusiveMaximum==="number")n=n.lt(e.exclusiveMaximum);else if(e.exclusiveMaximum===!0&&typeof e.maximum==="number")n=n.lt(e.maximum);if(typeof e.multipleOf==="number")n=n.multipleOf(e.multipleOf);o=n;break}case"boolean":{o=Se.boolean();break}case"null":{o=Se.null();break}case"object":{let n={},i=e.properties||{},s=new Set(e.required||[]);for(let[c,u]of Object.entries(i)){let d=er(u,t);n[c]=s.has(c)?d:d.optional()}if(e.propertyNames){let c=er(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties==="object"?er(e.additionalProperties,t):Se.any();if(Object.keys(n).length===0){o=Se.record(c,u);break}let d=Se.object(n).passthrough(),f=Se.looseRecord(c,u);o=Se.intersection(d,f);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),d=[];for(let m of u){let h=er(c[m],t),b=Se.string().regex(new RegExp(m));d.push(Se.looseRecord(b,h))}let f=[];if(Object.keys(n).length>0)f.push(Se.object(n).passthrough());if(f.push(...d),f.length===0)o=Se.object({}).passthrough();else if(f.length===1)o=f[0];else{let m=Se.intersection(f[0],f[1]);for(let h=2;h<f.length;h++)m=Se.intersection(m,f[h]);o=m}break}let a=Se.object(n);if(e.additionalProperties===!1)o=a.strict();else if(typeof e.additionalProperties==="object")o=a.catchall(er(e.additionalProperties,t));else o=a.passthrough();break}case"array":{let{prefixItems:n,items:i}=e;if(n&&Array.isArray(n)){let s=n.map((c)=>er(c,t)),a=i&&typeof i==="object"&&!Array.isArray(i)?er(i,t):void 0;if(a)o=Se.tuple(s).rest(a);else o=Se.tuple(s);if(typeof e.minItems==="number")o=o.check(Se.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(Se.maxLength(e.maxItems))}else if(Array.isArray(i)){let s=i.map((c)=>er(c,t)),a=e.additionalItems&&typeof e.additionalItems==="object"?er(e.additionalItems,t):void 0;if(a)o=Se.tuple(s).rest(a);else o=Se.tuple(s);if(typeof e.minItems==="number")o=o.check(Se.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(Se.maxLength(e.maxItems))}else if(i!==void 0){let s=er(i,t),a=Se.array(s);if(typeof e.minItems==="number")a=a.min(e.minItems);if(typeof e.maxItems==="number")a=a.max(e.maxItems);o=a}else o=Se.array(Se.any());break}default:throw Error(`Unsupported type: ${r}`)}return o}function er(e,t){if(typeof e==="boolean")return e?Se.any():Se.never();let r=wP(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map((u)=>er(u,t)),c=Se.union(a);r=o?Se.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map((u)=>er(u,t)),c=Se.xor(a);r=o?Se.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:Se.any();else{let a=o?r:er(e.allOf[0],t),c=o?0:1;for(let u=c;u<e.allOf.length;u++)a=Se.intersection(a,er(e.allOf[u],t));r=a}if(e.nullable===!0&&t.version==="openapi-3.0")r=Se.nullable(r);if(e.readOnly===!0)r=Se.readonly(r);if(e.default!==void 0)r=r.default(e.default);let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of i)if(a in e)n[a]=e[a];let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)if(a in e)n[a]=e[a];for(let a of Object.keys(e))if(!dH.has(a))n[a]=e[a];if(Object.keys(n).length>0)t.registry.add(r,n);if(e.description)r=r.describe(e.description);return r}function xP(e,t){if(typeof e==="boolean")return e?Se.any():Se.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=fH(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??qt};return er(r,i)}var Se,dH;var _P=w(()=>{eu();Wp();iu();au();Se={...su,...Vp,iso:qa},dH=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"])});var B_={};Ut(B_,{bigint:()=>yH,boolean:()=>gH,date:()=>bH,number:()=>hH,string:()=>mH});function mH(e){return ox(Ja,e)}function hH(e){return fx(Ha,e)}function gH(e){return Sx(Va,e)}function yH(e){return wx(Wa,e)}function bH(e){return Cx(mu,e)}var EP=w(()=>{Cr();au()});var l={};Ut(l,{$brand:()=>Cb,$input:()=>tx,$output:()=>ex,NEVER:()=>Ob,TimePrecision:()=>sx,ZodAny:()=>Y0,ZodArray:()=>r_,ZodBase64:()=>hm,ZodBase64URL:()=>gm,ZodBigInt:()=>Wa,ZodBigIntFormat:()=>Sm,ZodBoolean:()=>Va,ZodCIDRv4:()=>pm,ZodCIDRv6:()=>mm,ZodCUID:()=>sm,ZodCUID2:()=>am,ZodCatch:()=>E_,ZodCodec:()=>Su,ZodCustom:()=>vu,ZodCustomStringFormat:()=>Ka,ZodDate:()=>mu,ZodDefault:()=>b_,ZodDiscriminatedUnion:()=>o_,ZodE164:()=>ym,ZodEmail:()=>nm,ZodEmoji:()=>om,ZodEnum:()=>Fa,ZodError:()=>nC,ZodExactOptional:()=>h_,ZodFile:()=>p_,ZodFirstPartyTypeKind:()=>L_,ZodFunction:()=>z_,ZodGUID:()=>lu,ZodIPv4:()=>dm,ZodIPv6:()=>fm,ZodISODate:()=>Qp,ZodISODateTime:()=>Gp,ZodISODuration:()=>Xp,ZodISOTime:()=>Yp,ZodIntersection:()=>i_,ZodIssueCode:()=>cH,ZodJWT:()=>bm,ZodKSUID:()=>um,ZodLazy:()=>O_,ZodLiteral:()=>f_,ZodMAC:()=>J0,ZodMap:()=>u_,ZodNaN:()=>k_,ZodNanoID:()=>im,ZodNever:()=>e_,ZodNonOptional:()=>Im,ZodNull:()=>G0,ZodNullable:()=>y_,ZodNumber:()=>Ha,ZodNumberFormat:()=>hs,ZodObject:()=>gu,ZodOptional:()=>Em,ZodPipe:()=>bu,ZodPrefault:()=>v_,ZodPreprocess:()=>A_,ZodPromise:()=>P_,ZodReadonly:()=>T_,ZodRealError:()=>xr,ZodRecord:()=>Ma,ZodSet:()=>d_,ZodString:()=>Ja,ZodStringFormat:()=>Xe,ZodSuccess:()=>__,ZodSymbol:()=>V0,ZodTemplateLiteral:()=>R_,ZodTransform:()=>m_,ZodTuple:()=>a_,ZodType:()=>Be,ZodULID:()=>cm,ZodURL:()=>pu,ZodUUID:()=>Cn,ZodUndefined:()=>W0,ZodUnion:()=>yu,ZodUnknown:()=>X0,ZodVoid:()=>t_,ZodXID:()=>lm,ZodXor:()=>n_,_ZodString:()=>rm,_default:()=>S_,_function:()=>dP,any:()=>qC,array:()=>hu,base64:()=>IC,base64url:()=>kC,bigint:()=>LC,boolean:()=>H0,catch:()=>I_,check:()=>fP,cidrv4:()=>_C,cidrv6:()=>EC,clone:()=>lr,codec:()=>aP,coerce:()=>B_,config:()=>ht,core:()=>so,cuid:()=>hC,cuid2:()=>gC,custom:()=>pP,date:()=>FC,decode:()=>L0,decodeAsync:()=>j0,describe:()=>mP,discriminatedUnion:()=>GC,e164:()=>AC,email:()=>iC,emoji:()=>pC,encode:()=>D0,encodeAsync:()=>B0,endsWith:()=>Pa,enum:()=>xm,exactOptional:()=>g_,file:()=>nP,flattenError:()=>Ul,float32:()=>PC,float64:()=>zC,formatError:()=>ql,fromJSONSchema:()=>xP,function:()=>dP,getErrorMap:()=>uH,globalRegistry:()=>qt,gt:()=>Rn,gte:()=>dr,guid:()=>sC,hash:()=>CC,hex:()=>OC,hostname:()=>RC,httpUrl:()=>fC,includes:()=>Oa,instanceof:()=>gP,int:()=>em,int32:()=>NC,int64:()=>BC,intersection:()=>s_,invertCodec:()=>cP,ipv4:()=>vC,ipv6:()=>xC,iso:()=>qa,json:()=>bP,jwt:()=>TC,keyof:()=>JC,ksuid:()=>SC,lazy:()=>C_,length:()=>ps,literal:()=>rP,locales:()=>Xl,looseObject:()=>VC,looseRecord:()=>YC,lowercase:()=>$a,lt:()=>$n,lte:()=>Or,mac:()=>wC,map:()=>XC,maxLength:()=>fs,maxSize:()=>Yo,meta:()=>hP,mime:()=>za,minLength:()=>io,minSize:()=>On,multipleOf:()=>Qo,nan:()=>sP,nanoid:()=>mC,nativeEnum:()=>tP,negative:()=>Zp,never:()=>vm,nonnegative:()=>qp,nonoptional:()=>x_,nonpositive:()=>Up,normalize:()=>Na,null:()=>Q0,nullable:()=>du,nullish:()=>oP,number:()=>K0,object:()=>KC,optional:()=>uu,overwrite:()=>an,parse:()=>C0,parseAsync:()=>P0,partialRecord:()=>QC,pipe:()=>tm,positive:()=>jp,prefault:()=>w_,preprocess:()=>SP,prettifyError:()=>Fb,promise:()=>uP,property:()=>Mp,readonly:()=>$_,record:()=>l_,refine:()=>N_,regex:()=>Ta,regexes:()=>Rr,registry:()=>bp,safeDecode:()=>U0,safeDecodeAsync:()=>M0,safeEncode:()=>Z0,safeEncodeAsync:()=>q0,safeParse:()=>z0,safeParseAsync:()=>N0,set:()=>eP,setErrorMap:()=>lH,size:()=>ds,slugify:()=>ja,startsWith:()=>Ca,strictObject:()=>HC,string:()=>cu,stringFormat:()=>$C,stringbool:()=>yP,success:()=>iP,superRefine:()=>D_,symbol:()=>ZC,templateLiteral:()=>lP,toJSONSchema:()=>Hp,toLowerCase:()=>La,toUpperCase:()=>Ba,transform:()=>_m,treeifyError:()=>Mb,trim:()=>Da,tuple:()=>c_,uint32:()=>DC,uint64:()=>jC,ulid:()=>yC,undefined:()=>UC,union:()=>wm,unknown:()=>ms,uppercase:()=>Ra,url:()=>dC,util:()=>ue,uuid:()=>aC,uuidv4:()=>cC,uuidv6:()=>lC,uuidv7:()=>uC,void:()=>MC,xid:()=>bC,xor:()=>WC});var j_=w(()=>{Cr();Cr();uw();Cr();ou();_P();Xw();iu();iu();EP();au();Wp();O0();F0();vP();ht(Wl())});var IP=w(()=>{j_();j_()});var Z_=w(()=>{IP()});var he=w(()=>{Z_()});var U_,kP;var q_=w(()=>{he();U_=l.object({title:l.string().trim().min(1).max(500).optional(),introduction:l.string().trim().min(1).max(4000).optional(),topics:l.array(l.string().trim().min(1).max(500)).max(20).optional(),topicsHeading:l.string().trim().min(1).max(120).optional(),contactLabel:l.string().trim().min(1).max(80).optional(),contactNote:l.string().trim().min(1).max(240).optional(),mapCaption:l.string().trim().min(1).max(160).optional(),refusal:l.string().trim().min(1).max(500).optional(),faqHeading:l.string().trim().min(1).max(120).optional()}),kP=U_.omit({introduction:!0})});function km(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function TP(e){let t=Reflect.get(os,"types"),r=km(t)?t[e]:void 0;if(!(r instanceof ha))throw Error(`Required YAML type is unavailable: ${e}`);return r}function wH(e,t){let r=0,o=1;for(let n of e.split(":").reverse())r+=(t?Number.parseFloat(n):Number.parseInt(n,10))*o,o*=60;return r}function AP(e){let t=TP(e);return new ha(`tag:yaml.org,2002:${e}`,{kind:"scalar",resolve:(r)=>typeof r==="string"&&(e==="int"?SH:vH).test(r)&&!r.endsWith("_"),construct:(r)=>{let o=r.replace(/_/g,""),n=o.startsWith("-")?-1:1,i=o.replace(/^[+-]/,"");if(i.includes(":"))return n*wH(i,e==="float");if(e==="int"&&i==="0")return 0;if(e==="int"&&/^0[0-7]+$/.test(i))return n*Number.parseInt(i,8);return t.construct(o)},predicate:t.predicate??void 0,represent:t.represent??void 0,defaultStyle:t.defaultStyle??void 0})}var SH,vH,M_,xH,_H,EH;var $P=w(()=>{ya();SH=/^[+-]?(?:0|0b[01_]*[01]|0x[\da-fA-F_]*[\da-fA-F]|0[0-7_]*[0-7]|[1-9](?:[\d_]*\d)?|[1-9][\d_]*(?::[0-5]?\d)+)$/,vH=/^(?:[-+]?(?:0|[1-9][\d_]*)(?:\.[\d_]*)?(?:[eE][-+]?\d+)?|\.[\d_]+(?:[eE][-+]?\d+)?|[-+]?\d[\d_]*(?::[0-5]?\d)+\.[\d_]*|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/;M_=TP("binary"),xH=new ha("tag:yaml.org,2002:binary",{kind:"scalar",resolve:(e)=>M_.resolve(e),construct:(e)=>{let t=M_.construct(e);if(!(t instanceof Uint8Array))throw Error("Invalid YAML binary result");return typeof Buffer>"u"?Array.from(t):Buffer.from(t)},predicate:(e)=>typeof Buffer<"u"&&Buffer.isBuffer(e),represent:M_.represent??void 0}),_H=new ha("tag:yaml.org,2002:str",{kind:"scalar",resolve:(e)=>typeof e==="string"&&e.includes(":"),construct:(e)=>e}),EH=Rb.extend({implicit:[AP("int"),AP("float"),_H],explicit:[xH]})});var F_=w(()=>{ya();$P()});var RP,OP,CP,kH;var J_=w(()=>{F_();he();RP=l.object({audiences:l.array(l.string()).optional(),positioning:l.string().optional()}),OP=l.object({summary:l.string().optional(),traits:l.array(l.string()).optional(),principles:l.array(l.string()).optional(),preferredTerms:l.array(l.string()).optional(),avoid:l.array(l.string()).optional()}),CP=l.object({artDirection:l.string().optional(),palette:l.array(l.string()).optional(),composition:l.string().optional(),mood:l.string().optional(),preferred:l.array(l.string()).optional(),avoid:l.array(l.string()).optional()}),kH=l.object({name:l.string().describe("Style guide name"),messaging:RP.optional(),voice:OP.optional(),visual:CP.optional()})});var zP=w(()=>{F_();q_();J_()});var AH,Am,Xye,K_="data-ask-sheet",TH;var H_=w(()=>{he();AH=l.object({public:l.boolean(),preview:l.boolean()}),Am=l.object({name:l.string().trim().min(1).max(200),url:l.string().url().optional()}),Xye=l.object({sources:l.array(l.object({id:l.string(),title:l.string(),brain:Am.optional()}))}),TH=`body *:not([${K_}], [${K_}] *) { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }`});var ri;var Tm=w(()=>{he();ri=l.discriminatedUnion("kind",[l.object({kind:l.literal("user"),userId:l.string().min(1),canonicalId:l.string().min(1).optional()}),l.object({kind:l.literal("external"),externalActorId:l.string().min(1)}),l.object({kind:l.literal("agent"),agentId:l.string().min(1)}),l.object({kind:l.literal("service"),serviceId:l.string().min(1)})])});var $H,obe,Ga,RH,OH,NP,ibe,CH,PH,DP;var LP=w(()=>{he();$H=l.strictObject({messageCharacters:l.number().int().positive(),requestTimeoutSeconds:l.number().int().positive().max(2147483)}),obe=l.strictObject({limits:$H,maxCostMicroUsd:l.number().int().positive()}),Ga=l.number().int().nonnegative(),RH=l.strictObject({modelCalls:Ga,inputTokens:Ga,cachedInputTokens:Ga,outputTokens:Ga,reasoningTokens:Ga,embeddingTokens:Ga}),OH=l.discriminatedUnion("state",[l.strictObject({state:l.literal("known"),microUsd:l.number().int().nonnegative(),pricing:l.string().trim().min(1).max(120)}),l.strictObject({state:l.literal("unknown"),reason:l.enum(["missing-usage","unsupported-pricing"])})]),NP=l.strictObject({usage:RH,cost:OH}),ibe=l.strictObject({topics:l.array(l.string().trim().min(1).max(500)).max(20),introduction:l.string().trim().min(1).max(4000).optional(),refusal:l.string().trim().min(1).max(500).optional()}),CH=l.enum(["in-scope","off-topic","abusive","injection","harmful"]),PH=CH.exclude(["in-scope"]),DP=l.discriminatedUnion("outcome",[l.strictObject({outcome:l.literal("answered")}),l.strictObject({outcome:l.literal("refused"),category:PH}),l.strictObject({outcome:l.literal("unscreened")})])});function NH(e){let t=zH.safeParse(e);if(!t.success)return e;return{...t.data,cards:t.data.cards.filter((r)=>V_.safeParse(r).success)}}var BP,jP,ZP,UP,qP,MP,Qa,FP,JP,KP,HP,VP,V_,WP,GP,QP,zH,YP;var wu=w(()=>{he();H_();LP();BP=l.object({id:l.string(),toolCallId:l.string().optional(),toolName:l.string(),summary:l.string(),completionSummary:l.string().optional(),preview:l.string().optional(),args:l.unknown()}),jP=l.enum(["approval-requested","approval-responded","output-available","output-denied","output-error"]),ZP=l.object({kind:l.literal("tool-approval"),id:l.string(),toolCallId:l.string().optional(),toolName:l.string(),input:l.record(l.string(),l.unknown()).optional(),summary:l.string(),completionSummary:l.string().optional(),preview:l.string().optional(),state:jP,output:l.unknown().optional(),error:l.string().optional()}),UP=l.object({entityType:l.string().optional(),entityId:l.string().optional(),attachmentType:l.string().optional()}),qP=l.object({mediaType:l.string().min(1),url:l.string().min(1),downloadUrl:l.string().min(1).optional(),previewUrl:l.string().min(1).optional(),filename:l.string().min(1).optional(),sizeBytes:l.number().nonnegative().optional(),source:UP.optional()}),MP=l.object({kind:l.literal("attachment"),id:l.string(),jobId:l.string().optional(),title:l.string(),description:l.string().optional(),attachment:qP}),Qa=l.object({id:l.string().min(1),title:l.string().min(1).optional(),source:l.string().min(1),url:l.string().min(1).optional(),entityType:l.string().min(1).optional(),entityId:l.string().min(1).optional(),excerpt:l.string().min(1).optional(),provenance:l.record(l.string(),l.unknown()).optional(),brain:Am.optional()}),FP=l.object({kind:l.literal("sources"),id:l.string().min(1),title:l.string().min(1).optional(),sources:l.array(Qa).min(1)}),JP=l.object({type:l.literal("prompt"),id:l.string().min(1),label:l.string().min(1),prompt:l.string().min(1),description:l.string().min(1).optional()}),KP=l.object({type:l.literal("event"),id:l.string().min(1),label:l.string().min(1),event:l.string().min(1),fromState:l.string().min(1).optional(),description:l.string().min(1).optional()}),HP=l.discriminatedUnion("type",[JP,KP]),VP=l.object({kind:l.literal("actions"),id:l.string().min(1),title:l.string().min(1).optional(),defaultOpen:l.boolean().optional(),actions:l.array(HP).min(1)}),V_=l.discriminatedUnion("kind",[ZP,MP,FP,VP]),WP=l.object({toolName:l.string(),args:l.record(l.string(),l.unknown()).optional(),jobId:l.string().optional(),data:l.unknown().optional(),error:l.object({message:l.string(),code:l.string().optional()}).optional()}),GP=l.object({faqId:l.string().min(1)}),QP=l.object({text:l.string(),error:l.string().optional(),toolResults:l.array(WP).optional(),cards:l.array(V_).optional(),pendingConfirmations:l.array(BP).optional(),usage:l.object({promptTokens:l.number(),completionTokens:l.number(),totalTokens:l.number()}),guestSettlement:NP.optional(),guestScreening:DP.optional(),askedBefore:GP.optional()}),zH=l.looseObject({cards:l.array(l.unknown())});YP=l.preprocess((e)=>NH(Mf(e)),QP)});function _e(e){return Object.freeze({name:e.channel,schema:e.request,response:e.response,delivery:e.delivery})}var W_,DH,LH,XP,BH,jH,ZH,UH;var ez=w(()=>{he();Tm();wu();W_=l.object({state:l.string(),response:l.string(),sources:l.array(Qa)}),DH=l.object({agent:l.string().trim().min(1).max(253),question:l.string().trim().min(1).max(4000)}),LH=_e({channel:"a2a:ask:request",request:DH,response:W_,delivery:"request"}),XP=l.object({entityType:l.string().optional(),entityId:l.string().optional(),actor:ri.optional(),interfaceType:l.string().optional(),userPermissionLevel:l.enum(["admin","trusted","public"])}),BH=l.object({agent:l.string().trim().min(1).max(253),instruction:l.string().trim().min(1).max(2000),selection:l.string().min(1).max(8000),...XP.shape}),jH=_e({channel:"a2a:call:request",request:BH,response:W_,delivery:"request"}),ZH=l.object({agents:l.array(l.object({id:l.string(),label:l.string()}))}),UH=_e({channel:"a2a:call:agents",request:XP,response:ZH,delivery:"request"})});var qH,tz,MH,FH;var rz=w(()=>{he();wu();qH=l.object({type:l.literal("event"),event:l.string().min(1),fromState:l.string().min(1).optional()}),tz=l.object({conversationId:l.string().min(1),interfaceType:l.string().min(1),channelId:l.string().min(1).optional(),channelName:l.string().min(1),userPermissionLevel:l.enum(["admin","trusted","public"]),isAnchor:l.boolean(),action:qH}),MH=YP.nullable(),FH=_e({channel:"agent:action:request",request:tz,response:MH,delivery:"request"})});var nz,JH,oz,KH;var iz=w(()=>{he();wu();nz=l.object({question:l.string().trim().min(1)}),JH=l.object({faqId:l.string().min(1),faqQuestion:l.string().min(1),answer:l.string().trim().min(1),sources:l.array(Qa).default([])}),oz=l.object({hit:JH.optional()}),KH=_e({channel:"guest:asked-before",request:nz,response:oz,delivery:"collect"})});var HH,sz,az,Tbe,VH,WH;var cz=w(()=>{he();HH=l.enum(["admin","trusted","public"]),sz=l.object({conversationId:l.string().min(1),message:l.string(),interfaceType:l.string().min(1),channelId:l.string().optional(),channelName:l.string().optional(),userPermissionLevel:HH}),az=l.object({id:l.string().min(1),source:l.string().min(1),title:l.string().optional(),content:l.string().min(1),provenance:l.record(l.string(),l.unknown()).optional()}),Tbe=l.object({items:l.array(az).default([])}),VH=l.object({items:l.array(l.unknown()).default([]).transform((e)=>e.flatMap((t)=>{let r=az.safeParse(t);return r.success?[r.data]:[]}))}),WH=_e({channel:"agent:context:request",request:sz,response:VH,delivery:"collect"})});var GH,QH;var lz=w(()=>{he();GH=l.strictObject({entityType:l.string().min(1),entityId:l.string().min(1)}),QH=l.strictObject({startedAt:l.string().datetime(),retrieved:l.array(GH).max(50)})});var uz,YH,dz,XH;var fz=w(()=>{he();Tm();uz=l.object({actor:ri}),YH=l.object({userId:l.string().min(1),personId:l.string().min(1),canonicalId:l.string().min(1).optional(),displayName:l.string().min(1),permissionLevel:l.enum(["admin","trusted","public"])}),dz=l.object({principal:YH.nullable()}),XH=_e({channel:"auth:principal:resolve",request:uz,response:dz,delivery:"request"})});var pz=()=>{};var mz=()=>{};var G_,eV,hz,tV,rV;var gz=w(()=>{he();G_=l.strictObject({name:l.string().min(1).optional(),address:l.email()}),eV=l.strictObject({personId:l.string().min(1).max(200),displayName:l.string().trim().min(1).max(200),permissionLevel:l.enum(["admin","trusted","public"])}),hz=l.strictObject({messageId:l.string().min(1),sourceRef:l.string().min(1),threadId:l.string().min(1).optional(),from:G_,replyTo:G_.optional(),to:l.array(G_),subject:l.string(),receivedAt:l.iso.datetime(),text:l.string(),html:l.string().min(1).optional(),headers:l.strictObject({listUnsubscribe:l.string().min(1).optional(),autoSubmitted:l.string().min(1).optional(),precedence:l.string().min(1).optional(),inReplyTo:l.string().min(1).optional(),references:l.array(l.string().min(1)).optional()}),sender:eV.optional()}),tV=l.strictObject({}),rV=_e({channel:"email:inbound",request:hz,response:tV,delivery:"request"})});var nV,oV,yz,Q_,iV,bz,sV;var Sz=w(()=>{he();nV=l.strictObject({permissionLevel:l.enum(["admin","trusted","public"])}),oV=l.custom((e)=>typeof AbortSignal<"u"&&e instanceof AbortSignal),yz=l.strictObject({sourceRef:l.string().regex(/^imap:[a-f0-9]{64}$/),actor:nV,signal:oV.optional()}),Q_=l.strictObject({name:l.string().trim().min(1).max(300).optional(),address:l.email().max(320)}),iV=l.strictObject({messageId:l.string().trim().min(1).max(2000),from:Q_,replyTo:Q_.optional(),to:l.array(Q_).max(100),subject:l.string().max(1000),receivedAt:l.iso.datetime(),text:l.string().max(1e5),inReplyTo:l.string().trim().min(1).max(2000).optional(),references:l.array(l.string().trim().min(1).max(2000)).max(100),truncated:l.boolean()}),bz=l.discriminatedUnion("kind",[l.strictObject({kind:l.literal("available"),message:iV}),l.strictObject({kind:l.literal("unavailable")})]),sV=_e({channel:"email:source-read",request:yz,response:bz,delivery:"request"})});var vz=()=>{};var wz=w(()=>{vz()});var aV;var xz=w(()=>{he();aV=l.object({url:l.string(),authToken:l.string().optional()})});var cV;var _z=w(()=>{he();cV=l.object({success:l.boolean(),entityId:l.string().optional(),error:l.string().optional()})});var Ez=()=>{};function Y_(e,t="handler_failed"){let r=t,o;try{if(e!==null&&typeof e==="object"){let n=xu.safeParse(Reflect.get(e,"code"));if(n.success)r=n.data,o=$m.shape.message.safeParse(Reflect.get(e,"publicMessage")).data;else{let i=Reflect.get(e,"name");if(i==="AbortError")r="cancelled";if(i==="TimeoutError")r="deadline_exceeded"}}}catch{}return new Ya(r,{cause:e,...o!==void 0?{publicMessage:o}:{}})}var xu,kz=1024,$m,Iz,Ya;var Az=w(()=>{he();xu=l.enum(["no_handler","handler_failed","invalid_input","invalid_response","unauthenticated","permission_denied","not_found","conflict","cancelled","deadline_exceeded"]),$m=l.object({code:xu,message:l.string().max(kz)}),Iz={no_handler:"No handler is available for this capability",handler_failed:"The operation failed",invalid_input:"Invalid input",invalid_response:"Invalid response",unauthenticated:"Authentication required",permission_denied:"Permission denied",not_found:"Not found",conflict:"The operation conflicts with the current state",cancelled:"The operation was cancelled",deadline_exceeded:"The execution deadline was exceeded"};Ya=class Ya extends Error{code;publicMessage;constructor(e,t={}){let r=xu.parse(e),o=$m.shape.message.parse(t.publicMessage??Iz[r]);super(t.message??o,{cause:t.cause});this.name="SdkError",this.code=r,this.publicMessage=o}toJSON(){let e=xu.safeParse(this.code),t=e.data??"handler_failed",r=e.success?$m.shape.message.safeParse(this.publicMessage).data:void 0;return{code:t,message:r??Iz[t]}}}});var Rm,Om;var X_=w(()=>{he();Rm=l.lazy(()=>l.union([l.null(),l.boolean(),l.number().finite().refine((e)=>!Number.isInteger(e)||Number.isSafeInteger(e),{message:"integer exceeds the JSON-safe range"}),l.string(),l.array(Rm),l.record(l.string(),Rm)])),Om=l.record(l.string(),Rm)});var lV;var Tz=w(()=>{he();lV=l.enum(["user","assistant"])});var uV,ni;var $z=w(()=>{he();uV=l.object({entityType:l.string().min(1),entityId:l.string().min(1),contentHash:l.string().min(1).optional()}),ni=l.object({rootJobId:l.string().min(1),causationId:l.string().min(1),projectionId:l.string().min(1).optional(),projectionLineage:l.array(l.string().min(1)),sourceEntity:uV.optional(),derivationDepth:l.number().int().nonnegative()}).superRefine((e,t)=>{if(e.derivationDepth!==e.projectionLineage.length)t.addIssue({code:"custom",path:["derivationDepth"],message:"Derivation depth must equal projection lineage length"});let r=e.projectionLineage.at(-1);if(e.projectionId!==r)t.addIssue({code:"custom",path:["projectionId"],message:"Current projection must equal the final projection lineage entry"})})});var eE=10,Rz=82,tE,dV,fV,pV,mV,hV,gV;var Oz=w(()=>{he();tE=l.object({title:l.string().min(1).max(200),lines:l.array(l.string().min(1)).min(1).max(eE),actions:l.array(l.object({label:l.string().min(1).max(80),value:l.string().min(1).max(Rz)})).max(eE)}),dV=tE.extend({channelId:l.string().min(1),interfaceType:l.string().min(1),reactions:l.array(l.object({messageId:l.string().min(1),emoji:l.string().min(1)}))}),fV=l.object({messageId:l.string().min(1)}),pV=l.object({conversationId:l.string().min(1),noticeMessageId:l.string().min(1),value:l.string().min(1),by:l.string().min(1)}),mV=_e({channel:"chat:space-notice",request:dV,response:fV,delivery:"request"}),hV=tE.nullable(),gV=_e({channel:"chat:space-notice-action",request:pV,response:hV,delivery:"collect"})});function oi(e,t){return Object.freeze({name:e,schema:t})}var pSe;var rE=w(()=>{he();pSe=l.object({name:l.string(),schema:l.custom((e)=>typeof e==="object"&&e!==null&&("safeParse"in e))})});var nE,oE,yV,bV,SV,vV;var Cz=w(()=>{he();rE();nE={progress:"job-progress"},oE={completed:"publish:completed",failed:"publish:failed"},yV=l.object({entityType:l.string().min(1),entityId:l.string().min(1),result:l.object({id:l.string(),url:l.string().optional()})}),bV=l.object({entityType:l.string().min(1),entityId:l.string().min(1),error:l.string(),retryCount:l.number(),willRetry:l.boolean()}),SV=oi(oE.completed,yV),vV=oi(oE.failed,bV)});var Pz,zz,wV;var Nz=w(()=>{he();Pz=l.object({entityType:l.string().min(1),entityId:l.string(),metadata:l.record(l.string(),l.unknown()).default({}),content:l.string().default("")}),zz=l.object({relativePath:l.string(),leaf:l.object({start:l.number().int().nonnegative(),end:l.number().int().nonnegative()}).nullable(),owner:l.object({entityType:l.string(),id:l.string()}).optional(),writable:l.boolean().optional()}),wV=_e({channel:"sync:path:request",request:Pz,response:zz,delivery:"request"})});var xV,_V,EV,IV;var Dz=w(()=>{he();xV=l.strictObject({}),_V=l.object({branch:l.string(),hasChanges:l.boolean(),ahead:l.number(),behind:l.number(),lastCommit:l.string().nullable(),remote:l.string().nullable()}),EV=l.object({syncPath:l.string(),isInitialized:l.boolean(),watchEnabled:l.boolean(),lastSync:l.string().nullable(),totalFiles:l.number(),byEntityType:l.record(l.string(),l.number()),git:_V.nullable(),managementUrl:l.string().optional()}),IV=_e({channel:"sync:status:request",request:xV,response:EV,delivery:"request"})});var Lz=()=>{};var Bz,kV,AV;var jz=w(()=>{he();Bz=l.strictObject({waveId:l.string().trim().min(1),sourceTypes:l.array(l.string().trim().min(1)),changedTargetTypes:l.array(l.string().trim().min(1))}),kV=l.strictObject({}),AV=_e({channel:"projection:wave-ready",request:Bz,response:kV,delivery:"collect"})});var TV,$V,RV;var Zz=w(()=>{he();TV=l.strictObject({}),$V=l.string(),RV=_e({channel:"plugin:site-builder:head-scripts",request:TV,response:$V,delivery:"collect"})});function Uz(e){return typeof e==="function"}var qz=".site-build-manifest.json",OV,CV,PV;var Mz=w(()=>{he();OV=`/${qz}`;CV=l.object({outputDir:l.string(),environment:l.enum(["preview","production"]),routesBuilt:l.number(),siteConfig:l.object({title:l.string().optional(),description:l.string().optional(),url:l.string().optional(),copyright:l.string().optional(),themeMode:l.enum(["light","dark"]).optional()}),generateEntityUrl:l.custom(Uz),reportFailure:l.custom(Uz)}),PV=_e({channel:"site:build:staging",request:CV,response:l.void(),delivery:"command"})});var zV,NV,DV;var Fz=w(()=>{he();zV=l.object({id:l.string().min(1),trigger:l.string().min(1),playbookId:l.string().min(1),once:l.boolean().default(!0),starterText:l.string().min(1),description:l.string().min(1).optional(),starterPrompt:l.string().min(1)}).strict(),NV=l.object({registered:l.boolean(),id:l.string(),ignored:l.boolean().optional(),reason:l.string().optional()}),DV=_e({channel:"playbooks:register-lifecycle-starter",request:zV,response:NV,delivery:"request"})});var LV,BV,jV;var Jz=w(()=>{he();LV=l.object({id:l.string().min(1),markdown:l.string().min(1)}).strict(),BV=l.object({created:l.boolean()}),jV=_e({channel:"playbooks:seed",request:LV,response:BV,delivery:"request"})});var Kz,Cm,iE,Hz,Vz,ZV,UV;var Wz=w(()=>{he();Kz=["name","headline","industry","location","website","story"],Cm=l.enum(Kz),iE=l.object({name:l.string().optional(),headline:l.string().optional(),industry:l.string().optional(),location:l.string().optional(),website:l.string().optional(),story:l.string().optional()}),Hz=l.enum(["fill","preserve","unchanged"]),Vz=l.object({field:Cm,current:l.string().nullable(),imported:l.string(),outcome:Hz}),ZV=_e({channel:"@brains/profile:import-preview",request:l.object({fields:iE}),response:l.object({fields:l.array(Vz),changed:l.boolean(),revision:l.string()}),delivery:"request"}),UV=_e({channel:"@brains/profile:import-apply",request:l.object({fields:iE,revision:l.string()}),response:l.object({filled:l.array(Cm),kept:l.array(Cm)}),delivery:"request"})});function FV(e){return typeof e==="object"&&e!==null&&"name"in e&&typeof e.name==="string"&&"publish"in e&&typeof e.publish==="function"}var qV,MV,JV,KV,HV,VV,Gz,WV;var Qz=w(()=>{he();qV=l.enum(["provider"]),MV=l.object({executionMode:qV.optional(),publishResultIdField:l.string().min(1).optional(),publishTimestampField:l.string().min(1).optional(),enabled:l.boolean().optional()}).strict();JV=l.custom(FV),KV=l.object({entityType:l.string(),provider:JV.optional(),config:MV.optional()}),HV=_e({channel:"publish:register",request:KV,response:l.void(),delivery:"command"}),VV=l.union([l.string().min(1),l.object({location:l.enum(["metadata","frontmatter"]),field:l.string().min(1)})]),Gz=l.object({entityType:l.string().min(1),attachmentType:l.string().min(1),mediaEntityType:l.enum(["image"]),targetEntityField:VV.optional(),requiredWhen:l.object({status:l.string().min(1).optional(),visibility:l.string().min(1).optional()}).optional(),autoGenerate:l.boolean().optional(),requiredForPublish:l.boolean().optional()}),WV=_e({channel:"publish-assets:register",request:Gz,response:l.void(),delivery:"command"})});var GV,QV,YV,XV,e9,t9;var Yz=w(()=>{he();GV=l.object({entityType:l.string()}),QV=_e({channel:"generate:execute",request:GV,response:l.void(),delivery:"command"}),YV=l.object({entityType:l.string(),entityId:l.string()}),XV=_e({channel:"generate:report:success",request:YV,response:l.void(),delivery:"command"}),e9=l.object({entityType:l.string(),error:l.string()}),t9=_e({channel:"generate:report:failure",request:e9,response:l.void(),delivery:"command"})});var r9,Xz,eN,tN;var rN=w(()=>{he();r9=l.object({message:l.string().describe("Natural language response to the query"),summary:l.string().optional().describe("Brief summary if applicable"),topics:l.array(l.string()).optional().describe("Related topics mentioned"),sources:l.array(l.object({id:l.string(),type:l.string(),excerpt:l.string().optional(),relevance:l.number().min(0).max(1).optional()})).optional().describe("Source entities used to answer the query"),metadata:l.record(l.string(),l.unknown()).optional()}).describe("defaultQueryResponse"),Xz=l.object({message:l.string()}).describe("simpleTextResponse"),eN=l.object({success:l.boolean(),entityId:l.string().optional(),message:l.string()}).describe("createEntityResponse"),tN=l.object({success:l.boolean(),entityId:l.string(),changes:l.array(l.string()).optional(),message:l.string()}).describe("updateEntityResponse")});var nN,oN,n9,iN,sN,o9;var aN=w(()=>{he();nN=l.discriminatedUnion("type",[l.strictObject({type:l.literal("email"),address:l.email()})]),oN=l.strictObject({recipient:nN.optional(),title:l.string().min(1),body:l.string().min(1),html:l.string().min(1).optional(),sensitivity:l.enum(["normal","secret"]).default("normal"),idempotencyKey:l.string().trim().min(1).max(200).optional(),replyTo:l.email().optional()}),n9=l.enum(["recipient-missing","transport-missing","delivery-failed"]),iN=l.string().regex(/^[a-z0-9_:.-]{1,80}$/u),sN=l.discriminatedUnion("status",[l.strictObject({status:l.literal("sent"),deliveryId:l.string().optional()}),l.strictObject({status:l.literal("failed"),failure:n9,transportCode:iN.optional()})]),o9=_e({channel:"notifications:send",request:oN,response:sN,delivery:"request"})});var i9,cN,s9;var lN=w(()=>{he();i9=l.strictObject({}),cN=l.strictObject({titles:l.array(l.string().trim().min(1).max(500)).max(20)}),s9=_e({channel:"topics:public-titles",request:i9,response:cN,delivery:"request"})});var a9,c9,l9;var uN=w(()=>{he();a9=l.strictObject({}),c9=l.strictObject({types:l.array(l.string().trim().min(1))}),l9=_e({channel:"topics:source-types",request:a9,response:c9,delivery:"request"})});var dN,fN,u9;var pN=w(()=>{he();dN=l.strictObject({id:l.string().regex(/^[a-z0-9][a-z0-9-]{0,79}$/),title:l.string().trim().min(1).max(200),body:l.string().trim().min(1).max(20000)}),fN=l.strictObject({noteId:l.string(),created:l.boolean()}),u9=_e({channel:"note:capture",request:dN,response:fN,delivery:"request"})});var Xa,_u,d9,f9,p9,m9,h9;var mN=w(()=>{he();X_();Xa=l.string().regex(/^[a-z][a-z0-9-]{0,63}$/),_u=l.string().min(32).max(512),d9=l.strictObject({provider:Xa,brainState:_u}),f9=l.strictObject({authorizationUrl:l.url({protocol:/^https?$/})}),p9=l.strictObject({provider:Xa,grant:_u}),m9=l.strictObject({provider:Xa,credential:Om}),h9=l.union([l.strictObject({provider:Xa,state:_u,grant:_u}),l.strictObject({provider:Xa,state:_u,error:l.enum(["provider_denied","authorization_incomplete","credential_exchange_failed"])})])});var g9,y9,b9,S9;var hN=w(()=>{he();g9=l.object({permissionLevel:l.enum(["public","trusted","admin"])}),y9=l.object({id:l.string().min(1),title:l.string().min(1),sub:l.string().optional(),href:l.string().min(1),primary:l.boolean().optional(),keywords:l.array(l.string()).optional()}),b9=l.array(y9),S9=_e({channel:"console:jump-destinations",request:g9,response:b9,delivery:"collect"})});var Pm,sE;var gN=w(()=>{he();Pm=l.enum(["github","instagram","linkedin","podcast","email","website"]),sE=l.object({platform:Pm.describe("Social media platform"),url:l.string().describe("Profile or contact URL"),label:l.string().optional().describe("Optional display label")})});function zm(e){if(!e.type.includes(":"))throw Error(`Job contract type "${e.type}" must name its owner, as "owner:job"`);return Object.freeze({type:e.type,input:e.input})}var yN,bN,v9,SN,w9;var vN=w(()=>{he();yN=l.enum(["1:1","16:9","9:16","4:3","3:4"]),bN=l.object({prompt:l.string(),title:l.string().optional(),aspectRatio:yN.optional(),targetEntityType:l.string().optional(),targetEntityId:l.string().optional(),entityTitle:l.string().optional(),entityContent:l.string().optional()}),v9=zm({type:"image:image-generate",input:bN}),SN=l.object({sourceEntityType:l.string().min(1),sourceEntityId:l.string().min(1),attachmentType:l.string().min(1),imageId:l.string().min(1),dedupKey:l.string().min(1).optional(),replace:l.boolean().optional(),targetEntityType:l.string().min(1).optional(),targetEntityId:l.string().min(1).optional(),targetImageField:l.enum(["coverImageId","ogImageId"]).optional()}),w9=zm({type:"image:image-render-source",input:SN})});var x9;var wN=w(()=>{he();x9=l.enum(["none","low","medium","high","xhigh","max"])});var Mt=w(()=>{q_();zP();H_();ez();rz();wu();iz();cz();lz();Tm();fz();pz();mz();gz();Sz();wz();xz();_z();Ez();Az();X_();Tz();$z();Oz();Cz();rE();Nz();Dz();Lz();jz();J_();Zz();Mz();Fz();Jz();Wz();Qz();Yz();rN();aN();lN();uN();pN();mN();hN();gN();vN();wN()});var k9,A9,$t,pr,gs,T9,ii="capability-bundles-v1",Dm,$9,R9,O9,C9,xN,Nm,si,qr,P9,z9,N9,D9,L9,aE,B9,j9,Lm;var Pn=w(()=>{Mt();he();k9=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,A9=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,$t=l.string().regex(k9,"expected exact pinned version"),pr=l.string().regex(A9,"expected lowercase handle slug"),gs=l.string().min(1),T9=l.string().startsWith("age1").min(1),Dm=l.enum(["core","media","automation","web","chat","site","publishing","federation","team"]),$9=["professional","team","organization"],R9=l.enum($9),O9=["person","team","organization"],C9=l.enum(O9),xN=l.array(Dm).min(1),Nm=l.array(l.string().min(1)),si=l.strictObject({brainVersion:$t,bundleContract:l.literal(ii),bundles:xN,add:Nm.optional(),remove:Nm.optional(),githubOrg:l.string().min(1),contentRepoPrefix:l.string().min(1),domainSuffix:l.string().min(1),aiApiKey:gs,gitSyncToken:gs,contentRepoAdminToken:gs,agePublicKey:T9}).superRefine((e,t)=>{if(new Set(e.bundles).size!==e.bundles.length)t.addIssue({code:l.ZodIssueCode.custom,path:["bundles"],message:"canonical bundles must be unique"})}),qr=l.strictObject({members:l.array(pr).min(1),brainVersionOverride:$t.optional(),bundlesOverride:xN.optional(),addOverride:Nm.optional(),removeOverride:Nm.optional(),aiApiKeyOverride:gs.optional(),gitSyncTokenOverride:gs.optional()}).superRefine((e,t)=>{if(new Set(e.members).size!==e.members.length)t.addIssue({code:l.ZodIssueCode.custom,path:["members"],message:"cohort members must be unique"});if(e.bundlesOverride&&new Set(e.bundlesOverride).size!==e.bundlesOverride.length)t.addIssue({code:l.ZodIssueCode.custom,path:["bundlesOverride"],message:"canonical bundle overrides must be unique"})}),P9=l.strictObject({platform:Pm,url:l.string().min(1),label:l.string().min(1).optional()}),z9=l.strictObject({name:l.string().min(1).optional(),description:l.string().min(1).optional(),website:l.string().min(1).optional(),email:l.string().min(1).optional(),story:l.string().min(1).optional(),socialLinks:l.array(P9).optional()}),N9=l.strictObject({delivery:l.literal("email"),email:l.string().email()}),D9=l.strictObject({enabled:l.boolean().optional(),endpoint:l.string().url().refine((e)=>new URL(e).protocol==="wss:",{message:"Jetstream endpoint must use wss"}).optional(),replayWindowSeconds:l.number().int().min(60).optional(),denyDids:l.array(l.string().startsWith("did:plc:")).optional(),denyDomains:l.array(l.string().min(1)).optional(),skillKeywords:l.array(l.string().min(1)).optional(),queueLimit:l.number().int().min(1).max(1e4).optional(),concurrency:l.number().int().min(1).max(32).optional(),perDidCooldownSeconds:l.number().int().nonnegative().optional(),fetchBudgetPerMinute:l.number().int().min(1).optional(),newAgentsPerHour:l.number().int().min(1).optional(),pendingCandidateCeiling:l.number().int().min(1).optional(),staleCandidateRetentionDays:l.number().int().min(1).optional(),requestTimeoutMs:l.number().int().min(100).optional(),maxResponseBytes:l.number().int().min(1024).optional(),maxRedirects:l.number().int().nonnegative().optional(),retryAttempts:l.number().int().min(1).optional(),heartbeatIntervalHours:l.number().min(1).optional()}),L9=l.strictObject({identifier:l.string().min(1),accountDid:l.string().min(1).optional(),lexiconAuthority:l.boolean().optional(),jetstream:D9.optional()}),aE=l.strictObject({package:l.string().min(1),version:$t.optional(),theme:l.string().min(1).optional(),themeVersion:$t.optional()}).superRefine((e,t)=>{let r=e.package.startsWith("@rizom/");if(r&&e.version===void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["version"],message:"external @rizom site packages require an exact version pin"});if(!r&&e.version!==void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["version"],message:"version is valid only for external @rizom site packages"});let o=e.theme?.startsWith("@rizom/")===!0;if(o&&e.themeVersion===void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["themeVersion"],message:"external @rizom themes require an exact version pin"});if(!o&&e.themeVersion!==void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["themeVersion"],message:"themeVersion is valid only for external @rizom themes"})}),B9=l.strictObject({onboarding:l.boolean().optional()}),j9=l.record(l.string().min(1),l.record(l.string(),l.unknown())),Lm=l.strictObject({handle:pr,discord:l.strictObject({enabled:l.boolean(),anchorUserId:l.string().min(1).optional()}),aiApiKeyOverride:gs.optional(),gitSyncTokenOverride:gs.optional(),domainOverride:l.string().min(1).optional(),cloudflareZoneId:l.string().min(1).optional(),contentRepoOverride:l.string().min(1).optional(),profileKind:R9.optional(),anchorKind:C9.optional(),plugins:j9.optional(),spaces:l.array(l.string().min(1)).optional(),embeddingEnabled:l.boolean().optional(),topicExtractionEnabled:l.boolean().optional(),skillDerivationEnabled:l.boolean().optional(),swotDerivationEnabled:l.boolean().optional(),addOverride:l.array(l.string().min(1)).optional(),removeOverride:l.array(l.string().min(1)).optional(),siteOverride:aE.optional(),setup:N9.optional(),atproto:L9.optional(),playbooks:B9.optional(),anchorProfile:z9.optional()})});import{access as Z9,readdir as U9,readFile as q9}from"fs/promises";import{basename as cE,join as Eu,relative as M9}from"path";async function ut(e,t={}){let[r,o,n]=await Promise.all([lE(Eu(e,"pilot.yaml"),si),J9(e),K9(e)]),i=H9(o,n),s=n.map((c)=>({id:c.id,members:[...c.data.members].sort(),...ma({brainVersionOverride:c.data.brainVersionOverride,bundlesOverride:c.data.bundlesOverride,addOverride:c.data.addOverride,removeOverride:c.data.removeOverride,aiApiKeyOverride:c.data.aiApiKeyOverride,gitSyncTokenOverride:c.data.gitSyncTokenOverride})})).sort((c,u)=>c.id.localeCompare(u.id)),a=await Promise.all(o.map(async(c)=>{let u=i.get(c.data.handle);if(!u)throw new ys(`User ${c.data.handle} must belong to exactly one cohort`);let d={...F9(c.data,u,r),snapshotStatus:await G9(e,c.data.handle)},f=await t.resolveStatus?.(d);return{...d,serverStatus:f?.serverStatus??"unknown",deployStatus:f?.deployStatus??"unknown",dnsStatus:f?.dnsStatus??"unknown",mcpStatus:f?.mcpStatus??"unknown"}}));return a.sort((c,u)=>c.handle.localeCompare(u.handle)),{pilot:r,cohorts:s,users:a}}function F9(e,t,r){let o=t.data.bundlesOverride===void 0;return{handle:e.handle,cohort:t.id,brainVersion:t.data.brainVersionOverride??r.brainVersion,bundleContract:r.bundleContract,bundles:[...t.data.bundlesOverride??r.bundles],add:_N(t.data.addOverride??(o?r.add:void 0),e.addOverride),remove:_N(t.data.removeOverride??(o?r.remove:void 0),e.removeOverride),domain:e.domainOverride??`${e.handle}${r.domainSuffix}`,...ma({cloudflareZoneId:e.cloudflareZoneId}),contentRepo:e.contentRepoOverride??`${r.contentRepoPrefix}${e.handle}-content`,...ma({profileKind:e.profileKind,anchorKind:e.anchorKind,embeddingEnabled:e.embeddingEnabled,spaces:e.spaces,plugins:e.plugins,topicExtractionEnabled:e.topicExtractionEnabled,skillDerivationEnabled:e.skillDerivationEnabled,swotDerivationEnabled:e.swotDerivationEnabled,siteOverride:e.siteOverride&&{...e.siteOverride}}),discordEnabled:e.discord.enabled,...ma({discordAnchorUserId:e.discord.anchorUserId}),effectiveAiApiKey:e.aiApiKeyOverride??t.data.aiApiKeyOverride??r.aiApiKey,effectiveGitSyncToken:e.gitSyncTokenOverride??t.data.gitSyncTokenOverride??r.gitSyncToken,...ma({setup:e.setup,atproto:e.atproto,playbooks:e.playbooks}),anchorProfile:V9(e.handle,e.anchorProfile)}}function _N(e,t){return Q9([...e??[],...t??[]])}async function J9(e){let t=Eu(e,"users"),r=(await EN(t)).filter((n)=>!cE(n).endsWith(".secrets.yaml"));return(await Promise.all(r.map(async(n)=>{let i=IN(cE(n)),s=await lE(n,Lm);if(s.handle!==i){let a=kN(M9(e,n));throw new ys(`${a} must declare handle: ${i}`)}return{id:i,data:s}}))).sort((n,i)=>n.id.localeCompare(i.id))}async function K9(e){let t=Eu(e,"cohorts"),r=await EN(t);return(await Promise.all(r.map(async(n)=>({id:IN(cE(n)),data:await lE(n,qr)})))).sort((n,i)=>n.id.localeCompare(i.id))}function H9(e,t){let r=new Map(e.map((n)=>[n.data.handle,n])),o=new Map;for(let n of t)for(let i of n.data.members){if(!r.has(i))throw new ys(`Cohort ${n.id} references unknown user ${i}`);if(o.has(i))throw new ys(`User ${i} must belong to exactly one cohort`);o.set(i,n)}for(let n of e)if(!o.has(n.data.handle))throw new ys(`User ${n.data.handle} must belong to exactly one cohort`);return o}function V9(e,t){return{name:t?.name??W9(e),...t?.description?{description:t.description}:{},...t?.website?{website:t.website}:{},...t?.email?{email:t.email}:{},...t?.story?{story:t.story}:{},...t?.socialLinks?{socialLinks:t.socialLinks.map((r)=>({platform:r.platform,url:r.url,...r.label?{label:r.label}:{}}))}:{}}}function W9(e){return e.split("-").filter((t)=>t.length>0).map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function G9(e,t){let r=Eu(e,"users",t,"brain.yaml");try{return await Z9(r),"present"}catch{return"missing"}}async function EN(e){return(await U9(e,{withFileTypes:!0})).filter((r)=>r.isFile()&&r.name.endsWith(".yaml")).map((r)=>Eu(e,r.name)).sort((r,o)=>r.localeCompare(o))}async function lE(e,t){let r=await q9(e,"utf8"),o=sn(r,t);if(!o.ok)throw new ys(`${kN(e)}: ${o.error}`);return o.data}function Q9(e){return[...new Set(e)]}function IN(e){return e.replace(/\.ya?ml$/,"")}function kN(e){return e.replaceAll("\\","/")}var ys;var Mr=w(()=>{no();Pn();ys=class ys extends Error{}});import{mkdir as Y9,writeFile as X9}from"fs/promises";import{join as AN}from"path";async function ao(e,t={}){let o=(t.registry??await ut(e,t)).users.map((i)=>{let s=i.discordEnabled?"on":"off";return[i.handle,i.cohort,i.bundles.join(","),i.add.join(","),i.remove.join(","),i.brainVersion,i.domain,i.contentRepo,s,i.serverStatus,i.deployStatus,i.dnsStatus,i.mcpStatus]}),n=["<!-- generated by brains-ops; do not edit -->","",e7,t7,...o.map((i)=>`| ${i.join(" | ")} |`),""].join(`
213
- `);await Y9(AN(e,"views"),{recursive:!0}),await X9(AN(e,"views","users.md"),n)}var e7="| handle | cohort | bundles | add | remove | brainVersion | domain | contentRepo | discord | serverStatus | deployStatus | dnsStatus | mcpStatus |",t7="| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |";var ec=w(()=>{Mr()});import{spawn as w7}from"child_process";var Lt=async(e,t,r={})=>new Promise((o,n)=>{let i=w7(e,t,{stdio:["pipe","inherit","inherit"],env:r.env?{...process.env,...r.env}:process.env,cwd:r.cwd});if(i.on("error",n),i.on("close",(s)=>{if(s===0){o();return}n(Error(`${e} ${t.join(" ")} exited with code ${s??1}`))}),r.stdin)i.stdin.end(r.stdin);else i.stdin.end()});var zn=()=>{};async function ON(e,t,r=Lt){let o=`${e}:${t.tag}`;try{await r("docker",["run","--rm","--pull","always","--network","none","--read-only","--user","65534:65534","--cap-drop","ALL","--security-opt","no-new-privileges","--entrypoint","bun",o,"-e",x7,"--",JSON.stringify([`@rizom/brain@${t.brainVersion}`,...t.sitePackages])])}catch(n){throw Error(`Cannot verify required packages in ${o}; refusing image reuse. Do not overwrite a deployed tag. Inspect the image inventory and rollout plan.`,{cause:n})}}var x7=`
212
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref"){i(s);continue}}}}function ti(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,d={...u},f=c.ref;if(c.ref=null,f){o(f);let h=e.seen.get(f),b=h.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(b);else Object.assign(u,b);if(Object.assign(u,d),a._zod.parent===f)for(let S in u){if(S==="$ref"||S==="allOf")continue;if(!(S in d))delete u[S]}if(b.$ref&&h.def)for(let S in u){if(S==="$ref"||S==="allOf")continue;if(S in h.def&&JSON.stringify(u[S])===JSON.stringify(h.def[S]))delete u[S]}}let m=a._zod.parent;if(m&&m!==f){o(m);let h=e.seen.get(m);if(h?.schema.$ref){if(u.$ref=h.schema.$ref,h.def)for(let b in u){if(b==="$ref"||b==="allOf")continue;if(b in h.def&&JSON.stringify(u[b])===JSON.stringify(h.def[b]))delete u[b]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())o(a[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;s[c.defId]=c.def}}if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")n.$defs=s;else n.definitions=s;try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ua(t,"input",e.processors),output:Ua(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function fr(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return fr(o.element,r);if(o.type==="set")return fr(o.valueType,r);if(o.type==="lazy")return fr(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return fr(o.innerType,r);if(o.type==="intersection")return fr(o.left,r)||fr(o.right,r);if(o.type==="record"||o.type==="map")return fr(o.keyType,r)||fr(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return fr(o.in,r)||fr(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(fr(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(fr(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(fr(n,r))return!0;if(o.rest&&fr(o.rest,r))return!0;return!1}return!1}var qx=(e,t={})=>(r)=>{let o=Xo({...r,processors:t});return Ve(e,o),ei(o,e),ti(o,e)},Ua=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:i}=o??{},s=Xo({...n??{},target:i,io:t,processors:r});return Ve(e,s),ei(s,e),ti(s,e)};var nu=w(()=>{eu()});function Hp(e,t){if("_idmap"in e){let o=e,n=Xo({...t,processors:Fp}),i={};for(let c of o._idmap.entries()){let[u,d]=c;Ve(d,n)}let s={},a={registry:o,uri:t?.uri,defs:i};n.external=a;for(let c of o._idmap.entries()){let[u,d]=c;ei(n,d),s[u]=ti(n,d)}if(Object.keys(i).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let r=Xo({...t,processors:Fp});return Ve(e,r),ei(r,e),ti(r,e)}var iH,Mx=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(a){if(n.format=iH[a]??a,n.format==="")delete n.format;if(a==="time")delete n.format}if(u)n.contentEncoding=u;if(c&&c.size>0){let d=[...c];if(d.length===1)n.pattern=d[0].source;else if(d.length>1)n.allOf=[...d.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Fx=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;if(typeof a==="string"&&a.includes("int"))n.type="integer";else n.type="number";let f=typeof d==="number"&&d>=(i??Number.NEGATIVE_INFINITY),m=typeof u==="number"&&u<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(h)n.minimum=d,n.exclusiveMinimum=!0;else n.exclusiveMinimum=d;else if(typeof i==="number")n.minimum=i;if(m)if(h)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s==="number")n.maximum=s;if(typeof c==="number")n.multipleOf=c},Jx=(e,t,r,o)=>{r.type="boolean"},Kx=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Hx=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},Vx=(e,t,r,o)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},Wx=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},Gx=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},Qx=(e,t,r,o)=>{r.not={}},Yx=(e,t,r,o)=>{},Xx=(e,t,r,o)=>{},e0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},t0=(e,t,r,o)=>{let n=e._zod.def,i=Nl(n.entries);if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i},r0=(e,t,r,o)=>{let n=e._zod.def,i=[];for(let s of n.values)if(s===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[s];else r.const=s}else{if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";if(i.every((s)=>typeof s==="boolean"))r.type="boolean";if(i.every((s)=>s===null))r.type="null";r.enum=i}},n0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},o0=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},i0=(e,t,r,o)=>{let n=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=e._zod.bag;if(s!==void 0)i.minLength=s;if(a!==void 0)i.maxLength=a;if(c)if(c.length===1)i.contentMediaType=c[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=c.map((u)=>({contentMediaType:u}));else Object.assign(n,i)},s0=(e,t,r,o)=>{r.type="boolean"},a0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},c0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},l0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},u0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},d0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},f0=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s==="number")n.minItems=s;if(typeof a==="number")n.maxItems=a;n.type="array",n.items=Ve(i.element,t,{...o,path:[...o.path,"items"]})},p0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object",n.properties={};let s=i.shape;for(let u in s)n.properties[u]=Ve(s[u],t,{...o,path:[...o.path,"properties",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((u)=>{let d=i.shape[u]._zod;if(t.io==="input")return d.optin===void 0;else return d.optout===void 0}));if(c.size>0)n.required=Array.from(c);if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=Ve(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},Jp=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,c)=>Ve(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));if(i)r.oneOf=s;else r.anyOf=s},m0=(e,t,r,o)=>{let n=e._zod.def,i=Ve(n.left,t,{...o,path:[...o.path,"allOf",0]}),s=Ve(n.right,t,{...o,path:[...o.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c},h0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((m,h)=>Ve(m,t,{...o,path:[...o.path,s,h]})),u=i.rest?Ve(i.rest,t,{...o,path:[...o.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=c,u)n.items=u}else if(t.target==="openapi-3.0"){if(n.items={anyOf:c},u)n.items.anyOf.push(u);if(n.minItems=c.length,!u)n.maxItems=c.length}else if(n.items=c,u)n.additionalItems=u;let{minimum:d,maximum:f}=e._zod.bag;if(typeof d==="number")n.minItems=d;if(typeof f==="number")n.maxItems=f},g0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let d=Ve(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let f of c)n.patternProperties[f.source]=d}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=Ve(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});n.additionalProperties=Ve(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=s._zod.values;if(u){let d=[...u].filter((f)=>typeof f==="string"||typeof f==="number");if(d.length>0)n.required=d}},y0=(e,t,r,o)=>{let n=e._zod.def,i=Ve(n.innerType,t,o),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=n.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},b0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},S0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},v0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io==="input")r._prefault=JSON.parse(JSON.stringify(n.defaultValue))},w0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},x0=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;Ve(s,t,o);let a=t.seen.get(e);a.ref=s},_0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},E0=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Kp=(e,t,r,o)=>{let n=e._zod.def;Ve(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},I0=(e,t,r,o)=>{let n=e._zod.innerType;Ve(n,t,o);let i=t.seen.get(e);i.ref=n},Fp;var ou=w(()=>{nu();Ee();iH={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Fp={string:Mx,number:Fx,boolean:Jx,bigint:Kx,symbol:Hx,null:Vx,undefined:Wx,void:Gx,never:Qx,any:Yx,unknown:Xx,date:e0,enum:t0,literal:r0,nan:n0,template_literal:o0,file:i0,success:s0,custom:a0,function:c0,transform:l0,map:u0,set:d0,array:f0,object:p0,union:Jp,intersection:m0,tuple:h0,record:g0,nullable:y0,nonoptional:b0,default:S0,prefault:v0,catch:w0,pipe:x0,readonly:_0,promise:E0,optional:Kp,lazy:I0}});class k0{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(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";this.ctx=Xo({processors:Fp,target:t,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,t={path:[],schemaPath:[]}){return Ve(e,this.ctx,t)}emit(e,t){if(t){if(t.cycles)this.ctx.cycles=t.cycles;if(t.reused)this.ctx.reused=t.reused;if(t.external)this.ctx.external=t.external}ei(this.ctx,e);let r=ti(this.ctx,e),{"~standard":o,...n}=r;return n}}var X1=w(()=>{ou();nu()});var eC={};var tC=()=>{};var so={};Ut(so,{$ZodAny:()=>xv,$ZodArray:()=>Av,$ZodAsyncError:()=>Tn,$ZodBase64:()=>fv,$ZodBase64URL:()=>pv,$ZodBigInt:()=>mp,$ZodBigIntFormat:()=>bv,$ZodBoolean:()=>Kl,$ZodCIDRv4:()=>lv,$ZodCIDRv6:()=>uv,$ZodCUID:()=>QS,$ZodCUID2:()=>YS,$ZodCatch:()=>Jv,$ZodCheck:()=>rt,$ZodCheckBigIntFormat:()=>kS,$ZodCheckEndsWith:()=>BS,$ZodCheckGreaterThan:()=>sp,$ZodCheckIncludes:()=>DS,$ZodCheckLengthEquals:()=>CS,$ZodCheckLessThan:()=>ip,$ZodCheckLowerCase:()=>zS,$ZodCheckMaxLength:()=>RS,$ZodCheckMaxSize:()=>AS,$ZodCheckMimeType:()=>ZS,$ZodCheckMinLength:()=>OS,$ZodCheckMinSize:()=>TS,$ZodCheckMultipleOf:()=>ES,$ZodCheckNumberFormat:()=>IS,$ZodCheckOverwrite:()=>US,$ZodCheckProperty:()=>jS,$ZodCheckRegex:()=>PS,$ZodCheckSizeEquals:()=>$S,$ZodCheckStartsWith:()=>LS,$ZodCheckStringFormat:()=>ka,$ZodCheckUpperCase:()=>NS,$ZodCodec:()=>Vl,$ZodCustom:()=>Xv,$ZodCustomStringFormat:()=>gv,$ZodDate:()=>kv,$ZodDefault:()=>Uv,$ZodDiscriminatedUnion:()=>Rv,$ZodE164:()=>mv,$ZodEmail:()=>HS,$ZodEmoji:()=>WS,$ZodEncodeError:()=>ss,$ZodEnum:()=>Nv,$ZodError:()=>Zl,$ZodExactOptional:()=>jv,$ZodFile:()=>Lv,$ZodFunction:()=>Gv,$ZodGUID:()=>JS,$ZodIPv4:()=>sv,$ZodIPv6:()=>av,$ZodISODate:()=>nv,$ZodISODateTime:()=>rv,$ZodISODuration:()=>iv,$ZodISOTime:()=>ov,$ZodIntersection:()=>Ov,$ZodJWT:()=>hv,$ZodKSUID:()=>tv,$ZodLazy:()=>Yv,$ZodLiteral:()=>Dv,$ZodMAC:()=>cv,$ZodMap:()=>Pv,$ZodNaN:()=>Kv,$ZodNanoID:()=>GS,$ZodNever:()=>Ev,$ZodNonOptional:()=>Mv,$ZodNull:()=>wv,$ZodNullable:()=>Zv,$ZodNumber:()=>pp,$ZodNumberFormat:()=>yv,$ZodObject:()=>GO,$ZodObjectJIT:()=>Tv,$ZodOptional:()=>gp,$ZodPipe:()=>yp,$ZodPrefault:()=>qv,$ZodPreprocess:()=>Hv,$ZodPromise:()=>Qv,$ZodReadonly:()=>Vv,$ZodRealError:()=>wr,$ZodRecord:()=>Cv,$ZodRegistry:()=>rx,$ZodSet:()=>zv,$ZodString:()=>us,$ZodStringFormat:()=>Ye,$ZodSuccess:()=>Fv,$ZodSymbol:()=>Sv,$ZodTemplateLiteral:()=>Wv,$ZodTransform:()=>Bv,$ZodTuple:()=>hp,$ZodType:()=>Ne,$ZodULID:()=>XS,$ZodURL:()=>VS,$ZodUUID:()=>KS,$ZodUndefined:()=>vv,$ZodUnion:()=>Hl,$ZodUnknown:()=>_v,$ZodVoid:()=>Iv,$ZodXID:()=>ev,$ZodXor:()=>$v,$brand:()=>Cb,$constructor:()=>Z,$input:()=>tx,$output:()=>ex,Doc:()=>cp,JSONSchema:()=>eC,JSONSchemaGenerator:()=>k0,NEVER:()=>Ob,TimePrecision:()=>sx,_any:()=>Ax,_array:()=>zx,_base64:()=>Np,_base64url:()=>Dp,_bigint:()=>vx,_boolean:()=>bx,_catch:()=>XK,_check:()=>Q1,_cidrv4:()=>Pp,_cidrv6:()=>zp,_coercedBigint:()=>wx,_coercedBoolean:()=>Sx,_coercedDate:()=>Cx,_coercedNumber:()=>fx,_coercedString:()=>ox,_cuid:()=>kp,_cuid2:()=>Ap,_custom:()=>Dx,_date:()=>Ox,_decode:()=>Gf,_decodeAsync:()=>Yf,_default:()=>GK,_discriminatedUnion:()=>BK,_e164:()=>Lp,_email:()=>Sp,_emoji:()=>Ep,_encode:()=>Wf,_encodeAsync:()=>Qf,_endsWith:()=>Pa,_enum:()=>FK,_file:()=>Nx,_float32:()=>mx,_float64:()=>hx,_gt:()=>Rn,_gte:()=>dr,_guid:()=>tu,_includes:()=>Oa,_int:()=>px,_int32:()=>gx,_int64:()=>xx,_intersection:()=>jK,_ipv4:()=>Op,_ipv6:()=>Cp,_isoDate:()=>cx,_isoDateTime:()=>ax,_isoDuration:()=>ux,_isoTime:()=>lx,_jwt:()=>Bp,_ksuid:()=>Rp,_lazy:()=>nH,_length:()=>ps,_literal:()=>KK,_lowercase:()=>$a,_lt:()=>$n,_lte:()=>Or,_mac:()=>ix,_map:()=>qK,_max:()=>Or,_maxLength:()=>fs,_maxSize:()=>Yo,_mime:()=>za,_min:()=>dr,_minLength:()=>io,_minSize:()=>On,_multipleOf:()=>Qo,_nan:()=>Px,_nanoid:()=>Ip,_nativeEnum:()=>JK,_negative:()=>Zp,_never:()=>$x,_nonnegative:()=>qp,_nonoptional:()=>QK,_nonpositive:()=>Up,_normalize:()=>Na,_null:()=>kx,_nullable:()=>WK,_number:()=>dx,_optional:()=>VK,_overwrite:()=>an,_parse:()=>xa,_parseAsync:()=>_a,_pipe:()=>eH,_positive:()=>jp,_promise:()=>oH,_property:()=>Mp,_readonly:()=>tH,_record:()=>UK,_refine:()=>Lx,_regex:()=>Ta,_safeDecode:()=>ep,_safeDecodeAsync:()=>rp,_safeEncode:()=>Xf,_safeEncodeAsync:()=>tp,_safeParse:()=>Ea,_safeParseAsync:()=>Ia,_set:()=>MK,_size:()=>ds,_slugify:()=>ja,_startsWith:()=>Ca,_string:()=>nx,_stringFormat:()=>Za,_stringbool:()=>Ux,_success:()=>YK,_superRefine:()=>Bx,_symbol:()=>Ex,_templateLiteral:()=>rH,_toLowerCase:()=>La,_toUpperCase:()=>Ba,_transform:()=>HK,_trim:()=>Da,_tuple:()=>ZK,_uint32:()=>yx,_uint64:()=>_x,_ulid:()=>Tp,_undefined:()=>Ix,_union:()=>DK,_unknown:()=>Tx,_uppercase:()=>Ra,_url:()=>ru,_uuid:()=>vp,_uuidv4:()=>wp,_uuidv6:()=>xp,_uuidv7:()=>_p,_void:()=>Rx,_xid:()=>$p,_xor:()=>LK,clone:()=>lr,config:()=>ht,createStandardJSONSchemaMethod:()=>Ua,createToJSONSchemaMethod:()=>qx,decode:()=>oJ,decodeAsync:()=>sJ,describe:()=>jx,encode:()=>nJ,encodeAsync:()=>iJ,extractDefs:()=>ei,finalize:()=>ti,flattenError:()=>Ul,formatError:()=>ql,globalConfig:()=>is,globalRegistry:()=>qt,initializeContext:()=>Xo,isValidBase64:()=>dv,isValidBase64URL:()=>KO,isValidJWT:()=>HO,locales:()=>Xl,meta:()=>Zx,parse:()=>Hf,parseAsync:()=>Vf,prettifyError:()=>Fb,process:()=>Ve,regexes:()=>Rr,registry:()=>bp,safeDecode:()=>cJ,safeDecodeAsync:()=>uJ,safeEncode:()=>aJ,safeEncodeAsync:()=>lJ,safeParse:()=>Kb,safeParseAsync:()=>Hb,toDotPath:()=>IO,toJSONSchema:()=>Hp,treeifyError:()=>Mb,util:()=>ue,version:()=>qS});var Cr=w(()=>{Ee();op();Xw();ou();X1();tC();as();Vb();Jb();ew();ap();MS();eu();Y1();nu()});var Vp={};Ut(Vp,{endsWith:()=>Pa,gt:()=>Rn,gte:()=>dr,includes:()=>Oa,length:()=>ps,lowercase:()=>$a,lt:()=>$n,lte:()=>Or,maxLength:()=>fs,maxSize:()=>Yo,mime:()=>za,minLength:()=>io,minSize:()=>On,multipleOf:()=>Qo,negative:()=>Zp,nonnegative:()=>qp,nonpositive:()=>Up,normalize:()=>Na,overwrite:()=>an,positive:()=>jp,property:()=>Mp,regex:()=>Ta,size:()=>ds,slugify:()=>ja,startsWith:()=>Ca,toLowerCase:()=>La,toUpperCase:()=>Ba,trim:()=>Da,uppercase:()=>Ra});var Wp=w(()=>{Cr()});var qa={};Ut(qa,{ZodISODate:()=>Qp,ZodISODateTime:()=>Gp,ZodISODuration:()=>Xp,ZodISOTime:()=>Yp,date:()=>T0,datetime:()=>A0,duration:()=>R0,time:()=>$0});function A0(e){return ax(Gp,e)}function T0(e){return cx(Qp,e)}function $0(e){return lx(Yp,e)}function R0(e){return ux(Xp,e)}var Gp,Qp,Yp,Xp;var iu=w(()=>{Cr();au();Gp=Z("ZodISODateTime",(e,t)=>{rv.init(e,t),Xe.init(e,t)});Qp=Z("ZodISODate",(e,t)=>{nv.init(e,t),Xe.init(e,t)});Yp=Z("ZodISOTime",(e,t)=>{ov.init(e,t),Xe.init(e,t)});Xp=Z("ZodISODuration",(e,t)=>{iv.init(e,t),Xe.init(e,t)})});var rC=(e,t)=>{Zl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>ql(e,r)},flatten:{value:(r)=>Ul(e,r)},addIssue:{value:(r)=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Sa,2)}},addIssues:{value:(r)=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Sa,2)}},isEmpty:{get(){return e.issues.length===0}}})},nC,xr;var O0=w(()=>{Cr();Cr();Ee();nC=Z("ZodError",rC),xr=Z("ZodError",rC,{Parent:Error})});var C0,P0,z0,N0,D0,L0,B0,j0,Z0,U0,q0,M0;var F0=w(()=>{Cr();O0();C0=xa(xr),P0=_a(xr),z0=Ea(xr),N0=Ia(xr),D0=Wf(xr),L0=Gf(xr),B0=Qf(xr),j0=Yf(xr),Z0=Xf(xr),U0=ep(xr),q0=tp(xr),M0=rp(xr)});var su={};Ut(su,{ZodAny:()=>Y0,ZodArray:()=>r_,ZodBase64:()=>hm,ZodBase64URL:()=>gm,ZodBigInt:()=>Wa,ZodBigIntFormat:()=>Sm,ZodBoolean:()=>Va,ZodCIDRv4:()=>pm,ZodCIDRv6:()=>mm,ZodCUID:()=>sm,ZodCUID2:()=>am,ZodCatch:()=>E_,ZodCodec:()=>Su,ZodCustom:()=>vu,ZodCustomStringFormat:()=>Ka,ZodDate:()=>mu,ZodDefault:()=>b_,ZodDiscriminatedUnion:()=>o_,ZodE164:()=>ym,ZodEmail:()=>nm,ZodEmoji:()=>om,ZodEnum:()=>Fa,ZodExactOptional:()=>h_,ZodFile:()=>p_,ZodFunction:()=>z_,ZodGUID:()=>lu,ZodIPv4:()=>dm,ZodIPv6:()=>fm,ZodIntersection:()=>i_,ZodJWT:()=>bm,ZodKSUID:()=>um,ZodLazy:()=>O_,ZodLiteral:()=>f_,ZodMAC:()=>J0,ZodMap:()=>u_,ZodNaN:()=>k_,ZodNanoID:()=>im,ZodNever:()=>e_,ZodNonOptional:()=>Im,ZodNull:()=>G0,ZodNullable:()=>y_,ZodNumber:()=>Ha,ZodNumberFormat:()=>hs,ZodObject:()=>gu,ZodOptional:()=>Em,ZodPipe:()=>bu,ZodPrefault:()=>v_,ZodPreprocess:()=>A_,ZodPromise:()=>P_,ZodReadonly:()=>T_,ZodRecord:()=>Ma,ZodSet:()=>d_,ZodString:()=>Ja,ZodStringFormat:()=>Xe,ZodSuccess:()=>__,ZodSymbol:()=>V0,ZodTemplateLiteral:()=>R_,ZodTransform:()=>m_,ZodTuple:()=>a_,ZodType:()=>Be,ZodULID:()=>cm,ZodURL:()=>pu,ZodUUID:()=>Cn,ZodUndefined:()=>W0,ZodUnion:()=>yu,ZodUnknown:()=>X0,ZodVoid:()=>t_,ZodXID:()=>lm,ZodXor:()=>n_,_ZodString:()=>rm,_default:()=>S_,_function:()=>dP,any:()=>qC,array:()=>hu,base64:()=>IC,base64url:()=>kC,bigint:()=>LC,boolean:()=>H0,catch:()=>I_,check:()=>fP,cidrv4:()=>_C,cidrv6:()=>EC,codec:()=>aP,cuid:()=>hC,cuid2:()=>gC,custom:()=>pP,date:()=>FC,describe:()=>mP,discriminatedUnion:()=>GC,e164:()=>AC,email:()=>iC,emoji:()=>pC,enum:()=>xm,exactOptional:()=>g_,file:()=>nP,float32:()=>PC,float64:()=>zC,function:()=>dP,guid:()=>sC,hash:()=>CC,hex:()=>OC,hostname:()=>RC,httpUrl:()=>fC,instanceof:()=>gP,int:()=>em,int32:()=>NC,int64:()=>BC,intersection:()=>s_,invertCodec:()=>cP,ipv4:()=>vC,ipv6:()=>xC,json:()=>bP,jwt:()=>TC,keyof:()=>JC,ksuid:()=>SC,lazy:()=>C_,literal:()=>rP,looseObject:()=>VC,looseRecord:()=>YC,mac:()=>wC,map:()=>XC,meta:()=>hP,nan:()=>sP,nanoid:()=>mC,nativeEnum:()=>tP,never:()=>vm,nonoptional:()=>x_,null:()=>Q0,nullable:()=>du,nullish:()=>oP,number:()=>K0,object:()=>KC,optional:()=>uu,partialRecord:()=>QC,pipe:()=>tm,prefault:()=>w_,preprocess:()=>SP,promise:()=>uP,readonly:()=>$_,record:()=>l_,refine:()=>N_,set:()=>eP,strictObject:()=>HC,string:()=>cu,stringFormat:()=>$C,stringbool:()=>yP,success:()=>iP,superRefine:()=>D_,symbol:()=>ZC,templateLiteral:()=>lP,transform:()=>_m,tuple:()=>c_,uint32:()=>DC,uint64:()=>jC,ulid:()=>yC,undefined:()=>UC,union:()=>wm,unknown:()=>ms,url:()=>dC,uuid:()=>aC,uuidv4:()=>cC,uuidv6:()=>lC,uuidv7:()=>uC,void:()=>MC,xid:()=>bC,xor:()=>WC});function fu(e,t,r){let o=Object.getPrototypeOf(e),n=oC.get(o);if(!n)n=new Set,oC.set(o,n);if(n.has(t))return;n.add(t);for(let i in r){let s=r[i];Object.defineProperty(o,i,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}function cu(e){return nx(Ja,e)}function iC(e){return Sp(nm,e)}function sC(e){return tu(lu,e)}function aC(e){return vp(Cn,e)}function cC(e){return wp(Cn,e)}function lC(e){return xp(Cn,e)}function uC(e){return _p(Cn,e)}function dC(e){return ru(pu,e)}function fC(e){return ru(pu,{protocol:Rr.httpProtocol,hostname:Rr.domain,...ue.normalizeParams(e)})}function pC(e){return Ep(om,e)}function mC(e){return Ip(im,e)}function hC(e){return kp(sm,e)}function gC(e){return Ap(am,e)}function yC(e){return Tp(cm,e)}function bC(e){return $p(lm,e)}function SC(e){return Rp(um,e)}function vC(e){return Op(dm,e)}function wC(e){return ix(J0,e)}function xC(e){return Cp(fm,e)}function _C(e){return Pp(pm,e)}function EC(e){return zp(mm,e)}function IC(e){return Np(hm,e)}function kC(e){return Dp(gm,e)}function AC(e){return Lp(ym,e)}function TC(e){return Bp(bm,e)}function $C(e,t,r={}){return Za(Ka,e,t,r)}function RC(e){return Za(Ka,"hostname",Rr.hostname,e)}function OC(e){return Za(Ka,"hex",Rr.hex,e)}function CC(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Rr[o];if(!n)throw Error(`Unrecognized hash format: ${o}`);return Za(Ka,o,n,t)}function K0(e){return dx(Ha,e)}function em(e){return px(hs,e)}function PC(e){return mx(hs,e)}function zC(e){return hx(hs,e)}function NC(e){return gx(hs,e)}function DC(e){return yx(hs,e)}function H0(e){return bx(Va,e)}function LC(e){return vx(Wa,e)}function BC(e){return xx(Sm,e)}function jC(e){return _x(Sm,e)}function ZC(e){return Ex(V0,e)}function UC(e){return Ix(W0,e)}function Q0(e){return kx(G0,e)}function qC(){return Ax(Y0)}function ms(){return Tx(X0)}function vm(e){return $x(e_,e)}function MC(e){return Rx(t_,e)}function FC(e){return Ox(mu,e)}function hu(e,t){return zx(r_,e,t)}function JC(e){let t=e._zod.def.shape;return xm(Object.keys(t))}function KC(e,t){let r={type:"object",shape:e??{},...ue.normalizeParams(t)};return new gu(r)}function HC(e,t){return new gu({type:"object",shape:e,catchall:vm(),...ue.normalizeParams(t)})}function VC(e,t){return new gu({type:"object",shape:e,catchall:ms(),...ue.normalizeParams(t)})}function wm(e,t){return new yu({type:"union",options:e,...ue.normalizeParams(t)})}function WC(e,t){return new n_({type:"union",options:e,inclusive:!1,...ue.normalizeParams(t)})}function GC(e,t,r){return new o_({type:"union",options:t,discriminator:e,...ue.normalizeParams(r)})}function s_(e,t){return new i_({type:"intersection",left:e,right:t})}function c_(e,t,r){let o=t instanceof Ne,n=o?r:t;return new a_({type:"tuple",items:e,rest:o?t:null,...ue.normalizeParams(n)})}function l_(e,t,r){if(!t||!t._zod)return new Ma({type:"record",keyType:cu(),valueType:e,...ue.normalizeParams(t)});return new Ma({type:"record",keyType:e,valueType:t,...ue.normalizeParams(r)})}function QC(e,t,r){let o=lr(e);return o._zod.values=void 0,new Ma({type:"record",keyType:o,valueType:t,...ue.normalizeParams(r)})}function YC(e,t,r){return new Ma({type:"record",keyType:e,valueType:t,mode:"loose",...ue.normalizeParams(r)})}function XC(e,t,r){return new u_({type:"map",keyType:e,valueType:t,...ue.normalizeParams(r)})}function eP(e,t){return new d_({type:"set",valueType:e,...ue.normalizeParams(t)})}function xm(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new Fa({type:"enum",entries:r,...ue.normalizeParams(t)})}function tP(e,t){return new Fa({type:"enum",entries:e,...ue.normalizeParams(t)})}function rP(e,t){return new f_({type:"literal",values:Array.isArray(e)?e:[e],...ue.normalizeParams(t)})}function nP(e){return Nx(p_,e)}function _m(e){return new m_({type:"transform",transform:e})}function uu(e){return new Em({type:"optional",innerType:e})}function g_(e){return new h_({type:"optional",innerType:e})}function du(e){return new y_({type:"nullable",innerType:e})}function oP(e){return uu(du(e))}function S_(e,t){return new b_({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ue.shallowClone(t)}})}function w_(e,t){return new v_({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ue.shallowClone(t)}})}function x_(e,t){return new Im({type:"nonoptional",innerType:e,...ue.normalizeParams(t)})}function iP(e){return new __({type:"success",innerType:e})}function I_(e,t){return new E_({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}function sP(e){return Px(k_,e)}function tm(e,t){return new bu({type:"pipe",in:e,out:t})}function aP(e,t,r){return new Su({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function cP(e){let t=e._zod.def;return new Su({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function $_(e){return new T_({type:"readonly",innerType:e})}function lP(e,t){return new R_({type:"template_literal",parts:e,...ue.normalizeParams(t)})}function C_(e){return new O_({type:"lazy",getter:e})}function uP(e){return new P_({type:"promise",innerType:e})}function dP(e){return new z_({type:"function",input:Array.isArray(e?.input)?c_(e?.input):e?.input??hu(ms()),output:e?.output??ms()})}function fP(e){let t=new rt({check:"custom"});return t._zod.check=e,t}function pP(e,t){return Dx(vu,e??(()=>!0),t)}function N_(e,t={}){return Lx(vu,e,t)}function D_(e,t){return Bx(e,t)}function gP(e,t={}){let r=new vu({type:"custom",check:"custom",fn:(o)=>o instanceof e,abort:!0,...ue.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=(o)=>{if(!(o.value instanceof e))o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}function bP(e){let t=C_(()=>wm([cu(e),K0(),H0(),Q0(),hu(t),l_(cu(),t)]));return t}function SP(e,t){return new A_({type:"pipe",in:_m(e),out:t})}var oC,Be,rm,Ja,Xe,nm,lu,Cn,pu,om,im,sm,am,cm,lm,um,dm,J0,fm,pm,mm,hm,gm,ym,bm,Ka,Ha,hs,Va,Wa,Sm,V0,W0,G0,Y0,X0,e_,t_,mu,r_,gu,yu,n_,o_,i_,a_,Ma,u_,d_,Fa,f_,p_,m_,Em,h_,y_,b_,v_,Im,__,E_,k_,bu,Su,A_,T_,R_,O_,P_,z_,vu,mP,hP,yP=(...e)=>Ux({Codec:Su,Boolean:Va,String:Ja},...e);var au=w(()=>{Cr();Cr();ou();nu();Wp();iu();F0();oC=new WeakMap;Be=Z("ZodType",(e,t)=>(Ne.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ua(e,"input"),output:Ua(e,"output")}}),e.toJSONSchema=qx(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,o)=>C0(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>z0(e,r,o),e.parseAsync=async(r,o)=>P0(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>N0(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>D0(e,r,o),e.decode=(r,o)=>L0(e,r,o),e.encodeAsync=async(r,o)=>B0(e,r,o),e.decodeAsync=async(r,o)=>j0(e,r,o),e.safeEncode=(r,o)=>Z0(e,r,o),e.safeDecode=(r,o)=>U0(e,r,o),e.safeEncodeAsync=async(r,o)=>q0(e,r,o),e.safeDecodeAsync=async(r,o)=>M0(e,r,o),fu(e,"ZodType",{check(...r){let o=this.def;return this.clone(ue.mergeDefs(o,{checks:[...o.checks??[],...r.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,o){return lr(this,r,o)},brand(){return this},register(r,o){return r.add(this,o),this},refine(r,o){return this.check(N_(r,o))},superRefine(r,o){return this.check(D_(r,o))},overwrite(r){return this.check(an(r))},optional(){return uu(this)},exactOptional(){return g_(this)},nullable(){return du(this)},nullish(){return uu(du(this))},nonoptional(r){return x_(this,r)},array(){return hu(this)},or(r){return wm([this,r])},and(r){return s_(this,r)},transform(r){return tm(this,_m(r))},default(r){return S_(this,r)},prefault(r){return w_(this,r)},catch(r){return I_(this,r)},pipe(r){return tm(this,r)},readonly(){return $_(this)},describe(r){let o=this.clone();return qt.add(o,{description:r}),o},meta(...r){if(r.length===0)return qt.get(this);let o=this.clone();return qt.add(o,r[0]),o},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return qt.get(e)?.description},configurable:!0}),e)),rm=Z("_ZodString",(e,t)=>{us.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Mx(e,o,n,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,fu(e,"_ZodString",{regex(...o){return this.check(Ta(...o))},includes(...o){return this.check(Oa(...o))},startsWith(...o){return this.check(Ca(...o))},endsWith(...o){return this.check(Pa(...o))},min(...o){return this.check(io(...o))},max(...o){return this.check(fs(...o))},length(...o){return this.check(ps(...o))},nonempty(...o){return this.check(io(1,...o))},lowercase(o){return this.check($a(o))},uppercase(o){return this.check(Ra(o))},trim(){return this.check(Da())},normalize(...o){return this.check(Na(...o))},toLowerCase(){return this.check(La())},toUpperCase(){return this.check(Ba())},slugify(){return this.check(ja())}})}),Ja=Z("ZodString",(e,t)=>{us.init(e,t),rm.init(e,t),e.email=(r)=>e.check(Sp(nm,r)),e.url=(r)=>e.check(ru(pu,r)),e.jwt=(r)=>e.check(Bp(bm,r)),e.emoji=(r)=>e.check(Ep(om,r)),e.guid=(r)=>e.check(tu(lu,r)),e.uuid=(r)=>e.check(vp(Cn,r)),e.uuidv4=(r)=>e.check(wp(Cn,r)),e.uuidv6=(r)=>e.check(xp(Cn,r)),e.uuidv7=(r)=>e.check(_p(Cn,r)),e.nanoid=(r)=>e.check(Ip(im,r)),e.guid=(r)=>e.check(tu(lu,r)),e.cuid=(r)=>e.check(kp(sm,r)),e.cuid2=(r)=>e.check(Ap(am,r)),e.ulid=(r)=>e.check(Tp(cm,r)),e.base64=(r)=>e.check(Np(hm,r)),e.base64url=(r)=>e.check(Dp(gm,r)),e.xid=(r)=>e.check($p(lm,r)),e.ksuid=(r)=>e.check(Rp(um,r)),e.ipv4=(r)=>e.check(Op(dm,r)),e.ipv6=(r)=>e.check(Cp(fm,r)),e.cidrv4=(r)=>e.check(Pp(pm,r)),e.cidrv6=(r)=>e.check(zp(mm,r)),e.e164=(r)=>e.check(Lp(ym,r)),e.datetime=(r)=>e.check(A0(r)),e.date=(r)=>e.check(T0(r)),e.time=(r)=>e.check($0(r)),e.duration=(r)=>e.check(R0(r))});Xe=Z("ZodStringFormat",(e,t)=>{Ye.init(e,t),rm.init(e,t)}),nm=Z("ZodEmail",(e,t)=>{HS.init(e,t),Xe.init(e,t)});lu=Z("ZodGUID",(e,t)=>{JS.init(e,t),Xe.init(e,t)});Cn=Z("ZodUUID",(e,t)=>{KS.init(e,t),Xe.init(e,t)});pu=Z("ZodURL",(e,t)=>{VS.init(e,t),Xe.init(e,t)});om=Z("ZodEmoji",(e,t)=>{WS.init(e,t),Xe.init(e,t)});im=Z("ZodNanoID",(e,t)=>{GS.init(e,t),Xe.init(e,t)});sm=Z("ZodCUID",(e,t)=>{QS.init(e,t),Xe.init(e,t)});am=Z("ZodCUID2",(e,t)=>{YS.init(e,t),Xe.init(e,t)});cm=Z("ZodULID",(e,t)=>{XS.init(e,t),Xe.init(e,t)});lm=Z("ZodXID",(e,t)=>{ev.init(e,t),Xe.init(e,t)});um=Z("ZodKSUID",(e,t)=>{tv.init(e,t),Xe.init(e,t)});dm=Z("ZodIPv4",(e,t)=>{sv.init(e,t),Xe.init(e,t)});J0=Z("ZodMAC",(e,t)=>{cv.init(e,t),Xe.init(e,t)});fm=Z("ZodIPv6",(e,t)=>{av.init(e,t),Xe.init(e,t)});pm=Z("ZodCIDRv4",(e,t)=>{lv.init(e,t),Xe.init(e,t)});mm=Z("ZodCIDRv6",(e,t)=>{uv.init(e,t),Xe.init(e,t)});hm=Z("ZodBase64",(e,t)=>{fv.init(e,t),Xe.init(e,t)});gm=Z("ZodBase64URL",(e,t)=>{pv.init(e,t),Xe.init(e,t)});ym=Z("ZodE164",(e,t)=>{mv.init(e,t),Xe.init(e,t)});bm=Z("ZodJWT",(e,t)=>{hv.init(e,t),Xe.init(e,t)});Ka=Z("ZodCustomStringFormat",(e,t)=>{gv.init(e,t),Xe.init(e,t)});Ha=Z("ZodNumber",(e,t)=>{pp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Fx(e,o,n,i),fu(e,"ZodNumber",{gt(o,n){return this.check(Rn(o,n))},gte(o,n){return this.check(dr(o,n))},min(o,n){return this.check(dr(o,n))},lt(o,n){return this.check($n(o,n))},lte(o,n){return this.check(Or(o,n))},max(o,n){return this.check(Or(o,n))},int(o){return this.check(em(o))},safe(o){return this.check(em(o))},positive(o){return this.check(Rn(0,o))},nonnegative(o){return this.check(dr(0,o))},negative(o){return this.check($n(0,o))},nonpositive(o){return this.check(Or(0,o))},multipleOf(o,n){return this.check(Qo(o,n))},step(o,n){return this.check(Qo(o,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});hs=Z("ZodNumberFormat",(e,t)=>{yv.init(e,t),Ha.init(e,t)});Va=Z("ZodBoolean",(e,t)=>{Kl.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jx(e,r,o,n)});Wa=Z("ZodBigInt",(e,t)=>{mp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Kx(e,o,n,i),e.gte=(o,n)=>e.check(dr(o,n)),e.min=(o,n)=>e.check(dr(o,n)),e.gt=(o,n)=>e.check(Rn(o,n)),e.gte=(o,n)=>e.check(dr(o,n)),e.min=(o,n)=>e.check(dr(o,n)),e.lt=(o,n)=>e.check($n(o,n)),e.lte=(o,n)=>e.check(Or(o,n)),e.max=(o,n)=>e.check(Or(o,n)),e.positive=(o)=>e.check(Rn(BigInt(0),o)),e.negative=(o)=>e.check($n(BigInt(0),o)),e.nonpositive=(o)=>e.check(Or(BigInt(0),o)),e.nonnegative=(o)=>e.check(dr(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(Qo(o,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});Sm=Z("ZodBigIntFormat",(e,t)=>{bv.init(e,t),Wa.init(e,t)});V0=Z("ZodSymbol",(e,t)=>{Sv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hx(e,r,o,n)});W0=Z("ZodUndefined",(e,t)=>{vv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wx(e,r,o,n)});G0=Z("ZodNull",(e,t)=>{wv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vx(e,r,o,n)});Y0=Z("ZodAny",(e,t)=>{xv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yx(e,r,o,n)});X0=Z("ZodUnknown",(e,t)=>{_v.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xx(e,r,o,n)});e_=Z("ZodNever",(e,t)=>{Ev.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Qx(e,r,o,n)});t_=Z("ZodVoid",(e,t)=>{Iv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gx(e,r,o,n)});mu=Z("ZodDate",(e,t)=>{kv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>e0(e,o,n,i),e.min=(o,n)=>e.check(dr(o,n)),e.max=(o,n)=>e.check(Or(o,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});r_=Z("ZodArray",(e,t)=>{Av.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>f0(e,r,o,n),e.element=t.element,fu(e,"ZodArray",{min(r,o){return this.check(io(r,o))},nonempty(r){return this.check(io(1,r))},max(r,o){return this.check(fs(r,o))},length(r,o){return this.check(ps(r,o))},unwrap(){return this.element}})});gu=Z("ZodObject",(e,t)=>{Tv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>p0(e,r,o,n),ue.defineLazy(e,"shape",()=>t.shape),fu(e,"ZodObject",{keyof(){return xm(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:ms()})},loose(){return this.clone({...this._zod.def,catchall:ms()})},strict(){return this.clone({...this._zod.def,catchall:vm()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return ue.extend(this,r)},safeExtend(r){return ue.safeExtend(this,r)},merge(r){return ue.merge(this,r)},pick(r){return ue.pick(this,r)},omit(r){return ue.omit(this,r)},partial(...r){return ue.partial(Em,this,r[0])},required(...r){return ue.required(Im,this,r[0])}})});yu=Z("ZodUnion",(e,t)=>{Hl.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jp(e,r,o,n),e.options=t.options});n_=Z("ZodXor",(e,t)=>{yu.init(e,t),$v.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jp(e,r,o,n),e.options=t.options});o_=Z("ZodDiscriminatedUnion",(e,t)=>{yu.init(e,t),Rv.init(e,t)});i_=Z("ZodIntersection",(e,t)=>{Ov.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>m0(e,r,o,n)});a_=Z("ZodTuple",(e,t)=>{hp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>h0(e,r,o,n),e.rest=(r)=>e.clone({...e._zod.def,rest:r})});Ma=Z("ZodRecord",(e,t)=>{Cv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>g0(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});u_=Z("ZodMap",(e,t)=>{Pv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>u0(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(On(...r)),e.nonempty=(r)=>e.check(On(1,r)),e.max=(...r)=>e.check(Yo(...r)),e.size=(...r)=>e.check(ds(...r))});d_=Z("ZodSet",(e,t)=>{zv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>d0(e,r,o,n),e.min=(...r)=>e.check(On(...r)),e.nonempty=(r)=>e.check(On(1,r)),e.max=(...r)=>e.check(Yo(...r)),e.size=(...r)=>e.check(ds(...r))});Fa=Z("ZodEnum",(e,t)=>{Nv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>t0(e,o,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let s of o)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Fa({...t,checks:[],...ue.normalizeParams(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let s of o)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Fa({...t,checks:[],...ue.normalizeParams(n),entries:i})}});f_=Z("ZodLiteral",(e,t)=>{Dv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>r0(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});p_=Z("ZodFile",(e,t)=>{Lv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>i0(e,r,o,n),e.min=(r,o)=>e.check(On(r,o)),e.max=(r,o)=>e.check(Yo(r,o)),e.mime=(r,o)=>e.check(za(Array.isArray(r)?r:[r],o))});m_=Z("ZodTransform",(e,t)=>{Bv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>l0(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new ss(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(ue.issue(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(ue.issue(s))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((i)=>(r.value=i,r.fallback=!0,r));return r.value=n,r.fallback=!0,r}});Em=Z("ZodOptional",(e,t)=>{gp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});h_=Z("ZodExactOptional",(e,t)=>{jv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});y_=Z("ZodNullable",(e,t)=>{Zv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>y0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});b_=Z("ZodDefault",(e,t)=>{Uv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>S0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});v_=Z("ZodPrefault",(e,t)=>{qv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>v0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Im=Z("ZodNonOptional",(e,t)=>{Mv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>b0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});__=Z("ZodSuccess",(e,t)=>{Fv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>s0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});E_=Z("ZodCatch",(e,t)=>{Jv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>w0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});k_=Z("ZodNaN",(e,t)=>{Kv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>n0(e,r,o,n)});bu=Z("ZodPipe",(e,t)=>{yp.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>x0(e,r,o,n),e.in=t.in,e.out=t.out});Su=Z("ZodCodec",(e,t)=>{bu.init(e,t),Vl.init(e,t)});A_=Z("ZodPreprocess",(e,t)=>{bu.init(e,t),Hv.init(e,t)}),T_=Z("ZodReadonly",(e,t)=>{Vv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>_0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});R_=Z("ZodTemplateLiteral",(e,t)=>{Wv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>o0(e,r,o,n)});O_=Z("ZodLazy",(e,t)=>{Yv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>I0(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});P_=Z("ZodPromise",(e,t)=>{Qv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>E0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});z_=Z("ZodFunction",(e,t)=>{Gv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>c0(e,r,o,n)});vu=Z("ZodCustom",(e,t)=>{Xv.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>a0(e,r,o,n)});mP=jx,hP=Zx});function lH(e){ht({customError:e})}function uH(){return ht().customError}var cH,L_;var vP=w(()=>{Cr();cH={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(e){})(L_||(L_={}))});function fH(e,t){let r=e.$schema;if(r==="https://json-schema.org/draft/2020-12/schema")return"draft-2020-12";if(r==="http://json-schema.org/draft-07/schema#")return"draft-7";if(r==="http://json-schema.org/draft-04/schema#")return"draft-4";return t??"draft-2020-12"}function pH(e,t){if(!e.startsWith("#"))throw Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1];if(!n||!t.defs[n])throw Error(`Reference not found: ${e}`);return t.defs[n]}throw Error(`Reference not found: ${e}`)}function wP(e,t){if(e.not!==void 0){if(typeof e.not==="object"&&Object.keys(e.not).length===0)return Se.never();throw Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw 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 Se.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=pH(n,t),s=er(i,t);return t.refs.set(n,s),t.processing.delete(n),s}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 Se.null();if(n.length===0)return Se.never();if(n.length===1)return Se.literal(n[0]);if(n.every((s)=>typeof s==="string"))return Se.enum(n);let i=n.map((s)=>Se.literal(s));if(i.length<2)return i[0];return Se.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return Se.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map((i)=>{let s={...e,type:i};return wP(s,t)});if(n.length===0)return Se.never();if(n.length===1)return n[0];return Se.union(n)}if(!r)return Se.any();let o;switch(r){case"string":{let n=Se.string();if(e.format){let i=e.format;if(i==="email")n=n.check(Se.email());else if(i==="uri"||i==="uri-reference")n=n.check(Se.url());else if(i==="uuid"||i==="guid")n=n.check(Se.uuid());else if(i==="date-time")n=n.check(Se.iso.datetime());else if(i==="date")n=n.check(Se.iso.date());else if(i==="time")n=n.check(Se.iso.time());else if(i==="duration")n=n.check(Se.iso.duration());else if(i==="ipv4")n=n.check(Se.ipv4());else if(i==="ipv6")n=n.check(Se.ipv6());else if(i==="mac")n=n.check(Se.mac());else if(i==="cidr")n=n.check(Se.cidrv4());else if(i==="cidr-v6")n=n.check(Se.cidrv6());else if(i==="base64")n=n.check(Se.base64());else if(i==="base64url")n=n.check(Se.base64url());else if(i==="e164")n=n.check(Se.e164());else if(i==="jwt")n=n.check(Se.jwt());else if(i==="emoji")n=n.check(Se.emoji());else if(i==="nanoid")n=n.check(Se.nanoid());else if(i==="cuid")n=n.check(Se.cuid());else if(i==="cuid2")n=n.check(Se.cuid2());else if(i==="ulid")n=n.check(Se.ulid());else if(i==="xid")n=n.check(Se.xid());else if(i==="ksuid")n=n.check(Se.ksuid())}if(typeof e.minLength==="number")n=n.min(e.minLength);if(typeof e.maxLength==="number")n=n.max(e.maxLength);if(e.pattern)n=n.regex(new RegExp(e.pattern));o=n;break}case"number":case"integer":{let n=r==="integer"?Se.number().int():Se.number();if(typeof e.minimum==="number")n=n.min(e.minimum);if(typeof e.maximum==="number")n=n.max(e.maximum);if(typeof e.exclusiveMinimum==="number")n=n.gt(e.exclusiveMinimum);else if(e.exclusiveMinimum===!0&&typeof e.minimum==="number")n=n.gt(e.minimum);if(typeof e.exclusiveMaximum==="number")n=n.lt(e.exclusiveMaximum);else if(e.exclusiveMaximum===!0&&typeof e.maximum==="number")n=n.lt(e.maximum);if(typeof e.multipleOf==="number")n=n.multipleOf(e.multipleOf);o=n;break}case"boolean":{o=Se.boolean();break}case"null":{o=Se.null();break}case"object":{let n={},i=e.properties||{},s=new Set(e.required||[]);for(let[c,u]of Object.entries(i)){let d=er(u,t);n[c]=s.has(c)?d:d.optional()}if(e.propertyNames){let c=er(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties==="object"?er(e.additionalProperties,t):Se.any();if(Object.keys(n).length===0){o=Se.record(c,u);break}let d=Se.object(n).passthrough(),f=Se.looseRecord(c,u);o=Se.intersection(d,f);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),d=[];for(let m of u){let h=er(c[m],t),b=Se.string().regex(new RegExp(m));d.push(Se.looseRecord(b,h))}let f=[];if(Object.keys(n).length>0)f.push(Se.object(n).passthrough());if(f.push(...d),f.length===0)o=Se.object({}).passthrough();else if(f.length===1)o=f[0];else{let m=Se.intersection(f[0],f[1]);for(let h=2;h<f.length;h++)m=Se.intersection(m,f[h]);o=m}break}let a=Se.object(n);if(e.additionalProperties===!1)o=a.strict();else if(typeof e.additionalProperties==="object")o=a.catchall(er(e.additionalProperties,t));else o=a.passthrough();break}case"array":{let{prefixItems:n,items:i}=e;if(n&&Array.isArray(n)){let s=n.map((c)=>er(c,t)),a=i&&typeof i==="object"&&!Array.isArray(i)?er(i,t):void 0;if(a)o=Se.tuple(s).rest(a);else o=Se.tuple(s);if(typeof e.minItems==="number")o=o.check(Se.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(Se.maxLength(e.maxItems))}else if(Array.isArray(i)){let s=i.map((c)=>er(c,t)),a=e.additionalItems&&typeof e.additionalItems==="object"?er(e.additionalItems,t):void 0;if(a)o=Se.tuple(s).rest(a);else o=Se.tuple(s);if(typeof e.minItems==="number")o=o.check(Se.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(Se.maxLength(e.maxItems))}else if(i!==void 0){let s=er(i,t),a=Se.array(s);if(typeof e.minItems==="number")a=a.min(e.minItems);if(typeof e.maxItems==="number")a=a.max(e.maxItems);o=a}else o=Se.array(Se.any());break}default:throw Error(`Unsupported type: ${r}`)}return o}function er(e,t){if(typeof e==="boolean")return e?Se.any():Se.never();let r=wP(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map((u)=>er(u,t)),c=Se.union(a);r=o?Se.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map((u)=>er(u,t)),c=Se.xor(a);r=o?Se.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:Se.any();else{let a=o?r:er(e.allOf[0],t),c=o?0:1;for(let u=c;u<e.allOf.length;u++)a=Se.intersection(a,er(e.allOf[u],t));r=a}if(e.nullable===!0&&t.version==="openapi-3.0")r=Se.nullable(r);if(e.readOnly===!0)r=Se.readonly(r);if(e.default!==void 0)r=r.default(e.default);let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of i)if(a in e)n[a]=e[a];let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)if(a in e)n[a]=e[a];for(let a of Object.keys(e))if(!dH.has(a))n[a]=e[a];if(Object.keys(n).length>0)t.registry.add(r,n);if(e.description)r=r.describe(e.description);return r}function xP(e,t){if(typeof e==="boolean")return e?Se.any():Se.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=fH(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??qt};return er(r,i)}var Se,dH;var _P=w(()=>{eu();Wp();iu();au();Se={...su,...Vp,iso:qa},dH=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"])});var B_={};Ut(B_,{bigint:()=>yH,boolean:()=>gH,date:()=>bH,number:()=>hH,string:()=>mH});function mH(e){return ox(Ja,e)}function hH(e){return fx(Ha,e)}function gH(e){return Sx(Va,e)}function yH(e){return wx(Wa,e)}function bH(e){return Cx(mu,e)}var EP=w(()=>{Cr();au()});var l={};Ut(l,{$brand:()=>Cb,$input:()=>tx,$output:()=>ex,NEVER:()=>Ob,TimePrecision:()=>sx,ZodAny:()=>Y0,ZodArray:()=>r_,ZodBase64:()=>hm,ZodBase64URL:()=>gm,ZodBigInt:()=>Wa,ZodBigIntFormat:()=>Sm,ZodBoolean:()=>Va,ZodCIDRv4:()=>pm,ZodCIDRv6:()=>mm,ZodCUID:()=>sm,ZodCUID2:()=>am,ZodCatch:()=>E_,ZodCodec:()=>Su,ZodCustom:()=>vu,ZodCustomStringFormat:()=>Ka,ZodDate:()=>mu,ZodDefault:()=>b_,ZodDiscriminatedUnion:()=>o_,ZodE164:()=>ym,ZodEmail:()=>nm,ZodEmoji:()=>om,ZodEnum:()=>Fa,ZodError:()=>nC,ZodExactOptional:()=>h_,ZodFile:()=>p_,ZodFirstPartyTypeKind:()=>L_,ZodFunction:()=>z_,ZodGUID:()=>lu,ZodIPv4:()=>dm,ZodIPv6:()=>fm,ZodISODate:()=>Qp,ZodISODateTime:()=>Gp,ZodISODuration:()=>Xp,ZodISOTime:()=>Yp,ZodIntersection:()=>i_,ZodIssueCode:()=>cH,ZodJWT:()=>bm,ZodKSUID:()=>um,ZodLazy:()=>O_,ZodLiteral:()=>f_,ZodMAC:()=>J0,ZodMap:()=>u_,ZodNaN:()=>k_,ZodNanoID:()=>im,ZodNever:()=>e_,ZodNonOptional:()=>Im,ZodNull:()=>G0,ZodNullable:()=>y_,ZodNumber:()=>Ha,ZodNumberFormat:()=>hs,ZodObject:()=>gu,ZodOptional:()=>Em,ZodPipe:()=>bu,ZodPrefault:()=>v_,ZodPreprocess:()=>A_,ZodPromise:()=>P_,ZodReadonly:()=>T_,ZodRealError:()=>xr,ZodRecord:()=>Ma,ZodSet:()=>d_,ZodString:()=>Ja,ZodStringFormat:()=>Xe,ZodSuccess:()=>__,ZodSymbol:()=>V0,ZodTemplateLiteral:()=>R_,ZodTransform:()=>m_,ZodTuple:()=>a_,ZodType:()=>Be,ZodULID:()=>cm,ZodURL:()=>pu,ZodUUID:()=>Cn,ZodUndefined:()=>W0,ZodUnion:()=>yu,ZodUnknown:()=>X0,ZodVoid:()=>t_,ZodXID:()=>lm,ZodXor:()=>n_,_ZodString:()=>rm,_default:()=>S_,_function:()=>dP,any:()=>qC,array:()=>hu,base64:()=>IC,base64url:()=>kC,bigint:()=>LC,boolean:()=>H0,catch:()=>I_,check:()=>fP,cidrv4:()=>_C,cidrv6:()=>EC,clone:()=>lr,codec:()=>aP,coerce:()=>B_,config:()=>ht,core:()=>so,cuid:()=>hC,cuid2:()=>gC,custom:()=>pP,date:()=>FC,decode:()=>L0,decodeAsync:()=>j0,describe:()=>mP,discriminatedUnion:()=>GC,e164:()=>AC,email:()=>iC,emoji:()=>pC,encode:()=>D0,encodeAsync:()=>B0,endsWith:()=>Pa,enum:()=>xm,exactOptional:()=>g_,file:()=>nP,flattenError:()=>Ul,float32:()=>PC,float64:()=>zC,formatError:()=>ql,fromJSONSchema:()=>xP,function:()=>dP,getErrorMap:()=>uH,globalRegistry:()=>qt,gt:()=>Rn,gte:()=>dr,guid:()=>sC,hash:()=>CC,hex:()=>OC,hostname:()=>RC,httpUrl:()=>fC,includes:()=>Oa,instanceof:()=>gP,int:()=>em,int32:()=>NC,int64:()=>BC,intersection:()=>s_,invertCodec:()=>cP,ipv4:()=>vC,ipv6:()=>xC,iso:()=>qa,json:()=>bP,jwt:()=>TC,keyof:()=>JC,ksuid:()=>SC,lazy:()=>C_,length:()=>ps,literal:()=>rP,locales:()=>Xl,looseObject:()=>VC,looseRecord:()=>YC,lowercase:()=>$a,lt:()=>$n,lte:()=>Or,mac:()=>wC,map:()=>XC,maxLength:()=>fs,maxSize:()=>Yo,meta:()=>hP,mime:()=>za,minLength:()=>io,minSize:()=>On,multipleOf:()=>Qo,nan:()=>sP,nanoid:()=>mC,nativeEnum:()=>tP,negative:()=>Zp,never:()=>vm,nonnegative:()=>qp,nonoptional:()=>x_,nonpositive:()=>Up,normalize:()=>Na,null:()=>Q0,nullable:()=>du,nullish:()=>oP,number:()=>K0,object:()=>KC,optional:()=>uu,overwrite:()=>an,parse:()=>C0,parseAsync:()=>P0,partialRecord:()=>QC,pipe:()=>tm,positive:()=>jp,prefault:()=>w_,preprocess:()=>SP,prettifyError:()=>Fb,promise:()=>uP,property:()=>Mp,readonly:()=>$_,record:()=>l_,refine:()=>N_,regex:()=>Ta,regexes:()=>Rr,registry:()=>bp,safeDecode:()=>U0,safeDecodeAsync:()=>M0,safeEncode:()=>Z0,safeEncodeAsync:()=>q0,safeParse:()=>z0,safeParseAsync:()=>N0,set:()=>eP,setErrorMap:()=>lH,size:()=>ds,slugify:()=>ja,startsWith:()=>Ca,strictObject:()=>HC,string:()=>cu,stringFormat:()=>$C,stringbool:()=>yP,success:()=>iP,superRefine:()=>D_,symbol:()=>ZC,templateLiteral:()=>lP,toJSONSchema:()=>Hp,toLowerCase:()=>La,toUpperCase:()=>Ba,transform:()=>_m,treeifyError:()=>Mb,trim:()=>Da,tuple:()=>c_,uint32:()=>DC,uint64:()=>jC,ulid:()=>yC,undefined:()=>UC,union:()=>wm,unknown:()=>ms,uppercase:()=>Ra,url:()=>dC,util:()=>ue,uuid:()=>aC,uuidv4:()=>cC,uuidv6:()=>lC,uuidv7:()=>uC,void:()=>MC,xid:()=>bC,xor:()=>WC});var j_=w(()=>{Cr();Cr();uw();Cr();ou();_P();Xw();iu();iu();EP();au();Wp();O0();F0();vP();ht(Wl())});var IP=w(()=>{j_();j_()});var Z_=w(()=>{IP()});var he=w(()=>{Z_()});var U_,kP;var q_=w(()=>{he();U_=l.object({title:l.string().trim().min(1).max(500).optional(),introduction:l.string().trim().min(1).max(4000).optional(),topics:l.array(l.string().trim().min(1).max(500)).max(20).optional(),topicsHeading:l.string().trim().min(1).max(120).optional(),contactLabel:l.string().trim().min(1).max(80).optional(),contactNote:l.string().trim().min(1).max(240).optional(),mapCaption:l.string().trim().min(1).max(160).optional(),refusal:l.string().trim().min(1).max(500).optional(),faqHeading:l.string().trim().min(1).max(120).optional()}),kP=U_.omit({introduction:!0})});function km(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function TP(e){let t=Reflect.get(os,"types"),r=km(t)?t[e]:void 0;if(!(r instanceof ha))throw Error(`Required YAML type is unavailable: ${e}`);return r}function wH(e,t){let r=0,o=1;for(let n of e.split(":").reverse())r+=(t?Number.parseFloat(n):Number.parseInt(n,10))*o,o*=60;return r}function AP(e){let t=TP(e);return new ha(`tag:yaml.org,2002:${e}`,{kind:"scalar",resolve:(r)=>typeof r==="string"&&(e==="int"?SH:vH).test(r)&&!r.endsWith("_"),construct:(r)=>{let o=r.replace(/_/g,""),n=o.startsWith("-")?-1:1,i=o.replace(/^[+-]/,"");if(i.includes(":"))return n*wH(i,e==="float");if(e==="int"&&i==="0")return 0;if(e==="int"&&/^0[0-7]+$/.test(i))return n*Number.parseInt(i,8);return t.construct(o)},predicate:t.predicate??void 0,represent:t.represent??void 0,defaultStyle:t.defaultStyle??void 0})}var SH,vH,M_,xH,_H,EH;var $P=w(()=>{ya();SH=/^[+-]?(?:0|0b[01_]*[01]|0x[\da-fA-F_]*[\da-fA-F]|0[0-7_]*[0-7]|[1-9](?:[\d_]*\d)?|[1-9][\d_]*(?::[0-5]?\d)+)$/,vH=/^(?:[-+]?(?:0|[1-9][\d_]*)(?:\.[\d_]*)?(?:[eE][-+]?\d+)?|\.[\d_]+(?:[eE][-+]?\d+)?|[-+]?\d[\d_]*(?::[0-5]?\d)+\.[\d_]*|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/;M_=TP("binary"),xH=new ha("tag:yaml.org,2002:binary",{kind:"scalar",resolve:(e)=>M_.resolve(e),construct:(e)=>{let t=M_.construct(e);if(!(t instanceof Uint8Array))throw Error("Invalid YAML binary result");return typeof Buffer>"u"?Array.from(t):Buffer.from(t)},predicate:(e)=>typeof Buffer<"u"&&Buffer.isBuffer(e),represent:M_.represent??void 0}),_H=new ha("tag:yaml.org,2002:str",{kind:"scalar",resolve:(e)=>typeof e==="string"&&e.includes(":"),construct:(e)=>e}),EH=Rb.extend({implicit:[AP("int"),AP("float"),_H],explicit:[xH]})});var F_=w(()=>{ya();$P()});var RP,OP,CP,kH;var J_=w(()=>{F_();he();RP=l.object({audiences:l.array(l.string()).optional(),positioning:l.string().optional()}),OP=l.object({summary:l.string().optional(),traits:l.array(l.string()).optional(),principles:l.array(l.string()).optional(),preferredTerms:l.array(l.string()).optional(),avoid:l.array(l.string()).optional()}),CP=l.object({artDirection:l.string().optional(),palette:l.array(l.string()).optional(),composition:l.string().optional(),mood:l.string().optional(),preferred:l.array(l.string()).optional(),avoid:l.array(l.string()).optional()}),kH=l.object({name:l.string().describe("Style guide name"),messaging:RP.optional(),voice:OP.optional(),visual:CP.optional()})});var zP=w(()=>{F_();q_();J_()});var AH,Am,ebe,K_="data-ask-sheet",TH;var H_=w(()=>{he();AH=l.object({public:l.boolean(),preview:l.boolean()}),Am=l.object({name:l.string().trim().min(1).max(200),url:l.string().url().optional()}),ebe=l.object({sources:l.array(l.object({id:l.string(),title:l.string(),brain:Am.optional()}))}),TH=`body *:not([${K_}], [${K_}] *) { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }`});var ri;var Tm=w(()=>{he();ri=l.discriminatedUnion("kind",[l.object({kind:l.literal("user"),userId:l.string().min(1),canonicalId:l.string().min(1).optional()}),l.object({kind:l.literal("external"),externalActorId:l.string().min(1)}),l.object({kind:l.literal("agent"),agentId:l.string().min(1)}),l.object({kind:l.literal("service"),serviceId:l.string().min(1)})])});var $H,ibe,Ga,RH,OH,NP,sbe,CH,PH,DP;var LP=w(()=>{he();$H=l.strictObject({messageCharacters:l.number().int().positive(),requestTimeoutSeconds:l.number().int().positive().max(2147483)}),ibe=l.strictObject({limits:$H,maxCostMicroUsd:l.number().int().positive()}),Ga=l.number().int().nonnegative(),RH=l.strictObject({modelCalls:Ga,inputTokens:Ga,cachedInputTokens:Ga,outputTokens:Ga,reasoningTokens:Ga,embeddingTokens:Ga}),OH=l.discriminatedUnion("state",[l.strictObject({state:l.literal("known"),microUsd:l.number().int().nonnegative(),pricing:l.string().trim().min(1).max(120)}),l.strictObject({state:l.literal("unknown"),reason:l.enum(["missing-usage","unsupported-pricing"])})]),NP=l.strictObject({usage:RH,cost:OH}),sbe=l.strictObject({topics:l.array(l.string().trim().min(1).max(500)).max(20),introduction:l.string().trim().min(1).max(4000).optional(),refusal:l.string().trim().min(1).max(500).optional()}),CH=l.enum(["in-scope","off-topic","abusive","injection","harmful"]),PH=CH.exclude(["in-scope"]),DP=l.discriminatedUnion("outcome",[l.strictObject({outcome:l.literal("answered")}),l.strictObject({outcome:l.literal("refused"),category:PH}),l.strictObject({outcome:l.literal("unscreened")})])});function NH(e){let t=zH.safeParse(e);if(!t.success)return e;return{...t.data,cards:t.data.cards.filter((r)=>V_.safeParse(r).success)}}var BP,jP,ZP,UP,qP,MP,Qa,FP,JP,KP,HP,VP,V_,WP,GP,QP,zH,YP;var wu=w(()=>{he();H_();LP();BP=l.object({id:l.string(),toolCallId:l.string().optional(),toolName:l.string(),summary:l.string(),completionSummary:l.string().optional(),preview:l.string().optional(),args:l.unknown()}),jP=l.enum(["approval-requested","approval-responded","output-available","output-denied","output-error"]),ZP=l.object({kind:l.literal("tool-approval"),id:l.string(),toolCallId:l.string().optional(),toolName:l.string(),input:l.record(l.string(),l.unknown()).optional(),summary:l.string(),completionSummary:l.string().optional(),preview:l.string().optional(),state:jP,output:l.unknown().optional(),error:l.string().optional()}),UP=l.object({entityType:l.string().optional(),entityId:l.string().optional(),attachmentType:l.string().optional()}),qP=l.object({mediaType:l.string().min(1),url:l.string().min(1),downloadUrl:l.string().min(1).optional(),previewUrl:l.string().min(1).optional(),filename:l.string().min(1).optional(),sizeBytes:l.number().nonnegative().optional(),source:UP.optional()}),MP=l.object({kind:l.literal("attachment"),id:l.string(),jobId:l.string().optional(),title:l.string(),description:l.string().optional(),attachment:qP}),Qa=l.object({id:l.string().min(1),title:l.string().min(1).optional(),source:l.string().min(1),url:l.string().min(1).optional(),entityType:l.string().min(1).optional(),entityId:l.string().min(1).optional(),excerpt:l.string().min(1).optional(),provenance:l.record(l.string(),l.unknown()).optional(),brain:Am.optional()}),FP=l.object({kind:l.literal("sources"),id:l.string().min(1),title:l.string().min(1).optional(),sources:l.array(Qa).min(1)}),JP=l.object({type:l.literal("prompt"),id:l.string().min(1),label:l.string().min(1),prompt:l.string().min(1),description:l.string().min(1).optional()}),KP=l.object({type:l.literal("event"),id:l.string().min(1),label:l.string().min(1),event:l.string().min(1),fromState:l.string().min(1).optional(),description:l.string().min(1).optional()}),HP=l.discriminatedUnion("type",[JP,KP]),VP=l.object({kind:l.literal("actions"),id:l.string().min(1),title:l.string().min(1).optional(),defaultOpen:l.boolean().optional(),actions:l.array(HP).min(1)}),V_=l.discriminatedUnion("kind",[ZP,MP,FP,VP]),WP=l.object({toolName:l.string(),args:l.record(l.string(),l.unknown()).optional(),jobId:l.string().optional(),data:l.unknown().optional(),error:l.object({message:l.string(),code:l.string().optional()}).optional()}),GP=l.object({faqId:l.string().min(1)}),QP=l.object({text:l.string(),error:l.string().optional(),toolResults:l.array(WP).optional(),cards:l.array(V_).optional(),pendingConfirmations:l.array(BP).optional(),usage:l.object({promptTokens:l.number(),completionTokens:l.number(),totalTokens:l.number()}),guestSettlement:NP.optional(),guestScreening:DP.optional(),askedBefore:GP.optional()}),zH=l.looseObject({cards:l.array(l.unknown())});YP=l.preprocess((e)=>NH(Mf(e)),QP)});function _e(e){return Object.freeze({name:e.channel,schema:e.request,response:e.response,delivery:e.delivery})}var W_,DH,LH,XP,BH,jH,ZH,UH;var ez=w(()=>{he();Tm();wu();W_=l.object({state:l.string(),response:l.string(),sources:l.array(Qa)}),DH=l.object({agent:l.string().trim().min(1).max(253),question:l.string().trim().min(1).max(4000)}),LH=_e({channel:"a2a:ask:request",request:DH,response:W_,delivery:"request"}),XP=l.object({entityType:l.string().optional(),entityId:l.string().optional(),actor:ri.optional(),interfaceType:l.string().optional(),userPermissionLevel:l.enum(["admin","trusted","public"])}),BH=l.object({agent:l.string().trim().min(1).max(253),instruction:l.string().trim().min(1).max(2000),selection:l.string().min(1).max(8000),...XP.shape}),jH=_e({channel:"a2a:call:request",request:BH,response:W_,delivery:"request"}),ZH=l.object({agents:l.array(l.object({id:l.string(),label:l.string()}))}),UH=_e({channel:"a2a:call:agents",request:XP,response:ZH,delivery:"request"})});var qH,tz,MH,FH;var rz=w(()=>{he();wu();qH=l.object({type:l.literal("event"),event:l.string().min(1),fromState:l.string().min(1).optional()}),tz=l.object({conversationId:l.string().min(1),interfaceType:l.string().min(1),channelId:l.string().min(1).optional(),channelName:l.string().min(1),userPermissionLevel:l.enum(["admin","trusted","public"]),isAnchor:l.boolean(),action:qH}),MH=YP.nullable(),FH=_e({channel:"agent:action:request",request:tz,response:MH,delivery:"request"})});var nz,JH,oz,KH;var iz=w(()=>{he();wu();nz=l.object({question:l.string().trim().min(1)}),JH=l.object({faqId:l.string().min(1),faqQuestion:l.string().min(1),answer:l.string().trim().min(1),sources:l.array(Qa).default([])}),oz=l.object({hit:JH.optional()}),KH=_e({channel:"guest:asked-before",request:nz,response:oz,delivery:"collect"})});var HH,sz,az,$be,VH,WH;var cz=w(()=>{he();HH=l.enum(["admin","trusted","public"]),sz=l.object({conversationId:l.string().min(1),message:l.string(),interfaceType:l.string().min(1),channelId:l.string().optional(),channelName:l.string().optional(),userPermissionLevel:HH}),az=l.object({id:l.string().min(1),source:l.string().min(1),title:l.string().optional(),content:l.string().min(1),provenance:l.record(l.string(),l.unknown()).optional()}),$be=l.object({items:l.array(az).default([])}),VH=l.object({items:l.array(l.unknown()).default([]).transform((e)=>e.flatMap((t)=>{let r=az.safeParse(t);return r.success?[r.data]:[]}))}),WH=_e({channel:"agent:context:request",request:sz,response:VH,delivery:"collect"})});var GH,QH;var lz=w(()=>{he();GH=l.strictObject({entityType:l.string().min(1),entityId:l.string().min(1)}),QH=l.strictObject({startedAt:l.string().datetime(),retrieved:l.array(GH).max(50)})});var uz,YH,dz,XH;var fz=w(()=>{he();Tm();uz=l.object({actor:ri}),YH=l.object({userId:l.string().min(1),personId:l.string().min(1),canonicalId:l.string().min(1).optional(),displayName:l.string().min(1),permissionLevel:l.enum(["admin","trusted","public"])}),dz=l.object({principal:YH.nullable()}),XH=_e({channel:"auth:principal:resolve",request:uz,response:dz,delivery:"request"})});var pz=()=>{};var mz=()=>{};var G_,eV,hz,tV,rV;var gz=w(()=>{he();G_=l.strictObject({name:l.string().min(1).optional(),address:l.email()}),eV=l.strictObject({personId:l.string().min(1).max(200),displayName:l.string().trim().min(1).max(200),permissionLevel:l.enum(["admin","trusted","public"])}),hz=l.strictObject({messageId:l.string().min(1),sourceRef:l.string().min(1),threadId:l.string().min(1).optional(),from:G_,replyTo:G_.optional(),to:l.array(G_),subject:l.string(),receivedAt:l.iso.datetime(),text:l.string(),html:l.string().min(1).optional(),headers:l.strictObject({listUnsubscribe:l.string().min(1).optional(),autoSubmitted:l.string().min(1).optional(),precedence:l.string().min(1).optional(),inReplyTo:l.string().min(1).optional(),references:l.array(l.string().min(1)).optional()}),sender:eV.optional()}),tV=l.strictObject({}),rV=_e({channel:"email:inbound",request:hz,response:tV,delivery:"request"})});var nV,oV,yz,Q_,iV,bz,sV;var Sz=w(()=>{he();nV=l.strictObject({permissionLevel:l.enum(["admin","trusted","public"])}),oV=l.custom((e)=>typeof AbortSignal<"u"&&e instanceof AbortSignal),yz=l.strictObject({sourceRef:l.string().regex(/^imap:[a-f0-9]{64}$/),actor:nV,signal:oV.optional()}),Q_=l.strictObject({name:l.string().trim().min(1).max(300).optional(),address:l.email().max(320)}),iV=l.strictObject({messageId:l.string().trim().min(1).max(2000),from:Q_,replyTo:Q_.optional(),to:l.array(Q_).max(100),subject:l.string().max(1000),receivedAt:l.iso.datetime(),text:l.string().max(1e5),inReplyTo:l.string().trim().min(1).max(2000).optional(),references:l.array(l.string().trim().min(1).max(2000)).max(100),truncated:l.boolean()}),bz=l.discriminatedUnion("kind",[l.strictObject({kind:l.literal("available"),message:iV}),l.strictObject({kind:l.literal("unavailable")})]),sV=_e({channel:"email:source-read",request:yz,response:bz,delivery:"request"})});var vz=()=>{};var wz=w(()=>{vz()});var aV;var xz=w(()=>{he();aV=l.object({url:l.string(),authToken:l.string().optional()})});var cV;var _z=w(()=>{he();cV=l.object({success:l.boolean(),entityId:l.string().optional(),error:l.string().optional()})});var Ez=()=>{};function Y_(e,t="handler_failed"){let r=t,o;try{if(e!==null&&typeof e==="object"){let n=xu.safeParse(Reflect.get(e,"code"));if(n.success)r=n.data,o=$m.shape.message.safeParse(Reflect.get(e,"publicMessage")).data;else{let i=Reflect.get(e,"name");if(i==="AbortError")r="cancelled";if(i==="TimeoutError")r="deadline_exceeded"}}}catch{}return new Ya(r,{cause:e,...o!==void 0?{publicMessage:o}:{}})}var xu,kz=1024,$m,Iz,Ya;var Az=w(()=>{he();xu=l.enum(["no_handler","handler_failed","invalid_input","invalid_response","unauthenticated","permission_denied","not_found","conflict","cancelled","deadline_exceeded"]),$m=l.object({code:xu,message:l.string().max(kz)}),Iz={no_handler:"No handler is available for this capability",handler_failed:"The operation failed",invalid_input:"Invalid input",invalid_response:"Invalid response",unauthenticated:"Authentication required",permission_denied:"Permission denied",not_found:"Not found",conflict:"The operation conflicts with the current state",cancelled:"The operation was cancelled",deadline_exceeded:"The execution deadline was exceeded"};Ya=class Ya extends Error{code;publicMessage;constructor(e,t={}){let r=xu.parse(e),o=$m.shape.message.parse(t.publicMessage??Iz[r]);super(t.message??o,{cause:t.cause});this.name="SdkError",this.code=r,this.publicMessage=o}toJSON(){let e=xu.safeParse(this.code),t=e.data??"handler_failed",r=e.success?$m.shape.message.safeParse(this.publicMessage).data:void 0;return{code:t,message:r??Iz[t]}}}});var Rm,Om;var X_=w(()=>{he();Rm=l.lazy(()=>l.union([l.null(),l.boolean(),l.number().finite().refine((e)=>!Number.isInteger(e)||Number.isSafeInteger(e),{message:"integer exceeds the JSON-safe range"}),l.string(),l.array(Rm),l.record(l.string(),Rm)])),Om=l.record(l.string(),Rm)});var lV;var Tz=w(()=>{he();lV=l.enum(["user","assistant"])});var uV,ni;var $z=w(()=>{he();uV=l.object({entityType:l.string().min(1),entityId:l.string().min(1),contentHash:l.string().min(1).optional()}),ni=l.object({rootJobId:l.string().min(1),causationId:l.string().min(1),projectionId:l.string().min(1).optional(),projectionLineage:l.array(l.string().min(1)),sourceEntity:uV.optional(),derivationDepth:l.number().int().nonnegative()}).superRefine((e,t)=>{if(e.derivationDepth!==e.projectionLineage.length)t.addIssue({code:"custom",path:["derivationDepth"],message:"Derivation depth must equal projection lineage length"});let r=e.projectionLineage.at(-1);if(e.projectionId!==r)t.addIssue({code:"custom",path:["projectionId"],message:"Current projection must equal the final projection lineage entry"})})});var eE=10,Rz=82,tE,dV,fV,pV,mV,hV,gV;var Oz=w(()=>{he();tE=l.object({title:l.string().min(1).max(200),lines:l.array(l.string().min(1)).min(1).max(eE),actions:l.array(l.object({label:l.string().min(1).max(80),value:l.string().min(1).max(Rz)})).max(eE)}),dV=tE.extend({channelId:l.string().min(1),interfaceType:l.string().min(1),reactions:l.array(l.object({messageId:l.string().min(1),emoji:l.string().min(1)}))}),fV=l.object({messageId:l.string().min(1)}),pV=l.object({conversationId:l.string().min(1),noticeMessageId:l.string().min(1),value:l.string().min(1),by:l.string().min(1)}),mV=_e({channel:"chat:space-notice",request:dV,response:fV,delivery:"request"}),hV=tE.nullable(),gV=_e({channel:"chat:space-notice-action",request:pV,response:hV,delivery:"collect"})});function oi(e,t){return Object.freeze({name:e,schema:t})}var mSe;var rE=w(()=>{he();mSe=l.object({name:l.string(),schema:l.custom((e)=>typeof e==="object"&&e!==null&&("safeParse"in e))})});var nE,oE,yV,bV,SV,vV;var Cz=w(()=>{he();rE();nE={progress:"job-progress"},oE={completed:"publish:completed",failed:"publish:failed"},yV=l.object({entityType:l.string().min(1),entityId:l.string().min(1),result:l.object({id:l.string(),url:l.string().optional()})}),bV=l.object({entityType:l.string().min(1),entityId:l.string().min(1),error:l.string(),retryCount:l.number(),willRetry:l.boolean()}),SV=oi(oE.completed,yV),vV=oi(oE.failed,bV)});var Pz,zz,wV;var Nz=w(()=>{he();Pz=l.object({entityType:l.string().min(1),entityId:l.string(),metadata:l.record(l.string(),l.unknown()).default({}),content:l.string().default("")}),zz=l.object({relativePath:l.string(),leaf:l.object({start:l.number().int().nonnegative(),end:l.number().int().nonnegative()}).nullable(),owner:l.object({entityType:l.string(),id:l.string()}).optional(),writable:l.boolean().optional()}),wV=_e({channel:"sync:path:request",request:Pz,response:zz,delivery:"request"})});var xV,_V,EV,IV;var Dz=w(()=>{he();xV=l.strictObject({}),_V=l.object({branch:l.string(),hasChanges:l.boolean(),ahead:l.number(),behind:l.number(),lastCommit:l.string().nullable(),remote:l.string().nullable()}),EV=l.object({syncPath:l.string(),isInitialized:l.boolean(),watchEnabled:l.boolean(),lastSync:l.string().nullable(),totalFiles:l.number(),byEntityType:l.record(l.string(),l.number()),git:_V.nullable(),managementUrl:l.string().optional()}),IV=_e({channel:"sync:status:request",request:xV,response:EV,delivery:"request"})});var Lz=()=>{};var Bz,kV,AV;var jz=w(()=>{he();Bz=l.strictObject({waveId:l.string().trim().min(1),sourceTypes:l.array(l.string().trim().min(1)),changedTargetTypes:l.array(l.string().trim().min(1))}),kV=l.strictObject({}),AV=_e({channel:"projection:wave-ready",request:Bz,response:kV,delivery:"collect"})});var TV,$V,RV;var Zz=w(()=>{he();TV=l.strictObject({}),$V=l.string(),RV=_e({channel:"plugin:site-builder:head-scripts",request:TV,response:$V,delivery:"collect"})});function Uz(e){return typeof e==="function"}var qz=".site-build-manifest.json",OV,CV,PV;var Mz=w(()=>{he();OV=`/${qz}`;CV=l.object({outputDir:l.string(),environment:l.enum(["preview","production"]),routesBuilt:l.number(),siteConfig:l.object({title:l.string().optional(),description:l.string().optional(),url:l.string().optional(),copyright:l.string().optional(),themeMode:l.enum(["light","dark"]).optional()}),generateEntityUrl:l.custom(Uz),reportFailure:l.custom(Uz)}),PV=_e({channel:"site:build:staging",request:CV,response:l.void(),delivery:"command"})});var zV,NV,DV;var Fz=w(()=>{he();zV=l.object({id:l.string().min(1),trigger:l.string().min(1),playbookId:l.string().min(1),once:l.boolean().default(!0),starterText:l.string().min(1),description:l.string().min(1).optional(),starterPrompt:l.string().min(1)}).strict(),NV=l.object({registered:l.boolean(),id:l.string(),ignored:l.boolean().optional(),reason:l.string().optional()}),DV=_e({channel:"playbooks:register-lifecycle-starter",request:zV,response:NV,delivery:"request"})});var LV,BV,jV;var Jz=w(()=>{he();LV=l.object({id:l.string().min(1),markdown:l.string().min(1)}).strict(),BV=l.object({created:l.boolean()}),jV=_e({channel:"playbooks:seed",request:LV,response:BV,delivery:"request"})});var Kz,Cm,iE,Hz,Vz,ZV,UV;var Wz=w(()=>{he();Kz=["name","headline","industry","location","website","story"],Cm=l.enum(Kz),iE=l.object({name:l.string().optional(),headline:l.string().optional(),industry:l.string().optional(),location:l.string().optional(),website:l.string().optional(),story:l.string().optional()}),Hz=l.enum(["fill","preserve","unchanged"]),Vz=l.object({field:Cm,current:l.string().nullable(),imported:l.string(),outcome:Hz}),ZV=_e({channel:"@brains/profile:import-preview",request:l.object({fields:iE}),response:l.object({fields:l.array(Vz),changed:l.boolean(),revision:l.string()}),delivery:"request"}),UV=_e({channel:"@brains/profile:import-apply",request:l.object({fields:iE,revision:l.string()}),response:l.object({filled:l.array(Cm),kept:l.array(Cm)}),delivery:"request"})});function FV(e){return typeof e==="object"&&e!==null&&"name"in e&&typeof e.name==="string"&&"publish"in e&&typeof e.publish==="function"}var qV,MV,JV,KV,HV,VV,Gz,WV;var Qz=w(()=>{he();qV=l.enum(["provider"]),MV=l.object({executionMode:qV.optional(),publishResultIdField:l.string().min(1).optional(),publishTimestampField:l.string().min(1).optional(),enabled:l.boolean().optional()}).strict();JV=l.custom(FV),KV=l.object({entityType:l.string(),provider:JV.optional(),config:MV.optional()}),HV=_e({channel:"publish:register",request:KV,response:l.void(),delivery:"command"}),VV=l.union([l.string().min(1),l.object({location:l.enum(["metadata","frontmatter"]),field:l.string().min(1)})]),Gz=l.object({entityType:l.string().min(1),attachmentType:l.string().min(1),mediaEntityType:l.enum(["image"]),targetEntityField:VV.optional(),requiredWhen:l.object({status:l.string().min(1).optional(),visibility:l.string().min(1).optional()}).optional(),autoGenerate:l.boolean().optional(),requiredForPublish:l.boolean().optional()}),WV=_e({channel:"publish-assets:register",request:Gz,response:l.void(),delivery:"command"})});var GV,QV,YV,XV,e9,t9;var Yz=w(()=>{he();GV=l.object({entityType:l.string()}),QV=_e({channel:"generate:execute",request:GV,response:l.void(),delivery:"command"}),YV=l.object({entityType:l.string(),entityId:l.string()}),XV=_e({channel:"generate:report:success",request:YV,response:l.void(),delivery:"command"}),e9=l.object({entityType:l.string(),error:l.string()}),t9=_e({channel:"generate:report:failure",request:e9,response:l.void(),delivery:"command"})});var r9,Xz,eN,tN;var rN=w(()=>{he();r9=l.object({message:l.string().describe("Natural language response to the query"),summary:l.string().optional().describe("Brief summary if applicable"),topics:l.array(l.string()).optional().describe("Related topics mentioned"),sources:l.array(l.object({id:l.string(),type:l.string(),excerpt:l.string().optional(),relevance:l.number().min(0).max(1).optional()})).optional().describe("Source entities used to answer the query"),metadata:l.record(l.string(),l.unknown()).optional()}).describe("defaultQueryResponse"),Xz=l.object({message:l.string()}).describe("simpleTextResponse"),eN=l.object({success:l.boolean(),entityId:l.string().optional(),message:l.string()}).describe("createEntityResponse"),tN=l.object({success:l.boolean(),entityId:l.string(),changes:l.array(l.string()).optional(),message:l.string()}).describe("updateEntityResponse")});var nN,oN,n9,iN,sN,o9;var aN=w(()=>{he();nN=l.discriminatedUnion("type",[l.strictObject({type:l.literal("email"),address:l.email()})]),oN=l.strictObject({recipient:nN.optional(),title:l.string().min(1),body:l.string().min(1),html:l.string().min(1).optional(),sensitivity:l.enum(["normal","secret"]).default("normal"),idempotencyKey:l.string().trim().min(1).max(200).optional(),replyTo:l.email().optional()}),n9=l.enum(["recipient-missing","transport-missing","delivery-failed"]),iN=l.string().regex(/^[a-z0-9_:.-]{1,80}$/u),sN=l.discriminatedUnion("status",[l.strictObject({status:l.literal("sent"),deliveryId:l.string().optional()}),l.strictObject({status:l.literal("failed"),failure:n9,transportCode:iN.optional()})]),o9=_e({channel:"notifications:send",request:oN,response:sN,delivery:"request"})});var i9,cN,s9;var lN=w(()=>{he();i9=l.strictObject({}),cN=l.strictObject({titles:l.array(l.string().trim().min(1).max(500)).max(20)}),s9=_e({channel:"topics:public-titles",request:i9,response:cN,delivery:"request"})});var a9,c9,l9;var uN=w(()=>{he();a9=l.strictObject({}),c9=l.strictObject({types:l.array(l.string().trim().min(1))}),l9=_e({channel:"topics:source-types",request:a9,response:c9,delivery:"request"})});var dN,fN,u9;var pN=w(()=>{he();dN=l.strictObject({id:l.string().regex(/^[a-z0-9][a-z0-9-]{0,79}$/),title:l.string().trim().min(1).max(200),body:l.string().trim().min(1).max(20000)}),fN=l.strictObject({noteId:l.string(),created:l.boolean()}),u9=_e({channel:"note:capture",request:dN,response:fN,delivery:"request"})});var Xa,_u,d9,f9,p9,m9,h9,g9;var mN=w(()=>{he();X_();Xa=l.string().regex(/^[a-z][a-z0-9-]{0,63}$/),_u=l.string().min(32).max(512),d9=l.strictObject({provider:Xa,brainState:_u}),f9=l.strictObject({authorizationUrl:l.url({protocol:/^https?$/})}),p9=l.strictObject({provider:Xa,grant:_u}),m9=l.strictObject({provider:Xa,credential:Om}),h9=l.enum(["provider_denied","authorization_incomplete","credential_exchange_failed"]),g9=l.union([l.strictObject({provider:Xa,state:_u,grant:_u}),l.strictObject({provider:Xa,state:_u,error:h9})])});var y9,b9,S9,v9;var hN=w(()=>{he();y9=l.object({permissionLevel:l.enum(["public","trusted","admin"])}),b9=l.object({id:l.string().min(1),title:l.string().min(1),sub:l.string().optional(),href:l.string().min(1),primary:l.boolean().optional(),keywords:l.array(l.string()).optional()}),S9=l.array(b9),v9=_e({channel:"console:jump-destinations",request:y9,response:S9,delivery:"collect"})});var Pm,sE;var gN=w(()=>{he();Pm=l.enum(["github","instagram","linkedin","podcast","email","website"]),sE=l.object({platform:Pm.describe("Social media platform"),url:l.string().describe("Profile or contact URL"),label:l.string().optional().describe("Optional display label")})});function zm(e){if(!e.type.includes(":"))throw Error(`Job contract type "${e.type}" must name its owner, as "owner:job"`);return Object.freeze({type:e.type,input:e.input})}var yN,bN,w9,SN,x9;var vN=w(()=>{he();yN=l.enum(["1:1","16:9","9:16","4:3","3:4"]),bN=l.object({prompt:l.string(),title:l.string().optional(),aspectRatio:yN.optional(),targetEntityType:l.string().optional(),targetEntityId:l.string().optional(),entityTitle:l.string().optional(),entityContent:l.string().optional()}),w9=zm({type:"image:image-generate",input:bN}),SN=l.object({sourceEntityType:l.string().min(1),sourceEntityId:l.string().min(1),attachmentType:l.string().min(1),imageId:l.string().min(1),dedupKey:l.string().min(1).optional(),replace:l.boolean().optional(),targetEntityType:l.string().min(1).optional(),targetEntityId:l.string().min(1).optional(),targetImageField:l.enum(["coverImageId","ogImageId"]).optional()}),x9=zm({type:"image:image-render-source",input:SN})});var _9;var wN=w(()=>{he();_9=l.enum(["none","low","medium","high","xhigh","max"])});var Mt=w(()=>{q_();zP();H_();ez();rz();wu();iz();cz();lz();Tm();fz();pz();mz();gz();Sz();wz();xz();_z();Ez();Az();X_();Tz();$z();Oz();Cz();rE();Nz();Dz();Lz();jz();J_();Zz();Mz();Fz();Jz();Wz();Qz();Yz();rN();aN();lN();uN();pN();mN();hN();gN();vN();wN()});var A9,T9,$t,pr,gs,$9,ii="capability-bundles-v1",Dm,R9,O9,C9,P9,xN,Nm,si,qr,z9,N9,D9,L9,B9,aE,j9,Z9,Lm;var Pn=w(()=>{Mt();he();A9=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,T9=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,$t=l.string().regex(A9,"expected exact pinned version"),pr=l.string().regex(T9,"expected lowercase handle slug"),gs=l.string().min(1),$9=l.string().startsWith("age1").min(1),Dm=l.enum(["core","media","automation","web","chat","site","publishing","federation","team"]),R9=["professional","team","organization"],O9=l.enum(R9),C9=["person","team","organization"],P9=l.enum(C9),xN=l.array(Dm).min(1),Nm=l.array(l.string().min(1)),si=l.strictObject({brainVersion:$t,bundleContract:l.literal(ii),bundles:xN,add:Nm.optional(),remove:Nm.optional(),githubOrg:l.string().min(1),contentRepoPrefix:l.string().min(1),domainSuffix:l.string().min(1),aiApiKey:gs,gitSyncToken:gs,contentRepoAdminToken:gs,agePublicKey:$9}).superRefine((e,t)=>{if(new Set(e.bundles).size!==e.bundles.length)t.addIssue({code:l.ZodIssueCode.custom,path:["bundles"],message:"canonical bundles must be unique"})}),qr=l.strictObject({members:l.array(pr).min(1),brainVersionOverride:$t.optional(),bundlesOverride:xN.optional(),addOverride:Nm.optional(),removeOverride:Nm.optional(),aiApiKeyOverride:gs.optional(),gitSyncTokenOverride:gs.optional()}).superRefine((e,t)=>{if(new Set(e.members).size!==e.members.length)t.addIssue({code:l.ZodIssueCode.custom,path:["members"],message:"cohort members must be unique"});if(e.bundlesOverride&&new Set(e.bundlesOverride).size!==e.bundlesOverride.length)t.addIssue({code:l.ZodIssueCode.custom,path:["bundlesOverride"],message:"canonical bundle overrides must be unique"})}),z9=l.strictObject({platform:Pm,url:l.string().min(1),label:l.string().min(1).optional()}),N9=l.strictObject({name:l.string().min(1).optional(),description:l.string().min(1).optional(),website:l.string().min(1).optional(),email:l.string().min(1).optional(),story:l.string().min(1).optional(),socialLinks:l.array(z9).optional()}),D9=l.strictObject({delivery:l.literal("email"),email:l.string().email()}),L9=l.strictObject({enabled:l.boolean().optional(),endpoint:l.string().url().refine((e)=>new URL(e).protocol==="wss:",{message:"Jetstream endpoint must use wss"}).optional(),replayWindowSeconds:l.number().int().min(60).optional(),denyDids:l.array(l.string().startsWith("did:plc:")).optional(),denyDomains:l.array(l.string().min(1)).optional(),skillKeywords:l.array(l.string().min(1)).optional(),queueLimit:l.number().int().min(1).max(1e4).optional(),concurrency:l.number().int().min(1).max(32).optional(),perDidCooldownSeconds:l.number().int().nonnegative().optional(),fetchBudgetPerMinute:l.number().int().min(1).optional(),newAgentsPerHour:l.number().int().min(1).optional(),pendingCandidateCeiling:l.number().int().min(1).optional(),staleCandidateRetentionDays:l.number().int().min(1).optional(),requestTimeoutMs:l.number().int().min(100).optional(),maxResponseBytes:l.number().int().min(1024).optional(),maxRedirects:l.number().int().nonnegative().optional(),retryAttempts:l.number().int().min(1).optional(),heartbeatIntervalHours:l.number().min(1).optional()}),B9=l.strictObject({identifier:l.string().min(1),accountDid:l.string().min(1).optional(),lexiconAuthority:l.boolean().optional(),jetstream:L9.optional()}),aE=l.strictObject({package:l.string().min(1),version:$t.optional(),theme:l.string().min(1).optional(),themeVersion:$t.optional()}).superRefine((e,t)=>{let r=e.package.startsWith("@rizom/");if(r&&e.version===void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["version"],message:"external @rizom site packages require an exact version pin"});if(!r&&e.version!==void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["version"],message:"version is valid only for external @rizom site packages"});let o=e.theme?.startsWith("@rizom/")===!0;if(o&&e.themeVersion===void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["themeVersion"],message:"external @rizom themes require an exact version pin"});if(!o&&e.themeVersion!==void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["themeVersion"],message:"themeVersion is valid only for external @rizom themes"})}),j9=l.strictObject({onboarding:l.boolean().optional()}),Z9=l.record(l.string().min(1),l.record(l.string(),l.unknown())),Lm=l.strictObject({handle:pr,discord:l.strictObject({enabled:l.boolean(),anchorUserId:l.string().min(1).optional()}),aiApiKeyOverride:gs.optional(),gitSyncTokenOverride:gs.optional(),domainOverride:l.string().min(1).optional(),cloudflareZoneId:l.string().min(1).optional(),contentRepoOverride:l.string().min(1).optional(),profileKind:O9.optional(),anchorKind:P9.optional(),plugins:Z9.optional(),spaces:l.array(l.string().min(1)).optional(),embeddingEnabled:l.boolean().optional(),topicExtractionEnabled:l.boolean().optional(),skillDerivationEnabled:l.boolean().optional(),swotDerivationEnabled:l.boolean().optional(),addOverride:l.array(l.string().min(1)).optional(),removeOverride:l.array(l.string().min(1)).optional(),siteOverride:aE.optional(),setup:D9.optional(),atproto:B9.optional(),playbooks:j9.optional(),anchorProfile:N9.optional()})});import{access as U9,readdir as q9,readFile as M9}from"fs/promises";import{basename as cE,join as Eu,relative as F9}from"path";async function ut(e,t={}){let[r,o,n]=await Promise.all([lE(Eu(e,"pilot.yaml"),si),K9(e),H9(e)]),i=V9(o,n),s=n.map((c)=>({id:c.id,members:[...c.data.members].sort(),...ma({brainVersionOverride:c.data.brainVersionOverride,bundlesOverride:c.data.bundlesOverride,addOverride:c.data.addOverride,removeOverride:c.data.removeOverride,aiApiKeyOverride:c.data.aiApiKeyOverride,gitSyncTokenOverride:c.data.gitSyncTokenOverride})})).sort((c,u)=>c.id.localeCompare(u.id)),a=await Promise.all(o.map(async(c)=>{let u=i.get(c.data.handle);if(!u)throw new ys(`User ${c.data.handle} must belong to exactly one cohort`);let d={...J9(c.data,u,r),snapshotStatus:await Q9(e,c.data.handle)},f=await t.resolveStatus?.(d);return{...d,serverStatus:f?.serverStatus??"unknown",deployStatus:f?.deployStatus??"unknown",dnsStatus:f?.dnsStatus??"unknown",mcpStatus:f?.mcpStatus??"unknown"}}));return a.sort((c,u)=>c.handle.localeCompare(u.handle)),{pilot:r,cohorts:s,users:a}}function J9(e,t,r){let o=t.data.bundlesOverride===void 0;return{handle:e.handle,cohort:t.id,brainVersion:t.data.brainVersionOverride??r.brainVersion,bundleContract:r.bundleContract,bundles:[...t.data.bundlesOverride??r.bundles],add:_N(t.data.addOverride??(o?r.add:void 0),e.addOverride),remove:_N(t.data.removeOverride??(o?r.remove:void 0),e.removeOverride),domain:e.domainOverride??`${e.handle}${r.domainSuffix}`,...ma({cloudflareZoneId:e.cloudflareZoneId}),contentRepo:e.contentRepoOverride??`${r.contentRepoPrefix}${e.handle}-content`,...ma({profileKind:e.profileKind,anchorKind:e.anchorKind,embeddingEnabled:e.embeddingEnabled,spaces:e.spaces,plugins:e.plugins,topicExtractionEnabled:e.topicExtractionEnabled,skillDerivationEnabled:e.skillDerivationEnabled,swotDerivationEnabled:e.swotDerivationEnabled,siteOverride:e.siteOverride&&{...e.siteOverride}}),discordEnabled:e.discord.enabled,...ma({discordAnchorUserId:e.discord.anchorUserId}),effectiveAiApiKey:e.aiApiKeyOverride??t.data.aiApiKeyOverride??r.aiApiKey,effectiveGitSyncToken:e.gitSyncTokenOverride??t.data.gitSyncTokenOverride??r.gitSyncToken,...ma({setup:e.setup,atproto:e.atproto,playbooks:e.playbooks}),anchorProfile:W9(e.handle,e.anchorProfile)}}function _N(e,t){return Y9([...e??[],...t??[]])}async function K9(e){let t=Eu(e,"users"),r=(await EN(t)).filter((n)=>!cE(n).endsWith(".secrets.yaml"));return(await Promise.all(r.map(async(n)=>{let i=IN(cE(n)),s=await lE(n,Lm);if(s.handle!==i){let a=kN(F9(e,n));throw new ys(`${a} must declare handle: ${i}`)}return{id:i,data:s}}))).sort((n,i)=>n.id.localeCompare(i.id))}async function H9(e){let t=Eu(e,"cohorts"),r=await EN(t);return(await Promise.all(r.map(async(n)=>({id:IN(cE(n)),data:await lE(n,qr)})))).sort((n,i)=>n.id.localeCompare(i.id))}function V9(e,t){let r=new Map(e.map((n)=>[n.data.handle,n])),o=new Map;for(let n of t)for(let i of n.data.members){if(!r.has(i))throw new ys(`Cohort ${n.id} references unknown user ${i}`);if(o.has(i))throw new ys(`User ${i} must belong to exactly one cohort`);o.set(i,n)}for(let n of e)if(!o.has(n.data.handle))throw new ys(`User ${n.data.handle} must belong to exactly one cohort`);return o}function W9(e,t){return{name:t?.name??G9(e),...t?.description?{description:t.description}:{},...t?.website?{website:t.website}:{},...t?.email?{email:t.email}:{},...t?.story?{story:t.story}:{},...t?.socialLinks?{socialLinks:t.socialLinks.map((r)=>({platform:r.platform,url:r.url,...r.label?{label:r.label}:{}}))}:{}}}function G9(e){return e.split("-").filter((t)=>t.length>0).map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Q9(e,t){let r=Eu(e,"users",t,"brain.yaml");try{return await U9(r),"present"}catch{return"missing"}}async function EN(e){return(await q9(e,{withFileTypes:!0})).filter((r)=>r.isFile()&&r.name.endsWith(".yaml")).map((r)=>Eu(e,r.name)).sort((r,o)=>r.localeCompare(o))}async function lE(e,t){let r=await M9(e,"utf8"),o=sn(r,t);if(!o.ok)throw new ys(`${kN(e)}: ${o.error}`);return o.data}function Y9(e){return[...new Set(e)]}function IN(e){return e.replace(/\.ya?ml$/,"")}function kN(e){return e.replaceAll("\\","/")}var ys;var Mr=w(()=>{no();Pn();ys=class ys extends Error{}});import{mkdir as X9,writeFile as e7}from"fs/promises";import{join as AN}from"path";async function ao(e,t={}){let o=(t.registry??await ut(e,t)).users.map((i)=>{let s=i.discordEnabled?"on":"off";return[i.handle,i.cohort,i.bundles.join(","),i.add.join(","),i.remove.join(","),i.brainVersion,i.domain,i.contentRepo,s,i.serverStatus,i.deployStatus,i.dnsStatus,i.mcpStatus]}),n=["<!-- generated by brains-ops; do not edit -->","",t7,r7,...o.map((i)=>`| ${i.join(" | ")} |`),""].join(`
213
+ `);await X9(AN(e,"views"),{recursive:!0}),await e7(AN(e,"views","users.md"),n)}var t7="| handle | cohort | bundles | add | remove | brainVersion | domain | contentRepo | discord | serverStatus | deployStatus | dnsStatus | mcpStatus |",r7="| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |";var ec=w(()=>{Mr()});import{spawn as x7}from"child_process";var Lt=async(e,t,r={})=>new Promise((o,n)=>{let i=x7(e,t,{stdio:["pipe","inherit","inherit"],env:r.env?{...process.env,...r.env}:process.env,cwd:r.cwd});if(i.on("error",n),i.on("close",(s)=>{if(s===0){o();return}n(Error(`${e} ${t.join(" ")} exited with code ${s??1}`))}),r.stdin)i.stdin.end(r.stdin);else i.stdin.end()});var zn=()=>{};async function ON(e,t,r=Lt){let o=`${e}:${t.tag}`;try{await r("docker",["run","--rm","--pull","always","--network","none","--read-only","--user","65534:65534","--cap-drop","ALL","--security-opt","no-new-privileges","--entrypoint","bun",o,"-e",_7,"--",JSON.stringify([`@rizom/brain@${t.brainVersion}`,...t.sitePackages])])}catch(n){throw Error(`Cannot verify required packages in ${o}; refusing image reuse. Do not overwrite a deployed tag. Inspect the image inventory and rollout plan.`,{cause:n})}}var _7=`
214
214
  const specs = JSON.parse(process.argv.at(-1));
215
215
  for (const spec of specs) {
216
216
  const separator = spec.lastIndexOf("@");
@@ -222,9 +222,9 @@ for (const spec of specs) {
222
222
  throw new Error("Image requires " + spec + "; found " + manifest.name + "@" + manifest.version);
223
223
  }
224
224
  }
225
- `;var CN=w(()=>{zn()});import{lstat as hE,mkdir as PN,readFile as zN,unlink as _7,writeFile as NN}from"fs/promises";import{join as cn}from"path";import{isDeepStrictEqual as E7}from"util";function jN(e){return cn("deploy","runtime",I7.parse(e.tag))}function ZN(e){let t={"@rizom/brain":$t.parse(e.brainVersion)};for(let r of[...e.sitePackages].sort()){let o=r.lastIndexOf("@"),n=LN.parse(r.slice(0,o)),i=$t.parse(r.slice(o+1));if(t[n]!==void 0&&t[n]!==i)throw Error(`Conflicting runtime dependency pin: ${r}`);t[n]=i}return BN.parse({name:"rover-pilot-runtime",private:!0,packageManager:"bun@1.4.0",dependencies:t,overrides:{"postcss-selector-parser":"7.1.6"}})}async function gE(e){try{return await hE(e),!0}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return!1;throw t}}async function DN(e){if(!(await hE(e)).isFile())throw Error(`Runtime lock input must be a regular file: ${e}`)}async function UN(e){if(!(await hE(e)).isDirectory())throw Error(`Runtime lock input must be a directory: ${e}`)}async function qN(e){for(let t of["deploy",cn("deploy","runtime")]){let r=cn(e,t);if(await gE(r))await UN(r)}}async function mE(e,t){let r=cn(e,"package.json"),o=cn(e,"bun.lock");await DN(r),await DN(o);let n=BN.parse(JSON.parse(await zN(r,"utf8")));if(!E7(n,ZN(t)))throw Error(`Runtime dependency manifest does not match ${t.tag}`);if(!(await zN(o,"utf8")).trim())throw Error(`Empty runtime dependency lock: ${o}`)}async function yE(e,t){await qN(e);let r=cn(e,jN(t));if(await UN(r),await gE(cn(r,".incomplete")))throw Error(`Incomplete runtime dependency lock: ${r}`);await mE(r,t)}async function MN(e,t,r=Lt){if(Bun.version!=="1.4.0")throw Error("Runtime dependency locks must be generated with Bun 1.4.0");let o=ZN(t);await qN(e);let n=cn(e,jN(t));if(await gE(n))return await yE(e,t),"existing";await PN(cn(e,"deploy","runtime"),{recursive:!0}),await PN(n);let i=cn(n,".incomplete");return await NN(i,`Runtime dependency resolution has not completed.
225
+ `;var CN=w(()=>{zn()});import{lstat as hE,mkdir as PN,readFile as zN,unlink as E7,writeFile as NN}from"fs/promises";import{join as cn}from"path";import{isDeepStrictEqual as I7}from"util";function jN(e){return cn("deploy","runtime",k7.parse(e.tag))}function ZN(e){let t={"@rizom/brain":$t.parse(e.brainVersion)};for(let r of[...e.sitePackages].sort()){let o=r.lastIndexOf("@"),n=LN.parse(r.slice(0,o)),i=$t.parse(r.slice(o+1));if(t[n]!==void 0&&t[n]!==i)throw Error(`Conflicting runtime dependency pin: ${r}`);t[n]=i}return BN.parse({name:"rover-pilot-runtime",private:!0,packageManager:"bun@1.4.0",dependencies:t,overrides:{"postcss-selector-parser":"7.1.6"}})}async function gE(e){try{return await hE(e),!0}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return!1;throw t}}async function DN(e){if(!(await hE(e)).isFile())throw Error(`Runtime lock input must be a regular file: ${e}`)}async function UN(e){if(!(await hE(e)).isDirectory())throw Error(`Runtime lock input must be a directory: ${e}`)}async function qN(e){for(let t of["deploy",cn("deploy","runtime")]){let r=cn(e,t);if(await gE(r))await UN(r)}}async function mE(e,t){let r=cn(e,"package.json"),o=cn(e,"bun.lock");await DN(r),await DN(o);let n=BN.parse(JSON.parse(await zN(r,"utf8")));if(!I7(n,ZN(t)))throw Error(`Runtime dependency manifest does not match ${t.tag}`);if(!(await zN(o,"utf8")).trim())throw Error(`Empty runtime dependency lock: ${o}`)}async function yE(e,t){await qN(e);let r=cn(e,jN(t));if(await UN(r),await gE(cn(r,".incomplete")))throw Error(`Incomplete runtime dependency lock: ${r}`);await mE(r,t)}async function MN(e,t,r=Lt){if(Bun.version!=="1.4.0")throw Error("Runtime dependency locks must be generated with Bun 1.4.0");let o=ZN(t);await qN(e);let n=cn(e,jN(t));if(await gE(n))return await yE(e,t),"existing";await PN(cn(e,"deploy","runtime"),{recursive:!0}),await PN(n);let i=cn(n,".incomplete");return await NN(i,`Runtime dependency resolution has not completed.
226
226
  `,{flag:"wx"}),await NN(cn(n,"package.json"),`${JSON.stringify(o,null,2)}
227
- `,{flag:"wx"}),await r(process.execPath,["install","--lockfile-only","--ignore-scripts"],{cwd:n}),await mE(n,t),await r(process.execPath,["install","--frozen-lockfile","--ignore-scripts","--dry-run"],{cwd:n}),await mE(n,t),await _7(i),"created"}var I7,LN,BN;var bE=w(()=>{he();Pn();zn();I7=l.string().regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}$/),LN=l.string().regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/),BN=l.strictObject({name:l.literal("rover-pilot-runtime"),private:l.literal(!0),packageManager:l.literal("bun@1.4.0"),dependencies:l.record(LN,$t),overrides:l.strictObject({"postcss-selector-parser":l.literal("7.1.6")})})});import{createHash as k7}from"crypto";function Iu(e,t=[]){let r=`brain-${e}`,o=[...new Set(t)].sort();if(o.length===0)return r;let n=`${r}--${o.map((a)=>a.replace(/^@/,"").replace("/","-").replace(/@(?=[^@]*$)/,"-")).join("--")}`,s=`--s${k7("sha256").update(JSON.stringify([e,...o])).digest("hex").slice(0,12)}`;return`${n.length+s.length<=A7?n:r}${s}`}function jm(e){if(!e)return[];return[FN(e.package,e.version),FN(e.theme,e.themeVersion)].filter((t)=>t!==void 0)}function FN(e,t){if(!e?.startsWith("@rizom/"))return;if(t===void 0)throw Error(`Package ${e} has no explicit version pin`);return`${e}@${t}`}function JN(e){let t=new Map;for(let r of e){let o=[...new Set(jm(r.siteOverride))].sort(),n=Iu(r.brainVersion,o),i=t.get(n);if(i&&(i.brainVersion!==r.brainVersion||!Bun.deepEquals(i.sitePackages,o)))throw Error(`Image tag collision for distinct runtime requirements: ${n}`);t.set(n,{tag:n,brainVersion:r.brainVersion,sitePackages:o})}return[...t.values()].sort((r,o)=>r.tag.localeCompare(o.tag))}function T7(e,t){let r=new Map;for(let o of[...e,...t]){let n=o.lastIndexOf("@"),i=n>0?o.slice(0,n):o,s=r.get(i);if(s&&s!==o)throw Error(`Fleet shared images have conflicting pins for ${i}: ${s} and ${o}`);r.set(i,o)}return[...r.values()].sort()}async function Zm(e){let t=e.brainVersionInput?.trim()??"";if(t){let o=T7([],(e.sitePackagesInput??"").split(/\s+/).filter(Boolean)),n=Iu(t,o);if(!e.allowTagOverwrite&&await e.imageExists(n))throw Error(`Image tag ${n} already exists; published tags are immutable. Pick a new version, or pass overwrite=true only when replacing a tag whose containers were never deployed.`);return[{tag:n,brainVersion:t,sitePackages:o}]}let r=[];for(let o of JN(e.users))if(!await e.imageExists(o.tag))r.push(o);else await e.verifyImage(o);return r}async function $7(e,t,r){try{return await e("docker",["manifest","inspect",`${t}:${r}`]),!0}catch(o){if(o instanceof Error&&/exited with code/.test(o.message))return!1;throw o}}async function R7(e){let t=e.env??process.env,r=e.runCommand??Lt,o=e.log??console.log,n=t.BRAIN_VERSION_INPUT?.trim()??"",i=t.SITE_PACKAGES_INPUT?.trim()??"",s=t.ALLOW_TAG_OVERWRITE?.trim()==="true",{users:a}=await ut(e.rootDir),c=await Zm({users:a,brainVersionInput:n,sitePackagesInput:i,allowTagOverwrite:s,imageExists:(u)=>$7(r,e.imageRepository,u),verifyImage:(u)=>ON(e.imageRepository,u,r)});for(let u of c){try{await yE(e.rootDir,u)}catch(d){throw Error(`Missing or invalid runtime lock for ${u.tag}; run brains-ops images:lock and commit its reviewed package.json and bun.lock before building.`,{cause:d})}o(`build needed: ${u.tag} (brain ${u.brainVersion}${u.sitePackages.length>0?`, sites ${u.sitePackages.join(" ")}`:""})`)}if(c.length===0)o("All declared images already exist; nothing to build.");return e.writeOutput("images_json",JSON.stringify(c.map((u)=>({tag:u.tag,brain_version:u.brainVersion,site_packages:u.sitePackages.join(" ")})))),c}var A7=128;var Um=w(()=>{CN();bE();Mr();zn()});var HN,O7,C7,P7,lo,ku,z7,SE,N7,KN,D7,L7,VN,j0e,WN;var qm=w(()=>{Z_();HN=["primary","secondary"],O7=l.custom((e)=>typeof e==="function","Expected a React component"),C7=l.strictObject({show:l.boolean().optional(),label:l.string().min(1).optional(),slot:l.enum(HN).optional(),priority:l.number().optional()}),P7=l.strictObject({id:l.string().min(1),template:l.string().min(1),content:l.unknown().optional(),dataQuery:l.looseObject({entityType:l.string().optional(),template:l.string().optional(),query:l.record(l.string(),l.unknown()).optional()}).optional(),order:l.number().optional()}),lo=l.string().regex(/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/,{message:"must be a language tag such as en or zh-TW"}),ku=l.strictObject({title:l.string().optional(),description:l.string().optional(),navigationLabel:l.string().optional()}),z7=l.strictObject({id:l.string().min(1),path:l.string().startsWith("/"),title:l.string().optional(),pageLabel:l.string().optional(),description:l.string().optional(),sections:l.array(P7).optional(),layout:l.string().min(1).optional(),fullscreen:l.boolean().optional(),pluginId:l.string().optional(),sourceEntityType:l.string().optional(),external:l.boolean().optional(),navigation:C7.optional(),translations:l.record(lo,ku).optional()}),SE=l.strictObject({label:l.string().min(1),pluralName:l.string().min(1).optional(),layout:l.string().min(1).optional(),detailTemplate:l.string().min(1).optional(),paginate:l.boolean().optional(),pageSize:l.number().int().positive().optional(),citable:l.boolean().optional(),navigation:l.strictObject({show:l.boolean().optional(),slot:l.enum(HN).optional(),priority:l.number().optional()}).optional()}),N7=l.strictObject({schema:l.custom((e)=>e instanceof l.ZodType,"Expected a Zod schema"),component:l.custom((e)=>typeof e==="function","Expected a React component"),title:l.string().min(1),description:l.string(),requiredPermission:l.enum(["admin","trusted","public"]).optional(),fullscreen:l.boolean().optional()}),KN=l.strictObject({namespace:l.string().min(1),sections:l.record(l.string(),N7)}),D7=l.record(l.string(),l.json()),L7=l.record(l.string(),l.record(l.string(),D7)),VN={layouts:l.record(l.string(),O7).refine((e)=>typeof e.default==="function",{message:'Site layouts must include a "default" component'}),routes:l.array(z7),content:L7.optional(),sections:l.union([KN,l.array(KN)]).optional(),themeOverride:l.string().optional(),headScripts:l.array(l.string()).optional(),entityDisplay:l.record(l.string(),SE),staticAssets:l.record(l.string(),l.string()).optional(),languages:l.array(lo).min(1).optional()},j0e=l.strictObject(VN).partial(),WN=l.strictObject(VN).superRefine((e,t)=>{let r=e.languages??[],o=new Set;for(let[c,u]of r.entries()){let d=u.toLowerCase();if(o.has(d))t.addIssue({code:"custom",path:["languages",c],message:`Language "${u}" is declared twice`});o.add(d)}let n=r.slice(1).map((c)=>`/${c.toLowerCase()}`),i=new Set;for(let[c,u]of e.routes.entries()){if(i.has(u.id))t.addIssue({code:"custom",path:["routes",c,"id"],message:`Duplicate route id "${u.id}"`});i.add(u.id);let d=u.path.toLowerCase(),f=n.find((h)=>d===h||d.startsWith(`${h}/`));if(f)t.addIssue({code:"custom",path:["routes",c,"path"],message:`Route path "${u.path}" is under ${f}, where another language's pages are built`});let m=u.layout??"default";if(!e.layouts[m])t.addIssue({code:"custom",path:["routes",c,"layout"],message:`Unknown layout "${m}"`});for(let[h,b]of(u.sections??[]).entries()){let y=/^([^:.\s]+)\.([^:.\s]+)$/.exec(b.template);if(y)t.addIssue({code:"custom",path:["routes",c,"sections",h,"template"],message:`Section template "${b.template}" is written "${y[1]}:${y[2]}"`})}}let s=Array.isArray(e.sections)?e.sections:e.sections?[e.sections]:[],a=new Map(s.map((c)=>[c.namespace,c]));if(a.size!==s.length)t.addIssue({code:"custom",path:["sections"],message:"Section group namespaces must be unique"});for(let[c,u]of Object.entries(e.content??{})){let d=a.get(c);if(!d){t.addIssue({code:"custom",path:["content",c],message:`Content namespace "${c}" has no section group`});continue}for(let[f,m]of Object.entries(u)){let h=d.sections[f];if(!h){t.addIssue({code:"custom",path:["content",c,f],message:`Content section "${c}:${f}" is not defined`});continue}let b=h.schema.safeParse(m);if(!b.success)t.addIssue({code:"custom",path:["content",c,f],message:`Content does not satisfy the "${c}:${f}" schema: ${l.prettifyError(b.error)}`})}}})});var GN,QN,YN,Mm,XN,j7,e2,t2,Z7,r2,n2,U7,Fm;var vE=w(()=>{Mt();he();qm();qm();GN=l.object({id:l.string(),template:l.string(),content:l.unknown().optional(),dataQuery:l.looseObject({entityType:l.string().optional(),template:l.string().optional(),query:l.looseObject({id:l.string().optional(),limit:l.number().optional(),offset:l.number().optional()}).optional()}).optional(),order:l.number().optional()}),QN=["primary","secondary"],YN=l.object({show:l.boolean().default(!1),label:l.string().optional(),slot:l.enum(QN).default("primary"),priority:l.number().min(0).max(100).default(50)}).optional(),Mm=l.object({id:l.string(),path:l.string(),title:l.string().default(""),pageLabel:l.string().optional(),description:l.string().default(""),sections:l.array(GN).default([]),layout:l.string().default("default"),fullscreen:l.boolean().optional(),pluginId:l.string().optional(),sourceEntityType:l.string().optional(),external:l.boolean().optional(),navigation:YN,translations:l.record(lo,ku).optional(),languages:l.array(lo).optional()}),XN=l.object({routes:l.array(Mm),pluginId:l.string()}),j7=_e({channel:"plugin:site-builder:route:register",request:XN,response:l.void(),delivery:"command"}),e2=l.strictObject({}),t2=l.array(Mm),Z7=_e({channel:"site-builder:routes:list",request:e2,response:t2,delivery:"request"}),r2=l.strictObject({}),n2=l.array(Mm),U7=_e({channel:"plugin:site-builder:pages",request:r2,response:n2,delivery:"collect"}),Fm=l.object({label:l.string(),href:l.string(),priority:l.number()})});var o2,i2,s2,q7;var a2=w(()=>{Mt();he();o2=l.object({pluginId:l.string(),slotName:l.string(),render:l.custom((e)=>typeof e==="function"),priority:l.number().optional()}),i2=l.strictObject({}),s2=l.array(o2),q7=_e({channel:"plugin:site-builder:slots",request:i2,response:s2,delivery:"collect"})});var c2="site:metadata:updated",Jm,l2,u2,rc,d2,M7,F7,J7;var wE=w(()=>{Mt();he();vE();Jm=l.object({heading:l.string().describe("Main CTA heading text"),buttonText:l.string().describe("Call-to-action button text"),buttonLink:l.string().describe("URL or anchor for the CTA button")}),l2=l.object({title:l.string().optional(),description:l.string().optional(),copyright:l.string().optional(),cta:Jm.optional()}),u2=l.object({blurb:l.string().optional().describe("Short italic subtitle under the section title")}),rc=l.object({represents:l.enum(["brain","anchor"]).default("anchor").describe("Identity represented by the site"),title:l.string().describe("The site's title"),description:l.string().describe("The site's description"),url:l.string().optional().describe("Canonical site URL"),copyright:l.string().optional().describe("Copyright notice text"),logo:l.boolean().optional().describe("Whether to display logo instead of title text in header"),themeMode:l.enum(["light","dark"]).optional().describe("Default theme mode"),analyticsScript:l.string().optional().describe("Analytics script HTML"),cta:Jm.optional().describe("Call-to-action configuration"),sections:l.record(l.string(),u2).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers."),translations:l.record(lo,l2).optional().describe("The site's title, description, copyright and call to action in its other languages, keyed by language tag. A site is built in a language only once it has one.")}),d2=l.strictObject({}),M7=_e({channel:"site:metadata:get",request:d2,response:rc,delivery:"request"}),F7=oi(c2,rc),J7=rc.extend({copyright:l.string(),navigation:l.object({primary:l.array(Fm),secondary:l.array(Fm)}),socialLinks:l.array(sE).optional().describe("Social media links from profile metadata"),photo:l.string().optional().describe("The anchor's photo, as ![alt](entity://image/<id>)")})});var e_e;var xE=w(()=>{he();e_e=l.record(l.string(),l.unknown())});var Au=w(()=>{xE()});var f2=w(()=>{Mt();Au()});var p2=w(()=>{Au();Mt()});var m2=w(()=>{Au();Mt()});var g_e;var h2=w(()=>{he();g_e=l.record(l.string(),l.unknown())});var S_e;var g2=w(()=>{he();ya();S_e=l.record(l.string(),l.unknown())});var y2=w(()=>{ya()});var b2=w(()=>{Au();f2();p2();m2();h2();g2();y2();xE()});var tW;var S2=w(()=>{he();tW=l.object({slug:l.string(),title:l.string(),type:l.string(),entityId:l.string(),contentHash:l.string()})});var EE=w(()=>{b2();S2()});var v2=w(()=>{EE();he()});var rW,nW,oW;var Hm=w(()=>{he();Mt();rW={url:l.string(),typeLabel:l.string(),listUrl:l.string(),listLabel:l.string()},nW={url:l.string().nullable().default(null),typeLabel:l.string().nullable().default(null),listUrl:l.string().nullable().default(null),listLabel:l.string().nullable().default(null)},oW=l.object({name:l.string(),description:l.string(),schema:l.unknown(),basePrompt:l.string().optional(),useKnowledgeContext:l.boolean().optional(),requiredPermission:l.enum(["admin","trusted","public"]),formatter:l.unknown().optional(),overlayFormatter:l.unknown().optional(),layout:l.object({component:l.unknown().optional(),fullscreen:l.boolean().optional(),formats:l.unknown().optional()}).optional(),dataSourceId:l.string().optional()})});var Vm=w(()=>{Hm()});var _2=w(()=>{Vm()});var IE=()=>{};var sW,aW,nc,E2,cW;var I2=w(()=>{Mt();he();IE();sW=l.enum(["admin","trusted","public"]),aW=l.enum(["create","update","delete","extract","publish"]),nc=l.enum(["never","admin","trusted","public"]),E2=l.strictObject({create:nc.optional(),update:nc.optional(),delete:nc.optional(),extract:nc.optional(),publish:nc.optional()}),cW=l.record(l.string(),E2)});var k2=w(()=>{Vm();Hm()});var lW,uW,Wm,dW,fW,pW;var A2=w(()=>{he();lW=l.enum(["site-content-preview","site-content-production"]),uW=l.enum(["web","image","pdf","epub"]),Wm=l.custom((e)=>typeof e==="function"),dW=l.object({name:l.string(),schema:l.unknown(),description:l.string().optional(),pluginId:l.string(),renderers:l.object({web:l.union([Wm,l.string()]).optional(),image:l.union([Wm,l.string()]).optional(),pdf:l.union([Wm,l.string()]).optional(),epub:l.union([Wm,l.string()]).optional()})}),fW=l.object({enableContentGeneration:l.boolean().default(!1),outputDir:l.string(),workingDir:l.string().optional(),environment:l.enum(["preview","production"]).default("preview"),siteConfig:l.object({title:l.string(),description:l.string(),url:l.string().optional()}).optional()}),pW=l.object({success:l.boolean(),routesBuilt:l.number(),errors:l.array(l.string()).optional(),warnings:l.array(l.string()).optional()})});var T2=w(()=>{Hm();_2();Vm();I2();IE();k2();A2()});var kE=ge(function(hW,Gm){(function(){function e(g,E){Object.defineProperty(o.prototype,g,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",E[0],E[1])}})}function t(g){if(g===null||typeof g!=="object")return null;return g=De&&g[De]||g["@@iterator"],typeof g==="function"?g:null}function r(g,E){g=(g=g.constructor)&&(g.displayName||g.name)||"ReactClass";var D=g+"."+E;Qe[D]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",E,g),Qe[D]=!0)}function o(g,E,D){this.props=g,this.context=E,this.refs=Nt,this.updater=D||St}function n(){}function i(g,E,D){this.props=g,this.context=E,this.refs=Nt,this.updater=D||St}function s(){}function a(g){return""+g}function c(g){try{a(g);var E=!1}catch(q){E=!0}if(E){E=console;var D=E.error,J=typeof Symbol==="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return D.call(E,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",J),a(g)}}function u(g){if(g==null)return null;if(typeof g==="function")return g.$$typeof===In?null:g.displayName||g.name||null;if(typeof g==="string")return g;switch(g){case H:return"Fragment";case re:return"Profiler";case G:return"StrictMode";case ve:return"Suspense";case ke:return"SuspenseList";case Ue:return"Activity"}if(typeof g==="object")switch(typeof g.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case N:return"Portal";case pe:return g.displayName||"Context";case ae:return(g._context.displayName||"Context")+".Consumer";case be:var E=g.render;return g=g.displayName,g||(g=E.displayName||E.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case Ie:return E=g.displayName||null,E!==null?E:u(g.type)||"Memo";case we:E=g._payload,g=g._init;try{return u(g(E))}catch(D){}}return null}function d(g){if(g===H)return"<>";if(typeof g==="object"&&g!==null&&g.$$typeof===we)return"<...>";try{var E=u(g);return E?"<"+E+">":"<...>"}catch(D){return"<...>"}}function f(){var g=Le.A;return g===null?null:g.getOwner()}function m(){return Error("react-stack-top-frame")}function h(g){if(ro.call(g,"key")){var E=Object.getOwnPropertyDescriptor(g,"key").get;if(E&&E.isReactWarning)return!1}return g.key!==void 0}function b(g,E){function D(){es||(es=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",E))}D.isReactWarning=!0,Object.defineProperty(g,"key",{get:D,configurable:!0})}function y(){var g=u(this.type);return ts[g]||(ts[g]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),g=this.props.ref,g!==void 0?g:null}function S(g,E,D,J,q,te){var se=D.ref;return g={$$typeof:M,type:g,key:E,props:D,_owner:J},(se!==void 0?se:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:y}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:q}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function x(g,E){return E=S(g.type,E,g.props,g._owner,g._debugStack,g._debugTask),g._store&&(E._store.validated=g._store.validated),E}function _(g){A(g)?g._store&&(g._store.validated=1):typeof g==="object"&&g!==null&&g.$$typeof===we&&(g._payload.status==="fulfilled"?A(g._payload.value)&&g._payload.value._store&&(g._payload.value._store.validated=1):g._store&&(g._store.validated=1))}function A(g){return typeof g==="object"&&g!==null&&g.$$typeof===M}function O(g){var E={"=":"=0",":":"=2"};return"$"+g.replace(/[=:]/g,function(D){return E[D]})}function L(g,E){return typeof g==="object"&&g!==null&&g.key!=null?(c(g.key),O(""+g.key)):E.toString(36)}function z(g){switch(g.status){case"fulfilled":return g.value;case"rejected":throw g.reason;default:switch(typeof g.status==="string"?g.then(s,s):(g.status="pending",g.then(function(E){g.status==="pending"&&(g.status="fulfilled",g.value=E)},function(E){g.status==="pending"&&(g.status="rejected",g.reason=E)})),g.status){case"fulfilled":return g.value;case"rejected":throw g.reason}}throw g}function K(g,E,D,J,q){var te=typeof g;if(te==="undefined"||te==="boolean")g=null;var se=!1;if(g===null)se=!0;else switch(te){case"bigint":case"string":case"number":se=!0;break;case"object":switch(g.$$typeof){case M:case N:se=!0;break;case we:return se=g._init,K(se(g._payload),E,D,J,q)}}if(se){se=g,q=q(se);var ye=J===""?"."+L(se,0):J;return $r(q)?(D="",ye!=null&&(D=ye.replace(da,"$&/")+"/"),K(q,E,D,"",function($e){return $e})):q!=null&&(A(q)&&(q.key!=null&&(se&&se.key===q.key||c(q.key)),D=x(q,D+(q.key==null||se&&se.key===q.key?"":(""+q.key).replace(da,"$&/")+"/")+ye),J!==""&&se!=null&&A(se)&&se.key==null&&se._store&&!se._store.validated&&(D._store.validated=2),q=D),E.push(q)),1}if(se=0,ye=J===""?".":J+":",$r(g))for(var fe=0;fe<g.length;fe++)J=g[fe],te=ye+L(J,fe),se+=K(J,E,D,te,q);else if(fe=t(g),typeof fe==="function")for(fe===g.entries&&(Fo||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),Fo=!0),g=fe.call(g),fe=0;!(J=g.next()).done;)J=J.value,te=ye+L(J,fe++),se+=K(J,E,D,te,q);else if(te==="object"){if(typeof g.then==="function")return K(z(g),E,D,J,q);throw E=String(g),Error("Objects are not valid as a React child (found: "+(E==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":E)+"). If you meant to render a collection of children, use an array instead.")}return se}function P(g,E,D){if(g==null)return g;var J=[],q=0;return K(g,J,"","",function(te){return E.call(D,te,q++)}),J}function W(g){if(g._status===-1){var E=g._ioInfo;E!=null&&(E.start=E.end=performance.now()),E=g._result;var D=E();if(D.then(function(q){if(g._status===0||g._status===-1){g._status=1,g._result=q;var te=g._ioInfo;te!=null&&(te.end=performance.now()),D.status===void 0&&(D.status="fulfilled",D.value=q)}},function(q){if(g._status===0||g._status===-1){g._status=2,g._result=q;var te=g._ioInfo;te!=null&&(te.end=performance.now()),D.status===void 0&&(D.status="rejected",D.reason=q)}}),E=g._ioInfo,E!=null){E.value=D;var J=D.displayName;typeof J==="string"&&(E.name=J)}g._status===-1&&(g._status=0,g._result=D)}if(g._status===1)return E=g._result,E===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
227
+ `,{flag:"wx"}),await r(process.execPath,["install","--lockfile-only","--ignore-scripts"],{cwd:n}),await mE(n,t),await r(process.execPath,["install","--frozen-lockfile","--ignore-scripts","--dry-run"],{cwd:n}),await mE(n,t),await E7(i),"created"}var k7,LN,BN;var bE=w(()=>{he();Pn();zn();k7=l.string().regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}$/),LN=l.string().regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/),BN=l.strictObject({name:l.literal("rover-pilot-runtime"),private:l.literal(!0),packageManager:l.literal("bun@1.4.0"),dependencies:l.record(LN,$t),overrides:l.strictObject({"postcss-selector-parser":l.literal("7.1.6")})})});import{createHash as A7}from"crypto";function Iu(e,t=[]){let r=`brain-${e}`,o=[...new Set(t)].sort();if(o.length===0)return r;let n=`${r}--${o.map((a)=>a.replace(/^@/,"").replace("/","-").replace(/@(?=[^@]*$)/,"-")).join("--")}`,s=`--s${A7("sha256").update(JSON.stringify([e,...o])).digest("hex").slice(0,12)}`;return`${n.length+s.length<=T7?n:r}${s}`}function jm(e){if(!e)return[];return[FN(e.package,e.version),FN(e.theme,e.themeVersion)].filter((t)=>t!==void 0)}function FN(e,t){if(!e?.startsWith("@rizom/"))return;if(t===void 0)throw Error(`Package ${e} has no explicit version pin`);return`${e}@${t}`}function JN(e){let t=new Map;for(let r of e){let o=[...new Set(jm(r.siteOverride))].sort(),n=Iu(r.brainVersion,o),i=t.get(n);if(i&&(i.brainVersion!==r.brainVersion||!Bun.deepEquals(i.sitePackages,o)))throw Error(`Image tag collision for distinct runtime requirements: ${n}`);t.set(n,{tag:n,brainVersion:r.brainVersion,sitePackages:o})}return[...t.values()].sort((r,o)=>r.tag.localeCompare(o.tag))}function $7(e,t){let r=new Map;for(let o of[...e,...t]){let n=o.lastIndexOf("@"),i=n>0?o.slice(0,n):o,s=r.get(i);if(s&&s!==o)throw Error(`Fleet shared images have conflicting pins for ${i}: ${s} and ${o}`);r.set(i,o)}return[...r.values()].sort()}async function Zm(e){let t=e.brainVersionInput?.trim()??"";if(t){let o=$7([],(e.sitePackagesInput??"").split(/\s+/).filter(Boolean)),n=Iu(t,o);if(!e.allowTagOverwrite&&await e.imageExists(n))throw Error(`Image tag ${n} already exists; published tags are immutable. Pick a new version, or pass overwrite=true only when replacing a tag whose containers were never deployed.`);return[{tag:n,brainVersion:t,sitePackages:o}]}let r=[];for(let o of JN(e.users))if(!await e.imageExists(o.tag))r.push(o);else await e.verifyImage(o);return r}async function R7(e,t,r){try{return await e("docker",["manifest","inspect",`${t}:${r}`]),!0}catch(o){if(o instanceof Error&&/exited with code/.test(o.message))return!1;throw o}}async function O7(e){let t=e.env??process.env,r=e.runCommand??Lt,o=e.log??console.log,n=t.BRAIN_VERSION_INPUT?.trim()??"",i=t.SITE_PACKAGES_INPUT?.trim()??"",s=t.ALLOW_TAG_OVERWRITE?.trim()==="true",{users:a}=await ut(e.rootDir),c=await Zm({users:a,brainVersionInput:n,sitePackagesInput:i,allowTagOverwrite:s,imageExists:(u)=>R7(r,e.imageRepository,u),verifyImage:(u)=>ON(e.imageRepository,u,r)});for(let u of c){try{await yE(e.rootDir,u)}catch(d){throw Error(`Missing or invalid runtime lock for ${u.tag}; run brains-ops images:lock and commit its reviewed package.json and bun.lock before building.`,{cause:d})}o(`build needed: ${u.tag} (brain ${u.brainVersion}${u.sitePackages.length>0?`, sites ${u.sitePackages.join(" ")}`:""})`)}if(c.length===0)o("All declared images already exist; nothing to build.");return e.writeOutput("images_json",JSON.stringify(c.map((u)=>({tag:u.tag,brain_version:u.brainVersion,site_packages:u.sitePackages.join(" ")})))),c}var T7=128;var Um=w(()=>{CN();bE();Mr();zn()});var HN,C7,P7,z7,lo,ku,N7,SE,D7,KN,L7,B7,VN,Z0e,WN;var qm=w(()=>{Z_();HN=["primary","secondary"],C7=l.custom((e)=>typeof e==="function","Expected a React component"),P7=l.strictObject({show:l.boolean().optional(),label:l.string().min(1).optional(),slot:l.enum(HN).optional(),priority:l.number().optional()}),z7=l.strictObject({id:l.string().min(1),template:l.string().min(1),content:l.unknown().optional(),dataQuery:l.looseObject({entityType:l.string().optional(),template:l.string().optional(),query:l.record(l.string(),l.unknown()).optional()}).optional(),order:l.number().optional()}),lo=l.string().regex(/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/,{message:"must be a language tag such as en or zh-TW"}),ku=l.strictObject({title:l.string().optional(),description:l.string().optional(),navigationLabel:l.string().optional()}),N7=l.strictObject({id:l.string().min(1),path:l.string().startsWith("/"),title:l.string().optional(),pageLabel:l.string().optional(),description:l.string().optional(),sections:l.array(z7).optional(),layout:l.string().min(1).optional(),fullscreen:l.boolean().optional(),pluginId:l.string().optional(),sourceEntityType:l.string().optional(),external:l.boolean().optional(),navigation:P7.optional(),translations:l.record(lo,ku).optional()}),SE=l.strictObject({label:l.string().min(1),pluralName:l.string().min(1).optional(),layout:l.string().min(1).optional(),detailTemplate:l.string().min(1).optional(),paginate:l.boolean().optional(),pageSize:l.number().int().positive().optional(),citable:l.boolean().optional(),navigation:l.strictObject({show:l.boolean().optional(),slot:l.enum(HN).optional(),priority:l.number().optional()}).optional()}),D7=l.strictObject({schema:l.custom((e)=>e instanceof l.ZodType,"Expected a Zod schema"),component:l.custom((e)=>typeof e==="function","Expected a React component"),title:l.string().min(1),description:l.string(),requiredPermission:l.enum(["admin","trusted","public"]).optional(),fullscreen:l.boolean().optional()}),KN=l.strictObject({namespace:l.string().min(1),sections:l.record(l.string(),D7)}),L7=l.record(l.string(),l.json()),B7=l.record(l.string(),l.record(l.string(),L7)),VN={layouts:l.record(l.string(),C7).refine((e)=>typeof e.default==="function",{message:'Site layouts must include a "default" component'}),routes:l.array(N7),content:B7.optional(),sections:l.union([KN,l.array(KN)]).optional(),themeOverride:l.string().optional(),headScripts:l.array(l.string()).optional(),entityDisplay:l.record(l.string(),SE),staticAssets:l.record(l.string(),l.string()).optional(),languages:l.array(lo).min(1).optional()},Z0e=l.strictObject(VN).partial(),WN=l.strictObject(VN).superRefine((e,t)=>{let r=e.languages??[],o=new Set;for(let[c,u]of r.entries()){let d=u.toLowerCase();if(o.has(d))t.addIssue({code:"custom",path:["languages",c],message:`Language "${u}" is declared twice`});o.add(d)}let n=r.slice(1).map((c)=>`/${c.toLowerCase()}`),i=new Set;for(let[c,u]of e.routes.entries()){if(i.has(u.id))t.addIssue({code:"custom",path:["routes",c,"id"],message:`Duplicate route id "${u.id}"`});i.add(u.id);let d=u.path.toLowerCase(),f=n.find((h)=>d===h||d.startsWith(`${h}/`));if(f)t.addIssue({code:"custom",path:["routes",c,"path"],message:`Route path "${u.path}" is under ${f}, where another language's pages are built`});let m=u.layout??"default";if(!e.layouts[m])t.addIssue({code:"custom",path:["routes",c,"layout"],message:`Unknown layout "${m}"`});for(let[h,b]of(u.sections??[]).entries()){let y=/^([^:.\s]+)\.([^:.\s]+)$/.exec(b.template);if(y)t.addIssue({code:"custom",path:["routes",c,"sections",h,"template"],message:`Section template "${b.template}" is written "${y[1]}:${y[2]}"`})}}let s=Array.isArray(e.sections)?e.sections:e.sections?[e.sections]:[],a=new Map(s.map((c)=>[c.namespace,c]));if(a.size!==s.length)t.addIssue({code:"custom",path:["sections"],message:"Section group namespaces must be unique"});for(let[c,u]of Object.entries(e.content??{})){let d=a.get(c);if(!d){t.addIssue({code:"custom",path:["content",c],message:`Content namespace "${c}" has no section group`});continue}for(let[f,m]of Object.entries(u)){let h=d.sections[f];if(!h){t.addIssue({code:"custom",path:["content",c,f],message:`Content section "${c}:${f}" is not defined`});continue}let b=h.schema.safeParse(m);if(!b.success)t.addIssue({code:"custom",path:["content",c,f],message:`Content does not satisfy the "${c}:${f}" schema: ${l.prettifyError(b.error)}`})}}})});var GN,QN,YN,Mm,XN,Z7,e2,t2,U7,r2,n2,q7,Fm;var vE=w(()=>{Mt();he();qm();qm();GN=l.object({id:l.string(),template:l.string(),content:l.unknown().optional(),dataQuery:l.looseObject({entityType:l.string().optional(),template:l.string().optional(),query:l.looseObject({id:l.string().optional(),limit:l.number().optional(),offset:l.number().optional()}).optional()}).optional(),order:l.number().optional()}),QN=["primary","secondary"],YN=l.object({show:l.boolean().default(!1),label:l.string().optional(),slot:l.enum(QN).default("primary"),priority:l.number().min(0).max(100).default(50)}).optional(),Mm=l.object({id:l.string(),path:l.string(),title:l.string().default(""),pageLabel:l.string().optional(),description:l.string().default(""),sections:l.array(GN).default([]),layout:l.string().default("default"),fullscreen:l.boolean().optional(),pluginId:l.string().optional(),sourceEntityType:l.string().optional(),external:l.boolean().optional(),navigation:YN,translations:l.record(lo,ku).optional(),languages:l.array(lo).optional()}),XN=l.object({routes:l.array(Mm),pluginId:l.string()}),Z7=_e({channel:"plugin:site-builder:route:register",request:XN,response:l.void(),delivery:"command"}),e2=l.strictObject({}),t2=l.array(Mm),U7=_e({channel:"site-builder:routes:list",request:e2,response:t2,delivery:"request"}),r2=l.strictObject({}),n2=l.array(Mm),q7=_e({channel:"plugin:site-builder:pages",request:r2,response:n2,delivery:"collect"}),Fm=l.object({label:l.string(),href:l.string(),priority:l.number()})});var o2,i2,s2,M7;var a2=w(()=>{Mt();he();o2=l.object({pluginId:l.string(),slotName:l.string(),render:l.custom((e)=>typeof e==="function"),priority:l.number().optional()}),i2=l.strictObject({}),s2=l.array(o2),M7=_e({channel:"plugin:site-builder:slots",request:i2,response:s2,delivery:"collect"})});var c2="site:metadata:updated",Jm,l2,u2,rc,d2,F7,J7,K7;var wE=w(()=>{Mt();he();vE();Jm=l.object({heading:l.string().describe("Main CTA heading text"),buttonText:l.string().describe("Call-to-action button text"),buttonLink:l.string().describe("URL or anchor for the CTA button")}),l2=l.object({title:l.string().optional(),description:l.string().optional(),copyright:l.string().optional(),cta:Jm.optional()}),u2=l.object({blurb:l.string().optional().describe("Short italic subtitle under the section title")}),rc=l.object({represents:l.enum(["brain","anchor"]).default("anchor").describe("Identity represented by the site"),title:l.string().describe("The site's title"),description:l.string().describe("The site's description"),url:l.string().optional().describe("Canonical site URL"),copyright:l.string().optional().describe("Copyright notice text"),logo:l.boolean().optional().describe("Whether to display logo instead of title text in header"),themeMode:l.enum(["light","dark"]).optional().describe("Default theme mode"),analyticsScript:l.string().optional().describe("Analytics script HTML"),cta:Jm.optional().describe("Call-to-action configuration"),sections:l.record(l.string(),u2).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers."),translations:l.record(lo,l2).optional().describe("The site's title, description, copyright and call to action in its other languages, keyed by language tag. A site is built in a language only once it has one.")}),d2=l.strictObject({}),F7=_e({channel:"site:metadata:get",request:d2,response:rc,delivery:"request"}),J7=oi(c2,rc),K7=rc.extend({copyright:l.string(),navigation:l.object({primary:l.array(Fm),secondary:l.array(Fm)}),socialLinks:l.array(sE).optional().describe("Social media links from profile metadata"),photo:l.string().optional().describe("The anchor's photo, as ![alt](entity://image/<id>)")})});var t_e;var xE=w(()=>{he();t_e=l.record(l.string(),l.unknown())});var Au=w(()=>{xE()});var f2=w(()=>{Mt();Au()});var p2=w(()=>{Au();Mt()});var m2=w(()=>{Au();Mt()});var y_e;var h2=w(()=>{he();y_e=l.record(l.string(),l.unknown())});var v_e;var g2=w(()=>{he();ya();v_e=l.record(l.string(),l.unknown())});var y2=w(()=>{ya()});var b2=w(()=>{Au();f2();p2();m2();h2();g2();y2();xE()});var rW;var S2=w(()=>{he();rW=l.object({slug:l.string(),title:l.string(),type:l.string(),entityId:l.string(),contentHash:l.string()})});var EE=w(()=>{b2();S2()});var v2=w(()=>{EE();he()});var nW,oW,iW;var Hm=w(()=>{he();Mt();nW={url:l.string(),typeLabel:l.string(),listUrl:l.string(),listLabel:l.string()},oW={url:l.string().nullable().default(null),typeLabel:l.string().nullable().default(null),listUrl:l.string().nullable().default(null),listLabel:l.string().nullable().default(null)},iW=l.object({name:l.string(),description:l.string(),schema:l.unknown(),basePrompt:l.string().optional(),useKnowledgeContext:l.boolean().optional(),requiredPermission:l.enum(["admin","trusted","public"]),formatter:l.unknown().optional(),overlayFormatter:l.unknown().optional(),layout:l.object({component:l.unknown().optional(),fullscreen:l.boolean().optional(),formats:l.unknown().optional()}).optional(),dataSourceId:l.string().optional()})});var Vm=w(()=>{Hm()});var _2=w(()=>{Vm()});var IE=()=>{};var aW,cW,nc,E2,lW;var I2=w(()=>{Mt();he();IE();aW=l.enum(["admin","trusted","public"]),cW=l.enum(["create","update","delete","extract","publish"]),nc=l.enum(["never","admin","trusted","public"]),E2=l.strictObject({create:nc.optional(),update:nc.optional(),delete:nc.optional(),extract:nc.optional(),publish:nc.optional()}),lW=l.record(l.string(),E2)});var k2=w(()=>{Vm();Hm()});var uW,dW,Wm,fW,pW,mW;var A2=w(()=>{he();uW=l.enum(["site-content-preview","site-content-production"]),dW=l.enum(["web","image","pdf","epub"]),Wm=l.custom((e)=>typeof e==="function"),fW=l.object({name:l.string(),schema:l.unknown(),description:l.string().optional(),pluginId:l.string(),renderers:l.object({web:l.union([Wm,l.string()]).optional(),image:l.union([Wm,l.string()]).optional(),pdf:l.union([Wm,l.string()]).optional(),epub:l.union([Wm,l.string()]).optional()})}),pW=l.object({enableContentGeneration:l.boolean().default(!1),outputDir:l.string(),workingDir:l.string().optional(),environment:l.enum(["preview","production"]).default("preview"),siteConfig:l.object({title:l.string(),description:l.string(),url:l.string().optional()}).optional()}),mW=l.object({success:l.boolean(),routesBuilt:l.number(),errors:l.array(l.string()).optional(),warnings:l.array(l.string()).optional()})});var T2=w(()=>{Hm();_2();Vm();I2();IE();k2();A2()});var kE=ge(function(gW,Gm){(function(){function e(g,E){Object.defineProperty(o.prototype,g,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",E[0],E[1])}})}function t(g){if(g===null||typeof g!=="object")return null;return g=De&&g[De]||g["@@iterator"],typeof g==="function"?g:null}function r(g,E){g=(g=g.constructor)&&(g.displayName||g.name)||"ReactClass";var D=g+"."+E;Qe[D]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",E,g),Qe[D]=!0)}function o(g,E,D){this.props=g,this.context=E,this.refs=Nt,this.updater=D||St}function n(){}function i(g,E,D){this.props=g,this.context=E,this.refs=Nt,this.updater=D||St}function s(){}function a(g){return""+g}function c(g){try{a(g);var E=!1}catch(q){E=!0}if(E){E=console;var D=E.error,J=typeof Symbol==="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return D.call(E,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",J),a(g)}}function u(g){if(g==null)return null;if(typeof g==="function")return g.$$typeof===In?null:g.displayName||g.name||null;if(typeof g==="string")return g;switch(g){case H:return"Fragment";case re:return"Profiler";case G:return"StrictMode";case ve:return"Suspense";case ke:return"SuspenseList";case Ue:return"Activity"}if(typeof g==="object")switch(typeof g.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case N:return"Portal";case pe:return g.displayName||"Context";case ae:return(g._context.displayName||"Context")+".Consumer";case be:var E=g.render;return g=g.displayName,g||(g=E.displayName||E.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case Ie:return E=g.displayName||null,E!==null?E:u(g.type)||"Memo";case we:E=g._payload,g=g._init;try{return u(g(E))}catch(D){}}return null}function d(g){if(g===H)return"<>";if(typeof g==="object"&&g!==null&&g.$$typeof===we)return"<...>";try{var E=u(g);return E?"<"+E+">":"<...>"}catch(D){return"<...>"}}function f(){var g=Le.A;return g===null?null:g.getOwner()}function m(){return Error("react-stack-top-frame")}function h(g){if(ro.call(g,"key")){var E=Object.getOwnPropertyDescriptor(g,"key").get;if(E&&E.isReactWarning)return!1}return g.key!==void 0}function b(g,E){function D(){es||(es=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",E))}D.isReactWarning=!0,Object.defineProperty(g,"key",{get:D,configurable:!0})}function y(){var g=u(this.type);return ts[g]||(ts[g]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),g=this.props.ref,g!==void 0?g:null}function S(g,E,D,J,q,te){var se=D.ref;return g={$$typeof:M,type:g,key:E,props:D,_owner:J},(se!==void 0?se:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:y}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:q}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function x(g,E){return E=S(g.type,E,g.props,g._owner,g._debugStack,g._debugTask),g._store&&(E._store.validated=g._store.validated),E}function _(g){A(g)?g._store&&(g._store.validated=1):typeof g==="object"&&g!==null&&g.$$typeof===we&&(g._payload.status==="fulfilled"?A(g._payload.value)&&g._payload.value._store&&(g._payload.value._store.validated=1):g._store&&(g._store.validated=1))}function A(g){return typeof g==="object"&&g!==null&&g.$$typeof===M}function O(g){var E={"=":"=0",":":"=2"};return"$"+g.replace(/[=:]/g,function(D){return E[D]})}function L(g,E){return typeof g==="object"&&g!==null&&g.key!=null?(c(g.key),O(""+g.key)):E.toString(36)}function z(g){switch(g.status){case"fulfilled":return g.value;case"rejected":throw g.reason;default:switch(typeof g.status==="string"?g.then(s,s):(g.status="pending",g.then(function(E){g.status==="pending"&&(g.status="fulfilled",g.value=E)},function(E){g.status==="pending"&&(g.status="rejected",g.reason=E)})),g.status){case"fulfilled":return g.value;case"rejected":throw g.reason}}throw g}function K(g,E,D,J,q){var te=typeof g;if(te==="undefined"||te==="boolean")g=null;var se=!1;if(g===null)se=!0;else switch(te){case"bigint":case"string":case"number":se=!0;break;case"object":switch(g.$$typeof){case M:case N:se=!0;break;case we:return se=g._init,K(se(g._payload),E,D,J,q)}}if(se){se=g,q=q(se);var ye=J===""?"."+L(se,0):J;return $r(q)?(D="",ye!=null&&(D=ye.replace(da,"$&/")+"/"),K(q,E,D,"",function($e){return $e})):q!=null&&(A(q)&&(q.key!=null&&(se&&se.key===q.key||c(q.key)),D=x(q,D+(q.key==null||se&&se.key===q.key?"":(""+q.key).replace(da,"$&/")+"/")+ye),J!==""&&se!=null&&A(se)&&se.key==null&&se._store&&!se._store.validated&&(D._store.validated=2),q=D),E.push(q)),1}if(se=0,ye=J===""?".":J+":",$r(g))for(var fe=0;fe<g.length;fe++)J=g[fe],te=ye+L(J,fe),se+=K(J,E,D,te,q);else if(fe=t(g),typeof fe==="function")for(fe===g.entries&&(Fo||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),Fo=!0),g=fe.call(g),fe=0;!(J=g.next()).done;)J=J.value,te=ye+L(J,fe++),se+=K(J,E,D,te,q);else if(te==="object"){if(typeof g.then==="function")return K(z(g),E,D,J,q);throw E=String(g),Error("Objects are not valid as a React child (found: "+(E==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":E)+"). If you meant to render a collection of children, use an array instead.")}return se}function P(g,E,D){if(g==null)return g;var J=[],q=0;return K(g,J,"","",function(te){return E.call(D,te,q++)}),J}function W(g){if(g._status===-1){var E=g._ioInfo;E!=null&&(E.start=E.end=performance.now()),E=g._result;var D=E();if(D.then(function(q){if(g._status===0||g._status===-1){g._status=1,g._result=q;var te=g._ioInfo;te!=null&&(te.end=performance.now()),D.status===void 0&&(D.status="fulfilled",D.value=q)}},function(q){if(g._status===0||g._status===-1){g._status=2,g._result=q;var te=g._ioInfo;te!=null&&(te.end=performance.now()),D.status===void 0&&(D.status="rejected",D.reason=q)}}),E=g._ioInfo,E!=null){E.value=D;var J=D.displayName;typeof J==="string"&&(E.name=J)}g._status===-1&&(g._status=0,g._result=D)}if(g._status===1)return E=g._result,E===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
228
228
 
229
229
  Your code should look like:
230
230
  const MyComponent = lazy(() => import('./MyComponent'))
@@ -236,23 +236,23 @@ Your code should look like:
236
236
  1. You might have mismatching versions of React and the renderer (such as React DOM)
237
237
  2. You might be breaking the Rules of Hooks
238
238
  3. You might have more than one copy of React in the same app
239
- See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),g}function j(){Le.asyncTransitions--}function R(g){if(U===null)try{var E=("require"+Math.random()).slice(0,7);U=(Gm&&Gm[E]).call(Gm,"timers").setImmediate}catch(D){U=function(J){p===!1&&(p=!0,typeof MessageChannel>"u"&&console.error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var q=new MessageChannel;q.port1.onmessage=J,q.port2.postMessage(void 0)}}return U(g)}function B(g){return 1<g.length&&typeof AggregateError==="function"?AggregateError(g):g[0]}function I(g,E){E!==ne-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),ne=E}function T(g,E,D){var J=Le.actQueue;if(J!==null)if(J.length!==0)try{k(J),R(function(){return T(g,E,D)});return}catch(q){Le.thrownErrors.push(q)}else Le.actQueue=null;0<Le.thrownErrors.length?(J=B(Le.thrownErrors),Le.thrownErrors.length=0,D(J)):E(g)}function k(g){if(!X){X=!0;var E=0;try{for(;E<g.length;E++){var D=g[E];do{Le.didUsePromise=!1;var J=D(!1);if(J!==null){if(Le.didUsePromise){g[E]=D,g.splice(0,E);return}D=J}else break}while(1)}g.length=0}catch(q){g.splice(0,E+1),Le.thrownErrors.push(q)}finally{X=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var M=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),re=Symbol.for("react.profiler"),ae=Symbol.for("react.consumer"),pe=Symbol.for("react.context"),be=Symbol.for("react.forward_ref"),ve=Symbol.for("react.suspense"),ke=Symbol.for("react.suspense_list"),Ie=Symbol.for("react.memo"),we=Symbol.for("react.lazy"),Ue=Symbol.for("react.activity"),De=Symbol.iterator,Qe={},St={isMounted:function(){return!1},enqueueForceUpdate:function(g){r(g,"forceUpdate")},enqueueReplaceState:function(g){r(g,"replaceState")},enqueueSetState:function(g){r(g,"setState")}},Tt=Object.assign,Nt={};Object.freeze(Nt),o.prototype.isReactComponent={},o.prototype.setState=function(g,E){if(typeof g!=="object"&&typeof g!=="function"&&g!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,g,E,"setState")},o.prototype.forceUpdate=function(g){this.updater.enqueueForceUpdate(this,g,"forceUpdate")};var lt={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]};for(V in lt)lt.hasOwnProperty(V)&&e(V,lt[V]);n.prototype=o.prototype,lt=i.prototype=new n,lt.constructor=i,Tt(lt,o.prototype),lt.isPureReactComponent=!0;var $r=Array.isArray,In=Symbol.for("react.client.reference"),Le={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},ro=Object.prototype.hasOwnProperty,Xi=console.createTask?console.createTask:function(){return null};lt={react_stack_bottom_frame:function(g){return g()}};var es,ua,ts={},kn=lt.react_stack_bottom_frame.bind(lt,m)(),Tl=Xi(d(m)),Fo=!1,da=/\/+/g,fa=typeof reportError==="function"?reportError:function(g){if(typeof window==="object"&&typeof window.ErrorEvent==="function"){var E=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof g==="object"&&g!==null&&typeof g.message==="string"?String(g.message):String(g),error:g});if(!window.dispatchEvent(E))return}else if(typeof process==="object"&&typeof process.emit==="function"){process.emit("uncaughtException",g);return}console.error(g)},p=!1,U=null,ne=0,ie=!1,X=!1,v=typeof queueMicrotask==="function"?function(g){queueMicrotask(function(){return queueMicrotask(g)})}:R;lt=Object.freeze({__proto__:null,c:function(g){return ee().useMemoCache(g)}});var V={map:P,forEach:function(g,E,D){P(g,function(){E.apply(this,arguments)},D)},count:function(g){var E=0;return P(g,function(){E++}),E},toArray:function(g){return P(g,function(E){return E})||[]},only:function(g){if(!A(g))throw Error("React.Children.only expected to receive a single React element child.");return g}};hW.Activity=Ue,hW.Children=V,hW.Component=o,hW.Fragment=H,hW.Profiler=re,hW.PureComponent=i,hW.StrictMode=G,hW.Suspense=ve,hW.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Le,hW.__COMPILER_RUNTIME=lt,hW.act=function(g){var E=Le.actQueue,D=ne;ne++;var J=Le.actQueue=E!==null?E:[],q=!1;try{var te=g()}catch(fe){Le.thrownErrors.push(fe)}if(0<Le.thrownErrors.length)throw I(E,D),g=B(Le.thrownErrors),Le.thrownErrors.length=0,g;if(te!==null&&typeof te==="object"&&typeof te.then==="function"){var se=te;return v(function(){q||ie||(ie=!0,console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))}),{then:function(fe,$e){q=!0,se.then(function(ze){if(I(E,D),D===0){try{k(J),R(function(){return T(ze,fe,$e)})}catch(rs){Le.thrownErrors.push(rs)}if(0<Le.thrownErrors.length){var An=B(Le.thrownErrors);Le.thrownErrors.length=0,$e(An)}}else fe(ze)},function(ze){I(E,D),0<Le.thrownErrors.length?(ze=B(Le.thrownErrors),Le.thrownErrors.length=0,$e(ze)):$e(ze)})}}}var ye=te;if(I(E,D),D===0&&(k(J),J.length!==0&&v(function(){q||ie||(ie=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),Le.actQueue=null),0<Le.thrownErrors.length)throw g=B(Le.thrownErrors),Le.thrownErrors.length=0,g;return{then:function(fe,$e){q=!0,D===0?(Le.actQueue=J,R(function(){return T(ye,fe,$e)})):fe(ye)}}},hW.cache=function(g){return function(){return g.apply(null,arguments)}},hW.cacheSignal=function(){return null},hW.captureOwnerStack=function(){var g=Le.getCurrentStack;return g===null?null:g()},hW.cloneElement=function(g,E,D){if(g===null||g===void 0)throw Error("The argument must be a React element, but you passed "+g+".");var J=Tt({},g.props),q=g.key,te=g._owner;if(E!=null){var se;e:{if(ro.call(E,"ref")&&(se=Object.getOwnPropertyDescriptor(E,"ref").get)&&se.isReactWarning){se=!1;break e}se=E.ref!==void 0}se&&(te=f()),h(E)&&(c(E.key),q=""+E.key);for(ye in E)!ro.call(E,ye)||ye==="key"||ye==="__self"||ye==="__source"||ye==="ref"&&E.ref===void 0||(J[ye]=E[ye])}var ye=arguments.length-2;if(ye===1)J.children=D;else if(1<ye){se=Array(ye);for(var fe=0;fe<ye;fe++)se[fe]=arguments[fe+2];J.children=se}J=S(g.type,q,J,te,g._debugStack,g._debugTask);for(q=2;q<arguments.length;q++)_(arguments[q]);return J},hW.createContext=function(g){return g={$$typeof:pe,_currentValue:g,_currentValue2:g,_threadCount:0,Provider:null,Consumer:null},g.Provider=g,g.Consumer={$$typeof:ae,_context:g},g._currentRenderer=null,g._currentRenderer2=null,g},hW.createElement=function(g,E,D){for(var J=2;J<arguments.length;J++)_(arguments[J]);J={};var q=null;if(E!=null)for(fe in ua||!("__self"in E)||"key"in E||(ua=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),h(E)&&(c(E.key),q=""+E.key),E)ro.call(E,fe)&&fe!=="key"&&fe!=="__self"&&fe!=="__source"&&(J[fe]=E[fe]);var te=arguments.length-2;if(te===1)J.children=D;else if(1<te){for(var se=Array(te),ye=0;ye<te;ye++)se[ye]=arguments[ye+2];Object.freeze&&Object.freeze(se),J.children=se}if(g&&g.defaultProps)for(fe in te=g.defaultProps,te)J[fe]===void 0&&(J[fe]=te[fe]);q&&b(J,typeof g==="function"?g.displayName||g.name||"Unknown":g);var fe=1e4>Le.recentlyCreatedOwnerStacks++;return S(g,q,J,f(),fe?Error("react-stack-top-frame"):kn,fe?Xi(d(g)):Tl)},hW.createRef=function(){var g={current:null};return Object.seal(g),g},hW.forwardRef=function(g){g!=null&&g.$$typeof===Ie?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof g!=="function"?console.error("forwardRef requires a render function but was given %s.",g===null?"null":typeof g):g.length!==0&&g.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",g.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),g!=null&&g.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var E={$$typeof:be,render:g},D;return Object.defineProperty(E,"displayName",{enumerable:!1,configurable:!0,get:function(){return D},set:function(J){D=J,g.name||g.displayName||(Object.defineProperty(g,"name",{value:J}),g.displayName=J)}}),E},hW.isValidElement=A,hW.lazy=function(g){g={_status:-1,_result:g};var E={$$typeof:we,_payload:g,_init:W},D={name:"lazy",start:-1,end:-1,value:null,owner:null,debugStack:Error("react-stack-top-frame"),debugTask:console.createTask?console.createTask("lazy()"):null};return g._ioInfo=D,E._debugInfo=[{awaited:D}],E},hW.memo=function(g,E){g==null&&console.error("memo: The first argument must be a component. Instead received: %s",g===null?"null":typeof g),E={$$typeof:Ie,type:g,compare:E===void 0?null:E};var D;return Object.defineProperty(E,"displayName",{enumerable:!1,configurable:!0,get:function(){return D},set:function(J){D=J,g.name||g.displayName||(Object.defineProperty(g,"name",{value:J}),g.displayName=J)}}),E},hW.startTransition=function(g){var E=Le.T,D={};D._updatedFibers=new Set,Le.T=D;try{var J=g(),q=Le.S;q!==null&&q(D,J),typeof J==="object"&&J!==null&&typeof J.then==="function"&&(Le.asyncTransitions++,J.then(j,j),J.then(s,fa))}catch(te){fa(te)}finally{E===null&&D._updatedFibers&&(g=D._updatedFibers.size,D._updatedFibers.clear(),10<g&&console.warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.")),E!==null&&D.types!==null&&(E.types!==null&&E.types!==D.types&&console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."),E.types=D.types),Le.T=E}},hW.unstable_useCacheRefresh=function(){return ee().useCacheRefresh()},hW.use=function(g){return ee().use(g)},hW.useActionState=function(g,E,D){return ee().useActionState(g,E,D)},hW.useCallback=function(g,E){return ee().useCallback(g,E)},hW.useContext=function(g){var E=ee();return g.$$typeof===ae&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),E.useContext(g)},hW.useDebugValue=function(g,E){return ee().useDebugValue(g,E)},hW.useDeferredValue=function(g,E){return ee().useDeferredValue(g,E)},hW.useEffect=function(g,E){return g==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useEffect(g,E)},hW.useEffectEvent=function(g){return ee().useEffectEvent(g)},hW.useId=function(){return ee().useId()},hW.useImperativeHandle=function(g,E,D){return ee().useImperativeHandle(g,E,D)},hW.useInsertionEffect=function(g,E){return g==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useInsertionEffect(g,E)},hW.useLayoutEffect=function(g,E){return g==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useLayoutEffect(g,E)},hW.useMemo=function(g,E){return ee().useMemo(g,E)},hW.useOptimistic=function(g,E){return ee().useOptimistic(g,E)},hW.useReducer=function(g,E,D){return ee().useReducer(g,E,D)},hW.useRef=function(g){return ee().useRef(g)},hW.useState=function(g){return ee().useState(g)},hW.useSyncExternalStore=function(g,E,D){return ee().useSyncExternalStore(g,E,D)},hW.useTransition=function(){return ee().useTransition()},hW.version="19.2.7",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var $2,R2;var AE=w(()=>{$2=Rl(kE(),1),R2=$2.createContext(void 0)});var gW;var O2=w(()=>{EE();T2();AE();he();gW=Rl(kE(),1)});var yW,bW;var C2=w(()=>{Mt();he();wE();yW=rc.omit({url:!0,analyticsScript:!0}),bW=yW.extend({title:l.string().optional().describe("Optional site title override"),description:l.string().optional().describe("Optional site description override")})});function TE(e,t={}){let r=P2(e),o=P2(t.sharedDomain??"rizom.ai").replace(/^\./,""),n=`.${o}`;if(r.endsWith(n)){let i=r.slice(0,-n.length);if(i.length>0&&!i.includes("."))return`${i}-preview.${o}`}return`preview.${r}`}function P2(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/$/,"").toLowerCase()}var z2=()=>{};var N2=w(()=>{z2()});var SW,vW;var D2=w(()=>{he();qm();SW=l.string(),vW=l.custom((e)=>{if(!km(e))return!1;let{plugin:t,...r}=e;if(t!==void 0&&typeof t!=="function")return!1;return WN.safeParse(r).success})});var wW;var L2=w(()=>{he();wW=l.object({title:l.string().min(1),slug:l.string().min(1),description:l.string(),content:l.string(),author:l.string(),publishedAt:l.iso.datetime({offset:!0}),category:l.string().min(1).optional()})});var B2=w(()=>{vE();a2();wE();v2();O2();C2();N2();D2();AE();L2()});function $E(e,t={}){return TE(e,t)}var RE=w(()=>{B2()});function OE(e,t){let r=e.indexOf("/");if(r===-1)return{org:t,name:e};return{org:e.slice(0,r),name:e.slice(r+1)}}function j2(e,t){let{org:r,name:o}=OE(e,t);return`${r}/${o}`}function F2(e){return NW.safeParse(e).success}function CE(e,t,r={}){let o={...e};for(let n of Object.keys(t)){let i=t[n];if(i===null&&r.nulls!=="preserve")delete o[n];else if(F2(o[n])&&F2(i))o[n]=CE(o[n],i,r);else o[n]=i}return o}var NW;var J2=w(()=>{he();NW=l.record(l.string(),l.unknown())});function Qm(e){return async(t)=>({brainYaml:DW(t,e),envFile:jW(t,e),contentRepoFiles:LW(t)})}function DW(e,t){let r={...e.setup?.delivery==="email"?{"auth-service":{setupEmail:e.setup.email},notifications:{defaultRecipient:{type:"email",address:e.setup.email}},email:{transport:"resend",apiKey:"${SETUP_EMAIL_API_KEY}",from:"${SETUP_EMAIL_FROM}"}}:{},...e.playbooks?.onboarding?{onboarding:{enabled:!0}}:{},...e.topicExtractionEnabled!==void 0?{topics:{enableAutoExtraction:e.topicExtractionEnabled}}:{},...e.skillDerivationEnabled!==void 0?{agents:{enableSkillDerivation:e.skillDerivationEnabled}}:{},...e.swotDerivationEnabled!==void 0?{assessment:{enableSwotDerivation:e.swotDerivationEnabled}}:{},"directory-sync":{git:{repo:K2(e,t),authToken:"${GIT_SYNC_TOKEN}"}},...e.atproto?{atproto:{...e.atproto,appPassword:"${ATPROTO_APP_PASSWORD}"}}:{}};return ba({brain:"brain",bundleContract:e.bundleContract,kind:e.profileKind??"professional",domain:e.domain,bundles:e.bundles,...e.anchorKind?{anchor:e.anchorKind}:{},...e.embeddingEnabled!==void 0?{embedding:{enabled:e.embeddingEnabled}}:{},...e.add.length>0?{add:e.add}:{},...e.remove.length>0?{remove:e.remove}:{},...e.siteOverride?{site:{package:e.siteOverride.package,...e.siteOverride.theme?{theme:e.siteOverride.theme}:{}}}:{},...e.spaces&&e.spaces.length>0?{spaces:e.spaces}:{},anchors:e.discordEnabled&&e.discordAnchorUserId?[`discord:${e.discordAnchorUserId}`]:[],plugins:CE(r,e.plugins??{},{nulls:"preserve"})})}function K2(e,t){return j2(e.contentRepo,t)}function LW(e){return[{path:"anchor-profile/anchor-profile.md",content:BW(e)}]}function BW(e){let t={name:e.anchorProfile.name,...e.anchorProfile.description?{description:e.anchorProfile.description}:{},...e.anchorProfile.website?{website:e.anchorProfile.website}:{},...e.anchorProfile.email?{email:e.anchorProfile.email}:{},...e.anchorProfile.socialLinks?{socialLinks:e.anchorProfile.socialLinks}:{}},r=e.anchorProfile.story??"This profile was initialized by brains-ops. Edit it in your content repo.";return`---
239
+ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),g}function j(){Le.asyncTransitions--}function R(g){if(U===null)try{var E=("require"+Math.random()).slice(0,7);U=(Gm&&Gm[E]).call(Gm,"timers").setImmediate}catch(D){U=function(J){p===!1&&(p=!0,typeof MessageChannel>"u"&&console.error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var q=new MessageChannel;q.port1.onmessage=J,q.port2.postMessage(void 0)}}return U(g)}function B(g){return 1<g.length&&typeof AggregateError==="function"?AggregateError(g):g[0]}function I(g,E){E!==ne-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),ne=E}function T(g,E,D){var J=Le.actQueue;if(J!==null)if(J.length!==0)try{k(J),R(function(){return T(g,E,D)});return}catch(q){Le.thrownErrors.push(q)}else Le.actQueue=null;0<Le.thrownErrors.length?(J=B(Le.thrownErrors),Le.thrownErrors.length=0,D(J)):E(g)}function k(g){if(!X){X=!0;var E=0;try{for(;E<g.length;E++){var D=g[E];do{Le.didUsePromise=!1;var J=D(!1);if(J!==null){if(Le.didUsePromise){g[E]=D,g.splice(0,E);return}D=J}else break}while(1)}g.length=0}catch(q){g.splice(0,E+1),Le.thrownErrors.push(q)}finally{X=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var M=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),re=Symbol.for("react.profiler"),ae=Symbol.for("react.consumer"),pe=Symbol.for("react.context"),be=Symbol.for("react.forward_ref"),ve=Symbol.for("react.suspense"),ke=Symbol.for("react.suspense_list"),Ie=Symbol.for("react.memo"),we=Symbol.for("react.lazy"),Ue=Symbol.for("react.activity"),De=Symbol.iterator,Qe={},St={isMounted:function(){return!1},enqueueForceUpdate:function(g){r(g,"forceUpdate")},enqueueReplaceState:function(g){r(g,"replaceState")},enqueueSetState:function(g){r(g,"setState")}},Tt=Object.assign,Nt={};Object.freeze(Nt),o.prototype.isReactComponent={},o.prototype.setState=function(g,E){if(typeof g!=="object"&&typeof g!=="function"&&g!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,g,E,"setState")},o.prototype.forceUpdate=function(g){this.updater.enqueueForceUpdate(this,g,"forceUpdate")};var lt={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]};for(V in lt)lt.hasOwnProperty(V)&&e(V,lt[V]);n.prototype=o.prototype,lt=i.prototype=new n,lt.constructor=i,Tt(lt,o.prototype),lt.isPureReactComponent=!0;var $r=Array.isArray,In=Symbol.for("react.client.reference"),Le={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},ro=Object.prototype.hasOwnProperty,Xi=console.createTask?console.createTask:function(){return null};lt={react_stack_bottom_frame:function(g){return g()}};var es,ua,ts={},kn=lt.react_stack_bottom_frame.bind(lt,m)(),Tl=Xi(d(m)),Fo=!1,da=/\/+/g,fa=typeof reportError==="function"?reportError:function(g){if(typeof window==="object"&&typeof window.ErrorEvent==="function"){var E=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof g==="object"&&g!==null&&typeof g.message==="string"?String(g.message):String(g),error:g});if(!window.dispatchEvent(E))return}else if(typeof process==="object"&&typeof process.emit==="function"){process.emit("uncaughtException",g);return}console.error(g)},p=!1,U=null,ne=0,ie=!1,X=!1,v=typeof queueMicrotask==="function"?function(g){queueMicrotask(function(){return queueMicrotask(g)})}:R;lt=Object.freeze({__proto__:null,c:function(g){return ee().useMemoCache(g)}});var V={map:P,forEach:function(g,E,D){P(g,function(){E.apply(this,arguments)},D)},count:function(g){var E=0;return P(g,function(){E++}),E},toArray:function(g){return P(g,function(E){return E})||[]},only:function(g){if(!A(g))throw Error("React.Children.only expected to receive a single React element child.");return g}};gW.Activity=Ue,gW.Children=V,gW.Component=o,gW.Fragment=H,gW.Profiler=re,gW.PureComponent=i,gW.StrictMode=G,gW.Suspense=ve,gW.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Le,gW.__COMPILER_RUNTIME=lt,gW.act=function(g){var E=Le.actQueue,D=ne;ne++;var J=Le.actQueue=E!==null?E:[],q=!1;try{var te=g()}catch(fe){Le.thrownErrors.push(fe)}if(0<Le.thrownErrors.length)throw I(E,D),g=B(Le.thrownErrors),Le.thrownErrors.length=0,g;if(te!==null&&typeof te==="object"&&typeof te.then==="function"){var se=te;return v(function(){q||ie||(ie=!0,console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))}),{then:function(fe,$e){q=!0,se.then(function(ze){if(I(E,D),D===0){try{k(J),R(function(){return T(ze,fe,$e)})}catch(rs){Le.thrownErrors.push(rs)}if(0<Le.thrownErrors.length){var An=B(Le.thrownErrors);Le.thrownErrors.length=0,$e(An)}}else fe(ze)},function(ze){I(E,D),0<Le.thrownErrors.length?(ze=B(Le.thrownErrors),Le.thrownErrors.length=0,$e(ze)):$e(ze)})}}}var ye=te;if(I(E,D),D===0&&(k(J),J.length!==0&&v(function(){q||ie||(ie=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),Le.actQueue=null),0<Le.thrownErrors.length)throw g=B(Le.thrownErrors),Le.thrownErrors.length=0,g;return{then:function(fe,$e){q=!0,D===0?(Le.actQueue=J,R(function(){return T(ye,fe,$e)})):fe(ye)}}},gW.cache=function(g){return function(){return g.apply(null,arguments)}},gW.cacheSignal=function(){return null},gW.captureOwnerStack=function(){var g=Le.getCurrentStack;return g===null?null:g()},gW.cloneElement=function(g,E,D){if(g===null||g===void 0)throw Error("The argument must be a React element, but you passed "+g+".");var J=Tt({},g.props),q=g.key,te=g._owner;if(E!=null){var se;e:{if(ro.call(E,"ref")&&(se=Object.getOwnPropertyDescriptor(E,"ref").get)&&se.isReactWarning){se=!1;break e}se=E.ref!==void 0}se&&(te=f()),h(E)&&(c(E.key),q=""+E.key);for(ye in E)!ro.call(E,ye)||ye==="key"||ye==="__self"||ye==="__source"||ye==="ref"&&E.ref===void 0||(J[ye]=E[ye])}var ye=arguments.length-2;if(ye===1)J.children=D;else if(1<ye){se=Array(ye);for(var fe=0;fe<ye;fe++)se[fe]=arguments[fe+2];J.children=se}J=S(g.type,q,J,te,g._debugStack,g._debugTask);for(q=2;q<arguments.length;q++)_(arguments[q]);return J},gW.createContext=function(g){return g={$$typeof:pe,_currentValue:g,_currentValue2:g,_threadCount:0,Provider:null,Consumer:null},g.Provider=g,g.Consumer={$$typeof:ae,_context:g},g._currentRenderer=null,g._currentRenderer2=null,g},gW.createElement=function(g,E,D){for(var J=2;J<arguments.length;J++)_(arguments[J]);J={};var q=null;if(E!=null)for(fe in ua||!("__self"in E)||"key"in E||(ua=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),h(E)&&(c(E.key),q=""+E.key),E)ro.call(E,fe)&&fe!=="key"&&fe!=="__self"&&fe!=="__source"&&(J[fe]=E[fe]);var te=arguments.length-2;if(te===1)J.children=D;else if(1<te){for(var se=Array(te),ye=0;ye<te;ye++)se[ye]=arguments[ye+2];Object.freeze&&Object.freeze(se),J.children=se}if(g&&g.defaultProps)for(fe in te=g.defaultProps,te)J[fe]===void 0&&(J[fe]=te[fe]);q&&b(J,typeof g==="function"?g.displayName||g.name||"Unknown":g);var fe=1e4>Le.recentlyCreatedOwnerStacks++;return S(g,q,J,f(),fe?Error("react-stack-top-frame"):kn,fe?Xi(d(g)):Tl)},gW.createRef=function(){var g={current:null};return Object.seal(g),g},gW.forwardRef=function(g){g!=null&&g.$$typeof===Ie?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof g!=="function"?console.error("forwardRef requires a render function but was given %s.",g===null?"null":typeof g):g.length!==0&&g.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",g.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),g!=null&&g.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var E={$$typeof:be,render:g},D;return Object.defineProperty(E,"displayName",{enumerable:!1,configurable:!0,get:function(){return D},set:function(J){D=J,g.name||g.displayName||(Object.defineProperty(g,"name",{value:J}),g.displayName=J)}}),E},gW.isValidElement=A,gW.lazy=function(g){g={_status:-1,_result:g};var E={$$typeof:we,_payload:g,_init:W},D={name:"lazy",start:-1,end:-1,value:null,owner:null,debugStack:Error("react-stack-top-frame"),debugTask:console.createTask?console.createTask("lazy()"):null};return g._ioInfo=D,E._debugInfo=[{awaited:D}],E},gW.memo=function(g,E){g==null&&console.error("memo: The first argument must be a component. Instead received: %s",g===null?"null":typeof g),E={$$typeof:Ie,type:g,compare:E===void 0?null:E};var D;return Object.defineProperty(E,"displayName",{enumerable:!1,configurable:!0,get:function(){return D},set:function(J){D=J,g.name||g.displayName||(Object.defineProperty(g,"name",{value:J}),g.displayName=J)}}),E},gW.startTransition=function(g){var E=Le.T,D={};D._updatedFibers=new Set,Le.T=D;try{var J=g(),q=Le.S;q!==null&&q(D,J),typeof J==="object"&&J!==null&&typeof J.then==="function"&&(Le.asyncTransitions++,J.then(j,j),J.then(s,fa))}catch(te){fa(te)}finally{E===null&&D._updatedFibers&&(g=D._updatedFibers.size,D._updatedFibers.clear(),10<g&&console.warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.")),E!==null&&D.types!==null&&(E.types!==null&&E.types!==D.types&&console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."),E.types=D.types),Le.T=E}},gW.unstable_useCacheRefresh=function(){return ee().useCacheRefresh()},gW.use=function(g){return ee().use(g)},gW.useActionState=function(g,E,D){return ee().useActionState(g,E,D)},gW.useCallback=function(g,E){return ee().useCallback(g,E)},gW.useContext=function(g){var E=ee();return g.$$typeof===ae&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),E.useContext(g)},gW.useDebugValue=function(g,E){return ee().useDebugValue(g,E)},gW.useDeferredValue=function(g,E){return ee().useDeferredValue(g,E)},gW.useEffect=function(g,E){return g==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useEffect(g,E)},gW.useEffectEvent=function(g){return ee().useEffectEvent(g)},gW.useId=function(){return ee().useId()},gW.useImperativeHandle=function(g,E,D){return ee().useImperativeHandle(g,E,D)},gW.useInsertionEffect=function(g,E){return g==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useInsertionEffect(g,E)},gW.useLayoutEffect=function(g,E){return g==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useLayoutEffect(g,E)},gW.useMemo=function(g,E){return ee().useMemo(g,E)},gW.useOptimistic=function(g,E){return ee().useOptimistic(g,E)},gW.useReducer=function(g,E,D){return ee().useReducer(g,E,D)},gW.useRef=function(g){return ee().useRef(g)},gW.useState=function(g){return ee().useState(g)},gW.useSyncExternalStore=function(g,E,D){return ee().useSyncExternalStore(g,E,D)},gW.useTransition=function(){return ee().useTransition()},gW.version="19.2.7",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var $2,R2;var AE=w(()=>{$2=Rl(kE(),1),R2=$2.createContext(void 0)});var yW;var O2=w(()=>{EE();T2();AE();he();yW=Rl(kE(),1)});var bW,SW;var C2=w(()=>{Mt();he();wE();bW=rc.omit({url:!0,analyticsScript:!0}),SW=bW.extend({title:l.string().optional().describe("Optional site title override"),description:l.string().optional().describe("Optional site description override")})});function TE(e,t={}){let r=P2(e),o=P2(t.sharedDomain??"rizom.ai").replace(/^\./,""),n=`.${o}`;if(r.endsWith(n)){let i=r.slice(0,-n.length);if(i.length>0&&!i.includes("."))return`${i}-preview.${o}`}return`preview.${r}`}function P2(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/$/,"").toLowerCase()}var z2=()=>{};var N2=w(()=>{z2()});var vW,wW;var D2=w(()=>{he();qm();vW=l.string(),wW=l.custom((e)=>{if(!km(e))return!1;let{plugin:t,...r}=e;if(t!==void 0&&typeof t!=="function")return!1;return WN.safeParse(r).success})});var xW;var L2=w(()=>{he();xW=l.object({title:l.string().min(1),slug:l.string().min(1),description:l.string(),content:l.string(),author:l.string(),publishedAt:l.iso.datetime({offset:!0}),category:l.string().min(1).optional()})});var B2=w(()=>{vE();a2();wE();v2();O2();C2();N2();D2();AE();L2()});function $E(e,t={}){return TE(e,t)}var RE=w(()=>{B2()});function OE(e,t){let r=e.indexOf("/");if(r===-1)return{org:t,name:e};return{org:e.slice(0,r),name:e.slice(r+1)}}function j2(e,t){let{org:r,name:o}=OE(e,t);return`${r}/${o}`}function F2(e){return DW.safeParse(e).success}function CE(e,t,r={}){let o={...e};for(let n of Object.keys(t)){let i=t[n];if(i===null&&r.nulls!=="preserve")delete o[n];else if(F2(o[n])&&F2(i))o[n]=CE(o[n],i,r);else o[n]=i}return o}var DW;var J2=w(()=>{he();DW=l.record(l.string(),l.unknown())});function Qm(e){return async(t)=>({brainYaml:LW(t,e),envFile:ZW(t,e),contentRepoFiles:BW(t)})}function LW(e,t){let r={...e.setup?.delivery==="email"?{"auth-service":{setupEmail:e.setup.email},notifications:{defaultRecipient:{type:"email",address:e.setup.email}},email:{transport:"resend",apiKey:"${SETUP_EMAIL_API_KEY}",from:"${SETUP_EMAIL_FROM}"}}:{},...e.playbooks?.onboarding?{onboarding:{enabled:!0}}:{},...e.topicExtractionEnabled!==void 0?{topics:{enableAutoExtraction:e.topicExtractionEnabled}}:{},...e.skillDerivationEnabled!==void 0?{agents:{enableSkillDerivation:e.skillDerivationEnabled}}:{},...e.swotDerivationEnabled!==void 0?{assessment:{enableSwotDerivation:e.swotDerivationEnabled}}:{},"directory-sync":{git:{repo:K2(e,t),authToken:"${GIT_SYNC_TOKEN}"}},...e.atproto?{atproto:{...e.atproto,appPassword:"${ATPROTO_APP_PASSWORD}"}}:{}};return ba({brain:"brain",bundleContract:e.bundleContract,kind:e.profileKind??"professional",domain:e.domain,bundles:e.bundles,...e.anchorKind?{anchor:e.anchorKind}:{},...e.embeddingEnabled!==void 0?{embedding:{enabled:e.embeddingEnabled}}:{},...e.add.length>0?{add:e.add}:{},...e.remove.length>0?{remove:e.remove}:{},...e.siteOverride?{site:{package:e.siteOverride.package,...e.siteOverride.theme?{theme:e.siteOverride.theme}:{}}}:{},...e.spaces&&e.spaces.length>0?{spaces:e.spaces}:{},anchors:e.discordEnabled&&e.discordAnchorUserId?[`discord:${e.discordAnchorUserId}`]:[],plugins:CE(r,e.plugins??{},{nulls:"preserve"})})}function K2(e,t){return j2(e.contentRepo,t)}function BW(e){return[{path:"anchor-profile/anchor-profile.md",content:jW(e)}]}function jW(e){let t={name:e.anchorProfile.name,...e.anchorProfile.description?{description:e.anchorProfile.description}:{},...e.anchorProfile.website?{website:e.anchorProfile.website}:{},...e.anchorProfile.email?{email:e.anchorProfile.email}:{},...e.anchorProfile.socialLinks?{socialLinks:e.anchorProfile.socialLinks}:{}},r=e.anchorProfile.story??"This profile was initialized by brains-ops. Edit it in your content repo.";return`---
240
240
  ${ba(t).trimEnd()}
241
241
  ---
242
242
 
243
243
  ${r}
244
- `}function jW(e,t){let r=jm(e.siteOverride);return[`BRAIN_VERSION=${e.brainVersion}`,...r.length>0?[`IMAGE_TAG=${Iu(e.brainVersion,r)}`]:[],`CONTENT_REPO=${K2(e,t)}`,""].join(`
245
- `)}var PE=w(()=>{J2();Um();no()});var Me=ge(function(lG){var LE=Symbol.for("yaml.alias"),eD=Symbol.for("yaml.document"),Xm=Symbol.for("yaml.map"),tD=Symbol.for("yaml.pair"),BE=Symbol.for("yaml.scalar"),eh=Symbol.for("yaml.seq"),uo=Symbol.for("yaml.node.type"),rG=(e)=>!!e&&typeof e==="object"&&e[uo]===LE,nG=(e)=>!!e&&typeof e==="object"&&e[uo]===eD,oG=(e)=>!!e&&typeof e==="object"&&e[uo]===Xm,iG=(e)=>!!e&&typeof e==="object"&&e[uo]===tD,rD=(e)=>!!e&&typeof e==="object"&&e[uo]===BE,sG=(e)=>!!e&&typeof e==="object"&&e[uo]===eh;function nD(e){if(e&&typeof e==="object")switch(e[uo]){case Xm:case eh:return!0}return!1}function aG(e){if(e&&typeof e==="object")switch(e[uo]){case LE:case Xm:case BE:case eh:return!0}return!1}var cG=(e)=>(rD(e)||nD(e))&&!!e.anchor;lG.ALIAS=LE;lG.DOC=eD;lG.MAP=Xm;lG.NODE_TYPE=uo;lG.PAIR=tD;lG.SCALAR=BE;lG.SEQ=eh;lG.hasAnchor=cG;lG.isAlias=rG;lG.isCollection=nD;lG.isDocument=nG;lG.isMap=oG;lG.isNode=aG;lG.isPair=iG;lG.isScalar=rD;lG.isSeq=sG});var Tu=ge(function(kG){var Rt=Me(),_r=Symbol("break visit"),oD=Symbol("skip children"),Nn=Symbol("remove node");function th(e,t){let r=iD(t);if(Rt.isDocument(e)){if(sc(null,e.contents,r,Object.freeze([e]))===Nn)e.contents=null}else sc(null,e,r,Object.freeze([]))}th.BREAK=_r;th.SKIP=oD;th.REMOVE=Nn;function sc(e,t,r,o){let n=sD(e,t,r,o);if(Rt.isNode(n)||Rt.isPair(n))return aD(e,o,n),sc(e,n,r,o);if(typeof n!=="symbol"){if(Rt.isCollection(t)){o=Object.freeze(o.concat(t));for(let i=0;i<t.items.length;++i){let s=sc(i,t.items[i],r,o);if(typeof s==="number")i=s-1;else if(s===_r)return _r;else if(s===Nn)t.items.splice(i,1),i-=1}}else if(Rt.isPair(t)){o=Object.freeze(o.concat(t));let i=sc("key",t.key,r,o);if(i===_r)return _r;else if(i===Nn)t.key=null;let s=sc("value",t.value,r,o);if(s===_r)return _r;else if(s===Nn)t.value=null}}return n}async function rh(e,t){let r=iD(t);if(Rt.isDocument(e)){if(await ac(null,e.contents,r,Object.freeze([e]))===Nn)e.contents=null}else await ac(null,e,r,Object.freeze([]))}rh.BREAK=_r;rh.SKIP=oD;rh.REMOVE=Nn;async function ac(e,t,r,o){let n=await sD(e,t,r,o);if(Rt.isNode(n)||Rt.isPair(n))return aD(e,o,n),ac(e,n,r,o);if(typeof n!=="symbol"){if(Rt.isCollection(t)){o=Object.freeze(o.concat(t));for(let i=0;i<t.items.length;++i){let s=await ac(i,t.items[i],r,o);if(typeof s==="number")i=s-1;else if(s===_r)return _r;else if(s===Nn)t.items.splice(i,1),i-=1}}else if(Rt.isPair(t)){o=Object.freeze(o.concat(t));let i=await ac("key",t.key,r,o);if(i===_r)return _r;else if(i===Nn)t.key=null;let s=await ac("value",t.value,r,o);if(s===_r)return _r;else if(s===Nn)t.value=null}}return n}function iD(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function sD(e,t,r,o){if(typeof r==="function")return r(e,t,o);if(Rt.isMap(t))return r.Map?.(e,t,o);if(Rt.isSeq(t))return r.Seq?.(e,t,o);if(Rt.isPair(t))return r.Pair?.(e,t,o);if(Rt.isScalar(t))return r.Scalar?.(e,t,o);if(Rt.isAlias(t))return r.Alias?.(e,t,o);return}function aD(e,t,r){let o=t[t.length-1];if(Rt.isCollection(o))o.items[e]=r;else if(Rt.isPair(o))if(e==="key")o.key=r;else o.value=r;else if(Rt.isDocument(o))o.contents=r;else{let n=Rt.isAlias(o)?"alias":"scalar";throw Error(`Cannot replace node with ${n} parent`)}}kG.visit=th;kG.visitAsync=rh});var jE=ge(function(CG){var cD=Me(),$G=Tu(),RG={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},OG=(e)=>e.replace(/[!,[\]{}]/g,(t)=>RG[t]);class Fr{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Fr.defaultYaml,e),this.tags=Object.assign({},Fr.defaultTags,t)}clone(){let e=new Fr(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new Fr(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:Fr.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},Fr.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:Fr.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},Fr.defaultTags),this.atNextDocument=!1;let r=e.trim().split(/[ \t]+/),o=r.shift();switch(o){case"%TAG":{if(r.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),r.length<2)return!1}let[n,i]=r;return this.tags[n]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[n]=r;if(n==="1.1"||n==="1.2")return this.yaml.version=n,!0;else{let i=/^\d+\.\d+$/.test(n);return t(6,`Unsupported YAML version ${n}`,i),!1}}default:return t(0,`Unknown directive ${o}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);if(i==="!"||i==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return i}let[,r,o]=e.match(/^(.*!)([^!]*)$/s);if(!o)t(`The ${e} tag has no suffix`);let n=this.tags[r];if(n)try{return n+decodeURIComponent(o)}catch(i){return t(String(i)),null}if(r==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+OG(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),o;if(e&&r.length>0&&cD.isNode(e.contents)){let n={};$G.visit(e.contents,(i,s)=>{if(cD.isNode(s)&&s.tag)n[s.tag]=!0}),o=Object.keys(n)}else o=[];for(let[n,i]of r){if(n==="!!"&&i==="tag:yaml.org,2002:")continue;if(!e||o.some((s)=>s.startsWith(i)))t.push(`%TAG ${n} ${i}`)}return t.join(`
246
- `)}}Fr.defaultYaml={explicit:!1,version:"1.2"};Fr.defaultTags={"!!":"tag:yaml.org,2002:"};CG.Directives=Fr});var nh=ge(function(LG){var lD=Me(),zG=Tu();function NG(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(r)}return!0}function uD(e){let t=new Set;return zG.visit(e,{Value(r,o){if(o.anchor)t.add(o.anchor)}}),t}function dD(e,t){for(let r=1;;++r){let o=`${e}${r}`;if(!t.has(o))return o}}function DG(e,t){let r=[],o=new Map,n=null;return{onAnchor:(i)=>{r.push(i),n??(n=uD(e));let s=dD(t,n);return n.add(s),s},setAnchors:()=>{for(let i of r){let s=o.get(i);if(typeof s==="object"&&s.anchor&&(lD.isScalar(s.node)||lD.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:o}}LG.anchorIsValid=NG;LG.anchorNames=uD;LG.createNodeAnchors=DG;LG.findNewAnchor=dD});var ZE=ge(function(qG){function $u(e,t,r,o){if(o&&typeof o==="object")if(Array.isArray(o))for(let n=0,i=o.length;n<i;++n){let s=o[n],a=$u(e,o,String(n),s);if(a===void 0)delete o[n];else if(a!==s)o[n]=a}else if(o instanceof Map)for(let n of Array.from(o.keys())){let i=o.get(n),s=$u(e,o,n,i);if(s===void 0)o.delete(n);else if(s!==i)o.set(n,s)}else if(o instanceof Set)for(let n of Array.from(o)){let i=$u(e,o,n,n);if(i===void 0)o.delete(n);else if(i!==n)o.delete(n),o.add(i)}else for(let[n,i]of Object.entries(o)){let s=$u(e,o,n,i);if(s===void 0)delete o[n];else if(s!==i)o[n]=s}return e.call(t,r,o)}qG.applyReviver=$u});var ai=ge(function(JG){var FG=Me();function fD(e,t,r){if(Array.isArray(e))return e.map((o,n)=>fD(o,String(n),r));if(e&&typeof e.toJSON==="function"){if(!r||!FG.hasAnchor(e))return e.toJSON(t,r);let o={aliasCount:0,count:1,res:void 0};r.anchors.set(e,o),r.onCreate=(i)=>{o.res=i,delete r.onCreate};let n=e.toJSON(t,r);if(r.onCreate)r.onCreate(n);return n}if(typeof e==="bigint"&&!r?.keep)return Number(e);return e}JG.toJS=fD});var oh=ge(function(WG){var HG=ZE(),pD=Me(),VG=ai();class mD{constructor(e){Object.defineProperty(this,pD.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:r,onAnchor:o,reviver:n}={}){if(!pD.isDocument(e))throw TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof r==="number"?r:100},s=VG.toJS(this,"",i);if(typeof o==="function")for(let{count:a,res:c}of i.anchors.values())o(c,a);return typeof n==="function"?HG.applyReviver(n,{"":s},"",s):s}}WG.NodeBase=mD});var Ru=ge(function(tQ){var QG=nh(),YG=Tu(),cc=Me(),XG=oh(),eQ=ai();class hD extends XG.NodeBase{constructor(e){super(cc.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let r;if(t?.aliasResolveCache)r=t.aliasResolveCache;else if(r=[],YG.visit(e,{Node:(n,i)=>{if(cc.isAlias(i)||cc.hasAnchor(i))r.push(i)}}),t)t.aliasResolveCache=r;let o=void 0;for(let n of r){if(n===this)break;if(n.anchor===this.source)o=n}return o}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:o,maxAliasCount:n}=t,i=this.resolve(o,t);if(!i){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let s=r.get(i);if(!s)eQ.toJS(i,null,t),s=r.get(i);if(s?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(n>=0){if(s.count+=1,s.aliasCount===0)s.aliasCount=ih(o,i,r);if(s.count*s.aliasCount>n)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return s.res}toString(e,t,r){let o=`*${this.source}`;if(e){if(QG.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let n=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(n)}if(e.implicitKey)return`${o} `}return o}}function ih(e,t,r){if(cc.isAlias(t)){let o=t.resolve(e),n=r&&o&&r.get(o);return n?n.count*n.aliasCount:0}else if(cc.isCollection(t)){let o=0;for(let n of t.items){let i=ih(e,n,r);if(i>o)o=i}return o}else if(cc.isPair(t)){let o=ih(e,t.key,r),n=ih(e,t.value,r);return Math.max(o,n)}return 1}tQ.Alias=hD});var Et=ge(function(aQ){var nQ=Me(),oQ=oh(),iQ=ai(),sQ=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class bs extends oQ.NodeBase{constructor(e){super(nQ.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:iQ.toJS(this.value,e,t)}toString(){return String(this.value)}}bs.BLOCK_FOLDED="BLOCK_FOLDED";bs.BLOCK_LITERAL="BLOCK_LITERAL";bs.PLAIN="PLAIN";bs.QUOTE_DOUBLE="QUOTE_DOUBLE";bs.QUOTE_SINGLE="QUOTE_SINGLE";aQ.Scalar=bs;aQ.isScalarValue=sQ});var Ou=ge(function(mQ){var uQ=Ru(),Ss=Me(),gD=Et(),dQ="tag:yaml.org,2002:";function fQ(e,t,r){if(t){let o=r.filter((i)=>i.tag===t),n=o.find((i)=>!i.format)??o[0];if(!n)throw Error(`Tag ${t} not found`);return n}return r.find((o)=>o.identify?.(e)&&!o.format)}function pQ(e,t,r){if(Ss.isDocument(e))e=e.contents;if(Ss.isNode(e))return e;if(Ss.isPair(e)){let f=r.schema[Ss.MAP].createNode?.(r.schema,null,r);return f.items.push(e),f}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:o,onAnchor:n,onTagObj:i,schema:s,sourceObjects:a}=r,c=void 0;if(o&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=n(e)),new uQ.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=dQ+t.slice(2);let u=fQ(e,t,s.tags);if(!u){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let f=new gD.Scalar(e);if(c)c.node=f;return f}u=e instanceof Map?s[Ss.MAP]:(Symbol.iterator in Object(e))?s[Ss.SEQ]:s[Ss.MAP]}if(i)i(u),delete r.onTagObj;let d=u?.createNode?u.createNode(r.schema,e,r):typeof u?.nodeClass?.from==="function"?u.nodeClass.from(r.schema,e,r):new gD.Scalar(e);if(t)d.tag=t;else if(!u.default)d.tag=u.tag;if(c)c.node=d;return d}mQ.createNode=pQ});var sh=ge(function(bQ){var gQ=Ou(),Dn=Me(),yQ=oh();function UE(e,t,r){let o=r;for(let n=t.length-1;n>=0;--n){let i=t[n];if(typeof i==="number"&&Number.isInteger(i)&&i>=0){let s=[];s[i]=o,o=s}else o=new Map([[i,o]])}return gQ.createNode(o,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var yD=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class bD extends yQ.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((r)=>Dn.isNode(r)||Dn.isPair(r)?r.clone(e):r),this.range)t.range=this.range.slice();return t}addIn(e,t){if(yD(e))this.add(t);else{let[r,...o]=e,n=this.get(r,!0);if(Dn.isCollection(n))n.addIn(o,t);else if(n===void 0&&this.schema)this.set(r,UE(this.schema,o,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let o=this.get(t,!0);if(Dn.isCollection(o))return o.deleteIn(r);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...o]=e,n=this.get(r,!0);if(o.length===0)return!t&&Dn.isScalar(n)?n.value:n;else return Dn.isCollection(n)?n.getIn(o,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!Dn.isPair(t))return!1;let r=t.value;return r==null||e&&Dn.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let o=this.get(t,!0);return Dn.isCollection(o)?o.hasIn(r):!1}setIn(e,t){let[r,...o]=e;if(o.length===0)this.set(r,t);else{let n=this.get(r,!0);if(Dn.isCollection(n))n.setIn(o,t);else if(n===void 0&&this.schema)this.set(r,UE(this.schema,o,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}}bQ.Collection=bD;bQ.collectionFromPath=UE;bQ.isEmptyPath=yD});var Cu=ge(function(EQ){var xQ=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function qE(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var _Q=(e,t,r)=>e.endsWith(`
244
+ `}function ZW(e,t){let r=jm(e.siteOverride);return[`BRAIN_VERSION=${e.brainVersion}`,...r.length>0?[`IMAGE_TAG=${Iu(e.brainVersion,r)}`]:[],`CONTENT_REPO=${K2(e,t)}`,""].join(`
245
+ `)}var PE=w(()=>{J2();Um();no()});var Me=ge(function(uG){var LE=Symbol.for("yaml.alias"),eD=Symbol.for("yaml.document"),Xm=Symbol.for("yaml.map"),tD=Symbol.for("yaml.pair"),BE=Symbol.for("yaml.scalar"),eh=Symbol.for("yaml.seq"),uo=Symbol.for("yaml.node.type"),nG=(e)=>!!e&&typeof e==="object"&&e[uo]===LE,oG=(e)=>!!e&&typeof e==="object"&&e[uo]===eD,iG=(e)=>!!e&&typeof e==="object"&&e[uo]===Xm,sG=(e)=>!!e&&typeof e==="object"&&e[uo]===tD,rD=(e)=>!!e&&typeof e==="object"&&e[uo]===BE,aG=(e)=>!!e&&typeof e==="object"&&e[uo]===eh;function nD(e){if(e&&typeof e==="object")switch(e[uo]){case Xm:case eh:return!0}return!1}function cG(e){if(e&&typeof e==="object")switch(e[uo]){case LE:case Xm:case BE:case eh:return!0}return!1}var lG=(e)=>(rD(e)||nD(e))&&!!e.anchor;uG.ALIAS=LE;uG.DOC=eD;uG.MAP=Xm;uG.NODE_TYPE=uo;uG.PAIR=tD;uG.SCALAR=BE;uG.SEQ=eh;uG.hasAnchor=lG;uG.isAlias=nG;uG.isCollection=nD;uG.isDocument=oG;uG.isMap=iG;uG.isNode=cG;uG.isPair=sG;uG.isScalar=rD;uG.isSeq=aG});var Tu=ge(function(AG){var Rt=Me(),_r=Symbol("break visit"),oD=Symbol("skip children"),Nn=Symbol("remove node");function th(e,t){let r=iD(t);if(Rt.isDocument(e)){if(sc(null,e.contents,r,Object.freeze([e]))===Nn)e.contents=null}else sc(null,e,r,Object.freeze([]))}th.BREAK=_r;th.SKIP=oD;th.REMOVE=Nn;function sc(e,t,r,o){let n=sD(e,t,r,o);if(Rt.isNode(n)||Rt.isPair(n))return aD(e,o,n),sc(e,n,r,o);if(typeof n!=="symbol"){if(Rt.isCollection(t)){o=Object.freeze(o.concat(t));for(let i=0;i<t.items.length;++i){let s=sc(i,t.items[i],r,o);if(typeof s==="number")i=s-1;else if(s===_r)return _r;else if(s===Nn)t.items.splice(i,1),i-=1}}else if(Rt.isPair(t)){o=Object.freeze(o.concat(t));let i=sc("key",t.key,r,o);if(i===_r)return _r;else if(i===Nn)t.key=null;let s=sc("value",t.value,r,o);if(s===_r)return _r;else if(s===Nn)t.value=null}}return n}async function rh(e,t){let r=iD(t);if(Rt.isDocument(e)){if(await ac(null,e.contents,r,Object.freeze([e]))===Nn)e.contents=null}else await ac(null,e,r,Object.freeze([]))}rh.BREAK=_r;rh.SKIP=oD;rh.REMOVE=Nn;async function ac(e,t,r,o){let n=await sD(e,t,r,o);if(Rt.isNode(n)||Rt.isPair(n))return aD(e,o,n),ac(e,n,r,o);if(typeof n!=="symbol"){if(Rt.isCollection(t)){o=Object.freeze(o.concat(t));for(let i=0;i<t.items.length;++i){let s=await ac(i,t.items[i],r,o);if(typeof s==="number")i=s-1;else if(s===_r)return _r;else if(s===Nn)t.items.splice(i,1),i-=1}}else if(Rt.isPair(t)){o=Object.freeze(o.concat(t));let i=await ac("key",t.key,r,o);if(i===_r)return _r;else if(i===Nn)t.key=null;let s=await ac("value",t.value,r,o);if(s===_r)return _r;else if(s===Nn)t.value=null}}return n}function iD(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function sD(e,t,r,o){if(typeof r==="function")return r(e,t,o);if(Rt.isMap(t))return r.Map?.(e,t,o);if(Rt.isSeq(t))return r.Seq?.(e,t,o);if(Rt.isPair(t))return r.Pair?.(e,t,o);if(Rt.isScalar(t))return r.Scalar?.(e,t,o);if(Rt.isAlias(t))return r.Alias?.(e,t,o);return}function aD(e,t,r){let o=t[t.length-1];if(Rt.isCollection(o))o.items[e]=r;else if(Rt.isPair(o))if(e==="key")o.key=r;else o.value=r;else if(Rt.isDocument(o))o.contents=r;else{let n=Rt.isAlias(o)?"alias":"scalar";throw Error(`Cannot replace node with ${n} parent`)}}AG.visit=th;AG.visitAsync=rh});var jE=ge(function(PG){var cD=Me(),RG=Tu(),OG={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},CG=(e)=>e.replace(/[!,[\]{}]/g,(t)=>OG[t]);class Fr{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Fr.defaultYaml,e),this.tags=Object.assign({},Fr.defaultTags,t)}clone(){let e=new Fr(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new Fr(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:Fr.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},Fr.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:Fr.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},Fr.defaultTags),this.atNextDocument=!1;let r=e.trim().split(/[ \t]+/),o=r.shift();switch(o){case"%TAG":{if(r.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),r.length<2)return!1}let[n,i]=r;return this.tags[n]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[n]=r;if(n==="1.1"||n==="1.2")return this.yaml.version=n,!0;else{let i=/^\d+\.\d+$/.test(n);return t(6,`Unsupported YAML version ${n}`,i),!1}}default:return t(0,`Unknown directive ${o}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);if(i==="!"||i==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return i}let[,r,o]=e.match(/^(.*!)([^!]*)$/s);if(!o)t(`The ${e} tag has no suffix`);let n=this.tags[r];if(n)try{return n+decodeURIComponent(o)}catch(i){return t(String(i)),null}if(r==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+CG(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),o;if(e&&r.length>0&&cD.isNode(e.contents)){let n={};RG.visit(e.contents,(i,s)=>{if(cD.isNode(s)&&s.tag)n[s.tag]=!0}),o=Object.keys(n)}else o=[];for(let[n,i]of r){if(n==="!!"&&i==="tag:yaml.org,2002:")continue;if(!e||o.some((s)=>s.startsWith(i)))t.push(`%TAG ${n} ${i}`)}return t.join(`
246
+ `)}}Fr.defaultYaml={explicit:!1,version:"1.2"};Fr.defaultTags={"!!":"tag:yaml.org,2002:"};PG.Directives=Fr});var nh=ge(function(BG){var lD=Me(),NG=Tu();function DG(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(r)}return!0}function uD(e){let t=new Set;return NG.visit(e,{Value(r,o){if(o.anchor)t.add(o.anchor)}}),t}function dD(e,t){for(let r=1;;++r){let o=`${e}${r}`;if(!t.has(o))return o}}function LG(e,t){let r=[],o=new Map,n=null;return{onAnchor:(i)=>{r.push(i),n??(n=uD(e));let s=dD(t,n);return n.add(s),s},setAnchors:()=>{for(let i of r){let s=o.get(i);if(typeof s==="object"&&s.anchor&&(lD.isScalar(s.node)||lD.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:o}}BG.anchorIsValid=DG;BG.anchorNames=uD;BG.createNodeAnchors=LG;BG.findNewAnchor=dD});var ZE=ge(function(MG){function $u(e,t,r,o){if(o&&typeof o==="object")if(Array.isArray(o))for(let n=0,i=o.length;n<i;++n){let s=o[n],a=$u(e,o,String(n),s);if(a===void 0)delete o[n];else if(a!==s)o[n]=a}else if(o instanceof Map)for(let n of Array.from(o.keys())){let i=o.get(n),s=$u(e,o,n,i);if(s===void 0)o.delete(n);else if(s!==i)o.set(n,s)}else if(o instanceof Set)for(let n of Array.from(o)){let i=$u(e,o,n,n);if(i===void 0)o.delete(n);else if(i!==n)o.delete(n),o.add(i)}else for(let[n,i]of Object.entries(o)){let s=$u(e,o,n,i);if(s===void 0)delete o[n];else if(s!==i)o[n]=s}return e.call(t,r,o)}MG.applyReviver=$u});var ai=ge(function(KG){var JG=Me();function fD(e,t,r){if(Array.isArray(e))return e.map((o,n)=>fD(o,String(n),r));if(e&&typeof e.toJSON==="function"){if(!r||!JG.hasAnchor(e))return e.toJSON(t,r);let o={aliasCount:0,count:1,res:void 0};r.anchors.set(e,o),r.onCreate=(i)=>{o.res=i,delete r.onCreate};let n=e.toJSON(t,r);if(r.onCreate)r.onCreate(n);return n}if(typeof e==="bigint"&&!r?.keep)return Number(e);return e}KG.toJS=fD});var oh=ge(function(GG){var VG=ZE(),pD=Me(),WG=ai();class mD{constructor(e){Object.defineProperty(this,pD.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:r,onAnchor:o,reviver:n}={}){if(!pD.isDocument(e))throw TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof r==="number"?r:100},s=WG.toJS(this,"",i);if(typeof o==="function")for(let{count:a,res:c}of i.anchors.values())o(c,a);return typeof n==="function"?VG.applyReviver(n,{"":s},"",s):s}}GG.NodeBase=mD});var Ru=ge(function(rQ){var YG=nh(),XG=Tu(),cc=Me(),eQ=oh(),tQ=ai();class hD extends eQ.NodeBase{constructor(e){super(cc.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let r;if(t?.aliasResolveCache)r=t.aliasResolveCache;else if(r=[],XG.visit(e,{Node:(n,i)=>{if(cc.isAlias(i)||cc.hasAnchor(i))r.push(i)}}),t)t.aliasResolveCache=r;let o=void 0;for(let n of r){if(n===this)break;if(n.anchor===this.source)o=n}return o}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:o,maxAliasCount:n}=t,i=this.resolve(o,t);if(!i){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let s=r.get(i);if(!s)tQ.toJS(i,null,t),s=r.get(i);if(s?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(n>=0){if(s.count+=1,s.aliasCount===0)s.aliasCount=ih(o,i,r);if(s.count*s.aliasCount>n)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return s.res}toString(e,t,r){let o=`*${this.source}`;if(e){if(YG.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let n=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(n)}if(e.implicitKey)return`${o} `}return o}}function ih(e,t,r){if(cc.isAlias(t)){let o=t.resolve(e),n=r&&o&&r.get(o);return n?n.count*n.aliasCount:0}else if(cc.isCollection(t)){let o=0;for(let n of t.items){let i=ih(e,n,r);if(i>o)o=i}return o}else if(cc.isPair(t)){let o=ih(e,t.key,r),n=ih(e,t.value,r);return Math.max(o,n)}return 1}rQ.Alias=hD});var Et=ge(function(cQ){var oQ=Me(),iQ=oh(),sQ=ai(),aQ=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class bs extends iQ.NodeBase{constructor(e){super(oQ.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:sQ.toJS(this.value,e,t)}toString(){return String(this.value)}}bs.BLOCK_FOLDED="BLOCK_FOLDED";bs.BLOCK_LITERAL="BLOCK_LITERAL";bs.PLAIN="PLAIN";bs.QUOTE_DOUBLE="QUOTE_DOUBLE";bs.QUOTE_SINGLE="QUOTE_SINGLE";cQ.Scalar=bs;cQ.isScalarValue=aQ});var Ou=ge(function(hQ){var dQ=Ru(),Ss=Me(),gD=Et(),fQ="tag:yaml.org,2002:";function pQ(e,t,r){if(t){let o=r.filter((i)=>i.tag===t),n=o.find((i)=>!i.format)??o[0];if(!n)throw Error(`Tag ${t} not found`);return n}return r.find((o)=>o.identify?.(e)&&!o.format)}function mQ(e,t,r){if(Ss.isDocument(e))e=e.contents;if(Ss.isNode(e))return e;if(Ss.isPair(e)){let f=r.schema[Ss.MAP].createNode?.(r.schema,null,r);return f.items.push(e),f}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:o,onAnchor:n,onTagObj:i,schema:s,sourceObjects:a}=r,c=void 0;if(o&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=n(e)),new dQ.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=fQ+t.slice(2);let u=pQ(e,t,s.tags);if(!u){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let f=new gD.Scalar(e);if(c)c.node=f;return f}u=e instanceof Map?s[Ss.MAP]:(Symbol.iterator in Object(e))?s[Ss.SEQ]:s[Ss.MAP]}if(i)i(u),delete r.onTagObj;let d=u?.createNode?u.createNode(r.schema,e,r):typeof u?.nodeClass?.from==="function"?u.nodeClass.from(r.schema,e,r):new gD.Scalar(e);if(t)d.tag=t;else if(!u.default)d.tag=u.tag;if(c)c.node=d;return d}hQ.createNode=mQ});var sh=ge(function(SQ){var yQ=Ou(),Dn=Me(),bQ=oh();function UE(e,t,r){let o=r;for(let n=t.length-1;n>=0;--n){let i=t[n];if(typeof i==="number"&&Number.isInteger(i)&&i>=0){let s=[];s[i]=o,o=s}else o=new Map([[i,o]])}return yQ.createNode(o,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var yD=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class bD extends bQ.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((r)=>Dn.isNode(r)||Dn.isPair(r)?r.clone(e):r),this.range)t.range=this.range.slice();return t}addIn(e,t){if(yD(e))this.add(t);else{let[r,...o]=e,n=this.get(r,!0);if(Dn.isCollection(n))n.addIn(o,t);else if(n===void 0&&this.schema)this.set(r,UE(this.schema,o,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let o=this.get(t,!0);if(Dn.isCollection(o))return o.deleteIn(r);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...o]=e,n=this.get(r,!0);if(o.length===0)return!t&&Dn.isScalar(n)?n.value:n;else return Dn.isCollection(n)?n.getIn(o,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!Dn.isPair(t))return!1;let r=t.value;return r==null||e&&Dn.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let o=this.get(t,!0);return Dn.isCollection(o)?o.hasIn(r):!1}setIn(e,t){let[r,...o]=e;if(o.length===0)this.set(r,t);else{let n=this.get(r,!0);if(Dn.isCollection(n))n.setIn(o,t);else if(n===void 0&&this.schema)this.set(r,UE(this.schema,o,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}}SQ.Collection=bD;SQ.collectionFromPath=UE;SQ.isEmptyPath=yD});var Cu=ge(function(IQ){var _Q=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function qE(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var EQ=(e,t,r)=>e.endsWith(`
247
247
  `)?qE(r,t):r.includes(`
248
248
  `)?`
249
- `+qE(r,t):(e.endsWith(" ")?"":" ")+r;EQ.indentComment=qE;EQ.lineComment=_Q;EQ.stringifyComment=xQ});var vD=ge(function($Q){function TQ(e,t,r="flow",{indentAtStart:o,lineWidth:n=80,minContentWidth:i=20,onFold:s,onOverflow:a}={}){if(!n||n<0)return e;if(n<i)i=0;let c=Math.max(1+i,1+n-t.length);if(e.length<=c)return e;let u=[],d={},f=n-t.length;if(typeof o==="number")if(o>n-Math.max(2,i))u.push(0);else f=n-o;let m=void 0,h=void 0,b=!1,y=-1,S=-1,x=-1;if(r==="block"){if(y=SD(e,y,t.length),y!==-1)f=y+c}for(let A;A=e[y+=1];){if(r==="quoted"&&A==="\\"){switch(S=y,e[y+1]){case"x":y+=3;break;case"u":y+=5;break;case"U":y+=9;break;default:y+=1}x=y}if(A===`
249
+ `+qE(r,t):(e.endsWith(" ")?"":" ")+r;IQ.indentComment=qE;IQ.lineComment=EQ;IQ.stringifyComment=_Q});var vD=ge(function(RQ){function $Q(e,t,r="flow",{indentAtStart:o,lineWidth:n=80,minContentWidth:i=20,onFold:s,onOverflow:a}={}){if(!n||n<0)return e;if(n<i)i=0;let c=Math.max(1+i,1+n-t.length);if(e.length<=c)return e;let u=[],d={},f=n-t.length;if(typeof o==="number")if(o>n-Math.max(2,i))u.push(0);else f=n-o;let m=void 0,h=void 0,b=!1,y=-1,S=-1,x=-1;if(r==="block"){if(y=SD(e,y,t.length),y!==-1)f=y+c}for(let A;A=e[y+=1];){if(r==="quoted"&&A==="\\"){switch(S=y,e[y+1]){case"x":y+=3;break;case"u":y+=5;break;case"U":y+=9;break;default:y+=1}x=y}if(A===`
250
250
  `){if(r==="block")y=SD(e,y,t.length);f=y+t.length+c,m=void 0}else{if(A===" "&&h&&h!==" "&&h!==`
251
251
  `&&h!=="\t"){let O=e[y+1];if(O&&O!==" "&&O!==`
252
252
  `&&O!=="\t")m=y}if(y>=f)if(m)u.push(m),f=m+c,m=void 0;else if(r==="quoted"){while(h===" "||h==="\t")h=A,A=e[y+=1],b=!0;let O=y>x+1?y-2:S-1;if(d[O])return e;u.push(O),d[O]=!0,f=O+c,m=void 0}else b=!0}h=A}if(b&&a)a();if(u.length===0)return e;if(s)s();let _=e.slice(0,u[0]);for(let A=0;A<u.length;++A){let O=u[A],L=u[A+1]||e.length;if(O===0)_=`
253
253
  ${t}${e.slice(0,L)}`;else{if(r==="quoted"&&d[O])_+=`${e[O]}\\`;_+=`
254
254
  ${t}${e.slice(O+1,L)}`}}return _}function SD(e,t,r){let o=t,n=t+1,i=e[n];while(i===" "||i==="\t")if(t<n+r)i=e[++t];else{do i=e[++t];while(i&&i!==`
255
- `);o=t,n=t+1,i=e[n]}return o}$Q.FOLD_BLOCK="block";$Q.FOLD_FLOW="flow";$Q.FOLD_QUOTED="quoted";$Q.foldFlowLines=TQ});var zu=ge(function(LQ){var ln=Et(),ci=vD(),ch=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),lh=(e)=>/^(%|---|\.\.\.)/m.test(e);function zQ(e,t,r){if(!t||t<0)return!1;let o=t-r,n=e.length;if(n<=o)return!1;for(let i=0,s=0;i<n;++i)if(e[i]===`
255
+ `);o=t,n=t+1,i=e[n]}return o}RQ.FOLD_BLOCK="block";RQ.FOLD_FLOW="flow";RQ.FOLD_QUOTED="quoted";RQ.foldFlowLines=$Q});var zu=ge(function(BQ){var ln=Et(),ci=vD(),ch=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),lh=(e)=>/^(%|---|\.\.\.)/m.test(e);function NQ(e,t,r){if(!t||t<0)return!1;let o=t-r,n=e.length;if(n<=o)return!1;for(let i=0,s=0;i<n;++i)if(e[i]===`
256
256
  `){if(i-s>o)return!0;if(s=i+1,n-s<=o)return!1}return!0}function Pu(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:o}=t,n=t.options.doubleQuotedMinMultiLineLength,i=t.indent||(lh(e)?" ":""),s="",a=0;for(let c=0,u=r[c];u;u=r[++c]){if(u===" "&&r[c+1]==="\\"&&r[c+2]==="n")s+=r.slice(a,c)+"\\ ",c+=1,a=c,u="\\";if(u==="\\")switch(r[c+1]){case"u":{s+=r.slice(a,c);let d=r.substr(c+2,4);switch(d){case"0000":s+="\\0";break;case"0007":s+="\\a";break;case"000b":s+="\\v";break;case"001b":s+="\\e";break;case"0085":s+="\\N";break;case"00a0":s+="\\_";break;case"2028":s+="\\L";break;case"2029":s+="\\P";break;default:if(d.substr(0,2)==="00")s+="\\x"+d.substr(2);else s+=r.substr(c,6)}c+=5,a=c+1}break;case"n":if(o||r[c+2]==='"'||r.length<n)c+=1;else{s+=r.slice(a,c)+`
257
257
 
258
258
  `;while(r[c+2]==="\\"&&r[c+3]==="n"&&r[c+4]!=='"')s+=`
@@ -261,7 +261,7 @@ ${t}${e.slice(O+1,L)}`}}return _}function SD(e,t,r){let o=t,n=t+1,i=e[n];while(i
261
261
  ${r}`)+"'";return t.implicitKey?o:ci.foldFlowLines(o,r,ci.FOLD_FLOW,ch(t,!1))}function lc(e,t){let{singleQuote:r}=t.options,o;if(r===!1)o=Pu;else{let n=e.includes('"'),i=e.includes("'");if(n&&!i)o=ME;else if(i&&!n)o=Pu;else o=r?ME:Pu}return o(e,t)}var FE;try{FE=new RegExp(`(^|(?<!
262
262
  ))
263
263
  +(?!
264
- |$)`,"g")}catch{FE=/\n+(?!\n|$)/g}function ah({comment:e,type:t,value:r},o,n,i){let{blockQuote:s,commentString:a,lineWidth:c}=o.options;if(!s||/\n[\t ]+$/.test(r))return lc(r,o);let u=o.indent||(o.forceBlockIndent||lh(r)?" ":""),d=s==="literal"?!0:s==="folded"||t===ln.Scalar.BLOCK_FOLDED?!1:t===ln.Scalar.BLOCK_LITERAL?!0:!zQ(r,c,u.length);if(!r)return d?`|
264
+ |$)`,"g")}catch{FE=/\n+(?!\n|$)/g}function ah({comment:e,type:t,value:r},o,n,i){let{blockQuote:s,commentString:a,lineWidth:c}=o.options;if(!s||/\n[\t ]+$/.test(r))return lc(r,o);let u=o.indent||(o.forceBlockIndent||lh(r)?" ":""),d=s==="literal"?!0:s==="folded"||t===ln.Scalar.BLOCK_FOLDED?!1:t===ln.Scalar.BLOCK_LITERAL?!0:!NQ(r,c,u.length);if(!r)return d?`|
265
265
  `:`>
266
266
  `;let f,m;for(m=r.length;m>0;--m){let L=r[m-1];if(L!==`
267
267
  `&&L!=="\t"&&L!==" ")break}let h=r.substring(m),b=h.indexOf(`
@@ -270,12 +270,12 @@ ${r}`)+"'";return t.implicitKey?o:ci.foldFlowLines(o,r,ci.FOLD_FLOW,ch(t,!1))}fu
270
270
  `)x=S;else break}let _=r.substring(0,x<S?x+1:S);if(_)r=r.substring(_.length),_=_.replace(/\n+/g,`$&${u}`);let O=(y?u?"2":"1":"")+f;if(e){if(O+=" "+a(e.replace(/ ?[\r\n]+/g," ")),n)n()}if(!d){let L=r.replace(/\n+/g,`
271
271
  $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`),z=!1,K=ch(o,!0);if(s!=="folded"&&t!==ln.Scalar.BLOCK_FOLDED)K.onOverflow=()=>{z=!0};let P=ci.foldFlowLines(`${_}${L}${h}`,u,ci.FOLD_BLOCK,K);if(!z)return`>${O}
272
272
  ${u}${P}`}return r=r.replace(/\n+/g,`$&${u}`),`|${O}
273
- ${u}${_}${r}${h}`}function NQ(e,t,r,o){let{type:n,value:i}=e,{actualString:s,implicitKey:a,indent:c,indentStep:u,inFlow:d}=t;if(a&&i.includes(`
273
+ ${u}${_}${r}${h}`}function DQ(e,t,r,o){let{type:n,value:i}=e,{actualString:s,implicitKey:a,indent:c,indentStep:u,inFlow:d}=t;if(a&&i.includes(`
274
274
  `)||d&&/[[\]{},]/.test(i))return lc(i,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||d||!i.includes(`
275
275
  `)?lc(i,t):ah(e,t,r,o);if(!a&&!d&&n!==ln.Scalar.PLAIN&&i.includes(`
276
276
  `))return ah(e,t,r,o);if(lh(i)){if(c==="")return t.forceBlockIndent=!0,ah(e,t,r,o);else if(a&&c===u)return lc(i,t)}let f=i.replace(/\n+/g,`$&
277
- ${c}`);if(s){let m=(y)=>y.default&&y.tag!=="tag:yaml.org,2002:str"&&y.test?.test(f),{compat:h,tags:b}=t.doc.schema;if(b.some(m)||h?.some(m))return lc(i,t)}return a?f:ci.foldFlowLines(f,c,ci.FOLD_FLOW,ch(t,!1))}function DQ(e,t,r,o){let{implicitKey:n,inFlow:i}=t,s=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==ln.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value))a=ln.Scalar.QUOTE_DOUBLE}let c=(d)=>{switch(d){case ln.Scalar.BLOCK_FOLDED:case ln.Scalar.BLOCK_LITERAL:return n||i?lc(s.value,t):ah(s,t,r,o);case ln.Scalar.QUOTE_DOUBLE:return Pu(s.value,t);case ln.Scalar.QUOTE_SINGLE:return ME(s.value,t);case ln.Scalar.PLAIN:return NQ(s,t,r,o);default:return null}},u=c(a);if(u===null){let{defaultKeyType:d,defaultStringType:f}=t.options,m=n&&d||f;if(u=c(m),u===null)throw Error(`Unsupported default string type ${m}`)}return u}LQ.stringifyString=DQ});var Nu=ge(function(KQ){var jQ=nh(),li=Me(),ZQ=Cu(),UQ=zu();function qQ(e,t){let r=Object.assign({blockQuote:!0,commentString:ZQ.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),o;switch(r.collectionStyle){case"block":o=!1;break;case"flow":o=!0;break;default:o=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent==="number"?" ".repeat(r.indent):" ",inFlow:o,options:r}}function MQ(e,t){if(t.tag){let n=e.filter((i)=>i.tag===t.tag);if(n.length>0)return n.find((i)=>i.format===t.format)??n[0]}let r=void 0,o;if(li.isScalar(t)){o=t.value;let n=e.filter((i)=>i.identify?.(o));if(n.length>1){let i=n.filter((s)=>s.test);if(i.length>0)n=i}r=n.find((i)=>i.format===t.format)??n.find((i)=>!i.format)}else o=t,r=e.find((n)=>n.nodeClass&&o instanceof n.nodeClass);if(!r){let n=o?.constructor?.name??(o===null?"null":typeof o);throw Error(`Tag not resolved for ${n} value`)}return r}function FQ(e,t,{anchors:r,doc:o}){if(!o.directives)return"";let n=[],i=(li.isScalar(e)||li.isCollection(e))&&e.anchor;if(i&&jQ.anchorIsValid(i))r.add(i),n.push(`&${i}`);let s=e.tag??(t.default?null:t.tag);if(s)n.push(o.directives.tagString(s));return n.join(" ")}function JQ(e,t,r,o){if(li.isPair(e))return e.toString(t,r,o);if(li.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let n=void 0,i=li.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>n=c});n??(n=MQ(t.doc.schema.tags,i));let s=FQ(i,n,t);if(s.length>0)t.indentAtStart=(t.indentAtStart??0)+s.length+1;let a=typeof n.stringify==="function"?n.stringify(i,t,r,o):li.isScalar(i)?UQ.stringifyString(i,t,r,o):i.toString(t,r,o);if(!s)return a;return li.isScalar(i)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
278
- ${t.indent}${a}`}KQ.createStringifyContext=qQ;KQ.stringify=JQ});var _D=ge(function(GQ){var fo=Me(),wD=Et(),xD=Nu(),Du=Cu();function WQ({key:e,value:t},r,o,n){let{allNullValues:i,doc:s,indent:a,indentStep:c,options:{commentString:u,indentSeq:d,simpleKeys:f}}=r,m=fo.isNode(e)&&e.comment||null;if(f){if(m)throw Error("With simple keys, key nodes cannot have comments");if(fo.isCollection(e)||!fo.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let h=!f&&(!e||m&&t==null&&!r.inFlow||fo.isCollection(e)||(fo.isScalar(e)?e.type===wD.Scalar.BLOCK_FOLDED||e.type===wD.Scalar.BLOCK_LITERAL:typeof e==="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!h&&(f||!i),indent:a+c});let b=!1,y=!1,S=xD.stringify(e,r,()=>b=!0,()=>y=!0);if(!h&&!r.inFlow&&S.length>1024){if(f)throw Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(r.inFlow){if(i||t==null){if(b&&o)o();return S===""?"?":h?`? ${S}`:S}}else if(i&&!f||t==null&&h){if(S=`? ${S}`,m&&!b)S+=Du.lineComment(S,r.indent,u(m));else if(y&&n)n();return S}if(b)m=null;if(h){if(m)S+=Du.lineComment(S,r.indent,u(m));S=`? ${S}
277
+ ${c}`);if(s){let m=(y)=>y.default&&y.tag!=="tag:yaml.org,2002:str"&&y.test?.test(f),{compat:h,tags:b}=t.doc.schema;if(b.some(m)||h?.some(m))return lc(i,t)}return a?f:ci.foldFlowLines(f,c,ci.FOLD_FLOW,ch(t,!1))}function LQ(e,t,r,o){let{implicitKey:n,inFlow:i}=t,s=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==ln.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value))a=ln.Scalar.QUOTE_DOUBLE}let c=(d)=>{switch(d){case ln.Scalar.BLOCK_FOLDED:case ln.Scalar.BLOCK_LITERAL:return n||i?lc(s.value,t):ah(s,t,r,o);case ln.Scalar.QUOTE_DOUBLE:return Pu(s.value,t);case ln.Scalar.QUOTE_SINGLE:return ME(s.value,t);case ln.Scalar.PLAIN:return DQ(s,t,r,o);default:return null}},u=c(a);if(u===null){let{defaultKeyType:d,defaultStringType:f}=t.options,m=n&&d||f;if(u=c(m),u===null)throw Error(`Unsupported default string type ${m}`)}return u}BQ.stringifyString=LQ});var Nu=ge(function(HQ){var ZQ=nh(),li=Me(),UQ=Cu(),qQ=zu();function MQ(e,t){let r=Object.assign({blockQuote:!0,commentString:UQ.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),o;switch(r.collectionStyle){case"block":o=!1;break;case"flow":o=!0;break;default:o=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent==="number"?" ".repeat(r.indent):" ",inFlow:o,options:r}}function FQ(e,t){if(t.tag){let n=e.filter((i)=>i.tag===t.tag);if(n.length>0)return n.find((i)=>i.format===t.format)??n[0]}let r=void 0,o;if(li.isScalar(t)){o=t.value;let n=e.filter((i)=>i.identify?.(o));if(n.length>1){let i=n.filter((s)=>s.test);if(i.length>0)n=i}r=n.find((i)=>i.format===t.format)??n.find((i)=>!i.format)}else o=t,r=e.find((n)=>n.nodeClass&&o instanceof n.nodeClass);if(!r){let n=o?.constructor?.name??(o===null?"null":typeof o);throw Error(`Tag not resolved for ${n} value`)}return r}function JQ(e,t,{anchors:r,doc:o}){if(!o.directives)return"";let n=[],i=(li.isScalar(e)||li.isCollection(e))&&e.anchor;if(i&&ZQ.anchorIsValid(i))r.add(i),n.push(`&${i}`);let s=e.tag??(t.default?null:t.tag);if(s)n.push(o.directives.tagString(s));return n.join(" ")}function KQ(e,t,r,o){if(li.isPair(e))return e.toString(t,r,o);if(li.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let n=void 0,i=li.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>n=c});n??(n=FQ(t.doc.schema.tags,i));let s=JQ(i,n,t);if(s.length>0)t.indentAtStart=(t.indentAtStart??0)+s.length+1;let a=typeof n.stringify==="function"?n.stringify(i,t,r,o):li.isScalar(i)?qQ.stringifyString(i,t,r,o):i.toString(t,r,o);if(!s)return a;return li.isScalar(i)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
278
+ ${t.indent}${a}`}HQ.createStringifyContext=MQ;HQ.stringify=KQ});var _D=ge(function(QQ){var fo=Me(),wD=Et(),xD=Nu(),Du=Cu();function GQ({key:e,value:t},r,o,n){let{allNullValues:i,doc:s,indent:a,indentStep:c,options:{commentString:u,indentSeq:d,simpleKeys:f}}=r,m=fo.isNode(e)&&e.comment||null;if(f){if(m)throw Error("With simple keys, key nodes cannot have comments");if(fo.isCollection(e)||!fo.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let h=!f&&(!e||m&&t==null&&!r.inFlow||fo.isCollection(e)||(fo.isScalar(e)?e.type===wD.Scalar.BLOCK_FOLDED||e.type===wD.Scalar.BLOCK_LITERAL:typeof e==="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!h&&(f||!i),indent:a+c});let b=!1,y=!1,S=xD.stringify(e,r,()=>b=!0,()=>y=!0);if(!h&&!r.inFlow&&S.length>1024){if(f)throw Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(r.inFlow){if(i||t==null){if(b&&o)o();return S===""?"?":h?`? ${S}`:S}}else if(i&&!f||t==null&&h){if(S=`? ${S}`,m&&!b)S+=Du.lineComment(S,r.indent,u(m));else if(y&&n)n();return S}if(b)m=null;if(h){if(m)S+=Du.lineComment(S,r.indent,u(m));S=`? ${S}
279
279
  ${a}:`}else if(S=`${S}:`,m)S+=Du.lineComment(S,r.indent,u(m));let x,_,A;if(fo.isNode(t))x=!!t.spaceBefore,_=t.commentBefore,A=t.comment;else if(x=!1,_=null,A=null,t&&typeof t==="object")t=s.createNode(t);if(r.implicitKey=!1,!h&&!m&&fo.isScalar(t))r.indentAtStart=S.length+1;if(y=!1,!d&&c.length>=2&&!r.inFlow&&!h&&fo.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)r.indent=r.indent.substring(2);let O=!1,L=xD.stringify(t,r,()=>O=!0,()=>y=!0),z=" ";if(m||x||_){if(z=x?`
280
280
  `:"",_){let K=u(_);z+=`
281
281
  ${Du.indentComment(K,r.indent)}`}if(L===""&&!r.inFlow){if(z===`
@@ -285,32 +285,32 @@ ${Du.indentComment(K,r.indent)}`}if(L===""&&!r.inFlow){if(z===`
285
285
  ${r.indent}`}else if(!h&&fo.isCollection(t)){let K=L[0],P=L.indexOf(`
286
286
  `),W=P!==-1,ee=r.inFlow??t.flow??t.items.length===0;if(W||!ee){let j=!1;if(W&&(K==="&"||K==="!")){let R=L.indexOf(" ");if(K==="&"&&R!==-1&&R<P&&L[R+1]==="!")R=L.indexOf(" ",R+1);if(R===-1||P<R)j=!0}if(!j)z=`
287
287
  ${r.indent}`}}else if(L===""||L[0]===`
288
- `)z="";if(S+=z+L,r.inFlow){if(O&&o)o()}else if(A&&!O)S+=Du.lineComment(S,r.indent,u(A));else if(y&&n)n();return S}GQ.stringifyPair=WQ});var JE=ge(function(eY){var ED=Zr("process");function YQ(e,...t){if(e==="debug")console.log(...t)}function XQ(e,t){if(e==="debug"||e==="warn")if(typeof ED.emitWarning==="function")ED.emitWarning(t);else console.warn(t)}eY.debug=YQ;eY.warn=XQ});var ph=ge(function(oY){var fh=Me(),ID=Et(),uh="<<",dh={identify:(e)=>e===uh||typeof e==="symbol"&&e.description===uh,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ID.Scalar(Symbol(uh)),{addToJSMap:kD}),stringify:()=>uh},nY=(e,t)=>(dh.identify(t)||fh.isScalar(t)&&(!t.type||t.type===ID.Scalar.PLAIN)&&dh.identify(t.value))&&e?.doc.schema.tags.some((r)=>r.tag===dh.tag&&r.default);function kD(e,t,r){let o=AD(e,r);if(fh.isSeq(o))for(let n of o.items)KE(e,t,n);else if(Array.isArray(o))for(let n of o)KE(e,t,n);else KE(e,t,o)}function KE(e,t,r){let o=AD(e,r);if(!fh.isMap(o))throw Error("Merge sources must be maps or map aliases");let n=o.toJSON(null,e,Map);for(let[i,s]of n)if(t instanceof Map){if(!t.has(i))t.set(i,s)}else if(t instanceof Set)t.add(i);else if(!Object.prototype.hasOwnProperty.call(t,i))Object.defineProperty(t,i,{value:s,writable:!0,enumerable:!0,configurable:!0});return t}function AD(e,t){return e&&fh.isAlias(t)?t.resolve(e.doc,e):t}oY.addMergeToJSMap=kD;oY.isMergeKey=nY;oY.merge=dh});var VE=ge(function(fY){var cY=JE(),TD=ph(),lY=Nu(),$D=Me(),HE=ai();function uY(e,t,{key:r,value:o}){if($D.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(TD.isMergeKey(e,r))TD.addMergeToJSMap(e,t,o);else{let n=HE.toJS(r,"",e);if(t instanceof Map)t.set(n,HE.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=dY(r,n,e),s=HE.toJS(o,i,e);if(i in t)Object.defineProperty(t,i,{value:s,writable:!0,enumerable:!0,configurable:!0});else t[i]=s}}return t}function dY(e,t,r){if(t===null)return"";if(typeof t!=="object")return String(t);if($D.isNode(e)&&r?.doc){let o=lY.createStringifyContext(r.doc,{});o.anchors=new Set;for(let i of r.anchors.keys())o.anchors.add(i.anchor);o.inFlow=!0,o.inStringifyKey=!0;let n=e.toString(o);if(!r.mapKeyWarned){let i=JSON.stringify(n);if(i.length>40)i=i.substring(0,36)+'..."';cY.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(t)}fY.addPairToJSMap=uY});var ui=ge(function(yY){var RD=Ou(),mY=_D(),hY=VE(),mh=Me();function gY(e,t,r){let o=RD.createNode(e,void 0,r),n=RD.createNode(t,void 0,r);return new hh(o,n)}class hh{constructor(e,t=null){Object.defineProperty(this,mh.NODE_TYPE,{value:mh.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;if(mh.isNode(t))t=t.clone(e);if(mh.isNode(r))r=r.clone(e);return new hh(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return hY.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?mY.stringifyPair(this,e,t,r):JSON.stringify(this)}}yY.Pair=hh;yY.createPair=gY});var WE=ge(function(_Y){var vs=Me(),OD=Nu(),gh=Cu();function vY(e,t,r){return(t.inFlow??e.flow?xY:wY)(e,t,r)}function wY({comment:e,items:t},r,{blockItemPrefix:o,flowChars:n,itemIndent:i,onChompKeep:s,onComment:a}){let{indent:c,options:{commentString:u}}=r,d=Object.assign({},r,{indent:i,type:null}),f=!1,m=[];for(let b=0;b<t.length;++b){let y=t[b],S=null;if(vs.isNode(y)){if(!f&&y.spaceBefore)m.push("");if(yh(r,m,y.commentBefore,f),y.comment)S=y.comment}else if(vs.isPair(y)){let _=vs.isNode(y.key)?y.key:null;if(_){if(!f&&_.spaceBefore)m.push("");yh(r,m,_.commentBefore,f)}}f=!1;let x=OD.stringify(y,d,()=>S=null,()=>f=!0);if(S)x+=gh.lineComment(x,i,u(S));if(f&&S)f=!1;m.push(o+x)}let h;if(m.length===0)h=n.start+n.end;else{h=m[0];for(let b=1;b<m.length;++b){let y=m[b];h+=y?`
288
+ `)z="";if(S+=z+L,r.inFlow){if(O&&o)o()}else if(A&&!O)S+=Du.lineComment(S,r.indent,u(A));else if(y&&n)n();return S}QQ.stringifyPair=GQ});var JE=ge(function(tY){var ED=Zr("process");function XQ(e,...t){if(e==="debug")console.log(...t)}function eY(e,t){if(e==="debug"||e==="warn")if(typeof ED.emitWarning==="function")ED.emitWarning(t);else console.warn(t)}tY.debug=XQ;tY.warn=eY});var ph=ge(function(iY){var fh=Me(),ID=Et(),uh="<<",dh={identify:(e)=>e===uh||typeof e==="symbol"&&e.description===uh,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ID.Scalar(Symbol(uh)),{addToJSMap:kD}),stringify:()=>uh},oY=(e,t)=>(dh.identify(t)||fh.isScalar(t)&&(!t.type||t.type===ID.Scalar.PLAIN)&&dh.identify(t.value))&&e?.doc.schema.tags.some((r)=>r.tag===dh.tag&&r.default);function kD(e,t,r){let o=AD(e,r);if(fh.isSeq(o))for(let n of o.items)KE(e,t,n);else if(Array.isArray(o))for(let n of o)KE(e,t,n);else KE(e,t,o)}function KE(e,t,r){let o=AD(e,r);if(!fh.isMap(o))throw Error("Merge sources must be maps or map aliases");let n=o.toJSON(null,e,Map);for(let[i,s]of n)if(t instanceof Map){if(!t.has(i))t.set(i,s)}else if(t instanceof Set)t.add(i);else if(!Object.prototype.hasOwnProperty.call(t,i))Object.defineProperty(t,i,{value:s,writable:!0,enumerable:!0,configurable:!0});return t}function AD(e,t){return e&&fh.isAlias(t)?t.resolve(e.doc,e):t}iY.addMergeToJSMap=kD;iY.isMergeKey=oY;iY.merge=dh});var VE=ge(function(pY){var lY=JE(),TD=ph(),uY=Nu(),$D=Me(),HE=ai();function dY(e,t,{key:r,value:o}){if($D.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(TD.isMergeKey(e,r))TD.addMergeToJSMap(e,t,o);else{let n=HE.toJS(r,"",e);if(t instanceof Map)t.set(n,HE.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=fY(r,n,e),s=HE.toJS(o,i,e);if(i in t)Object.defineProperty(t,i,{value:s,writable:!0,enumerable:!0,configurable:!0});else t[i]=s}}return t}function fY(e,t,r){if(t===null)return"";if(typeof t!=="object")return String(t);if($D.isNode(e)&&r?.doc){let o=uY.createStringifyContext(r.doc,{});o.anchors=new Set;for(let i of r.anchors.keys())o.anchors.add(i.anchor);o.inFlow=!0,o.inStringifyKey=!0;let n=e.toString(o);if(!r.mapKeyWarned){let i=JSON.stringify(n);if(i.length>40)i=i.substring(0,36)+'..."';lY.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(t)}pY.addPairToJSMap=dY});var ui=ge(function(bY){var RD=Ou(),hY=_D(),gY=VE(),mh=Me();function yY(e,t,r){let o=RD.createNode(e,void 0,r),n=RD.createNode(t,void 0,r);return new hh(o,n)}class hh{constructor(e,t=null){Object.defineProperty(this,mh.NODE_TYPE,{value:mh.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;if(mh.isNode(t))t=t.clone(e);if(mh.isNode(r))r=r.clone(e);return new hh(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return gY.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?hY.stringifyPair(this,e,t,r):JSON.stringify(this)}}bY.Pair=hh;bY.createPair=yY});var WE=ge(function(EY){var vs=Me(),OD=Nu(),gh=Cu();function wY(e,t,r){return(t.inFlow??e.flow?_Y:xY)(e,t,r)}function xY({comment:e,items:t},r,{blockItemPrefix:o,flowChars:n,itemIndent:i,onChompKeep:s,onComment:a}){let{indent:c,options:{commentString:u}}=r,d=Object.assign({},r,{indent:i,type:null}),f=!1,m=[];for(let b=0;b<t.length;++b){let y=t[b],S=null;if(vs.isNode(y)){if(!f&&y.spaceBefore)m.push("");if(yh(r,m,y.commentBefore,f),y.comment)S=y.comment}else if(vs.isPair(y)){let _=vs.isNode(y.key)?y.key:null;if(_){if(!f&&_.spaceBefore)m.push("");yh(r,m,_.commentBefore,f)}}f=!1;let x=OD.stringify(y,d,()=>S=null,()=>f=!0);if(S)x+=gh.lineComment(x,i,u(S));if(f&&S)f=!1;m.push(o+x)}let h;if(m.length===0)h=n.start+n.end;else{h=m[0];for(let b=1;b<m.length;++b){let y=m[b];h+=y?`
289
289
  ${c}${y}`:`
290
290
  `}}if(e){if(h+=`
291
- `+gh.indentComment(u(e),c),a)a()}else if(f&&s)s();return h}function xY({items:e},t,{flowChars:r,itemIndent:o}){let{indent:n,indentStep:i,flowCollectionPadding:s,options:{commentString:a}}=t;o+=i;let c=Object.assign({},t,{indent:o,inFlow:!0,type:null}),u=!1,d=0,f=[];for(let b=0;b<e.length;++b){let y=e[b],S=null;if(vs.isNode(y)){if(y.spaceBefore)f.push("");if(yh(t,f,y.commentBefore,!1),y.comment)S=y.comment}else if(vs.isPair(y)){let _=vs.isNode(y.key)?y.key:null;if(_){if(_.spaceBefore)f.push("");if(yh(t,f,_.commentBefore,!1),_.comment)u=!0}let A=vs.isNode(y.value)?y.value:null;if(A){if(A.comment)S=A.comment;if(A.commentBefore)u=!0}else if(y.value==null&&_?.comment)S=_.comment}if(S)u=!0;let x=OD.stringify(y,c,()=>S=null);if(u||(u=f.length>d||x.includes(`
291
+ `+gh.indentComment(u(e),c),a)a()}else if(f&&s)s();return h}function _Y({items:e},t,{flowChars:r,itemIndent:o}){let{indent:n,indentStep:i,flowCollectionPadding:s,options:{commentString:a}}=t;o+=i;let c=Object.assign({},t,{indent:o,inFlow:!0,type:null}),u=!1,d=0,f=[];for(let b=0;b<e.length;++b){let y=e[b],S=null;if(vs.isNode(y)){if(y.spaceBefore)f.push("");if(yh(t,f,y.commentBefore,!1),y.comment)S=y.comment}else if(vs.isPair(y)){let _=vs.isNode(y.key)?y.key:null;if(_){if(_.spaceBefore)f.push("");if(yh(t,f,_.commentBefore,!1),_.comment)u=!0}let A=vs.isNode(y.value)?y.value:null;if(A){if(A.comment)S=A.comment;if(A.commentBefore)u=!0}else if(y.value==null&&_?.comment)S=_.comment}if(S)u=!0;let x=OD.stringify(y,c,()=>S=null);if(u||(u=f.length>d||x.includes(`
292
292
  `)),b<e.length-1)x+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)u||(u=f.reduce((_,A)=>_+A.length+2,2)+(x.length+2)>t.options.lineWidth);if(u)x+=","}if(S)x+=gh.lineComment(x,o,a(S));f.push(x),d=f.length}let{start:m,end:h}=r;if(f.length===0)return m+h;else{if(!u){let b=f.reduce((y,S)=>y+S.length+2,2);u=t.options.lineWidth>0&&b>t.options.lineWidth}if(u){let b=m;for(let y of f)b+=y?`
293
293
  ${i}${n}${y}`:`
294
294
  `;return`${b}
295
- ${n}${h}`}else return`${m}${s}${f.join(" ")}${s}${h}`}}function yh({indent:e,options:{commentString:t}},r,o,n){if(o&&n)o=o.replace(/^\n+/,"");if(o){let i=gh.indentComment(t(o),e);r.push(i.trimStart())}}_Y.stringifyCollection=vY});var fi=ge(function($Y){var IY=WE(),kY=VE(),AY=sh(),di=Me(),bh=ui(),TY=Et();function Lu(e,t){let r=di.isScalar(t)?t.value:t;for(let o of e)if(di.isPair(o)){if(o.key===t||o.key===r)return o;if(di.isScalar(o.key)&&o.key.value===r)return o}return}class CD extends AY.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(di.MAP,e);this.items=[]}static from(e,t,r){let{keepUndefined:o,replacer:n}=r,i=new this(e),s=(a,c)=>{if(typeof n==="function")c=n.call(t,a,c);else if(Array.isArray(n)&&!n.includes(a))return;if(c!==void 0||o)i.items.push(bh.createPair(a,c,r))};if(t instanceof Map)for(let[a,c]of t)s(a,c);else if(t&&typeof t==="object")for(let a of Object.keys(t))s(a,t[a]);if(typeof e.sortMapEntries==="function")i.items.sort(e.sortMapEntries);return i}add(e,t){let r;if(di.isPair(e))r=e;else if(!e||typeof e!=="object"||!("key"in e))r=new bh.Pair(e,e?.value);else r=new bh.Pair(e.key,e.value);let o=Lu(this.items,r.key),n=this.schema?.sortMapEntries;if(o){if(!t)throw Error(`Key ${r.key} already set`);if(di.isScalar(o.value)&&TY.isScalarValue(r.value))o.value.value=r.value;else o.value=r.value}else if(n){let i=this.items.findIndex((s)=>n(r,s)<0);if(i===-1)this.items.push(r);else this.items.splice(i,0,r)}else this.items.push(r)}delete(e){let t=Lu(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let o=Lu(this.items,e)?.value;return(!t&&di.isScalar(o)?o.value:o)??void 0}has(e){return!!Lu(this.items,e)}set(e,t){this.add(new bh.Pair(e,t),!0)}toJSON(e,t,r){let o=r?new r:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(o);for(let n of this.items)kY.addPairToJSMap(t,o,n);return o}toString(e,t,r){if(!e)return JSON.stringify(this);for(let o of this.items)if(!di.isPair(o))throw Error(`Map items must all be pairs; found ${JSON.stringify(o)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return IY.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}$Y.YAMLMap=CD;$Y.findPair=Lu});var uc=ge(function(zY){var CY=Me(),PD=fi(),PY={collection:"map",default:!0,nodeClass:PD.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!CY.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,r)=>PD.YAMLMap.from(e,t,r)};zY.map=PY});var pi=ge(function(UY){var DY=Ou(),LY=WE(),BY=sh(),vh=Me(),jY=Et(),ZY=ai();class zD extends BY.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(vh.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=Sh(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let r=Sh(e);if(typeof r!=="number")return;let o=this.items[r];return!t&&vh.isScalar(o)?o.value:o}has(e){let t=Sh(e);return typeof t==="number"&&t<this.items.length}set(e,t){let r=Sh(e);if(typeof r!=="number")throw Error(`Expected a valid index, not ${e}.`);let o=this.items[r];if(vh.isScalar(o)&&jY.isScalarValue(t))o.value=t;else this.items[r]=t}toJSON(e,t){let r=[];if(t?.onCreate)t.onCreate(r);let o=0;for(let n of this.items)r.push(ZY.toJS(n,String(o++),t));return r}toString(e,t,r){if(!e)return JSON.stringify(this);return LY.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t})}static from(e,t,r){let{replacer:o}=r,n=new this(e);if(t&&Symbol.iterator in Object(t)){let i=0;for(let s of t){if(typeof o==="function"){let a=t instanceof Set?s:String(i++);s=o.call(t,a,s)}n.items.push(DY.createNode(s,void 0,r))}}return n}}function Sh(e){let t=vh.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}UY.YAMLSeq=zD});var dc=ge(function(JY){var MY=Me(),ND=pi(),FY={collection:"seq",default:!0,nodeClass:ND.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!MY.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,r)=>ND.YAMLSeq.from(e,t,r)};JY.seq=FY});var Bu=ge(function(WY){var HY=zu(),VY={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,r,o){return t=Object.assign({actualString:!0},t),HY.stringifyString(e,t,r,o)}};WY.string=VY});var wh=ge(function(QY){var DD=Et(),LD={identify:(e)=>e==null,createNode:()=>new DD.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new DD.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&LD.test.test(e)?e:t.options.nullStr};QY.nullTag=LD});var GE=ge(function(eX){var XY=Et(),BD={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new XY.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&BD.test.test(e)){let o=e[0]==="t"||e[0]==="T";if(t===o)return e}return t?r.options.trueStr:r.options.falseStr}};eX.boolTag=BD});var fc=ge(function(nX){function rX({format:e,minFractionDigits:t,tag:r,value:o}){if(typeof o==="bigint")return String(o);let n=typeof o==="number"?o:Number(o);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let i=Object.is(o,-0)?"-0":JSON.stringify(o);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(i)&&!i.includes("e")){let s=i.indexOf(".");if(s<0)s=i.length,i+=".";let a=t-(i.length-s-1);while(a-- >0)i+="0"}return i}nX.stringifyNumber=rX});var YE=ge(function(lX){var iX=Et(),QE=fc(),sX={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:QE.stringifyNumber},aX={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():QE.stringifyNumber(e)}},cX={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new iX.Scalar(parseFloat(e)),r=e.indexOf(".");if(r!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-r-1;return t},stringify:QE.stringifyNumber};lX.float=cX;lX.floatExp=aX;lX.floatNaN=sX});var eI=ge(function(gX){var jD=fc(),xh=(e)=>typeof e==="bigint"||Number.isInteger(e),XE=(e,t,r,{intAsBigInt:o})=>o?BigInt(e):parseInt(e.substring(t),r);function ZD(e,t,r){let{value:o}=e;if(xh(o)&&o>=0)return r+o.toString(t);return jD.stringifyNumber(e)}var pX={identify:(e)=>xh(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>XE(e,2,8,r),stringify:(e)=>ZD(e,8,"0o")},mX={identify:xh,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>XE(e,0,10,r),stringify:jD.stringifyNumber},hX={identify:(e)=>xh(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>XE(e,2,16,r),stringify:(e)=>ZD(e,16,"0x")};gX.int=mX;gX.intHex=hX;gX.intOct=pX});var UD=ge(function(kX){var vX=uc(),wX=wh(),xX=dc(),_X=Bu(),EX=GE(),tI=YE(),rI=eI(),IX=[vX.map,xX.seq,_X.string,wX.nullTag,EX.boolTag,rI.intOct,rI.int,rI.intHex,tI.floatNaN,tI.floatExp,tI.float];kX.schema=IX});var MD=ge(function(zX){var TX=Et(),$X=uc(),RX=dc();function qD(e){return typeof e==="bigint"||Number.isInteger(e)}var _h=({value:e})=>JSON.stringify(e),OX=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:_h},{identify:(e)=>e==null,createNode:()=>new TX.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:_h},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:_h},{identify:qD,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>qD(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:_h}],CX={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},PX=[$X.map,RX.seq].concat(OX,CX);zX.schema=PX});var oI=ge(function(BX){var ju=Zr("buffer"),nI=Et(),DX=zu(),LX={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof ju.Buffer==="function")return ju.Buffer.from(e,"base64");else if(typeof atob==="function"){let r=atob(e.replace(/[\n\r]/g,"")),o=new Uint8Array(r.length);for(let n=0;n<r.length;++n)o[n]=r.charCodeAt(n);return o}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:r},o,n,i){if(!r)return"";let s=r,a;if(typeof ju.Buffer==="function")a=s instanceof ju.Buffer?s.toString("base64"):ju.Buffer.from(s.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let u=0;u<s.length;++u)c+=String.fromCharCode(s[u]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=nI.Scalar.BLOCK_LITERAL),t!==nI.Scalar.QUOTE_DOUBLE){let c=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),u=Math.ceil(a.length/c),d=Array(u);for(let f=0,m=0;f<u;++f,m+=c)d[f]=a.substr(m,c);a=d.join(t===nI.Scalar.BLOCK_LITERAL?`
296
- `:" ")}return DX.stringifyString({comment:e,type:t,value:a},o,n,i)}};BX.binary=LX});var Ih=ge(function(MX){var Eh=Me(),iI=ui(),ZX=Et(),UX=pi();function FD(e,t){if(Eh.isSeq(e))for(let r=0;r<e.items.length;++r){let o=e.items[r];if(Eh.isPair(o))continue;else if(Eh.isMap(o)){if(o.items.length>1)t("Each pair must have its own sequence indicator");let n=o.items[0]||new iI.Pair(new ZX.Scalar(null));if(o.commentBefore)n.key.commentBefore=n.key.commentBefore?`${o.commentBefore}
295
+ ${n}${h}`}else return`${m}${s}${f.join(" ")}${s}${h}`}}function yh({indent:e,options:{commentString:t}},r,o,n){if(o&&n)o=o.replace(/^\n+/,"");if(o){let i=gh.indentComment(t(o),e);r.push(i.trimStart())}}EY.stringifyCollection=wY});var fi=ge(function(RY){var kY=WE(),AY=VE(),TY=sh(),di=Me(),bh=ui(),$Y=Et();function Lu(e,t){let r=di.isScalar(t)?t.value:t;for(let o of e)if(di.isPair(o)){if(o.key===t||o.key===r)return o;if(di.isScalar(o.key)&&o.key.value===r)return o}return}class CD extends TY.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(di.MAP,e);this.items=[]}static from(e,t,r){let{keepUndefined:o,replacer:n}=r,i=new this(e),s=(a,c)=>{if(typeof n==="function")c=n.call(t,a,c);else if(Array.isArray(n)&&!n.includes(a))return;if(c!==void 0||o)i.items.push(bh.createPair(a,c,r))};if(t instanceof Map)for(let[a,c]of t)s(a,c);else if(t&&typeof t==="object")for(let a of Object.keys(t))s(a,t[a]);if(typeof e.sortMapEntries==="function")i.items.sort(e.sortMapEntries);return i}add(e,t){let r;if(di.isPair(e))r=e;else if(!e||typeof e!=="object"||!("key"in e))r=new bh.Pair(e,e?.value);else r=new bh.Pair(e.key,e.value);let o=Lu(this.items,r.key),n=this.schema?.sortMapEntries;if(o){if(!t)throw Error(`Key ${r.key} already set`);if(di.isScalar(o.value)&&$Y.isScalarValue(r.value))o.value.value=r.value;else o.value=r.value}else if(n){let i=this.items.findIndex((s)=>n(r,s)<0);if(i===-1)this.items.push(r);else this.items.splice(i,0,r)}else this.items.push(r)}delete(e){let t=Lu(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let o=Lu(this.items,e)?.value;return(!t&&di.isScalar(o)?o.value:o)??void 0}has(e){return!!Lu(this.items,e)}set(e,t){this.add(new bh.Pair(e,t),!0)}toJSON(e,t,r){let o=r?new r:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(o);for(let n of this.items)AY.addPairToJSMap(t,o,n);return o}toString(e,t,r){if(!e)return JSON.stringify(this);for(let o of this.items)if(!di.isPair(o))throw Error(`Map items must all be pairs; found ${JSON.stringify(o)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return kY.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}RY.YAMLMap=CD;RY.findPair=Lu});var uc=ge(function(NY){var PY=Me(),PD=fi(),zY={collection:"map",default:!0,nodeClass:PD.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!PY.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,r)=>PD.YAMLMap.from(e,t,r)};NY.map=zY});var pi=ge(function(qY){var LY=Ou(),BY=WE(),jY=sh(),vh=Me(),ZY=Et(),UY=ai();class zD extends jY.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(vh.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=Sh(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let r=Sh(e);if(typeof r!=="number")return;let o=this.items[r];return!t&&vh.isScalar(o)?o.value:o}has(e){let t=Sh(e);return typeof t==="number"&&t<this.items.length}set(e,t){let r=Sh(e);if(typeof r!=="number")throw Error(`Expected a valid index, not ${e}.`);let o=this.items[r];if(vh.isScalar(o)&&ZY.isScalarValue(t))o.value=t;else this.items[r]=t}toJSON(e,t){let r=[];if(t?.onCreate)t.onCreate(r);let o=0;for(let n of this.items)r.push(UY.toJS(n,String(o++),t));return r}toString(e,t,r){if(!e)return JSON.stringify(this);return BY.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t})}static from(e,t,r){let{replacer:o}=r,n=new this(e);if(t&&Symbol.iterator in Object(t)){let i=0;for(let s of t){if(typeof o==="function"){let a=t instanceof Set?s:String(i++);s=o.call(t,a,s)}n.items.push(LY.createNode(s,void 0,r))}}return n}}function Sh(e){let t=vh.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}qY.YAMLSeq=zD});var dc=ge(function(KY){var FY=Me(),ND=pi(),JY={collection:"seq",default:!0,nodeClass:ND.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!FY.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,r)=>ND.YAMLSeq.from(e,t,r)};KY.seq=JY});var Bu=ge(function(GY){var VY=zu(),WY={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,r,o){return t=Object.assign({actualString:!0},t),VY.stringifyString(e,t,r,o)}};GY.string=WY});var wh=ge(function(YY){var DD=Et(),LD={identify:(e)=>e==null,createNode:()=>new DD.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new DD.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&LD.test.test(e)?e:t.options.nullStr};YY.nullTag=LD});var GE=ge(function(tX){var eX=Et(),BD={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new eX.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&BD.test.test(e)){let o=e[0]==="t"||e[0]==="T";if(t===o)return e}return t?r.options.trueStr:r.options.falseStr}};tX.boolTag=BD});var fc=ge(function(oX){function nX({format:e,minFractionDigits:t,tag:r,value:o}){if(typeof o==="bigint")return String(o);let n=typeof o==="number"?o:Number(o);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let i=Object.is(o,-0)?"-0":JSON.stringify(o);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(i)&&!i.includes("e")){let s=i.indexOf(".");if(s<0)s=i.length,i+=".";let a=t-(i.length-s-1);while(a-- >0)i+="0"}return i}oX.stringifyNumber=nX});var YE=ge(function(uX){var sX=Et(),QE=fc(),aX={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:QE.stringifyNumber},cX={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():QE.stringifyNumber(e)}},lX={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new sX.Scalar(parseFloat(e)),r=e.indexOf(".");if(r!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-r-1;return t},stringify:QE.stringifyNumber};uX.float=lX;uX.floatExp=cX;uX.floatNaN=aX});var eI=ge(function(yX){var jD=fc(),xh=(e)=>typeof e==="bigint"||Number.isInteger(e),XE=(e,t,r,{intAsBigInt:o})=>o?BigInt(e):parseInt(e.substring(t),r);function ZD(e,t,r){let{value:o}=e;if(xh(o)&&o>=0)return r+o.toString(t);return jD.stringifyNumber(e)}var mX={identify:(e)=>xh(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>XE(e,2,8,r),stringify:(e)=>ZD(e,8,"0o")},hX={identify:xh,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>XE(e,0,10,r),stringify:jD.stringifyNumber},gX={identify:(e)=>xh(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>XE(e,2,16,r),stringify:(e)=>ZD(e,16,"0x")};yX.int=hX;yX.intHex=gX;yX.intOct=mX});var UD=ge(function(AX){var wX=uc(),xX=wh(),_X=dc(),EX=Bu(),IX=GE(),tI=YE(),rI=eI(),kX=[wX.map,_X.seq,EX.string,xX.nullTag,IX.boolTag,rI.intOct,rI.int,rI.intHex,tI.floatNaN,tI.floatExp,tI.float];AX.schema=kX});var MD=ge(function(NX){var $X=Et(),RX=uc(),OX=dc();function qD(e){return typeof e==="bigint"||Number.isInteger(e)}var _h=({value:e})=>JSON.stringify(e),CX=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:_h},{identify:(e)=>e==null,createNode:()=>new $X.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:_h},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:_h},{identify:qD,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>qD(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:_h}],PX={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},zX=[RX.map,OX.seq].concat(CX,PX);NX.schema=zX});var oI=ge(function(jX){var ju=Zr("buffer"),nI=Et(),LX=zu(),BX={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof ju.Buffer==="function")return ju.Buffer.from(e,"base64");else if(typeof atob==="function"){let r=atob(e.replace(/[\n\r]/g,"")),o=new Uint8Array(r.length);for(let n=0;n<r.length;++n)o[n]=r.charCodeAt(n);return o}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:r},o,n,i){if(!r)return"";let s=r,a;if(typeof ju.Buffer==="function")a=s instanceof ju.Buffer?s.toString("base64"):ju.Buffer.from(s.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let u=0;u<s.length;++u)c+=String.fromCharCode(s[u]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=nI.Scalar.BLOCK_LITERAL),t!==nI.Scalar.QUOTE_DOUBLE){let c=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),u=Math.ceil(a.length/c),d=Array(u);for(let f=0,m=0;f<u;++f,m+=c)d[f]=a.substr(m,c);a=d.join(t===nI.Scalar.BLOCK_LITERAL?`
296
+ `:" ")}return LX.stringifyString({comment:e,type:t,value:a},o,n,i)}};jX.binary=BX});var Ih=ge(function(FX){var Eh=Me(),iI=ui(),UX=Et(),qX=pi();function FD(e,t){if(Eh.isSeq(e))for(let r=0;r<e.items.length;++r){let o=e.items[r];if(Eh.isPair(o))continue;else if(Eh.isMap(o)){if(o.items.length>1)t("Each pair must have its own sequence indicator");let n=o.items[0]||new iI.Pair(new UX.Scalar(null));if(o.commentBefore)n.key.commentBefore=n.key.commentBefore?`${o.commentBefore}
297
297
  ${n.key.commentBefore}`:o.commentBefore;if(o.comment){let i=n.value??n.key;i.comment=i.comment?`${o.comment}
298
- ${i.comment}`:o.comment}o=n}e.items[r]=Eh.isPair(o)?o:new iI.Pair(o)}else t("Expected a sequence for this tag");return e}function JD(e,t,r){let{replacer:o}=r,n=new UX.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let i=0;if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof o==="function")s=o.call(t,String(i++),s);let a,c;if(Array.isArray(s))if(s.length===2)a=s[0],c=s[1];else throw TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let u=Object.keys(s);if(u.length===1)a=u[0],c=s[a];else throw TypeError(`Expected tuple with one key, not ${u.length} keys`)}else a=s;n.items.push(iI.createPair(a,c,r))}return n}var qX={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:FD,createNode:JD};MX.createPairs=JD;MX.pairs=qX;MX.resolvePairs=FD});var aI=ge(function(WX){var KD=Me(),sI=ai(),Zu=fi(),HX=pi(),HD=Ih();class ws extends HX.YAMLSeq{constructor(){super();this.add=Zu.YAMLMap.prototype.add.bind(this),this.delete=Zu.YAMLMap.prototype.delete.bind(this),this.get=Zu.YAMLMap.prototype.get.bind(this),this.has=Zu.YAMLMap.prototype.has.bind(this),this.set=Zu.YAMLMap.prototype.set.bind(this),this.tag=ws.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;if(t?.onCreate)t.onCreate(r);for(let o of this.items){let n,i;if(KD.isPair(o))n=sI.toJS(o.key,"",t),i=sI.toJS(o.value,n,t);else n=sI.toJS(o,"",t);if(r.has(n))throw Error("Ordered maps must not include duplicate keys");r.set(n,i)}return r}static from(e,t,r){let o=HD.createPairs(e,t,r),n=new this;return n.items=o.items,n}}ws.tag="tag:yaml.org,2002:omap";var VX={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:ws,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=HD.resolvePairs(e,t),o=[];for(let{key:n}of r.items)if(KD.isScalar(n))if(o.includes(n.value))t(`Ordered maps must not include duplicate keys: ${n.value}`);else o.push(n.value);return Object.assign(new ws,r)},createNode:(e,t,r)=>ws.from(e,t,r)};WX.YAMLOMap=ws;WX.omap=VX});var YD=ge(function(YX){var VD=Et();function WD({value:e,source:t},r){if(t&&(e?GD:QD).test.test(t))return t;return e?r.options.trueStr:r.options.falseStr}var GD={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new VD.Scalar(!0),stringify:WD},QD={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new VD.Scalar(!1),stringify:WD};YX.falseTag=QD;YX.trueTag=GD});var XD=ge(function(iee){var tee=Et(),cI=fc(),ree={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:cI.stringifyNumber},nee={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():cI.stringifyNumber(e)}},oee={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new tee.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let o=e.substring(r+1).replace(/_/g,"");if(o[o.length-1]==="0")t.minFractionDigits=o.length}return t},stringify:cI.stringifyNumber};iee.float=oee;iee.floatExp=nee;iee.floatNaN=ree});var tL=ge(function(pee){var eL=fc(),Uu=(e)=>typeof e==="bigint"||Number.isInteger(e);function kh(e,t,r,{intAsBigInt:o}){let n=e[0];if(n==="-"||n==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),o){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let s=BigInt(e);return n==="-"?BigInt(-1)*s:s}let i=parseInt(e,r);return n==="-"?-1*i:i}function lI(e,t,r){let{value:o}=e;if(Uu(o)){let n=o.toString(t);return o<0?"-"+r+n.substr(1):r+n}return eL.stringifyNumber(e)}var lee={identify:Uu,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>kh(e,2,2,r),stringify:(e)=>lI(e,2,"0b")},uee={identify:Uu,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>kh(e,1,8,r),stringify:(e)=>lI(e,8,"0")},dee={identify:Uu,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>kh(e,0,10,r),stringify:eL.stringifyNumber},fee={identify:Uu,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>kh(e,2,16,r),stringify:(e)=>lI(e,16,"0x")};pee.int=dee;pee.intBin=lee;pee.intHex=fee;pee.intOct=uee});var uI=ge(function(See){var $h=Me(),Ah=ui(),Th=fi();class xs extends Th.YAMLMap{constructor(e){super(e);this.tag=xs.tag}add(e){let t;if($h.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Ah.Pair(e.key,null);else t=new Ah.Pair(e,null);if(!Th.findPair(this.items,t.key))this.items.push(t)}get(e,t){let r=Th.findPair(this.items,e);return!t&&$h.isPair(r)?$h.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=Th.findPair(this.items,e);if(r&&!t)this.items.splice(this.items.indexOf(r),1);else if(!r&&t)this.items.push(new Ah.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);else throw Error("Set items must all have null values")}static from(e,t,r){let{replacer:o}=r,n=new this(e);if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof o==="function")i=o.call(t,i,i);n.items.push(Ah.createPair(i,null,r))}return n}}xs.tag="tag:yaml.org,2002:set";var bee={collection:"map",identify:(e)=>e instanceof Set,nodeClass:xs,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>xs.from(e,t,r),resolve(e,t){if($h.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new xs,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};See.YAMLSet=xs;See.set=bee});var fI=ge(function(Iee){var xee=fc();function dI(e,t){let r=e[0],o=r==="-"||r==="+"?e.substring(1):e,n=(s)=>t?BigInt(s):Number(s),i=o.replace(/_/g,"").split(":").reduce((s,a)=>s*n(60)+n(a),n(0));return r==="-"?n(-1)*i:i}function rL(e){let{value:t}=e,r=(s)=>s;if(typeof t==="bigint")r=(s)=>BigInt(s);else if(isNaN(t)||!isFinite(t))return xee.stringifyNumber(e);let o="";if(t<0)o="-",t*=r(-1);let n=r(60),i=[t%n];if(t<60)i.unshift(0);else if(t=(t-i[0])/n,i.unshift(t%n),t>=60)t=(t-i[0])/n,i.unshift(t);return o+i.map((s)=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var _ee={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>dI(e,r),stringify:rL},Eee={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>dI(e,!1),stringify:rL},nL={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(nL.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,o,n,i,s,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,u=Date.UTC(r,o-1,n,i||0,s||0,a||0,c),d=t[8];if(d&&d!=="Z"){let f=dI(d,!1);if(Math.abs(f)<30)f*=60;u-=60000*f}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Iee.floatTime=Eee;Iee.intTime=_ee;Iee.timestamp=nL});var iL=ge(function(jee){var $ee=uc(),Ree=wh(),Oee=dc(),Cee=Bu(),Pee=oI(),oL=YD(),pI=XD(),Rh=tL(),zee=ph(),Nee=aI(),Dee=Ih(),Lee=uI(),mI=fI(),Bee=[$ee.map,Oee.seq,Cee.string,Ree.nullTag,oL.trueTag,oL.falseTag,Rh.intBin,Rh.intOct,Rh.int,Rh.intHex,pI.floatNaN,pI.floatExp,pI.float,Pee.binary,zee.merge,Nee.omap,Dee.pairs,Lee.set,mI.intTime,mI.floatTime,mI.timestamp];jee.schema=Bee});var hL=ge(function(Vee){var lL=uc(),Uee=wh(),uL=dc(),qee=Bu(),Mee=GE(),hI=YE(),gI=eI(),Fee=UD(),Jee=MD(),dL=oI(),qu=ph(),fL=aI(),pL=Ih(),sL=iL(),mL=uI(),Oh=fI(),aL=new Map([["core",Fee.schema],["failsafe",[lL.map,uL.seq,qee.string]],["json",Jee.schema],["yaml11",sL.schema],["yaml-1.1",sL.schema]]),cL={binary:dL.binary,bool:Mee.boolTag,float:hI.float,floatExp:hI.floatExp,floatNaN:hI.floatNaN,floatTime:Oh.floatTime,int:gI.int,intHex:gI.intHex,intOct:gI.intOct,intTime:Oh.intTime,map:lL.map,merge:qu.merge,null:Uee.nullTag,omap:fL.omap,pairs:pL.pairs,seq:uL.seq,set:mL.set,timestamp:Oh.timestamp},Kee={"tag:yaml.org,2002:binary":dL.binary,"tag:yaml.org,2002:merge":qu.merge,"tag:yaml.org,2002:omap":fL.omap,"tag:yaml.org,2002:pairs":pL.pairs,"tag:yaml.org,2002:set":mL.set,"tag:yaml.org,2002:timestamp":Oh.timestamp};function Hee(e,t,r){let o=aL.get(t);if(o&&!e)return r&&!o.includes(qu.merge)?o.concat(qu.merge):o.slice();let n=o;if(!n)if(Array.isArray(e))n=[];else{let i=Array.from(aL.keys()).filter((s)=>s!=="yaml11").map((s)=>JSON.stringify(s)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${i} or define customTags array`)}if(Array.isArray(e))for(let i of e)n=n.concat(i);else if(typeof e==="function")n=e(n.slice());if(r)n=n.concat(qu.merge);return n.reduce((i,s)=>{let a=typeof s==="string"?cL[s]:s;if(!a){let c=JSON.stringify(s),u=Object.keys(cL).map((d)=>JSON.stringify(d)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${u}`)}if(!i.includes(a))i.push(a);return i},[])}Vee.coreKnownTags=Kee;Vee.getTags=Hee});var SI=ge(function(tte){var yI=Me(),Qee=uc(),Yee=dc(),Xee=Bu(),Ch=hL(),ete=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class bI{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:o,schema:n,sortMapEntries:i,toStringDefaults:s}){this.compat=Array.isArray(e)?Ch.getTags(e,"compat"):e?Ch.getTags(null,e):null,this.name=typeof n==="string"&&n||"core",this.knownTags=o?Ch.coreKnownTags:{},this.tags=Ch.getTags(t,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,yI.MAP,{value:Qee.map}),Object.defineProperty(this,yI.SCALAR,{value:Xee.string}),Object.defineProperty(this,yI.SEQ,{value:Yee.seq}),this.sortMapEntries=typeof i==="function"?i:i===!0?ete:null}clone(){let e=Object.create(bI.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}tte.Schema=bI});var gL=ge(function(ite){var nte=Me(),vI=Nu(),Mu=Cu();function ote(e,t){let r=[],o=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)r.push(c),o=!0;else if(e.directives.docStart)o=!0}if(o)r.push("---");let n=vI.createStringifyContext(e,t),{commentString:i}=n.options;if(e.commentBefore){if(r.length!==1)r.unshift("");let c=i(e.commentBefore);r.unshift(Mu.indentComment(c,""))}let s=!1,a=null;if(e.contents){if(nte.isNode(e.contents)){if(e.contents.spaceBefore&&o)r.push("");if(e.contents.commentBefore){let d=i(e.contents.commentBefore);r.push(Mu.indentComment(d,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>s=!0,u=vI.stringify(e.contents,n,()=>a=null,c);if(a)u+=Mu.lineComment(u,"",i(a));if((u[0]==="|"||u[0]===">")&&r[r.length-1]==="---")r[r.length-1]=`--- ${u}`;else r.push(u)}else r.push(vI.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=i(e.comment);if(c.includes(`
298
+ ${i.comment}`:o.comment}o=n}e.items[r]=Eh.isPair(o)?o:new iI.Pair(o)}else t("Expected a sequence for this tag");return e}function JD(e,t,r){let{replacer:o}=r,n=new qX.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let i=0;if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof o==="function")s=o.call(t,String(i++),s);let a,c;if(Array.isArray(s))if(s.length===2)a=s[0],c=s[1];else throw TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let u=Object.keys(s);if(u.length===1)a=u[0],c=s[a];else throw TypeError(`Expected tuple with one key, not ${u.length} keys`)}else a=s;n.items.push(iI.createPair(a,c,r))}return n}var MX={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:FD,createNode:JD};FX.createPairs=JD;FX.pairs=MX;FX.resolvePairs=FD});var aI=ge(function(GX){var KD=Me(),sI=ai(),Zu=fi(),VX=pi(),HD=Ih();class ws extends VX.YAMLSeq{constructor(){super();this.add=Zu.YAMLMap.prototype.add.bind(this),this.delete=Zu.YAMLMap.prototype.delete.bind(this),this.get=Zu.YAMLMap.prototype.get.bind(this),this.has=Zu.YAMLMap.prototype.has.bind(this),this.set=Zu.YAMLMap.prototype.set.bind(this),this.tag=ws.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;if(t?.onCreate)t.onCreate(r);for(let o of this.items){let n,i;if(KD.isPair(o))n=sI.toJS(o.key,"",t),i=sI.toJS(o.value,n,t);else n=sI.toJS(o,"",t);if(r.has(n))throw Error("Ordered maps must not include duplicate keys");r.set(n,i)}return r}static from(e,t,r){let o=HD.createPairs(e,t,r),n=new this;return n.items=o.items,n}}ws.tag="tag:yaml.org,2002:omap";var WX={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:ws,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=HD.resolvePairs(e,t),o=[];for(let{key:n}of r.items)if(KD.isScalar(n))if(o.includes(n.value))t(`Ordered maps must not include duplicate keys: ${n.value}`);else o.push(n.value);return Object.assign(new ws,r)},createNode:(e,t,r)=>ws.from(e,t,r)};GX.YAMLOMap=ws;GX.omap=WX});var YD=ge(function(XX){var VD=Et();function WD({value:e,source:t},r){if(t&&(e?GD:QD).test.test(t))return t;return e?r.options.trueStr:r.options.falseStr}var GD={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new VD.Scalar(!0),stringify:WD},QD={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new VD.Scalar(!1),stringify:WD};XX.falseTag=QD;XX.trueTag=GD});var XD=ge(function(see){var ree=Et(),cI=fc(),nee={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:cI.stringifyNumber},oee={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():cI.stringifyNumber(e)}},iee={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new ree.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let o=e.substring(r+1).replace(/_/g,"");if(o[o.length-1]==="0")t.minFractionDigits=o.length}return t},stringify:cI.stringifyNumber};see.float=iee;see.floatExp=oee;see.floatNaN=nee});var tL=ge(function(mee){var eL=fc(),Uu=(e)=>typeof e==="bigint"||Number.isInteger(e);function kh(e,t,r,{intAsBigInt:o}){let n=e[0];if(n==="-"||n==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),o){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let s=BigInt(e);return n==="-"?BigInt(-1)*s:s}let i=parseInt(e,r);return n==="-"?-1*i:i}function lI(e,t,r){let{value:o}=e;if(Uu(o)){let n=o.toString(t);return o<0?"-"+r+n.substr(1):r+n}return eL.stringifyNumber(e)}var uee={identify:Uu,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>kh(e,2,2,r),stringify:(e)=>lI(e,2,"0b")},dee={identify:Uu,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>kh(e,1,8,r),stringify:(e)=>lI(e,8,"0")},fee={identify:Uu,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>kh(e,0,10,r),stringify:eL.stringifyNumber},pee={identify:Uu,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>kh(e,2,16,r),stringify:(e)=>lI(e,16,"0x")};mee.int=fee;mee.intBin=uee;mee.intHex=pee;mee.intOct=dee});var uI=ge(function(vee){var $h=Me(),Ah=ui(),Th=fi();class xs extends Th.YAMLMap{constructor(e){super(e);this.tag=xs.tag}add(e){let t;if($h.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Ah.Pair(e.key,null);else t=new Ah.Pair(e,null);if(!Th.findPair(this.items,t.key))this.items.push(t)}get(e,t){let r=Th.findPair(this.items,e);return!t&&$h.isPair(r)?$h.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=Th.findPair(this.items,e);if(r&&!t)this.items.splice(this.items.indexOf(r),1);else if(!r&&t)this.items.push(new Ah.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);else throw Error("Set items must all have null values")}static from(e,t,r){let{replacer:o}=r,n=new this(e);if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof o==="function")i=o.call(t,i,i);n.items.push(Ah.createPair(i,null,r))}return n}}xs.tag="tag:yaml.org,2002:set";var See={collection:"map",identify:(e)=>e instanceof Set,nodeClass:xs,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>xs.from(e,t,r),resolve(e,t){if($h.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new xs,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};vee.YAMLSet=xs;vee.set=See});var fI=ge(function(kee){var _ee=fc();function dI(e,t){let r=e[0],o=r==="-"||r==="+"?e.substring(1):e,n=(s)=>t?BigInt(s):Number(s),i=o.replace(/_/g,"").split(":").reduce((s,a)=>s*n(60)+n(a),n(0));return r==="-"?n(-1)*i:i}function rL(e){let{value:t}=e,r=(s)=>s;if(typeof t==="bigint")r=(s)=>BigInt(s);else if(isNaN(t)||!isFinite(t))return _ee.stringifyNumber(e);let o="";if(t<0)o="-",t*=r(-1);let n=r(60),i=[t%n];if(t<60)i.unshift(0);else if(t=(t-i[0])/n,i.unshift(t%n),t>=60)t=(t-i[0])/n,i.unshift(t);return o+i.map((s)=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Eee={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>dI(e,r),stringify:rL},Iee={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>dI(e,!1),stringify:rL},nL={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(nL.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,o,n,i,s,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,u=Date.UTC(r,o-1,n,i||0,s||0,a||0,c),d=t[8];if(d&&d!=="Z"){let f=dI(d,!1);if(Math.abs(f)<30)f*=60;u-=60000*f}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};kee.floatTime=Iee;kee.intTime=Eee;kee.timestamp=nL});var iL=ge(function(Zee){var Ree=uc(),Oee=wh(),Cee=dc(),Pee=Bu(),zee=oI(),oL=YD(),pI=XD(),Rh=tL(),Nee=ph(),Dee=aI(),Lee=Ih(),Bee=uI(),mI=fI(),jee=[Ree.map,Cee.seq,Pee.string,Oee.nullTag,oL.trueTag,oL.falseTag,Rh.intBin,Rh.intOct,Rh.int,Rh.intHex,pI.floatNaN,pI.floatExp,pI.float,zee.binary,Nee.merge,Dee.omap,Lee.pairs,Bee.set,mI.intTime,mI.floatTime,mI.timestamp];Zee.schema=jee});var hL=ge(function(Wee){var lL=uc(),qee=wh(),uL=dc(),Mee=Bu(),Fee=GE(),hI=YE(),gI=eI(),Jee=UD(),Kee=MD(),dL=oI(),qu=ph(),fL=aI(),pL=Ih(),sL=iL(),mL=uI(),Oh=fI(),aL=new Map([["core",Jee.schema],["failsafe",[lL.map,uL.seq,Mee.string]],["json",Kee.schema],["yaml11",sL.schema],["yaml-1.1",sL.schema]]),cL={binary:dL.binary,bool:Fee.boolTag,float:hI.float,floatExp:hI.floatExp,floatNaN:hI.floatNaN,floatTime:Oh.floatTime,int:gI.int,intHex:gI.intHex,intOct:gI.intOct,intTime:Oh.intTime,map:lL.map,merge:qu.merge,null:qee.nullTag,omap:fL.omap,pairs:pL.pairs,seq:uL.seq,set:mL.set,timestamp:Oh.timestamp},Hee={"tag:yaml.org,2002:binary":dL.binary,"tag:yaml.org,2002:merge":qu.merge,"tag:yaml.org,2002:omap":fL.omap,"tag:yaml.org,2002:pairs":pL.pairs,"tag:yaml.org,2002:set":mL.set,"tag:yaml.org,2002:timestamp":Oh.timestamp};function Vee(e,t,r){let o=aL.get(t);if(o&&!e)return r&&!o.includes(qu.merge)?o.concat(qu.merge):o.slice();let n=o;if(!n)if(Array.isArray(e))n=[];else{let i=Array.from(aL.keys()).filter((s)=>s!=="yaml11").map((s)=>JSON.stringify(s)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${i} or define customTags array`)}if(Array.isArray(e))for(let i of e)n=n.concat(i);else if(typeof e==="function")n=e(n.slice());if(r)n=n.concat(qu.merge);return n.reduce((i,s)=>{let a=typeof s==="string"?cL[s]:s;if(!a){let c=JSON.stringify(s),u=Object.keys(cL).map((d)=>JSON.stringify(d)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${u}`)}if(!i.includes(a))i.push(a);return i},[])}Wee.coreKnownTags=Hee;Wee.getTags=Vee});var SI=ge(function(rte){var yI=Me(),Yee=uc(),Xee=dc(),ete=Bu(),Ch=hL(),tte=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class bI{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:o,schema:n,sortMapEntries:i,toStringDefaults:s}){this.compat=Array.isArray(e)?Ch.getTags(e,"compat"):e?Ch.getTags(null,e):null,this.name=typeof n==="string"&&n||"core",this.knownTags=o?Ch.coreKnownTags:{},this.tags=Ch.getTags(t,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,yI.MAP,{value:Yee.map}),Object.defineProperty(this,yI.SCALAR,{value:ete.string}),Object.defineProperty(this,yI.SEQ,{value:Xee.seq}),this.sortMapEntries=typeof i==="function"?i:i===!0?tte:null}clone(){let e=Object.create(bI.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}rte.Schema=bI});var gL=ge(function(ste){var ote=Me(),vI=Nu(),Mu=Cu();function ite(e,t){let r=[],o=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)r.push(c),o=!0;else if(e.directives.docStart)o=!0}if(o)r.push("---");let n=vI.createStringifyContext(e,t),{commentString:i}=n.options;if(e.commentBefore){if(r.length!==1)r.unshift("");let c=i(e.commentBefore);r.unshift(Mu.indentComment(c,""))}let s=!1,a=null;if(e.contents){if(ote.isNode(e.contents)){if(e.contents.spaceBefore&&o)r.push("");if(e.contents.commentBefore){let d=i(e.contents.commentBefore);r.push(Mu.indentComment(d,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>s=!0,u=vI.stringify(e.contents,n,()=>a=null,c);if(a)u+=Mu.lineComment(u,"",i(a));if((u[0]==="|"||u[0]===">")&&r[r.length-1]==="---")r[r.length-1]=`--- ${u}`;else r.push(u)}else r.push(vI.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=i(e.comment);if(c.includes(`
299
299
  `))r.push("..."),r.push(Mu.indentComment(c,""));else r.push(`... ${c}`)}else r.push("...");else{let c=e.comment;if(c&&s)c=c.replace(/^\n+/,"");if(c){if((!s||a)&&r[r.length-1]!=="")r.push("");r.push(Mu.indentComment(i(c),""))}}return r.join(`
300
300
  `)+`
301
- `}ite.stringifyDocument=ote});var Fu=ge(function(mte){var ate=Ru(),pc=sh(),Jr=Me(),cte=ui(),lte=ai(),ute=SI(),dte=gL(),wI=nh(),fte=ZE(),pte=Ou(),xI=jE();class _I{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Jr.NODE_TYPE,{value:Jr.DOC});let o=null;if(typeof t==="function"||Array.isArray(t))o=t;else if(r===void 0&&t)r=t,t=void 0;let n=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=n;let{version:i}=n;if(r?._directives){if(this.directives=r._directives.atDocument(),this.directives.yaml.explicit)i=this.directives.yaml.version}else this.directives=new xI.Directives({version:i});this.setSchema(i,r),this.contents=e===void 0?null:this.createNode(e,o,r)}clone(){let e=Object.create(_I.prototype,{[Jr.NODE_TYPE]:{value:Jr.DOC}});if(e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives)e.directives=this.directives.clone();if(e.schema=this.schema.clone(),e.contents=Jr.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(mc(this.contents))this.contents.add(e)}addIn(e,t){if(mc(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=wI.anchorNames(this);e.anchor=!t||r.has(t)?wI.findNewAnchor(t||"a",r):t}return new ate.Alias(e.anchor)}createNode(e,t,r){let o=void 0;if(typeof t==="function")e=t.call({"":e},"",e),o=t;else if(Array.isArray(t)){let y=(x)=>typeof x==="number"||x instanceof String||x instanceof Number,S=t.filter(y).map(String);if(S.length>0)t=t.concat(S);o=t}else if(r===void 0&&t)r=t,t=void 0;let{aliasDuplicateObjects:n,anchorPrefix:i,flow:s,keepUndefined:a,onTagObj:c,tag:u}=r??{},{onAnchor:d,setAnchors:f,sourceObjects:m}=wI.createNodeAnchors(this,i||"a"),h={aliasDuplicateObjects:n??!0,keepUndefined:a??!1,onAnchor:d,onTagObj:c,replacer:o,schema:this.schema,sourceObjects:m},b=pte.createNode(e,u,h);if(s&&Jr.isCollection(b))b.flow=!0;return f(),b}createPair(e,t,r={}){let o=this.createNode(e,null,r),n=this.createNode(t,null,r);return new cte.Pair(o,n)}delete(e){return mc(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(pc.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return mc(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Jr.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(pc.isEmptyPath(e))return!t&&Jr.isScalar(this.contents)?this.contents.value:this.contents;return Jr.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Jr.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(pc.isEmptyPath(e))return this.contents!==void 0;return Jr.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=pc.collectionFromPath(this.schema,[e],t);else if(mc(this.contents))this.contents.set(e,t)}setIn(e,t){if(pc.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=pc.collectionFromPath(this.schema,Array.from(e),t);else if(mc(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let r;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new xI.Directives({version:"1.1"});r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new xI.Directives({version:e});r={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;r=null;break;default:{let o=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${o}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new ute.Schema(Object.assign(r,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:r,maxAliasCount:o,onAnchor:n,reviver:i}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof o==="number"?o:100},a=lte.toJS(this.contents,t??"",s);if(typeof n==="function")for(let{count:c,res:u}of s.anchors.values())n(u,c);return typeof i==="function"?fte.applyReviver(i,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return dte.stringifyDocument(this,e)}}function mc(e){if(Jr.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}mte.Document=_I});var Ju=ge(function(yte){class Ph extends Error{constructor(e,t,r,o){super();this.name=e,this.code=r,this.message=o,this.pos=t}}class yL extends Ph{constructor(e,t,r){super("YAMLParseError",e,t,r)}}class bL extends Ph{constructor(e,t,r){super("YAMLWarning",e,t,r)}}var gte=(e,t)=>(r)=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map((a)=>t.linePos(a));let{line:o,col:n}=r.linePos[0];r.message+=` at line ${o}, column ${n}`;let i=n-1,s=e.substring(t.lineStarts[o-1],t.lineStarts[o]).replace(/[\n\r]+$/,"");if(i>=60&&s.length>80){let a=Math.min(i-39,s.length-79);s="\u2026"+s.substring(a),i-=a-1}if(s.length>80)s=s.substring(0,79)+"\u2026";if(o>1&&/^ *$/.test(s.substring(0,i))){let a=e.substring(t.lineStarts[o-2],t.lineStarts[o-1]);if(a.length>80)a=a.substring(0,79)+`\u2026
301
+ `}ste.stringifyDocument=ite});var Fu=ge(function(hte){var cte=Ru(),pc=sh(),Jr=Me(),lte=ui(),ute=ai(),dte=SI(),fte=gL(),wI=nh(),pte=ZE(),mte=Ou(),xI=jE();class _I{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Jr.NODE_TYPE,{value:Jr.DOC});let o=null;if(typeof t==="function"||Array.isArray(t))o=t;else if(r===void 0&&t)r=t,t=void 0;let n=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=n;let{version:i}=n;if(r?._directives){if(this.directives=r._directives.atDocument(),this.directives.yaml.explicit)i=this.directives.yaml.version}else this.directives=new xI.Directives({version:i});this.setSchema(i,r),this.contents=e===void 0?null:this.createNode(e,o,r)}clone(){let e=Object.create(_I.prototype,{[Jr.NODE_TYPE]:{value:Jr.DOC}});if(e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives)e.directives=this.directives.clone();if(e.schema=this.schema.clone(),e.contents=Jr.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(mc(this.contents))this.contents.add(e)}addIn(e,t){if(mc(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=wI.anchorNames(this);e.anchor=!t||r.has(t)?wI.findNewAnchor(t||"a",r):t}return new cte.Alias(e.anchor)}createNode(e,t,r){let o=void 0;if(typeof t==="function")e=t.call({"":e},"",e),o=t;else if(Array.isArray(t)){let y=(x)=>typeof x==="number"||x instanceof String||x instanceof Number,S=t.filter(y).map(String);if(S.length>0)t=t.concat(S);o=t}else if(r===void 0&&t)r=t,t=void 0;let{aliasDuplicateObjects:n,anchorPrefix:i,flow:s,keepUndefined:a,onTagObj:c,tag:u}=r??{},{onAnchor:d,setAnchors:f,sourceObjects:m}=wI.createNodeAnchors(this,i||"a"),h={aliasDuplicateObjects:n??!0,keepUndefined:a??!1,onAnchor:d,onTagObj:c,replacer:o,schema:this.schema,sourceObjects:m},b=mte.createNode(e,u,h);if(s&&Jr.isCollection(b))b.flow=!0;return f(),b}createPair(e,t,r={}){let o=this.createNode(e,null,r),n=this.createNode(t,null,r);return new lte.Pair(o,n)}delete(e){return mc(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(pc.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return mc(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Jr.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(pc.isEmptyPath(e))return!t&&Jr.isScalar(this.contents)?this.contents.value:this.contents;return Jr.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Jr.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(pc.isEmptyPath(e))return this.contents!==void 0;return Jr.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=pc.collectionFromPath(this.schema,[e],t);else if(mc(this.contents))this.contents.set(e,t)}setIn(e,t){if(pc.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=pc.collectionFromPath(this.schema,Array.from(e),t);else if(mc(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let r;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new xI.Directives({version:"1.1"});r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new xI.Directives({version:e});r={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;r=null;break;default:{let o=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${o}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new dte.Schema(Object.assign(r,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:r,maxAliasCount:o,onAnchor:n,reviver:i}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof o==="number"?o:100},a=ute.toJS(this.contents,t??"",s);if(typeof n==="function")for(let{count:c,res:u}of s.anchors.values())n(u,c);return typeof i==="function"?pte.applyReviver(i,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return fte.stringifyDocument(this,e)}}function mc(e){if(Jr.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}hte.Document=_I});var Ju=ge(function(bte){class Ph extends Error{constructor(e,t,r,o){super();this.name=e,this.code=r,this.message=o,this.pos=t}}class yL extends Ph{constructor(e,t,r){super("YAMLParseError",e,t,r)}}class bL extends Ph{constructor(e,t,r){super("YAMLWarning",e,t,r)}}var yte=(e,t)=>(r)=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map((a)=>t.linePos(a));let{line:o,col:n}=r.linePos[0];r.message+=` at line ${o}, column ${n}`;let i=n-1,s=e.substring(t.lineStarts[o-1],t.lineStarts[o]).replace(/[\n\r]+$/,"");if(i>=60&&s.length>80){let a=Math.min(i-39,s.length-79);s="\u2026"+s.substring(a),i-=a-1}if(s.length>80)s=s.substring(0,79)+"\u2026";if(o>1&&/^ *$/.test(s.substring(0,i))){let a=e.substring(t.lineStarts[o-2],t.lineStarts[o-1]);if(a.length>80)a=a.substring(0,79)+`\u2026
302
302
  `;s=a+s}if(/[^ ]/.test(s)){let a=1,c=r.linePos[1];if(c?.line===o&&c.col>n)a=Math.max(1,Math.min(c.col-n,80-i));let u=" ".repeat(i)+"^".repeat(a);r.message+=`:
303
303
 
304
304
  ${s}
305
305
  ${u}
306
- `}};yte.YAMLError=Ph;yte.YAMLParseError=yL;yte.YAMLWarning=bL;yte.prettifyError=gte});var Ku=ge(function(_te){function xte(e,{flow:t,indicator:r,next:o,offset:n,onError:i,parentIndent:s,startOnNewline:a}){let c=!1,u=a,d=a,f="",m="",h=!1,b=!1,y=null,S=null,x=null,_=null,A=null,O=null,L=null;for(let P of e){if(b){if(P.type!=="space"&&P.type!=="newline"&&P.type!=="comma")i(P.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");b=!1}if(y){if(u&&P.type!=="comment"&&P.type!=="newline")i(y,"TAB_AS_INDENT","Tabs are not allowed as indentation");y=null}switch(P.type){case"space":if(!t&&(r!=="doc-start"||o?.type!=="flow-collection")&&P.source.includes("\t"))y=P;d=!0;break;case"comment":{if(!d)i(P,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let W=P.source.substring(1)||" ";if(!f)f=W;else f+=m+W;m="",u=!1;break}case"newline":if(u){if(f)f+=P.source;else if(!O||r!=="seq-item-ind")c=!0}else m+=P.source;if(u=!0,h=!0,S||x)_=P;d=!0;break;case"anchor":if(S)i(P,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(P.source.endsWith(":"))i(P.offset+P.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);S=P,L??(L=P.offset),u=!1,d=!1,b=!0;break;case"tag":{if(x)i(P,"MULTIPLE_TAGS","A node can have at most one tag");x=P,L??(L=P.offset),u=!1,d=!1,b=!0;break}case r:if(S||x)i(P,"BAD_PROP_ORDER",`Anchors and tags must be after the ${P.source} indicator`);if(O)i(P,"UNEXPECTED_TOKEN",`Unexpected ${P.source} in ${t??"collection"}`);O=P,u=r==="seq-item-ind"||r==="explicit-key-ind",d=!1;break;case"comma":if(t){if(A)i(P,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);A=P,u=!1,d=!1;break}default:i(P,"UNEXPECTED_TOKEN",`Unexpected ${P.type} token`),u=!1,d=!1}}let z=e[e.length-1],K=z?z.offset+z.source.length:n;if(b&&o&&o.type!=="space"&&o.type!=="newline"&&o.type!=="comma"&&(o.type!=="scalar"||o.source!==""))i(o.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(y&&(u&&y.indent<=s||o?.type==="block-map"||o?.type==="block-seq"))i(y,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:A,found:O,spaceBefore:c,comment:f,hasNewline:h,anchor:S,tag:x,newlineAfterProp:_,end:K,start:L??K}}_te.resolveProps=xte});var zh=ge(function(Ite){function EI(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
307
- `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(EI(t.key)||EI(t.value))return!0}return!1;default:return!0}}Ite.containsNewline=EI});var II=ge(function($te){var Ate=zh();function Tte(e,t,r){if(t?.type==="flow-collection"){let o=t.end[0];if(o.indent===e&&(o.source==="]"||o.source==="}")&&Ate.containsNewline(t))r(o,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}$te.flowIndentCheck=Tte});var kI=ge(function(Cte){var SL=Me();function Ote(e,t,r){let{uniqueKeys:o}=e.options;if(o===!1)return!1;let n=typeof o==="function"?o:(i,s)=>i===s||SL.isScalar(i)&&SL.isScalar(s)&&i.value===s.value;return t.some((i)=>n(i.key,r))}Cte.mapIncludes=Ote});var EL=ge(function(Bte){var vL=ui(),zte=fi(),wL=Ku(),Nte=zh(),xL=II(),Dte=kI(),_L="All mapping items must start at the same column";function Lte({composeNode:e,composeEmptyNode:t},r,o,n,i){let a=new(i?.nodeClass??zte.YAMLMap)(r.schema);if(r.atRoot)r.atRoot=!1;let c=o.offset,u=null;for(let d of o.items){let{start:f,key:m,sep:h,value:b}=d,y=wL.resolveProps(f,{indicator:"explicit-key-ind",next:m??h?.[0],offset:c,onError:n,parentIndent:o.indent,startOnNewline:!0}),S=!y.found;if(S){if(m){if(m.type==="block-seq")n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in m&&m.indent!==o.indent)n(c,"BAD_INDENT",_L)}if(!y.anchor&&!y.tag&&!h){if(u=y.end,y.comment)if(a.comment)a.comment+=`
308
- `+y.comment;else a.comment=y.comment;continue}if(y.newlineAfterProp||Nte.containsNewline(m))n(m??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(y.found?.indent!==o.indent)n(c,"BAD_INDENT",_L);r.atKey=!0;let x=y.end,_=m?e(r,m,y,n):t(r,x,f,null,y,n);if(r.schema.compat)xL.flowIndentCheck(o.indent,m,n);if(r.atKey=!1,Dte.mapIncludes(r,a.items,_))n(x,"DUPLICATE_KEY","Map keys must be unique");let A=wL.resolveProps(h??[],{indicator:"map-value-ind",next:b,offset:_.range[2],onError:n,parentIndent:o.indent,startOnNewline:!m||m.type==="block-scalar"});if(c=A.end,A.found){if(S){if(b?.type==="block-map"&&!A.hasNewline)n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(r.options.strict&&y.start<A.found.offset-1024)n(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let O=b?e(r,b,A,n):t(r,c,h,null,A,n);if(r.schema.compat)xL.flowIndentCheck(o.indent,b,n);c=O.range[2];let L=new vL.Pair(_,O);if(r.options.keepSourceTokens)L.srcToken=d;a.items.push(L)}else{if(S)n(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(A.comment)if(_.comment)_.comment+=`
309
- `+A.comment;else _.comment=A.comment;let O=new vL.Pair(_);if(r.options.keepSourceTokens)O.srcToken=d;a.items.push(O)}}if(u&&u<c)n(u,"IMPOSSIBLE","Map comment with trailing content");return a.range=[o.offset,c,u??c],a}Bte.resolveBlockMap=Lte});var IL=ge(function(Fte){var Zte=pi(),Ute=Ku(),qte=II();function Mte({composeNode:e,composeEmptyNode:t},r,o,n,i){let a=new(i?.nodeClass??Zte.YAMLSeq)(r.schema);if(r.atRoot)r.atRoot=!1;if(r.atKey)r.atKey=!1;let c=o.offset,u=null;for(let{start:d,value:f}of o.items){let m=Ute.resolveProps(d,{indicator:"seq-item-ind",next:f,offset:c,onError:n,parentIndent:o.indent,startOnNewline:!0});if(!m.found)if(m.anchor||m.tag||f)if(f?.type==="block-seq")n(m.end,"BAD_INDENT","All sequence items must start at the same column");else n(c,"MISSING_CHAR","Sequence item without - indicator");else{if(u=m.end,m.comment)a.comment=m.comment;continue}let h=f?e(r,f,m,n):t(r,m.end,d,null,m,n);if(r.schema.compat)qte.flowIndentCheck(o.indent,f,n);c=h.range[2],a.items.push(h)}return a.range=[o.offset,c,u??c],a}Fte.resolveBlockSeq=Mte});var hc=ge(function(Hte){function Kte(e,t,r,o){let n="";if(e){let i=!1,s="";for(let a of e){let{source:c,type:u}=a;switch(u){case"space":i=!0;break;case"comment":{if(r&&!i)o(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=c.substring(1)||" ";if(!n)n=d;else n+=s+d;s="";break}case"newline":if(n)s+=c;i=!0;break;default:o(a,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}t+=c.length}}return{comment:n,offset:t}}Hte.resolveEnd=Kte});var TL=ge(function(rre){var Wte=Me(),Gte=ui(),kL=fi(),Qte=pi(),Yte=hc(),AL=Ku(),Xte=zh(),ere=kI(),AI="Block collections are not allowed within flow collections",TI=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function tre({composeNode:e,composeEmptyNode:t},r,o,n,i){let s=o.start.source==="{",a=s?"flow map":"flow sequence",u=new(i?.nodeClass??(s?kL.YAMLMap:Qte.YAMLSeq))(r.schema);u.flow=!0;let d=r.atRoot;if(d)r.atRoot=!1;if(r.atKey)r.atKey=!1;let f=o.offset+o.start.source.length;for(let S=0;S<o.items.length;++S){let x=o.items[S],{start:_,key:A,sep:O,value:L}=x,z=AL.resolveProps(_,{flow:a,indicator:"explicit-key-ind",next:A??O?.[0],offset:f,onError:n,parentIndent:o.indent,startOnNewline:!1});if(!z.found){if(!z.anchor&&!z.tag&&!O&&!L){if(S===0&&z.comma)n(z.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(S<o.items.length-1)n(z.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(z.comment)if(u.comment)u.comment+=`
310
- `+z.comment;else u.comment=z.comment;f=z.end;continue}if(!s&&r.options.strict&&Xte.containsNewline(A))n(A,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(S===0){if(z.comma)n(z.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!z.comma)n(z.start,"MISSING_CHAR",`Missing , between ${a} items`);if(z.comment){let K="";e:for(let P of _)switch(P.type){case"comma":case"space":break;case"comment":K=P.source.substring(1);break e;default:break e}if(K){let P=u.items[u.items.length-1];if(Wte.isPair(P))P=P.value??P.key;if(P.comment)P.comment+=`
306
+ `}};bte.YAMLError=Ph;bte.YAMLParseError=yL;bte.YAMLWarning=bL;bte.prettifyError=yte});var Ku=ge(function(Ete){function _te(e,{flow:t,indicator:r,next:o,offset:n,onError:i,parentIndent:s,startOnNewline:a}){let c=!1,u=a,d=a,f="",m="",h=!1,b=!1,y=null,S=null,x=null,_=null,A=null,O=null,L=null;for(let P of e){if(b){if(P.type!=="space"&&P.type!=="newline"&&P.type!=="comma")i(P.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");b=!1}if(y){if(u&&P.type!=="comment"&&P.type!=="newline")i(y,"TAB_AS_INDENT","Tabs are not allowed as indentation");y=null}switch(P.type){case"space":if(!t&&(r!=="doc-start"||o?.type!=="flow-collection")&&P.source.includes("\t"))y=P;d=!0;break;case"comment":{if(!d)i(P,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let W=P.source.substring(1)||" ";if(!f)f=W;else f+=m+W;m="",u=!1;break}case"newline":if(u){if(f)f+=P.source;else if(!O||r!=="seq-item-ind")c=!0}else m+=P.source;if(u=!0,h=!0,S||x)_=P;d=!0;break;case"anchor":if(S)i(P,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(P.source.endsWith(":"))i(P.offset+P.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);S=P,L??(L=P.offset),u=!1,d=!1,b=!0;break;case"tag":{if(x)i(P,"MULTIPLE_TAGS","A node can have at most one tag");x=P,L??(L=P.offset),u=!1,d=!1,b=!0;break}case r:if(S||x)i(P,"BAD_PROP_ORDER",`Anchors and tags must be after the ${P.source} indicator`);if(O)i(P,"UNEXPECTED_TOKEN",`Unexpected ${P.source} in ${t??"collection"}`);O=P,u=r==="seq-item-ind"||r==="explicit-key-ind",d=!1;break;case"comma":if(t){if(A)i(P,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);A=P,u=!1,d=!1;break}default:i(P,"UNEXPECTED_TOKEN",`Unexpected ${P.type} token`),u=!1,d=!1}}let z=e[e.length-1],K=z?z.offset+z.source.length:n;if(b&&o&&o.type!=="space"&&o.type!=="newline"&&o.type!=="comma"&&(o.type!=="scalar"||o.source!==""))i(o.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(y&&(u&&y.indent<=s||o?.type==="block-map"||o?.type==="block-seq"))i(y,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:A,found:O,spaceBefore:c,comment:f,hasNewline:h,anchor:S,tag:x,newlineAfterProp:_,end:K,start:L??K}}Ete.resolveProps=_te});var zh=ge(function(kte){function EI(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
307
+ `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(EI(t.key)||EI(t.value))return!0}return!1;default:return!0}}kte.containsNewline=EI});var II=ge(function(Rte){var Tte=zh();function $te(e,t,r){if(t?.type==="flow-collection"){let o=t.end[0];if(o.indent===e&&(o.source==="]"||o.source==="}")&&Tte.containsNewline(t))r(o,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Rte.flowIndentCheck=$te});var kI=ge(function(Pte){var SL=Me();function Cte(e,t,r){let{uniqueKeys:o}=e.options;if(o===!1)return!1;let n=typeof o==="function"?o:(i,s)=>i===s||SL.isScalar(i)&&SL.isScalar(s)&&i.value===s.value;return t.some((i)=>n(i.key,r))}Pte.mapIncludes=Cte});var EL=ge(function(jte){var vL=ui(),Nte=fi(),wL=Ku(),Dte=zh(),xL=II(),Lte=kI(),_L="All mapping items must start at the same column";function Bte({composeNode:e,composeEmptyNode:t},r,o,n,i){let a=new(i?.nodeClass??Nte.YAMLMap)(r.schema);if(r.atRoot)r.atRoot=!1;let c=o.offset,u=null;for(let d of o.items){let{start:f,key:m,sep:h,value:b}=d,y=wL.resolveProps(f,{indicator:"explicit-key-ind",next:m??h?.[0],offset:c,onError:n,parentIndent:o.indent,startOnNewline:!0}),S=!y.found;if(S){if(m){if(m.type==="block-seq")n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in m&&m.indent!==o.indent)n(c,"BAD_INDENT",_L)}if(!y.anchor&&!y.tag&&!h){if(u=y.end,y.comment)if(a.comment)a.comment+=`
308
+ `+y.comment;else a.comment=y.comment;continue}if(y.newlineAfterProp||Dte.containsNewline(m))n(m??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(y.found?.indent!==o.indent)n(c,"BAD_INDENT",_L);r.atKey=!0;let x=y.end,_=m?e(r,m,y,n):t(r,x,f,null,y,n);if(r.schema.compat)xL.flowIndentCheck(o.indent,m,n);if(r.atKey=!1,Lte.mapIncludes(r,a.items,_))n(x,"DUPLICATE_KEY","Map keys must be unique");let A=wL.resolveProps(h??[],{indicator:"map-value-ind",next:b,offset:_.range[2],onError:n,parentIndent:o.indent,startOnNewline:!m||m.type==="block-scalar"});if(c=A.end,A.found){if(S){if(b?.type==="block-map"&&!A.hasNewline)n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(r.options.strict&&y.start<A.found.offset-1024)n(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let O=b?e(r,b,A,n):t(r,c,h,null,A,n);if(r.schema.compat)xL.flowIndentCheck(o.indent,b,n);c=O.range[2];let L=new vL.Pair(_,O);if(r.options.keepSourceTokens)L.srcToken=d;a.items.push(L)}else{if(S)n(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(A.comment)if(_.comment)_.comment+=`
309
+ `+A.comment;else _.comment=A.comment;let O=new vL.Pair(_);if(r.options.keepSourceTokens)O.srcToken=d;a.items.push(O)}}if(u&&u<c)n(u,"IMPOSSIBLE","Map comment with trailing content");return a.range=[o.offset,c,u??c],a}jte.resolveBlockMap=Bte});var IL=ge(function(Jte){var Ute=pi(),qte=Ku(),Mte=II();function Fte({composeNode:e,composeEmptyNode:t},r,o,n,i){let a=new(i?.nodeClass??Ute.YAMLSeq)(r.schema);if(r.atRoot)r.atRoot=!1;if(r.atKey)r.atKey=!1;let c=o.offset,u=null;for(let{start:d,value:f}of o.items){let m=qte.resolveProps(d,{indicator:"seq-item-ind",next:f,offset:c,onError:n,parentIndent:o.indent,startOnNewline:!0});if(!m.found)if(m.anchor||m.tag||f)if(f?.type==="block-seq")n(m.end,"BAD_INDENT","All sequence items must start at the same column");else n(c,"MISSING_CHAR","Sequence item without - indicator");else{if(u=m.end,m.comment)a.comment=m.comment;continue}let h=f?e(r,f,m,n):t(r,m.end,d,null,m,n);if(r.schema.compat)Mte.flowIndentCheck(o.indent,f,n);c=h.range[2],a.items.push(h)}return a.range=[o.offset,c,u??c],a}Jte.resolveBlockSeq=Fte});var hc=ge(function(Vte){function Hte(e,t,r,o){let n="";if(e){let i=!1,s="";for(let a of e){let{source:c,type:u}=a;switch(u){case"space":i=!0;break;case"comment":{if(r&&!i)o(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=c.substring(1)||" ";if(!n)n=d;else n+=s+d;s="";break}case"newline":if(n)s+=c;i=!0;break;default:o(a,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}t+=c.length}}return{comment:n,offset:t}}Vte.resolveEnd=Hte});var TL=ge(function(nre){var Gte=Me(),Qte=ui(),kL=fi(),Yte=pi(),Xte=hc(),AL=Ku(),ere=zh(),tre=kI(),AI="Block collections are not allowed within flow collections",TI=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function rre({composeNode:e,composeEmptyNode:t},r,o,n,i){let s=o.start.source==="{",a=s?"flow map":"flow sequence",u=new(i?.nodeClass??(s?kL.YAMLMap:Yte.YAMLSeq))(r.schema);u.flow=!0;let d=r.atRoot;if(d)r.atRoot=!1;if(r.atKey)r.atKey=!1;let f=o.offset+o.start.source.length;for(let S=0;S<o.items.length;++S){let x=o.items[S],{start:_,key:A,sep:O,value:L}=x,z=AL.resolveProps(_,{flow:a,indicator:"explicit-key-ind",next:A??O?.[0],offset:f,onError:n,parentIndent:o.indent,startOnNewline:!1});if(!z.found){if(!z.anchor&&!z.tag&&!O&&!L){if(S===0&&z.comma)n(z.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(S<o.items.length-1)n(z.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(z.comment)if(u.comment)u.comment+=`
310
+ `+z.comment;else u.comment=z.comment;f=z.end;continue}if(!s&&r.options.strict&&ere.containsNewline(A))n(A,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(S===0){if(z.comma)n(z.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!z.comma)n(z.start,"MISSING_CHAR",`Missing , between ${a} items`);if(z.comment){let K="";e:for(let P of _)switch(P.type){case"comma":case"space":break;case"comment":K=P.source.substring(1);break e;default:break e}if(K){let P=u.items[u.items.length-1];if(Gte.isPair(P))P=P.value??P.key;if(P.comment)P.comment+=`
311
311
  `+K;else P.comment=K;z.comment=z.comment.substring(K.length+1)}}}if(!s&&!O&&!z.found){let K=L?e(r,L,z,n):t(r,z.end,O,null,z,n);if(u.items.push(K),f=K.range[2],TI(L))n(K.range,"BLOCK_IN_FLOW",AI)}else{r.atKey=!0;let K=z.end,P=A?e(r,A,z,n):t(r,K,_,null,z,n);if(TI(A))n(P.range,"BLOCK_IN_FLOW",AI);r.atKey=!1;let W=AL.resolveProps(O??[],{flow:a,indicator:"map-value-ind",next:L,offset:P.range[2],onError:n,parentIndent:o.indent,startOnNewline:!1});if(W.found){if(!s&&!z.found&&r.options.strict){if(O)for(let R of O){if(R===W.found)break;if(R.type==="newline"){n(R,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(z.start<W.found.offset-1024)n(W.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(L)if("source"in L&&L.source?.[0]===":")n(L,"MISSING_CHAR",`Missing space after : in ${a}`);else n(W.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let ee=L?e(r,L,W,n):W.found?t(r,W.end,O,null,W,n):null;if(ee){if(TI(L))n(ee.range,"BLOCK_IN_FLOW",AI)}else if(W.comment)if(P.comment)P.comment+=`
312
- `+W.comment;else P.comment=W.comment;let j=new Gte.Pair(P,ee);if(r.options.keepSourceTokens)j.srcToken=x;if(s){let R=u;if(ere.mapIncludes(r,R.items,P))n(K,"DUPLICATE_KEY","Map keys must be unique");R.items.push(j)}else{let R=new kL.YAMLMap(r.schema);R.flow=!0,R.items.push(j);let B=(ee??P).range;R.range=[P.range[0],B[1],B[2]],u.items.push(R)}f=ee?ee.range[2]:W.end}}let m=s?"}":"]",[h,...b]=o.end,y=f;if(h?.source===m)y=h.offset+h.source.length;else{let S=a[0].toUpperCase()+a.substring(1),x=d?`${S} must end with a ${m}`:`${S} in block collection must be sufficiently indented and end with a ${m}`;if(n(f,d?"MISSING_CHAR":"BAD_INDENT",x),h&&h.source.length!==1)b.unshift(h)}if(b.length>0){let S=Yte.resolveEnd(b,y,r.options.strict,n);if(S.comment)if(u.comment)u.comment+=`
313
- `+S.comment;else u.comment=S.comment;u.range=[o.offset,y,S.offset]}else u.range=[o.offset,y,y];return u}rre.resolveFlowCollection=tre});var $L=ge(function(fre){var ore=Me(),ire=Et(),sre=fi(),are=pi(),cre=EL(),lre=IL(),ure=TL();function $I(e,t,r,o,n,i){let s=r.type==="block-map"?cre.resolveBlockMap(e,t,r,o,i):r.type==="block-seq"?lre.resolveBlockSeq(e,t,r,o,i):ure.resolveFlowCollection(e,t,r,o,i),a=s.constructor;if(n==="!"||n===a.tagName)return s.tag=a.tagName,s;if(n)s.tag=n;return s}function dre(e,t,r,o,n){let i=o.tag,s=!i?null:t.directives.tagName(i.source,(m)=>n(i,"TAG_RESOLVE_FAILED",m));if(r.type==="block-seq"){let{anchor:m,newlineAfterProp:h}=o,b=m&&i?m.offset>i.offset?m:i:m??i;if(b&&(!h||h.offset<b.offset))n(b,"MISSING_CHAR","Missing newline after block sequence props")}let a=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!i||!s||s==="!"||s===sre.YAMLMap.tagName&&a==="map"||s===are.YAMLSeq.tagName&&a==="seq")return $I(e,t,r,n,s);let c=t.schema.tags.find((m)=>m.tag===s&&m.collection===a);if(!c){let m=t.schema.knownTags[s];if(m?.collection===a)t.schema.tags.push(Object.assign({},m,{default:!1})),c=m;else{if(m)n(i,"BAD_COLLECTION_TYPE",`${m.tag} used for ${a} collection, but expects ${m.collection??"scalar"}`,!0);else n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0);return $I(e,t,r,n,s)}}let u=$I(e,t,r,n,s,c),d=c.resolve?.(u,(m)=>n(i,"TAG_RESOLVE_FAILED",m),t.options)??u,f=ore.isNode(d)?d:new ire.Scalar(d);if(f.range=u.range,f.tag=s,c?.format)f.format=c.format;return f}fre.composeCollection=dre});var OI=ge(function(yre){var RI=Et();function mre(e,t,r){let o=t.offset,n=hre(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[o,o,o]};let i=n.mode===">"?RI.Scalar.BLOCK_FOLDED:RI.Scalar.BLOCK_LITERAL,s=t.source?gre(t.source):[],a=s.length;for(let y=s.length-1;y>=0;--y){let S=s[y][1];if(S===""||S==="\r")a=y;else break}if(a===0){let y=n.chomp==="+"&&s.length>0?`
312
+ `+W.comment;else P.comment=W.comment;let j=new Qte.Pair(P,ee);if(r.options.keepSourceTokens)j.srcToken=x;if(s){let R=u;if(tre.mapIncludes(r,R.items,P))n(K,"DUPLICATE_KEY","Map keys must be unique");R.items.push(j)}else{let R=new kL.YAMLMap(r.schema);R.flow=!0,R.items.push(j);let B=(ee??P).range;R.range=[P.range[0],B[1],B[2]],u.items.push(R)}f=ee?ee.range[2]:W.end}}let m=s?"}":"]",[h,...b]=o.end,y=f;if(h?.source===m)y=h.offset+h.source.length;else{let S=a[0].toUpperCase()+a.substring(1),x=d?`${S} must end with a ${m}`:`${S} in block collection must be sufficiently indented and end with a ${m}`;if(n(f,d?"MISSING_CHAR":"BAD_INDENT",x),h&&h.source.length!==1)b.unshift(h)}if(b.length>0){let S=Xte.resolveEnd(b,y,r.options.strict,n);if(S.comment)if(u.comment)u.comment+=`
313
+ `+S.comment;else u.comment=S.comment;u.range=[o.offset,y,S.offset]}else u.range=[o.offset,y,y];return u}nre.resolveFlowCollection=rre});var $L=ge(function(pre){var ire=Me(),sre=Et(),are=fi(),cre=pi(),lre=EL(),ure=IL(),dre=TL();function $I(e,t,r,o,n,i){let s=r.type==="block-map"?lre.resolveBlockMap(e,t,r,o,i):r.type==="block-seq"?ure.resolveBlockSeq(e,t,r,o,i):dre.resolveFlowCollection(e,t,r,o,i),a=s.constructor;if(n==="!"||n===a.tagName)return s.tag=a.tagName,s;if(n)s.tag=n;return s}function fre(e,t,r,o,n){let i=o.tag,s=!i?null:t.directives.tagName(i.source,(m)=>n(i,"TAG_RESOLVE_FAILED",m));if(r.type==="block-seq"){let{anchor:m,newlineAfterProp:h}=o,b=m&&i?m.offset>i.offset?m:i:m??i;if(b&&(!h||h.offset<b.offset))n(b,"MISSING_CHAR","Missing newline after block sequence props")}let a=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!i||!s||s==="!"||s===are.YAMLMap.tagName&&a==="map"||s===cre.YAMLSeq.tagName&&a==="seq")return $I(e,t,r,n,s);let c=t.schema.tags.find((m)=>m.tag===s&&m.collection===a);if(!c){let m=t.schema.knownTags[s];if(m?.collection===a)t.schema.tags.push(Object.assign({},m,{default:!1})),c=m;else{if(m)n(i,"BAD_COLLECTION_TYPE",`${m.tag} used for ${a} collection, but expects ${m.collection??"scalar"}`,!0);else n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0);return $I(e,t,r,n,s)}}let u=$I(e,t,r,n,s,c),d=c.resolve?.(u,(m)=>n(i,"TAG_RESOLVE_FAILED",m),t.options)??u,f=ire.isNode(d)?d:new sre.Scalar(d);if(f.range=u.range,f.tag=s,c?.format)f.format=c.format;return f}pre.composeCollection=fre});var OI=ge(function(bre){var RI=Et();function hre(e,t,r){let o=t.offset,n=gre(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[o,o,o]};let i=n.mode===">"?RI.Scalar.BLOCK_FOLDED:RI.Scalar.BLOCK_LITERAL,s=t.source?yre(t.source):[],a=s.length;for(let y=s.length-1;y>=0;--y){let S=s[y][1];if(S===""||S==="\r")a=y;else break}if(a===0){let y=n.chomp==="+"&&s.length>0?`
314
314
  `.repeat(Math.max(1,s.length-1)):"",S=o+n.length;if(t.source)S+=t.source.length;return{value:y,type:i,comment:n.comment,range:[o,S,S]}}let c=t.indent+n.indent,u=t.offset+n.length,d=0;for(let y=0;y<a;++y){let[S,x]=s[y];if(x===""||x==="\r"){if(n.indent===0&&S.length>c)c=S.length}else{if(S.length<c)r(u+S.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(n.indent===0)c=S.length;if(d=y,c===0&&!e.atRoot)r(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=S.length+x.length+1}for(let y=s.length-1;y>=a;--y)if(s[y][0].length>c)a=y+1;let f="",m="",h=!1;for(let y=0;y<d;++y)f+=s[y][0].slice(c)+`
315
315
  `;for(let y=d;y<a;++y){let[S,x]=s[y];u+=S.length+x.length+1;let _=x[x.length-1]==="\r";if(_)x=x.slice(0,-1);if(x&&S.length<c){let O=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(u-x.length-(_?2:1),"BAD_INDENT",O),S=""}if(i===RI.Scalar.BLOCK_LITERAL)f+=m+S.slice(c)+x,m=`
316
316
  `;else if(S.length>c||x[0]==="\t"){if(m===" ")m=`
@@ -325,41 +325,41 @@ ${u}
325
325
  `+s[y][0].slice(c);if(f[f.length-1]!==`
326
326
  `)f+=`
327
327
  `;break;default:f+=`
328
- `}let b=o+n.length+t.source.length;return{value:f,type:i,comment:n.comment,range:[o,b,b]}}function hre({offset:e,props:t},r,o){if(t[0].type!=="block-scalar-header")return o(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],i=n[0],s=0,a="",c=-1;for(let m=1;m<n.length;++m){let h=n[m];if(!a&&(h==="-"||h==="+"))a=h;else{let b=Number(h);if(!s&&b)s=b;else if(c===-1)c=e+m}}if(c!==-1)o(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let u=!1,d="",f=n.length;for(let m=1;m<t.length;++m){let h=t[m];switch(h.type){case"space":u=!0;case"newline":f+=h.source.length;break;case"comment":if(r&&!u)o(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");f+=h.source.length,d=h.source.substring(1);break;case"error":o(h,"UNEXPECTED_TOKEN",h.message),f+=h.source.length;break;default:{let b=`Unexpected token in block scalar header: ${h.type}`;o(h,"UNEXPECTED_TOKEN",b);let y=h.source;if(y&&typeof y==="string")f+=y.length}}}return{mode:i,indent:s,chomp:a,comment:d,length:f}}function gre(e){let t=e.split(/\n( *)/),r=t[0],o=r.match(/^( *)/),i=[o?.[1]?[o[1],r.slice(o[1].length)]:["",r]];for(let s=1;s<t.length;s+=2)i.push([t[s],t[s+1]]);return i}yre.resolveBlockScalar=mre});var PI=ge(function(Are){var CI=Et(),Sre=hc();function vre(e,t,r){let{offset:o,type:n,source:i,end:s}=e,a,c,u=(m,h,b)=>r(o+m,h,b);switch(n){case"scalar":a=CI.Scalar.PLAIN,c=wre(i,u);break;case"single-quoted-scalar":a=CI.Scalar.QUOTE_SINGLE,c=xre(i,u);break;case"double-quoted-scalar":a=CI.Scalar.QUOTE_DOUBLE,c=_re(i,u);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[o,o+i.length,o+i.length]}}let d=o+i.length,f=Sre.resolveEnd(s,d,t,r);return{value:c,type:a,comment:f.comment,range:[o,d,f.offset]}}function wre(e,t){let r="";switch(e[0]){case"\t":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}if(r)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`);return RL(e)}function xre(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return RL(e.slice(1,-1)).replace(/''/g,"'")}function RL(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
328
+ `}let b=o+n.length+t.source.length;return{value:f,type:i,comment:n.comment,range:[o,b,b]}}function gre({offset:e,props:t},r,o){if(t[0].type!=="block-scalar-header")return o(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],i=n[0],s=0,a="",c=-1;for(let m=1;m<n.length;++m){let h=n[m];if(!a&&(h==="-"||h==="+"))a=h;else{let b=Number(h);if(!s&&b)s=b;else if(c===-1)c=e+m}}if(c!==-1)o(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let u=!1,d="",f=n.length;for(let m=1;m<t.length;++m){let h=t[m];switch(h.type){case"space":u=!0;case"newline":f+=h.source.length;break;case"comment":if(r&&!u)o(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");f+=h.source.length,d=h.source.substring(1);break;case"error":o(h,"UNEXPECTED_TOKEN",h.message),f+=h.source.length;break;default:{let b=`Unexpected token in block scalar header: ${h.type}`;o(h,"UNEXPECTED_TOKEN",b);let y=h.source;if(y&&typeof y==="string")f+=y.length}}}return{mode:i,indent:s,chomp:a,comment:d,length:f}}function yre(e){let t=e.split(/\n( *)/),r=t[0],o=r.match(/^( *)/),i=[o?.[1]?[o[1],r.slice(o[1].length)]:["",r]];for(let s=1;s<t.length;s+=2)i.push([t[s],t[s+1]]);return i}bre.resolveBlockScalar=hre});var PI=ge(function(Tre){var CI=Et(),vre=hc();function wre(e,t,r){let{offset:o,type:n,source:i,end:s}=e,a,c,u=(m,h,b)=>r(o+m,h,b);switch(n){case"scalar":a=CI.Scalar.PLAIN,c=xre(i,u);break;case"single-quoted-scalar":a=CI.Scalar.QUOTE_SINGLE,c=_re(i,u);break;case"double-quoted-scalar":a=CI.Scalar.QUOTE_DOUBLE,c=Ere(i,u);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[o,o+i.length,o+i.length]}}let d=o+i.length,f=vre.resolveEnd(s,d,t,r);return{value:c,type:a,comment:f.comment,range:[o,d,f.offset]}}function xre(e,t){let r="";switch(e[0]){case"\t":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}if(r)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`);return RL(e)}function _re(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return RL(e.slice(1,-1)).replace(/''/g,"'")}function RL(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
329
329
  `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
330
330
  `,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let o=t.exec(e);if(!o)return e;let n=o[1],i=" ",s=t.lastIndex;r.lastIndex=s;while(o=r.exec(e)){if(o[1]==="")if(i===`
331
331
  `)n+=i;else i=`
332
- `;else n+=i+o[1],i=" ";s=r.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=s,o=a.exec(e),n+i+(o?.[1]??"")}function _re(e,t){let r="";for(let o=1;o<e.length-1;++o){let n=e[o];if(n==="\r"&&e[o+1]===`
332
+ `;else n+=i+o[1],i=" ";s=r.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=s,o=a.exec(e),n+i+(o?.[1]??"")}function Ere(e,t){let r="";for(let o=1;o<e.length-1;++o){let n=e[o];if(n==="\r"&&e[o+1]===`
333
333
  `)continue;if(n===`
334
- `){let{fold:i,offset:s}=Ere(e,o);r+=i,o=s}else if(n==="\\"){let i=e[++o],s=Ire[i];if(s)r+=s;else if(i===`
334
+ `){let{fold:i,offset:s}=Ire(e,o);r+=i,o=s}else if(n==="\\"){let i=e[++o],s=kre[i];if(s)r+=s;else if(i===`
335
335
  `){i=e[o+1];while(i===" "||i==="\t")i=e[++o+1]}else if(i==="\r"&&e[o+1]===`
336
- `){i=e[++o+1];while(i===" "||i==="\t")i=e[++o+1]}else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;r+=kre(e,o+1,a,t),o+=a}else{let a=e.substr(o-1,2);t(o-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(n===" "||n==="\t"){let i=o,s=e[o+1];while(s===" "||s==="\t")s=e[++o+1];if(s!==`
336
+ `){i=e[++o+1];while(i===" "||i==="\t")i=e[++o+1]}else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;r+=Are(e,o+1,a,t),o+=a}else{let a=e.substr(o-1,2);t(o-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(n===" "||n==="\t"){let i=o,s=e[o+1];while(s===" "||s==="\t")s=e[++o+1];if(s!==`
337
337
  `&&!(s==="\r"&&e[o+2]===`
338
- `))r+=o>i?e.slice(i,o+1):n}else r+=n}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return r}function Ere(e,t){let r="",o=e[t+1];while(o===" "||o==="\t"||o===`
338
+ `))r+=o>i?e.slice(i,o+1):n}else r+=n}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return r}function Ire(e,t){let r="",o=e[t+1];while(o===" "||o==="\t"||o===`
339
339
  `||o==="\r"){if(o==="\r"&&e[t+2]!==`
340
340
  `)break;if(o===`
341
341
  `)r+=`
342
- `;t+=1,o=e[t+1]}if(!r)r=" ";return{fold:r,offset:t}}var Ire={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
343
- `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function kre(e,t,r,o){let n=e.substr(t,r),s=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(s)}catch{let a=e.substr(t-2,r+2);return o(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Are.resolveFlowScalar=vre});var CL=ge(function(zre){var _s=Me(),OL=Et(),$re=OI(),Rre=PI();function Ore(e,t,r,o){let{value:n,type:i,comment:s,range:a}=t.type==="block-scalar"?$re.resolveBlockScalar(e,t,o):Rre.resolveFlowScalar(t,e.options.strict,o),c=r?e.directives.tagName(r.source,(f)=>o(r,"TAG_RESOLVE_FAILED",f)):null,u;if(e.options.stringKeys&&e.atKey)u=e.schema[_s.SCALAR];else if(c)u=Cre(e.schema,n,c,r,o);else if(t.type==="scalar")u=Pre(e,n,t,o);else u=e.schema[_s.SCALAR];let d;try{let f=u.resolve(n,(m)=>o(r??t,"TAG_RESOLVE_FAILED",m),e.options);d=_s.isScalar(f)?f:new OL.Scalar(f)}catch(f){let m=f instanceof Error?f.message:String(f);o(r??t,"TAG_RESOLVE_FAILED",m),d=new OL.Scalar(n)}if(d.range=a,d.source=n,i)d.type=i;if(c)d.tag=c;if(u.format)d.format=u.format;if(s)d.comment=s;return d}function Cre(e,t,r,o,n){if(r==="!")return e[_s.SCALAR];let i=[];for(let a of e.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(t))return a;let s=e.knownTags[r];if(s&&!s.collection)return e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s;return n(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[_s.SCALAR]}function Pre({atKey:e,directives:t,schema:r},o,n,i){let s=r.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(o))||r[_s.SCALAR];if(r.compat){let a=r.compat.find((c)=>c.default&&c.test?.test(o))??r[_s.SCALAR];if(s.tag!==a.tag){let c=t.tagString(s.tag),u=t.tagString(a.tag),d=`Value may be parsed as either ${c} or ${u}`;i(n,"TAG_RESOLVE_FAILED",d,!0)}}return s}zre.composeScalar=Ore});var PL=ge(function(Lre){function Dre(e,t,r){if(t){r??(r=t.length);for(let o=r-1;o>=0;--o){let n=t[o];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}n=t[++o];while(n?.type==="space")e+=n.source.length,n=t[++o];break}}return e}Lre.emptyScalarPosition=Dre});var DL=ge(function(Kre){var jre=Ru(),Zre=Me(),Ure=$L(),zL=CL(),qre=hc(),Mre=PL(),Fre={composeNode:NL,composeEmptyNode:zI};function NL(e,t,r,o){let n=e.atKey,{spaceBefore:i,comment:s,anchor:a,tag:c}=r,u,d=!0;switch(t.type){case"alias":if(u=Jre(e,t,o),a||c)o(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(u=zL.composeScalar(e,t,c,o),a)u.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(u=Ure.composeCollection(Fre,e,t,r,o),a)u.anchor=a.source.substring(1)}catch(f){let m=f instanceof Error?f.message:String(f);o(t,"RESOURCE_EXHAUSTION",m)}break;default:{let f=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;o(t,"UNEXPECTED_TOKEN",f),d=!1}}if(u??(u=zI(e,t.offset,void 0,null,r,o)),a&&u.anchor==="")o(a,"BAD_ALIAS","Anchor cannot be an empty string");if(n&&e.options.stringKeys&&(!Zre.isScalar(u)||typeof u.value!=="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str"))o(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(i)u.spaceBefore=!0;if(s)if(t.type==="scalar"&&t.source==="")u.comment=s;else u.commentBefore=s;if(e.options.keepSourceTokens&&d)u.srcToken=t;return u}function zI(e,t,r,o,{spaceBefore:n,comment:i,anchor:s,tag:a,end:c},u){let d={type:"scalar",offset:Mre.emptyScalarPosition(t,r,o),indent:-1,source:""},f=zL.composeScalar(e,d,a,u);if(s){if(f.anchor=s.source.substring(1),f.anchor==="")u(s,"BAD_ALIAS","Anchor cannot be an empty string")}if(n)f.spaceBefore=!0;if(i)f.comment=i,f.range[2]=c;return f}function Jre({options:e},{offset:t,source:r,end:o},n){let i=new jre.Alias(r.substring(1));if(i.source==="")n(t,"BAD_ALIAS","Alias cannot be an empty string");if(i.source.endsWith(":"))n(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=t+r.length,a=qre.resolveEnd(o,s,e.strict,n);if(i.range=[t,s,a.offset],a.comment)i.comment=a.comment;return i}Kre.composeEmptyNode=zI;Kre.composeNode=NL});var BL=ge(function(Xre){var Wre=Fu(),LL=DL(),Gre=hc(),Qre=Ku();function Yre(e,t,{offset:r,start:o,value:n,end:i},s){let a=Object.assign({_directives:t},e),c=new Wre.Document(void 0,a),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=Qre.resolveProps(o,{indicator:"doc-start",next:n??i?.[0],offset:r,onError:s,parentIndent:0,startOnNewline:!0});if(d.found){if(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!d.hasNewline)s(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=n?LL.composeNode(u,n,d,s):LL.composeEmptyNode(u,d.end,o,null,d,s);let f=c.contents.range[2],m=Gre.resolveEnd(i,f,!1,s);if(m.comment)c.comment=m.comment;return c.range=[r,f,m.offset],c}Xre.composeDoc=Yre});var NI=ge(function(sne){var tne=Zr("process"),rne=jE(),nne=Fu(),Hu=Ju(),jL=Me(),one=BL(),ine=hc();function Vu(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r==="string"?r.length:1)]}function ZL(e){let t="",r=!1,o=!1;for(let n=0;n<e.length;++n){let i=e[n];switch(i[0]){case"#":t+=(t===""?"":o?`
342
+ `;t+=1,o=e[t+1]}if(!r)r=" ";return{fold:r,offset:t}}var kre={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
343
+ `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Are(e,t,r,o){let n=e.substr(t,r),s=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(s)}catch{let a=e.substr(t-2,r+2);return o(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Tre.resolveFlowScalar=wre});var CL=ge(function(Nre){var _s=Me(),OL=Et(),Rre=OI(),Ore=PI();function Cre(e,t,r,o){let{value:n,type:i,comment:s,range:a}=t.type==="block-scalar"?Rre.resolveBlockScalar(e,t,o):Ore.resolveFlowScalar(t,e.options.strict,o),c=r?e.directives.tagName(r.source,(f)=>o(r,"TAG_RESOLVE_FAILED",f)):null,u;if(e.options.stringKeys&&e.atKey)u=e.schema[_s.SCALAR];else if(c)u=Pre(e.schema,n,c,r,o);else if(t.type==="scalar")u=zre(e,n,t,o);else u=e.schema[_s.SCALAR];let d;try{let f=u.resolve(n,(m)=>o(r??t,"TAG_RESOLVE_FAILED",m),e.options);d=_s.isScalar(f)?f:new OL.Scalar(f)}catch(f){let m=f instanceof Error?f.message:String(f);o(r??t,"TAG_RESOLVE_FAILED",m),d=new OL.Scalar(n)}if(d.range=a,d.source=n,i)d.type=i;if(c)d.tag=c;if(u.format)d.format=u.format;if(s)d.comment=s;return d}function Pre(e,t,r,o,n){if(r==="!")return e[_s.SCALAR];let i=[];for(let a of e.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(t))return a;let s=e.knownTags[r];if(s&&!s.collection)return e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s;return n(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[_s.SCALAR]}function zre({atKey:e,directives:t,schema:r},o,n,i){let s=r.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(o))||r[_s.SCALAR];if(r.compat){let a=r.compat.find((c)=>c.default&&c.test?.test(o))??r[_s.SCALAR];if(s.tag!==a.tag){let c=t.tagString(s.tag),u=t.tagString(a.tag),d=`Value may be parsed as either ${c} or ${u}`;i(n,"TAG_RESOLVE_FAILED",d,!0)}}return s}Nre.composeScalar=Cre});var PL=ge(function(Bre){function Lre(e,t,r){if(t){r??(r=t.length);for(let o=r-1;o>=0;--o){let n=t[o];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}n=t[++o];while(n?.type==="space")e+=n.source.length,n=t[++o];break}}return e}Bre.emptyScalarPosition=Lre});var DL=ge(function(Hre){var Zre=Ru(),Ure=Me(),qre=$L(),zL=CL(),Mre=hc(),Fre=PL(),Jre={composeNode:NL,composeEmptyNode:zI};function NL(e,t,r,o){let n=e.atKey,{spaceBefore:i,comment:s,anchor:a,tag:c}=r,u,d=!0;switch(t.type){case"alias":if(u=Kre(e,t,o),a||c)o(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(u=zL.composeScalar(e,t,c,o),a)u.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(u=qre.composeCollection(Jre,e,t,r,o),a)u.anchor=a.source.substring(1)}catch(f){let m=f instanceof Error?f.message:String(f);o(t,"RESOURCE_EXHAUSTION",m)}break;default:{let f=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;o(t,"UNEXPECTED_TOKEN",f),d=!1}}if(u??(u=zI(e,t.offset,void 0,null,r,o)),a&&u.anchor==="")o(a,"BAD_ALIAS","Anchor cannot be an empty string");if(n&&e.options.stringKeys&&(!Ure.isScalar(u)||typeof u.value!=="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str"))o(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(i)u.spaceBefore=!0;if(s)if(t.type==="scalar"&&t.source==="")u.comment=s;else u.commentBefore=s;if(e.options.keepSourceTokens&&d)u.srcToken=t;return u}function zI(e,t,r,o,{spaceBefore:n,comment:i,anchor:s,tag:a,end:c},u){let d={type:"scalar",offset:Fre.emptyScalarPosition(t,r,o),indent:-1,source:""},f=zL.composeScalar(e,d,a,u);if(s){if(f.anchor=s.source.substring(1),f.anchor==="")u(s,"BAD_ALIAS","Anchor cannot be an empty string")}if(n)f.spaceBefore=!0;if(i)f.comment=i,f.range[2]=c;return f}function Kre({options:e},{offset:t,source:r,end:o},n){let i=new Zre.Alias(r.substring(1));if(i.source==="")n(t,"BAD_ALIAS","Alias cannot be an empty string");if(i.source.endsWith(":"))n(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=t+r.length,a=Mre.resolveEnd(o,s,e.strict,n);if(i.range=[t,s,a.offset],a.comment)i.comment=a.comment;return i}Hre.composeEmptyNode=zI;Hre.composeNode=NL});var BL=ge(function(ene){var Gre=Fu(),LL=DL(),Qre=hc(),Yre=Ku();function Xre(e,t,{offset:r,start:o,value:n,end:i},s){let a=Object.assign({_directives:t},e),c=new Gre.Document(void 0,a),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=Yre.resolveProps(o,{indicator:"doc-start",next:n??i?.[0],offset:r,onError:s,parentIndent:0,startOnNewline:!0});if(d.found){if(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!d.hasNewline)s(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=n?LL.composeNode(u,n,d,s):LL.composeEmptyNode(u,d.end,o,null,d,s);let f=c.contents.range[2],m=Qre.resolveEnd(i,f,!1,s);if(m.comment)c.comment=m.comment;return c.range=[r,f,m.offset],c}ene.composeDoc=Xre});var NI=ge(function(ane){var rne=Zr("process"),nne=jE(),one=Fu(),Hu=Ju(),jL=Me(),ine=BL(),sne=hc();function Vu(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r==="string"?r.length:1)]}function ZL(e){let t="",r=!1,o=!1;for(let n=0;n<e.length;++n){let i=e[n];switch(i[0]){case"#":t+=(t===""?"":o?`
344
344
 
345
345
  `:`
346
- `)+(i.substring(1)||" "),r=!0,o=!1;break;case"%":if(e[n+1]?.[0]!=="#")n+=1;r=!1;break;default:if(!r)o=!0;r=!1}}return{comment:t,afterEmptyLine:o}}class UL{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,o,n)=>{let i=Vu(t);if(n)this.warnings.push(new Hu.YAMLWarning(i,r,o));else this.errors.push(new Hu.YAMLParseError(i,r,o))},this.directives=new rne.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:o}=ZL(this.prelude);if(r){let n=e.contents;if(t)e.comment=e.comment?`${e.comment}
346
+ `)+(i.substring(1)||" "),r=!0,o=!1;break;case"%":if(e[n+1]?.[0]!=="#")n+=1;r=!1;break;default:if(!r)o=!0;r=!1}}return{comment:t,afterEmptyLine:o}}class UL{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,o,n)=>{let i=Vu(t);if(n)this.warnings.push(new Hu.YAMLWarning(i,r,o));else this.errors.push(new Hu.YAMLParseError(i,r,o))},this.directives=new nne.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:o}=ZL(this.prelude);if(r){let n=e.contents;if(t)e.comment=e.comment?`${e.comment}
347
347
  ${r}`:r;else if(o||e.directives.docStart||!n)e.commentBefore=r;else if(jL.isCollection(n)&&!n.flow&&n.items.length>0){let i=n.items[0];if(jL.isPair(i))i=i.key;let s=i.commentBefore;i.commentBefore=s?`${r}
348
348
  ${s}`:r}else{let i=n.commentBefore;n.commentBefore=i?`${r}
349
- ${i}`:r}}if(t){for(let n=0;n<this.errors.length;++n)e.errors.push(this.errors[n]);for(let n=0;n<this.warnings.length;++n)e.warnings.push(this.warnings[n])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:ZL(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let o of e)yield*this.next(o);yield*this.end(t,r)}*next(e){if(tne.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,r,o)=>{let n=Vu(e);n[0]+=t,this.onError(n,"BAD_DIRECTIVE",r,o)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=one.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new Hu.YAMLParseError(Vu(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(r);else this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){this.errors.push(new Hu.YAMLParseError(Vu(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=ine.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
350
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Hu.YAMLParseError(Vu(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),o=new nne.Document(void 0,r);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");o.range=[0,t,t],this.decorate(o,!1),yield o}}}sne.Composer=UL});var FL=ge(function(hne){var cne=OI(),lne=PI(),une=Ju(),qL=zu();function dne(e,t=!0,r){if(e){let o=(n,i,s)=>{let a=typeof n==="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(a,i,s);else throw new une.YAMLParseError([a,a+1],i,s)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return lne.resolveFlowScalar(e,t,o);case"block-scalar":return cne.resolveBlockScalar({options:{strict:t}},e,o)}}return null}function fne(e,t){let{implicitKey:r=!1,indent:o,inFlow:n=!1,offset:i=-1,type:s="PLAIN"}=t,a=qL.stringifyString({type:s,value:e},{implicitKey:r,indent:o>0?" ".repeat(o):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:o,source:`
349
+ ${i}`:r}}if(t){for(let n=0;n<this.errors.length;++n)e.errors.push(this.errors[n]);for(let n=0;n<this.warnings.length;++n)e.warnings.push(this.warnings[n])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:ZL(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let o of e)yield*this.next(o);yield*this.end(t,r)}*next(e){if(rne.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,r,o)=>{let n=Vu(e);n[0]+=t,this.onError(n,"BAD_DIRECTIVE",r,o)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=ine.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new Hu.YAMLParseError(Vu(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(r);else this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){this.errors.push(new Hu.YAMLParseError(Vu(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=sne.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
350
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Hu.YAMLParseError(Vu(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),o=new one.Document(void 0,r);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");o.range=[0,t,t],this.decorate(o,!1),yield o}}}ane.Composer=UL});var FL=ge(function(gne){var lne=OI(),une=PI(),dne=Ju(),qL=zu();function fne(e,t=!0,r){if(e){let o=(n,i,s)=>{let a=typeof n==="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(a,i,s);else throw new dne.YAMLParseError([a,a+1],i,s)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return une.resolveFlowScalar(e,t,o);case"block-scalar":return lne.resolveBlockScalar({options:{strict:t}},e,o)}}return null}function pne(e,t){let{implicitKey:r=!1,indent:o,inFlow:n=!1,offset:i=-1,type:s="PLAIN"}=t,a=qL.stringifyString({type:s,value:e},{implicitKey:r,indent:o>0?" ".repeat(o):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:o,source:`
351
351
  `}];switch(a[0]){case"|":case">":{let u=a.indexOf(`
352
352
  `),d=a.substring(0,u),f=a.substring(u+1)+`
353
353
  `,m=[{type:"block-scalar-header",offset:i,indent:o,source:d}];if(!ML(m,c))m.push({type:"newline",offset:-1,indent:o,source:`
354
- `});return{type:"block-scalar",offset:i,indent:o,props:m,source:f}}case'"':return{type:"double-quoted-scalar",offset:i,indent:o,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:o,source:a,end:c};default:return{type:"scalar",offset:i,indent:o,source:a,end:c}}}function pne(e,t,r={}){let{afterKey:o=!1,implicitKey:n=!1,inFlow:i=!1,type:s}=r,a="indent"in e?e.indent:null;if(o&&typeof a==="number")a+=2;if(!s)switch(e.type){case"single-quoted-scalar":s="QUOTE_SINGLE";break;case"double-quoted-scalar":s="QUOTE_DOUBLE";break;case"block-scalar":{let u=e.props[0];if(u.type!=="block-scalar-header")throw Error("Invalid block scalar header");s=u.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:s="PLAIN"}let c=qL.stringifyString({type:s,value:t},{implicitKey:n||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":mne(e,c);break;case'"':DI(e,c,"double-quoted-scalar");break;case"'":DI(e,c,"single-quoted-scalar");break;default:DI(e,c,"scalar")}}function mne(e,t){let r=t.indexOf(`
354
+ `});return{type:"block-scalar",offset:i,indent:o,props:m,source:f}}case'"':return{type:"double-quoted-scalar",offset:i,indent:o,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:o,source:a,end:c};default:return{type:"scalar",offset:i,indent:o,source:a,end:c}}}function mne(e,t,r={}){let{afterKey:o=!1,implicitKey:n=!1,inFlow:i=!1,type:s}=r,a="indent"in e?e.indent:null;if(o&&typeof a==="number")a+=2;if(!s)switch(e.type){case"single-quoted-scalar":s="QUOTE_SINGLE";break;case"double-quoted-scalar":s="QUOTE_DOUBLE";break;case"block-scalar":{let u=e.props[0];if(u.type!=="block-scalar-header")throw Error("Invalid block scalar header");s=u.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:s="PLAIN"}let c=qL.stringifyString({type:s,value:t},{implicitKey:n||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":hne(e,c);break;case'"':DI(e,c,"double-quoted-scalar");break;case"'":DI(e,c,"single-quoted-scalar");break;default:DI(e,c,"scalar")}}function hne(e,t){let r=t.indexOf(`
355
355
  `),o=t.substring(0,r),n=t.substring(r+1)+`
356
356
  `;if(e.type==="block-scalar"){let i=e.props[0];if(i.type!=="block-scalar-header")throw Error("Invalid block scalar header");i.source=o,e.source=n}else{let{offset:i}=e,s="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:s,source:o}];if(!ML(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:s,source:`
357
357
  `});for(let c of Object.keys(e))if(c!=="type"&&c!=="offset")delete e[c];Object.assign(e,{type:"block-scalar",indent:s,props:a,source:n})}}function ML(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function DI(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let o=e.props.slice(1),n=t.length;if(e.props[0].type==="block-scalar-header")n-=e.props[0].source.length;for(let i of o)i.offset+=n;delete e.props,Object.assign(e,{type:r,source:t,end:o});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
358
- `};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let o="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter((i)=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(e))if(i!=="type"&&i!=="offset")delete e[i];Object.assign(e,{type:r,indent:o,source:t,end:n})}}}hne.createScalarToken=fne;hne.resolveAsScalar=dne;hne.setScalarValue=pne});var JL=ge(function(vne){var Sne=(e)=>("type"in e)?Dh(e):Nh(e);function Dh(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=Dh(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=Nh(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=Nh(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=Nh(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function Nh({start:e,key:t,sep:r,value:o}){let n="";for(let i of e)n+=i.source;if(t)n+=Dh(t);if(r)for(let i of r)n+=i.source;if(o)n+=Dh(o);return n}vne.stringify=Sne});var VL=ge(function(_ne){var LI=Symbol("break visit"),xne=Symbol("skip children"),KL=Symbol("remove item");function Es(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};HL(Object.freeze([]),e,t)}Es.BREAK=LI;Es.SKIP=xne;Es.REMOVE=KL;Es.itemAtPath=(e,t)=>{let r=e;for(let[o,n]of t){let i=r?.[o];if(i&&"items"in i)r=i.items[n];else return}return r};Es.parentCollection=(e,t)=>{let r=Es.itemAtPath(e,t.slice(0,-1)),o=t[t.length-1][0],n=r?.[o];if(n&&"items"in n)return n;throw Error("Parent collection not found")};function HL(e,t,r){let o=r(t,e);if(typeof o==="symbol")return o;for(let n of["key","value"]){let i=t[n];if(i&&"items"in i){for(let s=0;s<i.items.length;++s){let a=HL(Object.freeze(e.concat([[n,s]])),i.items[s],r);if(typeof a==="number")s=a-1;else if(a===LI)return LI;else if(a===KL)i.items.splice(s,1),s-=1}if(typeof o==="function"&&n==="key")o=o(t,e)}}return typeof o==="function"?o(t,e):o}_ne.visit=Es});var Lh=ge(function(One){var BI=FL(),Ine=JL(),kne=VL(),jI="\uFEFF",ZI="\x02",UI="\x18",qI="\x1F",Ane=(e)=>!!e&&("items"in e),Tne=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function $ne(e){switch(e){case jI:return"<BOM>";case ZI:return"<DOC>";case UI:return"<FLOW_END>";case qI:return"<SCALAR>";default:return JSON.stringify(e)}}function Rne(e){switch(e){case jI:return"byte-order-mark";case ZI:return"doc-mode";case UI:return"flow-error-end";case qI:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
358
+ `};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let o="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter((i)=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(e))if(i!=="type"&&i!=="offset")delete e[i];Object.assign(e,{type:r,indent:o,source:t,end:n})}}}gne.createScalarToken=pne;gne.resolveAsScalar=fne;gne.setScalarValue=mne});var JL=ge(function(wne){var vne=(e)=>("type"in e)?Dh(e):Nh(e);function Dh(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=Dh(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=Nh(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=Nh(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=Nh(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function Nh({start:e,key:t,sep:r,value:o}){let n="";for(let i of e)n+=i.source;if(t)n+=Dh(t);if(r)for(let i of r)n+=i.source;if(o)n+=Dh(o);return n}wne.stringify=vne});var VL=ge(function(Ene){var LI=Symbol("break visit"),_ne=Symbol("skip children"),KL=Symbol("remove item");function Es(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};HL(Object.freeze([]),e,t)}Es.BREAK=LI;Es.SKIP=_ne;Es.REMOVE=KL;Es.itemAtPath=(e,t)=>{let r=e;for(let[o,n]of t){let i=r?.[o];if(i&&"items"in i)r=i.items[n];else return}return r};Es.parentCollection=(e,t)=>{let r=Es.itemAtPath(e,t.slice(0,-1)),o=t[t.length-1][0],n=r?.[o];if(n&&"items"in n)return n;throw Error("Parent collection not found")};function HL(e,t,r){let o=r(t,e);if(typeof o==="symbol")return o;for(let n of["key","value"]){let i=t[n];if(i&&"items"in i){for(let s=0;s<i.items.length;++s){let a=HL(Object.freeze(e.concat([[n,s]])),i.items[s],r);if(typeof a==="number")s=a-1;else if(a===LI)return LI;else if(a===KL)i.items.splice(s,1),s-=1}if(typeof o==="function"&&n==="key")o=o(t,e)}}return typeof o==="function"?o(t,e):o}Ene.visit=Es});var Lh=ge(function(Cne){var BI=FL(),kne=JL(),Ane=VL(),jI="\uFEFF",ZI="\x02",UI="\x18",qI="\x1F",Tne=(e)=>!!e&&("items"in e),$ne=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Rne(e){switch(e){case jI:return"<BOM>";case ZI:return"<DOC>";case UI:return"<FLOW_END>";case qI:return"<SCALAR>";default:return JSON.stringify(e)}}function One(e){switch(e){case jI:return"byte-order-mark";case ZI:return"doc-mode";case UI:return"flow-error-end";case qI:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
359
359
  `:case`\r
360
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}One.createScalarToken=BI.createScalarToken;One.resolveAsScalar=BI.resolveAsScalar;One.setScalarValue=BI.setScalarValue;One.stringify=Ine.stringify;One.visit=kne.visit;One.BOM=jI;One.DOCUMENT=ZI;One.FLOW_END=UI;One.SCALAR=qI;One.isCollection=Ane;One.isScalar=Tne;One.prettyToken=$ne;One.tokenType=Rne});var FI=ge(function(Hne){var Wu=Lh();function un(e){switch(e){case void 0:case" ":case`
361
- `:case"\r":case"\t":return!0;default:return!1}}var WL=new Set("0123456789ABCDEFabcdef"),Jne=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Bh=new Set(",[]{}"),Kne=new Set(` ,[]{}
362
- \r `),MI=(e)=>!e||Kne.has(e);class GL{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let r=this.next??"stream";while(r&&(t||this.hasChars(1)))r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
360
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}Cne.createScalarToken=BI.createScalarToken;Cne.resolveAsScalar=BI.resolveAsScalar;Cne.setScalarValue=BI.setScalarValue;Cne.stringify=kne.stringify;Cne.visit=Ane.visit;Cne.BOM=jI;Cne.DOCUMENT=ZI;Cne.FLOW_END=UI;Cne.SCALAR=qI;Cne.isCollection=Tne;Cne.isScalar=$ne;Cne.prettyToken=Rne;Cne.tokenType=One});var FI=ge(function(Vne){var Wu=Lh();function un(e){switch(e){case void 0:case" ":case`
361
+ `:case"\r":case"\t":return!0;default:return!1}}var WL=new Set("0123456789ABCDEFabcdef"),Kne=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Bh=new Set(",[]{}"),Hne=new Set(` ,[]{}
362
+ \r `),MI=(e)=>!e||Hne.has(e);class GL{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let r=this.next??"stream";while(r&&(t||this.hasChars(1)))r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
363
363
  `)return!0;if(t==="\r")return this.buffer[e+1]===`
364
364
  `;return!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let r=0;while(t===" ")t=this.buffer[++r+e];if(t==="\r"){let o=this.buffer[r+e+1];if(o===`
365
365
  `||!o&&!this.atEnd)return e+r+1}return t===`
@@ -374,15 +374,15 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
374
374
  `&&n>=this.pos&&n+1+t>s)e=n;else break}while(!0);return yield Wu.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,r=this.pos-1,o;while(o=this.buffer[++r])if(o===":"){let n=this.buffer[r+1];if(un(n)||e&&Bh.has(n))break;t=r}else if(un(o)){let n=this.buffer[r+1];if(o==="\r")if(n===`
375
375
  `)r+=1,o=`
376
376
  `,n=this.buffer[r+1];else t=r;if(n==="#"||e&&Bh.has(n))break;if(o===`
377
- `){let i=this.continueScalar(r+1);if(i===-1)break;r=Math.max(r,i-2)}}else{if(e&&Bh.has(o))break;t=r}if(!o&&!this.atEnd)return this.setNext("plain-scalar");return yield Wu.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);if(r)return yield r,this.pos+=r.length,r.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(MI),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(un(r)||t&&Bh.has(r)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!un(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(Jne.has(t))t=this.buffer[++e];else if(t==="%"&&WL.has(this.buffer[e+1])&&WL.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];if(e===`
377
+ `){let i=this.continueScalar(r+1);if(i===-1)break;r=Math.max(r,i-2)}}else{if(e&&Bh.has(o))break;t=r}if(!o&&!this.atEnd)return this.setNext("plain-scalar");return yield Wu.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);if(r)return yield r,this.pos+=r.length,r.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(MI),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(un(r)||t&&Bh.has(r)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!un(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(Kne.has(t))t=this.buffer[++e];else if(t==="%"&&WL.has(this.buffer[e+1])&&WL.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];if(e===`
378
378
  `)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
379
- `)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,r;do r=this.buffer[++t];while(r===" "||e&&r==="\t");let o=t-this.pos;if(o>0)yield this.buffer.substr(this.pos,o),this.pos=t;return o}*pushUntil(e){let t=this.pos,r=this.buffer[t];while(!e(r))r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}Hne.Lexer=GL});var JI=ge(function(Wne){class QL{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,r=this.lineStarts.length;while(t<r){let n=t+r>>1;if(this.lineStarts[n]<e)t=n+1;else r=n}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let o=this.lineStarts[t-1];return{line:t,col:e-o+1}}}}Wne.LineCounter=QL});var KI=ge(function(Xne){var Qne=Zr("process"),YL=Lh(),Yne=FI();function mi(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function XL(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function tB(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function jh(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function gc(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function Zh(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function eB(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!mi(t.start,"explicit-key-ind")&&!mi(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,tB(t.value))if(t.value.end)Zh(t.value.end,t.sep);else t.value.end=t.sep;else Zh(t.start,t.sep);delete t.sep}}}class rB{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Yne.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let r of this.lexer.lex(e,t))yield*this.next(r);if(!t)yield*this.end()}*next(e){if(this.source=e,Qne.env.LOG_TOKENS)console.log("|",YL.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=YL.tokenType(e);if(!t){let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let r=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in r?r.indent:0;else if(t.type==="flow-collection"&&r.type==="document")t.indent=0;if(t.type==="flow-collection")eB(t);switch(r.type){case"document":r.value=t;break;case"block-scalar":r.props.push(t);break;case"block-map":{let o=r.items[r.items.length-1];if(o.value){r.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(o.sep)o.value=t;else{Object.assign(o,{key:t,sep:[]}),this.onKeyLine=!o.explicitKey;return}break}case"block-seq":{let o=r.items[r.items.length-1];if(o.value)r.items.push({start:[],value:t});else o.value=t;break}case"flow-collection":{let o=r.items[r.items.length-1];if(!o||o.value)r.items.push({start:[],key:t,sep:[]});else if(o.sep)o.value=t;else Object.assign(o,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let o=t.items[t.items.length-1];if(o&&!o.sep&&!o.value&&o.start.length>0&&XL(o.start)===-1&&(t.indent===0||o.start.every((n)=>n.type!=="comment"||n.indent<t.indent))){if(r.type==="document")r.end=o.start;else r.items.push({start:o.start});t.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")e.start.push(this.sourceToken);this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{if(XL(e.start)!==-1)yield*this.pop(),yield*this.step();else e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);if(t)this.stack.push(t);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=jh(this.peek(2)),r=gc(t),o;if(e.end)o=e.end,o.push(this.sourceToken),delete e.end;else o=[this.sourceToken];let n={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=n}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
379
+ `)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,r;do r=this.buffer[++t];while(r===" "||e&&r==="\t");let o=t-this.pos;if(o>0)yield this.buffer.substr(this.pos,o),this.pos=t;return o}*pushUntil(e){let t=this.pos,r=this.buffer[t];while(!e(r))r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}Vne.Lexer=GL});var JI=ge(function(Gne){class QL{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,r=this.lineStarts.length;while(t<r){let n=t+r>>1;if(this.lineStarts[n]<e)t=n+1;else r=n}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let o=this.lineStarts[t-1];return{line:t,col:e-o+1}}}}Gne.LineCounter=QL});var KI=ge(function(eoe){var Yne=Zr("process"),YL=Lh(),Xne=FI();function mi(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function XL(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function tB(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function jh(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function gc(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function Zh(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function eB(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!mi(t.start,"explicit-key-ind")&&!mi(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,tB(t.value))if(t.value.end)Zh(t.value.end,t.sep);else t.value.end=t.sep;else Zh(t.start,t.sep);delete t.sep}}}class rB{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Xne.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let r of this.lexer.lex(e,t))yield*this.next(r);if(!t)yield*this.end()}*next(e){if(this.source=e,Yne.env.LOG_TOKENS)console.log("|",YL.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=YL.tokenType(e);if(!t){let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let r=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in r?r.indent:0;else if(t.type==="flow-collection"&&r.type==="document")t.indent=0;if(t.type==="flow-collection")eB(t);switch(r.type){case"document":r.value=t;break;case"block-scalar":r.props.push(t);break;case"block-map":{let o=r.items[r.items.length-1];if(o.value){r.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(o.sep)o.value=t;else{Object.assign(o,{key:t,sep:[]}),this.onKeyLine=!o.explicitKey;return}break}case"block-seq":{let o=r.items[r.items.length-1];if(o.value)r.items.push({start:[],value:t});else o.value=t;break}case"flow-collection":{let o=r.items[r.items.length-1];if(!o||o.value)r.items.push({start:[],key:t,sep:[]});else if(o.sep)o.value=t;else Object.assign(o,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let o=t.items[t.items.length-1];if(o&&!o.sep&&!o.value&&o.start.length>0&&XL(o.start)===-1&&(t.indent===0||o.start.every((n)=>n.type!=="comment"||n.indent<t.indent))){if(r.type==="document")r.end=o.start;else r.items.push({start:o.start});t.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")e.start.push(this.sourceToken);this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{if(XL(e.start)!==-1)yield*this.pop(),yield*this.step();else e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);if(t)this.stack.push(t);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=jh(this.peek(2)),r=gc(t),o;if(e.end)o=e.end,o.push(this.sourceToken),delete e.end;else o=[this.sourceToken];let n={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=n}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
380
380
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
381
381
  `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let r="end"in t.value?t.value.end:void 0;if((Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment")r?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let o=e.items[e.items.length-2]?.value?.end;if(Array.isArray(o)){Zh(o,t.start),o.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,o=r&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",n=[];if(o&&t.sep&&!t.value){let i=[];for(let s=0;s<t.sep.length;++s){let a=t.sep[s];switch(a.type){case"newline":i.push(s);break;case"space":break;case"comment":if(a.indent>e.indent)i.length=0;break;default:i.length=0}}if(i.length>=2)n=t.sep.splice(i[1])}switch(this.type){case"anchor":case"tag":if(o||t.value)n.push(this.sourceToken),e.items.push({start:n}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(o||t.value)n.push(this.sourceToken),e.items.push({start:n,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(!t.sep)if(mi(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let i=gc(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(mi(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]});else if(tB(t.key)&&!mi(t.sep,"newline")){let i=gc(t.start),s=t.key,a=t.sep;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:s,sep:a}]})}else if(n.length>0)t.sep=t.sep.concat(n,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||o)e.items.push({start:n,key:null,sep:[this.sourceToken]});else if(mi(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);if(o||t.value)e.items.push({start:n,key:i,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(i);else Object.assign(t,{key:i,sep:[]}),this.onKeyLine=!0;return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!t.explicitKey&&t.sep&&!mi(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(r)e.items.push({start:n});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let r="end"in t.value?t.value.end:void 0;if((Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment")r?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let o=e.items[e.items.length-2]?.value?.end;if(Array.isArray(o)){Zh(o,t.start),o.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;if(t.value||mi(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:o,sep:[]});else if(t.sep)this.stack.push(o);else Object.assign(t,{key:o,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);if(r)this.stack.push(r);else yield*this.pop(),yield*this.step()}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let o=jh(r),n=gc(o);eB(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
382
382
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
383
- `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=jh(e),r=gc(t);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=jh(e),r=gc(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((r)=>r.type==="newline"||r.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}Xne.Parser=rB});var aB=ge(function(coe){var nB=NI(),toe=Fu(),Gu=Ju(),roe=JE(),noe=Me(),ooe=JI(),oB=KI();function iB(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new ooe.LineCounter||null,prettyErrors:t}}function ioe(e,t={}){let{lineCounter:r,prettyErrors:o}=iB(t),n=new oB.Parser(r?.addNewLine),i=new nB.Composer(t),s=Array.from(i.compose(n.parse(e)));if(o&&r)for(let a of s)a.errors.forEach(Gu.prettifyError(e,r)),a.warnings.forEach(Gu.prettifyError(e,r));if(s.length>0)return s;return Object.assign([],{empty:!0},i.streamInfo())}function sB(e,t={}){let{lineCounter:r,prettyErrors:o}=iB(t),n=new oB.Parser(r?.addNewLine),i=new nB.Composer(t),s=null;for(let a of i.compose(n.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new Gu.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(o&&r)s.errors.forEach(Gu.prettifyError(e,r)),s.warnings.forEach(Gu.prettifyError(e,r));return s}function soe(e,t,r){let o=void 0;if(typeof t==="function")o=t;else if(r===void 0&&t&&typeof t==="object")r=t;let n=sB(e,r);if(!n)return null;if(n.warnings.forEach((i)=>roe.warn(n.options.logLevel,i)),n.errors.length>0)if(n.options.logLevel!=="silent")throw n.errors[0];else n.errors=[];return n.toJS(Object.assign({reviver:o},r))}function aoe(e,t,r){let o=null;if(typeof t==="function"||Array.isArray(t))o=t;else if(r===void 0&&t)r=t;if(typeof r==="string")r=r.length;if(typeof r==="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(e===void 0){let{keepUndefined:n}=r??t??{};if(!n)return}if(noe.isDocument(e)&&!o)return e.toString(r);return new toe.Document(e,o,r).toString(r)}coe.parse=soe;coe.parseAllDocuments=ioe;coe.parseDocument=sB;coe.stringify=aoe});var poe,moe,hoe,HI,goe,hi,yoe,boe,Soe,voe,iTe,woe,xoe,_oe,Uh,cB,Eoe,Ioe,koe,Aoe,Toe,$oe,Roe,Ooe,Coe,Poe,po,mo,zoe,yc,VI,Noe,Doe,Loe,Boe,joe,Zoe,Uoe,qoe,Moe,Ln,Foe,Joe,Koe;var Qu=w(()=>{poe=NI(),moe=Fu(),hoe=SI(),HI=Ju(),goe=Ru(),hi=Me(),yoe=ui(),boe=Et(),Soe=fi(),voe=pi(),iTe=Lh(),woe=FI(),xoe=JI(),_oe=KI(),Uh=aB(),cB=Tu();Eoe=poe.Composer,Ioe=moe.Document,koe=hoe.Schema,Aoe=HI.YAMLError,Toe=HI.YAMLParseError,$oe=HI.YAMLWarning,Roe=goe.Alias,Ooe=hi.isAlias,Coe=hi.isCollection,Poe=hi.isDocument,po=hi.isMap,mo=hi.isNode,zoe=hi.isPair,yc=hi.isScalar,VI=hi.isSeq,Noe=yoe.Pair,Doe=boe.Scalar,Loe=Soe.YAMLMap,Boe=voe.YAMLSeq,joe=woe.Lexer,Zoe=xoe.LineCounter,Uoe=_oe.Parser,qoe=Uh.parse,Moe=Uh.parseAllDocuments,Ln=Uh.parseDocument,Foe=Uh.stringify,Joe=cB.visit,Koe=cB.visitAsync});var mB={};Ut(mB,{assertPilotUsersRemoved:()=>GI,createPilotOffboardDriver:()=>WI,offboardPilotUsers:()=>uB});import{access as Hoe,readdir as Voe,readFile as Woe,rm as Yu,writeFile as Goe}from"fs/promises";import{basename as Qoe,join as ho}from"path";async function uB(e,t){let r=[...new Set(t.handles.map((f)=>pr.parse(f)))].sort((f,m)=>f.localeCompare(m));if(r.length===0)throw Error("At least one pilot handle is required");let o=t.dryRun??!0,n=`sunset:${r.join(",")}`;if(!o&&t.confirmation!==n)throw Error(`Exact confirmation required: ${n}`);let i=t.env??process.env,s=t.logger??console.info,a=await ut(e),c=r.map((f)=>Yoe(a,f,i)),u=t.driver??WI({env:i,fetchImpl:t.fetchImpl,contentRepoTokenName:a.pilot.contentRepoAdminToken}),d=await Promise.all(c.map(async(f)=>({target:f,inspection:await u.inspect(f)})));if(eie(d),tie(d,o,s),!o){for(let f of d)if(!f.inspection.contentRepoArchived)await u.archiveContentRepo(f.target),s(`[${f.target.handle}] archived ${f.target.contentRepo}`);for(let f of d)for(let m of f.inspection.dnsRecords)await u.deleteDnsRecord(f.target,m),s(`[${f.target.handle}] deleted DNS ${m.name}`);for(let f of d)if(f.inspection.server)await u.deleteServer(f.target,f.inspection.server),s(`[${f.target.handle}] deleted ${f.target.instanceName}`);await Xoe(c,u,t.sleep??((f)=>new Promise((m)=>setTimeout(m,f)))),await rie(e,r),await ao(e),await GI(e,r),s(`Removed desired state for ${r.length} pilot user(s)`)}return{dryRun:o,handles:r,confirmation:n,plans:d}}function Yoe(e,t,r){let o=e.users.find((d)=>d.handle===t),n=`${t}${e.pilot.domainSuffix}`,i=o?.domain??n,s=$E(i,{sharedDomain:e.pilot.domainSuffix}),a=o?.cloudflareZoneId??qh(r,"CF_ZONE_ID"),c=o?.contentRepo??`${e.pilot.contentRepoPrefix}${t}-content`,u=c.includes("/")?c:`${e.pilot.githubOrg}/${c}`;return{handle:t,instanceName:`rover-${t}`,domain:i,previewDomain:s,...i===n?{}:{wwwDomain:`www.${i}`},contentRepo:u,cloudflareZoneId:a}}async function Xoe(e,t,r){for(let o of e)for(let n=1;n<=20;n+=1){let i=await t.inspect(o);if(!i.server&&i.dnsRecords.length===0&&i.contentRepoArchived)break;if(n===20)throw Error(`[${o.handle}] provider cleanup did not converge`);await r(1500)}}function eie(e){for(let{target:t,inspection:r}of e){if(r.server&&r.server.name!==t.instanceName)throw Error(`[${t.handle}] unexpected server name: ${r.server.name}`);let o=new Set([t.domain,t.previewDomain,...t.wwwDomain?[t.wwwDomain]:[]]);for(let n of r.dnsRecords){if(!o.has(n.name))throw Error(`[${t.handle}] refusing unexpected DNS record ${n.name}`);if(n.type==="A"&&r.server?.ip&&n.content!==r.server.ip)throw Error(`[${t.handle}] ${n.name} does not point to the retiring server`)}}}function tie(e,t,r){r(`${t?"Dry run":"Apply"}: ${e.map(({target:o})=>o.handle).join(", ")}`);for(let{target:o,inspection:n}of e){let i=n.server?`delete ${o.instanceName}`:"already absent",s=n.dnsRecords.length>0?n.dnsRecords.map((c)=>`${c.type} ${c.name}`).join(", "):"already absent",a=n.contentRepoArchived?"already archived":`archive ${o.contentRepo}`;r(`[${o.handle}] server: ${i}; DNS: ${s}; repo: ${a}`)}r("Runtime backups: none")}async function rie(e,t){let r=new Set(t),o=ho(e,"cohorts");for(let n of(await Voe(o)).filter((i)=>i.endsWith(".yaml"))){let i=ho(o,n),s=await Woe(i,"utf8"),a=Ln(s);if(a.errors.length>0)throw Error(`${n}: ${a.errors[0]?.message??"invalid YAML"}`);let c=a.get("members",!0);if(!VI(c))throw Error(`${n}: members must be a sequence`);let u=c.items.filter((d)=>!yc(d)||typeof d.value!=="string"||!r.has(d.value));if(u.length===c.items.length)continue;if(u.length===0){await Yu(i);continue}c.items=u,qr.parse(a.toJS()),await Goe(i,a.toString())}for(let n of t)await Promise.all([Yu(ho(e,"users",`${n}.yaml`),{force:!0}),Yu(ho(e,"users",`${n}.secrets.yaml`),{force:!0}),Yu(ho(e,"users",`${n}.secrets.yaml.age`),{force:!0}),Yu(ho(e,"users",n),{recursive:!0,force:!0})])}function WI(e){let t=e.fetchImpl??fetch,r=qh(e.env,"HCLOUD_TOKEN"),o=qh(e.env,"CF_API_TOKEN"),n=qh(e.env,e.contentRepoTokenName);return{async inspect(i){let[s,a,c]=await Promise.all([nie(t,r,i.instanceName),Promise.all([i.domain,i.previewDomain,...i.wwwDomain?[i.wwwDomain]:[]].map((u)=>oie(t,o,i.cloudflareZoneId,u))).then((u)=>u.flat()),iie(t,n,i.contentRepo)]);if(s.length>1)throw Error(`[${i.handle}] expected at most one server, found ${s.length}`);return{...s[0]?{server:s[0]}:{},dnsRecords:a,contentRepoArchived:c.archived}},async archiveContentRepo(i){await bc(t,`https://api.github.com/repos/${i.contentRepo}`,{method:"PATCH",headers:dB(n),body:JSON.stringify({archived:!0})},"GitHub repository archive")},async deleteDnsRecord(i,s){if(Sc(await bc(t,`https://api.cloudflare.com/client/v4/zones/${i.cloudflareZoneId}/dns_records/${s.id}`,{method:"DELETE",headers:fB(o)},"Cloudflare DNS delete")).success!==!0)throw Error(`Cloudflare DNS delete failed for ${s.name}`)},async deleteServer(i,s){await bc(t,`https://api.hetzner.cloud/v1/servers/${s.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}},"Hetzner server delete",!0)}}}async function nie(e,t,r){let o=new URL("https://api.hetzner.cloud/v1/servers");o.searchParams.set("label_selector",`brain=${r}`);let i=Sc(await bc(e,o.toString(),{headers:{Authorization:`Bearer ${t}`}},"Hetzner server lookup")).servers;if(!Array.isArray(i))throw Error("Hetzner server lookup returned an invalid payload");return i.map((s)=>{let a=Sc(s),c=lB(a.public_net),u=lB(c?.ipv4);return{id:sie(a.id,"Hetzner server id"),name:Xu(a.name,"Hetzner server name"),...typeof u?.ip==="string"?{ip:u.ip}:{}}})}async function oie(e,t,r,o){let n=new URL(`https://api.cloudflare.com/client/v4/zones/${r}/dns_records`);n.searchParams.set("name",o);let i=Sc(await bc(e,n.toString(),{headers:fB(t)},"Cloudflare DNS lookup")),s=i.result;if(i.success!==!0||!Array.isArray(s))throw Error(`Cloudflare DNS lookup failed for ${o}`);return s.map((a)=>{let c=Sc(a),u=Xu(c.type,"Cloudflare record type");if(u!=="A"&&u!=="CNAME")throw Error(`Unsupported Cloudflare record type ${u} for ${o}`);return{id:Xu(c.id,"Cloudflare record id"),name:Xu(c.name,"Cloudflare record name"),type:u,content:Xu(c.content,"Cloudflare record content")}})}async function iie(e,t,r){let o=Sc(await bc(e,`https://api.github.com/repos/${r}`,{headers:dB(t)},"GitHub repository lookup"));if(typeof o.archived!=="boolean")throw Error(`Invalid repository archive state for ${r}`);return{archived:o.archived}}async function bc(e,t,r,o,n=!1){let i=await e(t,r),s=await i.text();if(!i.ok)throw Error(`${o} failed (${i.status}): ${s}`);if(!s&&n)return{};try{return JSON.parse(s)}catch{throw Error(`${o} returned an invalid JSON response`)}}function dB(e){return{Accept:"application/vnd.github+json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"}}function fB(e){return{Authorization:`Bearer ${e}`}}function qh(e,t){let r=e[t];if(!r)throw Error(`Missing required environment variable: ${t}`);return r}function pB(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Sc(e){if(!pB(e))throw Error("Provider returned an unexpected payload");return e}function lB(e){return pB(e)?e:void 0}function Xu(e,t){if(typeof e!=="string"||e.length===0)throw Error(`Missing ${t}`);return e}function sie(e,t){if(typeof e!=="number")throw Error(`Missing ${t}`);return e}async function aie(e){try{return await Hoe(e),!0}catch{return!1}}async function GI(e,t){for(let r of t)for(let o of[ho(e,"users",`${r}.yaml`),ho(e,"users",`${r}.secrets.yaml.age`),ho(e,"users",r)])if(await aie(o))throw Error(`Offboarded user state remains: ${Qoe(o)}`)}var QI=w(()=>{Qu();Mr();RE();ec();Pn()});var f6={};Ut(f6,{upgradePilotRepo:()=>wle});import{readFile as yle}from"fs/promises";import{join as ble}from"path";async function d6(e){let t=ble(e,"package.json"),o=Sle.parse(JSON.parse(await yle(t,"utf8"))).devDependencies?.["@rizom/ops"];if(!o)throw Error(`${t} does not pin @rizom/ops as a devDependency`);return o}async function vle(e,t){let o=await Bun.spawn(e,{cwd:t,stdout:"inherit",stderr:"inherit"}).exited;if(o!==0)throw Error(`${e.join(" ")} failed with exit ${o}`)}async function wle(e,t={}){let r=t.exec??vle,o=await d6(e),n=t.version??"latest";await r(["bun","add","--dev","--exact",`@rizom/ops@${n}`],e);let i=await d6(e);return await r(["bun","x","brains-ops","init","."],e),{from:o,to:i}}var Sle;var p6=w(()=>{he();Sle=l.object({devDependencies:l.record(l.string(),l.string()).optional()})});function m6(e){if(e===null||typeof e!=="object"||Array.isArray(e))return!1;let t=xle(e);return t===Object.prototype||t===null}var xle;var h6=w(()=>{xle=Object.getPrototypeOf});function S6(e){if(e==="core")return{bundles:["core","media","web","chat"]};if(e==="default")return{bundles:["core","media","automation","web","chat","site","publishing","federation"],add:["obsidian-vault"],remove:[...Ile]};return{bundles:["core","media","automation","web","chat","site","publishing","federation"],add:["obsidian-vault"]}}function kle(e){let t=_le.parse(e);return si.parse({brainVersion:t.brainVersion,bundleContract:ii,...S6(t.preset),githubOrg:t.githubOrg,contentRepoPrefix:t.contentRepoPrefix,domainSuffix:t.domainSuffix,aiApiKey:t.aiApiKey,gitSyncToken:t.gitSyncToken,contentRepoAdminToken:t.contentRepoAdminToken,agePublicKey:t.agePublicKey})}function Ale(e){let t=Ele.parse(e),r=t.presetOverride?S6(t.presetOverride):void 0;return qr.parse({members:[...t.members],...t.brainVersionOverride?{brainVersionOverride:t.brainVersionOverride}:{},...r?{bundlesOverride:r.bundles,...r.add?{addOverride:r.add}:{},...r.remove?{removeOverride:r.remove}:{}}:{},...t.aiApiKeyOverride?{aiApiKeyOverride:t.aiApiKeyOverride}:{},...t.gitSyncTokenOverride?{gitSyncTokenOverride:t.gitSyncTokenOverride}:{}})}function v6(e){let t=Ln(e,{keepSourceTokens:!0});if(t.errors.length>0)throw Error(`Invalid desired-state YAML: ${t.errors[0]?.message}`);if(!po(t.contents))throw Error("Desired-state YAML must contain a mapping");return t}function QA(e,t){if(!po(e.contents))return;return e.contents.items.find((r)=>yc(r.key)&&r.key.value===t)}function g6(e,t){if(!mo(e)||!mo(t))return;if(e.commentBefore!==void 0)t.commentBefore=e.commentBefore;if(e.comment!==void 0)t.comment=e.comment;if(e.spaceBefore!==void 0)t.spaceBefore=e.spaceBefore}function y6(e,t){if(!e||!mo(t))return;let r=[mo(e.key)?e.key.commentBefore:void 0,mo(e.key)?e.key.comment:void 0,mo(e.value)?e.value.commentBefore:void 0,mo(e.value)?e.value.comment:void 0].filter((o)=>o!==void 0);if(r.length===0)return;t.commentBefore=[t.commentBefore,...r].filter((o)=>o!==void 0).join(`
384
- `)}function w6(e,t,r,o){if(!po(e.contents))throw Error("Desired-state YAML must contain a mapping");let n=e.contents.items.findIndex((s)=>yc(s.key)&&s.key.value===t),i=e.createPair(r,[...o]);if(n>=0){let s=e.contents.items[n];g6(s?.key,i.key),g6(s?.value,i.value),e.contents.items.splice(n,1,i)}else e.contents.add(i);return i}function x6(e){let t=v6(e),r=kle(t.toJS()),o=QA(t,"schemaVersion"),n=QA(t,"model");y6(o,QA(t,"brainVersion")?.key),t.delete("schemaVersion"),t.set("bundleContract",ii);let i=w6(t,"preset","bundles",r.bundles);if(y6(n,i.key),t.delete("model"),r.add)t.set("add",r.add);else t.delete("add");if(r.remove)t.set("remove",r.remove);else t.delete("remove");return si.parse(t.toJS()),t.toString({lineWidth:0})}function _6(e){let t=v6(e),r=Ale(t.toJS());if(r.bundlesOverride)w6(t,"presetOverride","bundlesOverride",r.bundlesOverride);else t.delete("presetOverride"),t.delete("bundlesOverride");if(r.addOverride)t.set("addOverride",r.addOverride);else t.delete("addOverride");if(r.removeOverride)t.set("removeOverride",r.removeOverride);else t.delete("removeOverride");return qr.parse(t.toJS()),t.toString({lineWidth:0})}var b6,jd,_le,Ele,Ile;var E6=w(()=>{no();he();Qu();Pn();b6=l.enum(["core","default","pro"]),jd=l.string().min(1),_le=l.strictObject({schemaVersion:l.literal(1),brainVersion:$t,model:l.literal("rover"),githubOrg:l.string().min(1),contentRepoPrefix:l.string().min(1),domainSuffix:l.string().min(1),preset:b6,aiApiKey:jd,gitSyncToken:jd,contentRepoAdminToken:jd,agePublicKey:l.string().startsWith("age1").min(1)}),Ele=l.strictObject({members:l.array(pr).min(1),brainVersionOverride:$t.optional(),presetOverride:b6.optional(),aiApiKeyOverride:jd.optional(),gitSyncTokenOverride:jd.optional()}).superRefine((e,t)=>{if(new Set(e.members).size!==e.members.length)t.addIssue({code:l.ZodIssueCode.custom,path:["members"],message:"cohort members must be unique"})}),Ile=["series","portfolio","content-pipeline","social-media","newsletter","stock-photo"]});function k6(e,t){let r=Ln(e,{keepSourceTokens:!0});if(r.errors.length>0||!po(r.contents))throw Error(`Invalid ${t} YAML`);return r}function Cle(e,t){return e.length===t.length&&e.every((r,o)=>r===t[o])}function A6(e,t,r){if(!Cle(t,r.sourceBundles))throw Error(`${e} source bundles changed after review: expected [${r.sourceBundles.join(", ")}], received [${t.join(", ")}]`)}function T6(e){let t=sn(e,Ole);if(!t.ok)throw Error(`Invalid capability bundle review: ${t.error}`);return t.data}function $6(e,t){let r=k6(e,"pilot desired-state"),o=$le.parse(r.toJS());return A6("pilot.yaml",o.bundles,t),r.set("bundleContract",ii),r.set("bundles",t.targetBundles),si.parse(r.toJS()),r.toString({lineWidth:0})}function R6(e,t,r){let o=k6(e,`cohort ${t}`),n=Rle.parse(o.toJS());if(n.bundlesOverride===void 0){if(r!==void 0)throw Error(`Capability bundle review names inheriting cohort ${t}`)}else{if(r===void 0)throw Error(`Cohort ${t} has an explicit legacy bundle selection but no reviewed mapping`);A6(`cohort ${t}`,n.bundlesOverride,r),o.set("bundlesOverride",r.targetBundles)}return qr.parse(o.toJS()),o.toString({lineWidth:0})}var Tle,YA,qg,$le,Rle,I6,Ole;var O6=w(()=>{no();he();Qu();Pn();Tle=l.enum(["core","site","publishing","team"]),YA=l.array(Tle).min(1),qg=l.array(l.string().min(1)),$le=l.strictObject({brainVersion:$t,bundles:YA,add:qg.optional(),remove:qg.optional(),githubOrg:l.string().min(1),contentRepoPrefix:l.string().min(1),domainSuffix:l.string().min(1),aiApiKey:l.string().min(1),gitSyncToken:l.string().min(1),contentRepoAdminToken:l.string().min(1),agePublicKey:l.string().startsWith("age1").min(1)}),Rle=l.strictObject({members:l.array(pr).min(1),brainVersionOverride:$t.optional(),bundlesOverride:YA.optional(),addOverride:qg.optional(),removeOverride:qg.optional(),aiApiKeyOverride:l.string().min(1).optional(),gitSyncTokenOverride:l.string().min(1).optional()}),I6=l.strictObject({sourceBundles:YA,targetBundles:l.array(Dm).min(1)}),Ole=l.strictObject({bundleContract:l.literal(ii),pilot:I6,cohorts:l.record(pr,I6)})});var D6={};Ut(D6,{loadCapabilityBundleReview:()=>Ule,loadReviewedSitePins:()=>Zle,parseReviewedSitePins:()=>N6,stageLegacyCrossover:()=>Mle});import{access as Ple,cp as zle,mkdir as C6,readFile as Kc,readdir as z6,writeFile as Jc}from"fs/promises";import{basename as Nle,join as Hn,relative as Mg,resolve as P6}from"path";import{fileURLToPath as Dle}from"url";function N6(e){let t=sn(e,Lle);if(!t.ok)throw Error(`Invalid reviewed site pins: ${t.error}`);return t.data.sites}async function Zle(e){return N6(await Kc(e,"utf8"))}async function Ule(e){return T6(await Kc(e,"utf8"))}async function qle(e,t){let r=Hn(e,"users"),o=(await z6(r,{withFileTypes:!0})).filter((s)=>s.isFile()&&/\.ya?ml$/.test(s.name)).map((s)=>s.name).sort(),n=new Set(Object.keys(t??{})),i=[];for(let s of o){let a=Hn(r,s),c=await Kc(a,"utf8"),u=Ln(c,{keepSourceTokens:!0});if(u.errors.length>0||!po(u.contents))throw Error(`Invalid user desired-state YAML: ${s}`);let d=Ble.parse(u.toJS());if(!d.siteOverride)continue;let f=t?.[d.handle];if(!f)throw Error(`User ${d.handle} has a siteOverride but no reviewed site pin`);if(n.delete(d.handle),f.package!==d.siteOverride.package||f.theme!==d.siteOverride.theme)throw Error(`Reviewed site pin identity does not match user ${d.handle}`);if(d.siteOverride.version!==void 0&&d.siteOverride.version!==f.version)throw Error(`Reviewed site version does not match the existing pin for user ${d.handle}`);if(d.siteOverride.themeVersion!==void 0&&d.siteOverride.themeVersion!==f.themeVersion)throw Error(`Reviewed theme version does not match the existing pin for user ${d.handle}`);if(u.setIn(["siteOverride","version"],f.version),f.themeVersion!==void 0)u.setIn(["siteOverride","themeVersion"],f.themeVersion);else u.deleteIn(["siteOverride","themeVersion"]);Lm.parse(u.toJS());let m=u.toString({lineWidth:0});if(m!==c)await Jc(a,m),i.push(Mg(e,a))}if(n.size>0)throw Error(`Reviewed site pins do not match site users: ${[...n].sort().join(", ")}`);return i}async function Mle(e,t,r={}){let o=P6(e),n=P6(t);if(o===n||n.startsWith(`${o}/`))throw Error("Crossover output must be outside the source repository");await zle(o,n,{recursive:!0,errorOnExist:!0,force:!1,filter:(A)=>{let O=Nle(A);return O!==".git"&&O!==".operator"&&O!==".brains-ops"&&O!==".turbo"&&O!=="dist"&&O!=="node_modules"&&O!==".env"&&O!==".env.local"&&!O.endsWith(".secrets.yaml")}});let i=[],s=Hn(n,"docs","canonical-crossover-record.md");try{await Ple(s)}catch{await C6(Hn(n,"docs"),{recursive:!0}),await Jc(s,await Kc(jle,"utf8")),i.push("docs/canonical-crossover-record.md")}let a=Hn(n,"pilot.yaml"),c=await Kc(a,"utf8"),d=Ln(c).toJS();if(!m6(d))throw Error(`${a} is not a YAML mapping`);let f=Array.isArray(d.bundles),m=r.bundleReview,h;if(f){if(!m)throw Error("Current canonical desired state requires an explicit capability bundle review manifest");h=$6(c,m.pilot)}else h=x6(c);await Jc(a,h),i.push("pilot.yaml");let b=Hn(n,"cohorts"),y=(await z6(b,{withFileTypes:!0})).filter((A)=>A.isFile()&&/\.ya?ml$/.test(A.name)).map((A)=>A.name).sort(),S=new Set(Object.keys(m?.cohorts??{}));for(let A of y){let O=Hn(b,A),L=await Kc(O,"utf8"),z=A.replace(/\.ya?ml$/,""),K=m?.cohorts[z];if(K)S.delete(z);await Jc(O,f?R6(L,z,K):_6(L)),i.push(Mg(n,O))}if(f&&S.size>0)throw Error(`Capability bundle review names unknown cohorts: ${[...S].sort().join(", ")}`);i.push(...await qle(n,r.sitePins));let x=await ut(n),_=Qm(x.pilot.githubOrg);for(let A of x.users){let O=await _(A),L=Hn(n,"users",A.handle);if(await C6(L,{recursive:!0}),O.brainYaml){let z=Hn(L,"brain.yaml");await Jc(z,O.brainYaml),i.push(Mg(n,z))}if(O.envFile){let z=Hn(L,".env");await Jc(z,O.envFile),i.push(Mg(n,z))}}return await ao(n,{registry:x}),i.push("views/users.md"),{outputDir:n,changedFiles:[...new Set(i)].sort()}}var Lle,Ble,jle;var L6=w(()=>{no();h6();he();Qu();PE();E6();O6();Mr();ec();Pn();Lle=l.strictObject({sites:l.record(pr,aE)}),Ble=l.object({handle:pr,siteOverride:l.object({package:l.string().min(1),version:$t.optional(),theme:l.string().min(1).optional(),themeVersion:$t.optional()}).optional()}).passthrough(),jle=Dle(new URL("../templates/rover-pilot/docs/canonical-crossover-record.md",import.meta.url))});var B6="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";import{webcrypto as j6}from"crypto";function Jle(e){if(e<0)throw RangeError("Wrong ID size");try{if(!Ni||Ni.length<e)Ni=Buffer.allocUnsafe(e*Fle),j6.getRandomValues(Ni),Hc=0;else if(Hc+e>Ni.length)j6.getRandomValues(Ni),Hc=0}catch(t){throw Ni=void 0,t}Hc+=e}function Z6(e=21){Jle(e|=0);let t="";for(let r=Hc-e;r<Hc;r++)t+=B6[Ni[r]&63];return t}var Fle=128,Ni,Hc;var U6=()=>{};function Ro(e=12){return Z6(e)}var Zd=w(()=>{U6()});import{openSync as Kle,writeSync as Hle}from"fs";class kr{static instance=null;level;context;useStderr;format;logFile;fileHandle;constructor(e={},t){if(this.level=e.level??Vs.INFO,this.context=e.context??void 0,this.useStderr=e.useStderr??!1,this.format=e.format??"text",this.logFile=e.logFile,t!==void 0)this.fileHandle=t;else if(this.logFile)try{this.fileHandle=Kle(this.logFile,"a")}catch{}}static getInstance(e){if(!kr.instance)kr.instance=new kr(e);else{if(e?.useStderr!==void 0)kr.instance.useStderr=e.useStderr;if(e?.level!==void 0)kr.instance.level=e.level}return kr.instance}static resetInstance(){kr.instance=null}static createFresh(e){return new kr(e)}formatEntry(e,t,r){let o=new Date().toISOString();if(this.format==="json"){let n={ts:o,level:e,msg:t};if(this.context)n.ctx=this.context;if(r.length>0)n.data=r;return JSON.stringify(n)}return this.context?`[${o}] [${this.context}] ${t}`:`[${o}] ${t}`}write(e,t,r,o){if(this.format==="json")e(this.formatEntry(t,r,o));else if(o.length>0)e(this.formatEntry(t,r,[]),...o);else e(this.formatEntry(t,r,[]));if(this.fileHandle!==void 0){let n=this.formatJsonEntry(t,r,o);try{Hle(this.fileHandle,n+`
385
- `)}catch{}}}formatJsonEntry(e,t,r){let o={ts:new Date().toISOString(),level:e,msg:t};if(this.context)o.ctx=this.context;if(r.length>0)o.data=r;return JSON.stringify(o)}silly(e,...t){if(this.level<=Vs.SILLY)this.write(console.debug.bind(console),"silly",e,t)}verbose(e,...t){if(this.level<=Vs.VERBOSE)this.write(console.debug.bind(console),"verbose",e,t)}debug(e,...t){if(this.level<=Vs.DEBUG)this.write(console.debug.bind(console),"debug",e,t)}info(e,...t){if(this.level<=Vs.INFO){let r=this.useStderr?console.error.bind(console):console.info.bind(console);this.write(r,"info",e,t)}}warn(e,...t){if(this.level<=Vs.WARN)this.write(console.warn.bind(console),"warn",e,t)}error(e,...t){if(this.level<=Vs.ERROR)this.write(console.error.bind(console),"error",e,t)}child(e){return new kr({level:this.level,context:e,useStderr:this.useStderr,format:this.format},this.fileHandle)}setUseStderr(e){this.useStderr=e}}var Vs,fPe;var XA=w(()=>{Vs={SILLY:0,VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};fPe=kr.getInstance()});var eT,Vle,Vc,gPe;var Ud=w(()=>{Mt();he();eT=l.enum(["file_operations","content_operations","data_processing","batch_processing"]),Vle=l.looseObject({pluginId:l.string().optional(),progressToken:l.union([l.string(),l.number()]).optional(),operationType:eT,operationTarget:l.string().optional(),interfaceType:l.string().optional(),conversationId:l.string().optional(),channelId:l.string().optional(),requestedByActor:ri.optional(),requestedByUserId:l.string().optional(),requestedByInterface:l.string().optional(),silent:l.boolean().optional(),provenance:ni.optional()}),Vc=l.looseObject({pluginId:l.string().optional(),progressToken:l.union([l.string(),l.number()]).optional(),operationType:eT,operationTarget:l.string().optional(),interfaceType:l.string().optional(),conversationId:l.string().optional(),channelId:l.string().optional(),requestedByActor:ri.optional(),requestedByUserId:l.string().optional(),requestedByInterface:l.string().optional(),silent:l.boolean().optional(),provenance:ni.optional(),rootJobId:l.string()}),gPe=l.enum(["none","skip","replace","coalesce"])});var Wle,Di=15000;var qd=w(()=>{Ud();he();Wle=l.object({id:l.string(),type:l.string(),data:l.string(),status:l.enum(["pending","processing","completed","failed"]),source:l.string().nullable(),priority:l.number(),retryCount:l.number(),maxRetries:l.number(),lastError:l.string().nullable(),lastErrorPublic:l.unknown(),createdAt:l.number(),scheduledFor:l.number(),startedAt:l.number().nullable(),completedAt:l.number().nullable(),attemptId:l.string().nullable(),workerSlotId:l.string().nullable(),workerSessionId:l.string().nullable(),leaseExpiresAt:l.number().nullable(),attemptHeartbeatAt:l.number().nullable(),runtimeUpdatedAt:l.number().nullable(),metadata:Vc,progress:l.custom((e)=>typeof e==="object"&&e!==null&&("progress"in e)&&typeof e.progress==="number").nullable(),result:l.unknown().nullable().optional()})});var tT,q6,Oe,Gle,Qle,M6,F6,J6;var Oo=w(()=>{Mt();he();Ud();tT=l.enum(["pending","processing","completed","failed"]),q6=l.enum(["completed","failed"]),Oe={PENDING:"pending",PROCESSING:"processing",COMPLETED:"completed",FAILED:"failed"},Gle=l.object({id:l.string(),type:l.string(),status:tT,data:l.unknown(),result:l.unknown().optional(),lastError:l.string().optional().nullable(),attempts:l.number(),maxRetries:l.number(),priority:l.number(),createdAt:l.date(),updatedAt:l.date(),processedAt:l.date().optional().nullable(),completedAt:l.date().optional().nullable(),failedAt:l.date().optional().nullable()}),Qle=l.object({jobId:l.string(),type:l.string(),status:q6,result:l.unknown().optional(),error:l.string().optional()}),M6=l.object({success:l.literal(!1),error:l.string().optional()}),F6=l.object({id:l.string(),type:l.enum(["job","batch"]),status:tT,message:l.string().optional(),progress:l.object({current:l.number(),total:l.number(),percentage:l.number()}).optional(),aggregationKey:l.string().optional(),batchDetails:l.object({totalOperations:l.number(),completedOperations:l.number(),failedOperations:l.number(),currentOperation:l.string().optional(),errors:l.array(l.string()).optional()}).optional(),jobDetails:l.object({jobType:l.string(),priority:l.number(),retryCount:l.number()}).optional(),metadata:Vc}),J6=oi(nE.progress,F6)});var Ce,Gt;var gn=w(()=>{Ce=class Ce extends Error{code;extendedCode;rawCode;constructor(e,t,r,o,n){if(t!==void 0)e=`${t}: ${e}`;super(e,{cause:n});this.code=t,this.extendedCode=r,this.rawCode=o,this.name="LibsqlError"}};Gt=class Gt extends Ce{statementIndex;constructor(e,t,r,o,n,i){super(e,r,o,n,i);this.statementIndex=t,this.name="LibsqlBatchError"}}});function K6(e){let t=Yle.exec(e);if(t===null)throw new Ce(`The URL '${e}' is not in a valid format`,"URL_INVALID");let r=t.groups,o=r.scheme,n=r.authority!==void 0?Xle(r.authority):void 0,i=Ws(r.path),s=r.query!==void 0?tue(r.query):void 0,a=r.fragment!==void 0?Ws(r.fragment):void 0;return{scheme:o,authority:n,path:i,query:s,fragment:a}}function Xle(e){let t=eue.exec(e);if(t===null)throw new Ce("The authority part of the URL is not in a valid format","URL_INVALID");let r=t.groups,o=Ws(r.host_br??r.host),n=r.port?parseInt(r.port,10):void 0,i=r.username!==void 0?{username:Ws(r.username),password:r.password!==void 0?Ws(r.password):void 0}:void 0;return{host:o,port:n,userinfo:i}}function tue(e){let t=e.split("&"),r=[];for(let o of t){if(o==="")continue;let n,i,s=o.indexOf("=");if(s<0)n=o,i="";else n=o.substring(0,s),i=o.substring(s+1);r.push({key:Ws(n.replaceAll("+"," ")),value:Ws(i.replaceAll("+"," "))})}return{pairs:r}}function Ws(e){try{return decodeURIComponent(e)}catch(t){if(t instanceof URIError)throw new Ce(`URL component has invalid percent encoding: ${t}`,"URL_INVALID",void 0,void 0,t);throw t}}function Md(e,t,r){if(t===void 0)throw new Ce(`URL with scheme ${JSON.stringify(e+":")} requires authority (the "//" part)`,"URL_INVALID");let o=`${e}:`,n=rue(t.host),i=nue(t.port),a=`//${oue(t.userinfo)}${n}${i}`,c=r.split("/").map(encodeURIComponent).join("/");if(c!==""&&!c.startsWith("/"))c="/"+c;return new URL(`${o}${a}${c}`)}function rue(e){return e.includes(":")?`[${encodeURI(e)}]`:encodeURI(e)}function nue(e){return e!==void 0?`:${e}`:""}function oue(e){if(e===void 0)return"";let t=encodeURIComponent(e.username),r=e.password!==void 0?`:${encodeURIComponent(e.password)}`:"";return`${t}${r}@`}var Yle,eue;var Fg=w(()=>{gn();Yle=(()=>new RegExp("^(?<scheme>[A-Za-z][A-Za-z.+-]*):(//(?<authority>[^/?#]*))?(?<path>[^?#]*)(\\?(?<query>[^#]*))?(#(?<fragment>.*))?$","su"))();eue=(()=>new RegExp("^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\[\\]]*)|(\\[(?<host_br>[^\\[\\]]*)\\]))(:(?<port>[0-9]*))?$","su"))()});var Gc,H6,V6,Fd,Jg,iue,Qt,W6,Y6=(e)=>e.replace(/=/g,"").replace(/[+\/]/g,(t)=>t=="+"?"-":"_"),X6=(e)=>e.replace(/[^A-Za-z0-9\+\/]/g,""),e4=(e)=>{let t,r,o,n,i="",s=e.length%3;for(let a=0;a<e.length;){if((r=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(n=e.charCodeAt(a++))>255)throw TypeError("invalid character found");t=r<<16|o<<8|n,i+=Fd[t>>18&63]+Fd[t>>12&63]+Fd[t>>6&63]+Fd[t&63]}return s?i.slice(0,s-3)+"===".substring(s):i},oT,rT,Kg=(e,t=!1)=>t?Y6(rT(e)):rT(e),sue=(e)=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?Qt(192|t>>>6)+Qt(128|t&63):Qt(224|t>>>12&15)+Qt(128|t>>>6&63)+Qt(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return Qt(240|t>>>18&7)+Qt(128|t>>>12&63)+Qt(128|t>>>6&63)+Qt(128|t&63)}},aue,t4=(e)=>e.replace(aue,sue),G6,Wc=(e,t=!1)=>t?Y6(G6(e)):G6(e),Q6=(e)=>Wc(e,!0),cue,lue=(e)=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return Qt((r>>>10)+55296)+Qt((r&1023)+56320);case 3:return Qt((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return Qt((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},r4=(e)=>e.replace(cue,lue),n4=(e)=>{if(e=e.replace(/\s+/g,""),!iue.test(e))throw TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r,o,n=[];for(let i=0;i<e.length;)if(t=Jg[e.charAt(i++)]<<18|Jg[e.charAt(i++)]<<12|(r=Jg[e.charAt(i++)])<<6|(o=Jg[e.charAt(i++)]),r===64)n.push(Qt(t>>16&255));else if(o===64)n.push(Qt(t>>16&255,t>>8&255));else n.push(Qt(t>>16&255,t>>8&255,t&255));return n.join("")},iT,o4,i4=(e)=>o4(s4(e)),uue,s4=(e)=>X6(e.replace(/[-_]/g,(t)=>t=="-"?"+":"/")),nT=(e)=>uue(s4(e)),due=(e)=>{if(typeof e!=="string")return!1;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},a4=(e)=>({value:e,enumerable:!1,writable:!0,configurable:!0}),c4=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,a4(r));e("fromBase64",function(){return nT(this)}),e("toBase64",function(t){return Wc(this,t)}),e("toBase64URI",function(){return Wc(this,!0)}),e("toBase64URL",function(){return Wc(this,!0)}),e("toUint8Array",function(){return i4(this)})},l4=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,a4(r));e("toBase64",function(t){return Kg(this,t)}),e("toBase64URI",function(){return Kg(this,!0)}),e("toBase64URL",function(){return Kg(this,!0)})},fue=()=>{c4(),l4()},Qc;var Hg=w(()=>{Gc=typeof Buffer==="function",H6=typeof TextDecoder==="function"?new TextDecoder("utf-8",{ignoreBOM:!0}):void 0,V6=typeof TextEncoder==="function"?new TextEncoder:void 0,Fd=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),Jg=((e)=>{let t={};return e.forEach((r,o)=>t[r]=o),t})(Fd),iue=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,Qt=String.fromCharCode.bind(String),W6=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):(e)=>new Uint8Array(Array.prototype.slice.call(e,0)),oT=typeof btoa==="function"?(e)=>btoa(e):Gc?(e)=>Buffer.from(e,"binary").toString("base64"):e4,rT=Gc?(e)=>Buffer.from(e).toString("base64"):(e)=>{let r=[];for(let o=0,n=e.length;o<n;o+=4096)r.push(Qt.apply(null,e.subarray(o,o+4096)));return oT(r.join(""))},aue=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,G6=Gc?(e)=>Buffer.from(e,"utf8").toString("base64"):V6?(e)=>rT(V6.encode(e)):(e)=>oT(t4(e)),cue=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,iT=typeof atob==="function"?(e)=>atob(X6(e)):Gc?(e)=>Buffer.from(e,"base64").toString("binary"):n4,o4=Gc?(e)=>W6(Buffer.from(e,"base64")):(e)=>W6(iT(e).split("").map((t)=>t.charCodeAt(0))),uue=Gc?(e)=>Buffer.from(e,"base64").toString("utf8"):H6?(e)=>H6.decode(o4(e)):(e)=>r4(iT(e)),Qc={version:"3.8.0",VERSION:"3.8.0",atob:iT,atobPolyfill:n4,btoa:oT,btoaPolyfill:e4,fromBase64:nT,toBase64:Wc,encode:Wc,encodeURI:Q6,encodeURL:Q6,utob:t4,btou:r4,decode:nT,isValid:due,fromUint8Array:Kg,toUint8Array:i4,extendString:c4,extendUint8Array:l4,extendBuiltins:fue}});function Li(e){if(e==="write")return"BEGIN IMMEDIATE";else if(e==="read")return"BEGIN TRANSACTION READONLY";else if(e==="deferred")return"BEGIN DEFERRED";else throw RangeError('Unknown transaction mode, supported values are "write", "read" and "deferred"')}class Yc{columns;columnTypes;rows;rowsAffected;lastInsertRowid;constructor(e,t,r,o,n){this.columns=e,this.columnTypes=t,this.rows=r,this.rowsAffected=o,this.lastInsertRowid=n}toJSON(){return{columns:this.columns,columnTypes:this.columnTypes,rows:this.rows.map(pue),rowsAffected:this.rowsAffected,lastInsertRowid:this.lastInsertRowid!==void 0?""+this.lastInsertRowid:null}}}function pue(e){return Array.prototype.map.call(e,mue)}function mue(e){if(typeof e==="bigint")return""+e;else if(e instanceof ArrayBuffer)return Qc.fromUint8Array(new Uint8Array(e));else return e}var Vn="https://github.com/libsql/libsql-client-ts#supported-urls";var Xc=w(()=>{Hg()});function d4(e){return e.scheme==="file"&&(e.path===":memory:"||e.path.startsWith(":memory:?"))}function Jd(e,t){if(typeof e!=="object")throw TypeError(`Expected client configuration as object, got ${typeof e}`);let{url:r,authToken:o,tls:n,intMode:i,concurrency:s}=e;s=Math.max(0,s||20),i??="number";let a=[];if(r===u4)r="file::memory:";let c=K6(r),u=c.scheme.toLowerCase(),d=u==="file"&&c.path===u4&&c.authority===void 0,f;if(d)f={cache:{values:["shared","private"],update:(y,S)=>a.push(`${y}=${S}`)}};else f={tls:{values:["0","1"],update:(y,S)=>n=S==="1"},authToken:{update:(y,S)=>o=S}};for(let{key:y,value:S}of c.query?.pairs??[]){if(!Object.hasOwn(f,y))throw new Ce(`Unsupported URL query parameter ${JSON.stringify(y)}`,"URL_PARAM_NOT_SUPPORTED");let x=f[y];if(x.values!==void 0&&!x.values.includes(S))throw new Ce(`Unknown value for the "${y}" query argument: ${JSON.stringify(S)}. Supported values are: [${x.values.map((_)=>'"'+_+'"').join(", ")}]`,"URL_INVALID");if(x.update!==void 0)x?.update(y,S)}let m=a.length===0?"":`?${a.join("&")}`,h=c.path+m,b;if(u==="libsql")if(n===!1){if(c.authority?.port===void 0)throw new Ce('A "libsql:" URL with ?tls=0 must specify an explicit port',"URL_INVALID");b=t?"http":"ws"}else b=t?"https":"wss";else b=u;if(b==="http"||b==="ws")n??=!1;else n??=!0;if(b!=="http"&&b!=="ws"&&b!=="https"&&b!=="wss"&&b!=="file")throw new Ce(`The client supports only "libsql:", "wss:", "ws:", "https:", "http:" and "file:" URLs, got ${JSON.stringify(c.scheme+":")}. For more information, please read ${Vn}`,"URL_SCHEME_NOT_SUPPORTED");if(i!=="number"&&i!=="bigint"&&i!=="string")throw TypeError(`Invalid value for intMode, expected "number", "bigint" or "string", got ${JSON.stringify(i)}`);if(c.fragment!==void 0)throw new Ce(`URL fragments are not supported: ${JSON.stringify("#"+c.fragment)}`,"URL_INVALID");if(d)return{scheme:"file",tls:!1,path:h,intMode:i,concurrency:s,syncUrl:e.syncUrl,syncInterval:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,fetch:e.fetch,timeout:e.timeout,authToken:void 0,encryptionKey:void 0,remoteEncryptionKey:void 0,authority:void 0};return{scheme:b,tls:n,authority:c.authority,path:h,authToken:o,intMode:i,concurrency:s,encryptionKey:e.encryptionKey,remoteEncryptionKey:e.remoteEncryptionKey,syncUrl:e.syncUrl,syncInterval:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,fetch:e.fetch,timeout:e.timeout}}var u4=":memory:";var Kd=w(()=>{gn();Fg();Xc()});var p4=ge(function(Yr){var hue=Yr&&Yr.__createBinding||(Object.create?function(e,t,r,o){if(o===void 0)o=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,o,n)}:function(e,t,r,o){if(o===void 0)o=r;e[o]=t[r]}),gue=Yr&&Yr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),f4=Yr&&Yr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null){for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))hue(t,e,r)}return gue(t,e),t};Object.defineProperty(Yr,"__esModule",{value:!0});Yr.load=Yr.currentTarget=void 0;var yue=f4(Zr("path")),bue=f4(Zr("fs"));function Sue(){let e=null;switch(process.platform){case"android":switch(process.arch){case"arm":return"android-arm-eabi";case"arm64":return"android-arm64"}e="Android";break;case"win32":switch(process.arch){case"x64":return"win32-x64-msvc";case"arm64":return"win32-arm64-msvc";case"ia32":return"win32-ia32-msvc"}e="Windows";break;case"darwin":switch(process.arch){case"x64":return"darwin-x64";case"arm64":return"darwin-arm64"}e="macOS";break;case"linux":switch(process.arch){case"x64":case"arm64":return vue()?`linux-${process.arch}-gnu`:`linux-${process.arch}-musl`;case"arm":return"linux-arm-gnueabihf"}e="Linux";break;case"freebsd":if(process.arch==="x64")return"freebsd-x64";e="FreeBSD";break}if(e)throw Error(`Neon: unsupported ${e} architecture: ${process.arch}`);throw Error(`Neon: unsupported system: ${process.platform}`)}Yr.currentTarget=Sue;function vue(){let e=process.report?.getReport();if(typeof e!=="object"||!e||!("header"in e))return!1;let t=e.header;return typeof t==="object"&&!!t&&"glibcVersionRuntime"in t}function wue(e){let t=yue.join(e,"index.node");return bue.existsSync(t)?Zr(t):null}Yr.load=wue});var g4=ge(function(LPe,h4){var m4=()=>process.platform==="linux",sT=null,xue=()=>{if(!sT)sT=m4()&&process.report?process.report.getReport():{};return sT};h4.exports={isLinux:m4,getReport:xue}});var S4=ge(function(BPe,b4){var y4=Zr("fs"),_ue=(e)=>y4.readFileSync(e,"utf-8"),Eue=(e)=>new Promise((t,r)=>{y4.readFile(e,"utf-8",(o,n)=>{if(o)r(o);else t(n)})});b4.exports={LDD_PATH:"/usr/bin/ldd",readFileSync:_ue,readFile:Eue}});var D4=ge(function(jPe,N4){var w4=Zr("child_process"),{isLinux:el,getReport:x4}=g4(),{LDD_PATH:Vg,readFile:_4,readFileSync:E4}=S4(),Wn,Gn,Bi="",I4=()=>{if(!Bi)return new Promise((e)=>{w4.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(t,r)=>{Bi=t?" ":r,e(Bi)})});return Bi},k4=()=>{if(!Bi)try{Bi=w4.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch(e){Bi=" "}return Bi},Co="glibc",A4=/GLIBC\s(\d+\.\d+)/,Gs="musl",Iue=Co.toUpperCase(),kue=Gs.toLowerCase(),Aue=(e)=>e.includes("libc.musl-")||e.includes("ld-musl-"),T4=()=>{let e=x4();if(e.header&&e.header.glibcVersionRuntime)return Co;if(Array.isArray(e.sharedObjects)){if(e.sharedObjects.some(Aue))return Gs}return null},$4=(e)=>{let[t,r]=e.split(/[\r\n]+/);if(t&&t.includes(Co))return Co;if(r&&r.includes(Gs))return Gs;return null},R4=(e)=>{if(e.includes(kue))return Gs;if(e.includes(Iue))return Co;return null},Tue=async()=>{if(Wn!==void 0)return Wn;Wn=null;try{let e=await _4(Vg);Wn=R4(e)}catch(e){}return Wn},$ue=()=>{if(Wn!==void 0)return Wn;Wn=null;try{let e=E4(Vg);Wn=R4(e)}catch(e){}return Wn},O4=async()=>{let e=null;if(el()){if(e=await Tue(),!e)e=T4();if(!e){let t=await I4();e=$4(t)}}return e},C4=()=>{let e=null;if(el()){if(e=$ue(),!e)e=T4();if(!e){let t=k4();e=$4(t)}}return e},Rue=async()=>el()&&await O4()!==Co,Oue=()=>el()&&C4()!==Co,Cue=async()=>{if(Gn!==void 0)return Gn;Gn=null;try{let t=(await _4(Vg)).match(A4);if(t)Gn=t[1]}catch(e){}return Gn},Pue=()=>{if(Gn!==void 0)return Gn;Gn=null;try{let t=E4(Vg).match(A4);if(t)Gn=t[1]}catch(e){}return Gn},P4=()=>{let e=x4();if(e.header&&e.header.glibcVersionRuntime)return e.header.glibcVersionRuntime;return null},v4=(e)=>e.trim().split(/\s+/)[1],z4=(e)=>{let[t,r,o]=e.split(/[\r\n]+/);if(t&&t.includes(Co))return v4(t);if(r&&o&&r.includes(Gs))return v4(o);return null},zue=async()=>{let e=null;if(el()){if(e=await Cue(),!e)e=P4();if(!e){let t=await I4();e=z4(t)}}return e},Nue=()=>{let e=null;if(el()){if(e=Pue(),!e)e=P4();if(!e){let t=k4();e=z4(t)}}return e};N4.exports={GLIBC:Co,MUSL:Gs,family:O4,familySync:C4,isNonGlibcLinux:Rue,isNonGlibcLinuxSync:Oue,version:zue,versionSync:Nue}});var B4=ge(function(ZPe,L4){var Due={ALLOW:0,DENY:1};L4.exports=Due});var Z4=ge(function(UPe,j4){var aT={value:"SqliteError",writable:!0,enumerable:!1,configurable:!0};function Qs(e,t,r){if(new.target!==Qs)return new Qs(e,t);if(typeof t!=="string")throw TypeError("Expected second argument to be a string");Error.call(this,e),aT.value=""+e,Object.defineProperty(this,"message",aT),Error.captureStackTrace(this,Qs),this.code=t,this.rawCode=r}Object.setPrototypeOf(Qs,Error);Object.setPrototypeOf(Qs.prototype,Error.prototype);Object.defineProperty(Qs.prototype,"name",aT);j4.exports=Qs});var V4=ge(function(qPe,Wg){var __dirname="/home/runner/work/brains/brains/node_modules/libsql",{load:Lue,currentTarget:Bue}=p4(),{familySync:U4,GLIBC:jue,MUSL:Zue}=D4();function Uue(){if(process.env.LIBSQL_JS_DEV)return Lue(__dirname);let e=Bue();if(U4()==jue)switch(e){case"linux-x64-musl":e="linux-x64-gnu";break;case"linux-arm64-musl":e="linux-arm64-gnu";break}if(e==="linux-arm-gnueabihf"&&U4()==Zue)e="linux-arm-musleabihf";return Zr(`@libsql/${e}`)}var{databaseOpen:que,databaseOpenWithSync:Mue,databaseInTransaction:Fue,databaseInterrupt:Jue,databaseClose:Kue,databaseSyncSync:Hue,databaseSyncUntilSync:Vue,databaseExecSync:Wue,databasePrepareSync:Gue,databaseDefaultSafeIntegers:Que,databaseAuthorizer:Yue,databaseLoadExtension:Xue,databaseMaxWriteReplicationIndex:ede,statementRaw:tde,statementIsReader:rde,statementGet:q4,statementRun:M4,statementInterrupt:nde,statementRowsSync:F4,statementColumns:ode,statementSafeIntegers:ide,rowsNext:sde}=Uue(),ade=B4(),J4=Z4();function tl(e){if(e.libsqlError)return new J4(e.message,e.code,e.rawCode);return e}class K4{constructor(e,t){let r=t?.encryptionCipher??"aes256cbc";if(t&&t.syncUrl){var o="";if(t.syncAuth)console.warn("Warning: The `syncAuth` option is deprecated, please use `authToken` option instead."),o=t.syncAuth;else if(t.authToken)o=t.authToken;let i=t?.encryptionKey??"",s=t?.syncPeriod??0,a=t?.readYourWrites??!0,c=t?.offline??!1,u=t?.remoteEncryptionKey??"";this.db=Mue(e,t.syncUrl,o,r,i,s,a,c,u)}else{let i=t?.authToken??"",s=t?.encryptionKey??"",a=t?.timeout??0,c=t?.remoteEncryptionKey??"";this.db=que(e,i,r,s,a,c)}this.memory=e===":memory:",this.readonly=!1,this.name="",this.open=!0;let n=this.db;Object.defineProperties(this,{inTransaction:{get(){return Fue(n)}}})}sync(){return Hue.call(this.db)}syncUntil(e){return Vue.call(this.db,e)}prepare(e){try{let t=Gue.call(this.db,e);return new H4(t)}catch(t){throw tl(t)}}transaction(e){if(typeof e!=="function")throw TypeError("Expected first argument to be a function");let t=this,r=(n)=>(...i)=>{t.exec("BEGIN "+n);try{let s=e(...i);return t.exec("COMMIT"),s}catch(s){throw t.exec("ROLLBACK"),s}},o={default:{value:r("")},deferred:{value:r("DEFERRED")},immediate:{value:r("IMMEDIATE")},exclusive:{value:r("EXCLUSIVE")},database:{value:this,enumerable:!0}};return Object.defineProperties(o.default.value,o),Object.defineProperties(o.deferred.value,o),Object.defineProperties(o.immediate.value,o),Object.defineProperties(o.exclusive.value,o),o.default.value}pragma(e,t){if(t==null)t={};if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof t!=="object")throw TypeError("Expected second argument to be an options object");let r=t.simple,o=this.prepare(`PRAGMA ${e}`,this,!0);return r?o.pluck().get():o.all()}backup(e,t){throw Error("not implemented")}serialize(e){throw Error("not implemented")}function(e,t,r){if(t==null)t={};if(typeof t==="function")r=t,t={};if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof r!=="function")throw TypeError("Expected last argument to be a function");if(typeof t!=="object")throw TypeError("Expected second argument to be an options object");if(!e)throw TypeError("User-defined function name cannot be an empty string");throw Error("not implemented")}aggregate(e,t){if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof t!=="object"||t===null)throw TypeError("Expected second argument to be an options object");if(!e)throw TypeError("User-defined function name cannot be an empty string");throw Error("not implemented")}table(e,t){if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(!e)throw TypeError("Virtual table module name cannot be an empty string");throw Error("not implemented")}authorizer(e){Yue.call(this.db,e)}loadExtension(...e){Xue.call(this.db,...e)}maxWriteReplicationIndex(){return ede.call(this.db)}exec(e){try{Wue.call(this.db,e)}catch(t){throw tl(t)}}interrupt(){Jue.call(this.db)}close(){Kue.call(this.db),this.open=!1}defaultSafeIntegers(e){return Que.call(this.db,e??!0),this}unsafeMode(...e){throw Error("not implemented")}}class H4{constructor(e){this.stmt=e,this.pluckMode=!1}raw(e){return tde.call(this.stmt,e??!0),this}pluck(e){return this.pluckMode=e??!0,this}get reader(){return rde.call(this.stmt)}run(...e){try{if(e.length==1&&typeof e[0]==="object")return M4.call(this.stmt,e[0]);else return M4.call(this.stmt,e.flat())}catch(t){throw tl(t)}}get(...e){try{if(e.length==1&&typeof e[0]==="object")return q4.call(this.stmt,e[0]);else return q4.call(this.stmt,e.flat())}catch(t){throw tl(t)}}iterate(...e){var t=void 0;if(e.length==1&&typeof e[0]==="object")t=F4.call(this.stmt,e[0]);else t=F4.call(this.stmt,e.flat());return{nextRows:Array(100),nextRowIndex:100,next(){try{if(this.nextRowIndex===100)sde.call(t,this.nextRows),this.nextRowIndex=0;let o=this.nextRows[this.nextRowIndex];if(this.nextRows[this.nextRowIndex]=void 0,!o)return{done:!0};return this.nextRowIndex++,{value:o,done:!1}}catch(o){throw tl(o)}},[Symbol.iterator](){return this}}}all(...e){try{let t=[];for(let r of this.iterate(...e))if(this.pluckMode)t.push(r[Object.keys(r)[0]]);else t.push(r);return t}catch(t){throw tl(t)}}interrupt(){nde.call(this.stmt)}columns(){return ode.call(this.stmt)}safeIntegers(e){return ide.call(this.stmt,e??!0),this}}Wg.exports=K4;Wg.exports.Authorization=ade;Wg.exports.SqliteError=J4});import{Buffer as G4}from"buffer";function Q4(e){if(e.scheme!=="file")throw new Ce(`URL scheme ${JSON.stringify(e.scheme+":")} is not supported by the local sqlite3 client. For more information, please read ${Vn}`,"URL_SCHEME_NOT_SUPPORTED");let t=e.authority;if(t!==void 0){let s=t.host.toLowerCase();if(s!==""&&s!=="localhost")throw new Ce(`Invalid host in file URL: ${JSON.stringify(t.host)}. A "file:" URL with an absolute path should start with one slash ("file:/absolute/path.db") or with three slashes ("file:///absolute/path.db"). For more information, please read ${Vn}`,"URL_INVALID");if(t.port!==void 0)throw new Ce("File URL cannot have a port","URL_INVALID");if(t.userinfo!==void 0)throw new Ce("File URL cannot have username and password","URL_INVALID")}let r=d4(e);if(r&&e.syncUrl)throw new Ce(`Embedded replica must use file for local db but URI with in-memory mode were provided instead: ${e.path}`,"URL_INVALID");let o=e.path;if(r)o=`${e.scheme}:${e.path}`;let n={authToken:e.authToken,encryptionKey:e.encryptionKey,remoteEncryptionKey:e.remoteEncryptionKey,syncUrl:e.syncUrl,syncPeriod:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,timeout:e.timeout},i=new Hd.default(o,n);return Pt(i,"SELECT 1 AS checkThatTheDatabaseCanBeOpened",e.intMode),new Y4(o,n,i,e.intMode)}class Y4{#e;#t;#r;#n;closed;protocol;constructor(e,t,r,o){this.#e=e,this.#t=t,this.#r=r,this.#n=o,this.closed=!1,this.protocol="file"}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.#o(),Pt(this.#i(),r,this.#n)}async batch(e,t="deferred"){this.#o();let r=this.#i();try{Pt(r,Li(t),this.#n);let o=[];for(let n=0;n<e.length;n++)try{if(!r.inTransaction)throw new Gt("The transaction has been rolled back",n,"TRANSACTION_CLOSED");let i=e[n],s=Array.isArray(i)?{sql:i[0],args:i[1]||[]}:i;o.push(Pt(r,s,this.#n))}catch(i){if(i instanceof Gt)throw i;if(i instanceof Ce)throw new Gt(i.message,n,i.code,i.extendedCode,i.rawCode,i.cause instanceof Error?i.cause:void 0);throw i}return Pt(r,"COMMIT",this.#n),o}finally{if(r.inTransaction)Pt(r,"ROLLBACK",this.#n)}}async migrate(e){this.#o();let t=this.#i();try{Pt(t,"PRAGMA foreign_keys=off",this.#n),Pt(t,Li("deferred"),this.#n);let r=[];for(let o=0;o<e.length;o++)try{if(!t.inTransaction)throw new Gt("The transaction has been rolled back",o,"TRANSACTION_CLOSED");r.push(Pt(t,e[o],this.#n))}catch(n){if(n instanceof Gt)throw n;if(n instanceof Ce)throw new Gt(n.message,o,n.code,n.extendedCode,n.rawCode,n.cause instanceof Error?n.cause:void 0);throw n}return Pt(t,"COMMIT",this.#n),r}finally{if(t.inTransaction)Pt(t,"ROLLBACK",this.#n);Pt(t,"PRAGMA foreign_keys=on",this.#n)}}async transaction(e="write"){let t=this.#i();return Pt(t,Li(e),this.#n),this.#r=null,new X4(t,this.#n)}async executeMultiple(e){this.#o();let t=this.#i();try{return eq(t,e)}finally{if(t.inTransaction)Pt(t,"ROLLBACK",this.#n)}}async sync(){this.#o();let e=await this.#i().sync();return{frames_synced:e.frames_synced,frame_no:e.frame_no}}async reconnect(){try{if(!this.closed&&this.#r!==null)this.#r.close()}finally{this.#r=new Hd.default(this.#e,this.#t),this.closed=!1}}close(){if(this.closed=!0,this.#r!==null)this.#r.close(),this.#r=null}#o(){if(this.closed)throw new Ce("The client is closed","CLIENT_CLOSED")}#i(){if(this.#r===null)this.#r=new Hd.default(this.#e,this.#t);return this.#r}}class X4{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.#r(),Pt(this.#e,r,this.#t)}async batch(e){let t=[];for(let r=0;r<e.length;r++)try{this.#r();let o=e[r],n=Array.isArray(o)?{sql:o[0],args:o[1]||[]}:o;t.push(Pt(this.#e,n,this.#t))}catch(o){if(o instanceof Gt)throw o;if(o instanceof Ce)throw new Gt(o.message,r,o.code,o.extendedCode,o.rawCode,o.cause instanceof Error?o.cause:void 0);throw o}return t}async executeMultiple(e){return this.#r(),eq(this.#e,e)}async rollback(){if(!this.#e.open)return;this.#r(),Pt(this.#e,"ROLLBACK",this.#t)}async commit(){this.#r(),Pt(this.#e,"COMMIT",this.#t)}close(){if(this.#e.inTransaction)Pt(this.#e,"ROLLBACK",this.#t)}get closed(){return!this.#e.inTransaction}#r(){if(this.closed)throw new Ce("The transaction is closed","TRANSACTION_CLOSED")}}function Pt(e,t,r){let o,n;if(typeof t==="string")o=t,n=[];else if(o=t.sql,Array.isArray(t.args))n=t.args.map((i)=>W4(i,r));else{n={};for(let i in t.args){let s=i[0]==="@"||i[0]==="$"||i[0]===":"?i.substring(1):i;n[s]=W4(t.args[i],r)}}try{let i=e.prepare(o);i.safeIntegers(!0);let s=!0;try{i.raw(!0)}catch{s=!1}if(s){let a=Array.from(i.columns().map((m)=>m.name)),c=Array.from(i.columns().map((m)=>m.type??"")),u=i.all(n).map((m)=>cde(m,a,r)),d=0,f=void 0;return new Yc(a,c,u,0,void 0)}else{let a=i.run(n),c=a.changes,u=BigInt(a.lastInsertRowid);return new Yc([],[],[],c,u)}}catch(i){throw tq(i)}}function cde(e,t,r){let o={};Object.defineProperty(o,"length",{value:e.length});for(let n=0;n<e.length;++n){let i=lde(e[n],r);Object.defineProperty(o,n,{value:i});let s=t[n];if(!Object.hasOwn(o,s))Object.defineProperty(o,s,{value:i,enumerable:!0,configurable:!0,writable:!0})}return o}function lde(e,t){if(typeof e==="bigint")if(t==="number"){if(e<ude||e>dde)throw RangeError("Received integer which cannot be safely represented as a JavaScript number");return Number(e)}else if(t==="bigint")return e;else if(t==="string")return""+e;else throw Error("Invalid value for IntMode");else if(e instanceof G4)return e.buffer;return e}function W4(e,t){if(typeof e==="number"){if(!Number.isFinite(e))throw RangeError("Only finite numbers (not Infinity or NaN) can be passed as arguments");return e}else if(typeof e==="bigint"){if(e<fde||e>pde)throw RangeError("bigint is too large to be represented as a 64-bit integer and passed as argument");return e}else if(typeof e==="boolean")switch(t){case"bigint":return e?1n:0n;case"string":return e?"1":"0";default:return e?1:0}else if(e instanceof ArrayBuffer)return G4.from(e);else if(e instanceof Date)return e.valueOf();else if(e===void 0)throw TypeError("undefined cannot be passed as argument to the database");else return e}function eq(e,t){try{e.exec(t)}catch(r){throw tq(r)}}function tq(e){if(e instanceof Hd.default.SqliteError){let t=e.code,r=mde(e.rawCode);return new Ce(e.message,r,t,e.rawCode,e)}return e}function mde(e){if(e===void 0)return"SQLITE_UNKNOWN";let t=e&255;return hde[t]??`SQLITE_UNKNOWN_${t.toString()}`}var Hd,ude,dde=9007199254740991n,fde,pde=9223372036854775807n,hde;var rq=w(()=>{gn();Kd();Xc();Hd=Rl(V4(),1);gn();ude=-9007199254740991n;fde=-9223372036854775808n;hde={1:"SQLITE_ERROR",2:"SQLITE_INTERNAL",3:"SQLITE_PERM",4:"SQLITE_ABORT",5:"SQLITE_BUSY",6:"SQLITE_LOCKED",7:"SQLITE_NOMEM",8:"SQLITE_READONLY",9:"SQLITE_INTERRUPT",10:"SQLITE_IOERR",11:"SQLITE_CORRUPT",12:"SQLITE_NOTFOUND",13:"SQLITE_FULL",14:"SQLITE_CANTOPEN",15:"SQLITE_PROTOCOL",16:"SQLITE_EMPTY",17:"SQLITE_SCHEMA",18:"SQLITE_TOOBIG",19:"SQLITE_CONSTRAINT",20:"SQLITE_MISMATCH",21:"SQLITE_MISUSE",22:"SQLITE_NOLFS",23:"SQLITE_AUTH",24:"SQLITE_FORMAT",25:"SQLITE_RANGE",26:"SQLITE_NOTADB",27:"SQLITE_NOTICE",28:"SQLITE_WARNING"}});var ji;var cT=w(()=>{if(typeof WebSocket<"u")ji=WebSocket;else if(typeof global<"u")ji=global.WebSocket;else if(typeof window<"u")ji=window.WebSocket;else if(typeof self<"u")ji=self.WebSocket});class rl{constructor(){this.intMode="number"}intMode}var We,Pe,Vd,xt,Wd,nl,Ys,yn,or,Qn;var _t=w(()=>{We=class We extends Error{constructor(e){super(e);this.name="ClientError"}};Pe=class Pe extends We{constructor(e){super(e);this.name="ProtoError"}};Vd=class Vd extends We{code;proto;constructor(e,t){super(e);this.name="ResponseError",this.code=t.code,this.proto=t,this.stack=void 0}};xt=class xt extends We{constructor(e,t){if(t!==void 0){super(`${e}: ${t}`);this.cause=t}else super(e);this.name="ClosedError"}};Wd=class Wd extends We{constructor(e){super(e);this.name="WebSocketUnsupportedError"}};nl=class nl extends We{constructor(e){super(e);this.name="WebSocketError"}};Ys=class Ys extends We{status;constructor(e,t){super(e);this.status=t,this.name="HttpServerError"}};yn=class yn extends We{constructor(e){super(e);this.name="ProtocolVersionError"}};or=class or extends We{constructor(e){super(e);this.name="InternalError"}};Qn=class Qn extends We{constructor(e){super(e);this.name="MisuseError"}}});function Ar(e){if(typeof e==="string")return e;throw ol(e,"string")}function Lr(e){if(e===null||e===void 0)return;else if(typeof e==="string")return e;throw ol(e,"string or null")}function Po(e){if(typeof e==="number")return e;throw ol(e,"number")}function Zi(e){if(typeof e==="boolean")return e;throw ol(e,"boolean")}function Gd(e){if(Array.isArray(e))return e;throw ol(e,"array")}function kt(e){if(e!==null&&typeof e==="object"&&!Array.isArray(e))return e;throw ol(e,"object")}function bn(e,t){return Gd(e).map((r)=>t(kt(r)))}function ol(e,t){if(e===void 0)return new Pe(`Expected ${t}, but the property was missing`);let r=typeof e;if(e===null)r="null";else if(Array.isArray(e))r="array";return new Pe(`Expected ${t}, received ${r}`)}function Xs(e,t){return t(kt(e))}var il=w(()=>{_t()});class nq{#e;#t;constructor(e){this.#e=e,this.#t=!1}begin(){this.#e.push("{"),this.#t=!0}end(){this.#e.push("}"),this.#t=!1}#r(e){if(this.#t)this.#e.push('"'),this.#t=!1;else this.#e.push(',"');this.#e.push(e),this.#e.push('":')}string(e,t){this.#r(e),this.#e.push(JSON.stringify(t))}stringRaw(e,t){this.#r(e),this.#e.push('"'),this.#e.push(t),this.#e.push('"')}number(e,t){this.#r(e),this.#e.push(""+t)}boolean(e,t){this.#r(e),this.#e.push(t?"true":"false")}object(e,t,r){this.#r(e),this.begin(),r(this,t),this.end()}arrayObjects(e,t,r){this.#r(e),this.#e.push("[");for(let o=0;o<t.length;++o){if(o!==0)this.#e.push(",");this.begin(),r(this,t[o]),this.end()}this.#e.push("]")}}function Qd(e,t){let r=[],o=new nq(r);return o.begin(),t(o,e),o.end(),r.join("")}var ea=0,Yd=1,Xd=2,oq=5;class iq{#e;#t;#r;constructor(e){this.#e=e,this.#t=new DataView(e.buffer,e.byteOffset,e.byteLength),this.#r=0}varint(){let e=0;for(let t=0;;t+=7){let r=this.#e[this.#r++];if(e|=(r&127)<<t,!(r&128))break}return e}varintBig(){let e=0n;for(let t=0n;;t+=7n){let r=this.#e[this.#r++];if(e|=BigInt(r&127)<<t,!(r&128))break}return e}bytes(e){let t=new Uint8Array(this.#e.buffer,this.#e.byteOffset+this.#r,e);return this.#r+=e,t}double(){let e=this.#t.getFloat64(this.#r,!0);return this.#r+=8,e}skipVarint(){for(;;)if(!(this.#e[this.#r++]&128))break}skip(e){this.#r+=e}eof(){return this.#r>=this.#e.byteLength}}class sq{#e;#t;constructor(e){this.#e=e,this.#t=-1}setup(e){this.#t=e}#r(e){if(this.#t!==e)throw new Pe(`Expected wire type ${e}, got ${this.#t}`);this.#t=-1}bytes(){this.#r(Xd);let e=this.#e.varint();return this.#e.bytes(e)}string(){return new TextDecoder().decode(this.bytes())}message(e){return Ui(this.bytes(),e)}int32(){return this.#r(ea),this.#e.varint()}uint32(){return this.int32()}bool(){return this.int32()!==0}uint64(){return this.#r(ea),this.#e.varintBig()}sint64(){let e=this.uint64();return e>>1n^-(e&1n)}double(){return this.#r(Yd),this.#e.double()}maybeSkip(){if(this.#t<0)return;else if(this.#t===ea)this.#e.skipVarint();else if(this.#t===Yd)this.#e.skip(8);else if(this.#t===Xd){let e=this.#e.varint();this.#e.skip(e)}else if(this.#t===oq)this.#e.skip(4);else throw new Pe(`Unexpected wire type ${this.#t}`);this.#t=-1}}function Ui(e,t){let r=new iq(e),o=new sq(r),n=t.default();while(!r.eof()){let i=r.varint(),s=i>>3,a=i&7;o.setup(a);let c=t[s];if(c!==void 0){let u=c(o,n);if(u!==void 0)n=u}o.maybeSkip()}return n}var lT=w(()=>{_t()});class uT{#e;#t;#r;#n;constructor(){this.#e=new ArrayBuffer(256),this.#t=new Uint8Array(this.#e),this.#r=new DataView(this.#e),this.#n=0}#o(e){if(this.#n+e<=this.#e.byteLength)return;let t=this.#e.byteLength;while(t<this.#n+e)t*=2;let r=new ArrayBuffer(t),o=new Uint8Array(r),n=new DataView(r);o.set(new Uint8Array(this.#e,0,this.#n)),this.#e=r,this.#t=o,this.#r=n}#i(e){this.#o(5),e=0|e;do{let t=e&127;e>>>=7,t|=e?128:0,this.#t[this.#n++]=t}while(e)}#a(e){this.#o(10),e=e&0xffffffffffffffffn;do{let t=Number(e&0x7fn);e>>=7n,t|=e?128:0,this.#t[this.#n++]=t}while(e)}#s(e,t){this.#i(e<<3|t)}bytes(e,t){this.#s(e,Xd),this.#i(t.byteLength),this.#o(t.byteLength),this.#t.set(t,this.#n),this.#n+=t.byteLength}string(e,t){this.bytes(e,new TextEncoder().encode(t))}message(e,t,r){let o=new uT;r(o,t),this.bytes(e,o.data())}int32(e,t){this.#s(e,ea),this.#i(t)}uint32(e,t){this.int32(e,t)}bool(e,t){this.int32(e,t?1:0)}sint64(e,t){this.#s(e,ea),this.#a(t<<1n^t>>63n)}double(e,t){this.#s(e,Yd),this.#o(8),this.#r.setFloat64(this.#n,t,!0),this.#n+=8}data(){return new Uint8Array(this.#e,0,this.#n)}}function ef(e,t){let r=new uT;return t(r,e),r.data()}var aq=()=>{};var dT=w(()=>{il();lT();aq()});class qi{#e;#t;constructor(){this.#e=new Set,this.#t=new Set}alloc(){for(let t of this.#t){if(this.#t.delete(t),this.#e.add(t),!this.#e.has(this.#e.size-1))this.#t.add(this.#e.size-1);return t}let e=this.#e.size;return this.#e.add(e),e}free(e){if(!this.#e.delete(e))throw new or("Freeing an id that is not allocated");if(this.#t.delete(this.#e.size),e<this.#e.size)this.#t.add(e)}}var fT=w(()=>{_t()});function Ke(e,t){throw new or(t)}var Xr=w(()=>{_t()});function sl(e){if(e===null)return null;else if(typeof e==="string")return e;else if(typeof e==="number"){if(!Number.isFinite(e))throw RangeError("Only finite numbers (not Infinity or NaN) can be passed as arguments");return e}else if(typeof e==="bigint"){if(e<yde||e>bde)throw RangeError("This bigint value is too large to be represented as a 64-bit integer and passed as argument");return e}else if(typeof e==="boolean")return e?1n:0n;else if(e instanceof ArrayBuffer)return new Uint8Array(e);else if(e instanceof Uint8Array)return e;else if(e instanceof Date)return+e.valueOf();else if(typeof e==="object")return""+e.toString();else throw TypeError("Unsupported type of value")}function pT(e,t){if(e===null)return null;else if(typeof e==="number")return e;else if(typeof e==="string")return e;else if(typeof e==="bigint")if(t==="number"){let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError("Received integer which is too large to be safely represented as a JavaScript number");return r}else if(t==="bigint")return e;else if(t==="string")return""+e;else throw new Qn("Invalid value for IntMode");else if(e instanceof Uint8Array)return e.slice().buffer;else if(e===void 0)throw new Pe("Received unrecognized type of Value");else throw Ke(e,"Impossible type of Value")}var yde,bde=9223372036854775807n;var mT=w(()=>{_t();Xr();yde=-9223372036854775808n});function ta(e){return{affectedRowCount:e.affectedRowCount,lastInsertRowid:e.lastInsertRowid,columnNames:e.cols.map((t)=>t.name),columnDecltypes:e.cols.map((t)=>t.decltype)}}function Qg(e,t){let r=ta(e),o=e.rows.map((n)=>cq(r.columnNames,n,t));return{...r,rows:o}}function Yg(e,t){let r=ta(e),o;if(e.rows.length>0)o=cq(r.columnNames,e.rows[0],t);return{...r,row:o}}function Xg(e,t){let r=ta(e),o;if(e.rows.length>0&&r.columnNames.length>0)o=pT(e.rows[0][0],t);return{...r,value:o}}function cq(e,t,r){let o={};Object.defineProperty(o,"length",{value:t.length});for(let n=0;n<t.length;++n){let i=pT(t[n],r);Object.defineProperty(o,n,{value:i});let s=e[n];if(s!==void 0&&!Object.hasOwn(o,s))Object.defineProperty(o,s,{value:i,enumerable:!0,configurable:!0,writable:!0})}return o}function zo(e){return new Vd(e.message,e)}var tf=w(()=>{_t();mT()});class ra{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=void 0}_getSqlId(e){if(this.#e!==e)throw new Qn("Attempted to use SQL text opened with other object");else if(this.#r!==void 0)throw new xt("SQL text is closed",this.#r);return this.#t}close(){this._setClosed(new We("SQL text was manually closed"))}_setClosed(e){if(this.#r===void 0)this.#r=e,this.#e._closeSql(this.#t)}get closed(){return this.#r!==void 0}}function rf(e,t){if(t instanceof ra)return{sqlId:t._getSqlId(e)};else return{sql:""+t}}var al=w(()=>{_t()});class Mi{#e;#t;constructor(){this.#e=[],this.#t=[]}get length(){return this.#e.length+this.#t.length}push(e){this.#e.push(e)}shift(){if(this.#t.length===0&&this.#e.length>0)this.#t=this.#e.reverse(),this.#e=[];return this.#t.pop()}first(){return this.#t.length!==0?this.#t[this.#t.length-1]:this.#e[0]}}class nf{sql;_args;_namedArgs;constructor(e){this.sql=e,this._args=[],this._namedArgs=new Map}bindIndexes(e){this._args.length=0;for(let t of e)this._args.push(sl(t));return this}bindIndex(e,t){if(e!==(e|0)||e<=0)throw RangeError("Index of a positional argument must be positive integer");while(this._args.length<e)this._args.push(null);return this._args[e-1]=sl(t),this}bindName(e,t){return this._namedArgs.set(e,sl(t)),this}unbindAll(){return this._args.length=0,this._namedArgs.clear(),this}}function ey(e,t,r){let o,n=[],i=[];if(t instanceof nf){o=t.sql,n=t._args;for(let[c,u]of t._namedArgs.entries())i.push({name:c,value:u})}else if(Array.isArray(t))if(o=t[0],Array.isArray(t[1]))n=t[1].map((c)=>sl(c));else i=Object.entries(t[1]).map(([c,u])=>({name:c,value:sl(u)}));else o=t;let{sql:s,sqlId:a}=rf(e,o);return{sql:s,sqlId:a,args:n,namedArgs:i,wantRows:r}}var ty=w(()=>{al();mT()});class ry{_stream;#e;_steps;#t;constructor(e,t){this._stream=e,this.#e=t,this._steps=[],this.#t=!1}step(){return new hT(this)}execute(){if(this.#t)throw new Qn("This batch has already been executed");this.#t=!0;let e={steps:this._steps.map((t)=>t.proto)};if(this.#e)return vde(this._stream,this._steps,e);else return Sde(this._stream,this._steps,e)}}function Sde(e,t,r){return e._batch(r).then((o)=>{for(let n=0;n<t.length;++n){let i=o.stepResults.get(n),s=o.stepErrors.get(n);t[n].callback(i,s)}})}async function vde(e,t,r){let o=await e._openCursor(r);try{let n=0,i=void 0,s=[];for(;;){let a=await o.next();if(a===void 0)break;if(a.type==="step_begin"){if(a.step<n||a.step>=t.length)throw new Pe("Server produced StepBeginEntry for unexpected step");else if(i!==void 0)throw new Pe("Server produced StepBeginEntry before terminating previous step");for(let c=n;c<a.step;++c)t[c].callback(void 0,void 0);n=a.step+1,i=a,s=[]}else if(a.type==="step_end"){if(i===void 0)throw new Pe("Server produced StepEndEntry but no step is active");let c={cols:i.cols,rows:s,affectedRowCount:a.affectedRowCount,lastInsertRowid:a.lastInsertRowid};t[i.step].callback(c,void 0),i=void 0,s=[]}else if(a.type==="step_error"){if(i===void 0){if(a.step>=t.length)throw new Pe("Server produced StepErrorEntry for unexpected step");for(let c=n;c<a.step;++c)t[c].callback(void 0,void 0)}else{if(a.step!==i.step)throw new Pe("Server produced StepErrorEntry for unexpected step");i=void 0,s=[]}t[a.step].callback(void 0,a.error),n=a.step+1}else if(a.type==="row"){if(i===void 0)throw new Pe("Server produced RowEntry but no step is active");s.push(a.row)}else if(a.type==="error")throw zo(a.error);else if(a.type==="none")throw new Pe("Server produced unrecognized CursorEntry");else throw Ke(a,"Impossible CursorEntry")}if(i!==void 0)throw new Pe("Server closed Cursor before terminating active step");for(let a=n;a<t.length;++a)t[a].callback(void 0,void 0)}finally{o.close()}}class hT{_batch;#e;_index;constructor(e){this._batch=e,this.#e=[],this._index=void 0}condition(e){return this.#e.push(e._proto),this}query(e){return this.#t(e,!0,Qg)}queryRow(e){return this.#t(e,!0,Yg)}queryValue(e){return this.#t(e,!0,Xg)}run(e){return this.#t(e,!1,ta)}#t(e,t,r){if(this._index!==void 0)throw new Qn("This BatchStep has already been added to the batch");let o=ey(this._batch._stream._sqlOwner(),e,t),n;if(this.#e.length===0)n=void 0;else if(this.#e.length===1)n=this.#e[0];else n={type:"and",conds:this.#e.slice()};let i={stmt:o,condition:n};return new Promise((s,a)=>{let c=(u,d)=>{if(u!==void 0&&d!==void 0)a(new Pe("Server returned both result and error"));else if(d!==void 0)a(zo(d));else if(u!==void 0)s(r(u,this._batch._stream.intMode));else s(void 0)};this._index=this._batch._steps.length,this._batch._steps.push({proto:i,callback:c})})}}class dt{_batch;_proto;constructor(e,t){this._batch=e,this._proto=t}static ok(e){return new dt(e._batch,{type:"ok",step:lq(e)})}static error(e){return new dt(e._batch,{type:"error",step:lq(e)})}static not(e){return new dt(e._batch,{type:"not",cond:e._proto})}static and(e,t){for(let r of t)uq(e,r);return new dt(e,{type:"and",conds:t.map((r)=>r._proto)})}static or(e,t){for(let r of t)uq(e,r);return new dt(e,{type:"or",conds:t.map((r)=>r._proto)})}static isAutocommit(e){return e._stream.client()._ensureVersion(3,"BatchCond.isAutocommit()"),new dt(e,{type:"is_autocommit"})}}function lq(e){if(e._index===void 0)throw new Qn("Cannot add a condition referencing a step that has not been added to the batch");return e._index}function uq(e,t){if(t._batch!==e)throw new Qn("Cannot mix BatchCond objects for different Batch objects")}var gT=w(()=>{_t();tf();ty();Xr()});function dq(e){return{paramNames:e.params.map((t)=>t.name),columns:e.cols,isExplain:e.isExplain,isReadonly:e.isReadonly}}class cl{constructor(e){this.intMode=e}query(e){return this.#e(e,!0,Qg)}queryRow(e){return this.#e(e,!0,Yg)}queryValue(e){return this.#e(e,!0,Xg)}run(e){return this.#e(e,!1,ta)}#e(e,t,r){let o=ey(this._sqlOwner(),e,t);return this._execute(o).then((n)=>r(n,this.intMode))}batch(e=!1){return new ry(this,e)}describe(e){let t=rf(this._sqlOwner(),e);return this._describe(t).then(dq)}sequence(e){let t=rf(this._sqlOwner(),e);return this._sequence(t)}intMode}var ny=w(()=>{gT();tf();al();ty()});class of{}var wde=1000,xde=10,yT;var fq=w(()=>{_t();yT=class yT extends of{#e;#t;#r;#n;#o;#i;#a;constructor(e,t,r){super();this.#e=e,this.#t=t,this.#r=r,this.#n=new Mi,this.#o=new Mi,this.#i=void 0,this.#a=!1}async next(){for(;;){if(this.#i!==void 0)throw new xt("Cursor is closed",this.#i);while(!this.#a&&this.#o.length<xde)this.#o.push(this.#s());let e=this.#n.shift();if(this.#a||e!==void 0)return e;await this.#o.shift().then((t)=>{if(t===void 0)return;for(let r of t.entries)this.#n.push(r);this.#a||=t.done})}}#s(){return this.#t._sendCursorRequest(this,{type:"fetch_cursor",cursorId:this.#r,maxCount:wde}).then((e)=>e,(e)=>{this._setClosed(e);return})}_setClosed(e){if(this.#i!==void 0)return;this.#i=e,this.#t._sendCursorRequest(this,{type:"close_cursor",cursorId:this.#r}).catch(()=>{return}),this.#t._cursorClosed(this)}close(){this._setClosed(new We("Cursor was manually closed"))}get closed(){return this.#i!==void 0}}});var sf;var bT=w(()=>{_t();ny();fq();sf=class sf extends cl{#e;#t;#r;#n;#o;#i;static open(e){let t=e._streamIdAlloc.alloc(),r=new sf(e,t),o=()=>{return},n=(s)=>r.#l(s),i={type:"open_stream",streamId:t};return e._sendRequest(i,{responseCallback:o,errorCallback:n}),r}constructor(e,t){super(e.intMode);this.#e=e,this.#t=t,this.#r=new Mi,this.#n=void 0,this.#o=!1,this.#i=void 0}client(){return this.#e}_sqlOwner(){return this.#e}_execute(e){return this.#a({type:"execute",streamId:this.#t,stmt:e}).then((t)=>t.result)}_batch(e){return this.#a({type:"batch",streamId:this.#t,batch:e}).then((t)=>t.result)}_describe(e){return this.#e._ensureVersion(2,"describe()"),this.#a({type:"describe",streamId:this.#t,sql:e.sql,sqlId:e.sqlId}).then((t)=>t.result)}_sequence(e){return this.#e._ensureVersion(2,"sequence()"),this.#a({type:"sequence",streamId:this.#t,sql:e.sql,sqlId:e.sqlId}).then((t)=>{return})}getAutocommit(){return this.#e._ensureVersion(3,"getAutocommit()"),this.#a({type:"get_autocommit",streamId:this.#t}).then((e)=>e.isAutocommit)}#a(e){return new Promise((t,r)=>{this.#s({type:"request",request:e,responseCallback:t,errorCallback:r})})}_openCursor(e){return this.#e._ensureVersion(3,"cursor"),new Promise((t,r)=>{this.#s({type:"cursor",batch:e,cursorCallback:t,errorCallback:r})})}_sendCursorRequest(e,t){if(e!==this.#n)throw new or("Cursor not associated with the stream attempted to execute a request");return new Promise((r,o)=>{if(this.#i!==void 0)o(new xt("Stream is closed",this.#i));else this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})})}_cursorClosed(e){if(e!==this.#n)throw new or("Cursor was closed, but it was not associated with the stream");this.#n=void 0,this.#c()}#s(e){if(this.#i!==void 0)e.errorCallback(new xt("Stream is closed",this.#i));else if(this.#o)e.errorCallback(new xt("Stream is closing",void 0));else this.#r.push(e),this.#c()}#c(){for(;;){let e=this.#r.first();if(e===void 0&&this.#n===void 0&&this.#o){this.#l(new We("Stream was gracefully closed"));break}else if(e?.type==="request"&&this.#n===void 0){let{request:t,responseCallback:r,errorCallback:o}=e;this.#r.shift(),this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})}else if(e?.type==="cursor"&&this.#n===void 0){let{batch:t,cursorCallback:r}=e;this.#r.shift();let o=this.#e._cursorIdAlloc.alloc(),n=new yT(this.#e,this,o),i={type:"open_cursor",streamId:this.#t,cursorId:o,batch:t},s=()=>{return},a=(c)=>n._setClosed(c);this.#e._sendRequest(i,{responseCallback:s,errorCallback:a}),this.#n=n,r(n)}else break}}#l(e){if(this.#i!==void 0)return;if(this.#i=e,this.#n!==void 0)this.#n._setClosed(e);for(;;){let n=this.#r.shift();if(n!==void 0)n.errorCallback(e);else break}let t={type:"close_stream",streamId:this.#t},r=()=>this.#e._streamIdAlloc.free(this.#t),o=()=>{return};this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})}close(){this.#l(new We("Stream was manually closed"))}closeGracefully(){this.#o=!0,this.#c()}get closed(){return this.#i!==void 0||this.#o}}});function af(e,t){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId);e.arrayObjects("args",t.args,pq),e.arrayObjects("named_args",t.namedArgs,_de),e.boolean("want_rows",t.wantRows)}function _de(e,t){e.string("name",t.name),e.object("value",t.value,pq)}function ll(e,t){e.arrayObjects("steps",t.steps,Ede)}function Ede(e,t){if(t.condition!==void 0)e.object("condition",t.condition,ST);e.object("stmt",t.stmt,af)}function ST(e,t){if(e.stringRaw("type",t.type),t.type==="ok"||t.type==="error")e.number("step",t.step);else if(t.type==="not")e.object("cond",t.cond,ST);else if(t.type==="and"||t.type==="or")e.arrayObjects("conds",t.conds,ST);else if(t.type==="is_autocommit");else throw Ke(t,"Impossible type of BatchCond")}function pq(e,t){if(t===null)e.stringRaw("type","null");else if(typeof t==="bigint")e.stringRaw("type","integer"),e.stringRaw("value",""+t);else if(typeof t==="number")e.stringRaw("type","float"),e.number("value",t);else if(typeof t==="string")e.stringRaw("type","text"),e.string("value",t);else if(t instanceof Uint8Array)e.stringRaw("type","blob"),e.stringRaw("base64",Qc.fromUint8Array(t));else if(t===void 0);else throw Ke(t,"Impossible type of Value")}var vT=w(()=>{Hg();Xr()});function mq(e,t){if(e.stringRaw("type",t.type),t.type==="hello"){if(t.jwt!==void 0)e.string("jwt",t.jwt)}else if(t.type==="request")e.number("request_id",t.requestId),e.object("request",t.request,Ide);else throw Ke(t,"Impossible type of ClientMsg")}function Ide(e,t){if(e.stringRaw("type",t.type),t.type==="open_stream")e.number("stream_id",t.streamId);else if(t.type==="close_stream")e.number("stream_id",t.streamId);else if(t.type==="execute")e.number("stream_id",t.streamId),e.object("stmt",t.stmt,af);else if(t.type==="batch")e.number("stream_id",t.streamId),e.object("batch",t.batch,ll);else if(t.type==="open_cursor")e.number("stream_id",t.streamId),e.number("cursor_id",t.cursorId),e.object("batch",t.batch,ll);else if(t.type==="close_cursor")e.number("cursor_id",t.cursorId);else if(t.type==="fetch_cursor")e.number("cursor_id",t.cursorId),e.number("max_count",t.maxCount);else if(t.type==="sequence"){if(e.number("stream_id",t.streamId),t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="describe"){if(e.number("stream_id",t.streamId),t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="store_sql")e.number("sql_id",t.sqlId),e.string("sql",t.sql);else if(t.type==="close_sql")e.number("sql_id",t.sqlId);else if(t.type==="get_autocommit")e.number("stream_id",t.streamId);else throw Ke(t,"Impossible type of Request")}var hq=w(()=>{vT();Xr()});function cf(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId);for(let r of t.args)e.message(3,r,yq);for(let r of t.namedArgs)e.message(4,r,kde);e.bool(5,t.wantRows)}function kde(e,t){e.string(1,t.name),e.message(2,t.value,yq)}function ul(e,t){for(let r of t.steps)e.message(1,r,Ade)}function Ade(e,t){if(t.condition!==void 0)e.message(1,t.condition,wT);e.message(2,t.stmt,cf)}function wT(e,t){if(t.type==="ok")e.uint32(1,t.step);else if(t.type==="error")e.uint32(2,t.step);else if(t.type==="not")e.message(3,t.cond,wT);else if(t.type==="and")e.message(4,t.conds,gq);else if(t.type==="or")e.message(5,t.conds,gq);else if(t.type==="is_autocommit")e.message(6,void 0,bq);else throw Ke(t,"Impossible type of BatchCond")}function gq(e,t){for(let r of t)e.message(1,r,wT)}function yq(e,t){if(t===null)e.message(1,void 0,bq);else if(typeof t==="bigint")e.sint64(2,t);else if(typeof t==="number")e.double(3,t);else if(typeof t==="string")e.string(4,t);else if(t instanceof Uint8Array)e.bytes(5,t);else if(t===void 0);else throw Ke(t,"Impossible type of Value")}function bq(e,t){}var xT=w(()=>{Xr()});function Sq(e,t){if(t.type==="hello")e.message(1,t,Tde);else if(t.type==="request")e.message(2,t,$de);else throw Ke(t,"Impossible type of ClientMsg")}function Tde(e,t){if(t.jwt!==void 0)e.string(1,t.jwt)}function $de(e,t){e.int32(1,t.requestId);let r=t.request;if(r.type==="open_stream")e.message(2,r,Rde);else if(r.type==="close_stream")e.message(3,r,Ode);else if(r.type==="execute")e.message(4,r,Cde);else if(r.type==="batch")e.message(5,r,Pde);else if(r.type==="open_cursor")e.message(6,r,zde);else if(r.type==="close_cursor")e.message(7,r,Nde);else if(r.type==="fetch_cursor")e.message(8,r,Dde);else if(r.type==="sequence")e.message(9,r,Lde);else if(r.type==="describe")e.message(10,r,Bde);else if(r.type==="store_sql")e.message(11,r,jde);else if(r.type==="close_sql")e.message(12,r,Zde);else if(r.type==="get_autocommit")e.message(13,r,Ude);else throw Ke(r,"Impossible type of Request")}function Rde(e,t){e.int32(1,t.streamId)}function Ode(e,t){e.int32(1,t.streamId)}function Cde(e,t){e.int32(1,t.streamId),e.message(2,t.stmt,cf)}function Pde(e,t){e.int32(1,t.streamId),e.message(2,t.batch,ul)}function zde(e,t){e.int32(1,t.streamId),e.int32(2,t.cursorId),e.message(3,t.batch,ul)}function Nde(e,t){e.int32(1,t.cursorId)}function Dde(e,t){e.int32(1,t.cursorId),e.uint32(2,t.maxCount)}function Lde(e,t){if(e.int32(1,t.streamId),t.sql!==void 0)e.string(2,t.sql);if(t.sqlId!==void 0)e.int32(3,t.sqlId)}function Bde(e,t){if(e.int32(1,t.streamId),t.sql!==void 0)e.string(2,t.sql);if(t.sqlId!==void 0)e.int32(3,t.sqlId)}function jde(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function Zde(e,t){e.int32(1,t.sqlId)}function Ude(e,t){e.int32(1,t.streamId)}var vq=w(()=>{xT();Xr()});function Fi(e){let t=Ar(e.message),r=Lr(e.code);return{message:t,code:r}}function lf(e){let t=bn(e.cols,wq),r=Gd(e.rows).map((s)=>bn(s,xq)),o=Po(e.affected_row_count),n=Lr(e.last_insert_rowid),i=n!==void 0?BigInt(n):void 0;return{cols:t,rows:r,affectedRowCount:o,lastInsertRowid:i}}function wq(e){let t=Lr(e.name),r=Lr(e.decltype);return{name:t,decltype:r}}function oy(e){let t=new Map;Gd(e.step_results).forEach((o,n)=>{if(o!==null)t.set(n,lf(kt(o)))});let r=new Map;return Gd(e.step_errors).forEach((o,n)=>{if(o!==null)r.set(n,Fi(kt(o)))}),{stepResults:t,stepErrors:r}}function iy(e){let t=Ar(e.type);if(t==="step_begin"){let r=Po(e.step),o=bn(e.cols,wq);return{type:"step_begin",step:r,cols:o}}else if(t==="step_end"){let r=Po(e.affected_row_count),o=Lr(e.last_insert_rowid),n=o!==void 0?BigInt(o):void 0;return{type:"step_end",affectedRowCount:r,lastInsertRowid:n}}else if(t==="step_error"){let r=Po(e.step),o=Fi(kt(e.error));return{type:"step_error",step:r,error:o}}else if(t==="row")return{type:"row",row:bn(e.row,xq)};else if(t==="error")return{type:"error",error:Fi(kt(e.error))};else throw new Pe("Unexpected type of CursorEntry")}function sy(e){let t=bn(e.params,qde),r=bn(e.cols,Mde),o=Zi(e.is_explain),n=Zi(e.is_readonly);return{params:t,cols:r,isExplain:o,isReadonly:n}}function qde(e){return{name:Lr(e.name)}}function Mde(e){let t=Ar(e.name),r=Lr(e.decltype);return{name:t,decltype:r}}function xq(e){let t=Ar(e.type);if(t==="null")return null;else if(t==="integer"){let r=Ar(e.value);return BigInt(r)}else if(t==="float")return Po(e.value);else if(t==="text")return Ar(e.value);else if(t==="blob")return Qc.toUint8Array(Ar(e.base64));else throw new Pe("Unexpected type of Value")}var ay=w(()=>{Hg();_t();il()});function _q(e){let t=Ar(e.type);if(t==="hello_ok")return{type:"hello_ok"};else if(t==="hello_error")return{type:"hello_error",error:Fi(kt(e.error))};else if(t==="response_ok"){let r=Po(e.request_id),o=Fde(kt(e.response));return{type:"response_ok",requestId:r,response:o}}else if(t==="response_error"){let r=Po(e.request_id),o=Fi(kt(e.error));return{type:"response_error",requestId:r,error:o}}else throw new Pe("Unexpected type of ServerMsg")}function Fde(e){let t=Ar(e.type);if(t==="open_stream")return{type:"open_stream"};else if(t==="close_stream")return{type:"close_stream"};else if(t==="execute")return{type:"execute",result:lf(kt(e.result))};else if(t==="batch")return{type:"batch",result:oy(kt(e.result))};else if(t==="open_cursor")return{type:"open_cursor"};else if(t==="close_cursor")return{type:"close_cursor"};else if(t==="fetch_cursor"){let r=bn(e.entries,iy),o=Zi(e.done);return{type:"fetch_cursor",entries:r,done:o}}else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:sy(kt(e.result))};else if(t==="store_sql")return{type:"store_sql"};else if(t==="close_sql")return{type:"close_sql"};else if(t==="get_autocommit")return{type:"get_autocommit",isAutocommit:Zi(e.is_autocommit)};else throw new Pe("Unexpected type of Response")}var Eq=w(()=>{_t();il();ay()});var en,Ji,Iq,kq,dl,Jde,Kde,cy,Hde,Vde,Wde,fl,Gde,Qde,Yde;var ly=w(()=>{en={default(){return{message:"",code:void 0}},1(e,t){t.message=e.string()},2(e,t){t.code=e.string()}},Ji={default(){return{cols:[],rows:[],affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.cols.push(e.message(Iq))},2(e,t){t.rows.push(e.message(kq))},3(e,t){t.affectedRowCount=Number(e.uint64())},4(e,t){t.lastInsertRowid=e.sint64()}},Iq={default(){return{name:void 0,decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},kq={default(){return[]},1(e,t){t.push(e.message(Yde))}},dl={default(){return{stepResults:new Map,stepErrors:new Map}},1(e,t){let[r,o]=e.message(Jde);t.stepResults.set(r,o)},2(e,t){let[r,o]=e.message(Kde);t.stepErrors.set(r,o)}},Jde={default(){return[0,Ji.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(Ji)}},Kde={default(){return[0,en.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(en)}},cy={default(){return{type:"none"}},1(e){return e.message(Hde)},2(e){return e.message(Vde)},3(e){return e.message(Wde)},4(e){return{type:"row",row:e.message(kq)}},5(e){return{type:"error",error:e.message(en)}}},Hde={default(){return{type:"step_begin",step:0,cols:[]}},1(e,t){t.step=e.uint32()},2(e,t){t.cols.push(e.message(Iq))}},Vde={default(){return{type:"step_end",affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.affectedRowCount=e.uint32()},2(e,t){t.lastInsertRowid=e.uint64()}},Wde={default(){return{type:"step_error",step:0,error:en.default()}},1(e,t){t.step=e.uint32()},2(e,t){t.error=e.message(en)}},fl={default(){return{params:[],cols:[],isExplain:!1,isReadonly:!1}},1(e,t){t.params.push(e.message(Gde))},2(e,t){t.cols.push(e.message(Qde))},3(e,t){t.isExplain=e.bool()},4(e,t){t.isReadonly=e.bool()}},Gde={default(){return{name:void 0}},1(e,t){t.name=e.string()}},Qde={default(){return{name:"",decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},Yde={default(){return},1(e){return null},2(e){return e.sint64()},3(e){return e.double()},4(e){return e.string()},5(e){return e.bytes()}}});var Aq,Xde,efe,tfe,rfe,nfe,ofe,ife,sfe;var Tq=w(()=>{ly();Aq={default(){return{type:"none"}},1(e){return{type:"hello_ok"}},2(e){return e.message(Xde)},3(e){return e.message(tfe)},4(e){return e.message(efe)}},Xde={default(){return{type:"hello_error",error:en.default()}},1(e,t){t.error=e.message(en)}},efe={default(){return{type:"response_error",requestId:0,error:en.default()}},1(e,t){t.requestId=e.int32()},2(e,t){t.error=e.message(en)}},tfe={default(){return{type:"response_ok",requestId:0,response:{type:"none"}}},1(e,t){t.requestId=e.int32()},2(e,t){t.response={type:"open_stream"}},3(e,t){t.response={type:"close_stream"}},4(e,t){t.response=e.message(rfe)},5(e,t){t.response=e.message(nfe)},6(e,t){t.response={type:"open_cursor"}},7(e,t){t.response={type:"close_cursor"}},8(e,t){t.response=e.message(ofe)},9(e,t){t.response={type:"sequence"}},10(e,t){t.response=e.message(ife)},11(e,t){t.response={type:"store_sql"}},12(e,t){t.response={type:"close_sql"}},13(e,t){t.response=e.message(sfe)}},rfe={default(){return{type:"execute",result:Ji.default()}},1(e,t){t.result=e.message(Ji)}},nfe={default(){return{type:"batch",result:dl.default()}},1(e,t){t.result=e.message(dl)}},ofe={default(){return{type:"fetch_cursor",entries:[],done:!1}},1(e,t){t.entries.push(e.message(cy))},2(e,t){t.done=e.bool()}},ife={default(){return{type:"describe",result:fl.default()}},1(e,t){t.result=e.message(fl)}},sfe={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}}});var $q,_T,uy;var dy=w(()=>{dT();_t();fT();tf();al();Xr();bT();hq();vq();Eq();Tq();$q=new Map([["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]),_T=new Map([["hrana3-protobuf",{version:3,encoding:"protobuf"}],["hrana3",{version:3,encoding:"json"}],["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]);uy=class uy extends rl{#e;#t;#r;#n;#o;#i;#a;#s;#c;_streamIdAlloc;_cursorIdAlloc;#l;constructor(e,t){super();this.#e=e,this.#t=[],this.#r=!1,this.#n=void 0,this.#o=!1,this.#i=void 0,this.#a=!1,this.#s=new Map,this.#c=new qi,this._streamIdAlloc=new qi,this._cursorIdAlloc=new qi,this.#l=new qi,this.#e.binaryType="arraybuffer",this.#e.addEventListener("open",()=>this.#f()),this.#e.addEventListener("close",(r)=>this.#g(r)),this.#e.addEventListener("error",(r)=>this.#p(r)),this.#e.addEventListener("message",(r)=>this.#y(r)),this.#d({type:"hello",jwt:t})}#d(e){if(this.#n!==void 0)throw new or("Trying to send a message on a closed client");if(this.#r)this.#m(e);else{let t=()=>this.#m(e),r=()=>{return};this.#t.push({openCallback:t,errorCallback:r})}}#f(){let e=this.#e.protocol;if(e===void 0){this.#u(new We("The `WebSocket.protocol` property is undefined. This most likely means that the WebSocket implementation provided by the environment is broken. If you are using Miniflare 2, please update to Miniflare 3, which fixes this problem."));return}else if(e==="")this.#i={version:1,encoding:"json"};else if(this.#i=_T.get(e),this.#i===void 0){this.#u(new Pe(`Unrecognized WebSocket subprotocol: ${JSON.stringify(e)}`));return}for(let t of this.#t)t.openCallback();this.#t.length=0,this.#r=!0}#m(e){let t=this.#i.encoding;if(t==="json"){let r=Qd(e,mq);this.#e.send(r)}else if(t==="protobuf"){let r=ef(e,Sq);this.#e.send(r)}else throw Ke(t,"Impossible encoding")}getVersion(){return new Promise((e,t)=>{if(this.#a=!0,this.#n!==void 0)t(this.#n);else if(!this.#r){let r=()=>e(this.#i.version);this.#t.push({openCallback:r,errorCallback:t})}else e(this.#i.version)})}_ensureVersion(e,t){if(this.#i===void 0||!this.#a)throw new yn(`${t} is supported only on protocol version ${e} and higher, but the version supported by the WebSocket server is not yet known. Use Client.getVersion() to wait until the version is available.`);else if(this.#i.version<e)throw new yn(`${t} is supported on protocol version ${e} and higher, but the WebSocket server only supports version ${this.#i.version}`)}_sendRequest(e,t){if(this.#n!==void 0){t.errorCallback(new xt("Client is closed",this.#n));return}let r=this.#c.alloc();this.#s.set(r,{...t,type:e.type}),this.#d({type:"request",requestId:r,request:e})}#p(e){let r=e.message??"WebSocket was closed due to an error";this.#u(new nl(r))}#g(e){let t=`WebSocket was closed with code ${e.code}`;if(e.reason)t+=`: ${e.reason}`;this.#u(new nl(t))}#u(e){if(this.#n!==void 0)return;this.#n=e;for(let t of this.#t)t.errorCallback(e);this.#t.length=0;for(let[t,r]of this.#s.entries())r.errorCallback(e),this.#c.free(t);this.#s.clear(),this.#e.close()}#y(e){if(this.#n!==void 0)return;try{let t,r=this.#i.encoding;if(r==="json"){if(typeof e.data!=="string"){this.#e.close(3003,"Only text messages are accepted with JSON encoding"),this.#u(new Pe("Received non-text message from server with JSON encoding"));return}t=Xs(JSON.parse(e.data),_q)}else if(r==="protobuf"){if(!(e.data instanceof ArrayBuffer)){this.#e.close(3003,"Only binary messages are accepted with Protobuf encoding"),this.#u(new Pe("Received non-binary message from server with Protobuf encoding"));return}t=Ui(new Uint8Array(e.data),Aq)}else throw Ke(r,"Impossible encoding");this.#b(t)}catch(t){this.#e.close(3007,"Could not handle message"),this.#u(t)}}#b(e){if(e.type==="none")throw new Pe("Received an unrecognized ServerMsg");else if(e.type==="hello_ok"||e.type==="hello_error"){if(this.#o)throw new Pe("Received a duplicated hello response");if(this.#o=!0,e.type==="hello_error")throw zo(e.error);return}else if(!this.#o)throw new Pe("Received a non-hello message before a hello response");if(e.type==="response_ok"){let t=e.requestId,r=this.#s.get(t);if(this.#s.delete(t),r===void 0)throw new Pe("Received unexpected OK response");this.#c.free(t);try{if(r.type!==e.response.type)throw console.dir({responseState:r,msg:e}),new Pe("Received unexpected type of response");r.responseCallback(e.response)}catch(o){throw r.errorCallback(o),o}}else if(e.type==="response_error"){let t=e.requestId,r=this.#s.get(t);if(this.#s.delete(t),r===void 0)throw new Pe("Received unexpected error response");this.#c.free(t),r.errorCallback(zo(e.error))}else throw Ke(e,"Impossible ServerMsg type")}openStream(){return sf.open(this)}storeSql(e){this._ensureVersion(2,"storeSql()");let t=this.#l.alloc(),r=new ra(this,t),o=()=>{return},n=(s)=>r._setClosed(s),i={type:"store_sql",sqlId:t,sql:e};return this._sendRequest(i,{responseCallback:o,errorCallback:n}),r}_closeSql(e){if(this.#n!==void 0)return;let t=()=>this.#l.free(e),r=(n)=>this.#u(n),o={type:"close_sql",sqlId:e};this._sendRequest(o,{responseCallback:t,errorCallback:r})}close(){this.#u(new We("Client was manually closed"))}get closed(){return this.#n!==void 0}}});var na;var Rq=w(()=>{if(typeof queueMicrotask<"u")na=queueMicrotask;else{let e=Promise.resolve();na=(t)=>{e.then(t)}}});class ET{#e;#t;#r;constructor(e){this.#e=new Uint8Array(new ArrayBuffer(e)),this.#t=0,this.#r=0}get length(){return this.#r-this.#t}data(){return this.#e.slice(this.#t,this.#r)}push(e){this.#n(e.byteLength),this.#e.set(e,this.#r),this.#r+=e.byteLength}#n(e){if(this.#r+e<=this.#e.byteLength)return;let t=this.#r-this.#t;if(t+e<=this.#e.byteLength&&2*this.#r>=this.#e.byteLength)this.#e.copyWithin(0,this.#t,this.#r);else{let r=this.#e.byteLength;do r*=2;while(t+e>r);let o=new Uint8Array(new ArrayBuffer(r));o.set(this.#e.slice(this.#t,this.#r),0),this.#e=o}this.#r=t,this.#t=0}shift(e){this.#t+=e}}function Oq(e){let t=Lr(e.baton),r=Lr(e.base_url),o=bn(e.results,afe);return{baton:t,baseUrl:r,results:o}}function afe(e){let t=Ar(e.type);if(t==="ok")return{type:"ok",response:cfe(kt(e.response))};else if(t==="error")return{type:"error",error:Fi(kt(e.error))};else throw new Pe("Unexpected type of StreamResult")}function cfe(e){let t=Ar(e.type);if(t==="close")return{type:"close"};else if(t==="execute")return{type:"execute",result:lf(kt(e.result))};else if(t==="batch")return{type:"batch",result:oy(kt(e.result))};else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:sy(kt(e.result))};else if(t==="store_sql")return{type:"store_sql"};else if(t==="close_sql")return{type:"close_sql"};else if(t==="get_autocommit")return{type:"get_autocommit",isAutocommit:Zi(e.is_autocommit)};else throw new Pe("Unexpected type of StreamResponse")}function Cq(e){let t=Lr(e.baton),r=Lr(e.base_url);return{baton:t,baseUrl:r}}var IT=w(()=>{_t();il();ay()});var Pq,lfe,ufe,dfe,ffe,pfe,mfe,zq;var kT=w(()=>{ly();Pq={default(){return{baton:void 0,baseUrl:void 0,results:[]}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()},3(e,t){t.results.push(e.message(lfe))}},lfe={default(){return{type:"none"}},1(e){return{type:"ok",response:e.message(ufe)}},2(e){return{type:"error",error:e.message(en)}}},ufe={default(){return{type:"none"}},1(e){return{type:"close"}},2(e){return e.message(dfe)},3(e){return e.message(ffe)},4(e){return{type:"sequence"}},5(e){return e.message(pfe)},6(e){return{type:"store_sql"}},7(e){return{type:"close_sql"}},8(e){return e.message(mfe)}},dfe={default(){return{type:"execute",result:Ji.default()}},1(e,t){t.result=e.message(Ji)}},ffe={default(){return{type:"batch",result:dl.default()}},1(e,t){t.result=e.message(dl)}},pfe={default(){return{type:"describe",result:fl.default()}},1(e,t){t.result=e.message(fl)}},mfe={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}},zq={default(){return{baton:void 0,baseUrl:void 0}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()}}});var AT;var Nq=w(()=>{il();lT();_t();Xr();IT();kT();ay();ly();AT=class AT extends of{#e;#t;#r;#n;#o;#i;constructor(e,t){super();this.#e=e,this.#t=t,this.#r=void 0,this.#n=new ET(16384),this.#o=void 0,this.#i=!1}async open(e){if(e.body===null)throw new Pe("No response body for cursor request");this.#r=e.body[Symbol.asyncIterator]();let t=await this.#a(Cq,zq);if(t===void 0)throw new Pe("Empty response to cursor request");return t}next(){return this.#a(iy,cy)}close(){this._setClosed(new We("Cursor was manually closed"))}_setClosed(e){if(this.#o!==void 0)return;if(this.#o=e,this.#e._cursorClosed(this),this.#r!==void 0)this.#r.return()}get closed(){return this.#o!==void 0}async#a(e,t){for(;;){if(this.#i)return;else if(this.#o!==void 0)throw new xt("Cursor is closed",this.#o);if(this.#t==="json"){let n=this.#s();if(n!==void 0){let i=new TextDecoder().decode(n),s=JSON.parse(i);return Xs(s,e)}}else if(this.#t==="protobuf"){let n=this.#c();if(n!==void 0)return Ui(n,t)}else throw Ke(this.#t,"Impossible encoding");if(this.#r===void 0)throw new or("Attempted to read from HTTP cursor before it was opened");let{value:r,done:o}=await this.#r.next();if(o&&this.#n.length===0)this.#i=!0;else if(o)throw new Pe("Unexpected end of cursor stream");else this.#n.push(r)}}#s(){let e=this.#n.data(),t=10,r=e.indexOf(10);if(r<0)return;let o=e.slice(0,r);return this.#n.shift(r+1),o}#c(){let e=this.#n.data(),t=0,r=0;for(;;){if(r>=e.byteLength)return;let n=e[r];if(t|=(n&127)<<7*r,r+=1,!(n&128))break}if(e.byteLength<r+t)return;let o=e.slice(r,r+t);return this.#n.shift(r+t),o}}});function Dq(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.arrayObjects("requests",t.requests,hfe)}function hfe(e,t){if(e.stringRaw("type",t.type),t.type==="close");else if(t.type==="execute")e.object("stmt",t.stmt,af);else if(t.type==="batch")e.object("batch",t.batch,ll);else if(t.type==="sequence"){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="describe"){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="store_sql")e.number("sql_id",t.sqlId),e.string("sql",t.sql);else if(t.type==="close_sql")e.number("sql_id",t.sqlId);else if(t.type==="get_autocommit");else throw Ke(t,"Impossible type of StreamRequest")}function Lq(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.object("batch",t.batch,ll)}var TT=w(()=>{vT();Xr()});function Bq(e,t){if(t.baton!==void 0)e.string(1,t.baton);for(let r of t.requests)e.message(2,r,gfe)}function gfe(e,t){if(t.type==="close")e.message(1,t,yfe);else if(t.type==="execute")e.message(2,t,bfe);else if(t.type==="batch")e.message(3,t,Sfe);else if(t.type==="sequence")e.message(4,t,vfe);else if(t.type==="describe")e.message(5,t,wfe);else if(t.type==="store_sql")e.message(6,t,xfe);else if(t.type==="close_sql")e.message(7,t,_fe);else if(t.type==="get_autocommit")e.message(8,t,Efe);else throw Ke(t,"Impossible type of StreamRequest")}function yfe(e,t){}function bfe(e,t){e.message(1,t.stmt,cf)}function Sfe(e,t){e.message(1,t.batch,ul)}function vfe(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function wfe(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function xfe(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function _fe(e,t){e.int32(1,t.sqlId)}function Efe(e,t){}function jq(e,t){if(t.baton!==void 0)e.string(1,t.baton);e.message(2,t.batch,ul)}var $T=w(()=>{xT();Xr()});function Ife(e,t){if(t.results.length!==e.length)throw new Pe("Server returned unexpected number of pipeline results");for(let r=0;r<e.length;++r){let o=t.results[r],n=e[r];if(o.type==="ok"){if(o.response.type!==n.request.type)throw new Pe("Received unexpected type of response");n.responseCallback(o.response)}else if(o.type==="error")n.errorCallback(zo(o.error));else if(o.type==="none")throw new Pe("Received unrecognized type of StreamResult");else throw Ke(o,"Received impossible type of StreamResult")}}async function kfe(e,t){if(t==="json"){let r=await e.json();return Xs(r,Oq)}if(t==="protobuf"){let r=await e.arrayBuffer();return Ui(new Uint8Array(r),Pq)}throw await e.body?.cancel(),Ke(t,"Impossible encoding")}async function Afe(e){let t=e.headers.get("content-type")??"text/plain",r=`Server returned HTTP status ${e.status}`;if(t==="application/json"){let o=await e.json();if("message"in o)return zo(o);return new Ys(r,e.status)}if(t==="text/plain"){let o=(await e.text()).trim();if(o!=="")r+=`: ${o}`;return new Ys(r,e.status)}return await e.body?.cancel(),new Ys(r,e.status)}var fy;var RT=w(()=>{_t();dT();fT();Rq();tf();al();ny();Xr();Nq();TT();$T();TT();$T();IT();kT();fy=class fy extends cl{#e;#t;#r;#n;#o;#i;#a;#s;#c;#l;#d;#f;#m;constructor(e,t,r,o,n){super(e.intMode);this.#e=e,this.#t=t.toString(),this.#r=r,this.#n=o,this.#o=n,this.#i=void 0,this.#a=new Mi,this.#s=!1,this.#l=!1,this.#d=!1,this.#f=void 0,this.#m=new qi}client(){return this.#e}_sqlOwner(){return this}storeSql(e){let t=this.#m.alloc();return this.#p({type:"store_sql",sqlId:t,sql:e}).then(()=>{return},(r)=>this._setClosed(r)),new ra(this,t)}_closeSql(e){if(this.#f!==void 0)return;this.#p({type:"close_sql",sqlId:e}).then(()=>this.#m.free(e),(t)=>this._setClosed(t))}_execute(e){return this.#p({type:"execute",stmt:e}).then((t)=>t.result)}_batch(e){return this.#p({type:"batch",batch:e}).then((t)=>t.result)}_describe(e){return this.#p({type:"describe",sql:e.sql,sqlId:e.sqlId}).then((t)=>t.result)}_sequence(e){return this.#p({type:"sequence",sql:e.sql,sqlId:e.sqlId}).then((t)=>{return})}getAutocommit(){return this.#e._ensureVersion(3,"getAutocommit()"),this.#p({type:"get_autocommit"}).then((e)=>e.isAutocommit)}#p(e){return new Promise((t,r)=>{this.#g({type:"pipeline",request:e,responseCallback:t,errorCallback:r})})}_openCursor(e){return new Promise((t,r)=>{this.#g({type:"cursor",batch:e,cursorCallback:t,errorCallback:r})})}_cursorClosed(e){if(e!==this.#c)throw new or("Cursor was closed, but it was not associated with the stream");this.#c=void 0,na(()=>this.#u())}close(){this._setClosed(new We("Stream was manually closed"))}closeGracefully(){this.#l=!0,na(()=>this.#u())}get closed(){return this.#f!==void 0||this.#l}_setClosed(e){if(this.#f!==void 0)return;if(this.#f=e,this.#c!==void 0)this.#c._setClosed(e);this.#e._streamClosed(this);for(;;){let t=this.#a.shift();if(t!==void 0)t.errorCallback(e);else break}if((this.#i!==void 0||this.#s)&&!this.#d)this.#a.push({type:"pipeline",request:{type:"close"},responseCallback:()=>{return},errorCallback:()=>{return}}),this.#d=!0,na(()=>this.#u())}#g(e){if(this.#f!==void 0)throw new xt("Stream is closed",this.#f);else if(this.#l)throw new xt("Stream is closing",void 0);else this.#a.push(e),na(()=>this.#u())}#u(){if(this.#s||this.#c!==void 0)return;if(this.#l&&this.#a.length===0){this._setClosed(new We("Stream was gracefully closed"));return}let e=this.#e._endpoint;if(e===void 0){this.#e._endpointPromise.then(()=>this.#u(),(r)=>this._setClosed(r));return}let t=this.#a.shift();if(t===void 0)return;else if(t.type==="pipeline"){let r=[t];for(;;){let o=this.#a.first();if(o!==void 0&&o.type==="pipeline")r.push(o),this.#a.shift();else if(o===void 0&&this.#l&&!this.#d){r.push({type:"pipeline",request:{type:"close"},responseCallback:()=>{return},errorCallback:()=>{return}}),this.#d=!0;break}else break}this.#y(e,r)}else if(t.type==="cursor")this.#b(e,t);else throw Ke(t,"Impossible type of QueueEntry")}#y(e,t){this.#h(()=>this.#S(t,e),(r)=>kfe(r,e.encoding),(r)=>r.baton,(r)=>r.baseUrl,(r)=>Ife(t,r),(r)=>t.forEach((o)=>o.errorCallback(r)))}#b(e,t){let r=new AT(this,e.encoding);this.#c=r,this.#h(()=>this.#v(t,e),(o)=>r.open(o),(o)=>o.baton,(o)=>o.baseUrl,(o)=>t.cursorCallback(r),(o)=>t.errorCallback(o))}#h(e,t,r,o,n,i){let s;try{let a=e(),c=this.#n;s=c(a)}catch(a){s=Promise.reject(a)}this.#s=!0,s.then((a)=>{if(!a.ok)return Afe(a).then((c)=>{throw c});return t(a)}).then((a)=>{this.#i=r(a),this.#t=o(a)??this.#t,n(a)}).catch((a)=>{this._setClosed(a),i(a)}).finally(()=>{this.#s=!1,this.#u()})}#S(e,t){return this.#w(new URL(t.pipelinePath,this.#t),{baton:this.#i,requests:e.map((r)=>r.request)},t.encoding,Dq,Bq)}#v(e,t){if(t.cursorPath===void 0)throw new yn(`Cursors are supported only on protocol version 3 and higher, but the HTTP server only supports version ${t.version}.`);return this.#w(new URL(t.cursorPath,this.#t),{baton:this.#i,batch:e.batch},t.encoding,Lq,jq)}#w(e,t,r,o,n){let i,s;if(r==="json")i=Qd(t,o),s="application/json";else if(r==="protobuf")i=ef(t,n),s="application/x-protobuf";else throw Ke(r,"Impossible encoding");let a=new Headers;if(a.set("content-type",s),this.#r!==void 0)a.set("authorization",`Bearer ${this.#r}`);if(this.#o!==void 0)a.set("x-turso-encryption-key",this.#o);return new Request(e.toString(),{method:"POST",headers:a,body:i})}}});async function $fe(e,t){let r=e;for(let o of Tfe){let n=new URL(o.versionPath,t),i=new Request(n.toString(),{method:"GET"}),s=await r(i);if(await s.arrayBuffer(),s.ok)return o}return OT}var Tfe,OT,py;var CT=w(()=>{_t();RT();Tfe=[{versionPath:"v3-protobuf",pipelinePath:"v3-protobuf/pipeline",cursorPath:"v3-protobuf/cursor",version:3,encoding:"protobuf"}],OT={versionPath:"v2",pipelinePath:"v2/pipeline",cursorPath:void 0,version:2,encoding:"json"};py=class py extends rl{#e;#t;#r;#n;#o;#i;_endpointPromise;_endpoint;constructor(e,t,r,o,n=2){super();if(this.#e=e,this.#t=t,this.#r=r??globalThis.fetch,this.#n=o,this.#o=void 0,this.#i=new Set,n==3)this._endpointPromise=$fe(this.#r,this.#e),this._endpointPromise.then((i)=>this._endpoint=i,(i)=>this.#a(i));else this._endpointPromise=Promise.resolve(OT),this._endpointPromise.then((i)=>this._endpoint=i,(i)=>this.#a(i))}async getVersion(){if(this._endpoint!==void 0)return this._endpoint.version;return(await this._endpointPromise).version}_ensureVersion(e,t){if(e<=OT.version)return;else if(this._endpoint===void 0)throw new yn(`${t} is supported only on protocol version ${e} and higher, but the version supported by the HTTP server is not yet known. Use Client.getVersion() to wait until the version is available.`);else if(this._endpoint.version<e)throw new yn(`${t} is supported only on protocol version ${e} and higher, but the HTTP server only supports version ${this._endpoint.version}.`)}openStream(){if(this.#o!==void 0)throw new xt("Client is closed",this.#o);let e=new fy(this,this.#e,this.#t,this.#r,this.#n);return this.#i.add(e),e}_streamClosed(e){this.#i.delete(e)}close(){this.#a(new We("Client was manually closed"))}get closed(){return this.#o!==void 0}#a(e){if(this.#o!==void 0)return;this.#o=e;for(let t of Array.from(this.#i))t._setClosed(new xt("Client was closed",e))}}});var Zq=w(()=>{_t()});function PT(e,t,r=2){if(typeof ji>"u")throw new Wd("WebSockets are not supported in this environment");var o=void 0;if(r==3)o=Array.from(_T.keys());else o=Array.from($q.keys());let n=new ji(e,o);return new uy(n,t)}function zT(e,t,r,o,n=2){return new py(e instanceof URL?e:new URL(e),t,r,o,n)}var my=w(()=>{cT();dy();_t();CT();dy();cT();gT();Zq();al();ty();ny();CT();RT();dy();bT();_t()});class uf{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=void 0}execute(e){return this.batch([e]).then((t)=>t[0])}async batch(e){let t=this._getStream();if(t.closed)throw new Ce("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{let r=e.map(No),o;if(this.#r===void 0){this._getSqlCache().apply(r);let i=t.batch(this.#t>=3),s=i.step(),a=s.run(Li(this.#e)),c=s;o=r.map((u)=>{let d=i.step().condition(dt.ok(c));if(this.#t>=3)d.condition(dt.not(dt.isAutocommit(i)));let f=d.query(u);return f.catch(()=>{return}),c=d,f}),this.#r=i.execute().then(()=>a).then(()=>{return});try{await this.#r}catch(u){throw this.close(),u}}else{if(this.#t<3)await this.#r;this._getSqlCache().apply(r);let i=t.batch(this.#t>=3),s=void 0;o=r.map((a)=>{let c=i.step();if(s!==void 0)c.condition(dt.ok(s));if(this.#t>=3)c.condition(dt.not(dt.isAutocommit(i)));let u=c.query(a);return u.catch(()=>{return}),s=c,u}),await i.execute()}let n=[];for(let i=0;i<o.length;i++)try{let s=await o[i];if(s===void 0)throw new Gt("Statement in a transaction was not executed, probably because the transaction has been rolled back",i,"TRANSACTION_CLOSED");n.push(ml(s))}catch(s){if(s instanceof Gt)throw s;let a=st(s);if(a instanceof Ce)throw new Gt(a.message,i,a.code,a.extendedCode,a.rawCode,a.cause instanceof Error?a.cause:void 0);throw a}return n}catch(r){throw st(r)}}async executeMultiple(e){let t=this._getStream();if(t.closed)throw new Ce("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{if(this.#r===void 0){this.#r=t.run(Li(this.#e)).then(()=>{return});try{await this.#r}catch(r){throw this.close(),r}}else await this.#r;await t.sequence(e)}catch(r){throw st(r)}}async rollback(){try{let e=this._getStream();if(e.closed)return;if(this.#r!==void 0);else return;let t=e.run("ROLLBACK").catch((r)=>{throw st(r)});e.closeGracefully(),await t}catch(e){throw st(e)}finally{this.close()}}async commit(){try{let e=this._getStream();if(e.closed)throw new Ce("Cannot commit the transaction because it is already closed","TRANSACTION_CLOSED");if(this.#r!==void 0)await this.#r;else return;let t=e.run("COMMIT").catch((r)=>{throw st(r)});e.closeGracefully(),await t}catch(e){throw st(e)}finally{this.close()}}}async function pl(e,t,r,o,n=!1){if(n)r.step().run("PRAGMA foreign_keys=off");let i=r.step(),s=i.run(Li(e)),a=i,c=o.map((h)=>{let b=r.step().condition(dt.ok(a));if(t>=3)b.condition(dt.not(dt.isAutocommit(r)));let y=b.query(h);return a=b,y}),u=r.step().condition(dt.ok(a));if(t>=3)u.condition(dt.not(dt.isAutocommit(r)));let d=u.run("COMMIT");if(r.step().condition(dt.not(dt.ok(u))).run("ROLLBACK").catch((h)=>{return}),n)r.step().run("PRAGMA foreign_keys=on");await r.execute();let m=[];await s;for(let h=0;h<c.length;h++)try{let b=await c[h];if(b===void 0)throw new Gt("Statement in a batch was not executed, probably because the transaction has been rolled back",h,"TRANSACTION_CLOSED");m.push(ml(b))}catch(b){if(b instanceof Gt)throw b;let y=st(b);if(y instanceof Ce)throw new Gt(y.message,h,y.code,y.extendedCode,y.rawCode,y.cause instanceof Error?y.cause:void 0);throw y}return await d,m}function No(e){let t,r;if(Array.isArray(e))[t,r]=e;else if(typeof e==="string")t=e;else t=e.sql,r=e.args;let o=new nf(t);if(r)if(Array.isArray(r))o.bindIndexes(r);else for(let[n,i]of Object.entries(r))o.bindName(n,i);return o}function ml(e){let t=e.columnNames.map((s)=>s??""),r=e.columnDecltypes.map((s)=>s??""),o=e.rows,n=e.affectedRowCount,i=e.lastInsertRowid!==void 0?e.lastInsertRowid:void 0;return new Yc(t,r,o,n,i)}function st(e){if(e instanceof We){let t=Uq(e);return new Ce(e.message,t,void 0,void 0,e)}return e}function Uq(e){if(e instanceof Vd&&e.code!==void 0)return e.code;else if(e instanceof Pe)return"HRANA_PROTO_ERROR";else if(e instanceof xt)return e.cause instanceof We?Uq(e.cause):"HRANA_CLOSED_ERROR";else if(e instanceof nl)return"HRANA_WEBSOCKET_ERROR";else if(e instanceof Ys)return"SERVER_ERROR";else if(e instanceof yn)return"PROTOCOL_VERSION_ERROR";else if(e instanceof or)return"INTERNAL_ERROR";else return"UNKNOWN"}var DT=w(()=>{my();gn();Xc()});class hl{#e;#t;capacity;constructor(e,t){this.#e=e,this.#t=new qq,this.capacity=t}apply(e){if(this.capacity<=0)return;let t=new Set;for(let r of e){if(typeof r.sql!=="string")continue;let o=r.sql;if(o.length>=5000)continue;let n=this.#t.get(o);if(n===void 0){while(this.#t.size+1>this.capacity){let[i,s]=this.#t.peekLru();if(t.has(s))break;s.close(),this.#t.delete(i)}if(this.#t.size+1<=this.capacity)n=this.#e.storeSql(o),this.#t.set(o,n)}if(n!==void 0)r.sql=n,t.add(n)}}}class qq{#e;constructor(){this.#e=new Map}get(e){let t=this.#e.get(e);if(t!==void 0)this.#e.delete(e),this.#e.set(e,t);return t}set(e,t){this.#e.set(e,t)}peekLru(){for(let e of this.#e.entries())return e;return}delete(e){this.#e.delete(e)}get size(){return this.#e.size}}var LT=ge(function(q2e,Fq){function Rfe(e){var t=0,r=[];function o(){if(t--,t<e)n()}function n(){var c=r.shift();if(a.queue=r.length,c)s(c.fn).then(c.resolve).catch(c.reject)}function i(c){return new Promise(function(u,d){r.push({fn:c,resolve:u,reject:d}),a.queue=r.length})}function s(c){t++;try{return Promise.resolve(c()).then(function(u){return o(),u},function(u){throw o(),u})}catch(u){return o(),Promise.reject(u)}}var a=function(c){if(t>=e)return i(c);else return s(c)};return a}function Ofe(e,t){var r=!1,o=this;return Promise.all(e.map(function(){var n=arguments;return o(function(){if(!r)return t.apply(void 0,n).catch(function(i){throw r=!0,i})})}))}function Mq(e){return e.queue=0,e.map=Ofe,e}Fq.exports=function(e){if(e)return Mq(Rfe(e));else return Mq(function(t){return t()})}});function Hq(e){if(e.scheme!=="wss"&&e.scheme!=="ws")throw new Ce(`The WebSocket client supports only "libsql:", "wss:" and "ws:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${Vn}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new Ce("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="ws"&&e.tls)throw new Ce('A "ws:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="wss"&&!e.tls)throw new Ce('A "wss:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=Md(e.scheme,e.authority,e.path),r;try{r=PT(t,e.authToken)}catch(o){if(o instanceof Wd){let n=e.scheme==="wss"?"https":"http",i=Md(n,e.authority,e.path);throw new Ce(`This environment does not support WebSockets, please switch to the HTTP client by using a "${n}:" URL (${JSON.stringify(i)}). For more information, please read ${Vn}`,"WEBSOCKETS_NOT_SUPPORTED")}throw st(o)}return new Vq(r,t,e.authToken,e.intMode,e.concurrency)}class Vq{#e;#t;#r;#n;#o;closed;protocol;#i;#a;constructor(e,t,r,o,n){this.#e=t,this.#t=r,this.#r=o,this.#n=this.#c(e),this.#o=void 0,this.closed=!1,this.protocol="ws",this.#a=Kq.default(n)}async limit(e){return this.#a(e)}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.limit(async()=>{let o=await this.#s();try{let n=No(r);o.conn.sqlCache.apply([n]);let i=o.stream.query(n);o.stream.closeGracefully();let s=await i;return ml(s)}catch(n){throw st(n)}finally{this._closeStream(o)}})}async batch(e,t="deferred"){return this.limit(async()=>{let r=await this.#s();try{let n=e.map((u)=>{if(Array.isArray(u))return{sql:u[0],args:u[1]||[]};return u}).map(No),i=await r.conn.client.getVersion();r.conn.sqlCache.apply(n);let s=r.stream.batch(i>=3);return await pl(t,i,s,n)}catch(o){throw st(o)}finally{this._closeStream(r)}})}async migrate(e){return this.limit(async()=>{let t=await this.#s();try{let r=e.map(No),o=await t.conn.client.getVersion(),n=t.stream.batch(o>=3);return await pl("deferred",o,n,r,!0)}catch(r){throw st(r)}finally{this._closeStream(t)}})}async transaction(e="write"){return this.limit(async()=>{let t=await this.#s();try{let r=await t.conn.client.getVersion();return new Wq(this,t,e,r)}catch(r){throw this._closeStream(t),st(r)}})}async executeMultiple(e){return this.limit(async()=>{let t=await this.#s();try{let r=t.stream.sequence(e);t.stream.closeGracefully(),await r}catch(r){throw st(r)}finally{this._closeStream(t)}})}sync(){throw new Ce("sync not supported in ws mode","SYNC_NOT_SUPPORTED")}async#s(){if(this.closed)throw new Ce("The client is closed","CLIENT_CLOSED");if(new Date().valueOf()-this.#n.openTime.valueOf()>Cfe&&this.#o===void 0){let o=this.#c();this.#o=o,o.client.getVersion().then((n)=>{if(this.#n!==o){if(this.#n.streamStates.size===0)this.#n.client.close()}this.#n=o,this.#o=void 0},(n)=>{this.#o=void 0})}if(this.#n.client.closed)try{if(this.#o!==void 0)this.#n=this.#o;else this.#n=this.#c()}catch(o){throw st(o)}let r=this.#n;try{if(r.useSqlCache===void 0){if(r.useSqlCache=await r.client.getVersion()>=2,r.useSqlCache)r.sqlCache.capacity=Jq}let o=r.client.openStream();o.intMode=this.#r;let n={conn:r,stream:o};return r.streamStates.add(n),n}catch(o){throw st(o)}}#c(e){try{return e??=PT(this.#e,this.#t),{client:e,useSqlCache:void 0,sqlCache:new hl(e,0),openTime:new Date,streamStates:new Set}}catch(t){throw st(t)}}async reconnect(){try{for(let r of Array.from(this.#n.streamStates))try{r.stream.close()}catch{}this.#n.client.close()}catch{}if(this.#o){try{this.#o.client.close()}catch{}this.#o=void 0}let e=this.#c(),t=await e.client.getVersion();if(e.useSqlCache=t>=2,e.useSqlCache)e.sqlCache.capacity=Jq;this.#n=e,this.closed=!1}_closeStream(e){e.stream.close();let t=e.conn;if(t.streamStates.delete(e),t.streamStates.size===0&&t!==this.#n)t.client.close()}close(){if(this.#n.client.close(),this.closed=!0,this.#o){try{this.#o.client.close()}catch{}this.#o=void 0}this.closed=!0}}var Kq,Cfe=60000,Jq=100,Wq;var Gq=w(()=>{my();gn();Kd();DT();Fg();Xc();Kq=Rl(LT(),1);gn();Wq=class Wq extends uf{#e;#t;constructor(e,t,r,o){super(r,o);this.#e=e,this.#t=t}_getStream(){return this.#t.stream}_getSqlCache(){return this.#t.conn.sqlCache}close(){this.#e._closeStream(this.#t)}get closed(){return this.#t.stream.closed}}});function Yq(e){if(e.scheme!=="https"&&e.scheme!=="http")throw new Ce(`The HTTP client supports only "libsql:", "https:" and "http:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${Vn}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new Ce("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="http"&&e.tls)throw new Ce('A "http:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="https"&&!e.tls)throw new Ce('A "https:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=Md(e.scheme,e.authority,e.path);return new eM(t,e.authToken,e.intMode,e.fetch,e.concurrency,e.remoteEncryptionKey)}class eM{#e;protocol;#t;#r;#n;#o;#i;#a;#s;constructor(e,t,r,o,n,i){this.#t=e,this.#i=t,this.#r=r,this.#n=o,this.#o=n,this.#a=i,this.#e=zT(this.#t,this.#i,this.#n,i),this.#e.intMode=this.#r,this.protocol="http",this.#s=Qq.default(this.#o)}async limit(e){return this.#s(e)}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.limit(async()=>{try{let o=No(r),n,i=this.#e.openStream();try{n=i.query(o)}finally{i.closeGracefully()}let s=await n;return ml(s)}catch(o){throw st(o)}})}async batch(e,t="deferred"){return this.limit(async()=>{try{let o=e.map((c)=>{if(Array.isArray(c))return{sql:c[0],args:c[1]||[]};return c}).map(No),n=await this.#e.getVersion(),i,s=this.#e.openStream();try{new hl(s,Xq).apply(o);let u=s.batch(!1);i=pl(t,n,u,o)}finally{s.closeGracefully()}return await i}catch(r){throw st(r)}})}async migrate(e){return this.limit(async()=>{try{let t=e.map(No),r=await this.#e.getVersion(),o,n=this.#e.openStream();try{let s=n.batch(!1);o=pl("deferred",r,s,t,!0)}finally{n.closeGracefully()}return await o}catch(t){throw st(t)}})}async transaction(e="write"){return this.limit(async()=>{try{let t=await this.#e.getVersion();return new tM(this.#e.openStream(),e,t)}catch(t){throw st(t)}})}async executeMultiple(e){return this.limit(async()=>{try{let t,r=this.#e.openStream();try{t=r.sequence(e)}finally{r.closeGracefully()}await t}catch(t){throw st(t)}})}sync(){throw new Ce("sync not supported in http mode","SYNC_NOT_SUPPORTED")}close(){this.#e.close()}async reconnect(){try{if(!this.closed)this.#e.close()}finally{this.#e=zT(this.#t,this.#i,this.#n,this.#a),this.#e.intMode=this.#r}}get closed(){return this.#e.closed}}var Qq,Xq=30,tM;var rM=w(()=>{my();gn();Kd();DT();Fg();Xc();Qq=Rl(LT(),1);gn();tM=class tM extends uf{#e;#t;constructor(e,t,r){super(t,r);this.#e=e,this.#t=new hl(e,Xq)}_getStream(){return this.#e}_getSqlCache(){return this.#t}close(){this.#e.close()}get closed(){return this.#e.closed}}});function gl(e){return Pfe(Jd(e,!0))}function Pfe(e){if(e.scheme==="wss"||e.scheme==="ws")return Hq(e);else if(e.scheme==="https"||e.scheme==="http")return Yq(e);else return Q4(e)}var BT=w(()=>{Kd();rq();Gq();rM();gn()});function oe(e,t){if(!e||typeof e!=="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,F))throw 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 r=Object.getPrototypeOf(e).constructor;if(r)while(r){if(F in r&&r[F]===t[F])return!0;r=Object.getPrototypeOf(r)}return!1}var F;var Re=w(()=>{F=Symbol.for("drizzle:entityKind")});var He;var Sn=w(()=>{Re();He=class He{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[F]="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(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}});var df;var hy=w(()=>{Re();df=class df{static[F]="ColumnBuilder";config;constructor(e,t,r){this.config={name:e,keyAsName:e==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:r,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){if(this.config.name!=="")return;this.config.name=e}}});var ir;var yl=w(()=>{ir=Symbol.for("drizzle:Name")});var jT,nM;var oM=w(()=>{Re();yl();jT=class jT{static[F]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){if(this.reference=()=>{let{name:r,columns:o,foreignColumns:n}=e();return{name:r,columns:o,foreignTable:n[0].table,foreignColumns:n}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e===void 0?"no action":e,this}onDelete(e){return this._onDelete=e===void 0?"no action":e,this}build(e){return new nM(e,this)}};nM=class nM{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[F]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),o=t.map((s)=>s.name),n=r.map((s)=>s.name),i=[this.table[ir],...o,r[0].table[ir],...n];return e??`${i.join("_")}_fk`}}});function gy(e,...t){return e(...t)}var ZT=()=>{};function UT(e,t){return`${e[ir]}_${t.join("_")}_unique`}var iM,zfe,sM;var aM=w(()=>{Re();yl();iM=class iM{constructor(e,t){this.name=t,this.columns=e}static[F]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new sM(e,this.columns,this.nullsNotDistinctConfig,this.name)}};zfe=class zfe{static[F]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new iM(e,this.name)}};sM=class sM{constructor(e,t,r,o){this.table=e,this.columns=t,this.name=o??UT(this.table,this.columns.map((n)=>n.name)),this.nullsNotDistinct=r}static[F]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}});function cM(e,t,r){for(let o=t;o<e.length;o++){let n=e[o];if(n==="\\"){o++;continue}if(n==='"')return[e.slice(t,o).replace(/\\/g,""),o+1];if(r)continue;if(n===","||n==="}")return[e.slice(t,o).replace(/\\/g,""),o]}return[e.slice(t).replace(/\\/g,""),e.length]}function lM(e,t=0){let r=[],o=t,n=!1;while(o<e.length){let i=e[o];if(i===","){if(n||o===t)r.push("");n=!0,o++;continue}if(n=!1,i==="\\"){o+=2;continue}if(i==='"'){let[c,u]=cM(e,o+1,!0);r.push(c),o=u;continue}if(i==="}")return[r,o+1];if(i==="{"){let[c,u]=lM(e,o+1);r.push(c),o=u;continue}let[s,a]=cM(e,o,!1);r.push(s),o=a}return[r,o]}function uM(e){let[t]=lM(e,1);return t}function qT(e){return`{${e.map((t)=>{if(Array.isArray(t))return qT(t);if(typeof t==="string")return`"${t.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${t}`}).join(",")}}`}var dM=()=>{};var ff,bl,fM,Nfe,pM,MT;var mM=w(()=>{hy();Sn();Re();oM();ZT();aM();dM();ff=class ff extends df{foreignKeyConfigs=[];static[F]="PgColumnBuilder";array(e){return new pM(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:"always",mode:"stored"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:r,actions:o})=>gy((n,i)=>{let s=new jT(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(i.onUpdate)s.onUpdate(i.onUpdate);if(i.onDelete)s.onDelete(i.onDelete);return s.build(t)},r,o))}buildExtraConfigColumn(e){return new fM(e,this.config)}};bl=class bl extends He{constructor(e,t){if(!t.uniqueName)t.uniqueName=UT(e,[t.name]);super(e,t);this.table=e}static[F]="PgColumn"};fM=class fM extends bl{static[F]="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(e){return this.indexConfig.opClass=e,this}};Nfe=class Nfe{static[F]="IndexedColumn";constructor(e,t,r,o){this.name=e,this.keyAsName=t,this.type=r,this.indexConfig=o}name;keyAsName;type;indexConfig};pM=class pM extends ff{static[F]="PgArrayBuilder";constructor(e,t,r){super(e,"array","PgArray");this.config.baseBuilder=t,this.config.size=r}build(e){let t=this.config.baseBuilder.build(e);return new MT(e,this.config,t)}};MT=class MT extends bl{constructor(e,t,r,o){super(e,t);this.baseColumn=r,this.range=o,this.size=t.size}size;static[F]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(e){if(typeof e==="string")e=uM(e);return e.map((t)=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let r=e.map((o)=>o===null?null:oe(this.baseColumn,MT)?this.baseColumn.mapToDriverValue(o,!0):this.baseColumn.mapToDriverValue(o));if(t)return r;return qT(r)}}});function yM(e){return!!e&&typeof e==="function"&&hM in e&&e[hM]===!0}var Dfe,gM,hM,Lfe,bM;var SM=w(()=>{Re();mM();Dfe=class Dfe extends ff{static[F]="PgEnumObjectColumnBuilder";constructor(e,t){super(e,"string","PgEnumObjectColumn");this.config.enum=t}build(e){return new gM(e,this.config)}};gM=class gM extends bl{static[F]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}};hM=Symbol.for("drizzle:isPgEnum");Lfe=class Lfe extends ff{static[F]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn");this.config.enum=t}build(e){return new bM(e,this.config)}};bM=class bM extends bl{static[F]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}}});var ft,pf;var vn=w(()=>{Re();ft=class ft{static[F]="Subquery";constructor(e,t,r,o=!1,n=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:r,isWith:o,usedTables:n}}};pf=class pf extends ft{static[F]="WithSubquery"}});var vM="0.45.2";var wM=()=>{};var FT,JT,xM;var _M=w(()=>{ZT();wM();xM={startActiveSpan(e,t){if(!FT)return t();if(!JT)JT=FT.trace.getTracer("drizzle-orm",vM);return gy((r,o)=>o.startActiveSpan(e,(n)=>{try{return t(n)}catch(i){throw n.setStatus({code:r.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{n.end()}}),FT,JT)}}});var pt;var Do=w(()=>{pt=Symbol.for("drizzle:ViewBaseConfig")});function Ki(e){return e[ir]}function oa(e){return`${e[yy]??"public"}.${e[ir]}`}var yy,by,EM,KT,HT,mf,IM,Bfe,me;var sr=w(()=>{Re();yl();yy=Symbol.for("drizzle:Schema"),by=Symbol.for("drizzle:Columns"),EM=Symbol.for("drizzle:ExtraConfigColumns"),KT=Symbol.for("drizzle:OriginalName"),HT=Symbol.for("drizzle:BaseName"),mf=Symbol.for("drizzle:IsAlias"),IM=Symbol.for("drizzle:ExtraConfigBuilder"),Bfe=Symbol.for("drizzle:IsDrizzleTable");me=class me{static[F]="Table";static Symbol={Name:ir,Schema:yy,OriginalName:KT,Columns:by,ExtraConfigColumns:EM,BaseName:HT,IsAlias:mf,ExtraConfigBuilder:IM};[ir];[KT];[yy];[by];[EM];[HT];[mf]=!1;[Bfe]=!0;[IM]=void 0;constructor(e,t,r){this[ir]=this[KT]=e,this[yy]=t,this[HT]=r}}});function VT(e){return e!==null&&e!==void 0&&typeof e.getSQL==="function"}function Zfe(e){let t={sql:"",params:[]};for(let r of e)if(t.sql+=r.sql,t.params.push(...r.params),r.typings?.length){if(!t.typings)t.typings=[];t.typings.push(...r.typings)}return t}function kM(e){return typeof e==="object"&&e!==null&&"mapToDriverValue"in e&&typeof e.mapToDriverValue==="function"}function C(e,...t){let r=[];if(t.length>0||e.length>0&&e[0]!=="")r.push(new zt(e[0]));for(let[o,n]of t.entries())r.push(n,new zt(e[o+1]));return new xe(r)}function hf(e,t){return e.map((r)=>{if(oe(r,Hi)){if(!(r.name in t))throw Error(`No value for placeholder "${r.name}" was provided`);return t[r.name]}if(oe(r,Br)&&oe(r.value,Hi)){if(!(r.value.name in t))throw Error(`No value for placeholder "${r.value.name}" was provided`);return r.encoder.mapToDriverValue(t[r.value.name])}return r})}var jfe,zt,xe,Sy,AM,TM,XDe,Br,Hi,Ufe,tn;var Yt=w(()=>{Re();SM();vn();_M();Do();Sn();sr();jfe=class jfe{static[F]="FakePrimitiveParam"};zt=class zt{static[F]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new xe([this])}};xe=class xe{constructor(e){this.queryChunks=e;for(let t of e)if(oe(t,me)){let r=t[me.Symbol.Schema];this.usedTables.push(r===void 0?t[me.Symbol.Name]:r+"."+t[me.Symbol.Name])}}static[F]="SQL";decoder=AM;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return xM.startActiveSpan("drizzle.buildSQL",(t)=>{let r=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":r.sql,"drizzle.query.params":JSON.stringify(r.params)}),r})}buildQueryFromSourceParams(e,t){let r=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:o,escapeName:n,escapeParam:i,prepareTyping:s,inlineParams:a,paramStartIndex:c}=r;return Zfe(e.map((u)=>{if(oe(u,zt))return{sql:u.value.join(""),params:[]};if(oe(u,Sy))return{sql:n(u.value),params:[]};if(u===void 0)return{sql:"",params:[]};if(Array.isArray(u)){let d=[new zt("(")];for(let[f,m]of u.entries())if(d.push(m),f<u.length-1)d.push(new zt(", "));return d.push(new zt(")")),this.buildQueryFromSourceParams(d,r)}if(oe(u,xe))return this.buildQueryFromSourceParams(u.queryChunks,{...r,inlineParams:a||u.shouldInlineParams});if(oe(u,me)){let d=u[me.Symbol.Schema],f=u[me.Symbol.Name];return{sql:d===void 0||u[mf]?n(f):n(d)+"."+n(f),params:[]}}if(oe(u,He)){let d=o.getColumnCasing(u);if(t.invokeSource==="indexes")return{sql:n(d),params:[]};let f=u.table[me.Symbol.Schema];return{sql:u.table[mf]||f===void 0?n(u.table[me.Symbol.Name])+"."+n(d):n(f)+"."+n(u.table[me.Symbol.Name])+"."+n(d),params:[]}}if(oe(u,tn)){let d=u[pt].schema,f=u[pt].name;return{sql:d===void 0||u[pt].isAlias?n(f):n(d)+"."+n(f),params:[]}}if(oe(u,Br)){if(oe(u.value,Hi))return{sql:i(c.value++,u),params:[u],typings:["none"]};let d=u.value===null?null:u.encoder.mapToDriverValue(u.value);if(oe(d,xe))return this.buildQueryFromSourceParams([d],r);if(a)return{sql:this.mapInlineParam(d,r),params:[]};let f=["none"];if(s)f=[s(u.encoder)];return{sql:i(c.value++,d),params:[d],typings:f}}if(oe(u,Hi))return{sql:i(c.value++,u),params:[u],typings:["none"]};if(oe(u,xe.Aliased)&&u.fieldAlias!==void 0)return{sql:n(u.fieldAlias),params:[]};if(oe(u,ft)){if(u._.isWith)return{sql:n(u._.alias),params:[]};return this.buildQueryFromSourceParams([new zt("("),u._.sql,new zt(") "),new Sy(u._.alias)],r)}if(yM(u)){if(u.schema)return{sql:n(u.schema)+"."+n(u.enumName),params:[]};return{sql:n(u.enumName),params:[]}}if(VT(u)){if(u.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([u.getSQL()],r);return this.buildQueryFromSourceParams([new zt("("),u.getSQL(),new zt(")")],r)}if(a)return{sql:this.mapInlineParam(u,r),params:[]};return{sql:i(c.value++,u),params:[u],typings:["none"]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return"null";if(typeof e==="number"||typeof e==="boolean")return e.toString();if(typeof e==="string")return t(e);if(typeof e==="object"){let r=e.toString();if(r==="[object Object]")return t(JSON.stringify(e));return t(r)}throw Error("Unexpected param value: "+e)}getSQL(){return this}as(e){if(e===void 0)return this;return new xe.Aliased(this,e)}mapWith(e){return this.decoder=typeof e==="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}};Sy=class Sy{constructor(e){this.value=e}static[F]="Name";brand;getSQL(){return new xe([this])}};AM={mapFromDriverValue:(e)=>e},TM={mapToDriverValue:(e)=>e},XDe={...AM,...TM};Br=class Br{constructor(e,t=TM){this.value=e,this.encoder=t}static[F]="Param";brand;getSQL(){return new xe([this])}};((e)=>{function t(){return new xe([])}e.empty=t;function r(c){return new xe(c)}e.fromList=r;function o(c){return new xe([new zt(c)])}e.raw=o;function n(c,u){let d=[];for(let[f,m]of c.entries()){if(f>0&&u!==void 0)d.push(u);d.push(m)}return new xe(d)}e.join=n;function i(c){return new Sy(c)}e.identifier=i;function s(c){return new Hi(c)}e.placeholder=s;function a(c,u){return new Br(c,u)}e.param=a})(C||(C={}));((e)=>{class t{constructor(r,o){this.sql=r,this.fieldAlias=o}static[F]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(xe||(xe={}));Hi=class Hi{constructor(e){this.name=e}static[F]="Placeholder";getSQL(){return new xe([this])}};Ufe=Symbol.for("drizzle:IsDrizzleView");tn=class tn{static[F]="View";[pt];[Ufe]=!0;constructor({name:e,schema:t,selectedFields:r,query:o}){this[pt]={name:e,originalName:e,schema:t,selectedFields:r,query:o,isExisting:!o,isAlias:!1}}getSQL(){return new xe([this])}};He.prototype.getSQL=function(){return new xe([this])};me.prototype.getSQL=function(){return new xe([this])};ft.prototype.getSQL=function(){return new xe([this])}});function WT(e,t,r){let o={},n=e.reduce((i,{path:s,field:a},c)=>{let u;if(oe(a,He))u=a;else if(oe(a,xe))u=a.decoder;else if(oe(a,ft))u=a._.sql.decoder;else u=a.sql.decoder;let d=i;for(let[f,m]of s.entries())if(f<s.length-1){if(!(m in d))d[m]={};d=d[m]}else{let h=t[c],b=d[m]=h===null?null:u.mapFromDriverValue(h);if(r&&oe(a,He)&&s.length===2){let y=s[0];if(!(y in o))o[y]=b===null?Ki(a.table):!1;else if(typeof o[y]==="string"&&o[y]!==Ki(a.table))o[y]=!1}}return i},{});if(r&&Object.keys(o).length>0){for(let[i,s]of Object.entries(o))if(typeof s==="string"&&!r[s])n[i]=null}return n}function rn(e,t){return Object.entries(e).reduce((r,[o,n])=>{if(typeof o!=="string")return r;let i=t?[...t,o]:[o];if(oe(n,He)||oe(n,xe)||oe(n,xe.Aliased)||oe(n,ft))r.push({path:i,field:n});else if(oe(n,me))r.push(...rn(n[me.Symbol.Columns],i));else r.push(...rn(n,i));return r},[])}function gf(e,t){let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let[n,i]of r.entries())if(i!==o[n])return!1;return!0}function vy(e,t){let r=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,n])=>{if(oe(n,xe)||oe(n,He))return[o,n];else return[o,new Br(n,e[me.Symbol.Columns][o])]});if(r.length===0)throw Error("No values to set");return Object.fromEntries(r)}function $M(e,t){for(let r of t)for(let o of Object.getOwnPropertyNames(r.prototype)){if(o==="constructor")continue;Object.defineProperty(e.prototype,o,Object.getOwnPropertyDescriptor(r.prototype,o)||Object.create(null))}}function wy(e){return e[me.Symbol.Columns]}function yf(e){return oe(e,ft)?e._.alias:oe(e,tn)?e[pt].name:oe(e,xe)?void 0:e[me.Symbol.IsAlias]?e[me.Symbol.Name]:e[me.Symbol.BaseName]}function Yn(e,t){return{name:typeof e==="string"&&e.length>0?e:"",config:typeof e==="object"?e:t}}function RM(e){if(typeof e!=="object"||e===null)return!1;if(e.constructor.name!=="Object")return!1;if("logger"in e){let t=typeof e.logger;if(t!=="boolean"&&(t!=="object"||typeof e.logger.logQuery!=="function")&&t!=="undefined")return!1;return!0}if("schema"in e){let t=typeof e.schema;if(t!=="object"&&t!=="undefined")return!1;return!0}if("casing"in e){let t=typeof e.casing;if(t!=="string"&&t!=="undefined")return!1;return!0}if("mode"in e){if(e.mode!=="default"||e.mode!=="planetscale"||e.mode!==void 0)return!1;return!0}if("connection"in e){let t=typeof e.connection;if(t!=="string"&&t!=="object"&&t!=="undefined")return!1;return!0}if("client"in e){let t=typeof e.client;if(t!=="object"&&t!=="function"&&t!=="undefined")return!1;return!0}if(Object.keys(e).length===0)return!0;return!1}var GT;var br=w(()=>{Sn();Re();Yt();vn();sr();Do();GT=typeof TextDecoder>"u"?null:new TextDecoder});var OM,QT,YT;var xy=w(()=>{Re();OM=class OM{static[F]="ConsoleLogWriter";write(e){console.log(e)}};QT=class QT{static[F]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new OM}logQuery(e,t){let r=t.map((n)=>{try{return JSON.stringify(n)}catch{return String(n)}}),o=r.length?` -- params: [${r.join(", ")}]`:"";this.writer.write(`Query: ${e}${o}`)}};YT=class YT{static[F]="NoopLogger";logQuery(){}}});var CM,PM,XT;var zM=w(()=>{Re();sr();CM=Symbol.for("drizzle:PgInlineForeignKeys"),PM=Symbol.for("drizzle:EnableRLS");XT=class XT extends me{static[F]="PgTable";static Symbol=Object.assign({},me.Symbol,{InlineForeignKeys:CM,EnableRLS:PM});[CM]=[];[PM]=!1;[me.Symbol.ExtraConfigBuilder]=void 0;[me.Symbol.ExtraConfigColumns]={}}});var e$,NM;var DM=w(()=>{Re();zM();e$=class e${static[F]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new NM(e,this.columns,this.name)}};NM=class NM{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[F]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[XT.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Tr(e,t){if(kM(t)&&!VT(e)&&!oe(e,Br)&&!oe(e,Hi)&&!oe(e,He)&&!oe(e,me)&&!oe(e,tn))return new Br(e,t);return e}function tt(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new xe(t);return new xe([new zt("("),C.join(t,new zt(" and ")),new zt(")")])}function nn(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new xe(t);return new xe([new zt("("),C.join(t,new zt(" or ")),new zt(")")])}function BM(e){return C`not ${e}`}function Wi(e,t){if(Array.isArray(t)){if(t.length===0)return C`false`;return C`${e} in ${t.map((r)=>Tr(r,e))}`}return C`${e} in ${Tr(t,e)}`}function _y(e,t){if(Array.isArray(t)){if(t.length===0)return C`true`;return C`${e} not in ${t.map((r)=>Tr(r,e))}`}return C`${e} not in ${Tr(t,e)}`}function jr(e){return C`${e} is null`}function UM(e){return C`${e} is not null`}function Ey(e){return C`exists ${e}`}function Gi(e){return C`not exists ${e}`}function qM(e,t,r){return C`${e} between ${Tr(t,e)} and ${Tr(r,e)}`}function MM(e,t,r){return C`${e} not between ${Tr(t,e)} and ${Tr(r,e)}`}function FM(e,t){return C`${e} like ${t}`}function JM(e,t){return C`${e} not like ${t}`}function KM(e,t){return C`${e} ilike ${t}`}function HM(e,t){return C`${e} not ilike ${t}`}var je=(e,t)=>C`${e} = ${Tr(t,e)}`,LM=(e,t)=>C`${e} <> ${Tr(t,e)}`,wn=(e,t)=>C`${e} > ${Tr(t,e)}`,jM=(e,t)=>C`${e} >= ${Tr(t,e)}`,ZM=(e,t)=>C`${e} < ${Tr(t,e)}`,Vi=(e,t)=>C`${e} <= ${Tr(t,e)}`;var VM=w(()=>{Sn();Re();sr();Yt()});function Lo(e){return C`${e} asc`}function ia(e){return C`${e} desc`}var WM=w(()=>{Yt()});var t$=w(()=>{VM();WM()});function QM(){return{and:tt,between:qM,eq:je,exists:Ey,gt:wn,gte:jM,ilike:KM,inArray:Wi,isNull:jr,isNotNull:UM,like:FM,lt:ZM,lte:Vi,ne:LM,not:BM,notBetween:MM,notExists:Gi,notLike:JM,notIlike:HM,notInArray:_y,or:nn,sql:C}}function YM(){return{sql:C,asc:Lo,desc:ia}}function XM(e,t){if(Object.keys(e).length===1&&"default"in e&&!oe(e.default,me))e=e.default;let r={},o={},n={};for(let[i,s]of Object.entries(e))if(oe(s,me)){let a=oa(s),c=o[a];r[a]=i,n[i]={tsName:i,dbName:s[me.Symbol.Name],schema:s[me.Symbol.Schema],columns:s[me.Symbol.Columns],relations:c?.relations??{},primaryKey:c?.primaryKey??[]};for(let d of Object.values(s[me.Symbol.Columns]))if(d.primary)n[i].primaryKey.push(d);let u=s[me.Symbol.ExtraConfigBuilder]?.(s[me.Symbol.ExtraConfigColumns]);if(u){for(let d of Object.values(u))if(oe(d,e$))n[i].primaryKey.push(...d.columns)}}else if(oe(s,GM)){let a=oa(s.table),c=r[a],u=s.config(t(s.table)),d;for(let[f,m]of Object.entries(u))if(c){let h=n[c];if(h.relations[f]=m,d)h.primaryKey.push(...d)}else{if(!(a in o))o[a]={relations:{},primaryKey:d};o[a].relations[f]=m}}return{tables:n,tableNamesMap:r}}function qfe(e){return function(r,o){return new Qi(e,r,o,o?.fields.reduce((n,i)=>n&&i.notNull,!0)??!1)}}function Mfe(e){return function(r,o){return new bf(e,r,o)}}function eF(e,t,r){if(oe(r,Qi)&&r.config)return{fields:r.config.fields,references:r.config.references};let o=t[oa(r.referencedTable)];if(!o)throw Error(`Table "${r.referencedTable[me.Symbol.Name]}" not found in schema`);let n=e[o];if(!n)throw Error(`Table "${o}" not found in schema`);let i=r.sourceTable,s=t[oa(i)];if(!s)throw Error(`Table "${i[me.Symbol.Name]}" not found in schema`);let a=[];for(let c of Object.values(n.relations))if(r.relationName&&r!==c&&c.relationName===r.relationName||!r.relationName&&c.referencedTable===r.sourceTable)a.push(c);if(a.length>1)throw r.relationName?Error(`There are multiple relations with name "${r.relationName}" in table "${o}"`):Error(`There are multiple relations between "${o}" and "${r.sourceTable[me.Symbol.Name]}". Please specify relation name`);if(a[0]&&oe(a[0],Qi)&&a[0].config)return{fields:a[0].config.references,references:a[0].config.fields};throw Error(`There is not enough information to infer relation "${s}.${r.fieldName}"`)}function tF(e){return{one:qfe(e),many:Mfe(e)}}function Iy(e,t,r,o,n=(i)=>i){let i={};for(let[s,a]of o.entries())if(a.isJson){let c=t.relations[a.tsKey],u=r[s],d=typeof u==="string"?JSON.parse(u):u;i[a.tsKey]=oe(c,Qi)?d&&Iy(e,e[a.relationTableTsKey],d,a.selection,n):d.map((f)=>Iy(e,e[a.relationTableTsKey],f,a.selection,n))}else{let c=n(r[s]),u=a.field,d;if(oe(u,He))d=u;else if(oe(u,xe))d=u.decoder;else d=u.sql.decoder;i[a.tsKey]=c===null?null:d.mapFromDriverValue(c)}return i}var r$,GM,Qi,bf;var Sf=w(()=>{sr();Sn();Re();DM();t$();Yt();r$=class r${constructor(e,t,r){this.sourceTable=e,this.referencedTable=t,this.relationName=r,this.referencedTableName=t[me.Symbol.Name]}static[F]="Relation";referencedTableName;fieldName};GM=class GM{constructor(e,t){this.table=e,this.config=t}static[F]="Relations"};Qi=class Qi extends r${constructor(e,t,r,o){super(e,t,r?.relationName);this.config=r,this.isNullable=o}static[F]="One";withFieldName(e){let t=new Qi(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}};bf=class bf extends r${constructor(e,t,r){super(e,t,r?.relationName);this.config=r}static[F]="Many";withFieldName(e){let t=new bf(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}});function vf(e,t){return new Proxy(e,new sa(t,!1))}function Xn(e,t){return new Proxy(e,new Sl(new Proxy(e.table,new sa(t,!1))))}function n$(e,t){return new xe.Aliased(wf(e.sql,t),e.fieldAlias)}function wf(e,t){return C.join(e.queryChunks.map((r)=>{if(oe(r,He))return Xn(r,t);if(oe(r,xe))return wf(r,t);if(oe(r,xe.Aliased))return n$(r,t);return r}))}var Sl,sa,Ffe;var xf=w(()=>{Sn();Re();Yt();sr();Do();Sl=class Sl{constructor(e){this.table=e}static[F]="ColumnAliasProxyHandler";get(e,t){if(t==="table")return this.table;return e[t]}};sa=class sa{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[F]="TableAliasProxyHandler";get(e,t){if(t===me.Symbol.IsAlias)return!0;if(t===me.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===me.Symbol.OriginalName)return this.alias;if(t===pt)return{...e[pt],name:this.alias,isAlias:!0};if(t===me.Symbol.Columns){let o=e[me.Symbol.Columns];if(!o)return o;let n={};return Object.keys(o).map((i)=>{n[i]=new Proxy(o[i],new Sl(new Proxy(e,this)))}),n}let r=e[t];if(oe(r,He))return new Proxy(r,new Sl(new Proxy(e,this)));return r}};Ffe=class Ffe{constructor(e){this.alias=e}static[F]="RelationTableAliasProxyHandler";get(e,t){if(t==="sourceTable")return vf(e.sourceTable,this.alias);return e[t]}}});var at;var aa=w(()=>{xf();Sn();Re();Yt();vn();Do();at=class at{static[F]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if(t==="_")return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===pt)return{...e[pt],selectedFields:new Proxy(e[pt].selectedFields,this)};if(typeof t==="symbol")return e[t];let o=(oe(e,ft)?e._.selectedFields:oe(e,tn)?e[pt].selectedFields:e)[t];if(oe(o,xe.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!o.isSelectionField)return o.sql;let n=o.clone();return n.isSelectionField=!0,n}if(oe(o,xe)){if(this.config.sqlBehavior==="sql")return o;throw Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(oe(o,He)){if(this.config.alias)return new Proxy(o,new Sl(new Proxy(o.table,new sa(this.config.alias,this.config.replaceOriginalName??!1))));return o}if(typeof o!=="object"||o===null)return o;return new Proxy(o,new at(this.config))}}});var Sr;var Bo=w(()=>{Re();Sr=class Sr{static[F]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then((t)=>(e?.(),t),(t)=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}});var o$,rF;var i$=w(()=>{Re();yl();o$=class o${static[F]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){if(this.reference=()=>{let{name:r,columns:o,foreignColumns:n}=e();return{name:r,columns:o,foreignTable:n[0].table,foreignColumns:n}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new rF(e,this)}};rF=class rF{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[F]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),o=t.map((s)=>s.name),n=r.map((s)=>s.name),i=[this.table[ir],...o,r[0].table[ir],...n];return e??`${i.join("_")}_fk`}}});function s$(e,t){return`${e[ir]}_${t.join("_")}_unique`}var nF,Jfe,oF;var a$=w(()=>{Re();yl();nF=class nF{constructor(e,t){this.name=t,this.columns=e}static[F]="SQLiteUniqueConstraintBuilder";columns;build(e){return new oF(e,this.columns,this.name)}};Jfe=class Jfe{static[F]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new nF(e,this.name)}};oF=class oF{constructor(e,t,r){this.table=e,this.columns=t,this.name=r??s$(this.table,this.columns.map((o)=>o.name))}static[F]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}});var jt,yt;var Yi=w(()=>{hy();Sn();Re();i$();a$();jt=class jt extends df{static[F]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:r,actions:o})=>((n,i)=>{let s=new o$(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(i.onUpdate)s.onUpdate(i.onUpdate);if(i.onDelete)s.onDelete(i.onDelete);return s.build(t)})(r,o))}};yt=class yt extends He{constructor(e,t){if(!t.uniqueName)t.uniqueName=s$(e,[t.name]);super(e,t);this.table=e}static[F]="SQLiteColumn"}});function dF(e,t){let{name:r,config:o}=Yn(e,t);if(o?.mode==="json")return new aF(r);if(o?.mode==="bigint")return new iF(r);return new lF(r)}var iF,sF,aF,cF,lF,uF;var c$=w(()=>{Re();br();Yi();iF=class iF extends jt{static[F]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new sF(e,this.config)}};sF=class sF extends yt{static[F]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString("utf8"))}return BigInt(GT.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}};aF=class aF extends jt{static[F]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new cF(e,this.config)}};cF=class cF extends yt{static[F]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString("utf8"))}return JSON.parse(GT.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}};lF=class lF extends jt{static[F]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new uF(e,this.config)}};uF=class uF extends yt{static[F]="SQLiteBlobBuffer";mapFromDriverValue(e){if(Buffer.isBuffer(e))return e;return Buffer.from(e)}getSQLType(){return"blob"}}});function mF(e){return(t,r)=>{let{name:o,config:n}=Yn(t,r);return new fF(o,n,e)}}var fF,pF;var l$=w(()=>{Re();br();Yi();fF=class fF extends jt{static[F]="SQLiteCustomColumnBuilder";constructor(e,t,r){super(e,"custom","SQLiteCustomColumn");this.config.fieldConfig=t,this.config.customTypeParams=r}build(e){return new pF(e,this.config)}};pF=class pF extends yt{static[F]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t);this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==="function"?this.mapTo(e):e}}});function ar(e,t){let{name:r,config:o}=Yn(e,t);if(o?.mode==="timestamp"||o?.mode==="timestamp_ms")return new yF(r,o.mode);if(o?.mode==="boolean")return new SF(r,o.mode);return new hF(r)}var ky,Ay,hF,gF,yF,bF,SF,vF;var u$=w(()=>{Re();Yt();br();Yi();ky=class ky extends jt{static[F]="SQLiteBaseIntegerBuilder";constructor(e,t,r){super(e,t,r);this.config.autoIncrement=!1}primaryKey(e){if(e?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}};Ay=class Ay extends yt{static[F]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}};hF=class hF extends ky{static[F]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new gF(e,this.config)}};gF=class gF extends Ay{static[F]="SQLiteInteger"};yF=class yF extends ky{static[F]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp");this.config.mode=t}defaultNow(){return this.default(C`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new bF(e,this.config)}};bF=class bF extends Ay{static[F]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){if(this.config.mode==="timestamp")return new Date(e*1000);return new Date(e)}mapToDriverValue(e){let t=e.getTime();if(this.config.mode==="timestamp")return Math.floor(t/1000);return t}};SF=class SF extends ky{static[F]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean");this.config.mode=t}build(e){return new vF(e,this.config)}};vF=class vF extends Ay{static[F]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}}});function AF(e,t){let{name:r,config:o}=Yn(e,t),n=o?.mode;return n==="number"?new _F(r):n==="bigint"?new IF(r):new wF(r)}var wF,xF,_F,EF,IF,kF;var d$=w(()=>{Re();br();Yi();wF=class wF extends jt{static[F]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new xF(e,this.config)}};xF=class xF extends yt{static[F]="SQLiteNumeric";mapFromDriverValue(e){if(typeof e==="string")return e;return String(e)}getSQLType(){return"numeric"}};_F=class _F extends jt{static[F]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new EF(e,this.config)}};EF=class EF extends yt{static[F]="SQLiteNumericNumber";mapFromDriverValue(e){if(typeof e==="number")return e;return Number(e)}mapToDriverValue=String;getSQLType(){return"numeric"}};IF=class IF extends jt{static[F]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new kF(e,this.config)}};kF=class kF extends yt{static[F]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}});function RF(e){return new TF(e??"")}var TF,$F;var f$=w(()=>{Re();Yi();TF=class TF extends jt{static[F]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new $F(e,this.config)}};$F=class $F extends yt{static[F]="SQLiteReal";getSQLType(){return"real"}}});function mt(e,t={}){let{name:r,config:o}=Yn(e,t);if(o.mode==="json")return new PF(r);return new OF(r,o)}var OF,CF,PF,zF;var p$=w(()=>{Re();br();Yi();OF=class OF extends jt{static[F]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText");this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new CF(e,this.config)}};CF=class CF extends yt{static[F]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}};PF=class PF extends jt{static[F]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new zF(e,this.config)}};zF=class zF extends yt{static[F]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}});function NF(){return{blob:dF,customType:mF,integer:ar,numeric:AF,real:RF,text:mt}}var DF=w(()=>{c$();l$();u$();d$();f$();p$()});function Kfe(e,t,r,o,n=e){let i=new At(e,o,n),s=typeof t==="function"?t(NF()):t,a=Object.fromEntries(Object.entries(s).map(([u,d])=>{let f=d;f.setName(u);let m=f.build(i);return i[m$].push(...f.buildForeignKeys(m,i)),[u,m]})),c=Object.assign(i,a);if(c[me.Symbol.Columns]=a,c[me.Symbol.ExtraConfigColumns]=a,r)c[At.Symbol.ExtraConfigBuilder]=r;return c}var m$,At,_f=(e,t,r)=>Kfe(e,t,r);var jo=w(()=>{Re();sr();DF();m$=Symbol.for("drizzle:SQLiteInlineForeignKeys");At=class At extends me{static[F]="SQLiteTable";static Symbol=Object.assign({},me.Symbol,{InlineForeignKeys:m$});[me.Symbol.Columns];[m$]=[];[me.Symbol.ExtraConfigBuilder]=void 0}});var Hfe,LF;var BF=w(()=>{Re();Hfe=class Hfe{constructor(e,t){this.name=e,this.value=t}static[F]="SQLiteCheckBuilder";brand;build(e){return new LF(e,this)}};LF=class LF{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}static[F]="SQLiteCheck";name;value}});function Zo(e){return new jF(e,!1)}var jF,ZF,UF;var qF=w(()=>{Re();jF=class jF{constructor(e,t){this.name=e,this.unique=t}static[F]="SQLiteIndexBuilderOn";on(...e){return new ZF(this.name,e,this.unique)}};ZF=class ZF{static[F]="SQLiteIndexBuilder";config;constructor(e,t,r){this.config={name:e,columns:t,unique:r,where:void 0}}where(e){return this.config.where=e,this}build(e){return new UF(this.config,e)}};UF=class UF{static[F]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}});var Vfe,MF;var FF=w(()=>{Re();jo();Vfe=class Vfe{static[F]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new MF(e,this.columns,this.name)}};MF=class MF{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[F]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[At.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function xn(e){if(oe(e,At))return[`${e[me.Symbol.BaseName]}`];if(oe(e,ft))return e._.usedTables??[];if(oe(e,xe))return e.usedTables??[];return[]}var vl=w(()=>{Re();Yt();vn();sr();jo()});var Ty;var JF=w(()=>{Re();Bo();aa();jo();sr();br();vl();Ty=class Ty extends Sr{constructor(e,t,r,o){super();this.table=e,this.session=t,this.dialect=r,this.config={table:e,withList:o}}static[F]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.table[me.Symbol.Columns],new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];this.config.orderBy=r}else{let t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.table[At.Symbol.Columns]){return this.config.returning=rn(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"delete",tables:xn(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}});function Wfe(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((r)=>r.toLowerCase()).join("_")}function Gfe(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((r,o,n)=>{let i=n===0?o.toLowerCase():`${o[0].toUpperCase()}${o.slice(1)}`;return r+i},"")}function Qfe(e){return e}var h$;var KF=w(()=>{Re();sr();h$=class h${static[F]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?Wfe:e==="camelCase"?Gfe:Qfe}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[me.Symbol.Schema]??"public",r=e.table[me.Symbol.OriginalName],o=`${t}.${r}.${e.name}`;if(!this.cache[o])this.cacheTable(e.table);return this.cache[o]}cacheTable(e){let t=e[me.Symbol.Schema]??"public",r=e[me.Symbol.OriginalName],o=`${t}.${r}`;if(!this.cachedTables[o]){for(let n of Object.values(e[me.Symbol.Columns])){let i=`${o}.${n.name}`;this.cache[i]=this.convert(n.name)}this.cachedTables[o]=!0}}clearCache(){this.cache={},this.cachedTables={}}}});var wl,Uo,g$;var $y=w(()=>{Re();wl=class wl extends Error{static[F]="DrizzleError";constructor({message:e,cause:t}){super(e);this.name="DrizzleError",this.cause=t}};Uo=class Uo extends Error{constructor(e,t,r){super(`Failed query: ${e}
383
+ `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=jh(e),r=gc(t);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=jh(e),r=gc(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((r)=>r.type==="newline"||r.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}eoe.Parser=rB});var aB=ge(function(loe){var nB=NI(),roe=Fu(),Gu=Ju(),noe=JE(),ooe=Me(),ioe=JI(),oB=KI();function iB(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new ioe.LineCounter||null,prettyErrors:t}}function soe(e,t={}){let{lineCounter:r,prettyErrors:o}=iB(t),n=new oB.Parser(r?.addNewLine),i=new nB.Composer(t),s=Array.from(i.compose(n.parse(e)));if(o&&r)for(let a of s)a.errors.forEach(Gu.prettifyError(e,r)),a.warnings.forEach(Gu.prettifyError(e,r));if(s.length>0)return s;return Object.assign([],{empty:!0},i.streamInfo())}function sB(e,t={}){let{lineCounter:r,prettyErrors:o}=iB(t),n=new oB.Parser(r?.addNewLine),i=new nB.Composer(t),s=null;for(let a of i.compose(n.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new Gu.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(o&&r)s.errors.forEach(Gu.prettifyError(e,r)),s.warnings.forEach(Gu.prettifyError(e,r));return s}function aoe(e,t,r){let o=void 0;if(typeof t==="function")o=t;else if(r===void 0&&t&&typeof t==="object")r=t;let n=sB(e,r);if(!n)return null;if(n.warnings.forEach((i)=>noe.warn(n.options.logLevel,i)),n.errors.length>0)if(n.options.logLevel!=="silent")throw n.errors[0];else n.errors=[];return n.toJS(Object.assign({reviver:o},r))}function coe(e,t,r){let o=null;if(typeof t==="function"||Array.isArray(t))o=t;else if(r===void 0&&t)r=t;if(typeof r==="string")r=r.length;if(typeof r==="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(e===void 0){let{keepUndefined:n}=r??t??{};if(!n)return}if(ooe.isDocument(e)&&!o)return e.toString(r);return new roe.Document(e,o,r).toString(r)}loe.parse=aoe;loe.parseAllDocuments=soe;loe.parseDocument=sB;loe.stringify=coe});var moe,hoe,goe,HI,yoe,hi,boe,Soe,voe,woe,sTe,xoe,_oe,Eoe,Uh,cB,Ioe,koe,Aoe,Toe,$oe,Roe,Ooe,Coe,Poe,zoe,po,mo,Noe,yc,VI,Doe,Loe,Boe,joe,Zoe,Uoe,qoe,Moe,Foe,Ln,Joe,Koe,Hoe;var Qu=w(()=>{moe=NI(),hoe=Fu(),goe=SI(),HI=Ju(),yoe=Ru(),hi=Me(),boe=ui(),Soe=Et(),voe=fi(),woe=pi(),sTe=Lh(),xoe=FI(),_oe=JI(),Eoe=KI(),Uh=aB(),cB=Tu();Ioe=moe.Composer,koe=hoe.Document,Aoe=goe.Schema,Toe=HI.YAMLError,$oe=HI.YAMLParseError,Roe=HI.YAMLWarning,Ooe=yoe.Alias,Coe=hi.isAlias,Poe=hi.isCollection,zoe=hi.isDocument,po=hi.isMap,mo=hi.isNode,Noe=hi.isPair,yc=hi.isScalar,VI=hi.isSeq,Doe=boe.Pair,Loe=Soe.Scalar,Boe=voe.YAMLMap,joe=woe.YAMLSeq,Zoe=xoe.Lexer,Uoe=_oe.LineCounter,qoe=Eoe.Parser,Moe=Uh.parse,Foe=Uh.parseAllDocuments,Ln=Uh.parseDocument,Joe=Uh.stringify,Koe=cB.visit,Hoe=cB.visitAsync});var mB={};Ut(mB,{assertPilotUsersRemoved:()=>GI,createPilotOffboardDriver:()=>WI,offboardPilotUsers:()=>uB});import{access as Voe,readdir as Woe,readFile as Goe,rm as Yu,writeFile as Qoe}from"fs/promises";import{basename as Yoe,join as ho}from"path";async function uB(e,t){let r=[...new Set(t.handles.map((f)=>pr.parse(f)))].sort((f,m)=>f.localeCompare(m));if(r.length===0)throw Error("At least one pilot handle is required");let o=t.dryRun??!0,n=`sunset:${r.join(",")}`;if(!o&&t.confirmation!==n)throw Error(`Exact confirmation required: ${n}`);let i=t.env??process.env,s=t.logger??console.info,a=await ut(e),c=r.map((f)=>Xoe(a,f,i)),u=t.driver??WI({env:i,fetchImpl:t.fetchImpl,contentRepoTokenName:a.pilot.contentRepoAdminToken}),d=await Promise.all(c.map(async(f)=>({target:f,inspection:await u.inspect(f)})));if(tie(d),rie(d,o,s),!o){for(let f of d)if(!f.inspection.contentRepoArchived)await u.archiveContentRepo(f.target),s(`[${f.target.handle}] archived ${f.target.contentRepo}`);for(let f of d)for(let m of f.inspection.dnsRecords)await u.deleteDnsRecord(f.target,m),s(`[${f.target.handle}] deleted DNS ${m.name}`);for(let f of d)if(f.inspection.server)await u.deleteServer(f.target,f.inspection.server),s(`[${f.target.handle}] deleted ${f.target.instanceName}`);await eie(c,u,t.sleep??((f)=>new Promise((m)=>setTimeout(m,f)))),await nie(e,r),await ao(e),await GI(e,r),s(`Removed desired state for ${r.length} pilot user(s)`)}return{dryRun:o,handles:r,confirmation:n,plans:d}}function Xoe(e,t,r){let o=e.users.find((d)=>d.handle===t),n=`${t}${e.pilot.domainSuffix}`,i=o?.domain??n,s=$E(i,{sharedDomain:e.pilot.domainSuffix}),a=o?.cloudflareZoneId??qh(r,"CF_ZONE_ID"),c=o?.contentRepo??`${e.pilot.contentRepoPrefix}${t}-content`,u=c.includes("/")?c:`${e.pilot.githubOrg}/${c}`;return{handle:t,instanceName:`rover-${t}`,domain:i,previewDomain:s,...i===n?{}:{wwwDomain:`www.${i}`},contentRepo:u,cloudflareZoneId:a}}async function eie(e,t,r){for(let o of e)for(let n=1;n<=20;n+=1){let i=await t.inspect(o);if(!i.server&&i.dnsRecords.length===0&&i.contentRepoArchived)break;if(n===20)throw Error(`[${o.handle}] provider cleanup did not converge`);await r(1500)}}function tie(e){for(let{target:t,inspection:r}of e){if(r.server&&r.server.name!==t.instanceName)throw Error(`[${t.handle}] unexpected server name: ${r.server.name}`);let o=new Set([t.domain,t.previewDomain,...t.wwwDomain?[t.wwwDomain]:[]]);for(let n of r.dnsRecords){if(!o.has(n.name))throw Error(`[${t.handle}] refusing unexpected DNS record ${n.name}`);if(n.type==="A"&&r.server?.ip&&n.content!==r.server.ip)throw Error(`[${t.handle}] ${n.name} does not point to the retiring server`)}}}function rie(e,t,r){r(`${t?"Dry run":"Apply"}: ${e.map(({target:o})=>o.handle).join(", ")}`);for(let{target:o,inspection:n}of e){let i=n.server?`delete ${o.instanceName}`:"already absent",s=n.dnsRecords.length>0?n.dnsRecords.map((c)=>`${c.type} ${c.name}`).join(", "):"already absent",a=n.contentRepoArchived?"already archived":`archive ${o.contentRepo}`;r(`[${o.handle}] server: ${i}; DNS: ${s}; repo: ${a}`)}r("Runtime backups: none")}async function nie(e,t){let r=new Set(t),o=ho(e,"cohorts");for(let n of(await Woe(o)).filter((i)=>i.endsWith(".yaml"))){let i=ho(o,n),s=await Goe(i,"utf8"),a=Ln(s);if(a.errors.length>0)throw Error(`${n}: ${a.errors[0]?.message??"invalid YAML"}`);let c=a.get("members",!0);if(!VI(c))throw Error(`${n}: members must be a sequence`);let u=c.items.filter((d)=>!yc(d)||typeof d.value!=="string"||!r.has(d.value));if(u.length===c.items.length)continue;if(u.length===0){await Yu(i);continue}c.items=u,qr.parse(a.toJS()),await Qoe(i,a.toString())}for(let n of t)await Promise.all([Yu(ho(e,"users",`${n}.yaml`),{force:!0}),Yu(ho(e,"users",`${n}.secrets.yaml`),{force:!0}),Yu(ho(e,"users",`${n}.secrets.yaml.age`),{force:!0}),Yu(ho(e,"users",n),{recursive:!0,force:!0})])}function WI(e){let t=e.fetchImpl??fetch,r=qh(e.env,"HCLOUD_TOKEN"),o=qh(e.env,"CF_API_TOKEN"),n=qh(e.env,e.contentRepoTokenName);return{async inspect(i){let[s,a,c]=await Promise.all([oie(t,r,i.instanceName),Promise.all([i.domain,i.previewDomain,...i.wwwDomain?[i.wwwDomain]:[]].map((u)=>iie(t,o,i.cloudflareZoneId,u))).then((u)=>u.flat()),sie(t,n,i.contentRepo)]);if(s.length>1)throw Error(`[${i.handle}] expected at most one server, found ${s.length}`);return{...s[0]?{server:s[0]}:{},dnsRecords:a,contentRepoArchived:c.archived}},async archiveContentRepo(i){await bc(t,`https://api.github.com/repos/${i.contentRepo}`,{method:"PATCH",headers:dB(n),body:JSON.stringify({archived:!0})},"GitHub repository archive")},async deleteDnsRecord(i,s){if(Sc(await bc(t,`https://api.cloudflare.com/client/v4/zones/${i.cloudflareZoneId}/dns_records/${s.id}`,{method:"DELETE",headers:fB(o)},"Cloudflare DNS delete")).success!==!0)throw Error(`Cloudflare DNS delete failed for ${s.name}`)},async deleteServer(i,s){await bc(t,`https://api.hetzner.cloud/v1/servers/${s.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}},"Hetzner server delete",!0)}}}async function oie(e,t,r){let o=new URL("https://api.hetzner.cloud/v1/servers");o.searchParams.set("label_selector",`brain=${r}`);let i=Sc(await bc(e,o.toString(),{headers:{Authorization:`Bearer ${t}`}},"Hetzner server lookup")).servers;if(!Array.isArray(i))throw Error("Hetzner server lookup returned an invalid payload");return i.map((s)=>{let a=Sc(s),c=lB(a.public_net),u=lB(c?.ipv4);return{id:aie(a.id,"Hetzner server id"),name:Xu(a.name,"Hetzner server name"),...typeof u?.ip==="string"?{ip:u.ip}:{}}})}async function iie(e,t,r,o){let n=new URL(`https://api.cloudflare.com/client/v4/zones/${r}/dns_records`);n.searchParams.set("name",o);let i=Sc(await bc(e,n.toString(),{headers:fB(t)},"Cloudflare DNS lookup")),s=i.result;if(i.success!==!0||!Array.isArray(s))throw Error(`Cloudflare DNS lookup failed for ${o}`);return s.map((a)=>{let c=Sc(a),u=Xu(c.type,"Cloudflare record type");if(u!=="A"&&u!=="CNAME")throw Error(`Unsupported Cloudflare record type ${u} for ${o}`);return{id:Xu(c.id,"Cloudflare record id"),name:Xu(c.name,"Cloudflare record name"),type:u,content:Xu(c.content,"Cloudflare record content")}})}async function sie(e,t,r){let o=Sc(await bc(e,`https://api.github.com/repos/${r}`,{headers:dB(t)},"GitHub repository lookup"));if(typeof o.archived!=="boolean")throw Error(`Invalid repository archive state for ${r}`);return{archived:o.archived}}async function bc(e,t,r,o,n=!1){let i=await e(t,r),s=await i.text();if(!i.ok)throw Error(`${o} failed (${i.status}): ${s}`);if(!s&&n)return{};try{return JSON.parse(s)}catch{throw Error(`${o} returned an invalid JSON response`)}}function dB(e){return{Accept:"application/vnd.github+json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"}}function fB(e){return{Authorization:`Bearer ${e}`}}function qh(e,t){let r=e[t];if(!r)throw Error(`Missing required environment variable: ${t}`);return r}function pB(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Sc(e){if(!pB(e))throw Error("Provider returned an unexpected payload");return e}function lB(e){return pB(e)?e:void 0}function Xu(e,t){if(typeof e!=="string"||e.length===0)throw Error(`Missing ${t}`);return e}function aie(e,t){if(typeof e!=="number")throw Error(`Missing ${t}`);return e}async function cie(e){try{return await Voe(e),!0}catch{return!1}}async function GI(e,t){for(let r of t)for(let o of[ho(e,"users",`${r}.yaml`),ho(e,"users",`${r}.secrets.yaml.age`),ho(e,"users",r)])if(await cie(o))throw Error(`Offboarded user state remains: ${Yoe(o)}`)}var QI=w(()=>{Qu();Mr();RE();ec();Pn()});var f6={};Ut(f6,{upgradePilotRepo:()=>xle});import{readFile as ble}from"fs/promises";import{join as Sle}from"path";async function d6(e){let t=Sle(e,"package.json"),o=vle.parse(JSON.parse(await ble(t,"utf8"))).devDependencies?.["@rizom/ops"];if(!o)throw Error(`${t} does not pin @rizom/ops as a devDependency`);return o}async function wle(e,t){let o=await Bun.spawn(e,{cwd:t,stdout:"inherit",stderr:"inherit"}).exited;if(o!==0)throw Error(`${e.join(" ")} failed with exit ${o}`)}async function xle(e,t={}){let r=t.exec??wle,o=await d6(e),n=t.version??"latest";await r(["bun","add","--dev","--exact",`@rizom/ops@${n}`],e);let i=await d6(e);return await r(["bun","x","brains-ops","init","."],e),{from:o,to:i}}var vle;var p6=w(()=>{he();vle=l.object({devDependencies:l.record(l.string(),l.string()).optional()})});function m6(e){if(e===null||typeof e!=="object"||Array.isArray(e))return!1;let t=_le(e);return t===Object.prototype||t===null}var _le;var h6=w(()=>{_le=Object.getPrototypeOf});function S6(e){if(e==="core")return{bundles:["core","media","web","chat"]};if(e==="default")return{bundles:["core","media","automation","web","chat","site","publishing","federation"],add:["obsidian-vault"],remove:[...kle]};return{bundles:["core","media","automation","web","chat","site","publishing","federation"],add:["obsidian-vault"]}}function Ale(e){let t=Ele.parse(e);return si.parse({brainVersion:t.brainVersion,bundleContract:ii,...S6(t.preset),githubOrg:t.githubOrg,contentRepoPrefix:t.contentRepoPrefix,domainSuffix:t.domainSuffix,aiApiKey:t.aiApiKey,gitSyncToken:t.gitSyncToken,contentRepoAdminToken:t.contentRepoAdminToken,agePublicKey:t.agePublicKey})}function Tle(e){let t=Ile.parse(e),r=t.presetOverride?S6(t.presetOverride):void 0;return qr.parse({members:[...t.members],...t.brainVersionOverride?{brainVersionOverride:t.brainVersionOverride}:{},...r?{bundlesOverride:r.bundles,...r.add?{addOverride:r.add}:{},...r.remove?{removeOverride:r.remove}:{}}:{},...t.aiApiKeyOverride?{aiApiKeyOverride:t.aiApiKeyOverride}:{},...t.gitSyncTokenOverride?{gitSyncTokenOverride:t.gitSyncTokenOverride}:{}})}function v6(e){let t=Ln(e,{keepSourceTokens:!0});if(t.errors.length>0)throw Error(`Invalid desired-state YAML: ${t.errors[0]?.message}`);if(!po(t.contents))throw Error("Desired-state YAML must contain a mapping");return t}function QA(e,t){if(!po(e.contents))return;return e.contents.items.find((r)=>yc(r.key)&&r.key.value===t)}function g6(e,t){if(!mo(e)||!mo(t))return;if(e.commentBefore!==void 0)t.commentBefore=e.commentBefore;if(e.comment!==void 0)t.comment=e.comment;if(e.spaceBefore!==void 0)t.spaceBefore=e.spaceBefore}function y6(e,t){if(!e||!mo(t))return;let r=[mo(e.key)?e.key.commentBefore:void 0,mo(e.key)?e.key.comment:void 0,mo(e.value)?e.value.commentBefore:void 0,mo(e.value)?e.value.comment:void 0].filter((o)=>o!==void 0);if(r.length===0)return;t.commentBefore=[t.commentBefore,...r].filter((o)=>o!==void 0).join(`
384
+ `)}function w6(e,t,r,o){if(!po(e.contents))throw Error("Desired-state YAML must contain a mapping");let n=e.contents.items.findIndex((s)=>yc(s.key)&&s.key.value===t),i=e.createPair(r,[...o]);if(n>=0){let s=e.contents.items[n];g6(s?.key,i.key),g6(s?.value,i.value),e.contents.items.splice(n,1,i)}else e.contents.add(i);return i}function x6(e){let t=v6(e),r=Ale(t.toJS()),o=QA(t,"schemaVersion"),n=QA(t,"model");y6(o,QA(t,"brainVersion")?.key),t.delete("schemaVersion"),t.set("bundleContract",ii);let i=w6(t,"preset","bundles",r.bundles);if(y6(n,i.key),t.delete("model"),r.add)t.set("add",r.add);else t.delete("add");if(r.remove)t.set("remove",r.remove);else t.delete("remove");return si.parse(t.toJS()),t.toString({lineWidth:0})}function _6(e){let t=v6(e),r=Tle(t.toJS());if(r.bundlesOverride)w6(t,"presetOverride","bundlesOverride",r.bundlesOverride);else t.delete("presetOverride"),t.delete("bundlesOverride");if(r.addOverride)t.set("addOverride",r.addOverride);else t.delete("addOverride");if(r.removeOverride)t.set("removeOverride",r.removeOverride);else t.delete("removeOverride");return qr.parse(t.toJS()),t.toString({lineWidth:0})}var b6,jd,Ele,Ile,kle;var E6=w(()=>{no();he();Qu();Pn();b6=l.enum(["core","default","pro"]),jd=l.string().min(1),Ele=l.strictObject({schemaVersion:l.literal(1),brainVersion:$t,model:l.literal("rover"),githubOrg:l.string().min(1),contentRepoPrefix:l.string().min(1),domainSuffix:l.string().min(1),preset:b6,aiApiKey:jd,gitSyncToken:jd,contentRepoAdminToken:jd,agePublicKey:l.string().startsWith("age1").min(1)}),Ile=l.strictObject({members:l.array(pr).min(1),brainVersionOverride:$t.optional(),presetOverride:b6.optional(),aiApiKeyOverride:jd.optional(),gitSyncTokenOverride:jd.optional()}).superRefine((e,t)=>{if(new Set(e.members).size!==e.members.length)t.addIssue({code:l.ZodIssueCode.custom,path:["members"],message:"cohort members must be unique"})}),kle=["series","portfolio","content-pipeline","social-media","newsletter","stock-photo"]});function k6(e,t){let r=Ln(e,{keepSourceTokens:!0});if(r.errors.length>0||!po(r.contents))throw Error(`Invalid ${t} YAML`);return r}function Ple(e,t){return e.length===t.length&&e.every((r,o)=>r===t[o])}function A6(e,t,r){if(!Ple(t,r.sourceBundles))throw Error(`${e} source bundles changed after review: expected [${r.sourceBundles.join(", ")}], received [${t.join(", ")}]`)}function T6(e){let t=sn(e,Cle);if(!t.ok)throw Error(`Invalid capability bundle review: ${t.error}`);return t.data}function $6(e,t){let r=k6(e,"pilot desired-state"),o=Rle.parse(r.toJS());return A6("pilot.yaml",o.bundles,t),r.set("bundleContract",ii),r.set("bundles",t.targetBundles),si.parse(r.toJS()),r.toString({lineWidth:0})}function R6(e,t,r){let o=k6(e,`cohort ${t}`),n=Ole.parse(o.toJS());if(n.bundlesOverride===void 0){if(r!==void 0)throw Error(`Capability bundle review names inheriting cohort ${t}`)}else{if(r===void 0)throw Error(`Cohort ${t} has an explicit legacy bundle selection but no reviewed mapping`);A6(`cohort ${t}`,n.bundlesOverride,r),o.set("bundlesOverride",r.targetBundles)}return qr.parse(o.toJS()),o.toString({lineWidth:0})}var $le,YA,qg,Rle,Ole,I6,Cle;var O6=w(()=>{no();he();Qu();Pn();$le=l.enum(["core","site","publishing","team"]),YA=l.array($le).min(1),qg=l.array(l.string().min(1)),Rle=l.strictObject({brainVersion:$t,bundles:YA,add:qg.optional(),remove:qg.optional(),githubOrg:l.string().min(1),contentRepoPrefix:l.string().min(1),domainSuffix:l.string().min(1),aiApiKey:l.string().min(1),gitSyncToken:l.string().min(1),contentRepoAdminToken:l.string().min(1),agePublicKey:l.string().startsWith("age1").min(1)}),Ole=l.strictObject({members:l.array(pr).min(1),brainVersionOverride:$t.optional(),bundlesOverride:YA.optional(),addOverride:qg.optional(),removeOverride:qg.optional(),aiApiKeyOverride:l.string().min(1).optional(),gitSyncTokenOverride:l.string().min(1).optional()}),I6=l.strictObject({sourceBundles:YA,targetBundles:l.array(Dm).min(1)}),Cle=l.strictObject({bundleContract:l.literal(ii),pilot:I6,cohorts:l.record(pr,I6)})});var D6={};Ut(D6,{loadCapabilityBundleReview:()=>qle,loadReviewedSitePins:()=>Ule,parseReviewedSitePins:()=>N6,stageLegacyCrossover:()=>Fle});import{access as zle,cp as Nle,mkdir as C6,readFile as Kc,readdir as z6,writeFile as Jc}from"fs/promises";import{basename as Dle,join as Hn,relative as Mg,resolve as P6}from"path";import{fileURLToPath as Lle}from"url";function N6(e){let t=sn(e,Ble);if(!t.ok)throw Error(`Invalid reviewed site pins: ${t.error}`);return t.data.sites}async function Ule(e){return N6(await Kc(e,"utf8"))}async function qle(e){return T6(await Kc(e,"utf8"))}async function Mle(e,t){let r=Hn(e,"users"),o=(await z6(r,{withFileTypes:!0})).filter((s)=>s.isFile()&&/\.ya?ml$/.test(s.name)).map((s)=>s.name).sort(),n=new Set(Object.keys(t??{})),i=[];for(let s of o){let a=Hn(r,s),c=await Kc(a,"utf8"),u=Ln(c,{keepSourceTokens:!0});if(u.errors.length>0||!po(u.contents))throw Error(`Invalid user desired-state YAML: ${s}`);let d=jle.parse(u.toJS());if(!d.siteOverride)continue;let f=t?.[d.handle];if(!f)throw Error(`User ${d.handle} has a siteOverride but no reviewed site pin`);if(n.delete(d.handle),f.package!==d.siteOverride.package||f.theme!==d.siteOverride.theme)throw Error(`Reviewed site pin identity does not match user ${d.handle}`);if(d.siteOverride.version!==void 0&&d.siteOverride.version!==f.version)throw Error(`Reviewed site version does not match the existing pin for user ${d.handle}`);if(d.siteOverride.themeVersion!==void 0&&d.siteOverride.themeVersion!==f.themeVersion)throw Error(`Reviewed theme version does not match the existing pin for user ${d.handle}`);if(u.setIn(["siteOverride","version"],f.version),f.themeVersion!==void 0)u.setIn(["siteOverride","themeVersion"],f.themeVersion);else u.deleteIn(["siteOverride","themeVersion"]);Lm.parse(u.toJS());let m=u.toString({lineWidth:0});if(m!==c)await Jc(a,m),i.push(Mg(e,a))}if(n.size>0)throw Error(`Reviewed site pins do not match site users: ${[...n].sort().join(", ")}`);return i}async function Fle(e,t,r={}){let o=P6(e),n=P6(t);if(o===n||n.startsWith(`${o}/`))throw Error("Crossover output must be outside the source repository");await Nle(o,n,{recursive:!0,errorOnExist:!0,force:!1,filter:(A)=>{let O=Dle(A);return O!==".git"&&O!==".operator"&&O!==".brains-ops"&&O!==".turbo"&&O!=="dist"&&O!=="node_modules"&&O!==".env"&&O!==".env.local"&&!O.endsWith(".secrets.yaml")}});let i=[],s=Hn(n,"docs","canonical-crossover-record.md");try{await zle(s)}catch{await C6(Hn(n,"docs"),{recursive:!0}),await Jc(s,await Kc(Zle,"utf8")),i.push("docs/canonical-crossover-record.md")}let a=Hn(n,"pilot.yaml"),c=await Kc(a,"utf8"),d=Ln(c).toJS();if(!m6(d))throw Error(`${a} is not a YAML mapping`);let f=Array.isArray(d.bundles),m=r.bundleReview,h;if(f){if(!m)throw Error("Current canonical desired state requires an explicit capability bundle review manifest");h=$6(c,m.pilot)}else h=x6(c);await Jc(a,h),i.push("pilot.yaml");let b=Hn(n,"cohorts"),y=(await z6(b,{withFileTypes:!0})).filter((A)=>A.isFile()&&/\.ya?ml$/.test(A.name)).map((A)=>A.name).sort(),S=new Set(Object.keys(m?.cohorts??{}));for(let A of y){let O=Hn(b,A),L=await Kc(O,"utf8"),z=A.replace(/\.ya?ml$/,""),K=m?.cohorts[z];if(K)S.delete(z);await Jc(O,f?R6(L,z,K):_6(L)),i.push(Mg(n,O))}if(f&&S.size>0)throw Error(`Capability bundle review names unknown cohorts: ${[...S].sort().join(", ")}`);i.push(...await Mle(n,r.sitePins));let x=await ut(n),_=Qm(x.pilot.githubOrg);for(let A of x.users){let O=await _(A),L=Hn(n,"users",A.handle);if(await C6(L,{recursive:!0}),O.brainYaml){let z=Hn(L,"brain.yaml");await Jc(z,O.brainYaml),i.push(Mg(n,z))}if(O.envFile){let z=Hn(L,".env");await Jc(z,O.envFile),i.push(Mg(n,z))}}return await ao(n,{registry:x}),i.push("views/users.md"),{outputDir:n,changedFiles:[...new Set(i)].sort()}}var Ble,jle,Zle;var L6=w(()=>{no();h6();he();Qu();PE();E6();O6();Mr();ec();Pn();Ble=l.strictObject({sites:l.record(pr,aE)}),jle=l.object({handle:pr,siteOverride:l.object({package:l.string().min(1),version:$t.optional(),theme:l.string().min(1).optional(),themeVersion:$t.optional()}).optional()}).passthrough(),Zle=Lle(new URL("../templates/rover-pilot/docs/canonical-crossover-record.md",import.meta.url))});var B6="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";import{webcrypto as j6}from"crypto";function Kle(e){if(e<0)throw RangeError("Wrong ID size");try{if(!Ni||Ni.length<e)Ni=Buffer.allocUnsafe(e*Jle),j6.getRandomValues(Ni),Hc=0;else if(Hc+e>Ni.length)j6.getRandomValues(Ni),Hc=0}catch(t){throw Ni=void 0,t}Hc+=e}function Z6(e=21){Kle(e|=0);let t="";for(let r=Hc-e;r<Hc;r++)t+=B6[Ni[r]&63];return t}var Jle=128,Ni,Hc;var U6=()=>{};function Ro(e=12){return Z6(e)}var Zd=w(()=>{U6()});import{openSync as Hle,writeSync as Vle}from"fs";class kr{static instance=null;level;context;useStderr;format;logFile;fileHandle;constructor(e={},t){if(this.level=e.level??Vs.INFO,this.context=e.context??void 0,this.useStderr=e.useStderr??!1,this.format=e.format??"text",this.logFile=e.logFile,t!==void 0)this.fileHandle=t;else if(this.logFile)try{this.fileHandle=Hle(this.logFile,"a")}catch{}}static getInstance(e){if(!kr.instance)kr.instance=new kr(e);else{if(e?.useStderr!==void 0)kr.instance.useStderr=e.useStderr;if(e?.level!==void 0)kr.instance.level=e.level}return kr.instance}static resetInstance(){kr.instance=null}static createFresh(e){return new kr(e)}formatEntry(e,t,r){let o=new Date().toISOString();if(this.format==="json"){let n={ts:o,level:e,msg:t};if(this.context)n.ctx=this.context;if(r.length>0)n.data=r;return JSON.stringify(n)}return this.context?`[${o}] [${this.context}] ${t}`:`[${o}] ${t}`}write(e,t,r,o){if(this.format==="json")e(this.formatEntry(t,r,o));else if(o.length>0)e(this.formatEntry(t,r,[]),...o);else e(this.formatEntry(t,r,[]));if(this.fileHandle!==void 0){let n=this.formatJsonEntry(t,r,o);try{Vle(this.fileHandle,n+`
385
+ `)}catch{}}}formatJsonEntry(e,t,r){let o={ts:new Date().toISOString(),level:e,msg:t};if(this.context)o.ctx=this.context;if(r.length>0)o.data=r;return JSON.stringify(o)}silly(e,...t){if(this.level<=Vs.SILLY)this.write(console.debug.bind(console),"silly",e,t)}verbose(e,...t){if(this.level<=Vs.VERBOSE)this.write(console.debug.bind(console),"verbose",e,t)}debug(e,...t){if(this.level<=Vs.DEBUG)this.write(console.debug.bind(console),"debug",e,t)}info(e,...t){if(this.level<=Vs.INFO){let r=this.useStderr?console.error.bind(console):console.info.bind(console);this.write(r,"info",e,t)}}warn(e,...t){if(this.level<=Vs.WARN)this.write(console.warn.bind(console),"warn",e,t)}error(e,...t){if(this.level<=Vs.ERROR)this.write(console.error.bind(console),"error",e,t)}child(e){return new kr({level:this.level,context:e,useStderr:this.useStderr,format:this.format},this.fileHandle)}setUseStderr(e){this.useStderr=e}}var Vs,pPe;var XA=w(()=>{Vs={SILLY:0,VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};pPe=kr.getInstance()});var eT,Wle,Vc,yPe;var Ud=w(()=>{Mt();he();eT=l.enum(["file_operations","content_operations","data_processing","batch_processing"]),Wle=l.looseObject({pluginId:l.string().optional(),progressToken:l.union([l.string(),l.number()]).optional(),operationType:eT,operationTarget:l.string().optional(),interfaceType:l.string().optional(),conversationId:l.string().optional(),channelId:l.string().optional(),requestedByActor:ri.optional(),requestedByUserId:l.string().optional(),requestedByInterface:l.string().optional(),silent:l.boolean().optional(),provenance:ni.optional()}),Vc=l.looseObject({pluginId:l.string().optional(),progressToken:l.union([l.string(),l.number()]).optional(),operationType:eT,operationTarget:l.string().optional(),interfaceType:l.string().optional(),conversationId:l.string().optional(),channelId:l.string().optional(),requestedByActor:ri.optional(),requestedByUserId:l.string().optional(),requestedByInterface:l.string().optional(),silent:l.boolean().optional(),provenance:ni.optional(),rootJobId:l.string()}),yPe=l.enum(["none","skip","replace","coalesce"])});var Gle,Di=15000;var qd=w(()=>{Ud();he();Gle=l.object({id:l.string(),type:l.string(),data:l.string(),status:l.enum(["pending","processing","completed","failed"]),source:l.string().nullable(),priority:l.number(),retryCount:l.number(),maxRetries:l.number(),lastError:l.string().nullable(),lastErrorPublic:l.unknown(),createdAt:l.number(),scheduledFor:l.number(),startedAt:l.number().nullable(),completedAt:l.number().nullable(),attemptId:l.string().nullable(),workerSlotId:l.string().nullable(),workerSessionId:l.string().nullable(),leaseExpiresAt:l.number().nullable(),attemptHeartbeatAt:l.number().nullable(),runtimeUpdatedAt:l.number().nullable(),metadata:Vc,progress:l.custom((e)=>typeof e==="object"&&e!==null&&("progress"in e)&&typeof e.progress==="number").nullable(),result:l.unknown().nullable().optional()})});var tT,q6,Oe,Qle,Yle,M6,F6,J6;var Oo=w(()=>{Mt();he();Ud();tT=l.enum(["pending","processing","completed","failed"]),q6=l.enum(["completed","failed"]),Oe={PENDING:"pending",PROCESSING:"processing",COMPLETED:"completed",FAILED:"failed"},Qle=l.object({id:l.string(),type:l.string(),status:tT,data:l.unknown(),result:l.unknown().optional(),lastError:l.string().optional().nullable(),attempts:l.number(),maxRetries:l.number(),priority:l.number(),createdAt:l.date(),updatedAt:l.date(),processedAt:l.date().optional().nullable(),completedAt:l.date().optional().nullable(),failedAt:l.date().optional().nullable()}),Yle=l.object({jobId:l.string(),type:l.string(),status:q6,result:l.unknown().optional(),error:l.string().optional()}),M6=l.object({success:l.literal(!1),error:l.string().optional()}),F6=l.object({id:l.string(),type:l.enum(["job","batch"]),status:tT,message:l.string().optional(),progress:l.object({current:l.number(),total:l.number(),percentage:l.number()}).optional(),aggregationKey:l.string().optional(),batchDetails:l.object({totalOperations:l.number(),completedOperations:l.number(),failedOperations:l.number(),currentOperation:l.string().optional(),errors:l.array(l.string()).optional()}).optional(),jobDetails:l.object({jobType:l.string(),priority:l.number(),retryCount:l.number()}).optional(),metadata:Vc}),J6=oi(nE.progress,F6)});var Ce,Gt;var gn=w(()=>{Ce=class Ce extends Error{code;extendedCode;rawCode;constructor(e,t,r,o,n){if(t!==void 0)e=`${t}: ${e}`;super(e,{cause:n});this.code=t,this.extendedCode=r,this.rawCode=o,this.name="LibsqlError"}};Gt=class Gt extends Ce{statementIndex;constructor(e,t,r,o,n,i){super(e,r,o,n,i);this.statementIndex=t,this.name="LibsqlBatchError"}}});function K6(e){let t=Xle.exec(e);if(t===null)throw new Ce(`The URL '${e}' is not in a valid format`,"URL_INVALID");let r=t.groups,o=r.scheme,n=r.authority!==void 0?eue(r.authority):void 0,i=Ws(r.path),s=r.query!==void 0?rue(r.query):void 0,a=r.fragment!==void 0?Ws(r.fragment):void 0;return{scheme:o,authority:n,path:i,query:s,fragment:a}}function eue(e){let t=tue.exec(e);if(t===null)throw new Ce("The authority part of the URL is not in a valid format","URL_INVALID");let r=t.groups,o=Ws(r.host_br??r.host),n=r.port?parseInt(r.port,10):void 0,i=r.username!==void 0?{username:Ws(r.username),password:r.password!==void 0?Ws(r.password):void 0}:void 0;return{host:o,port:n,userinfo:i}}function rue(e){let t=e.split("&"),r=[];for(let o of t){if(o==="")continue;let n,i,s=o.indexOf("=");if(s<0)n=o,i="";else n=o.substring(0,s),i=o.substring(s+1);r.push({key:Ws(n.replaceAll("+"," ")),value:Ws(i.replaceAll("+"," "))})}return{pairs:r}}function Ws(e){try{return decodeURIComponent(e)}catch(t){if(t instanceof URIError)throw new Ce(`URL component has invalid percent encoding: ${t}`,"URL_INVALID",void 0,void 0,t);throw t}}function Md(e,t,r){if(t===void 0)throw new Ce(`URL with scheme ${JSON.stringify(e+":")} requires authority (the "//" part)`,"URL_INVALID");let o=`${e}:`,n=nue(t.host),i=oue(t.port),a=`//${iue(t.userinfo)}${n}${i}`,c=r.split("/").map(encodeURIComponent).join("/");if(c!==""&&!c.startsWith("/"))c="/"+c;return new URL(`${o}${a}${c}`)}function nue(e){return e.includes(":")?`[${encodeURI(e)}]`:encodeURI(e)}function oue(e){return e!==void 0?`:${e}`:""}function iue(e){if(e===void 0)return"";let t=encodeURIComponent(e.username),r=e.password!==void 0?`:${encodeURIComponent(e.password)}`:"";return`${t}${r}@`}var Xle,tue;var Fg=w(()=>{gn();Xle=(()=>new RegExp("^(?<scheme>[A-Za-z][A-Za-z.+-]*):(//(?<authority>[^/?#]*))?(?<path>[^?#]*)(\\?(?<query>[^#]*))?(#(?<fragment>.*))?$","su"))();tue=(()=>new RegExp("^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\[\\]]*)|(\\[(?<host_br>[^\\[\\]]*)\\]))(:(?<port>[0-9]*))?$","su"))()});var Gc,H6,V6,Fd,Jg,sue,Qt,W6,Y6=(e)=>e.replace(/=/g,"").replace(/[+\/]/g,(t)=>t=="+"?"-":"_"),X6=(e)=>e.replace(/[^A-Za-z0-9\+\/]/g,""),e4=(e)=>{let t,r,o,n,i="",s=e.length%3;for(let a=0;a<e.length;){if((r=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(n=e.charCodeAt(a++))>255)throw TypeError("invalid character found");t=r<<16|o<<8|n,i+=Fd[t>>18&63]+Fd[t>>12&63]+Fd[t>>6&63]+Fd[t&63]}return s?i.slice(0,s-3)+"===".substring(s):i},oT,rT,Kg=(e,t=!1)=>t?Y6(rT(e)):rT(e),aue=(e)=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?Qt(192|t>>>6)+Qt(128|t&63):Qt(224|t>>>12&15)+Qt(128|t>>>6&63)+Qt(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return Qt(240|t>>>18&7)+Qt(128|t>>>12&63)+Qt(128|t>>>6&63)+Qt(128|t&63)}},cue,t4=(e)=>e.replace(cue,aue),G6,Wc=(e,t=!1)=>t?Y6(G6(e)):G6(e),Q6=(e)=>Wc(e,!0),lue,uue=(e)=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return Qt((r>>>10)+55296)+Qt((r&1023)+56320);case 3:return Qt((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return Qt((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},r4=(e)=>e.replace(lue,uue),n4=(e)=>{if(e=e.replace(/\s+/g,""),!sue.test(e))throw TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r,o,n=[];for(let i=0;i<e.length;)if(t=Jg[e.charAt(i++)]<<18|Jg[e.charAt(i++)]<<12|(r=Jg[e.charAt(i++)])<<6|(o=Jg[e.charAt(i++)]),r===64)n.push(Qt(t>>16&255));else if(o===64)n.push(Qt(t>>16&255,t>>8&255));else n.push(Qt(t>>16&255,t>>8&255,t&255));return n.join("")},iT,o4,i4=(e)=>o4(s4(e)),due,s4=(e)=>X6(e.replace(/[-_]/g,(t)=>t=="-"?"+":"/")),nT=(e)=>due(s4(e)),fue=(e)=>{if(typeof e!=="string")return!1;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},a4=(e)=>({value:e,enumerable:!1,writable:!0,configurable:!0}),c4=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,a4(r));e("fromBase64",function(){return nT(this)}),e("toBase64",function(t){return Wc(this,t)}),e("toBase64URI",function(){return Wc(this,!0)}),e("toBase64URL",function(){return Wc(this,!0)}),e("toUint8Array",function(){return i4(this)})},l4=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,a4(r));e("toBase64",function(t){return Kg(this,t)}),e("toBase64URI",function(){return Kg(this,!0)}),e("toBase64URL",function(){return Kg(this,!0)})},pue=()=>{c4(),l4()},Qc;var Hg=w(()=>{Gc=typeof Buffer==="function",H6=typeof TextDecoder==="function"?new TextDecoder("utf-8",{ignoreBOM:!0}):void 0,V6=typeof TextEncoder==="function"?new TextEncoder:void 0,Fd=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),Jg=((e)=>{let t={};return e.forEach((r,o)=>t[r]=o),t})(Fd),sue=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,Qt=String.fromCharCode.bind(String),W6=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):(e)=>new Uint8Array(Array.prototype.slice.call(e,0)),oT=typeof btoa==="function"?(e)=>btoa(e):Gc?(e)=>Buffer.from(e,"binary").toString("base64"):e4,rT=Gc?(e)=>Buffer.from(e).toString("base64"):(e)=>{let r=[];for(let o=0,n=e.length;o<n;o+=4096)r.push(Qt.apply(null,e.subarray(o,o+4096)));return oT(r.join(""))},cue=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,G6=Gc?(e)=>Buffer.from(e,"utf8").toString("base64"):V6?(e)=>rT(V6.encode(e)):(e)=>oT(t4(e)),lue=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,iT=typeof atob==="function"?(e)=>atob(X6(e)):Gc?(e)=>Buffer.from(e,"base64").toString("binary"):n4,o4=Gc?(e)=>W6(Buffer.from(e,"base64")):(e)=>W6(iT(e).split("").map((t)=>t.charCodeAt(0))),due=Gc?(e)=>Buffer.from(e,"base64").toString("utf8"):H6?(e)=>H6.decode(o4(e)):(e)=>r4(iT(e)),Qc={version:"3.8.0",VERSION:"3.8.0",atob:iT,atobPolyfill:n4,btoa:oT,btoaPolyfill:e4,fromBase64:nT,toBase64:Wc,encode:Wc,encodeURI:Q6,encodeURL:Q6,utob:t4,btou:r4,decode:nT,isValid:fue,fromUint8Array:Kg,toUint8Array:i4,extendString:c4,extendUint8Array:l4,extendBuiltins:pue}});function Li(e){if(e==="write")return"BEGIN IMMEDIATE";else if(e==="read")return"BEGIN TRANSACTION READONLY";else if(e==="deferred")return"BEGIN DEFERRED";else throw RangeError('Unknown transaction mode, supported values are "write", "read" and "deferred"')}class Yc{columns;columnTypes;rows;rowsAffected;lastInsertRowid;constructor(e,t,r,o,n){this.columns=e,this.columnTypes=t,this.rows=r,this.rowsAffected=o,this.lastInsertRowid=n}toJSON(){return{columns:this.columns,columnTypes:this.columnTypes,rows:this.rows.map(mue),rowsAffected:this.rowsAffected,lastInsertRowid:this.lastInsertRowid!==void 0?""+this.lastInsertRowid:null}}}function mue(e){return Array.prototype.map.call(e,hue)}function hue(e){if(typeof e==="bigint")return""+e;else if(e instanceof ArrayBuffer)return Qc.fromUint8Array(new Uint8Array(e));else return e}var Vn="https://github.com/libsql/libsql-client-ts#supported-urls";var Xc=w(()=>{Hg()});function d4(e){return e.scheme==="file"&&(e.path===":memory:"||e.path.startsWith(":memory:?"))}function Jd(e,t){if(typeof e!=="object")throw TypeError(`Expected client configuration as object, got ${typeof e}`);let{url:r,authToken:o,tls:n,intMode:i,concurrency:s}=e;s=Math.max(0,s||20),i??="number";let a=[];if(r===u4)r="file::memory:";let c=K6(r),u=c.scheme.toLowerCase(),d=u==="file"&&c.path===u4&&c.authority===void 0,f;if(d)f={cache:{values:["shared","private"],update:(y,S)=>a.push(`${y}=${S}`)}};else f={tls:{values:["0","1"],update:(y,S)=>n=S==="1"},authToken:{update:(y,S)=>o=S}};for(let{key:y,value:S}of c.query?.pairs??[]){if(!Object.hasOwn(f,y))throw new Ce(`Unsupported URL query parameter ${JSON.stringify(y)}`,"URL_PARAM_NOT_SUPPORTED");let x=f[y];if(x.values!==void 0&&!x.values.includes(S))throw new Ce(`Unknown value for the "${y}" query argument: ${JSON.stringify(S)}. Supported values are: [${x.values.map((_)=>'"'+_+'"').join(", ")}]`,"URL_INVALID");if(x.update!==void 0)x?.update(y,S)}let m=a.length===0?"":`?${a.join("&")}`,h=c.path+m,b;if(u==="libsql")if(n===!1){if(c.authority?.port===void 0)throw new Ce('A "libsql:" URL with ?tls=0 must specify an explicit port',"URL_INVALID");b=t?"http":"ws"}else b=t?"https":"wss";else b=u;if(b==="http"||b==="ws")n??=!1;else n??=!0;if(b!=="http"&&b!=="ws"&&b!=="https"&&b!=="wss"&&b!=="file")throw new Ce(`The client supports only "libsql:", "wss:", "ws:", "https:", "http:" and "file:" URLs, got ${JSON.stringify(c.scheme+":")}. For more information, please read ${Vn}`,"URL_SCHEME_NOT_SUPPORTED");if(i!=="number"&&i!=="bigint"&&i!=="string")throw TypeError(`Invalid value for intMode, expected "number", "bigint" or "string", got ${JSON.stringify(i)}`);if(c.fragment!==void 0)throw new Ce(`URL fragments are not supported: ${JSON.stringify("#"+c.fragment)}`,"URL_INVALID");if(d)return{scheme:"file",tls:!1,path:h,intMode:i,concurrency:s,syncUrl:e.syncUrl,syncInterval:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,fetch:e.fetch,timeout:e.timeout,authToken:void 0,encryptionKey:void 0,remoteEncryptionKey:void 0,authority:void 0};return{scheme:b,tls:n,authority:c.authority,path:h,authToken:o,intMode:i,concurrency:s,encryptionKey:e.encryptionKey,remoteEncryptionKey:e.remoteEncryptionKey,syncUrl:e.syncUrl,syncInterval:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,fetch:e.fetch,timeout:e.timeout}}var u4=":memory:";var Kd=w(()=>{gn();Fg();Xc()});var p4=ge(function(Yr){var gue=Yr&&Yr.__createBinding||(Object.create?function(e,t,r,o){if(o===void 0)o=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,o,n)}:function(e,t,r,o){if(o===void 0)o=r;e[o]=t[r]}),yue=Yr&&Yr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),f4=Yr&&Yr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null){for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))gue(t,e,r)}return yue(t,e),t};Object.defineProperty(Yr,"__esModule",{value:!0});Yr.load=Yr.currentTarget=void 0;var bue=f4(Zr("path")),Sue=f4(Zr("fs"));function vue(){let e=null;switch(process.platform){case"android":switch(process.arch){case"arm":return"android-arm-eabi";case"arm64":return"android-arm64"}e="Android";break;case"win32":switch(process.arch){case"x64":return"win32-x64-msvc";case"arm64":return"win32-arm64-msvc";case"ia32":return"win32-ia32-msvc"}e="Windows";break;case"darwin":switch(process.arch){case"x64":return"darwin-x64";case"arm64":return"darwin-arm64"}e="macOS";break;case"linux":switch(process.arch){case"x64":case"arm64":return wue()?`linux-${process.arch}-gnu`:`linux-${process.arch}-musl`;case"arm":return"linux-arm-gnueabihf"}e="Linux";break;case"freebsd":if(process.arch==="x64")return"freebsd-x64";e="FreeBSD";break}if(e)throw Error(`Neon: unsupported ${e} architecture: ${process.arch}`);throw Error(`Neon: unsupported system: ${process.platform}`)}Yr.currentTarget=vue;function wue(){let e=process.report?.getReport();if(typeof e!=="object"||!e||!("header"in e))return!1;let t=e.header;return typeof t==="object"&&!!t&&"glibcVersionRuntime"in t}function xue(e){let t=bue.join(e,"index.node");return Sue.existsSync(t)?Zr(t):null}Yr.load=xue});var g4=ge(function(BPe,h4){var m4=()=>process.platform==="linux",sT=null,_ue=()=>{if(!sT)sT=m4()&&process.report?process.report.getReport():{};return sT};h4.exports={isLinux:m4,getReport:_ue}});var S4=ge(function(jPe,b4){var y4=Zr("fs"),Eue=(e)=>y4.readFileSync(e,"utf-8"),Iue=(e)=>new Promise((t,r)=>{y4.readFile(e,"utf-8",(o,n)=>{if(o)r(o);else t(n)})});b4.exports={LDD_PATH:"/usr/bin/ldd",readFileSync:Eue,readFile:Iue}});var D4=ge(function(ZPe,N4){var w4=Zr("child_process"),{isLinux:el,getReport:x4}=g4(),{LDD_PATH:Vg,readFile:_4,readFileSync:E4}=S4(),Wn,Gn,Bi="",I4=()=>{if(!Bi)return new Promise((e)=>{w4.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(t,r)=>{Bi=t?" ":r,e(Bi)})});return Bi},k4=()=>{if(!Bi)try{Bi=w4.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch(e){Bi=" "}return Bi},Co="glibc",A4=/GLIBC\s(\d+\.\d+)/,Gs="musl",kue=Co.toUpperCase(),Aue=Gs.toLowerCase(),Tue=(e)=>e.includes("libc.musl-")||e.includes("ld-musl-"),T4=()=>{let e=x4();if(e.header&&e.header.glibcVersionRuntime)return Co;if(Array.isArray(e.sharedObjects)){if(e.sharedObjects.some(Tue))return Gs}return null},$4=(e)=>{let[t,r]=e.split(/[\r\n]+/);if(t&&t.includes(Co))return Co;if(r&&r.includes(Gs))return Gs;return null},R4=(e)=>{if(e.includes(Aue))return Gs;if(e.includes(kue))return Co;return null},$ue=async()=>{if(Wn!==void 0)return Wn;Wn=null;try{let e=await _4(Vg);Wn=R4(e)}catch(e){}return Wn},Rue=()=>{if(Wn!==void 0)return Wn;Wn=null;try{let e=E4(Vg);Wn=R4(e)}catch(e){}return Wn},O4=async()=>{let e=null;if(el()){if(e=await $ue(),!e)e=T4();if(!e){let t=await I4();e=$4(t)}}return e},C4=()=>{let e=null;if(el()){if(e=Rue(),!e)e=T4();if(!e){let t=k4();e=$4(t)}}return e},Oue=async()=>el()&&await O4()!==Co,Cue=()=>el()&&C4()!==Co,Pue=async()=>{if(Gn!==void 0)return Gn;Gn=null;try{let t=(await _4(Vg)).match(A4);if(t)Gn=t[1]}catch(e){}return Gn},zue=()=>{if(Gn!==void 0)return Gn;Gn=null;try{let t=E4(Vg).match(A4);if(t)Gn=t[1]}catch(e){}return Gn},P4=()=>{let e=x4();if(e.header&&e.header.glibcVersionRuntime)return e.header.glibcVersionRuntime;return null},v4=(e)=>e.trim().split(/\s+/)[1],z4=(e)=>{let[t,r,o]=e.split(/[\r\n]+/);if(t&&t.includes(Co))return v4(t);if(r&&o&&r.includes(Gs))return v4(o);return null},Nue=async()=>{let e=null;if(el()){if(e=await Pue(),!e)e=P4();if(!e){let t=await I4();e=z4(t)}}return e},Due=()=>{let e=null;if(el()){if(e=zue(),!e)e=P4();if(!e){let t=k4();e=z4(t)}}return e};N4.exports={GLIBC:Co,MUSL:Gs,family:O4,familySync:C4,isNonGlibcLinux:Oue,isNonGlibcLinuxSync:Cue,version:Nue,versionSync:Due}});var B4=ge(function(UPe,L4){var Lue={ALLOW:0,DENY:1};L4.exports=Lue});var Z4=ge(function(qPe,j4){var aT={value:"SqliteError",writable:!0,enumerable:!1,configurable:!0};function Qs(e,t,r){if(new.target!==Qs)return new Qs(e,t);if(typeof t!=="string")throw TypeError("Expected second argument to be a string");Error.call(this,e),aT.value=""+e,Object.defineProperty(this,"message",aT),Error.captureStackTrace(this,Qs),this.code=t,this.rawCode=r}Object.setPrototypeOf(Qs,Error);Object.setPrototypeOf(Qs.prototype,Error.prototype);Object.defineProperty(Qs.prototype,"name",aT);j4.exports=Qs});var V4=ge(function(MPe,Wg){var __dirname="/home/runner/work/brains/brains/node_modules/libsql",{load:Bue,currentTarget:jue}=p4(),{familySync:U4,GLIBC:Zue,MUSL:Uue}=D4();function que(){if(process.env.LIBSQL_JS_DEV)return Bue(__dirname);let e=jue();if(U4()==Zue)switch(e){case"linux-x64-musl":e="linux-x64-gnu";break;case"linux-arm64-musl":e="linux-arm64-gnu";break}if(e==="linux-arm-gnueabihf"&&U4()==Uue)e="linux-arm-musleabihf";return Zr(`@libsql/${e}`)}var{databaseOpen:Mue,databaseOpenWithSync:Fue,databaseInTransaction:Jue,databaseInterrupt:Kue,databaseClose:Hue,databaseSyncSync:Vue,databaseSyncUntilSync:Wue,databaseExecSync:Gue,databasePrepareSync:Que,databaseDefaultSafeIntegers:Yue,databaseAuthorizer:Xue,databaseLoadExtension:ede,databaseMaxWriteReplicationIndex:tde,statementRaw:rde,statementIsReader:nde,statementGet:q4,statementRun:M4,statementInterrupt:ode,statementRowsSync:F4,statementColumns:ide,statementSafeIntegers:sde,rowsNext:ade}=que(),cde=B4(),J4=Z4();function tl(e){if(e.libsqlError)return new J4(e.message,e.code,e.rawCode);return e}class K4{constructor(e,t){let r=t?.encryptionCipher??"aes256cbc";if(t&&t.syncUrl){var o="";if(t.syncAuth)console.warn("Warning: The `syncAuth` option is deprecated, please use `authToken` option instead."),o=t.syncAuth;else if(t.authToken)o=t.authToken;let i=t?.encryptionKey??"",s=t?.syncPeriod??0,a=t?.readYourWrites??!0,c=t?.offline??!1,u=t?.remoteEncryptionKey??"";this.db=Fue(e,t.syncUrl,o,r,i,s,a,c,u)}else{let i=t?.authToken??"",s=t?.encryptionKey??"",a=t?.timeout??0,c=t?.remoteEncryptionKey??"";this.db=Mue(e,i,r,s,a,c)}this.memory=e===":memory:",this.readonly=!1,this.name="",this.open=!0;let n=this.db;Object.defineProperties(this,{inTransaction:{get(){return Jue(n)}}})}sync(){return Vue.call(this.db)}syncUntil(e){return Wue.call(this.db,e)}prepare(e){try{let t=Que.call(this.db,e);return new H4(t)}catch(t){throw tl(t)}}transaction(e){if(typeof e!=="function")throw TypeError("Expected first argument to be a function");let t=this,r=(n)=>(...i)=>{t.exec("BEGIN "+n);try{let s=e(...i);return t.exec("COMMIT"),s}catch(s){throw t.exec("ROLLBACK"),s}},o={default:{value:r("")},deferred:{value:r("DEFERRED")},immediate:{value:r("IMMEDIATE")},exclusive:{value:r("EXCLUSIVE")},database:{value:this,enumerable:!0}};return Object.defineProperties(o.default.value,o),Object.defineProperties(o.deferred.value,o),Object.defineProperties(o.immediate.value,o),Object.defineProperties(o.exclusive.value,o),o.default.value}pragma(e,t){if(t==null)t={};if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof t!=="object")throw TypeError("Expected second argument to be an options object");let r=t.simple,o=this.prepare(`PRAGMA ${e}`,this,!0);return r?o.pluck().get():o.all()}backup(e,t){throw Error("not implemented")}serialize(e){throw Error("not implemented")}function(e,t,r){if(t==null)t={};if(typeof t==="function")r=t,t={};if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof r!=="function")throw TypeError("Expected last argument to be a function");if(typeof t!=="object")throw TypeError("Expected second argument to be an options object");if(!e)throw TypeError("User-defined function name cannot be an empty string");throw Error("not implemented")}aggregate(e,t){if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof t!=="object"||t===null)throw TypeError("Expected second argument to be an options object");if(!e)throw TypeError("User-defined function name cannot be an empty string");throw Error("not implemented")}table(e,t){if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(!e)throw TypeError("Virtual table module name cannot be an empty string");throw Error("not implemented")}authorizer(e){Xue.call(this.db,e)}loadExtension(...e){ede.call(this.db,...e)}maxWriteReplicationIndex(){return tde.call(this.db)}exec(e){try{Gue.call(this.db,e)}catch(t){throw tl(t)}}interrupt(){Kue.call(this.db)}close(){Hue.call(this.db),this.open=!1}defaultSafeIntegers(e){return Yue.call(this.db,e??!0),this}unsafeMode(...e){throw Error("not implemented")}}class H4{constructor(e){this.stmt=e,this.pluckMode=!1}raw(e){return rde.call(this.stmt,e??!0),this}pluck(e){return this.pluckMode=e??!0,this}get reader(){return nde.call(this.stmt)}run(...e){try{if(e.length==1&&typeof e[0]==="object")return M4.call(this.stmt,e[0]);else return M4.call(this.stmt,e.flat())}catch(t){throw tl(t)}}get(...e){try{if(e.length==1&&typeof e[0]==="object")return q4.call(this.stmt,e[0]);else return q4.call(this.stmt,e.flat())}catch(t){throw tl(t)}}iterate(...e){var t=void 0;if(e.length==1&&typeof e[0]==="object")t=F4.call(this.stmt,e[0]);else t=F4.call(this.stmt,e.flat());return{nextRows:Array(100),nextRowIndex:100,next(){try{if(this.nextRowIndex===100)ade.call(t,this.nextRows),this.nextRowIndex=0;let o=this.nextRows[this.nextRowIndex];if(this.nextRows[this.nextRowIndex]=void 0,!o)return{done:!0};return this.nextRowIndex++,{value:o,done:!1}}catch(o){throw tl(o)}},[Symbol.iterator](){return this}}}all(...e){try{let t=[];for(let r of this.iterate(...e))if(this.pluckMode)t.push(r[Object.keys(r)[0]]);else t.push(r);return t}catch(t){throw tl(t)}}interrupt(){ode.call(this.stmt)}columns(){return ide.call(this.stmt)}safeIntegers(e){return sde.call(this.stmt,e??!0),this}}Wg.exports=K4;Wg.exports.Authorization=cde;Wg.exports.SqliteError=J4});import{Buffer as G4}from"buffer";function Q4(e){if(e.scheme!=="file")throw new Ce(`URL scheme ${JSON.stringify(e.scheme+":")} is not supported by the local sqlite3 client. For more information, please read ${Vn}`,"URL_SCHEME_NOT_SUPPORTED");let t=e.authority;if(t!==void 0){let s=t.host.toLowerCase();if(s!==""&&s!=="localhost")throw new Ce(`Invalid host in file URL: ${JSON.stringify(t.host)}. A "file:" URL with an absolute path should start with one slash ("file:/absolute/path.db") or with three slashes ("file:///absolute/path.db"). For more information, please read ${Vn}`,"URL_INVALID");if(t.port!==void 0)throw new Ce("File URL cannot have a port","URL_INVALID");if(t.userinfo!==void 0)throw new Ce("File URL cannot have username and password","URL_INVALID")}let r=d4(e);if(r&&e.syncUrl)throw new Ce(`Embedded replica must use file for local db but URI with in-memory mode were provided instead: ${e.path}`,"URL_INVALID");let o=e.path;if(r)o=`${e.scheme}:${e.path}`;let n={authToken:e.authToken,encryptionKey:e.encryptionKey,remoteEncryptionKey:e.remoteEncryptionKey,syncUrl:e.syncUrl,syncPeriod:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,timeout:e.timeout},i=new Hd.default(o,n);return Pt(i,"SELECT 1 AS checkThatTheDatabaseCanBeOpened",e.intMode),new Y4(o,n,i,e.intMode)}class Y4{#e;#t;#r;#n;closed;protocol;constructor(e,t,r,o){this.#e=e,this.#t=t,this.#r=r,this.#n=o,this.closed=!1,this.protocol="file"}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.#o(),Pt(this.#i(),r,this.#n)}async batch(e,t="deferred"){this.#o();let r=this.#i();try{Pt(r,Li(t),this.#n);let o=[];for(let n=0;n<e.length;n++)try{if(!r.inTransaction)throw new Gt("The transaction has been rolled back",n,"TRANSACTION_CLOSED");let i=e[n],s=Array.isArray(i)?{sql:i[0],args:i[1]||[]}:i;o.push(Pt(r,s,this.#n))}catch(i){if(i instanceof Gt)throw i;if(i instanceof Ce)throw new Gt(i.message,n,i.code,i.extendedCode,i.rawCode,i.cause instanceof Error?i.cause:void 0);throw i}return Pt(r,"COMMIT",this.#n),o}finally{if(r.inTransaction)Pt(r,"ROLLBACK",this.#n)}}async migrate(e){this.#o();let t=this.#i();try{Pt(t,"PRAGMA foreign_keys=off",this.#n),Pt(t,Li("deferred"),this.#n);let r=[];for(let o=0;o<e.length;o++)try{if(!t.inTransaction)throw new Gt("The transaction has been rolled back",o,"TRANSACTION_CLOSED");r.push(Pt(t,e[o],this.#n))}catch(n){if(n instanceof Gt)throw n;if(n instanceof Ce)throw new Gt(n.message,o,n.code,n.extendedCode,n.rawCode,n.cause instanceof Error?n.cause:void 0);throw n}return Pt(t,"COMMIT",this.#n),r}finally{if(t.inTransaction)Pt(t,"ROLLBACK",this.#n);Pt(t,"PRAGMA foreign_keys=on",this.#n)}}async transaction(e="write"){let t=this.#i();return Pt(t,Li(e),this.#n),this.#r=null,new X4(t,this.#n)}async executeMultiple(e){this.#o();let t=this.#i();try{return eq(t,e)}finally{if(t.inTransaction)Pt(t,"ROLLBACK",this.#n)}}async sync(){this.#o();let e=await this.#i().sync();return{frames_synced:e.frames_synced,frame_no:e.frame_no}}async reconnect(){try{if(!this.closed&&this.#r!==null)this.#r.close()}finally{this.#r=new Hd.default(this.#e,this.#t),this.closed=!1}}close(){if(this.closed=!0,this.#r!==null)this.#r.close(),this.#r=null}#o(){if(this.closed)throw new Ce("The client is closed","CLIENT_CLOSED")}#i(){if(this.#r===null)this.#r=new Hd.default(this.#e,this.#t);return this.#r}}class X4{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.#r(),Pt(this.#e,r,this.#t)}async batch(e){let t=[];for(let r=0;r<e.length;r++)try{this.#r();let o=e[r],n=Array.isArray(o)?{sql:o[0],args:o[1]||[]}:o;t.push(Pt(this.#e,n,this.#t))}catch(o){if(o instanceof Gt)throw o;if(o instanceof Ce)throw new Gt(o.message,r,o.code,o.extendedCode,o.rawCode,o.cause instanceof Error?o.cause:void 0);throw o}return t}async executeMultiple(e){return this.#r(),eq(this.#e,e)}async rollback(){if(!this.#e.open)return;this.#r(),Pt(this.#e,"ROLLBACK",this.#t)}async commit(){this.#r(),Pt(this.#e,"COMMIT",this.#t)}close(){if(this.#e.inTransaction)Pt(this.#e,"ROLLBACK",this.#t)}get closed(){return!this.#e.inTransaction}#r(){if(this.closed)throw new Ce("The transaction is closed","TRANSACTION_CLOSED")}}function Pt(e,t,r){let o,n;if(typeof t==="string")o=t,n=[];else if(o=t.sql,Array.isArray(t.args))n=t.args.map((i)=>W4(i,r));else{n={};for(let i in t.args){let s=i[0]==="@"||i[0]==="$"||i[0]===":"?i.substring(1):i;n[s]=W4(t.args[i],r)}}try{let i=e.prepare(o);i.safeIntegers(!0);let s=!0;try{i.raw(!0)}catch{s=!1}if(s){let a=Array.from(i.columns().map((m)=>m.name)),c=Array.from(i.columns().map((m)=>m.type??"")),u=i.all(n).map((m)=>lde(m,a,r)),d=0,f=void 0;return new Yc(a,c,u,0,void 0)}else{let a=i.run(n),c=a.changes,u=BigInt(a.lastInsertRowid);return new Yc([],[],[],c,u)}}catch(i){throw tq(i)}}function lde(e,t,r){let o={};Object.defineProperty(o,"length",{value:e.length});for(let n=0;n<e.length;++n){let i=ude(e[n],r);Object.defineProperty(o,n,{value:i});let s=t[n];if(!Object.hasOwn(o,s))Object.defineProperty(o,s,{value:i,enumerable:!0,configurable:!0,writable:!0})}return o}function ude(e,t){if(typeof e==="bigint")if(t==="number"){if(e<dde||e>fde)throw RangeError("Received integer which cannot be safely represented as a JavaScript number");return Number(e)}else if(t==="bigint")return e;else if(t==="string")return""+e;else throw Error("Invalid value for IntMode");else if(e instanceof G4)return e.buffer;return e}function W4(e,t){if(typeof e==="number"){if(!Number.isFinite(e))throw RangeError("Only finite numbers (not Infinity or NaN) can be passed as arguments");return e}else if(typeof e==="bigint"){if(e<pde||e>mde)throw RangeError("bigint is too large to be represented as a 64-bit integer and passed as argument");return e}else if(typeof e==="boolean")switch(t){case"bigint":return e?1n:0n;case"string":return e?"1":"0";default:return e?1:0}else if(e instanceof ArrayBuffer)return G4.from(e);else if(e instanceof Date)return e.valueOf();else if(e===void 0)throw TypeError("undefined cannot be passed as argument to the database");else return e}function eq(e,t){try{e.exec(t)}catch(r){throw tq(r)}}function tq(e){if(e instanceof Hd.default.SqliteError){let t=e.code,r=hde(e.rawCode);return new Ce(e.message,r,t,e.rawCode,e)}return e}function hde(e){if(e===void 0)return"SQLITE_UNKNOWN";let t=e&255;return gde[t]??`SQLITE_UNKNOWN_${t.toString()}`}var Hd,dde,fde=9007199254740991n,pde,mde=9223372036854775807n,gde;var rq=w(()=>{gn();Kd();Xc();Hd=Rl(V4(),1);gn();dde=-9007199254740991n;pde=-9223372036854775808n;gde={1:"SQLITE_ERROR",2:"SQLITE_INTERNAL",3:"SQLITE_PERM",4:"SQLITE_ABORT",5:"SQLITE_BUSY",6:"SQLITE_LOCKED",7:"SQLITE_NOMEM",8:"SQLITE_READONLY",9:"SQLITE_INTERRUPT",10:"SQLITE_IOERR",11:"SQLITE_CORRUPT",12:"SQLITE_NOTFOUND",13:"SQLITE_FULL",14:"SQLITE_CANTOPEN",15:"SQLITE_PROTOCOL",16:"SQLITE_EMPTY",17:"SQLITE_SCHEMA",18:"SQLITE_TOOBIG",19:"SQLITE_CONSTRAINT",20:"SQLITE_MISMATCH",21:"SQLITE_MISUSE",22:"SQLITE_NOLFS",23:"SQLITE_AUTH",24:"SQLITE_FORMAT",25:"SQLITE_RANGE",26:"SQLITE_NOTADB",27:"SQLITE_NOTICE",28:"SQLITE_WARNING"}});var ji;var cT=w(()=>{if(typeof WebSocket<"u")ji=WebSocket;else if(typeof global<"u")ji=global.WebSocket;else if(typeof window<"u")ji=window.WebSocket;else if(typeof self<"u")ji=self.WebSocket});class rl{constructor(){this.intMode="number"}intMode}var We,Pe,Vd,xt,Wd,nl,Ys,yn,or,Qn;var _t=w(()=>{We=class We extends Error{constructor(e){super(e);this.name="ClientError"}};Pe=class Pe extends We{constructor(e){super(e);this.name="ProtoError"}};Vd=class Vd extends We{code;proto;constructor(e,t){super(e);this.name="ResponseError",this.code=t.code,this.proto=t,this.stack=void 0}};xt=class xt extends We{constructor(e,t){if(t!==void 0){super(`${e}: ${t}`);this.cause=t}else super(e);this.name="ClosedError"}};Wd=class Wd extends We{constructor(e){super(e);this.name="WebSocketUnsupportedError"}};nl=class nl extends We{constructor(e){super(e);this.name="WebSocketError"}};Ys=class Ys extends We{status;constructor(e,t){super(e);this.status=t,this.name="HttpServerError"}};yn=class yn extends We{constructor(e){super(e);this.name="ProtocolVersionError"}};or=class or extends We{constructor(e){super(e);this.name="InternalError"}};Qn=class Qn extends We{constructor(e){super(e);this.name="MisuseError"}}});function Ar(e){if(typeof e==="string")return e;throw ol(e,"string")}function Lr(e){if(e===null||e===void 0)return;else if(typeof e==="string")return e;throw ol(e,"string or null")}function Po(e){if(typeof e==="number")return e;throw ol(e,"number")}function Zi(e){if(typeof e==="boolean")return e;throw ol(e,"boolean")}function Gd(e){if(Array.isArray(e))return e;throw ol(e,"array")}function kt(e){if(e!==null&&typeof e==="object"&&!Array.isArray(e))return e;throw ol(e,"object")}function bn(e,t){return Gd(e).map((r)=>t(kt(r)))}function ol(e,t){if(e===void 0)return new Pe(`Expected ${t}, but the property was missing`);let r=typeof e;if(e===null)r="null";else if(Array.isArray(e))r="array";return new Pe(`Expected ${t}, received ${r}`)}function Xs(e,t){return t(kt(e))}var il=w(()=>{_t()});class nq{#e;#t;constructor(e){this.#e=e,this.#t=!1}begin(){this.#e.push("{"),this.#t=!0}end(){this.#e.push("}"),this.#t=!1}#r(e){if(this.#t)this.#e.push('"'),this.#t=!1;else this.#e.push(',"');this.#e.push(e),this.#e.push('":')}string(e,t){this.#r(e),this.#e.push(JSON.stringify(t))}stringRaw(e,t){this.#r(e),this.#e.push('"'),this.#e.push(t),this.#e.push('"')}number(e,t){this.#r(e),this.#e.push(""+t)}boolean(e,t){this.#r(e),this.#e.push(t?"true":"false")}object(e,t,r){this.#r(e),this.begin(),r(this,t),this.end()}arrayObjects(e,t,r){this.#r(e),this.#e.push("[");for(let o=0;o<t.length;++o){if(o!==0)this.#e.push(",");this.begin(),r(this,t[o]),this.end()}this.#e.push("]")}}function Qd(e,t){let r=[],o=new nq(r);return o.begin(),t(o,e),o.end(),r.join("")}var ea=0,Yd=1,Xd=2,oq=5;class iq{#e;#t;#r;constructor(e){this.#e=e,this.#t=new DataView(e.buffer,e.byteOffset,e.byteLength),this.#r=0}varint(){let e=0;for(let t=0;;t+=7){let r=this.#e[this.#r++];if(e|=(r&127)<<t,!(r&128))break}return e}varintBig(){let e=0n;for(let t=0n;;t+=7n){let r=this.#e[this.#r++];if(e|=BigInt(r&127)<<t,!(r&128))break}return e}bytes(e){let t=new Uint8Array(this.#e.buffer,this.#e.byteOffset+this.#r,e);return this.#r+=e,t}double(){let e=this.#t.getFloat64(this.#r,!0);return this.#r+=8,e}skipVarint(){for(;;)if(!(this.#e[this.#r++]&128))break}skip(e){this.#r+=e}eof(){return this.#r>=this.#e.byteLength}}class sq{#e;#t;constructor(e){this.#e=e,this.#t=-1}setup(e){this.#t=e}#r(e){if(this.#t!==e)throw new Pe(`Expected wire type ${e}, got ${this.#t}`);this.#t=-1}bytes(){this.#r(Xd);let e=this.#e.varint();return this.#e.bytes(e)}string(){return new TextDecoder().decode(this.bytes())}message(e){return Ui(this.bytes(),e)}int32(){return this.#r(ea),this.#e.varint()}uint32(){return this.int32()}bool(){return this.int32()!==0}uint64(){return this.#r(ea),this.#e.varintBig()}sint64(){let e=this.uint64();return e>>1n^-(e&1n)}double(){return this.#r(Yd),this.#e.double()}maybeSkip(){if(this.#t<0)return;else if(this.#t===ea)this.#e.skipVarint();else if(this.#t===Yd)this.#e.skip(8);else if(this.#t===Xd){let e=this.#e.varint();this.#e.skip(e)}else if(this.#t===oq)this.#e.skip(4);else throw new Pe(`Unexpected wire type ${this.#t}`);this.#t=-1}}function Ui(e,t){let r=new iq(e),o=new sq(r),n=t.default();while(!r.eof()){let i=r.varint(),s=i>>3,a=i&7;o.setup(a);let c=t[s];if(c!==void 0){let u=c(o,n);if(u!==void 0)n=u}o.maybeSkip()}return n}var lT=w(()=>{_t()});class uT{#e;#t;#r;#n;constructor(){this.#e=new ArrayBuffer(256),this.#t=new Uint8Array(this.#e),this.#r=new DataView(this.#e),this.#n=0}#o(e){if(this.#n+e<=this.#e.byteLength)return;let t=this.#e.byteLength;while(t<this.#n+e)t*=2;let r=new ArrayBuffer(t),o=new Uint8Array(r),n=new DataView(r);o.set(new Uint8Array(this.#e,0,this.#n)),this.#e=r,this.#t=o,this.#r=n}#i(e){this.#o(5),e=0|e;do{let t=e&127;e>>>=7,t|=e?128:0,this.#t[this.#n++]=t}while(e)}#a(e){this.#o(10),e=e&0xffffffffffffffffn;do{let t=Number(e&0x7fn);e>>=7n,t|=e?128:0,this.#t[this.#n++]=t}while(e)}#s(e,t){this.#i(e<<3|t)}bytes(e,t){this.#s(e,Xd),this.#i(t.byteLength),this.#o(t.byteLength),this.#t.set(t,this.#n),this.#n+=t.byteLength}string(e,t){this.bytes(e,new TextEncoder().encode(t))}message(e,t,r){let o=new uT;r(o,t),this.bytes(e,o.data())}int32(e,t){this.#s(e,ea),this.#i(t)}uint32(e,t){this.int32(e,t)}bool(e,t){this.int32(e,t?1:0)}sint64(e,t){this.#s(e,ea),this.#a(t<<1n^t>>63n)}double(e,t){this.#s(e,Yd),this.#o(8),this.#r.setFloat64(this.#n,t,!0),this.#n+=8}data(){return new Uint8Array(this.#e,0,this.#n)}}function ef(e,t){let r=new uT;return t(r,e),r.data()}var aq=()=>{};var dT=w(()=>{il();lT();aq()});class qi{#e;#t;constructor(){this.#e=new Set,this.#t=new Set}alloc(){for(let t of this.#t){if(this.#t.delete(t),this.#e.add(t),!this.#e.has(this.#e.size-1))this.#t.add(this.#e.size-1);return t}let e=this.#e.size;return this.#e.add(e),e}free(e){if(!this.#e.delete(e))throw new or("Freeing an id that is not allocated");if(this.#t.delete(this.#e.size),e<this.#e.size)this.#t.add(e)}}var fT=w(()=>{_t()});function Ke(e,t){throw new or(t)}var Xr=w(()=>{_t()});function sl(e){if(e===null)return null;else if(typeof e==="string")return e;else if(typeof e==="number"){if(!Number.isFinite(e))throw RangeError("Only finite numbers (not Infinity or NaN) can be passed as arguments");return e}else if(typeof e==="bigint"){if(e<bde||e>Sde)throw RangeError("This bigint value is too large to be represented as a 64-bit integer and passed as argument");return e}else if(typeof e==="boolean")return e?1n:0n;else if(e instanceof ArrayBuffer)return new Uint8Array(e);else if(e instanceof Uint8Array)return e;else if(e instanceof Date)return+e.valueOf();else if(typeof e==="object")return""+e.toString();else throw TypeError("Unsupported type of value")}function pT(e,t){if(e===null)return null;else if(typeof e==="number")return e;else if(typeof e==="string")return e;else if(typeof e==="bigint")if(t==="number"){let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError("Received integer which is too large to be safely represented as a JavaScript number");return r}else if(t==="bigint")return e;else if(t==="string")return""+e;else throw new Qn("Invalid value for IntMode");else if(e instanceof Uint8Array)return e.slice().buffer;else if(e===void 0)throw new Pe("Received unrecognized type of Value");else throw Ke(e,"Impossible type of Value")}var bde,Sde=9223372036854775807n;var mT=w(()=>{_t();Xr();bde=-9223372036854775808n});function ta(e){return{affectedRowCount:e.affectedRowCount,lastInsertRowid:e.lastInsertRowid,columnNames:e.cols.map((t)=>t.name),columnDecltypes:e.cols.map((t)=>t.decltype)}}function Qg(e,t){let r=ta(e),o=e.rows.map((n)=>cq(r.columnNames,n,t));return{...r,rows:o}}function Yg(e,t){let r=ta(e),o;if(e.rows.length>0)o=cq(r.columnNames,e.rows[0],t);return{...r,row:o}}function Xg(e,t){let r=ta(e),o;if(e.rows.length>0&&r.columnNames.length>0)o=pT(e.rows[0][0],t);return{...r,value:o}}function cq(e,t,r){let o={};Object.defineProperty(o,"length",{value:t.length});for(let n=0;n<t.length;++n){let i=pT(t[n],r);Object.defineProperty(o,n,{value:i});let s=e[n];if(s!==void 0&&!Object.hasOwn(o,s))Object.defineProperty(o,s,{value:i,enumerable:!0,configurable:!0,writable:!0})}return o}function zo(e){return new Vd(e.message,e)}var tf=w(()=>{_t();mT()});class ra{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=void 0}_getSqlId(e){if(this.#e!==e)throw new Qn("Attempted to use SQL text opened with other object");else if(this.#r!==void 0)throw new xt("SQL text is closed",this.#r);return this.#t}close(){this._setClosed(new We("SQL text was manually closed"))}_setClosed(e){if(this.#r===void 0)this.#r=e,this.#e._closeSql(this.#t)}get closed(){return this.#r!==void 0}}function rf(e,t){if(t instanceof ra)return{sqlId:t._getSqlId(e)};else return{sql:""+t}}var al=w(()=>{_t()});class Mi{#e;#t;constructor(){this.#e=[],this.#t=[]}get length(){return this.#e.length+this.#t.length}push(e){this.#e.push(e)}shift(){if(this.#t.length===0&&this.#e.length>0)this.#t=this.#e.reverse(),this.#e=[];return this.#t.pop()}first(){return this.#t.length!==0?this.#t[this.#t.length-1]:this.#e[0]}}class nf{sql;_args;_namedArgs;constructor(e){this.sql=e,this._args=[],this._namedArgs=new Map}bindIndexes(e){this._args.length=0;for(let t of e)this._args.push(sl(t));return this}bindIndex(e,t){if(e!==(e|0)||e<=0)throw RangeError("Index of a positional argument must be positive integer");while(this._args.length<e)this._args.push(null);return this._args[e-1]=sl(t),this}bindName(e,t){return this._namedArgs.set(e,sl(t)),this}unbindAll(){return this._args.length=0,this._namedArgs.clear(),this}}function ey(e,t,r){let o,n=[],i=[];if(t instanceof nf){o=t.sql,n=t._args;for(let[c,u]of t._namedArgs.entries())i.push({name:c,value:u})}else if(Array.isArray(t))if(o=t[0],Array.isArray(t[1]))n=t[1].map((c)=>sl(c));else i=Object.entries(t[1]).map(([c,u])=>({name:c,value:sl(u)}));else o=t;let{sql:s,sqlId:a}=rf(e,o);return{sql:s,sqlId:a,args:n,namedArgs:i,wantRows:r}}var ty=w(()=>{al();mT()});class ry{_stream;#e;_steps;#t;constructor(e,t){this._stream=e,this.#e=t,this._steps=[],this.#t=!1}step(){return new hT(this)}execute(){if(this.#t)throw new Qn("This batch has already been executed");this.#t=!0;let e={steps:this._steps.map((t)=>t.proto)};if(this.#e)return wde(this._stream,this._steps,e);else return vde(this._stream,this._steps,e)}}function vde(e,t,r){return e._batch(r).then((o)=>{for(let n=0;n<t.length;++n){let i=o.stepResults.get(n),s=o.stepErrors.get(n);t[n].callback(i,s)}})}async function wde(e,t,r){let o=await e._openCursor(r);try{let n=0,i=void 0,s=[];for(;;){let a=await o.next();if(a===void 0)break;if(a.type==="step_begin"){if(a.step<n||a.step>=t.length)throw new Pe("Server produced StepBeginEntry for unexpected step");else if(i!==void 0)throw new Pe("Server produced StepBeginEntry before terminating previous step");for(let c=n;c<a.step;++c)t[c].callback(void 0,void 0);n=a.step+1,i=a,s=[]}else if(a.type==="step_end"){if(i===void 0)throw new Pe("Server produced StepEndEntry but no step is active");let c={cols:i.cols,rows:s,affectedRowCount:a.affectedRowCount,lastInsertRowid:a.lastInsertRowid};t[i.step].callback(c,void 0),i=void 0,s=[]}else if(a.type==="step_error"){if(i===void 0){if(a.step>=t.length)throw new Pe("Server produced StepErrorEntry for unexpected step");for(let c=n;c<a.step;++c)t[c].callback(void 0,void 0)}else{if(a.step!==i.step)throw new Pe("Server produced StepErrorEntry for unexpected step");i=void 0,s=[]}t[a.step].callback(void 0,a.error),n=a.step+1}else if(a.type==="row"){if(i===void 0)throw new Pe("Server produced RowEntry but no step is active");s.push(a.row)}else if(a.type==="error")throw zo(a.error);else if(a.type==="none")throw new Pe("Server produced unrecognized CursorEntry");else throw Ke(a,"Impossible CursorEntry")}if(i!==void 0)throw new Pe("Server closed Cursor before terminating active step");for(let a=n;a<t.length;++a)t[a].callback(void 0,void 0)}finally{o.close()}}class hT{_batch;#e;_index;constructor(e){this._batch=e,this.#e=[],this._index=void 0}condition(e){return this.#e.push(e._proto),this}query(e){return this.#t(e,!0,Qg)}queryRow(e){return this.#t(e,!0,Yg)}queryValue(e){return this.#t(e,!0,Xg)}run(e){return this.#t(e,!1,ta)}#t(e,t,r){if(this._index!==void 0)throw new Qn("This BatchStep has already been added to the batch");let o=ey(this._batch._stream._sqlOwner(),e,t),n;if(this.#e.length===0)n=void 0;else if(this.#e.length===1)n=this.#e[0];else n={type:"and",conds:this.#e.slice()};let i={stmt:o,condition:n};return new Promise((s,a)=>{let c=(u,d)=>{if(u!==void 0&&d!==void 0)a(new Pe("Server returned both result and error"));else if(d!==void 0)a(zo(d));else if(u!==void 0)s(r(u,this._batch._stream.intMode));else s(void 0)};this._index=this._batch._steps.length,this._batch._steps.push({proto:i,callback:c})})}}class dt{_batch;_proto;constructor(e,t){this._batch=e,this._proto=t}static ok(e){return new dt(e._batch,{type:"ok",step:lq(e)})}static error(e){return new dt(e._batch,{type:"error",step:lq(e)})}static not(e){return new dt(e._batch,{type:"not",cond:e._proto})}static and(e,t){for(let r of t)uq(e,r);return new dt(e,{type:"and",conds:t.map((r)=>r._proto)})}static or(e,t){for(let r of t)uq(e,r);return new dt(e,{type:"or",conds:t.map((r)=>r._proto)})}static isAutocommit(e){return e._stream.client()._ensureVersion(3,"BatchCond.isAutocommit()"),new dt(e,{type:"is_autocommit"})}}function lq(e){if(e._index===void 0)throw new Qn("Cannot add a condition referencing a step that has not been added to the batch");return e._index}function uq(e,t){if(t._batch!==e)throw new Qn("Cannot mix BatchCond objects for different Batch objects")}var gT=w(()=>{_t();tf();ty();Xr()});function dq(e){return{paramNames:e.params.map((t)=>t.name),columns:e.cols,isExplain:e.isExplain,isReadonly:e.isReadonly}}class cl{constructor(e){this.intMode=e}query(e){return this.#e(e,!0,Qg)}queryRow(e){return this.#e(e,!0,Yg)}queryValue(e){return this.#e(e,!0,Xg)}run(e){return this.#e(e,!1,ta)}#e(e,t,r){let o=ey(this._sqlOwner(),e,t);return this._execute(o).then((n)=>r(n,this.intMode))}batch(e=!1){return new ry(this,e)}describe(e){let t=rf(this._sqlOwner(),e);return this._describe(t).then(dq)}sequence(e){let t=rf(this._sqlOwner(),e);return this._sequence(t)}intMode}var ny=w(()=>{gT();tf();al();ty()});class of{}var xde=1000,_de=10,yT;var fq=w(()=>{_t();yT=class yT extends of{#e;#t;#r;#n;#o;#i;#a;constructor(e,t,r){super();this.#e=e,this.#t=t,this.#r=r,this.#n=new Mi,this.#o=new Mi,this.#i=void 0,this.#a=!1}async next(){for(;;){if(this.#i!==void 0)throw new xt("Cursor is closed",this.#i);while(!this.#a&&this.#o.length<_de)this.#o.push(this.#s());let e=this.#n.shift();if(this.#a||e!==void 0)return e;await this.#o.shift().then((t)=>{if(t===void 0)return;for(let r of t.entries)this.#n.push(r);this.#a||=t.done})}}#s(){return this.#t._sendCursorRequest(this,{type:"fetch_cursor",cursorId:this.#r,maxCount:xde}).then((e)=>e,(e)=>{this._setClosed(e);return})}_setClosed(e){if(this.#i!==void 0)return;this.#i=e,this.#t._sendCursorRequest(this,{type:"close_cursor",cursorId:this.#r}).catch(()=>{return}),this.#t._cursorClosed(this)}close(){this._setClosed(new We("Cursor was manually closed"))}get closed(){return this.#i!==void 0}}});var sf;var bT=w(()=>{_t();ny();fq();sf=class sf extends cl{#e;#t;#r;#n;#o;#i;static open(e){let t=e._streamIdAlloc.alloc(),r=new sf(e,t),o=()=>{return},n=(s)=>r.#l(s),i={type:"open_stream",streamId:t};return e._sendRequest(i,{responseCallback:o,errorCallback:n}),r}constructor(e,t){super(e.intMode);this.#e=e,this.#t=t,this.#r=new Mi,this.#n=void 0,this.#o=!1,this.#i=void 0}client(){return this.#e}_sqlOwner(){return this.#e}_execute(e){return this.#a({type:"execute",streamId:this.#t,stmt:e}).then((t)=>t.result)}_batch(e){return this.#a({type:"batch",streamId:this.#t,batch:e}).then((t)=>t.result)}_describe(e){return this.#e._ensureVersion(2,"describe()"),this.#a({type:"describe",streamId:this.#t,sql:e.sql,sqlId:e.sqlId}).then((t)=>t.result)}_sequence(e){return this.#e._ensureVersion(2,"sequence()"),this.#a({type:"sequence",streamId:this.#t,sql:e.sql,sqlId:e.sqlId}).then((t)=>{return})}getAutocommit(){return this.#e._ensureVersion(3,"getAutocommit()"),this.#a({type:"get_autocommit",streamId:this.#t}).then((e)=>e.isAutocommit)}#a(e){return new Promise((t,r)=>{this.#s({type:"request",request:e,responseCallback:t,errorCallback:r})})}_openCursor(e){return this.#e._ensureVersion(3,"cursor"),new Promise((t,r)=>{this.#s({type:"cursor",batch:e,cursorCallback:t,errorCallback:r})})}_sendCursorRequest(e,t){if(e!==this.#n)throw new or("Cursor not associated with the stream attempted to execute a request");return new Promise((r,o)=>{if(this.#i!==void 0)o(new xt("Stream is closed",this.#i));else this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})})}_cursorClosed(e){if(e!==this.#n)throw new or("Cursor was closed, but it was not associated with the stream");this.#n=void 0,this.#c()}#s(e){if(this.#i!==void 0)e.errorCallback(new xt("Stream is closed",this.#i));else if(this.#o)e.errorCallback(new xt("Stream is closing",void 0));else this.#r.push(e),this.#c()}#c(){for(;;){let e=this.#r.first();if(e===void 0&&this.#n===void 0&&this.#o){this.#l(new We("Stream was gracefully closed"));break}else if(e?.type==="request"&&this.#n===void 0){let{request:t,responseCallback:r,errorCallback:o}=e;this.#r.shift(),this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})}else if(e?.type==="cursor"&&this.#n===void 0){let{batch:t,cursorCallback:r}=e;this.#r.shift();let o=this.#e._cursorIdAlloc.alloc(),n=new yT(this.#e,this,o),i={type:"open_cursor",streamId:this.#t,cursorId:o,batch:t},s=()=>{return},a=(c)=>n._setClosed(c);this.#e._sendRequest(i,{responseCallback:s,errorCallback:a}),this.#n=n,r(n)}else break}}#l(e){if(this.#i!==void 0)return;if(this.#i=e,this.#n!==void 0)this.#n._setClosed(e);for(;;){let n=this.#r.shift();if(n!==void 0)n.errorCallback(e);else break}let t={type:"close_stream",streamId:this.#t},r=()=>this.#e._streamIdAlloc.free(this.#t),o=()=>{return};this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})}close(){this.#l(new We("Stream was manually closed"))}closeGracefully(){this.#o=!0,this.#c()}get closed(){return this.#i!==void 0||this.#o}}});function af(e,t){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId);e.arrayObjects("args",t.args,pq),e.arrayObjects("named_args",t.namedArgs,Ede),e.boolean("want_rows",t.wantRows)}function Ede(e,t){e.string("name",t.name),e.object("value",t.value,pq)}function ll(e,t){e.arrayObjects("steps",t.steps,Ide)}function Ide(e,t){if(t.condition!==void 0)e.object("condition",t.condition,ST);e.object("stmt",t.stmt,af)}function ST(e,t){if(e.stringRaw("type",t.type),t.type==="ok"||t.type==="error")e.number("step",t.step);else if(t.type==="not")e.object("cond",t.cond,ST);else if(t.type==="and"||t.type==="or")e.arrayObjects("conds",t.conds,ST);else if(t.type==="is_autocommit");else throw Ke(t,"Impossible type of BatchCond")}function pq(e,t){if(t===null)e.stringRaw("type","null");else if(typeof t==="bigint")e.stringRaw("type","integer"),e.stringRaw("value",""+t);else if(typeof t==="number")e.stringRaw("type","float"),e.number("value",t);else if(typeof t==="string")e.stringRaw("type","text"),e.string("value",t);else if(t instanceof Uint8Array)e.stringRaw("type","blob"),e.stringRaw("base64",Qc.fromUint8Array(t));else if(t===void 0);else throw Ke(t,"Impossible type of Value")}var vT=w(()=>{Hg();Xr()});function mq(e,t){if(e.stringRaw("type",t.type),t.type==="hello"){if(t.jwt!==void 0)e.string("jwt",t.jwt)}else if(t.type==="request")e.number("request_id",t.requestId),e.object("request",t.request,kde);else throw Ke(t,"Impossible type of ClientMsg")}function kde(e,t){if(e.stringRaw("type",t.type),t.type==="open_stream")e.number("stream_id",t.streamId);else if(t.type==="close_stream")e.number("stream_id",t.streamId);else if(t.type==="execute")e.number("stream_id",t.streamId),e.object("stmt",t.stmt,af);else if(t.type==="batch")e.number("stream_id",t.streamId),e.object("batch",t.batch,ll);else if(t.type==="open_cursor")e.number("stream_id",t.streamId),e.number("cursor_id",t.cursorId),e.object("batch",t.batch,ll);else if(t.type==="close_cursor")e.number("cursor_id",t.cursorId);else if(t.type==="fetch_cursor")e.number("cursor_id",t.cursorId),e.number("max_count",t.maxCount);else if(t.type==="sequence"){if(e.number("stream_id",t.streamId),t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="describe"){if(e.number("stream_id",t.streamId),t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="store_sql")e.number("sql_id",t.sqlId),e.string("sql",t.sql);else if(t.type==="close_sql")e.number("sql_id",t.sqlId);else if(t.type==="get_autocommit")e.number("stream_id",t.streamId);else throw Ke(t,"Impossible type of Request")}var hq=w(()=>{vT();Xr()});function cf(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId);for(let r of t.args)e.message(3,r,yq);for(let r of t.namedArgs)e.message(4,r,Ade);e.bool(5,t.wantRows)}function Ade(e,t){e.string(1,t.name),e.message(2,t.value,yq)}function ul(e,t){for(let r of t.steps)e.message(1,r,Tde)}function Tde(e,t){if(t.condition!==void 0)e.message(1,t.condition,wT);e.message(2,t.stmt,cf)}function wT(e,t){if(t.type==="ok")e.uint32(1,t.step);else if(t.type==="error")e.uint32(2,t.step);else if(t.type==="not")e.message(3,t.cond,wT);else if(t.type==="and")e.message(4,t.conds,gq);else if(t.type==="or")e.message(5,t.conds,gq);else if(t.type==="is_autocommit")e.message(6,void 0,bq);else throw Ke(t,"Impossible type of BatchCond")}function gq(e,t){for(let r of t)e.message(1,r,wT)}function yq(e,t){if(t===null)e.message(1,void 0,bq);else if(typeof t==="bigint")e.sint64(2,t);else if(typeof t==="number")e.double(3,t);else if(typeof t==="string")e.string(4,t);else if(t instanceof Uint8Array)e.bytes(5,t);else if(t===void 0);else throw Ke(t,"Impossible type of Value")}function bq(e,t){}var xT=w(()=>{Xr()});function Sq(e,t){if(t.type==="hello")e.message(1,t,$de);else if(t.type==="request")e.message(2,t,Rde);else throw Ke(t,"Impossible type of ClientMsg")}function $de(e,t){if(t.jwt!==void 0)e.string(1,t.jwt)}function Rde(e,t){e.int32(1,t.requestId);let r=t.request;if(r.type==="open_stream")e.message(2,r,Ode);else if(r.type==="close_stream")e.message(3,r,Cde);else if(r.type==="execute")e.message(4,r,Pde);else if(r.type==="batch")e.message(5,r,zde);else if(r.type==="open_cursor")e.message(6,r,Nde);else if(r.type==="close_cursor")e.message(7,r,Dde);else if(r.type==="fetch_cursor")e.message(8,r,Lde);else if(r.type==="sequence")e.message(9,r,Bde);else if(r.type==="describe")e.message(10,r,jde);else if(r.type==="store_sql")e.message(11,r,Zde);else if(r.type==="close_sql")e.message(12,r,Ude);else if(r.type==="get_autocommit")e.message(13,r,qde);else throw Ke(r,"Impossible type of Request")}function Ode(e,t){e.int32(1,t.streamId)}function Cde(e,t){e.int32(1,t.streamId)}function Pde(e,t){e.int32(1,t.streamId),e.message(2,t.stmt,cf)}function zde(e,t){e.int32(1,t.streamId),e.message(2,t.batch,ul)}function Nde(e,t){e.int32(1,t.streamId),e.int32(2,t.cursorId),e.message(3,t.batch,ul)}function Dde(e,t){e.int32(1,t.cursorId)}function Lde(e,t){e.int32(1,t.cursorId),e.uint32(2,t.maxCount)}function Bde(e,t){if(e.int32(1,t.streamId),t.sql!==void 0)e.string(2,t.sql);if(t.sqlId!==void 0)e.int32(3,t.sqlId)}function jde(e,t){if(e.int32(1,t.streamId),t.sql!==void 0)e.string(2,t.sql);if(t.sqlId!==void 0)e.int32(3,t.sqlId)}function Zde(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function Ude(e,t){e.int32(1,t.sqlId)}function qde(e,t){e.int32(1,t.streamId)}var vq=w(()=>{xT();Xr()});function Fi(e){let t=Ar(e.message),r=Lr(e.code);return{message:t,code:r}}function lf(e){let t=bn(e.cols,wq),r=Gd(e.rows).map((s)=>bn(s,xq)),o=Po(e.affected_row_count),n=Lr(e.last_insert_rowid),i=n!==void 0?BigInt(n):void 0;return{cols:t,rows:r,affectedRowCount:o,lastInsertRowid:i}}function wq(e){let t=Lr(e.name),r=Lr(e.decltype);return{name:t,decltype:r}}function oy(e){let t=new Map;Gd(e.step_results).forEach((o,n)=>{if(o!==null)t.set(n,lf(kt(o)))});let r=new Map;return Gd(e.step_errors).forEach((o,n)=>{if(o!==null)r.set(n,Fi(kt(o)))}),{stepResults:t,stepErrors:r}}function iy(e){let t=Ar(e.type);if(t==="step_begin"){let r=Po(e.step),o=bn(e.cols,wq);return{type:"step_begin",step:r,cols:o}}else if(t==="step_end"){let r=Po(e.affected_row_count),o=Lr(e.last_insert_rowid),n=o!==void 0?BigInt(o):void 0;return{type:"step_end",affectedRowCount:r,lastInsertRowid:n}}else if(t==="step_error"){let r=Po(e.step),o=Fi(kt(e.error));return{type:"step_error",step:r,error:o}}else if(t==="row")return{type:"row",row:bn(e.row,xq)};else if(t==="error")return{type:"error",error:Fi(kt(e.error))};else throw new Pe("Unexpected type of CursorEntry")}function sy(e){let t=bn(e.params,Mde),r=bn(e.cols,Fde),o=Zi(e.is_explain),n=Zi(e.is_readonly);return{params:t,cols:r,isExplain:o,isReadonly:n}}function Mde(e){return{name:Lr(e.name)}}function Fde(e){let t=Ar(e.name),r=Lr(e.decltype);return{name:t,decltype:r}}function xq(e){let t=Ar(e.type);if(t==="null")return null;else if(t==="integer"){let r=Ar(e.value);return BigInt(r)}else if(t==="float")return Po(e.value);else if(t==="text")return Ar(e.value);else if(t==="blob")return Qc.toUint8Array(Ar(e.base64));else throw new Pe("Unexpected type of Value")}var ay=w(()=>{Hg();_t();il()});function _q(e){let t=Ar(e.type);if(t==="hello_ok")return{type:"hello_ok"};else if(t==="hello_error")return{type:"hello_error",error:Fi(kt(e.error))};else if(t==="response_ok"){let r=Po(e.request_id),o=Jde(kt(e.response));return{type:"response_ok",requestId:r,response:o}}else if(t==="response_error"){let r=Po(e.request_id),o=Fi(kt(e.error));return{type:"response_error",requestId:r,error:o}}else throw new Pe("Unexpected type of ServerMsg")}function Jde(e){let t=Ar(e.type);if(t==="open_stream")return{type:"open_stream"};else if(t==="close_stream")return{type:"close_stream"};else if(t==="execute")return{type:"execute",result:lf(kt(e.result))};else if(t==="batch")return{type:"batch",result:oy(kt(e.result))};else if(t==="open_cursor")return{type:"open_cursor"};else if(t==="close_cursor")return{type:"close_cursor"};else if(t==="fetch_cursor"){let r=bn(e.entries,iy),o=Zi(e.done);return{type:"fetch_cursor",entries:r,done:o}}else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:sy(kt(e.result))};else if(t==="store_sql")return{type:"store_sql"};else if(t==="close_sql")return{type:"close_sql"};else if(t==="get_autocommit")return{type:"get_autocommit",isAutocommit:Zi(e.is_autocommit)};else throw new Pe("Unexpected type of Response")}var Eq=w(()=>{_t();il();ay()});var en,Ji,Iq,kq,dl,Kde,Hde,cy,Vde,Wde,Gde,fl,Qde,Yde,Xde;var ly=w(()=>{en={default(){return{message:"",code:void 0}},1(e,t){t.message=e.string()},2(e,t){t.code=e.string()}},Ji={default(){return{cols:[],rows:[],affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.cols.push(e.message(Iq))},2(e,t){t.rows.push(e.message(kq))},3(e,t){t.affectedRowCount=Number(e.uint64())},4(e,t){t.lastInsertRowid=e.sint64()}},Iq={default(){return{name:void 0,decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},kq={default(){return[]},1(e,t){t.push(e.message(Xde))}},dl={default(){return{stepResults:new Map,stepErrors:new Map}},1(e,t){let[r,o]=e.message(Kde);t.stepResults.set(r,o)},2(e,t){let[r,o]=e.message(Hde);t.stepErrors.set(r,o)}},Kde={default(){return[0,Ji.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(Ji)}},Hde={default(){return[0,en.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(en)}},cy={default(){return{type:"none"}},1(e){return e.message(Vde)},2(e){return e.message(Wde)},3(e){return e.message(Gde)},4(e){return{type:"row",row:e.message(kq)}},5(e){return{type:"error",error:e.message(en)}}},Vde={default(){return{type:"step_begin",step:0,cols:[]}},1(e,t){t.step=e.uint32()},2(e,t){t.cols.push(e.message(Iq))}},Wde={default(){return{type:"step_end",affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.affectedRowCount=e.uint32()},2(e,t){t.lastInsertRowid=e.uint64()}},Gde={default(){return{type:"step_error",step:0,error:en.default()}},1(e,t){t.step=e.uint32()},2(e,t){t.error=e.message(en)}},fl={default(){return{params:[],cols:[],isExplain:!1,isReadonly:!1}},1(e,t){t.params.push(e.message(Qde))},2(e,t){t.cols.push(e.message(Yde))},3(e,t){t.isExplain=e.bool()},4(e,t){t.isReadonly=e.bool()}},Qde={default(){return{name:void 0}},1(e,t){t.name=e.string()}},Yde={default(){return{name:"",decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},Xde={default(){return},1(e){return null},2(e){return e.sint64()},3(e){return e.double()},4(e){return e.string()},5(e){return e.bytes()}}});var Aq,efe,tfe,rfe,nfe,ofe,ife,sfe,afe;var Tq=w(()=>{ly();Aq={default(){return{type:"none"}},1(e){return{type:"hello_ok"}},2(e){return e.message(efe)},3(e){return e.message(rfe)},4(e){return e.message(tfe)}},efe={default(){return{type:"hello_error",error:en.default()}},1(e,t){t.error=e.message(en)}},tfe={default(){return{type:"response_error",requestId:0,error:en.default()}},1(e,t){t.requestId=e.int32()},2(e,t){t.error=e.message(en)}},rfe={default(){return{type:"response_ok",requestId:0,response:{type:"none"}}},1(e,t){t.requestId=e.int32()},2(e,t){t.response={type:"open_stream"}},3(e,t){t.response={type:"close_stream"}},4(e,t){t.response=e.message(nfe)},5(e,t){t.response=e.message(ofe)},6(e,t){t.response={type:"open_cursor"}},7(e,t){t.response={type:"close_cursor"}},8(e,t){t.response=e.message(ife)},9(e,t){t.response={type:"sequence"}},10(e,t){t.response=e.message(sfe)},11(e,t){t.response={type:"store_sql"}},12(e,t){t.response={type:"close_sql"}},13(e,t){t.response=e.message(afe)}},nfe={default(){return{type:"execute",result:Ji.default()}},1(e,t){t.result=e.message(Ji)}},ofe={default(){return{type:"batch",result:dl.default()}},1(e,t){t.result=e.message(dl)}},ife={default(){return{type:"fetch_cursor",entries:[],done:!1}},1(e,t){t.entries.push(e.message(cy))},2(e,t){t.done=e.bool()}},sfe={default(){return{type:"describe",result:fl.default()}},1(e,t){t.result=e.message(fl)}},afe={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}}});var $q,_T,uy;var dy=w(()=>{dT();_t();fT();tf();al();Xr();bT();hq();vq();Eq();Tq();$q=new Map([["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]),_T=new Map([["hrana3-protobuf",{version:3,encoding:"protobuf"}],["hrana3",{version:3,encoding:"json"}],["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]);uy=class uy extends rl{#e;#t;#r;#n;#o;#i;#a;#s;#c;_streamIdAlloc;_cursorIdAlloc;#l;constructor(e,t){super();this.#e=e,this.#t=[],this.#r=!1,this.#n=void 0,this.#o=!1,this.#i=void 0,this.#a=!1,this.#s=new Map,this.#c=new qi,this._streamIdAlloc=new qi,this._cursorIdAlloc=new qi,this.#l=new qi,this.#e.binaryType="arraybuffer",this.#e.addEventListener("open",()=>this.#f()),this.#e.addEventListener("close",(r)=>this.#g(r)),this.#e.addEventListener("error",(r)=>this.#p(r)),this.#e.addEventListener("message",(r)=>this.#y(r)),this.#d({type:"hello",jwt:t})}#d(e){if(this.#n!==void 0)throw new or("Trying to send a message on a closed client");if(this.#r)this.#m(e);else{let t=()=>this.#m(e),r=()=>{return};this.#t.push({openCallback:t,errorCallback:r})}}#f(){let e=this.#e.protocol;if(e===void 0){this.#u(new We("The `WebSocket.protocol` property is undefined. This most likely means that the WebSocket implementation provided by the environment is broken. If you are using Miniflare 2, please update to Miniflare 3, which fixes this problem."));return}else if(e==="")this.#i={version:1,encoding:"json"};else if(this.#i=_T.get(e),this.#i===void 0){this.#u(new Pe(`Unrecognized WebSocket subprotocol: ${JSON.stringify(e)}`));return}for(let t of this.#t)t.openCallback();this.#t.length=0,this.#r=!0}#m(e){let t=this.#i.encoding;if(t==="json"){let r=Qd(e,mq);this.#e.send(r)}else if(t==="protobuf"){let r=ef(e,Sq);this.#e.send(r)}else throw Ke(t,"Impossible encoding")}getVersion(){return new Promise((e,t)=>{if(this.#a=!0,this.#n!==void 0)t(this.#n);else if(!this.#r){let r=()=>e(this.#i.version);this.#t.push({openCallback:r,errorCallback:t})}else e(this.#i.version)})}_ensureVersion(e,t){if(this.#i===void 0||!this.#a)throw new yn(`${t} is supported only on protocol version ${e} and higher, but the version supported by the WebSocket server is not yet known. Use Client.getVersion() to wait until the version is available.`);else if(this.#i.version<e)throw new yn(`${t} is supported on protocol version ${e} and higher, but the WebSocket server only supports version ${this.#i.version}`)}_sendRequest(e,t){if(this.#n!==void 0){t.errorCallback(new xt("Client is closed",this.#n));return}let r=this.#c.alloc();this.#s.set(r,{...t,type:e.type}),this.#d({type:"request",requestId:r,request:e})}#p(e){let r=e.message??"WebSocket was closed due to an error";this.#u(new nl(r))}#g(e){let t=`WebSocket was closed with code ${e.code}`;if(e.reason)t+=`: ${e.reason}`;this.#u(new nl(t))}#u(e){if(this.#n!==void 0)return;this.#n=e;for(let t of this.#t)t.errorCallback(e);this.#t.length=0;for(let[t,r]of this.#s.entries())r.errorCallback(e),this.#c.free(t);this.#s.clear(),this.#e.close()}#y(e){if(this.#n!==void 0)return;try{let t,r=this.#i.encoding;if(r==="json"){if(typeof e.data!=="string"){this.#e.close(3003,"Only text messages are accepted with JSON encoding"),this.#u(new Pe("Received non-text message from server with JSON encoding"));return}t=Xs(JSON.parse(e.data),_q)}else if(r==="protobuf"){if(!(e.data instanceof ArrayBuffer)){this.#e.close(3003,"Only binary messages are accepted with Protobuf encoding"),this.#u(new Pe("Received non-binary message from server with Protobuf encoding"));return}t=Ui(new Uint8Array(e.data),Aq)}else throw Ke(r,"Impossible encoding");this.#b(t)}catch(t){this.#e.close(3007,"Could not handle message"),this.#u(t)}}#b(e){if(e.type==="none")throw new Pe("Received an unrecognized ServerMsg");else if(e.type==="hello_ok"||e.type==="hello_error"){if(this.#o)throw new Pe("Received a duplicated hello response");if(this.#o=!0,e.type==="hello_error")throw zo(e.error);return}else if(!this.#o)throw new Pe("Received a non-hello message before a hello response");if(e.type==="response_ok"){let t=e.requestId,r=this.#s.get(t);if(this.#s.delete(t),r===void 0)throw new Pe("Received unexpected OK response");this.#c.free(t);try{if(r.type!==e.response.type)throw console.dir({responseState:r,msg:e}),new Pe("Received unexpected type of response");r.responseCallback(e.response)}catch(o){throw r.errorCallback(o),o}}else if(e.type==="response_error"){let t=e.requestId,r=this.#s.get(t);if(this.#s.delete(t),r===void 0)throw new Pe("Received unexpected error response");this.#c.free(t),r.errorCallback(zo(e.error))}else throw Ke(e,"Impossible ServerMsg type")}openStream(){return sf.open(this)}storeSql(e){this._ensureVersion(2,"storeSql()");let t=this.#l.alloc(),r=new ra(this,t),o=()=>{return},n=(s)=>r._setClosed(s),i={type:"store_sql",sqlId:t,sql:e};return this._sendRequest(i,{responseCallback:o,errorCallback:n}),r}_closeSql(e){if(this.#n!==void 0)return;let t=()=>this.#l.free(e),r=(n)=>this.#u(n),o={type:"close_sql",sqlId:e};this._sendRequest(o,{responseCallback:t,errorCallback:r})}close(){this.#u(new We("Client was manually closed"))}get closed(){return this.#n!==void 0}}});var na;var Rq=w(()=>{if(typeof queueMicrotask<"u")na=queueMicrotask;else{let e=Promise.resolve();na=(t)=>{e.then(t)}}});class ET{#e;#t;#r;constructor(e){this.#e=new Uint8Array(new ArrayBuffer(e)),this.#t=0,this.#r=0}get length(){return this.#r-this.#t}data(){return this.#e.slice(this.#t,this.#r)}push(e){this.#n(e.byteLength),this.#e.set(e,this.#r),this.#r+=e.byteLength}#n(e){if(this.#r+e<=this.#e.byteLength)return;let t=this.#r-this.#t;if(t+e<=this.#e.byteLength&&2*this.#r>=this.#e.byteLength)this.#e.copyWithin(0,this.#t,this.#r);else{let r=this.#e.byteLength;do r*=2;while(t+e>r);let o=new Uint8Array(new ArrayBuffer(r));o.set(this.#e.slice(this.#t,this.#r),0),this.#e=o}this.#r=t,this.#t=0}shift(e){this.#t+=e}}function Oq(e){let t=Lr(e.baton),r=Lr(e.base_url),o=bn(e.results,cfe);return{baton:t,baseUrl:r,results:o}}function cfe(e){let t=Ar(e.type);if(t==="ok")return{type:"ok",response:lfe(kt(e.response))};else if(t==="error")return{type:"error",error:Fi(kt(e.error))};else throw new Pe("Unexpected type of StreamResult")}function lfe(e){let t=Ar(e.type);if(t==="close")return{type:"close"};else if(t==="execute")return{type:"execute",result:lf(kt(e.result))};else if(t==="batch")return{type:"batch",result:oy(kt(e.result))};else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:sy(kt(e.result))};else if(t==="store_sql")return{type:"store_sql"};else if(t==="close_sql")return{type:"close_sql"};else if(t==="get_autocommit")return{type:"get_autocommit",isAutocommit:Zi(e.is_autocommit)};else throw new Pe("Unexpected type of StreamResponse")}function Cq(e){let t=Lr(e.baton),r=Lr(e.base_url);return{baton:t,baseUrl:r}}var IT=w(()=>{_t();il();ay()});var Pq,ufe,dfe,ffe,pfe,mfe,hfe,zq;var kT=w(()=>{ly();Pq={default(){return{baton:void 0,baseUrl:void 0,results:[]}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()},3(e,t){t.results.push(e.message(ufe))}},ufe={default(){return{type:"none"}},1(e){return{type:"ok",response:e.message(dfe)}},2(e){return{type:"error",error:e.message(en)}}},dfe={default(){return{type:"none"}},1(e){return{type:"close"}},2(e){return e.message(ffe)},3(e){return e.message(pfe)},4(e){return{type:"sequence"}},5(e){return e.message(mfe)},6(e){return{type:"store_sql"}},7(e){return{type:"close_sql"}},8(e){return e.message(hfe)}},ffe={default(){return{type:"execute",result:Ji.default()}},1(e,t){t.result=e.message(Ji)}},pfe={default(){return{type:"batch",result:dl.default()}},1(e,t){t.result=e.message(dl)}},mfe={default(){return{type:"describe",result:fl.default()}},1(e,t){t.result=e.message(fl)}},hfe={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}},zq={default(){return{baton:void 0,baseUrl:void 0}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()}}});var AT;var Nq=w(()=>{il();lT();_t();Xr();IT();kT();ay();ly();AT=class AT extends of{#e;#t;#r;#n;#o;#i;constructor(e,t){super();this.#e=e,this.#t=t,this.#r=void 0,this.#n=new ET(16384),this.#o=void 0,this.#i=!1}async open(e){if(e.body===null)throw new Pe("No response body for cursor request");this.#r=e.body[Symbol.asyncIterator]();let t=await this.#a(Cq,zq);if(t===void 0)throw new Pe("Empty response to cursor request");return t}next(){return this.#a(iy,cy)}close(){this._setClosed(new We("Cursor was manually closed"))}_setClosed(e){if(this.#o!==void 0)return;if(this.#o=e,this.#e._cursorClosed(this),this.#r!==void 0)this.#r.return()}get closed(){return this.#o!==void 0}async#a(e,t){for(;;){if(this.#i)return;else if(this.#o!==void 0)throw new xt("Cursor is closed",this.#o);if(this.#t==="json"){let n=this.#s();if(n!==void 0){let i=new TextDecoder().decode(n),s=JSON.parse(i);return Xs(s,e)}}else if(this.#t==="protobuf"){let n=this.#c();if(n!==void 0)return Ui(n,t)}else throw Ke(this.#t,"Impossible encoding");if(this.#r===void 0)throw new or("Attempted to read from HTTP cursor before it was opened");let{value:r,done:o}=await this.#r.next();if(o&&this.#n.length===0)this.#i=!0;else if(o)throw new Pe("Unexpected end of cursor stream");else this.#n.push(r)}}#s(){let e=this.#n.data(),t=10,r=e.indexOf(10);if(r<0)return;let o=e.slice(0,r);return this.#n.shift(r+1),o}#c(){let e=this.#n.data(),t=0,r=0;for(;;){if(r>=e.byteLength)return;let n=e[r];if(t|=(n&127)<<7*r,r+=1,!(n&128))break}if(e.byteLength<r+t)return;let o=e.slice(r,r+t);return this.#n.shift(r+t),o}}});function Dq(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.arrayObjects("requests",t.requests,gfe)}function gfe(e,t){if(e.stringRaw("type",t.type),t.type==="close");else if(t.type==="execute")e.object("stmt",t.stmt,af);else if(t.type==="batch")e.object("batch",t.batch,ll);else if(t.type==="sequence"){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="describe"){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="store_sql")e.number("sql_id",t.sqlId),e.string("sql",t.sql);else if(t.type==="close_sql")e.number("sql_id",t.sqlId);else if(t.type==="get_autocommit");else throw Ke(t,"Impossible type of StreamRequest")}function Lq(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.object("batch",t.batch,ll)}var TT=w(()=>{vT();Xr()});function Bq(e,t){if(t.baton!==void 0)e.string(1,t.baton);for(let r of t.requests)e.message(2,r,yfe)}function yfe(e,t){if(t.type==="close")e.message(1,t,bfe);else if(t.type==="execute")e.message(2,t,Sfe);else if(t.type==="batch")e.message(3,t,vfe);else if(t.type==="sequence")e.message(4,t,wfe);else if(t.type==="describe")e.message(5,t,xfe);else if(t.type==="store_sql")e.message(6,t,_fe);else if(t.type==="close_sql")e.message(7,t,Efe);else if(t.type==="get_autocommit")e.message(8,t,Ife);else throw Ke(t,"Impossible type of StreamRequest")}function bfe(e,t){}function Sfe(e,t){e.message(1,t.stmt,cf)}function vfe(e,t){e.message(1,t.batch,ul)}function wfe(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function xfe(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function _fe(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function Efe(e,t){e.int32(1,t.sqlId)}function Ife(e,t){}function jq(e,t){if(t.baton!==void 0)e.string(1,t.baton);e.message(2,t.batch,ul)}var $T=w(()=>{xT();Xr()});function kfe(e,t){if(t.results.length!==e.length)throw new Pe("Server returned unexpected number of pipeline results");for(let r=0;r<e.length;++r){let o=t.results[r],n=e[r];if(o.type==="ok"){if(o.response.type!==n.request.type)throw new Pe("Received unexpected type of response");n.responseCallback(o.response)}else if(o.type==="error")n.errorCallback(zo(o.error));else if(o.type==="none")throw new Pe("Received unrecognized type of StreamResult");else throw Ke(o,"Received impossible type of StreamResult")}}async function Afe(e,t){if(t==="json"){let r=await e.json();return Xs(r,Oq)}if(t==="protobuf"){let r=await e.arrayBuffer();return Ui(new Uint8Array(r),Pq)}throw await e.body?.cancel(),Ke(t,"Impossible encoding")}async function Tfe(e){let t=e.headers.get("content-type")??"text/plain",r=`Server returned HTTP status ${e.status}`;if(t==="application/json"){let o=await e.json();if("message"in o)return zo(o);return new Ys(r,e.status)}if(t==="text/plain"){let o=(await e.text()).trim();if(o!=="")r+=`: ${o}`;return new Ys(r,e.status)}return await e.body?.cancel(),new Ys(r,e.status)}var fy;var RT=w(()=>{_t();dT();fT();Rq();tf();al();ny();Xr();Nq();TT();$T();TT();$T();IT();kT();fy=class fy extends cl{#e;#t;#r;#n;#o;#i;#a;#s;#c;#l;#d;#f;#m;constructor(e,t,r,o,n){super(e.intMode);this.#e=e,this.#t=t.toString(),this.#r=r,this.#n=o,this.#o=n,this.#i=void 0,this.#a=new Mi,this.#s=!1,this.#l=!1,this.#d=!1,this.#f=void 0,this.#m=new qi}client(){return this.#e}_sqlOwner(){return this}storeSql(e){let t=this.#m.alloc();return this.#p({type:"store_sql",sqlId:t,sql:e}).then(()=>{return},(r)=>this._setClosed(r)),new ra(this,t)}_closeSql(e){if(this.#f!==void 0)return;this.#p({type:"close_sql",sqlId:e}).then(()=>this.#m.free(e),(t)=>this._setClosed(t))}_execute(e){return this.#p({type:"execute",stmt:e}).then((t)=>t.result)}_batch(e){return this.#p({type:"batch",batch:e}).then((t)=>t.result)}_describe(e){return this.#p({type:"describe",sql:e.sql,sqlId:e.sqlId}).then((t)=>t.result)}_sequence(e){return this.#p({type:"sequence",sql:e.sql,sqlId:e.sqlId}).then((t)=>{return})}getAutocommit(){return this.#e._ensureVersion(3,"getAutocommit()"),this.#p({type:"get_autocommit"}).then((e)=>e.isAutocommit)}#p(e){return new Promise((t,r)=>{this.#g({type:"pipeline",request:e,responseCallback:t,errorCallback:r})})}_openCursor(e){return new Promise((t,r)=>{this.#g({type:"cursor",batch:e,cursorCallback:t,errorCallback:r})})}_cursorClosed(e){if(e!==this.#c)throw new or("Cursor was closed, but it was not associated with the stream");this.#c=void 0,na(()=>this.#u())}close(){this._setClosed(new We("Stream was manually closed"))}closeGracefully(){this.#l=!0,na(()=>this.#u())}get closed(){return this.#f!==void 0||this.#l}_setClosed(e){if(this.#f!==void 0)return;if(this.#f=e,this.#c!==void 0)this.#c._setClosed(e);this.#e._streamClosed(this);for(;;){let t=this.#a.shift();if(t!==void 0)t.errorCallback(e);else break}if((this.#i!==void 0||this.#s)&&!this.#d)this.#a.push({type:"pipeline",request:{type:"close"},responseCallback:()=>{return},errorCallback:()=>{return}}),this.#d=!0,na(()=>this.#u())}#g(e){if(this.#f!==void 0)throw new xt("Stream is closed",this.#f);else if(this.#l)throw new xt("Stream is closing",void 0);else this.#a.push(e),na(()=>this.#u())}#u(){if(this.#s||this.#c!==void 0)return;if(this.#l&&this.#a.length===0){this._setClosed(new We("Stream was gracefully closed"));return}let e=this.#e._endpoint;if(e===void 0){this.#e._endpointPromise.then(()=>this.#u(),(r)=>this._setClosed(r));return}let t=this.#a.shift();if(t===void 0)return;else if(t.type==="pipeline"){let r=[t];for(;;){let o=this.#a.first();if(o!==void 0&&o.type==="pipeline")r.push(o),this.#a.shift();else if(o===void 0&&this.#l&&!this.#d){r.push({type:"pipeline",request:{type:"close"},responseCallback:()=>{return},errorCallback:()=>{return}}),this.#d=!0;break}else break}this.#y(e,r)}else if(t.type==="cursor")this.#b(e,t);else throw Ke(t,"Impossible type of QueueEntry")}#y(e,t){this.#h(()=>this.#S(t,e),(r)=>Afe(r,e.encoding),(r)=>r.baton,(r)=>r.baseUrl,(r)=>kfe(t,r),(r)=>t.forEach((o)=>o.errorCallback(r)))}#b(e,t){let r=new AT(this,e.encoding);this.#c=r,this.#h(()=>this.#v(t,e),(o)=>r.open(o),(o)=>o.baton,(o)=>o.baseUrl,(o)=>t.cursorCallback(r),(o)=>t.errorCallback(o))}#h(e,t,r,o,n,i){let s;try{let a=e(),c=this.#n;s=c(a)}catch(a){s=Promise.reject(a)}this.#s=!0,s.then((a)=>{if(!a.ok)return Tfe(a).then((c)=>{throw c});return t(a)}).then((a)=>{this.#i=r(a),this.#t=o(a)??this.#t,n(a)}).catch((a)=>{this._setClosed(a),i(a)}).finally(()=>{this.#s=!1,this.#u()})}#S(e,t){return this.#w(new URL(t.pipelinePath,this.#t),{baton:this.#i,requests:e.map((r)=>r.request)},t.encoding,Dq,Bq)}#v(e,t){if(t.cursorPath===void 0)throw new yn(`Cursors are supported only on protocol version 3 and higher, but the HTTP server only supports version ${t.version}.`);return this.#w(new URL(t.cursorPath,this.#t),{baton:this.#i,batch:e.batch},t.encoding,Lq,jq)}#w(e,t,r,o,n){let i,s;if(r==="json")i=Qd(t,o),s="application/json";else if(r==="protobuf")i=ef(t,n),s="application/x-protobuf";else throw Ke(r,"Impossible encoding");let a=new Headers;if(a.set("content-type",s),this.#r!==void 0)a.set("authorization",`Bearer ${this.#r}`);if(this.#o!==void 0)a.set("x-turso-encryption-key",this.#o);return new Request(e.toString(),{method:"POST",headers:a,body:i})}}});async function Rfe(e,t){let r=e;for(let o of $fe){let n=new URL(o.versionPath,t),i=new Request(n.toString(),{method:"GET"}),s=await r(i);if(await s.arrayBuffer(),s.ok)return o}return OT}var $fe,OT,py;var CT=w(()=>{_t();RT();$fe=[{versionPath:"v3-protobuf",pipelinePath:"v3-protobuf/pipeline",cursorPath:"v3-protobuf/cursor",version:3,encoding:"protobuf"}],OT={versionPath:"v2",pipelinePath:"v2/pipeline",cursorPath:void 0,version:2,encoding:"json"};py=class py extends rl{#e;#t;#r;#n;#o;#i;_endpointPromise;_endpoint;constructor(e,t,r,o,n=2){super();if(this.#e=e,this.#t=t,this.#r=r??globalThis.fetch,this.#n=o,this.#o=void 0,this.#i=new Set,n==3)this._endpointPromise=Rfe(this.#r,this.#e),this._endpointPromise.then((i)=>this._endpoint=i,(i)=>this.#a(i));else this._endpointPromise=Promise.resolve(OT),this._endpointPromise.then((i)=>this._endpoint=i,(i)=>this.#a(i))}async getVersion(){if(this._endpoint!==void 0)return this._endpoint.version;return(await this._endpointPromise).version}_ensureVersion(e,t){if(e<=OT.version)return;else if(this._endpoint===void 0)throw new yn(`${t} is supported only on protocol version ${e} and higher, but the version supported by the HTTP server is not yet known. Use Client.getVersion() to wait until the version is available.`);else if(this._endpoint.version<e)throw new yn(`${t} is supported only on protocol version ${e} and higher, but the HTTP server only supports version ${this._endpoint.version}.`)}openStream(){if(this.#o!==void 0)throw new xt("Client is closed",this.#o);let e=new fy(this,this.#e,this.#t,this.#r,this.#n);return this.#i.add(e),e}_streamClosed(e){this.#i.delete(e)}close(){this.#a(new We("Client was manually closed"))}get closed(){return this.#o!==void 0}#a(e){if(this.#o!==void 0)return;this.#o=e;for(let t of Array.from(this.#i))t._setClosed(new xt("Client was closed",e))}}});var Zq=w(()=>{_t()});function PT(e,t,r=2){if(typeof ji>"u")throw new Wd("WebSockets are not supported in this environment");var o=void 0;if(r==3)o=Array.from(_T.keys());else o=Array.from($q.keys());let n=new ji(e,o);return new uy(n,t)}function zT(e,t,r,o,n=2){return new py(e instanceof URL?e:new URL(e),t,r,o,n)}var my=w(()=>{cT();dy();_t();CT();dy();cT();gT();Zq();al();ty();ny();CT();RT();dy();bT();_t()});class uf{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=void 0}execute(e){return this.batch([e]).then((t)=>t[0])}async batch(e){let t=this._getStream();if(t.closed)throw new Ce("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{let r=e.map(No),o;if(this.#r===void 0){this._getSqlCache().apply(r);let i=t.batch(this.#t>=3),s=i.step(),a=s.run(Li(this.#e)),c=s;o=r.map((u)=>{let d=i.step().condition(dt.ok(c));if(this.#t>=3)d.condition(dt.not(dt.isAutocommit(i)));let f=d.query(u);return f.catch(()=>{return}),c=d,f}),this.#r=i.execute().then(()=>a).then(()=>{return});try{await this.#r}catch(u){throw this.close(),u}}else{if(this.#t<3)await this.#r;this._getSqlCache().apply(r);let i=t.batch(this.#t>=3),s=void 0;o=r.map((a)=>{let c=i.step();if(s!==void 0)c.condition(dt.ok(s));if(this.#t>=3)c.condition(dt.not(dt.isAutocommit(i)));let u=c.query(a);return u.catch(()=>{return}),s=c,u}),await i.execute()}let n=[];for(let i=0;i<o.length;i++)try{let s=await o[i];if(s===void 0)throw new Gt("Statement in a transaction was not executed, probably because the transaction has been rolled back",i,"TRANSACTION_CLOSED");n.push(ml(s))}catch(s){if(s instanceof Gt)throw s;let a=st(s);if(a instanceof Ce)throw new Gt(a.message,i,a.code,a.extendedCode,a.rawCode,a.cause instanceof Error?a.cause:void 0);throw a}return n}catch(r){throw st(r)}}async executeMultiple(e){let t=this._getStream();if(t.closed)throw new Ce("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{if(this.#r===void 0){this.#r=t.run(Li(this.#e)).then(()=>{return});try{await this.#r}catch(r){throw this.close(),r}}else await this.#r;await t.sequence(e)}catch(r){throw st(r)}}async rollback(){try{let e=this._getStream();if(e.closed)return;if(this.#r!==void 0);else return;let t=e.run("ROLLBACK").catch((r)=>{throw st(r)});e.closeGracefully(),await t}catch(e){throw st(e)}finally{this.close()}}async commit(){try{let e=this._getStream();if(e.closed)throw new Ce("Cannot commit the transaction because it is already closed","TRANSACTION_CLOSED");if(this.#r!==void 0)await this.#r;else return;let t=e.run("COMMIT").catch((r)=>{throw st(r)});e.closeGracefully(),await t}catch(e){throw st(e)}finally{this.close()}}}async function pl(e,t,r,o,n=!1){if(n)r.step().run("PRAGMA foreign_keys=off");let i=r.step(),s=i.run(Li(e)),a=i,c=o.map((h)=>{let b=r.step().condition(dt.ok(a));if(t>=3)b.condition(dt.not(dt.isAutocommit(r)));let y=b.query(h);return a=b,y}),u=r.step().condition(dt.ok(a));if(t>=3)u.condition(dt.not(dt.isAutocommit(r)));let d=u.run("COMMIT");if(r.step().condition(dt.not(dt.ok(u))).run("ROLLBACK").catch((h)=>{return}),n)r.step().run("PRAGMA foreign_keys=on");await r.execute();let m=[];await s;for(let h=0;h<c.length;h++)try{let b=await c[h];if(b===void 0)throw new Gt("Statement in a batch was not executed, probably because the transaction has been rolled back",h,"TRANSACTION_CLOSED");m.push(ml(b))}catch(b){if(b instanceof Gt)throw b;let y=st(b);if(y instanceof Ce)throw new Gt(y.message,h,y.code,y.extendedCode,y.rawCode,y.cause instanceof Error?y.cause:void 0);throw y}return await d,m}function No(e){let t,r;if(Array.isArray(e))[t,r]=e;else if(typeof e==="string")t=e;else t=e.sql,r=e.args;let o=new nf(t);if(r)if(Array.isArray(r))o.bindIndexes(r);else for(let[n,i]of Object.entries(r))o.bindName(n,i);return o}function ml(e){let t=e.columnNames.map((s)=>s??""),r=e.columnDecltypes.map((s)=>s??""),o=e.rows,n=e.affectedRowCount,i=e.lastInsertRowid!==void 0?e.lastInsertRowid:void 0;return new Yc(t,r,o,n,i)}function st(e){if(e instanceof We){let t=Uq(e);return new Ce(e.message,t,void 0,void 0,e)}return e}function Uq(e){if(e instanceof Vd&&e.code!==void 0)return e.code;else if(e instanceof Pe)return"HRANA_PROTO_ERROR";else if(e instanceof xt)return e.cause instanceof We?Uq(e.cause):"HRANA_CLOSED_ERROR";else if(e instanceof nl)return"HRANA_WEBSOCKET_ERROR";else if(e instanceof Ys)return"SERVER_ERROR";else if(e instanceof yn)return"PROTOCOL_VERSION_ERROR";else if(e instanceof or)return"INTERNAL_ERROR";else return"UNKNOWN"}var DT=w(()=>{my();gn();Xc()});class hl{#e;#t;capacity;constructor(e,t){this.#e=e,this.#t=new qq,this.capacity=t}apply(e){if(this.capacity<=0)return;let t=new Set;for(let r of e){if(typeof r.sql!=="string")continue;let o=r.sql;if(o.length>=5000)continue;let n=this.#t.get(o);if(n===void 0){while(this.#t.size+1>this.capacity){let[i,s]=this.#t.peekLru();if(t.has(s))break;s.close(),this.#t.delete(i)}if(this.#t.size+1<=this.capacity)n=this.#e.storeSql(o),this.#t.set(o,n)}if(n!==void 0)r.sql=n,t.add(n)}}}class qq{#e;constructor(){this.#e=new Map}get(e){let t=this.#e.get(e);if(t!==void 0)this.#e.delete(e),this.#e.set(e,t);return t}set(e,t){this.#e.set(e,t)}peekLru(){for(let e of this.#e.entries())return e;return}delete(e){this.#e.delete(e)}get size(){return this.#e.size}}var LT=ge(function(M2e,Fq){function Ofe(e){var t=0,r=[];function o(){if(t--,t<e)n()}function n(){var c=r.shift();if(a.queue=r.length,c)s(c.fn).then(c.resolve).catch(c.reject)}function i(c){return new Promise(function(u,d){r.push({fn:c,resolve:u,reject:d}),a.queue=r.length})}function s(c){t++;try{return Promise.resolve(c()).then(function(u){return o(),u},function(u){throw o(),u})}catch(u){return o(),Promise.reject(u)}}var a=function(c){if(t>=e)return i(c);else return s(c)};return a}function Cfe(e,t){var r=!1,o=this;return Promise.all(e.map(function(){var n=arguments;return o(function(){if(!r)return t.apply(void 0,n).catch(function(i){throw r=!0,i})})}))}function Mq(e){return e.queue=0,e.map=Cfe,e}Fq.exports=function(e){if(e)return Mq(Ofe(e));else return Mq(function(t){return t()})}});function Hq(e){if(e.scheme!=="wss"&&e.scheme!=="ws")throw new Ce(`The WebSocket client supports only "libsql:", "wss:" and "ws:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${Vn}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new Ce("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="ws"&&e.tls)throw new Ce('A "ws:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="wss"&&!e.tls)throw new Ce('A "wss:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=Md(e.scheme,e.authority,e.path),r;try{r=PT(t,e.authToken)}catch(o){if(o instanceof Wd){let n=e.scheme==="wss"?"https":"http",i=Md(n,e.authority,e.path);throw new Ce(`This environment does not support WebSockets, please switch to the HTTP client by using a "${n}:" URL (${JSON.stringify(i)}). For more information, please read ${Vn}`,"WEBSOCKETS_NOT_SUPPORTED")}throw st(o)}return new Vq(r,t,e.authToken,e.intMode,e.concurrency)}class Vq{#e;#t;#r;#n;#o;closed;protocol;#i;#a;constructor(e,t,r,o,n){this.#e=t,this.#t=r,this.#r=o,this.#n=this.#c(e),this.#o=void 0,this.closed=!1,this.protocol="ws",this.#a=Kq.default(n)}async limit(e){return this.#a(e)}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.limit(async()=>{let o=await this.#s();try{let n=No(r);o.conn.sqlCache.apply([n]);let i=o.stream.query(n);o.stream.closeGracefully();let s=await i;return ml(s)}catch(n){throw st(n)}finally{this._closeStream(o)}})}async batch(e,t="deferred"){return this.limit(async()=>{let r=await this.#s();try{let n=e.map((u)=>{if(Array.isArray(u))return{sql:u[0],args:u[1]||[]};return u}).map(No),i=await r.conn.client.getVersion();r.conn.sqlCache.apply(n);let s=r.stream.batch(i>=3);return await pl(t,i,s,n)}catch(o){throw st(o)}finally{this._closeStream(r)}})}async migrate(e){return this.limit(async()=>{let t=await this.#s();try{let r=e.map(No),o=await t.conn.client.getVersion(),n=t.stream.batch(o>=3);return await pl("deferred",o,n,r,!0)}catch(r){throw st(r)}finally{this._closeStream(t)}})}async transaction(e="write"){return this.limit(async()=>{let t=await this.#s();try{let r=await t.conn.client.getVersion();return new Wq(this,t,e,r)}catch(r){throw this._closeStream(t),st(r)}})}async executeMultiple(e){return this.limit(async()=>{let t=await this.#s();try{let r=t.stream.sequence(e);t.stream.closeGracefully(),await r}catch(r){throw st(r)}finally{this._closeStream(t)}})}sync(){throw new Ce("sync not supported in ws mode","SYNC_NOT_SUPPORTED")}async#s(){if(this.closed)throw new Ce("The client is closed","CLIENT_CLOSED");if(new Date().valueOf()-this.#n.openTime.valueOf()>Pfe&&this.#o===void 0){let o=this.#c();this.#o=o,o.client.getVersion().then((n)=>{if(this.#n!==o){if(this.#n.streamStates.size===0)this.#n.client.close()}this.#n=o,this.#o=void 0},(n)=>{this.#o=void 0})}if(this.#n.client.closed)try{if(this.#o!==void 0)this.#n=this.#o;else this.#n=this.#c()}catch(o){throw st(o)}let r=this.#n;try{if(r.useSqlCache===void 0){if(r.useSqlCache=await r.client.getVersion()>=2,r.useSqlCache)r.sqlCache.capacity=Jq}let o=r.client.openStream();o.intMode=this.#r;let n={conn:r,stream:o};return r.streamStates.add(n),n}catch(o){throw st(o)}}#c(e){try{return e??=PT(this.#e,this.#t),{client:e,useSqlCache:void 0,sqlCache:new hl(e,0),openTime:new Date,streamStates:new Set}}catch(t){throw st(t)}}async reconnect(){try{for(let r of Array.from(this.#n.streamStates))try{r.stream.close()}catch{}this.#n.client.close()}catch{}if(this.#o){try{this.#o.client.close()}catch{}this.#o=void 0}let e=this.#c(),t=await e.client.getVersion();if(e.useSqlCache=t>=2,e.useSqlCache)e.sqlCache.capacity=Jq;this.#n=e,this.closed=!1}_closeStream(e){e.stream.close();let t=e.conn;if(t.streamStates.delete(e),t.streamStates.size===0&&t!==this.#n)t.client.close()}close(){if(this.#n.client.close(),this.closed=!0,this.#o){try{this.#o.client.close()}catch{}this.#o=void 0}this.closed=!0}}var Kq,Pfe=60000,Jq=100,Wq;var Gq=w(()=>{my();gn();Kd();DT();Fg();Xc();Kq=Rl(LT(),1);gn();Wq=class Wq extends uf{#e;#t;constructor(e,t,r,o){super(r,o);this.#e=e,this.#t=t}_getStream(){return this.#t.stream}_getSqlCache(){return this.#t.conn.sqlCache}close(){this.#e._closeStream(this.#t)}get closed(){return this.#t.stream.closed}}});function Yq(e){if(e.scheme!=="https"&&e.scheme!=="http")throw new Ce(`The HTTP client supports only "libsql:", "https:" and "http:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${Vn}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new Ce("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="http"&&e.tls)throw new Ce('A "http:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="https"&&!e.tls)throw new Ce('A "https:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=Md(e.scheme,e.authority,e.path);return new eM(t,e.authToken,e.intMode,e.fetch,e.concurrency,e.remoteEncryptionKey)}class eM{#e;protocol;#t;#r;#n;#o;#i;#a;#s;constructor(e,t,r,o,n,i){this.#t=e,this.#i=t,this.#r=r,this.#n=o,this.#o=n,this.#a=i,this.#e=zT(this.#t,this.#i,this.#n,i),this.#e.intMode=this.#r,this.protocol="http",this.#s=Qq.default(this.#o)}async limit(e){return this.#s(e)}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.limit(async()=>{try{let o=No(r),n,i=this.#e.openStream();try{n=i.query(o)}finally{i.closeGracefully()}let s=await n;return ml(s)}catch(o){throw st(o)}})}async batch(e,t="deferred"){return this.limit(async()=>{try{let o=e.map((c)=>{if(Array.isArray(c))return{sql:c[0],args:c[1]||[]};return c}).map(No),n=await this.#e.getVersion(),i,s=this.#e.openStream();try{new hl(s,Xq).apply(o);let u=s.batch(!1);i=pl(t,n,u,o)}finally{s.closeGracefully()}return await i}catch(r){throw st(r)}})}async migrate(e){return this.limit(async()=>{try{let t=e.map(No),r=await this.#e.getVersion(),o,n=this.#e.openStream();try{let s=n.batch(!1);o=pl("deferred",r,s,t,!0)}finally{n.closeGracefully()}return await o}catch(t){throw st(t)}})}async transaction(e="write"){return this.limit(async()=>{try{let t=await this.#e.getVersion();return new tM(this.#e.openStream(),e,t)}catch(t){throw st(t)}})}async executeMultiple(e){return this.limit(async()=>{try{let t,r=this.#e.openStream();try{t=r.sequence(e)}finally{r.closeGracefully()}await t}catch(t){throw st(t)}})}sync(){throw new Ce("sync not supported in http mode","SYNC_NOT_SUPPORTED")}close(){this.#e.close()}async reconnect(){try{if(!this.closed)this.#e.close()}finally{this.#e=zT(this.#t,this.#i,this.#n,this.#a),this.#e.intMode=this.#r}}get closed(){return this.#e.closed}}var Qq,Xq=30,tM;var rM=w(()=>{my();gn();Kd();DT();Fg();Xc();Qq=Rl(LT(),1);gn();tM=class tM extends uf{#e;#t;constructor(e,t,r){super(t,r);this.#e=e,this.#t=new hl(e,Xq)}_getStream(){return this.#e}_getSqlCache(){return this.#t}close(){this.#e.close()}get closed(){return this.#e.closed}}});function gl(e){return zfe(Jd(e,!0))}function zfe(e){if(e.scheme==="wss"||e.scheme==="ws")return Hq(e);else if(e.scheme==="https"||e.scheme==="http")return Yq(e);else return Q4(e)}var BT=w(()=>{Kd();rq();Gq();rM();gn()});function oe(e,t){if(!e||typeof e!=="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,F))throw 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 r=Object.getPrototypeOf(e).constructor;if(r)while(r){if(F in r&&r[F]===t[F])return!0;r=Object.getPrototypeOf(r)}return!1}var F;var Re=w(()=>{F=Symbol.for("drizzle:entityKind")});var He;var Sn=w(()=>{Re();He=class He{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[F]="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(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}});var df;var hy=w(()=>{Re();df=class df{static[F]="ColumnBuilder";config;constructor(e,t,r){this.config={name:e,keyAsName:e==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:r,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){if(this.config.name!=="")return;this.config.name=e}}});var ir;var yl=w(()=>{ir=Symbol.for("drizzle:Name")});var jT,nM;var oM=w(()=>{Re();yl();jT=class jT{static[F]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){if(this.reference=()=>{let{name:r,columns:o,foreignColumns:n}=e();return{name:r,columns:o,foreignTable:n[0].table,foreignColumns:n}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e===void 0?"no action":e,this}onDelete(e){return this._onDelete=e===void 0?"no action":e,this}build(e){return new nM(e,this)}};nM=class nM{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[F]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),o=t.map((s)=>s.name),n=r.map((s)=>s.name),i=[this.table[ir],...o,r[0].table[ir],...n];return e??`${i.join("_")}_fk`}}});function gy(e,...t){return e(...t)}var ZT=()=>{};function UT(e,t){return`${e[ir]}_${t.join("_")}_unique`}var iM,Nfe,sM;var aM=w(()=>{Re();yl();iM=class iM{constructor(e,t){this.name=t,this.columns=e}static[F]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new sM(e,this.columns,this.nullsNotDistinctConfig,this.name)}};Nfe=class Nfe{static[F]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new iM(e,this.name)}};sM=class sM{constructor(e,t,r,o){this.table=e,this.columns=t,this.name=o??UT(this.table,this.columns.map((n)=>n.name)),this.nullsNotDistinct=r}static[F]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}});function cM(e,t,r){for(let o=t;o<e.length;o++){let n=e[o];if(n==="\\"){o++;continue}if(n==='"')return[e.slice(t,o).replace(/\\/g,""),o+1];if(r)continue;if(n===","||n==="}")return[e.slice(t,o).replace(/\\/g,""),o]}return[e.slice(t).replace(/\\/g,""),e.length]}function lM(e,t=0){let r=[],o=t,n=!1;while(o<e.length){let i=e[o];if(i===","){if(n||o===t)r.push("");n=!0,o++;continue}if(n=!1,i==="\\"){o+=2;continue}if(i==='"'){let[c,u]=cM(e,o+1,!0);r.push(c),o=u;continue}if(i==="}")return[r,o+1];if(i==="{"){let[c,u]=lM(e,o+1);r.push(c),o=u;continue}let[s,a]=cM(e,o,!1);r.push(s),o=a}return[r,o]}function uM(e){let[t]=lM(e,1);return t}function qT(e){return`{${e.map((t)=>{if(Array.isArray(t))return qT(t);if(typeof t==="string")return`"${t.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${t}`}).join(",")}}`}var dM=()=>{};var ff,bl,fM,Dfe,pM,MT;var mM=w(()=>{hy();Sn();Re();oM();ZT();aM();dM();ff=class ff extends df{foreignKeyConfigs=[];static[F]="PgColumnBuilder";array(e){return new pM(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:"always",mode:"stored"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:r,actions:o})=>gy((n,i)=>{let s=new jT(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(i.onUpdate)s.onUpdate(i.onUpdate);if(i.onDelete)s.onDelete(i.onDelete);return s.build(t)},r,o))}buildExtraConfigColumn(e){return new fM(e,this.config)}};bl=class bl extends He{constructor(e,t){if(!t.uniqueName)t.uniqueName=UT(e,[t.name]);super(e,t);this.table=e}static[F]="PgColumn"};fM=class fM extends bl{static[F]="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(e){return this.indexConfig.opClass=e,this}};Dfe=class Dfe{static[F]="IndexedColumn";constructor(e,t,r,o){this.name=e,this.keyAsName=t,this.type=r,this.indexConfig=o}name;keyAsName;type;indexConfig};pM=class pM extends ff{static[F]="PgArrayBuilder";constructor(e,t,r){super(e,"array","PgArray");this.config.baseBuilder=t,this.config.size=r}build(e){let t=this.config.baseBuilder.build(e);return new MT(e,this.config,t)}};MT=class MT extends bl{constructor(e,t,r,o){super(e,t);this.baseColumn=r,this.range=o,this.size=t.size}size;static[F]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(e){if(typeof e==="string")e=uM(e);return e.map((t)=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let r=e.map((o)=>o===null?null:oe(this.baseColumn,MT)?this.baseColumn.mapToDriverValue(o,!0):this.baseColumn.mapToDriverValue(o));if(t)return r;return qT(r)}}});function yM(e){return!!e&&typeof e==="function"&&hM in e&&e[hM]===!0}var Lfe,gM,hM,Bfe,bM;var SM=w(()=>{Re();mM();Lfe=class Lfe extends ff{static[F]="PgEnumObjectColumnBuilder";constructor(e,t){super(e,"string","PgEnumObjectColumn");this.config.enum=t}build(e){return new gM(e,this.config)}};gM=class gM extends bl{static[F]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}};hM=Symbol.for("drizzle:isPgEnum");Bfe=class Bfe extends ff{static[F]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn");this.config.enum=t}build(e){return new bM(e,this.config)}};bM=class bM extends bl{static[F]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}}});var ft,pf;var vn=w(()=>{Re();ft=class ft{static[F]="Subquery";constructor(e,t,r,o=!1,n=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:r,isWith:o,usedTables:n}}};pf=class pf extends ft{static[F]="WithSubquery"}});var vM="0.45.2";var wM=()=>{};var FT,JT,xM;var _M=w(()=>{ZT();wM();xM={startActiveSpan(e,t){if(!FT)return t();if(!JT)JT=FT.trace.getTracer("drizzle-orm",vM);return gy((r,o)=>o.startActiveSpan(e,(n)=>{try{return t(n)}catch(i){throw n.setStatus({code:r.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{n.end()}}),FT,JT)}}});var pt;var Do=w(()=>{pt=Symbol.for("drizzle:ViewBaseConfig")});function Ki(e){return e[ir]}function oa(e){return`${e[yy]??"public"}.${e[ir]}`}var yy,by,EM,KT,HT,mf,IM,jfe,me;var sr=w(()=>{Re();yl();yy=Symbol.for("drizzle:Schema"),by=Symbol.for("drizzle:Columns"),EM=Symbol.for("drizzle:ExtraConfigColumns"),KT=Symbol.for("drizzle:OriginalName"),HT=Symbol.for("drizzle:BaseName"),mf=Symbol.for("drizzle:IsAlias"),IM=Symbol.for("drizzle:ExtraConfigBuilder"),jfe=Symbol.for("drizzle:IsDrizzleTable");me=class me{static[F]="Table";static Symbol={Name:ir,Schema:yy,OriginalName:KT,Columns:by,ExtraConfigColumns:EM,BaseName:HT,IsAlias:mf,ExtraConfigBuilder:IM};[ir];[KT];[yy];[by];[EM];[HT];[mf]=!1;[jfe]=!0;[IM]=void 0;constructor(e,t,r){this[ir]=this[KT]=e,this[yy]=t,this[HT]=r}}});function VT(e){return e!==null&&e!==void 0&&typeof e.getSQL==="function"}function Ufe(e){let t={sql:"",params:[]};for(let r of e)if(t.sql+=r.sql,t.params.push(...r.params),r.typings?.length){if(!t.typings)t.typings=[];t.typings.push(...r.typings)}return t}function kM(e){return typeof e==="object"&&e!==null&&"mapToDriverValue"in e&&typeof e.mapToDriverValue==="function"}function C(e,...t){let r=[];if(t.length>0||e.length>0&&e[0]!=="")r.push(new zt(e[0]));for(let[o,n]of t.entries())r.push(n,new zt(e[o+1]));return new xe(r)}function hf(e,t){return e.map((r)=>{if(oe(r,Hi)){if(!(r.name in t))throw Error(`No value for placeholder "${r.name}" was provided`);return t[r.name]}if(oe(r,Br)&&oe(r.value,Hi)){if(!(r.value.name in t))throw Error(`No value for placeholder "${r.value.name}" was provided`);return r.encoder.mapToDriverValue(t[r.value.name])}return r})}var Zfe,zt,xe,Sy,AM,TM,eLe,Br,Hi,qfe,tn;var Yt=w(()=>{Re();SM();vn();_M();Do();Sn();sr();Zfe=class Zfe{static[F]="FakePrimitiveParam"};zt=class zt{static[F]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new xe([this])}};xe=class xe{constructor(e){this.queryChunks=e;for(let t of e)if(oe(t,me)){let r=t[me.Symbol.Schema];this.usedTables.push(r===void 0?t[me.Symbol.Name]:r+"."+t[me.Symbol.Name])}}static[F]="SQL";decoder=AM;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return xM.startActiveSpan("drizzle.buildSQL",(t)=>{let r=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":r.sql,"drizzle.query.params":JSON.stringify(r.params)}),r})}buildQueryFromSourceParams(e,t){let r=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:o,escapeName:n,escapeParam:i,prepareTyping:s,inlineParams:a,paramStartIndex:c}=r;return Ufe(e.map((u)=>{if(oe(u,zt))return{sql:u.value.join(""),params:[]};if(oe(u,Sy))return{sql:n(u.value),params:[]};if(u===void 0)return{sql:"",params:[]};if(Array.isArray(u)){let d=[new zt("(")];for(let[f,m]of u.entries())if(d.push(m),f<u.length-1)d.push(new zt(", "));return d.push(new zt(")")),this.buildQueryFromSourceParams(d,r)}if(oe(u,xe))return this.buildQueryFromSourceParams(u.queryChunks,{...r,inlineParams:a||u.shouldInlineParams});if(oe(u,me)){let d=u[me.Symbol.Schema],f=u[me.Symbol.Name];return{sql:d===void 0||u[mf]?n(f):n(d)+"."+n(f),params:[]}}if(oe(u,He)){let d=o.getColumnCasing(u);if(t.invokeSource==="indexes")return{sql:n(d),params:[]};let f=u.table[me.Symbol.Schema];return{sql:u.table[mf]||f===void 0?n(u.table[me.Symbol.Name])+"."+n(d):n(f)+"."+n(u.table[me.Symbol.Name])+"."+n(d),params:[]}}if(oe(u,tn)){let d=u[pt].schema,f=u[pt].name;return{sql:d===void 0||u[pt].isAlias?n(f):n(d)+"."+n(f),params:[]}}if(oe(u,Br)){if(oe(u.value,Hi))return{sql:i(c.value++,u),params:[u],typings:["none"]};let d=u.value===null?null:u.encoder.mapToDriverValue(u.value);if(oe(d,xe))return this.buildQueryFromSourceParams([d],r);if(a)return{sql:this.mapInlineParam(d,r),params:[]};let f=["none"];if(s)f=[s(u.encoder)];return{sql:i(c.value++,d),params:[d],typings:f}}if(oe(u,Hi))return{sql:i(c.value++,u),params:[u],typings:["none"]};if(oe(u,xe.Aliased)&&u.fieldAlias!==void 0)return{sql:n(u.fieldAlias),params:[]};if(oe(u,ft)){if(u._.isWith)return{sql:n(u._.alias),params:[]};return this.buildQueryFromSourceParams([new zt("("),u._.sql,new zt(") "),new Sy(u._.alias)],r)}if(yM(u)){if(u.schema)return{sql:n(u.schema)+"."+n(u.enumName),params:[]};return{sql:n(u.enumName),params:[]}}if(VT(u)){if(u.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([u.getSQL()],r);return this.buildQueryFromSourceParams([new zt("("),u.getSQL(),new zt(")")],r)}if(a)return{sql:this.mapInlineParam(u,r),params:[]};return{sql:i(c.value++,u),params:[u],typings:["none"]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return"null";if(typeof e==="number"||typeof e==="boolean")return e.toString();if(typeof e==="string")return t(e);if(typeof e==="object"){let r=e.toString();if(r==="[object Object]")return t(JSON.stringify(e));return t(r)}throw Error("Unexpected param value: "+e)}getSQL(){return this}as(e){if(e===void 0)return this;return new xe.Aliased(this,e)}mapWith(e){return this.decoder=typeof e==="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}};Sy=class Sy{constructor(e){this.value=e}static[F]="Name";brand;getSQL(){return new xe([this])}};AM={mapFromDriverValue:(e)=>e},TM={mapToDriverValue:(e)=>e},eLe={...AM,...TM};Br=class Br{constructor(e,t=TM){this.value=e,this.encoder=t}static[F]="Param";brand;getSQL(){return new xe([this])}};((e)=>{function t(){return new xe([])}e.empty=t;function r(c){return new xe(c)}e.fromList=r;function o(c){return new xe([new zt(c)])}e.raw=o;function n(c,u){let d=[];for(let[f,m]of c.entries()){if(f>0&&u!==void 0)d.push(u);d.push(m)}return new xe(d)}e.join=n;function i(c){return new Sy(c)}e.identifier=i;function s(c){return new Hi(c)}e.placeholder=s;function a(c,u){return new Br(c,u)}e.param=a})(C||(C={}));((e)=>{class t{constructor(r,o){this.sql=r,this.fieldAlias=o}static[F]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(xe||(xe={}));Hi=class Hi{constructor(e){this.name=e}static[F]="Placeholder";getSQL(){return new xe([this])}};qfe=Symbol.for("drizzle:IsDrizzleView");tn=class tn{static[F]="View";[pt];[qfe]=!0;constructor({name:e,schema:t,selectedFields:r,query:o}){this[pt]={name:e,originalName:e,schema:t,selectedFields:r,query:o,isExisting:!o,isAlias:!1}}getSQL(){return new xe([this])}};He.prototype.getSQL=function(){return new xe([this])};me.prototype.getSQL=function(){return new xe([this])};ft.prototype.getSQL=function(){return new xe([this])}});function WT(e,t,r){let o={},n=e.reduce((i,{path:s,field:a},c)=>{let u;if(oe(a,He))u=a;else if(oe(a,xe))u=a.decoder;else if(oe(a,ft))u=a._.sql.decoder;else u=a.sql.decoder;let d=i;for(let[f,m]of s.entries())if(f<s.length-1){if(!(m in d))d[m]={};d=d[m]}else{let h=t[c],b=d[m]=h===null?null:u.mapFromDriverValue(h);if(r&&oe(a,He)&&s.length===2){let y=s[0];if(!(y in o))o[y]=b===null?Ki(a.table):!1;else if(typeof o[y]==="string"&&o[y]!==Ki(a.table))o[y]=!1}}return i},{});if(r&&Object.keys(o).length>0){for(let[i,s]of Object.entries(o))if(typeof s==="string"&&!r[s])n[i]=null}return n}function rn(e,t){return Object.entries(e).reduce((r,[o,n])=>{if(typeof o!=="string")return r;let i=t?[...t,o]:[o];if(oe(n,He)||oe(n,xe)||oe(n,xe.Aliased)||oe(n,ft))r.push({path:i,field:n});else if(oe(n,me))r.push(...rn(n[me.Symbol.Columns],i));else r.push(...rn(n,i));return r},[])}function gf(e,t){let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let[n,i]of r.entries())if(i!==o[n])return!1;return!0}function vy(e,t){let r=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,n])=>{if(oe(n,xe)||oe(n,He))return[o,n];else return[o,new Br(n,e[me.Symbol.Columns][o])]});if(r.length===0)throw Error("No values to set");return Object.fromEntries(r)}function $M(e,t){for(let r of t)for(let o of Object.getOwnPropertyNames(r.prototype)){if(o==="constructor")continue;Object.defineProperty(e.prototype,o,Object.getOwnPropertyDescriptor(r.prototype,o)||Object.create(null))}}function wy(e){return e[me.Symbol.Columns]}function yf(e){return oe(e,ft)?e._.alias:oe(e,tn)?e[pt].name:oe(e,xe)?void 0:e[me.Symbol.IsAlias]?e[me.Symbol.Name]:e[me.Symbol.BaseName]}function Yn(e,t){return{name:typeof e==="string"&&e.length>0?e:"",config:typeof e==="object"?e:t}}function RM(e){if(typeof e!=="object"||e===null)return!1;if(e.constructor.name!=="Object")return!1;if("logger"in e){let t=typeof e.logger;if(t!=="boolean"&&(t!=="object"||typeof e.logger.logQuery!=="function")&&t!=="undefined")return!1;return!0}if("schema"in e){let t=typeof e.schema;if(t!=="object"&&t!=="undefined")return!1;return!0}if("casing"in e){let t=typeof e.casing;if(t!=="string"&&t!=="undefined")return!1;return!0}if("mode"in e){if(e.mode!=="default"||e.mode!=="planetscale"||e.mode!==void 0)return!1;return!0}if("connection"in e){let t=typeof e.connection;if(t!=="string"&&t!=="object"&&t!=="undefined")return!1;return!0}if("client"in e){let t=typeof e.client;if(t!=="object"&&t!=="function"&&t!=="undefined")return!1;return!0}if(Object.keys(e).length===0)return!0;return!1}var GT;var br=w(()=>{Sn();Re();Yt();vn();sr();Do();GT=typeof TextDecoder>"u"?null:new TextDecoder});var OM,QT,YT;var xy=w(()=>{Re();OM=class OM{static[F]="ConsoleLogWriter";write(e){console.log(e)}};QT=class QT{static[F]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new OM}logQuery(e,t){let r=t.map((n)=>{try{return JSON.stringify(n)}catch{return String(n)}}),o=r.length?` -- params: [${r.join(", ")}]`:"";this.writer.write(`Query: ${e}${o}`)}};YT=class YT{static[F]="NoopLogger";logQuery(){}}});var CM,PM,XT;var zM=w(()=>{Re();sr();CM=Symbol.for("drizzle:PgInlineForeignKeys"),PM=Symbol.for("drizzle:EnableRLS");XT=class XT extends me{static[F]="PgTable";static Symbol=Object.assign({},me.Symbol,{InlineForeignKeys:CM,EnableRLS:PM});[CM]=[];[PM]=!1;[me.Symbol.ExtraConfigBuilder]=void 0;[me.Symbol.ExtraConfigColumns]={}}});var e$,NM;var DM=w(()=>{Re();zM();e$=class e${static[F]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new NM(e,this.columns,this.name)}};NM=class NM{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[F]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[XT.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Tr(e,t){if(kM(t)&&!VT(e)&&!oe(e,Br)&&!oe(e,Hi)&&!oe(e,He)&&!oe(e,me)&&!oe(e,tn))return new Br(e,t);return e}function tt(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new xe(t);return new xe([new zt("("),C.join(t,new zt(" and ")),new zt(")")])}function nn(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new xe(t);return new xe([new zt("("),C.join(t,new zt(" or ")),new zt(")")])}function BM(e){return C`not ${e}`}function Wi(e,t){if(Array.isArray(t)){if(t.length===0)return C`false`;return C`${e} in ${t.map((r)=>Tr(r,e))}`}return C`${e} in ${Tr(t,e)}`}function _y(e,t){if(Array.isArray(t)){if(t.length===0)return C`true`;return C`${e} not in ${t.map((r)=>Tr(r,e))}`}return C`${e} not in ${Tr(t,e)}`}function jr(e){return C`${e} is null`}function UM(e){return C`${e} is not null`}function Ey(e){return C`exists ${e}`}function Gi(e){return C`not exists ${e}`}function qM(e,t,r){return C`${e} between ${Tr(t,e)} and ${Tr(r,e)}`}function MM(e,t,r){return C`${e} not between ${Tr(t,e)} and ${Tr(r,e)}`}function FM(e,t){return C`${e} like ${t}`}function JM(e,t){return C`${e} not like ${t}`}function KM(e,t){return C`${e} ilike ${t}`}function HM(e,t){return C`${e} not ilike ${t}`}var je=(e,t)=>C`${e} = ${Tr(t,e)}`,LM=(e,t)=>C`${e} <> ${Tr(t,e)}`,wn=(e,t)=>C`${e} > ${Tr(t,e)}`,jM=(e,t)=>C`${e} >= ${Tr(t,e)}`,ZM=(e,t)=>C`${e} < ${Tr(t,e)}`,Vi=(e,t)=>C`${e} <= ${Tr(t,e)}`;var VM=w(()=>{Sn();Re();sr();Yt()});function Lo(e){return C`${e} asc`}function ia(e){return C`${e} desc`}var WM=w(()=>{Yt()});var t$=w(()=>{VM();WM()});function QM(){return{and:tt,between:qM,eq:je,exists:Ey,gt:wn,gte:jM,ilike:KM,inArray:Wi,isNull:jr,isNotNull:UM,like:FM,lt:ZM,lte:Vi,ne:LM,not:BM,notBetween:MM,notExists:Gi,notLike:JM,notIlike:HM,notInArray:_y,or:nn,sql:C}}function YM(){return{sql:C,asc:Lo,desc:ia}}function XM(e,t){if(Object.keys(e).length===1&&"default"in e&&!oe(e.default,me))e=e.default;let r={},o={},n={};for(let[i,s]of Object.entries(e))if(oe(s,me)){let a=oa(s),c=o[a];r[a]=i,n[i]={tsName:i,dbName:s[me.Symbol.Name],schema:s[me.Symbol.Schema],columns:s[me.Symbol.Columns],relations:c?.relations??{},primaryKey:c?.primaryKey??[]};for(let d of Object.values(s[me.Symbol.Columns]))if(d.primary)n[i].primaryKey.push(d);let u=s[me.Symbol.ExtraConfigBuilder]?.(s[me.Symbol.ExtraConfigColumns]);if(u){for(let d of Object.values(u))if(oe(d,e$))n[i].primaryKey.push(...d.columns)}}else if(oe(s,GM)){let a=oa(s.table),c=r[a],u=s.config(t(s.table)),d;for(let[f,m]of Object.entries(u))if(c){let h=n[c];if(h.relations[f]=m,d)h.primaryKey.push(...d)}else{if(!(a in o))o[a]={relations:{},primaryKey:d};o[a].relations[f]=m}}return{tables:n,tableNamesMap:r}}function Mfe(e){return function(r,o){return new Qi(e,r,o,o?.fields.reduce((n,i)=>n&&i.notNull,!0)??!1)}}function Ffe(e){return function(r,o){return new bf(e,r,o)}}function eF(e,t,r){if(oe(r,Qi)&&r.config)return{fields:r.config.fields,references:r.config.references};let o=t[oa(r.referencedTable)];if(!o)throw Error(`Table "${r.referencedTable[me.Symbol.Name]}" not found in schema`);let n=e[o];if(!n)throw Error(`Table "${o}" not found in schema`);let i=r.sourceTable,s=t[oa(i)];if(!s)throw Error(`Table "${i[me.Symbol.Name]}" not found in schema`);let a=[];for(let c of Object.values(n.relations))if(r.relationName&&r!==c&&c.relationName===r.relationName||!r.relationName&&c.referencedTable===r.sourceTable)a.push(c);if(a.length>1)throw r.relationName?Error(`There are multiple relations with name "${r.relationName}" in table "${o}"`):Error(`There are multiple relations between "${o}" and "${r.sourceTable[me.Symbol.Name]}". Please specify relation name`);if(a[0]&&oe(a[0],Qi)&&a[0].config)return{fields:a[0].config.references,references:a[0].config.fields};throw Error(`There is not enough information to infer relation "${s}.${r.fieldName}"`)}function tF(e){return{one:Mfe(e),many:Ffe(e)}}function Iy(e,t,r,o,n=(i)=>i){let i={};for(let[s,a]of o.entries())if(a.isJson){let c=t.relations[a.tsKey],u=r[s],d=typeof u==="string"?JSON.parse(u):u;i[a.tsKey]=oe(c,Qi)?d&&Iy(e,e[a.relationTableTsKey],d,a.selection,n):d.map((f)=>Iy(e,e[a.relationTableTsKey],f,a.selection,n))}else{let c=n(r[s]),u=a.field,d;if(oe(u,He))d=u;else if(oe(u,xe))d=u.decoder;else d=u.sql.decoder;i[a.tsKey]=c===null?null:d.mapFromDriverValue(c)}return i}var r$,GM,Qi,bf;var Sf=w(()=>{sr();Sn();Re();DM();t$();Yt();r$=class r${constructor(e,t,r){this.sourceTable=e,this.referencedTable=t,this.relationName=r,this.referencedTableName=t[me.Symbol.Name]}static[F]="Relation";referencedTableName;fieldName};GM=class GM{constructor(e,t){this.table=e,this.config=t}static[F]="Relations"};Qi=class Qi extends r${constructor(e,t,r,o){super(e,t,r?.relationName);this.config=r,this.isNullable=o}static[F]="One";withFieldName(e){let t=new Qi(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}};bf=class bf extends r${constructor(e,t,r){super(e,t,r?.relationName);this.config=r}static[F]="Many";withFieldName(e){let t=new bf(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}});function vf(e,t){return new Proxy(e,new sa(t,!1))}function Xn(e,t){return new Proxy(e,new Sl(new Proxy(e.table,new sa(t,!1))))}function n$(e,t){return new xe.Aliased(wf(e.sql,t),e.fieldAlias)}function wf(e,t){return C.join(e.queryChunks.map((r)=>{if(oe(r,He))return Xn(r,t);if(oe(r,xe))return wf(r,t);if(oe(r,xe.Aliased))return n$(r,t);return r}))}var Sl,sa,Jfe;var xf=w(()=>{Sn();Re();Yt();sr();Do();Sl=class Sl{constructor(e){this.table=e}static[F]="ColumnAliasProxyHandler";get(e,t){if(t==="table")return this.table;return e[t]}};sa=class sa{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[F]="TableAliasProxyHandler";get(e,t){if(t===me.Symbol.IsAlias)return!0;if(t===me.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===me.Symbol.OriginalName)return this.alias;if(t===pt)return{...e[pt],name:this.alias,isAlias:!0};if(t===me.Symbol.Columns){let o=e[me.Symbol.Columns];if(!o)return o;let n={};return Object.keys(o).map((i)=>{n[i]=new Proxy(o[i],new Sl(new Proxy(e,this)))}),n}let r=e[t];if(oe(r,He))return new Proxy(r,new Sl(new Proxy(e,this)));return r}};Jfe=class Jfe{constructor(e){this.alias=e}static[F]="RelationTableAliasProxyHandler";get(e,t){if(t==="sourceTable")return vf(e.sourceTable,this.alias);return e[t]}}});var at;var aa=w(()=>{xf();Sn();Re();Yt();vn();Do();at=class at{static[F]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if(t==="_")return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===pt)return{...e[pt],selectedFields:new Proxy(e[pt].selectedFields,this)};if(typeof t==="symbol")return e[t];let o=(oe(e,ft)?e._.selectedFields:oe(e,tn)?e[pt].selectedFields:e)[t];if(oe(o,xe.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!o.isSelectionField)return o.sql;let n=o.clone();return n.isSelectionField=!0,n}if(oe(o,xe)){if(this.config.sqlBehavior==="sql")return o;throw Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(oe(o,He)){if(this.config.alias)return new Proxy(o,new Sl(new Proxy(o.table,new sa(this.config.alias,this.config.replaceOriginalName??!1))));return o}if(typeof o!=="object"||o===null)return o;return new Proxy(o,new at(this.config))}}});var Sr;var Bo=w(()=>{Re();Sr=class Sr{static[F]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then((t)=>(e?.(),t),(t)=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}});var o$,rF;var i$=w(()=>{Re();yl();o$=class o${static[F]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){if(this.reference=()=>{let{name:r,columns:o,foreignColumns:n}=e();return{name:r,columns:o,foreignTable:n[0].table,foreignColumns:n}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new rF(e,this)}};rF=class rF{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[F]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),o=t.map((s)=>s.name),n=r.map((s)=>s.name),i=[this.table[ir],...o,r[0].table[ir],...n];return e??`${i.join("_")}_fk`}}});function s$(e,t){return`${e[ir]}_${t.join("_")}_unique`}var nF,Kfe,oF;var a$=w(()=>{Re();yl();nF=class nF{constructor(e,t){this.name=t,this.columns=e}static[F]="SQLiteUniqueConstraintBuilder";columns;build(e){return new oF(e,this.columns,this.name)}};Kfe=class Kfe{static[F]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new nF(e,this.name)}};oF=class oF{constructor(e,t,r){this.table=e,this.columns=t,this.name=r??s$(this.table,this.columns.map((o)=>o.name))}static[F]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}});var jt,yt;var Yi=w(()=>{hy();Sn();Re();i$();a$();jt=class jt extends df{static[F]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:r,actions:o})=>((n,i)=>{let s=new o$(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(i.onUpdate)s.onUpdate(i.onUpdate);if(i.onDelete)s.onDelete(i.onDelete);return s.build(t)})(r,o))}};yt=class yt extends He{constructor(e,t){if(!t.uniqueName)t.uniqueName=s$(e,[t.name]);super(e,t);this.table=e}static[F]="SQLiteColumn"}});function dF(e,t){let{name:r,config:o}=Yn(e,t);if(o?.mode==="json")return new aF(r);if(o?.mode==="bigint")return new iF(r);return new lF(r)}var iF,sF,aF,cF,lF,uF;var c$=w(()=>{Re();br();Yi();iF=class iF extends jt{static[F]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new sF(e,this.config)}};sF=class sF extends yt{static[F]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString("utf8"))}return BigInt(GT.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}};aF=class aF extends jt{static[F]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new cF(e,this.config)}};cF=class cF extends yt{static[F]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString("utf8"))}return JSON.parse(GT.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}};lF=class lF extends jt{static[F]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new uF(e,this.config)}};uF=class uF extends yt{static[F]="SQLiteBlobBuffer";mapFromDriverValue(e){if(Buffer.isBuffer(e))return e;return Buffer.from(e)}getSQLType(){return"blob"}}});function mF(e){return(t,r)=>{let{name:o,config:n}=Yn(t,r);return new fF(o,n,e)}}var fF,pF;var l$=w(()=>{Re();br();Yi();fF=class fF extends jt{static[F]="SQLiteCustomColumnBuilder";constructor(e,t,r){super(e,"custom","SQLiteCustomColumn");this.config.fieldConfig=t,this.config.customTypeParams=r}build(e){return new pF(e,this.config)}};pF=class pF extends yt{static[F]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t);this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==="function"?this.mapTo(e):e}}});function ar(e,t){let{name:r,config:o}=Yn(e,t);if(o?.mode==="timestamp"||o?.mode==="timestamp_ms")return new yF(r,o.mode);if(o?.mode==="boolean")return new SF(r,o.mode);return new hF(r)}var ky,Ay,hF,gF,yF,bF,SF,vF;var u$=w(()=>{Re();Yt();br();Yi();ky=class ky extends jt{static[F]="SQLiteBaseIntegerBuilder";constructor(e,t,r){super(e,t,r);this.config.autoIncrement=!1}primaryKey(e){if(e?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}};Ay=class Ay extends yt{static[F]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}};hF=class hF extends ky{static[F]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new gF(e,this.config)}};gF=class gF extends Ay{static[F]="SQLiteInteger"};yF=class yF extends ky{static[F]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp");this.config.mode=t}defaultNow(){return this.default(C`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new bF(e,this.config)}};bF=class bF extends Ay{static[F]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){if(this.config.mode==="timestamp")return new Date(e*1000);return new Date(e)}mapToDriverValue(e){let t=e.getTime();if(this.config.mode==="timestamp")return Math.floor(t/1000);return t}};SF=class SF extends ky{static[F]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean");this.config.mode=t}build(e){return new vF(e,this.config)}};vF=class vF extends Ay{static[F]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}}});function AF(e,t){let{name:r,config:o}=Yn(e,t),n=o?.mode;return n==="number"?new _F(r):n==="bigint"?new IF(r):new wF(r)}var wF,xF,_F,EF,IF,kF;var d$=w(()=>{Re();br();Yi();wF=class wF extends jt{static[F]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new xF(e,this.config)}};xF=class xF extends yt{static[F]="SQLiteNumeric";mapFromDriverValue(e){if(typeof e==="string")return e;return String(e)}getSQLType(){return"numeric"}};_F=class _F extends jt{static[F]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new EF(e,this.config)}};EF=class EF extends yt{static[F]="SQLiteNumericNumber";mapFromDriverValue(e){if(typeof e==="number")return e;return Number(e)}mapToDriverValue=String;getSQLType(){return"numeric"}};IF=class IF extends jt{static[F]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new kF(e,this.config)}};kF=class kF extends yt{static[F]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}});function RF(e){return new TF(e??"")}var TF,$F;var f$=w(()=>{Re();Yi();TF=class TF extends jt{static[F]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new $F(e,this.config)}};$F=class $F extends yt{static[F]="SQLiteReal";getSQLType(){return"real"}}});function mt(e,t={}){let{name:r,config:o}=Yn(e,t);if(o.mode==="json")return new PF(r);return new OF(r,o)}var OF,CF,PF,zF;var p$=w(()=>{Re();br();Yi();OF=class OF extends jt{static[F]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText");this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new CF(e,this.config)}};CF=class CF extends yt{static[F]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}};PF=class PF extends jt{static[F]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new zF(e,this.config)}};zF=class zF extends yt{static[F]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}});function NF(){return{blob:dF,customType:mF,integer:ar,numeric:AF,real:RF,text:mt}}var DF=w(()=>{c$();l$();u$();d$();f$();p$()});function Hfe(e,t,r,o,n=e){let i=new At(e,o,n),s=typeof t==="function"?t(NF()):t,a=Object.fromEntries(Object.entries(s).map(([u,d])=>{let f=d;f.setName(u);let m=f.build(i);return i[m$].push(...f.buildForeignKeys(m,i)),[u,m]})),c=Object.assign(i,a);if(c[me.Symbol.Columns]=a,c[me.Symbol.ExtraConfigColumns]=a,r)c[At.Symbol.ExtraConfigBuilder]=r;return c}var m$,At,_f=(e,t,r)=>Hfe(e,t,r);var jo=w(()=>{Re();sr();DF();m$=Symbol.for("drizzle:SQLiteInlineForeignKeys");At=class At extends me{static[F]="SQLiteTable";static Symbol=Object.assign({},me.Symbol,{InlineForeignKeys:m$});[me.Symbol.Columns];[m$]=[];[me.Symbol.ExtraConfigBuilder]=void 0}});var Vfe,LF;var BF=w(()=>{Re();Vfe=class Vfe{constructor(e,t){this.name=e,this.value=t}static[F]="SQLiteCheckBuilder";brand;build(e){return new LF(e,this)}};LF=class LF{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}static[F]="SQLiteCheck";name;value}});function Zo(e){return new jF(e,!1)}var jF,ZF,UF;var qF=w(()=>{Re();jF=class jF{constructor(e,t){this.name=e,this.unique=t}static[F]="SQLiteIndexBuilderOn";on(...e){return new ZF(this.name,e,this.unique)}};ZF=class ZF{static[F]="SQLiteIndexBuilder";config;constructor(e,t,r){this.config={name:e,columns:t,unique:r,where:void 0}}where(e){return this.config.where=e,this}build(e){return new UF(this.config,e)}};UF=class UF{static[F]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}});var Wfe,MF;var FF=w(()=>{Re();jo();Wfe=class Wfe{static[F]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new MF(e,this.columns,this.name)}};MF=class MF{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[F]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[At.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function xn(e){if(oe(e,At))return[`${e[me.Symbol.BaseName]}`];if(oe(e,ft))return e._.usedTables??[];if(oe(e,xe))return e.usedTables??[];return[]}var vl=w(()=>{Re();Yt();vn();sr();jo()});var Ty;var JF=w(()=>{Re();Bo();aa();jo();sr();br();vl();Ty=class Ty extends Sr{constructor(e,t,r,o){super();this.table=e,this.session=t,this.dialect=r,this.config={table:e,withList:o}}static[F]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.table[me.Symbol.Columns],new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];this.config.orderBy=r}else{let t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.table[At.Symbol.Columns]){return this.config.returning=rn(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"delete",tables:xn(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}});function Gfe(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((r)=>r.toLowerCase()).join("_")}function Qfe(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((r,o,n)=>{let i=n===0?o.toLowerCase():`${o[0].toUpperCase()}${o.slice(1)}`;return r+i},"")}function Yfe(e){return e}var h$;var KF=w(()=>{Re();sr();h$=class h${static[F]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?Gfe:e==="camelCase"?Qfe:Yfe}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[me.Symbol.Schema]??"public",r=e.table[me.Symbol.OriginalName],o=`${t}.${r}.${e.name}`;if(!this.cache[o])this.cacheTable(e.table);return this.cache[o]}cacheTable(e){let t=e[me.Symbol.Schema]??"public",r=e[me.Symbol.OriginalName],o=`${t}.${r}`;if(!this.cachedTables[o]){for(let n of Object.values(e[me.Symbol.Columns])){let i=`${o}.${n.name}`;this.cache[i]=this.convert(n.name)}this.cachedTables[o]=!0}}clearCache(){this.cache={},this.cachedTables={}}}});var wl,Uo,g$;var $y=w(()=>{Re();wl=class wl extends Error{static[F]="DrizzleError";constructor({message:e,cause:t}){super(e);this.name="DrizzleError",this.cause=t}};Uo=class Uo extends Error{constructor(e,t,r){super(`Failed query: ${e}
386
386
  params: ${t}`);if(this.query=e,this.params=t,this.cause=r,Error.captureStackTrace(this,Uo),r)this.cause=r}};g$=class g$ extends wl{static[F]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}});var HF=()=>{};var VF=()=>{};var WF=w(()=>{HF();VF()});var y$=w(()=>{t$();WF();Yt()});var b$=w(()=>{c$();Yi();l$();u$();d$();f$();p$()});var qo;var Ef=w(()=>{Re();Yt();qo=class qo extends tn{static[F]="SQLiteViewBase"}});var xl,S$,v$;var Ry=w(()=>{xf();KF();Sn();Re();$y();Sf();y$();Yt();b$();jo();vn();sr();br();Do();Ef();xl=class xl{static[F]="SQLiteDialect";casing;constructor(e){this.casing=new h$(e?.casing)}escapeName(e){return`"${e.replace(/"/g,'""')}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[C`with `];for(let[r,o]of e.entries())if(t.push(C`${C.identifier(o._.alias)} as (${o._.sql})`),r<e.length-1)t.push(C`, `);return t.push(C` `),C.join(t)}buildDeleteQuery({table:e,where:t,returning:r,withList:o,limit:n,orderBy:i}){let s=this.buildWithCTE(o),a=r?C` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0,c=t?C` where ${t}`:void 0,u=this.buildOrderBy(i),d=this.buildLimit(n);return C`${s}delete from ${e}${c}${a}${u}${d}`}buildUpdateSet(e,t){let r=e[me.Symbol.Columns],o=Object.keys(r).filter((i)=>t[i]!==void 0||r[i]?.onUpdateFn!==void 0),n=o.length;return C.join(o.flatMap((i,s)=>{let a=r[i],c=a.onUpdateFn?.(),u=t[i]??(oe(c,xe)?c:C.param(c,a)),d=C`${C.identifier(this.casing.getColumnCasing(a))} = ${u}`;if(s<n-1)return[d,C.raw(", ")];return[d]}))}buildUpdateQuery({table:e,set:t,where:r,returning:o,withList:n,joins:i,from:s,limit:a,orderBy:c}){let u=this.buildWithCTE(n),d=this.buildUpdateSet(e,t),f=s&&C.join([C.raw(" from "),this.buildFromTable(s)]),m=this.buildJoins(i),h=o?C` returning ${this.buildSelection(o,{isSingleTable:!0})}`:void 0,b=r?C` where ${r}`:void 0,y=this.buildOrderBy(c),S=this.buildLimit(a);return C`${u}update ${e} set ${d}${f}${m}${b}${h}${y}${S}`}buildSelection(e,{isSingleTable:t=!1}={}){let r=e.length,o=e.flatMap(({field:n},i)=>{let s=[];if(oe(n,xe.Aliased)&&n.isSelectionField)s.push(C.identifier(n.fieldAlias));else if(oe(n,xe.Aliased)||oe(n,xe)){let a=oe(n,xe.Aliased)?n.sql:n;if(t)s.push(new xe(a.queryChunks.map((c)=>{if(oe(c,He))return C.identifier(this.casing.getColumnCasing(c));return c})));else s.push(a);if(oe(n,xe.Aliased))s.push(C` as ${C.identifier(n.fieldAlias)}`)}else if(oe(n,He)){let a=n.table[me.Symbol.Name];if(n.columnType==="SQLiteNumericBigInt")if(t)s.push(C`cast(${C.identifier(this.casing.getColumnCasing(n))} as text)`);else s.push(C`cast(${C.identifier(a)}.${C.identifier(this.casing.getColumnCasing(n))} as text)`);else if(t)s.push(C.identifier(this.casing.getColumnCasing(n)));else s.push(C`${C.identifier(a)}.${C.identifier(this.casing.getColumnCasing(n))}`)}else if(oe(n,ft)){let a=Object.entries(n._.selectedFields);if(a.length===1){let c=a[0][1],u=oe(c,xe)?c.decoder:oe(c,He)?{mapFromDriverValue:(d)=>c.mapFromDriverValue(d)}:c.sql.decoder;if(u)n._.sql.decoder=u}s.push(n)}if(i<r-1)s.push(C`, `);return s});return C.join(o)}buildJoins(e){if(!e||e.length===0)return;let t=[];if(e)for(let[r,o]of e.entries()){if(r===0)t.push(C` `);let n=o.table,i=o.on?C` on ${o.on}`:void 0;if(oe(n,At)){let s=n[At.Symbol.Name],a=n[At.Symbol.Schema],c=n[At.Symbol.OriginalName],u=s===c?void 0:o.alias;t.push(C`${C.raw(o.joinType)} join ${a?C`${C.identifier(a)}.`:void 0}${C.identifier(c)}${u&&C` ${C.identifier(u)}`}${i}`)}else t.push(C`${C.raw(o.joinType)} join ${n}${i}`);if(r<e.length-1)t.push(C` `)}return C.join(t)}buildLimit(e){return typeof e==="object"||typeof e==="number"&&e>=0?C` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e){for(let[r,o]of e.entries())if(t.push(o),r<e.length-1)t.push(C`, `)}return t.length>0?C` order by ${C.join(t)}`:void 0}buildFromTable(e){if(oe(e,me)&&e[me.Symbol.IsAlias])return C`${C`${C.identifier(e[me.Symbol.Schema]??"")}.`.if(e[me.Symbol.Schema])}${C.identifier(e[me.Symbol.OriginalName])} ${C.identifier(e[me.Symbol.Name])}`;return e}buildSelectQuery({withList:e,fields:t,fieldsFlat:r,where:o,having:n,table:i,joins:s,orderBy:a,groupBy:c,limit:u,offset:d,distinct:f,setOperators:m}){let h=r??rn(t);for(let R of h)if(oe(R.field,He)&&Ki(R.field.table)!==(oe(i,ft)?i._.alias:oe(i,qo)?i[pt].name:oe(i,xe)?void 0:Ki(i))&&!((B)=>s?.some(({alias:I})=>I===(B[me.Symbol.IsAlias]?Ki(B):B[me.Symbol.BaseName])))(R.field.table)){let B=Ki(R.field.table);throw Error(`Your "${R.path.join("->")}" field references a column "${B}"."${R.field.name}", but the table "${B}" is not part of the query! Did you forget to join it?`)}let b=!s||s.length===0,y=this.buildWithCTE(e),S=f?C` distinct`:void 0,x=this.buildSelection(h,{isSingleTable:b}),_=this.buildFromTable(i),A=this.buildJoins(s),O=o?C` where ${o}`:void 0,L=n?C` having ${n}`:void 0,z=[];if(c){for(let[R,B]of c.entries())if(z.push(B),R<c.length-1)z.push(C`, `)}let K=z.length>0?C` group by ${C.join(z)}`:void 0,P=this.buildOrderBy(a),W=this.buildLimit(u),ee=d?C` offset ${d}`:void 0,j=C`${y}select${S} ${x} from ${_}${A}${O}${K}${L}${P}${W}${ee}`;if(m.length>0)return this.buildSetOperations(j,m);return j}buildSetOperations(e,t){let[r,...o]=t;if(!r)throw Error("Cannot pass undefined values to any set operator");if(o.length===0)return this.buildSetOperationQuery({leftSelect:e,setOperator:r});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:r}),o)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:r,rightSelect:o,limit:n,orderBy:i,offset:s}}){let a=C`${e.getSQL()} `,c=C`${o.getSQL()}`,u;if(i&&i.length>0){let h=[];for(let b of i)if(oe(b,yt))h.push(C.identifier(b.name));else if(oe(b,xe)){for(let y=0;y<b.queryChunks.length;y++){let S=b.queryChunks[y];if(oe(S,yt))b.queryChunks[y]=C.identifier(this.casing.getColumnCasing(S))}h.push(C`${b}`)}else h.push(C`${b}`);u=C` order by ${C.join(h,C`, `)}`}let d=typeof n==="object"||typeof n==="number"&&n>=0?C` limit ${n}`:void 0,f=C.raw(`${t} ${r?"all ":""}`),m=s?C` offset ${s}`:void 0;return C`${a}${f}${c}${u}${d}${m}`}buildInsertQuery({table:e,values:t,onConflict:r,returning:o,withList:n,select:i}){let s=[],a=e[me.Symbol.Columns],c=Object.entries(a).filter(([b,y])=>!y.shouldDisableInsert()),u=c.map(([,b])=>C.identifier(this.casing.getColumnCasing(b)));if(i){let b=t;if(oe(b,xe))s.push(b);else s.push(b.getSQL())}else{let b=t;s.push(C.raw("values "));for(let[y,S]of b.entries()){let x=[];for(let[_,A]of c){let O=S[_];if(O===void 0||oe(O,Br)&&O.value===void 0){let L;if(A.default!==null&&A.default!==void 0)L=oe(A.default,xe)?A.default:C.param(A.default,A);else if(A.defaultFn!==void 0){let z=A.defaultFn();L=oe(z,xe)?z:C.param(z,A)}else if(!A.default&&A.onUpdateFn!==void 0){let z=A.onUpdateFn();L=oe(z,xe)?z:C.param(z,A)}else L=C`null`;x.push(L)}else x.push(O)}if(s.push(x),y<b.length-1)s.push(C`, `)}}let d=this.buildWithCTE(n),f=C.join(s),m=o?C` returning ${this.buildSelection(o,{isSingleTable:!0})}`:void 0,h=r?.length?C.join(r):void 0;return C`${d}insert into ${e} ${u} ${f}${h}${m}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:r,table:o,tableConfig:n,queryConfig:i,tableAlias:s,nestedQueryRelation:a,joinOn:c}){let u=[],d,f,m=[],h,b=[];if(i===!0)u=Object.entries(n.columns).map(([x,_])=>({dbKey:_.name,tsKey:x,field:Xn(_,s),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let S=Object.fromEntries(Object.entries(n.columns).map(([z,K])=>[z,Xn(K,s)]));if(i.where){let z=typeof i.where==="function"?i.where(S,QM()):i.where;h=z&&wf(z,s)}let x=[],_=[];if(i.columns){let z=!1;for(let[K,P]of Object.entries(i.columns)){if(P===void 0)continue;if(K in n.columns){if(!z&&P===!0)z=!0;_.push(K)}}if(_.length>0)_=z?_.filter((K)=>i.columns?.[K]===!0):Object.keys(n.columns).filter((K)=>!_.includes(K))}else _=Object.keys(n.columns);for(let z of _){let K=n.columns[z];x.push({tsKey:z,value:K})}let A=[];if(i.with)A=Object.entries(i.with).filter((z)=>!!z[1]).map(([z,K])=>({tsKey:z,queryConfig:K,relation:n.relations[z]}));let O;if(i.extras){O=typeof i.extras==="function"?i.extras(S,{sql:C}):i.extras;for(let[z,K]of Object.entries(O))x.push({tsKey:z,value:n$(K,s)})}for(let{tsKey:z,value:K}of x)u.push({dbKey:oe(K,xe.Aliased)?K.fieldAlias:n.columns[z].name,tsKey:z,field:oe(K,He)?Xn(K,s):K,relationTableTsKey:void 0,isJson:!1,selection:[]});let L=typeof i.orderBy==="function"?i.orderBy(S,YM()):i.orderBy??[];if(!Array.isArray(L))L=[L];m=L.map((z)=>{if(oe(z,He))return Xn(z,s);return wf(z,s)}),d=i.limit,f=i.offset;for(let{tsKey:z,queryConfig:K,relation:P}of A){let W=eF(t,r,P),ee=oa(P.referencedTable),j=r[ee],R=`${s}_${z}`,B=tt(...W.fields.map((k,M)=>je(Xn(W.references[M],R),Xn(k,s)))),I=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:r,table:e[j],tableConfig:t[j],queryConfig:oe(P,Qi)?K===!0?{limit:1}:{...K,limit:1}:K,tableAlias:R,joinOn:B,nestedQueryRelation:P}),T=C`(${I.sql})`.as(z);u.push({dbKey:z,tsKey:z,field:T,relationTableTsKey:j,isJson:!0,selection:I.selection})}}if(u.length===0)throw new wl({message:`No fields selected for table "${n.tsName}" ("${s}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});let y;if(h=tt(c,h),a){let S=C`json_array(${C.join(u.map(({field:A})=>oe(A,yt)?C.identifier(this.casing.getColumnCasing(A)):oe(A,xe.Aliased)?A.sql:A),C`, `)})`;if(oe(a,bf))S=C`coalesce(json_group_array(${S}), json_array())`;let x=[{dbKey:"data",tsKey:"data",field:S.as("data"),isJson:!0,relationTableTsKey:n.tsName,selection:u}];if(d!==void 0||f!==void 0||m.length>0)y=this.buildSelectQuery({table:vf(o,s),fields:{},fieldsFlat:[{path:[],field:C.raw("*")}],where:h,limit:d,offset:f,orderBy:m,setOperators:[]}),h=void 0,d=void 0,f=void 0,m=void 0;else y=vf(o,s);y=this.buildSelectQuery({table:oe(y,At)?y:new ft(y,{},s),fields:{},fieldsFlat:x.map(({field:A})=>({path:[],field:oe(A,He)?Xn(A,s):A})),joins:b,where:h,limit:d,offset:f,orderBy:m,setOperators:[]})}else y=this.buildSelectQuery({table:vf(o,s),fields:{},fieldsFlat:u.map(({field:S})=>({path:[],field:oe(S,He)?Xn(S,s):S})),joins:b,where:h,limit:d,offset:f,orderBy:m,setOperators:[]});return{tableTsKey:n.tsName,sql:y,selection:u}}};S$=class S$ extends xl{static[F]="SQLiteSyncDialect";migrate(e,t,r){let o=r===void 0?"__drizzle_migrations":typeof r==="string"?"__drizzle_migrations":r.migrationsTable??"__drizzle_migrations",n=C`
387
387
  CREATE TABLE IF NOT EXISTS ${C.identifier(o)} (
388
388
  id SERIAL PRIMARY KEY,
@@ -395,21 +395,21 @@ params: ${t}`);if(this.query=e,this.params=t,this.cause=r,Error.captureStackTrac
395
395
  hash text NOT NULL,
396
396
  created_at numeric
397
397
  )
398
- `;await t.run(n);let s=(await t.values(C`SELECT id, hash, created_at FROM ${C.identifier(o)} ORDER BY created_at DESC LIMIT 1`))[0]??void 0;await t.transaction(async(a)=>{for(let c of e)if(!s||Number(s[2])<c.folderMillis){for(let u of c.sql)await a.run(C.raw(u));await a.run(C`INSERT INTO ${C.identifier(o)} ("hash", "created_at") VALUES(${c.hash}, ${c.folderMillis})`)}})}}});var w$;var GF=w(()=>{Re();w$=class w${static[F]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}});function Oy(e,t){return(r,o,...n)=>{let i=[o,...n].map((s)=>({type:e,isAll:t,rightSelect:s}));for(let s of i)if(!gf(r.getSelectedFields(),s.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return r.addSetOperators(i)}}var _n,QF,x$,Yfe=()=>({union:Xfe,unionAll:epe,intersect:tpe,except:rpe}),Xfe,epe,tpe,rpe;var _$=w(()=>{Re();GF();Bo();aa();Yt();vn();sr();br();Do();vl();Ef();_n=class _n{static[F]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let t=!!this.fields,r;if(this.fields)r=this.fields;else if(oe(e,ft))r=Object.fromEntries(Object.keys(e._.selectedFields).map((o)=>[o,e[o]]));else if(oe(e,qo))r=e[pt].selectedFields;else if(oe(e,xe))r={};else r=wy(e);return new x$({table:e,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}};QF=class QF extends w${static[F]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:r,session:o,dialect:n,withList:i,distinct:s}){super();this.config={withList:i,table:e,fields:{...t},distinct:s,setOperators:[]},this.isPartialSelect=r,this.session=o,this.dialect=n,this._={selectedFields:t,config:this.config},this.tableName=yf(e),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let a of xn(e))this.usedTables.add(a)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,r)=>{let o=this.tableName,n=yf(t);for(let i of xn(t))this.usedTables.add(i);if(typeof n==="string"&&this.config.joins?.some((i)=>i.alias===n))throw Error(`Alias "${n}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof o==="string")this.config.fields={[o]:this.config.fields};if(typeof n==="string"&&!oe(t,xe)){let i=oe(t,ft)?t._.selectedFields:oe(t,tn)?t[pt].selectedFields:t[me.Symbol.Columns];this.config.fields[n]=i}}if(typeof r==="function")r=r(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:r,table:t,joinType:e,alias:n}),typeof n==="string")switch(e){case"left":{this.joinsNotNullableMap[n]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([i])=>[i,!1])),this.joinsNotNullableMap[n]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[n]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([i])=>[i,!1])),this.joinsNotNullableMap[n]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(e,t){return(r)=>{let o=typeof r==="function"?r(Yfe()):r;if(!gf(this.getSelectedFields(),o.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:o}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){if(typeof e==="function")e=e(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=e,this}having(e){if(typeof e==="function")e=e(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=e,this}groupBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.fields,new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.fields,new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=r;else this.config.orderBy=r}else{let t=e;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=t;else this.config.orderBy=t}return this}limit(e){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=e;else this.config.limit=e;return this}offset(e){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=e;else this.config.offset=e;return this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){let t=[];if(t.push(...xn(this.config.table)),this.config.joins)for(let r of this.config.joins)t.push(...xn(r.table));return new Proxy(new ft(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new at({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}};x$=class x$ extends QF{static[F]="SQLiteSelect";_prepare(e=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let t=rn(this.config.fields),r=this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),t,"all",!0,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return r.joinsNotNullableMap=this.joinsNotNullableMap,r}$withCache(e){return this.cacheConfig=e===void 0?{config:{},enable:!0,autoInvalidate:!0}:e===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...e},this}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.all()}};$M(x$,[Sr]);Xfe=Oy("union",!1),epe=Oy("union",!0),tpe=Oy("intersect",!1),rpe=Oy("except",!1)});var ca;var Cy=w(()=>{Re();aa();Ry();vn();_$();ca=class ca{static[F]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=oe(e,xl)?e:void 0,this.dialectConfig=oe(e,xl)?void 0:e}$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(r);return new Proxy(new pf(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...e){let t=this;function r(n){return new _n({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function o(n){return new _n({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}return{select:r,selectDistinct:o}}select(e){return new _n({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new _n({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){if(!this.dialect)this.dialect=new S$(this.dialectConfig);return this.dialect}}});var Py,E$;var YF=w(()=>{Re();Bo();Yt();jo();sr();br();vl();Cy();Py=class Py{constructor(e,t,r,o){this.table=e,this.session=t,this.dialect=r,this.withList=o}static[F]="SQLiteInsertBuilder";values(e){if(e=Array.isArray(e)?e:[e],e.length===0)throw Error("values() must be called with at least one value");let t=e.map((r)=>{let o={},n=this.table[me.Symbol.Columns];for(let i of Object.keys(r)){let s=r[i];o[i]=oe(s,xe)?s:new Br(s,n[i])}return o});return new E$(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e==="function"?e(new ca):e;if(!oe(t,xe)&&!gf(this.table[by],t._.selectedFields))throw Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new E$(this.table,t,this.session,this.dialect,this.withList,!0)}};E$=class E$ extends Sr{constructor(e,t,r,o,n,i){super();this.session=r,this.dialect=o,this.config={table:e,values:t,withList:n,select:i}}static[F]="SQLiteInsert";config;returning(e=this.config.table[At.Symbol.Columns]){return this.config.returning=rn(e),this}onConflictDoNothing(e={}){if(!this.config.onConflict)this.config.onConflict=[];if(e.target===void 0)this.config.onConflict.push(C` on conflict do nothing`);else{let t=Array.isArray(e.target)?C`${e.target}`:C`${[e.target]}`,r=e.where?C` where ${e.where}`:C``;this.config.onConflict.push(C` on conflict ${t} do nothing${r}`)}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');if(!this.config.onConflict)this.config.onConflict=[];let t=e.where?C` where ${e.where}`:void 0,r=e.targetWhere?C` where ${e.targetWhere}`:void 0,o=e.setWhere?C` where ${e.setWhere}`:void 0,n=Array.isArray(e.target)?C`${e.target}`:C`${[e.target]}`,i=this.dialect.buildUpdateSet(this.config.table,vy(this.config.table,e.set));return this.config.onConflict.push(C` on conflict ${n}${r} do update set ${i}${t}${o}`),this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:xn(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}});var zy,XF;var e3=w(()=>{Re();Bo();aa();jo();vn();sr();br();Do();vl();Ef();zy=class zy{constructor(e,t,r,o){this.table=e,this.session=t,this.dialect=r,this.withList=o}static[F]="SQLiteUpdateBuilder";set(e){return new XF(this.table,vy(this.table,e),this.session,this.dialect,this.withList)}};XF=class XF extends Sr{constructor(e,t,r,o,n){super();this.session=r,this.dialect=o,this.config={set:t,table:e,withList:n,joins:[]}}static[F]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return(t,r)=>{let o=yf(t);if(typeof o==="string"&&this.config.joins.some((n)=>n.alias===o))throw Error(`Alias "${o}" is already used in this query`);if(typeof r==="function"){let n=this.config.from?oe(t,At)?t[me.Symbol.Columns]:oe(t,ft)?t._.selectedFields:oe(t,qo)?t[pt].selectedFields:void 0:void 0;r=r(new Proxy(this.config.table[me.Symbol.Columns],new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),n&&new Proxy(n,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:r,table:t,joinType:e,alias:o}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.table[me.Symbol.Columns],new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];this.config.orderBy=r}else{let t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[At.Symbol.Columns]){return this.config.returning=rn(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:xn(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}});var I$=w(()=>{JF();YF();Cy();_$();e3()});var If;var t3=w(()=>{Re();Yt();If=class If extends xe{constructor(e){super(If.buildEmbeddedCount(e.source,e.filters).queryChunks);this.params=e,this.session=e.session,this.sql=If.buildCount(e.source,e.filters)}sql;static[F]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return C`(select count(*) from ${e}${C.raw(" where ").if(t)}${t})`}static buildCount(e,t){return C`select count(*) from ${e}${C.raw(" where ").if(t)}${t}`}then(e,t){return Promise.resolve(this.session.count(this.sql)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then((t)=>(e?.(),t),(t)=>{throw e?.(),t})}}});var A$,Ny,k$;var r3=w(()=>{Re();Bo();Sf();A$=class A${constructor(e,t,r,o,n,i,s,a){this.mode=e,this.fullSchema=t,this.schema=r,this.tableNamesMap=o,this.table=n,this.tableConfig=i,this.dialect=s,this.session=a}static[F]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return this.mode==="sync"?new k$(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many"):new Ny(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many")}findFirst(e){return this.mode==="sync"?new k$(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new Ny(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}};Ny=class Ny extends Sr{constructor(e,t,r,o,n,i,s,a,c){super();this.fullSchema=e,this.schema=t,this.tableNamesMap=r,this.table=o,this.tableConfig=n,this.dialect=i,this.session=s,this.config=a,this.mode=c}static[F]="SQLiteAsyncRelationalQuery";mode;getSQL(){return this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(e=!1){let{query:t,builtQuery:r}=this._toSQL();return this.session[e?"prepareOneTimeQuery":"prepareQuery"](r,void 0,this.mode==="first"?"get":"all",!0,(o,n)=>{let i=o.map((s)=>Iy(this.schema,this.tableConfig,s,t.selection,n));if(this.mode==="first")return i[0];return i})}prepare(){return this._prepare(!1)}_toSQL(){let e=this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}executeRaw(){if(this.mode==="first")return this._prepare(!1).get();return this._prepare(!1).all()}async execute(){return this.executeRaw()}};k$=class k$ extends Ny{static[F]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}});var _l;var n3=w(()=>{Re();Bo();_l=class _l extends Sr{constructor(e,t,r,o,n){super();this.execute=e,this.getSQL=t,this.dialect=o,this.mapBatchResult=n,this.config={action:r}}static[F]="SQLiteRaw";config;getQuery(){return{...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}});var kf;var Dy=w(()=>{Re();aa();Yt();I$();vn();t3();r3();n3();kf=class kf{constructor(e,t,r,o){this.resultKind=e,this.dialect=t,this.session=r,this._=o?{schema:o.schema,fullSchema:o.fullSchema,tableNamesMap:o.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};let n=this.query;if(this._.schema)for(let[i,s]of Object.entries(this._.schema))n[i]=new A$(e,o.fullSchema,this._.schema,this._.tableNamesMap,o.fullSchema[i],s,t,r);this.$cache={invalidate:async(i)=>{}}}static[F]="BaseSQLiteDatabase";query;$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(new ca(r.dialect));return new Proxy(new pf(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(e,t){return new If({source:e,filters:t,session:this.session})}with(...e){let t=this;function r(a){return new _n({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e})}function o(a){return new _n({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function n(a){return new zy(a,t.session,t.dialect,e)}function i(a){return new Py(a,t.session,t.dialect,e)}function s(a){return new Ty(a,t.session,t.dialect,e)}return{select:r,selectDistinct:o,update:n,insert:i,delete:s}}select(e){return new _n({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new _n({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new zy(e,this.session,this.dialect)}$cache;insert(e){return new Py(e,this.session,this.dialect)}delete(e){return new Ty(e,this.session,this.dialect)}run(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new _l(async()=>this.session.run(t),()=>t,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session));return this.session.run(t)}all(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new _l(async()=>this.session.all(t),()=>t,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session));return this.session.all(t)}get(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new _l(async()=>this.session.get(t),()=>t,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session));return this.session.get(t)}values(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new _l(async()=>this.session.values(t),()=>t,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session));return this.session.values(t)}transaction(e,t){return this.session.transaction(e,t)}}});async function T$(e,t){let r=`${e}-${JSON.stringify(t)}`,n=new TextEncoder().encode(r),i=await crypto.subtle.digest("SHA-256",n);return[...new Uint8Array(i)].map((c)=>c.toString(16).padStart(2,"0")).join("")}var o3,Af;var $$=w(()=>{Re();o3=class o3{static[F]="Cache"};Af=class Af extends o3{strategy(){return"all"}static[F]="NoopCache";async get(e){return}async put(e,t,r,o){}async onMutate(e){}}});var i3=w(()=>{$$()});function Ly(e,t){return new Proxy(e,new sa(t,!1))}var s3=w(()=>{xf()});var a3,R$,O$,C$;var P$=w(()=>{$$();Re();$y();Bo();Dy();a3=class a3 extends Sr{constructor(e){super();this.resultCb=e}static[F]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}};R$=class R${constructor(e,t,r,o,n,i){if(this.mode=e,this.executeMethod=t,this.query=r,this.cache=o,this.queryMetadata=n,this.cacheConfig=i,o&&o.strategy()==="all"&&i===void 0)this.cacheConfig={enable:!0,autoInvalidate:!0};if(!this.cacheConfig?.enable)this.cacheConfig=void 0}static[F]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,r){if(this.cache===void 0||oe(this.cache,Af)||this.queryMetadata===void 0)try{return await r()}catch(o){throw new Uo(e,t,o)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await r()}catch(o){throw new Uo(e,t,o)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[o]=await Promise.all([r(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return o}catch(o){throw new Uo(e,t,o)}if(!this.cacheConfig)try{return await r()}catch(o){throw new Uo(e,t,o)}if(this.queryMetadata.type==="select"){let o=await this.cache.get(this.cacheConfig.tag??await T$(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(o===void 0){let n;try{n=await r()}catch(i){throw new Uo(e,t,i)}return await this.cache.put(this.cacheConfig.tag??await T$(e,t),n,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),n}return o}try{return await r()}catch(o){throw new Uo(e,t,o)}}getQuery(){return this.query}mapRunResult(e,t){return e}mapAllResult(e,t){throw Error("Not implemented")}mapGetResult(e,t){throw Error("Not implemented")}execute(e){if(this.mode==="async")return this[this.executeMethod](e);return new a3(()=>this[this.executeMethod](e))}mapResult(e,t){switch(this.executeMethod){case"run":return this.mapRunResult(e,t);case"all":return this.mapAllResult(e,t);case"get":return this.mapGetResult(e,t)}}};O$=class O${constructor(e){this.dialect=e}static[F]="SQLiteSession";prepareOneTimeQuery(e,t,r,o,n,i,s){return this.prepareQuery(e,t,r,o,n,i,s)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(r){throw new wl({cause:r,message:`Failed to run the query '${t.sql}'`})}}extractRawRunValueFromBatchResult(e){return e}all(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).all()}extractRawAllValueFromBatchResult(e){throw Error("Not implemented")}get(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).get()}extractRawGetValueFromBatchResult(e){throw Error("Not implemented")}values(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).values()}async count(e){return(await this.values(e))[0][0]}extractRawValuesValueFromBatchResult(e){throw Error("Not implemented")}};C$=class C$ extends kf{constructor(e,t,r,o,n=0){super(e,t,r,o);this.schema=o,this.nestedIndex=n}static[F]="SQLiteTransaction";rollback(){throw new g$}}});var z$,npe,ope,By;var c3=w(()=>{Re();aa();br();Cy();jo();Ef();z$=class z${constructor(e){this.name=e}static[F]="SQLiteViewBuilderCore";config={}};npe=class npe extends z${static[F]="SQLiteViewBuilder";as(e){if(typeof e==="function")e=e(new ca);let t=new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}),r=e.getSelectedFields();return new Proxy(new By({config:{name:this.name,schema:void 0,selectedFields:r,query:e.getSQL().inlineParams()}}),t)}};ope=class ope extends z${static[F]="SQLiteManualViewBuilder";columns;constructor(e,t){super(e);this.columns=wy(_f(e,t))}existing(){return new Proxy(new By({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:void 0}}),new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}as(e){return new Proxy(new By({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:e.inlineParams()}}),new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}};By=class By extends qo{static[F]="SQLiteView";constructor({config:e}){super(e)}}});var jy=w(()=>{s3();BF();b$();Dy();Ry();i$();qF();FF();I$();P$();jo();a$();vl();c3()});function l3(e){return Object.keys(e).reduce((t,r)=>{if(Object.prototype.propertyIsEnumerable.call(e,r))t[r]=e[r];return t},{})}function Zy(e){if(typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer){if(typeof Buffer<"u"){if(!(e instanceof Buffer))return Buffer.from(e);return e}if(typeof TextDecoder<"u")return new TextDecoder().decode(e);throw Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.")}return e}var Uy,N$,u3;var D$=w(()=>{i3();Re();xy();Yt();jy();P$();br();Uy=class Uy extends O${constructor(e,t,r,o,n){super(t);this.client=e,this.schema=r,this.options=o,this.tx=n,this.logger=o.logger??new YT,this.cache=o.cache??new Af}static[F]="LibSQLSession";logger;cache;prepareQuery(e,t,r,o,n,i,s){return new u3(this.client,e,this.logger,this.cache,i,s,t,this.tx,r,o,n)}async batch(e){let t=[],r=[];for(let n of e){let i=n._prepare(),s=i.getQuery();t.push(i),r.push({sql:s.sql,args:s.params})}return(await this.client.batch(r)).map((n,i)=>t[i].mapResult(n,!0))}async migrate(e){let t=[],r=[];for(let n of e){let i=n._prepare(),s=i.getQuery();t.push(i),r.push({sql:s.sql,args:s.params})}return(await this.client.migrate(r)).map((n,i)=>t[i].mapResult(n,!0))}async transaction(e,t){let r=await this.client.transaction(),o=new Uy(this.client,this.dialect,this.schema,this.options,r),n=new N$("async",this.dialect,o,this.schema);try{let i=await e(n);return await r.commit(),i}catch(i){throw await r.rollback(),i}}extractRawAllValueFromBatchResult(e){return e.rows}extractRawGetValueFromBatchResult(e){return e.rows[0]}extractRawValuesValueFromBatchResult(e){return e.rows}};N$=class N$ extends C${static[F]="LibSQLTransaction";async transaction(e){let t=`sp${this.nestedIndex}`,r=new N$("async",this.dialect,this.session,this.schema,this.nestedIndex+1);await this.session.run(C.raw(`savepoint ${t}`));try{let o=await e(r);return await this.session.run(C.raw(`release savepoint ${t}`)),o}catch(o){throw await this.session.run(C.raw(`rollback to savepoint ${t}`)),o}}};u3=class u3 extends R${constructor(e,t,r,o,n,i,s,a,c,u,d){super("async",c,t,o,n,i);this.client=e,this.logger=r,this.fields=s,this.tx=a,this._isResponseInArrayMode=u,this.customResultMapper=d,this.customResultMapper=d,this.fields=s}static[F]="LibSQLPreparedQuery";async run(e){let t=hf(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let r={sql:this.query.sql,args:t};return this.tx?this.tx.execute(r):this.client.execute(r)})}async all(e){let{fields:t,logger:r,query:o,tx:n,client:i,customResultMapper:s}=this;if(!t&&!s){let c=hf(o.params,e??{});return r.logQuery(o.sql,c),await this.queryWithCache(o.sql,c,async()=>{let u={sql:o.sql,args:c};return(n?n.execute(u):i.execute(u)).then(({rows:d})=>this.mapAllResult(d))})}let a=await this.values(e);return this.mapAllResult(a)}mapAllResult(e,t){if(t)e=e.rows;if(!this.fields&&!this.customResultMapper)return e.map((r)=>l3(r));if(this.customResultMapper)return this.customResultMapper(e,Zy);return e.map((r)=>WT(this.fields,Array.prototype.slice.call(r).map((o)=>Zy(o)),this.joinsNotNullableMap))}async get(e){let{fields:t,logger:r,query:o,tx:n,client:i,customResultMapper:s}=this;if(!t&&!s){let c=hf(o.params,e??{});return r.logQuery(o.sql,c),await this.queryWithCache(o.sql,c,async()=>{let u={sql:o.sql,args:c};return(n?n.execute(u):i.execute(u)).then(({rows:d})=>this.mapGetResult(d))})}let a=await this.values(e);return this.mapGetResult(a)}mapGetResult(e,t){if(t)e=e.rows;let r=e[0];if(!this.fields&&!this.customResultMapper)return l3(r);if(!r)return;if(this.customResultMapper)return this.customResultMapper(e,Zy);return WT(this.fields,Array.prototype.slice.call(r).map((o)=>Zy(o)),this.joinsNotNullableMap)}async values(e){let t=hf(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let r={sql:this.query.sql,args:t};return(this.tx?this.tx.execute(r):this.client.execute(r)).then(({rows:o})=>o)})}isResponseInArrayMode(){return this._isResponseInArrayMode}}});function El(e,t={}){let r=new v$({casing:t.casing}),o;if(t.logger===!0)o=new QT;else if(t.logger!==!1)o=t.logger;let n;if(t.schema){let a=XM(t.schema,tF);n={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}let i=new Uy(e,r,n,{logger:o,cache:t.cache},void 0),s=new d3("async",r,i,n);if(s.$client=e,s.$cache=t.cache,s.$cache)s.$cache.invalidate=t.cache?.onMutate;return s}var d3;var f3=w(()=>{Re();xy();Sf();Dy();Ry();D$();d3=class d3 extends kf{static[F]="LibSQLDatabase";async batch(e){return this.session.batch(e)}}});function qy(...e){if(typeof e[0]==="string"){let t=gl({url:e[0]});return El(t,e[1])}if(RM(e[0])){let{connection:t,client:r,...o}=e[0];if(r)return El(r,o);let n=typeof t==="string"?gl({url:t}):gl(t);return El(n,o)}return El(e[0],e[1])}var p3=w(()=>{BT();br();f3();((e)=>{function t(r){return El({},r)}e.mock=t})(qy||(qy={}))});var m3=w(()=>{p3();D$()});function ipe(){return new Promise((e)=>setTimeout(e,0))}function ape(){if(L$)return;L$=!0,setTimeout(()=>{L$=!1,B$=performance.now()},0)}async function Tf(e=spe){if(ape(),performance.now()-B$<e)return;await ipe(),B$=performance.now()}var spe=50,B$,L$=!1;var h3=w(()=>{B$=performance.now()});function g3(e){if(e.authToken!==void 0)return e.authToken;if(e.authTokenEnv===void 0)return;return process.env[e.authTokenEnv]}function dpe(e){return e instanceof Ce&&/^SQLITE_(?:BUSY|LOCKED)$/u.test(e.code)}async function My(e,t){let r=Date.now()+(t.budgetMs??cpe),o=async(n)=>{if(t.isClosed())throw new Ce("The client is closed","CLIENT_CLOSED");try{return await e()}catch(i){if(t.isClosed()||!dpe(i))throw i;await t.afterRefusal?.();let s=Math.min(lpe*2**(n-1),upe),a=s/2+Math.random()*(s/2);if(t.isClosed()||Date.now()+a>=r)throw i;if(await new Promise((c)=>setTimeout(c,a)),t.isClosed()||Date.now()>=r)throw i;return o(n+1)}};return o(1)}function j$(e,t={}){let r=gl({...e,...e.url.startsWith("file:")?{timeout:0}:{}});if(e.url.startsWith("file:")&&e.syncUrl===void 0){let o=r.transaction.bind(r),n=()=>r.closed,i=t.contentionRetryBudgetMs,s=r.execute.bind(r),a=r.batch.bind(r),c=r.migrate.bind(r),u={isClosed:n,budgetMs:i,afterRefusal:async()=>{await Promise.resolve(r.reconnect())}};async function d(f,m){return await Tf(),My(()=>typeof f==="string"?s(f,m):s(f),u)}r.execute=d,r.batch=async(f,m)=>(await Tf(),My(()=>a(f,m),u)),r.migrate=async(f)=>(await Tf(),My(()=>c(f),u)),r.transaction=async(f)=>(await Tf(),My(()=>o(f),u))}return r}function Fy(e){let{url:t,schema:r}=e,o=g3(e),n={contentionRetryBudgetMs:e.contentionRetryBudgetMs},i=o?j$({url:t,authToken:o},n):j$({url:t},n);return{db:qy(i,{schema:r}),client:i,url:t}}async function Jy(e,t){if(!t.startsWith("file:"))return;for(let r of["PRAGMA busy_timeout = 0","PRAGMA journal_mode = WAL"])await e.execute(r)}var cpe=5000,lpe=5,upe=40;var Z$=w(()=>{BT();m3();h3()});var y3=w(()=>{XA();Z$()});var U$=w(()=>{Z$();y3()});var q$=w(()=>{xf();hy();Sn();Re();$y();xy();Bo();Sf();y$();vn();sr();br();Do()});var Y,qe;var M$=w(()=>{jy();q$();Zd();Y=_f("job_queue",{id:mt("id").primaryKey().$defaultFn(()=>Ro()),type:mt("type").notNull(),data:mt("data").notNull(),result:mt("result",{mode:"json"}),progress:mt("progress",{mode:"json"}).$type(),source:mt("source"),metadata:mt("metadata",{mode:"json"}).$type().notNull(),status:mt("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:ar("priority").notNull().default(0),retryCount:ar("retryCount").notNull().default(0),maxRetries:ar("maxRetries").notNull().default(3),lastError:mt("lastError"),lastErrorPublic:mt("lastErrorPublic",{mode:"json"}),createdAt:ar("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:ar("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:ar("startedAt"),completedAt:ar("completedAt"),attemptId:mt("attemptId"),workerSlotId:mt("workerSlotId"),workerSessionId:mt("workerSessionId"),leaseExpiresAt:ar("leaseExpiresAt"),attemptHeartbeatAt:ar("attemptHeartbeatAt"),runtimeUpdatedAt:ar("runtimeUpdatedAt"),brainVersion:mt("brainVersion"),brainVersionSortKey:mt("brainVersionSortKey")},(e)=>({queueReadyIdx:Zo("idx_job_queue_ready").on(e.status,e.priority,e.scheduledFor),jobTypeIdx:Zo("idx_job_queue_type").on(e.type,e.status),runtimeUpdatesIdx:Zo("idx_job_queue_runtime_updates").on(e.runtimeUpdatedAt,e.id),jobSourceIdx:Zo("idx_job_queue_source").on(e.source),rootJobIdx:Zo("idx_job_queue_root_job").on(C`json_extract(${e.metadata}, '$.rootJobId')`,e.createdAt,e.id),deduplicationIdx:Zo("idx_job_queue_deduplication").on(e.type,C`json_extract(${e.metadata}, '$.deduplicationKey')`,e.status)})),qe=_f("job_worker_sessions",{slotId:mt("slotId").primaryKey(),sessionId:mt("sessionId").notNull().unique(),startedAt:ar("startedAt").notNull(),heartbeatAt:ar("heartbeatAt").notNull(),expiresAt:ar("expiresAt").notNull().default(0),brainVersion:mt("brainVersion"),brainVersionSortKey:mt("brainVersionSortKey"),stableSlotId:mt("stableSlotId")},(e)=>({heartbeatIdx:Zo("idx_job_worker_sessions_heartbeat").on(e.heartbeatAt),expiresIdx:Zo("idx_job_worker_sessions_expires").on(e.expiresAt)}))});function b3(e){return Fy({url:e.url,schema:{jobQueue:Y,jobWorkerSessions:qe},authToken:e.authToken,authTokenEnv:"JOB_QUEUE_DATABASE_AUTH_TOKEN",contentionRetryBudgetMs:0})}var S3=w(()=>{U$();M$()});class F${declarations=new Map;handlers=new Map;validators=new Map;logger;mode;finalizedRegistrations;constructor(e,t){this.logger=e.child("HandlerRegistry"),this.mode=t}registerHandler(e,t,r){if(this.finalizedRegistrations)throw Error("Job handler registrations are finalized");if(this.declarations.has(e))throw Error(`Job handler is already registered for type: ${e}`);if(this.declarations.set(e,{handler:t,pluginId:r}),this.validators.set(e,t),this.mode!=="validation-only")this.handlers.set(e,t);this.logger.debug("Registered job execution declaration",{type:e,pluginId:r,mode:this.mode})}unregisterHandler(e){this.declarations.delete(e),this.handlers.delete(e),this.validators.delete(e),this.logger.debug("Unregistered job handler",{type:e})}unregisterPluginHandlers(e){let t=[...this.declarations.entries()].filter(([,r])=>r.pluginId===e).map(([r])=>r);for(let r of t)this.declarations.delete(r),this.handlers.delete(r),this.validators.delete(r);if(t.length>0)this.logger.debug("Unregistered plugin handlers",{pluginId:e,count:t.length,types:t})}finalizeRegistrations(){return this.finalizedRegistrations??=Object.freeze([...this.declarations.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>Object.freeze({type:e,pluginId:t.pluginId}))),this.finalizedRegistrations}getExecutionRegistrations(){return this.finalizedRegistrations}getRegisteredTypes(){return[...this.handlers.keys()]}getExclusiveTypes(){return[...this.handlers].filter(([,e])=>e.exclusive===!0).map(([e])=>e)}getHandler(e){return this.handlers.get(e)}getValidator(e){return this.validators.get(e)}}class J${tails=new Map;async run(e,t){let r=this.tails.get(e),o=()=>{},n=new Promise((i)=>{o=i});this.tails.set(e,n),await r;try{return await t()}finally{if(o(),this.tails.get(e)===n)this.tails.delete(e)}}}class K${findDuplicate(e,t,r){if(!t||t==="none")return null;let o=this.filterByDeduplicationKey(e,r).sort((i,s)=>s.createdAt-i.createdAt||s.id.localeCompare(i.id)),n=o.find((i)=>i.status===Oe.PENDING)??null;if(t==="skip"||t==="replace")return n;return n??o[0]??null}filterByDeduplicationKey(e,t){if(!t)return e;return e.filter((r)=>{let o=fpe.safeParse(r.metadata);return o.success&&o.data.deduplicationKey===t})}}var fpe;var v3=w(()=>{he();Oo();fpe=l.looseObject({deduplicationKey:l.string().optional()})});function _3(e){return`${String(e.length).padStart(2,"0")}${e}`}function mpe(e){return ppe.test(e)?`0${_3(e)}`:`1${e}`}function $f(e){let t=w3.exec(e);if(!t)throw Error(`Invalid brain version "${e}"`);let[,r="",o="",n="",i]=t,s=[r,o,n].map(_3).join("");return i===void 0?`${s}~`:`${s}-${i.split(".").map(mpe).join("!")}`}var w3,ppe,x3;var H$=w(()=>{he();w3=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/u,ppe=/^\d+$/u,x3=l.string().regex(w3,"Brain version must be a semver version")});function E3(e){return JSON.stringify(new Ya(e).toJSON())}class V${db;transactionClient;databaseUrl;logger;deduplicator=new K$;writeRetryBudgetMs;constructor(e,t,r,o,n){this.db=e,this.transactionClient=t,this.databaseUrl=r,this.logger=o.child("JobQueueRepository"),this.writeRetryBudgetMs=n?.writeRetryBudgetMs??hpe}async insert(e){await this.write("insert",async()=>this.db.insert(Y).values(e))}async enqueueAtomic(e){return Spe.run(this.databaseUrl,async()=>{let t=Date.now()+this.writeRetryBudgetMs;return this.attemptEnqueue(e,t,1)})}async attemptEnqueue(e,t,r){let o=await this.runEnqueueTransaction(e,t,r);if(o.retry)return this.attemptEnqueue(e,t,r+1);return o.decision}async runEnqueueTransaction(e,t,r){let o=await this.acquireWriteTransaction(e,t),n={prepared:!1},i=!1;try{let s=await this.decideEnqueue(o,e,()=>{n.prepared=!0});return i=!0,await o.commit(),{retry:!1,decision:s}}catch(s){let a=i&&this.isSerializationConflict(s)&&!o.closed,c=!0;if(!o.closed)try{await o.rollback()}catch(u){c=!1,this.logger.error("Failed to roll back atomic enqueue",{type:e.jobData.type,rollbackError:u})}if(n.prepared)e.onInsertRollback?.();if(!a||!c)throw s;return await this.waitForConflictRetry("commit",e,t,r,s),{retry:!0}}finally{o.close()}}async decideEnqueue(e,t,r){let{jobData:o,strategy:n,deduplicationKey:i,beforeInsert:s}=t,a=n??"none",c=async()=>{await s?.(),r()},u=async()=>{await c(),await this.insertJob(e,o)};if(a==="none")return await u(),{kind:"inserted",jobId:o.id};let d=await this.getActiveDeduplicationCandidates(e,o.type,i),f=this.deduplicator.findDuplicate(d,a,i);if(!f)return await u(),{kind:"inserted",jobId:o.id};if(a==="skip")return await this.raiseBrainVersion(e,f.id,o),{kind:"skipped",jobId:f.id};if(a==="coalesce"){if(await this.raiseBrainVersion(e,f.id,o),(await e.execute({sql:"UPDATE `job_queue` SET `scheduledFor` = ? WHERE `id` = ? AND `status` = ?",args:[Date.now(),f.id,f.status]})).rowsAffected!==1)throw Error(`Atomic coalesce lost selected job ${f.id}`);return{kind:"coalesced",jobId:f.id}}await c();let m=Date.now();if((await e.execute({sql:"UPDATE `job_queue`\n SET `status` = ?,\n `lastError` = ?,\n `lastErrorPublic` = ?,\n `completedAt` = ?,\n `runtimeUpdatedAt` = max(?, coalesce((SELECT max(`runtimeUpdatedAt`) FROM `job_queue`), 0) + 1)\n WHERE `id` = ? AND `status` = ?",args:[Oe.FAILED,"Replaced by newer job",E3("cancelled"),m,m,f.id,Oe.PENDING]})).rowsAffected!==1)throw Error(`Atomic replace lost selected job ${f.id}`);return await this.insertJob(e,o),{kind:"replaced",jobId:o.id,replacedJobId:f.id}}async getActiveDeduplicationCandidates(e,t,r){return(await e.execute(r?{sql:"SELECT `id`, `status`, `createdAt`, `metadata`\n FROM `job_queue`\n WHERE `type` = ?\n AND json_extract(`metadata`, '$.deduplicationKey') = ?\n AND `status` IN (?, ?)",args:[t,r,Oe.PENDING,Oe.PROCESSING]}:{sql:"SELECT `id`, `status`, `createdAt`, `metadata`\n FROM `job_queue`\n WHERE `type` = ? AND `status` IN (?, ?)",args:[t,Oe.PENDING,Oe.PROCESSING]})).rows.map((n)=>this.parseDeduplicationCandidate(n))}parseDeduplicationCandidate(e){let{id:t,status:r,createdAt:o,metadata:n}=e;if(typeof t!=="string"||r!==Oe.PENDING&&r!==Oe.PROCESSING||typeof o!=="number"&&typeof o!=="bigint"||typeof n!=="string")throw Error("Invalid active job row returned during atomic enqueue");let i=JSON.parse(n);return{id:t,status:r,createdAt:Number(o),metadata:i}}async raiseBrainVersion(e,t,r){if(!r.brainVersion)return;let o=$f(r.brainVersion);await e.execute({sql:"UPDATE `job_queue`\n SET `brainVersion` = ?, `brainVersionSortKey` = ?\n WHERE `id` = ?\n AND (`brainVersionSortKey` IS NULL OR `brainVersionSortKey` < ?)",args:[r.brainVersion,o,t,o]})}async insertJob(e,t){if((await e.execute({sql:"INSERT INTO `job_queue` (\n `id`, `type`, `data`, `result`, `source`, `metadata`,\n `status`, `priority`, `retryCount`, `maxRetries`,\n `lastError`, `createdAt`, `scheduledFor`, `startedAt`,\n `completedAt`, `brainVersion`, `brainVersionSortKey`\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",args:[t.id,t.type,t.data,this.serializeJson(t.result),t.source,JSON.stringify(t.metadata),t.status,t.priority,t.retryCount,t.maxRetries,t.lastError,t.createdAt,t.scheduledFor,t.startedAt,t.completedAt,t.brainVersion??null,t.brainVersion?$f(t.brainVersion):null]})).rowsAffected!==1)throw Error(`Atomic enqueue did not insert job ${t.id}`)}serializeJson(e){if(e===void 0||e===null)return null;return JSON.stringify(e)}acquireWriteTransaction(e,t){return this.retryOnConflict("acquire",e,()=>this.transactionClient.transaction("write"),(r)=>this.isSerializationConflict(r),t)}async waitForConflictRetry(e,t,r,o,n){let i=Math.min(gpe*2**(o-1),ype),s=i/2+Math.random()*(i/2);if(Date.now()+s>=r)throw this.transactionConflictError(e,t,o,n);await new Promise((a)=>setTimeout(a,s))}async retryOnConflict(e,t,r,o,n=Date.now()+this.writeRetryBudgetMs,i=1){try{return await r()}catch(s){if(!o(s))throw s;return await this.waitForConflictRetry(e,t,n,i,s),this.retryOnConflict(e,t,r,o,n,i+1)}}transactionConflictError(e,t,r,o){if(typeof t==="string")return Error(`Failed job queue write "${t}" within ${this.writeRetryBudgetMs}ms after ${r} attempts`,{cause:o});let n=t.strategy??"none",i=t.deduplicationKey?"present":"absent";return Error(`Failed to ${e} atomic enqueue transaction for type "${t.jobData.type}" within ${this.writeRetryBudgetMs}ms after ${r} attempts (strategy: ${n}, key: ${i})`,{cause:o})}write(e,t){return this.retryOnConflict("write",e,t,(r)=>{let o=new Set;for(let n=r;n!==void 0&&!o.has(n);){if(o.add(n),typeof n==="object"&&n!==null&&"code"in n&&/^SQLITE_(?:BUSY|LOCKED)(?:_|$)/u.test(String(n.code)))return!0;n=n instanceof Error?n.cause:void 0}return!1})}isSerializationConflict(e){for(let t=e;t!==void 0;){let r=typeof t==="object"&&t!==null&&"code"in t?String(t.code):"",o=Ge(t,"");if(/SQLITE_(?:BUSY|LOCKED)/u.test(r)||/SQLITE_(?:BUSY|LOCKED)|database is locked|transaction (?:busy|conflict)/iu.test(o))return!0;t=t instanceof Error?t.cause:void 0}return!1}async startWorkerSession(e,t,r=Date.now(),o=Di,n,i){let s=r+o,a={brainVersion:n??null,brainVersionSortKey:n?$f(n):null,stableSlotId:i??null};await this.write("start worker session",async()=>{await this.db.insert(qe).values({slotId:e,sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:s,...a}).onConflictDoUpdate({target:qe.slotId,set:{sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:s,...a}}),await this.pruneDeadWorkerSessions(r,o)})}async heartbeatWorkerSession(e,t,r=Date.now(),o=Di){return(await this.write("heartbeat worker session",async()=>{let i=await this.db.update(qe).set({heartbeatAt:r,expiresAt:r+o}).where(tt(je(qe.slotId,e),je(qe.sessionId,t))).returning({slotId:qe.slotId});return await this.pruneDeadWorkerSessions(r,o),i})).length===1}async pruneDeadWorkerSessions(e,t){let r=this.db.select({id:Y.id}).from(Y).where(tt(je(Y.workerSlotId,qe.slotId),je(Y.workerSessionId,qe.sessionId),je(Y.status,Oe.PROCESSING),wn(Y.leaseExpiresAt,e)));await this.db.delete(qe).where(tt(Vi(qe.expiresAt,e-t),Gi(r)))}async endWorkerSession(e,t){return(await this.write("end worker session",async()=>this.db.delete(qe).where(tt(je(qe.slotId,e),je(qe.sessionId,t))).returning({slotId:qe.slotId}))).length===1}async complete(e,t,r){let o=Date.now(),i=(await this.write("complete",async()=>this.db.update(Y).set({status:Oe.COMPLETED,result:t,lastError:null,lastErrorPublic:null,completedAt:o,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o)}).where(this.attemptWriteGuard(e,r)).returning({id:Y.id}))).length===1;if(i)this.logger.debug("Job completed",{jobId:e,hasResult:t!==void 0});return i}async update(e,t,r){let n=(await this.write("update",async()=>this.db.update(Y).set({data:JSON.stringify(t)}).where(this.attemptWriteGuard(e,r)).returning({id:Y.id}))).length===1;if(n)this.logger.debug("Job data updated",{jobId:e});return n}async recordAttemptProgress(e,t,r,o=Date.now()){return(await this.write("record progress",async()=>this.db.update(Y).set({attemptHeartbeatAt:o,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o),progress:r}).where(this.attemptWriteGuard(e,t)).returning({id:Y.id}))).length===1}async renewAttemptLease(e,t,r,o){return(await this.write("renew attempt lease",async()=>this.db.update(Y).set({attemptHeartbeatAt:r,leaseExpiresAt:r+o}).where(this.attemptWriteGuard(e,t)).returning({id:Y.id}))).length===1}async fail(e,t,r,o=Date.now()){let i=(await this.db.select({retryCount:Y.retryCount,maxRetries:Y.maxRetries,type:Y.type,scheduledFor:Y.scheduledFor,startedAt:Y.startedAt,runtimeUpdatedAt:Y.runtimeUpdatedAt}).from(Y).where(this.attemptWriteGuard(e,r)).limit(1))[0];if(!i)return!1;let s=i.retryCount<i.maxRetries,a=s?i.retryCount+1:i.retryCount,c=Math.min(1000*2**i.retryCount,60000),u=s?o+c:i.scheduledFor;if((await this.write("fail",async()=>this.db.update(Y).set({status:s?Oe.PENDING:Oe.FAILED,retryCount:a,lastError:t.message,lastErrorPublic:Y_(t).toJSON(),scheduledFor:u,completedAt:s?null:o,runtimeUpdatedAt:s?i.runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o),startedAt:s?null:i.startedAt,attemptId:null,workerSlotId:null,workerSessionId:null,leaseExpiresAt:null,attemptHeartbeatAt:null}).where(tt(this.attemptWriteGuard(e,r),je(Y.retryCount,i.retryCount))).returning({id:Y.id}))).length!==1)return!1;if(s)this.logger.debug("Job scheduled for retry",{jobId:e,retryCount:a,backoffMs:c,scheduledFor:new Date(u).toISOString()});else this.logger.error("Job failed after max retries",{jobId:e,type:i.type,retryCount:i.retryCount,error:t.message});return!0}async retireUnownedActiveJob(e){let t=e.reason.trim();if(t.length===0)throw Error("Retired job reason must not be empty");let o=(await this.write("retire unowned job",async()=>this.db.update(Y).set({status:Oe.FAILED,lastError:t,lastErrorPublic:new Ya("no_handler").toJSON(),completedAt:e.now,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(e.now)}).where(tt(je(Y.id,e.jobId),je(Y.type,e.expectedType),nn(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)),jr(Y.attemptId),jr(Y.workerSlotId),jr(Y.workerSessionId),jr(Y.leaseExpiresAt),jr(Y.attemptHeartbeatAt),jr(Y.progress),jr(Y.result))).returning()))[0]??null;if(o)this.logger.warn("Retired unowned legacy job",{jobId:o.id,type:o.type,reason:t});return o}async getStatus(e){return(await this.db.select().from(Y).where(je(Y.id,e)).limit(1))[0]??null}async getJobsByRootJobId(e){return this.db.select().from(Y).where(C`json_extract(${Y.metadata}, '$.rootJobId') = ${e}`).orderBy(Lo(Y.createdAt),Lo(Y.id))}async getStatusByEntityId(e){return(await this.db.select().from(Y).where(C`json_extract(${Y.data}, '$.id') = ${e}`).orderBy(ia(Y.createdAt)).limit(1))[0]??null}async getStats(){let e=await this.db.select({status:Y.status,count:C`count(*)`}).from(Y).groupBy(Y.status),t={pending:0,processing:0,failed:0,completed:0,total:0};for(let r of e){let o=Number(r.count);t[r.status]=o,t.total+=o}return t}async getDiagnostics(e=Date.now()){let[t,r,o]=await Promise.all([this.db.select({type:Y.type,status:Y.status,count:C`count(*)`}).from(Y).groupBy(Y.type,Y.status),this.db.select({oldestPendingAt:C`min(case when ${Y.status} = ${Oe.PENDING} then ${Y.createdAt} end)`,duePending:C`coalesce(sum(case when ${Y.status} = ${Oe.PENDING} and ${Y.scheduledFor} <= ${e} then 1 else 0 end), 0)`,oldestDuePendingAt:C`min(case when ${Y.status} = ${Oe.PENDING} and ${Y.scheduledFor} <= ${e} then ${Y.scheduledFor} end)`,latestClaimAt:C`max(${Y.startedAt})`,oldestProcessingAt:C`min(case when ${Y.status} = ${Oe.PROCESSING} then ${Y.startedAt} end)`,staleLeaseCount:C`coalesce(sum(case when ${Y.status} = ${Oe.PROCESSING} and ${Y.leaseExpiresAt} is not null and ${Y.leaseExpiresAt} <= ${e} then 1 else 0 end), 0)`}).from(Y),this.db.select({total:C`count(*)`,active:C`coalesce(sum(case when ${qe.expiresAt} > ${e} then 1 else 0 end), 0)`,stale:C`coalesce(sum(case when ${qe.expiresAt} <= ${e} then 1 else 0 end), 0)`,latestHeartbeatAt:C`max(${qe.heartbeatAt})`}).from(qe)]),n={pending:0,processing:0,completed:0,failed:0},i=t.map((u)=>{let d=Number(u.count);return n[u.status]+=d,{type:u.type,status:u.status,count:d}}),s=r[0],a=o[0],c=(u)=>u===null||u===void 0?null:Math.max(0,e-Number(u));return{totals:n,byType:i,oldestPendingAgeMs:c(s?.oldestPendingAt),duePending:Number(s?.duePending??0),oldestDuePendingAgeMs:c(s?.oldestDuePendingAt),latestClaimAgeMs:c(s?.latestClaimAt),oldestProcessingAgeMs:c(s?.oldestProcessingAt),staleLeaseCount:Number(s?.staleLeaseCount??0),workerSessions:{total:Number(a?.total??0),active:Number(a?.active??0),stale:Number(a?.stale??0),latestHeartbeatAgeMs:c(a?.latestHeartbeatAt)}}}async getRuntimeUpdates(e,t){let r=bpe.parse(t);if(r===0)return[];return(await this.db.select().from(Y).where(C`(${Y.runtimeUpdatedAt}, ${Y.id}) > (${e.updatedAt}, ${e.jobId})`).orderBy(Lo(Y.runtimeUpdatedAt),Lo(Y.id)).limit(r)).map((n)=>({job:n,cursor:{updatedAt:n.runtimeUpdatedAt??0,jobId:n.id}}))}async cleanup(e){let t=Date.now()-e;return(await this.write("cleanup",async()=>this.db.delete(Y).where(tt(nn(je(Y.status,Oe.COMPLETED),je(Y.status,Oe.FAILED)),Vi(Y.completedAt,t))))).rowsAffected}async getActiveJobs(e){let t=nn(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)),r=e&&e.length>0?tt(t,Wi(Y.type,e)):t;return this.db.select().from(Y).where(r).orderBy(ia(Y.createdAt))}async getRecentJobs(e,t=20){let r=e&&e.length>0?Wi(Y.type,e):void 0;return this.db.select().from(Y).where(r).orderBy(ia(Y.createdAt)).limit(t)}async getFailedJobs(e){let t=je(Y.status,Oe.FAILED),r=e&&e.length>0?tt(t,Wi(Y.type,e)):t;return this.db.select().from(Y).where(r).orderBy(ia(Y.createdAt))}async claimNextReady(e){let{now:t,attemptId:r,workerSlotId:o,workerSessionId:n,leaseDurationMs:i,executableTypes:s,exclusiveTypes:a=[],brainVersion:c}=e,u=c?this.brainVersionGate(c,t):{admissible:void 0,noNewerWorker:void 0},d=this.db.select({slotId:qe.slotId}).from(qe).where(tt(je(qe.slotId,o),je(qe.sessionId,n),wn(qe.expiresAt,t))),f=this.noNewerLiveInstance(o,n,t),m=this.db.select({slotId:qe.slotId}).from(qe).where(tt(je(qe.slotId,Y.workerSlotId),je(qe.sessionId,Y.workerSessionId))),h=tt(je(Y.status,Oe.PROCESSING),nn(jr(Y.attemptId),Gi(m),Vi(Y.leaseExpiresAt,t))),b=Ly(Y,"running"),y=this.db.select({id:b.id}).from(b).where(tt(je(b.type,Y.type),je(b.status,Oe.PROCESSING),wn(b.leaseExpiresAt,t),C`${b.id} <> ${Y.id}`)),S=a.length===0?void 0:nn(_y(Y.type,[...a]),Gi(y)),x=C`${Y.status} = ${Oe.PROCESSING} AND ${Y.retryCount} + 1 > ${Y.maxRetries}`,_=this.db.select({id:Y.id}).from(Y).where(tt(Wi(Y.type,s),S,u.admissible,nn(tt(je(Y.status,Oe.PENDING),Vi(Y.scheduledFor,t)),h))).orderBy(Lo(Y.priority),Lo(Y.createdAt)).limit(1),O=(await this.write("claim",async()=>this.db.update(Y).set({status:C`CASE WHEN ${x} THEN ${Oe.FAILED} ELSE ${Oe.PROCESSING} END`,retryCount:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN ${Y.retryCount} + 1 ELSE ${Y.retryCount} END`,lastError:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN 'Attempt lease expired' ELSE ${Y.lastError} END`,lastErrorPublic:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN ${E3("deadline_exceeded")} ELSE ${Y.lastErrorPublic} END`,startedAt:C`CASE WHEN ${x} THEN ${Y.startedAt} ELSE ${t} END`,completedAt:C`CASE WHEN ${x} THEN ${t} ELSE NULL END`,attemptId:C`CASE WHEN ${x} THEN ${Y.attemptId} ELSE ${r} END`,workerSlotId:C`CASE WHEN ${x} THEN ${Y.workerSlotId} ELSE ${o} END`,workerSessionId:C`CASE WHEN ${x} THEN ${Y.workerSessionId} ELSE ${n} END`,leaseExpiresAt:C`CASE WHEN ${x} THEN ${Y.leaseExpiresAt} ELSE ${t+i} END`,attemptHeartbeatAt:C`CASE WHEN ${x} THEN ${Y.attemptHeartbeatAt} ELSE ${t} END`,runtimeUpdatedAt:C`CASE WHEN ${x} THEN ${this.nextRuntimeUpdatedAt(t)} ELSE ${Y.runtimeUpdatedAt} END`}).where(tt(Wi(Y.id,_),Ey(d),f,u.noNewerWorker)).returning()))[0];if(!O)return null;if(O.status===Oe.FAILED)return O;return this.logger.debug("Job claimed",{jobId:O.id,attemptId:O.attemptId,workerSlotId:o,workerSessionId:n}),O}noNewerLiveInstance(e,t,r){let o=Ly(qe,"claimer"),n=Ly(qe,"peer"),i=this.db.select({slotId:n.slotId}).from(n).innerJoin(o,tt(je(o.slotId,e),je(o.sessionId,t))).where(tt(je(n.stableSlotId,o.stableSlotId),wn(n.expiresAt,r),nn(wn(n.startedAt,o.startedAt),tt(je(n.startedAt,o.startedAt),wn(n.slotId,o.slotId)))));return Gi(i)}brainVersionGate(e,t){let r=$f(e),o=this.db.select({slotId:qe.slotId}).from(qe).where(tt(wn(qe.expiresAt,t),wn(qe.brainVersionSortKey,r)));return{admissible:nn(jr(Y.brainVersionSortKey),Vi(Y.brainVersionSortKey,r)),noNewerWorker:Gi(o)}}nextRuntimeUpdatedAt(e){return C`max(${e}, coalesce((select max(${Y.runtimeUpdatedAt}) from ${Y}), 0) + 1)`}attemptWriteGuard(e,t){return t?tt(je(Y.id,e),je(Y.status,Oe.PROCESSING),je(Y.attemptId,t)):tt(je(Y.id,e),jr(Y.attemptId),nn(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)))}}var hpe=2000,gpe=5,ype=40,bpe,Spe;var I3=w(()=>{q$();jy();M$();Mt();he();Oo();qd();v3();H$();bpe=l.number().int().min(0).max(1000),Spe=new J$});import{AsyncLocalStorage as vpe}from"async_hooks";class Rf{storage=new vpe;static createFresh(){return new Rf}constructor(){}current(){return this.storage.getStore()}run(e,t,r){if(t.length===0)throw Error("Operation ID must not be empty");let o=ni.parse(e),n=wpe(o);return this.storage.run(Object.freeze({provenance:n,operationId:t}),r)}}function wpe(e){if(Object.freeze(e.projectionLineage),e.sourceEntity)Object.freeze(e.sourceEntity);return Object.freeze(e)}var W$=w(()=>{Mt()});class Of{client;logger;handlerRegistry;repository;walInitialization=null;walInitializationSettled=!1;closeRequested=!1;clientClosed=!1;inFlightEnqueues=0;databaseUrl;operationContext;projectionAdmission;directWorkerSlotId=`direct:${Ro()}`;directWorkerSessionId=Ro();directLeaseDurationMs;directSessionStart=null;brainVersion;close(){this.closeRequested=!0,this.closeClientWhenReady()}static createFresh(e,t,r){return new Of(e,t??kr.getInstance(),r)}constructor(e,t,r){this.brainVersion=e.brainVersion===void 0?void 0:x3.parse(e.brainVersion);let{db:o,client:n,url:i}=b3(e);this.client=n,this.databaseUrl=i,this.logger=t.child("JobQueueService"),this.operationContext=r?.operationContext??Rf.createFresh(),this.projectionAdmission=r?.projectionAdmission,this.handlerRegistry=new F$(this.logger,r?.handlerRegistrationMode??"combined"),this.repository=new V$(o,n,i,this.logger),this.directLeaseDurationMs=e.claimTimeoutMs??300000}initialize(){if(this.closeRequested)return Promise.resolve();return this.walInitialization??=this.initializeWALMode(),this.walInitialization}async initializeWALMode(){try{await Jy(this.client,this.databaseUrl)}catch(e){this.logger.warn("Failed to enable WAL mode (non-fatal)",e)}finally{this.walInitializationSettled=!0,this.closeClientWhenReady()}}closeClientWhenReady(){if(!this.closeRequested||this.inFlightEnqueues>0||this.walInitialization!==null&&!this.walInitializationSettled)return;this.closeClient()}closeClient(){if(this.clientClosed)return;this.clientClosed=!0,this.client.close()}registerHandler(e,t,r){this.handlerRegistry.registerHandler(e,t,r)}unregisterHandler(e){this.handlerRegistry.unregisterHandler(e)}unregisterPluginHandlers(e){this.handlerRegistry.unregisterPluginHandlers(e)}getRegisteredTypes(){return this.handlerRegistry.getRegisteredTypes()}getHandler(e){return this.handlerRegistry.getHandler(e)}getValidator(e){return this.handlerRegistry.getValidator(e)}finalizeHandlerRegistrations(){return this.handlerRegistry.finalizeRegistrations()}getExecutionRegistrations(){return this.handlerRegistry.getExecutionRegistrations()}async enqueue(e){if(this.closeRequested)throw Error("Cannot enqueue a job after the queue service is closed");this.inFlightEnqueues++;try{return await this.enqueueValidated(e)}finally{this.inFlightEnqueues--,this.closeClientWhenReady()}}async enqueueValidated(e){let{type:t,data:r,options:o}=e,n=this.handlerRegistry.getValidator(t);if(!n)throw Error(`No job type declared: ${t}`);let i=n.validateAndParse(r);if(i===null)throw Error(`Invalid job data for type: ${t}`);let s=Date.now(),a=Ro(),c=o?.rootJobId??(o?.detached?a:this.operationContext.current()?.provenance.rootJobId)??a,u=this.createJobProvenance(a,c,o),d=o?.metadata??{operationType:"data_processing"},{provenance:f,...m}=d,h={id:a,type:t,data:JSON.stringify(i),status:Oe.PENDING,priority:o?.priority??0,maxRetries:o?.maxRetries??3,retryCount:0,source:o?.source??null,metadata:{...m,...o?.deduplicationKey&&{deduplicationKey:o.deduplicationKey},rootJobId:c,provenance:u},createdAt:s,scheduledFor:o?.delayMs?s+o.delayMs:s,result:null,lastError:null,startedAt:null,completedAt:null,brainVersion:this.brainVersion},b,y=()=>{b?.rollback(),b=void 0};try{let S=await this.repository.enqueueAtomic({jobData:h,strategy:o?.deduplication,deduplicationKey:o?.deduplicationKey,beforeInsert:async()=>{b=await this.projectionAdmission?.reserveJobAdmission(u)},onInsertRollback:y});if(b?.commit(),b=void 0,S.kind==="skipped")this.logger.debug("Skipping duplicate job (already pending)",{type:t,existingJobId:S.jobId});else if(S.kind==="coalesced")this.logger.debug("Coalescing with existing job",{type:t,existingJobId:S.jobId});else{if(S.kind==="replaced")this.logger.debug("Replacing duplicate job",{type:t,oldJobId:S.replacedJobId});this.logger.debug("Job enqueued",{id:S.jobId,type:t,priority:h.priority,rootJobId:h.metadata.rootJobId})}return S.jobId}catch(S){throw y(),this.logger.error("Failed to enqueue job",{type:t,error:Ge(S)}),S}}createJobProvenance(e,t,r){let o=this.operationContext.current(),n=r?.metadata.provenance??o?.provenance,i=n?.rootJobId===t?n:void 0,s=o?.provenance.rootJobId===t?o.operationId:void 0,a=r?.projection,c=a?[...i?.projectionLineage??[],a.id]:[...i?.projectionLineage??[]],u=a?.id??i?.projectionId;return ni.parse({rootJobId:t,causationId:s??i?.causationId??e,...u?{projectionId:u}:{},projectionLineage:c,...a?.sourceEntity?{sourceEntity:a.sourceEntity}:i?.sourceEntity?{sourceEntity:i.sourceEntity}:{},derivationDepth:c.length})}async dequeue(e){let t=this.handlerRegistry.getRegisteredTypes();if(t.length===0)return null;let{onTerminalReclaim:r,...o}=e??await this.getDirectClaimOptions(),n=Date.now(),i=await this.repository.claimNextReady({...o,workerSlotId:this.sessionSlotId(o.workerSlotId,o.workerSessionId),brainVersion:this.brainVersion,now:n,attemptId:Ro(),executableTypes:t,exclusiveTypes:this.handlerRegistry.getExclusiveTypes()});if(!i)return null;if(i.status===Oe.FAILED)return this.logger.warn("Expired attempt failed terminally on reclaim",{id:i.id,type:i.type,retryCount:i.retryCount}),await r?.(i),null;return this.logger.debug("Job dequeued",{id:i.id,type:i.type,priority:i.priority,retryCount:i.retryCount,attemptId:i.attemptId,workerSlotId:i.workerSlotId,workerSessionId:i.workerSessionId}),i}async startWorkerSession(e,t,r=Di){await this.repository.startWorkerSession(this.sessionSlotId(e,t),t,Date.now(),r,this.brainVersion,this.versionedSlotId(e))}heartbeatWorkerSession(e,t,r=Di){return this.repository.heartbeatWorkerSession(this.sessionSlotId(e,t),t,Date.now(),r)}endWorkerSession(e,t){return this.repository.endWorkerSession(this.sessionSlotId(e,t),t)}versionedSlotId(e){return this.brainVersion?`${e}@${this.brainVersion}`:e}sessionSlotId(e,t){return`${this.versionedSlotId(e)}#${t}`}renewAttemptLease(e,t,r){return this.repository.renewAttemptLease(e,t,Date.now(),r)}recordAttemptProgress(e,t,r){return this.repository.recordAttemptProgress(e,t,r)}complete(e,t,r){return this.repository.complete(e,t,r)}update(e,t,r){return this.repository.update(e,t,r)}fail(e,t,r){return this.repository.fail(e,t,r)}retireUnownedActiveJob(e){return this.repository.retireUnownedActiveJob(e)}async getDirectClaimOptions(){return this.directSessionStart??=this.repository.startWorkerSession(this.sessionSlotId(this.directWorkerSlotId,this.directWorkerSessionId),this.directWorkerSessionId,Date.now(),this.directLeaseDurationMs,this.brainVersion),await this.directSessionStart,{workerSlotId:this.directWorkerSlotId,workerSessionId:this.directWorkerSessionId,leaseDurationMs:this.directLeaseDurationMs}}async getStatus(e){return this.repository.getStatus(e)}async getJobsByRootJobId(e){return this.repository.getJobsByRootJobId(e)}async getStatusByEntityId(e){return this.repository.getStatusByEntityId(e)}async getStats(){return this.repository.getStats()}getDiagnostics(e){return this.repository.getDiagnostics(e)}async waitForIdle(e={}){let t=e.quietMs??250,r=e.pollIntervalMs??25,o=Date.now()+(e.timeoutMs??30000),n=async(i)=>{e.signal?.throwIfAborted();let{totals:s}=await this.getDiagnostics(),c=s.pending===0&&s.processing===0?i??Date.now():null;if(c!==null&&Date.now()-c>=t)return;if(Date.now()>=o)throw Error(`Timed out waiting for the job queue to settle: ${s.pending} pending, ${s.processing} processing`);return await Bun.sleep(r),n(c)};return n(null)}getRuntimeUpdates(e,t=1000){return this.repository.getRuntimeUpdates(e,t)}async cleanup(e){let t=await this.repository.cleanup(e);if(t>0)this.logger.info("Cleaned up old jobs",{deletedCount:t,olderThanMs:e});return t}async getActiveJobs(e){return this.repository.getActiveJobs(e)}async getRecentJobs(e,t){return this.repository.getRecentJobs(e,t)}async getFailedJobs(e){return this.repository.getFailedJobs(e)}}var k3=w(()=>{Zd();XA();qd();Oo();U$();S3();I3();Mt();W$();H$()});var G$=()=>{};var A3=w(()=>{Zd();Oo();qd();Oo();G$();W$()});var T3=w(()=>{Oo();G$()});var Y4e;var $3=w(()=>{he();Ud();Oo();Y4e=l.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},l.record(l.string(),l.unknown()))});var tqe;var R3=w(()=>{he();tqe=l.record(l.string(),l.unknown())});var O3=w(()=>{Mt();Zd()});var C3=w(()=>{k3();A3();T3();$3();R3();qd();Oo();Ud();O3()});var Q$={};Ut(Q$,{LEGACY_PROJECTION_JOB_TYPES:()=>z3,LEGACY_PROJECTION_RETIREMENT_REASON:()=>D3,legacyProjectionJobTypeSchema:()=>N3,retireLegacyProjectionJob:()=>Ope});import{existsSync as Tpe}from"fs";import{resolve as $pe}from"path";function P3(e){return{id:e.id,type:e.type,status:e.status,retryCount:e.retryCount,maxRetries:e.maxRetries,createdAt:e.createdAt,startedAt:e.startedAt,completedAt:e.completedAt}}function Rpe(e,t){if(e.type!==t)throw Error(`Job ${e.id} has type ${e.type}; expected ${t}`);if(e.status!=="pending"&&e.status!=="processing")throw Error(`Job ${e.id} is already terminal (${e.status})`);if(e.attemptId!==null||e.workerSlotId!==null||e.workerSessionId!==null||e.leaseExpiresAt!==null||e.attemptHeartbeatAt!==null)throw Error(`Job ${e.id} still has attempt ownership`);if(e.progress!==null||e.result!=null)throw Error(`Job ${e.id} contains partial progress or a result`)}async function Ope(e){let t=$pe(e.databasePath);if(!Tpe(t))throw Error(`Job database does not exist: ${t}`);let r=N3.parse(e.jobType),o=Of.createFresh({url:`file:${t}`});try{let n=await o.getStatus(e.jobId);if(!n)throw Error(`Job not found: ${e.jobId}`);if(Rpe(n,r),e.dryRun){if(e.confirmation!==void 0)throw Error("Dry-run recovery must not include confirmation");return{databasePath:t,job:P3(n),retired:!1}}let i=`retire:${n.id}`;if(e.confirmation!==i)throw Error(`Refusing to retire ${n.id}; expected --confirm ${i}`);let s=await o.retireUnownedActiveJob({jobId:n.id,expectedType:r,reason:D3,now:e.now?.()??Date.now()});if(!s)throw Error(`Job ${n.id} changed or acquired ownership before retirement`);return{databasePath:t,job:P3(s),retired:!0}}finally{o.close()}}var z3,N3,D3="Retired legacy projection job superseded by scheduler-owned projections";var Y$=w(()=>{C3();he();z3=["conversation-memory:project","skill:project","swot:derive","topic:project"],N3=l.enum(z3)});function Zt(e,t,r,o,n){return B3.parse({id:e,operation:t,count:r,targetProbeCount:o,settleMs:n})}function eR(e){return Pf.parse(structuredClone(Npe[e]))}function zf(e){let t=`stress:${e.handle}`;if(e.confirmation!==t)throw Error(`Directory-sync stress requires --confirm ${t}`);let r=/(^|[-_.])smoke($|[-_.])/i;if(!r.test(e.handle)||!r.test(e.domain)||!r.test(e.contentRepo))throw Error("Directory-sync stress is smoke-only; handle, domain, and content repository must all identify smoke")}async function Hy(e,t={}){let r=t.fetchImpl??fetch,o=t.now??(()=>new Date),n=t.timeoutMs??20000,i=o(),s=new AbortController,a=setTimeout(()=>s.abort(),n);try{let c=await r(e,{method:"GET",signal:s.signal});return await c.arrayBuffer(),X$.parse({timestamp:i.toISOString(),endpoint:new URL(e).pathname,status:c.status,durationMs:Math.max(0,o().getTime()-i.getTime()),ok:c.ok})}catch(c){return X$.parse({timestamp:i.toISOString(),endpoint:new URL(e).pathname,status:0,durationMs:Math.max(0,o().getTime()-i.getTime()),ok:!1,error:Dpe(c)})}finally{clearTimeout(a)}}async function tR(e,t){let r=Pf.parse(e),o=[],n,i=await t.prepare(r),s,a;try{try{await t.startMonitoring()}catch(c){n=`monitor: ${Ky(c)}`}if(!n)for(let c of r.phases)try{let u=j3.parse(await t.executePhase(c,i));if(o.push(u),!u.success){n=`${c.id}: ${u.error??"phase failed"}`;break}}catch(u){let d=Ky(u);o.push({id:c.id,operation:c.operation,count:c.count,success:!1,error:d}),n=`${c.id}: ${d}`;break}}finally{try{if(s=Z3.parse(await t.cleanup(i)),!s.success&&!n)n=s.error??"cleanup failed"}catch(c){let u=Ky(c);s={success:!1,probesRemaining:0,error:u},n??=`cleanup: ${u}`}try{a=U3.parse(await t.stopMonitoring())}catch(c){let u=Ky(c);a={health:[],runtime:[]},n??=`monitor: ${u}`}}return n??=M3(a,r.maximumExternalAiCalls??0),q3.parse({profile:r.profile,success:n===void 0&&o.length===r.phases.length&&s.success,baseline:i,phases:o,cleanup:s,metrics:a,...n?{failure:n}:{}})}function M3(e,t=0){let r=e.health.find((i)=>!i.ok);if(r)return`health: ${r.endpoint} unavailable`;let o=e.externalAiCalls??0;if(o>t)return t===0?`external AI: observed ${o} call(s)`:`external AI: observed ${o} call(s), cap ${t}`;if(e.container?.oomKilled)return"container: OOM killed";let n=e.container?.restartCount??0;if(n>0)return`container: restarted ${n} time(s)`;if(e.container&&e.container.status!=="running")return`container: ${e.container.status}`;return}function Dpe(e){if(e instanceof Error)return`${e.name}: ${e.message}`;return String(e)}function Ky(e){return Ge(e)}var Cf,L3,B3,Pf,Cpe,X$,Ppe,j3,Z3,zpe,U3,q3,Npe;var Vy=w(()=>{he();Cf=l.enum(["regression","load","stress"]),L3=l.enum(["add","update","rename","delete"]),B3=l.object({id:l.string().min(1),operation:L3,count:l.number().int().positive().max(700),targetProbeCount:l.number().int().min(0).max(700),settleMs:l.number().int().nonnegative().max(300000)}),Pf=l.object({profile:Cf,maximumProbeCount:l.number().int().positive().max(700),maximumExternalAiCalls:l.number().int().nonnegative().max(1e4).optional(),phases:l.array(B3).min(1)}),Cpe=l.object({entities:l.number().int().nonnegative(),notes:l.number().int().nonnegative(),version:l.string().min(1)}),X$=l.object({timestamp:l.iso.datetime(),endpoint:l.string().startsWith("/"),status:l.number().int().nonnegative(),durationMs:l.number().nonnegative(),ok:l.boolean(),error:l.string().optional()}),Ppe=l.object({timestamp:l.iso.datetime(),cpuPercent:l.number().nonnegative(),memoryPercent:l.number().nonnegative(),pids:l.number().int().nonnegative()}),j3=l.object({id:l.string().min(1),operation:L3,count:l.number().int().positive(),success:l.boolean(),commitLatencyMs:l.number().nonnegative().optional(),persistenceLatencyMs:l.number().nonnegative().optional(),error:l.string().optional()}),Z3=l.object({success:l.boolean(),probesRemaining:l.number().int().nonnegative(),finalEntities:l.number().int().nonnegative().optional(),finalNotes:l.number().int().nonnegative().optional(),contentTreeRestored:l.boolean().optional(),error:l.string().optional()}),zpe=l.object({status:l.string(),restartCount:l.number().int().nonnegative(),oomKilled:l.boolean()}),U3=l.object({health:l.array(X$),runtime:l.array(Ppe),externalAiCalls:l.number().int().nonnegative().optional(),container:zpe.optional()}),q3=l.object({profile:Cf,success:l.boolean(),baseline:Cpe,phases:l.array(j3),cleanup:Z3,metrics:U3,failure:l.string().optional()}),Npe={regression:{profile:"regression",maximumProbeCount:20,phases:[Zt("add20","add",20,20,0),Zt("update20","update",20,20,30000),Zt("delete20","delete",20,0,150000)]},load:{profile:"load",maximumProbeCount:350,phases:[Zt("add50","add",50,50,0),Zt("add150","add",100,150,0),Zt("add350","add",200,350,0),Zt("update350a","update",350,350,45000),Zt("rename100","rename",100,350,45000),Zt("update350b","update",350,350,45000),Zt("delete350","delete",350,0,150000)]},stress:{profile:"stress",maximumProbeCount:700,phases:[Zt("add50","add",50,50,0),Zt("add150","add",100,150,0),Zt("add350","add",200,350,0),Zt("add700","add",350,700,0),Zt("update700a","update",700,700,45000),Zt("rename200","rename",200,700,45000),Zt("update700b","update",700,700,45000),Zt("delete700","delete",700,0,150000)]}}});import{spawn as Lpe}from"child_process";async function F3(e,t,r,o){let n=await e(t,r,o);if(n.exitCode!==0)throw eo(t,r,n);return n}function eo(e,t,r){let o=r.stderr.trim()||r.stdout.trim();return Error(`${e} ${t.join(" ")} exited with ${r.exitCode}${o?`: ${o}`:""}`)}var Mo=async(e,t,r={})=>new Promise((o,n)=>{let i=Lpe(e,[...t],{cwd:r.cwd,env:r.env?{...process.env,...r.env}:process.env,stdio:["pipe","pipe","pipe"]}),s="",a="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",(c)=>{s+=c}),i.stderr.on("data",(c)=>{a+=c}),i.on("error",n),i.on("close",(c)=>{o({exitCode:c??1,stdout:s,stderr:a})}),i.stdin.end(r.stdin)});var Nf=()=>{};class Il{#e;#t;dir;constructor(e,t,r){this.#e=e,this.dir=t,this.#t=r}static async clone(e,t,r,o){let n=new Il(e,r,o);return await F3(e,"git",["-c","credential.helper=","-c",`credential.helper=${J3}`,"clone","--branch","main","--single-branch",`https://github.com/${t}.git`,r],{env:n.environment()}),await n.run(["config","--local","credential.helper",J3]),await n.run(["reset","--hard","origin/main"]),n}async run(e,t=!0){let r=await this.#e("git",e,{cwd:this.dir,env:this.environment()});if(t&&r.exitCode!==0)throw eo("git",e,r);return r}async output(e){return(await this.run(e)).stdout.trim()}async sync(e=!1){if(await this.run(["fetch","origin","main"]),e)await this.run(["reset","--hard","origin/main"]);else await this.run(["pull","--rebase","origin","main"])}async commitAll(e){await this.run(["add","-A"]),await this.run(["-c","user.name=brains-ops","-c","user.email=ops@rizom.ai","commit","-m",e])}async pushMainWithRebase(){for(let e=1;e<=5;e+=1){if((await this.run(["push","origin","main"],!1)).exitCode===0)return;await this.run(["pull","--rebase","origin","main"])}throw Error("Unable to push content main after five rebase attempts")}async pruneStressBackupBranches(){let t=(await this.run(["ls-remote","--heads","origin","refs/heads/ops/directory-sync-stress-backup-*"])).stdout.split(/\r?\n/).map((r)=>r.match(/\trefs\/heads\/(ops\/directory-sync-stress-backup-[^\s]+)$/)?.[1]).filter((r)=>r!==void 0).sort();for(let r of t)await this.run(["push","origin","--delete",r]);return t}environment(){return{GH_TOKEN:this.#t,GITHUB_TOKEN:this.#t}}}var J3='!f() { test "$1" = get && echo username=x-access-token && echo "password=$GH_TOKEN"; }; f';var K3=w(()=>{Nf()});function Df(e){return e.entityCounts.find((t)=>t.entityType==="note")?.count??0}class rR{#e;#t=[];#r=[];#n=new Set(["/health/ready"]);#o=!0;#i;#a;#s="";#c=0;#l;constructor(e){this.#e=e}get startedAt(){return this.#s}get error(){return this.#a}get healthSamples(){return this.#t}get runtimeSamples(){return this.#r}gateHealthSamples(){return this.#t.slice(this.#c,this.#l??this.#t.length)}markGateEnd(){this.#l=this.#t.length}async discoverEndpoints(){for(let e of["/health/live","/health/operate"])if((await Hy(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:5000})).status!==404)this.#n.add(e)}start(){this.#o=!1,this.#a=void 0,this.#c=this.#t.length,this.#l=void 0,this.#s=this.#e.now().toISOString(),this.#i=Promise.all([this.#m(),this.#p()]).then(()=>{return}).catch((e)=>{this.#a=e,this.#o=!0})}async stop(){this.#o=!0,await this.#i}async waitForHealthSnapshot(e){return this.waitForEntityBaseline(void 0,void 0,e)}async waitForEntityBaseline(e,t,r){let o=this.#e.now().getTime();while(this.#e.now().getTime()-o<r){let n=await this.fetchHealthPayload();if(this.#f(n,e,t))return n;await this.#e.sleep(5000)}return}async waitForStableEntityBaseline(e,t,r){let o=this.#e.now().getTime(),n=0;while(this.#e.now().getTime()-o<r){let i=await this.fetchHealthPayload();if(this.#f(i,e,t)){if(n+=1,n===2)return i}else n=0;await this.#e.sleep(5000)}return}async fetchHealthPayload(){let e=await this.#d();if(e===void 0)return;let t=await this.#e.readEntityCounts();if(!t)return;return{version:e,entities:t.reduce((r,o)=>r+o.count,0),entityCounts:t}}async#d(){let e=this.#e.now(),t=new AbortController,r=setTimeout(()=>t.abort(),20000);try{let o=await this.#e.fetchImpl(`https://${this.#e.domain}/health/operate`,{signal:t.signal}),n=await o.text();if(this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:o.status,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:o.ok}),!o.ok)return;return Bpe.parse(JSON.parse(n)).app.version}catch(o){this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:0,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:!1,error:o instanceof Error?`${o.name}: ${o.message}`:String(o)});return}finally{clearTimeout(r)}}#f(e,t,r){return e!==void 0&&(t===void 0||Df(e)===t)&&(r===void 0||e.entities===r)}async#m(){while(!this.#o){for(let e of this.#n)this.#t.push(await Hy(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:20000}));await this.#e.sleep(4000)}}async#p(){while(!this.#o){let e=await this.#e.sampleRuntime();if(e)this.#r.push(e);await this.#e.sleep(1000)}}}var H3,Bpe;var V3=w(()=>{he();Vy();H3=l.array(l.object({entityType:l.string(),count:l.number().int().nonnegative()})),Bpe=l.object({status:l.literal("ready"),operationalStatus:l.literal("operational"),app:l.object({version:l.string()})})});var Wy={};Ut(Wy,{applyDirectorySyncStressPhase:()=>t5,cleanupDirectorySyncStress:()=>Y3,listProbeFiles:()=>la,parseStressRuntimeSample:()=>r5,removeProbeFiles:()=>lR,runDeployedDirectorySyncStress:()=>G3,runStressCommand:()=>Mo,verifyDirectorySyncStressAccess:()=>Q3});import{chmod as jpe,mkdir as oR,mkdtemp as iR,readFile as Zpe,readdir as Upe,rename as qpe,rm as Bf,writeFile as En}from"fs/promises";import{tmpdir as sR}from"os";import{join as ct,resolve as aR}from"path";async function G3(e){let t=e.now??(()=>new Date),r=t().toISOString(),o=uR(r),n=aR(e.artifactsDir??ct(e.rootDir,".brains-ops","stress",o));await oR(n,{recursive:!0});let{pilot:i,user:s}=await cR(e.rootDir,e.handle);zf({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation});let a=Cf.parse(e.profile),c=e.plan?Pf.parse(e.plan):eR(a);if(c.profile!==a)throw Error(`Directory-sync stress plan profile ${c.profile} does not match requested profile ${a}`);if((c.maximumExternalAiCalls??0)===0)e5(s);let u=Mpe.parse(e.env??process.env),d=new X3({runId:o,artifactsDir:n,user:s,githubOrg:i.githubOrg,serverLabel:`${i.contentRepoPrefix}${s.handle}`,environment:u,fetchImpl:e.fetchImpl??fetch,commandRunner:e.commandRunner??Mo,logger:e.logger??console.info,now:t,sleep:e.sleep??Bun.sleep}),f;try{f=await tR(c,d)}finally{await d.dispose()}let m={runId:o,artifactsDir:n,target:{handle:s.handle,domain:s.domain,contentRepo:`${i.githubOrg}/${s.contentRepo}`},startedAt:r,completedAt:t().toISOString(),report:f};return await Wpe(m),m}async function Q3(e){let r=(e.now??(()=>new Date))().toISOString(),o=uR(r),n=aR(e.artifactsDir??ct(e.rootDir,".brains-ops","stress",`access-check-${o}`));await oR(n,{recursive:!0});let{pilot:i,user:s}=await cR(e.rootDir,e.handle);zf({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation}),e5(s);let a=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!a)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let c=await iR(ct(sR(),"brains-ops-directory-sync-access-check-"));try{let u=await Il.clone(e.commandRunner??Mo,`${i.githubOrg}/${s.contentRepo}`,ct(c,"content"),a),d=await u.output(["rev-parse","HEAD"]);await u.run(["push","--dry-run","origin",`HEAD:refs/heads/ops/directory-sync-stress-access-check-${o}`]);let f={success:!0,artifactsDir:n,checkedAt:r,remoteHead:d,target:{handle:s.handle,domain:s.domain,contentRepo:`${i.githubOrg}/${s.contentRepo}`}};return await En(ct(n,"access-check.json"),`${JSON.stringify(f,null,2)}
398
+ `;await t.run(n);let s=(await t.values(C`SELECT id, hash, created_at FROM ${C.identifier(o)} ORDER BY created_at DESC LIMIT 1`))[0]??void 0;await t.transaction(async(a)=>{for(let c of e)if(!s||Number(s[2])<c.folderMillis){for(let u of c.sql)await a.run(C.raw(u));await a.run(C`INSERT INTO ${C.identifier(o)} ("hash", "created_at") VALUES(${c.hash}, ${c.folderMillis})`)}})}}});var w$;var GF=w(()=>{Re();w$=class w${static[F]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}});function Oy(e,t){return(r,o,...n)=>{let i=[o,...n].map((s)=>({type:e,isAll:t,rightSelect:s}));for(let s of i)if(!gf(r.getSelectedFields(),s.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return r.addSetOperators(i)}}var _n,QF,x$,Xfe=()=>({union:epe,unionAll:tpe,intersect:rpe,except:npe}),epe,tpe,rpe,npe;var _$=w(()=>{Re();GF();Bo();aa();Yt();vn();sr();br();Do();vl();Ef();_n=class _n{static[F]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let t=!!this.fields,r;if(this.fields)r=this.fields;else if(oe(e,ft))r=Object.fromEntries(Object.keys(e._.selectedFields).map((o)=>[o,e[o]]));else if(oe(e,qo))r=e[pt].selectedFields;else if(oe(e,xe))r={};else r=wy(e);return new x$({table:e,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}};QF=class QF extends w${static[F]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:r,session:o,dialect:n,withList:i,distinct:s}){super();this.config={withList:i,table:e,fields:{...t},distinct:s,setOperators:[]},this.isPartialSelect=r,this.session=o,this.dialect=n,this._={selectedFields:t,config:this.config},this.tableName=yf(e),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let a of xn(e))this.usedTables.add(a)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,r)=>{let o=this.tableName,n=yf(t);for(let i of xn(t))this.usedTables.add(i);if(typeof n==="string"&&this.config.joins?.some((i)=>i.alias===n))throw Error(`Alias "${n}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof o==="string")this.config.fields={[o]:this.config.fields};if(typeof n==="string"&&!oe(t,xe)){let i=oe(t,ft)?t._.selectedFields:oe(t,tn)?t[pt].selectedFields:t[me.Symbol.Columns];this.config.fields[n]=i}}if(typeof r==="function")r=r(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:r,table:t,joinType:e,alias:n}),typeof n==="string")switch(e){case"left":{this.joinsNotNullableMap[n]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([i])=>[i,!1])),this.joinsNotNullableMap[n]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[n]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([i])=>[i,!1])),this.joinsNotNullableMap[n]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(e,t){return(r)=>{let o=typeof r==="function"?r(Xfe()):r;if(!gf(this.getSelectedFields(),o.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:o}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){if(typeof e==="function")e=e(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=e,this}having(e){if(typeof e==="function")e=e(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=e,this}groupBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.fields,new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.fields,new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=r;else this.config.orderBy=r}else{let t=e;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=t;else this.config.orderBy=t}return this}limit(e){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=e;else this.config.limit=e;return this}offset(e){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=e;else this.config.offset=e;return this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){let t=[];if(t.push(...xn(this.config.table)),this.config.joins)for(let r of this.config.joins)t.push(...xn(r.table));return new Proxy(new ft(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new at({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}};x$=class x$ extends QF{static[F]="SQLiteSelect";_prepare(e=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let t=rn(this.config.fields),r=this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),t,"all",!0,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return r.joinsNotNullableMap=this.joinsNotNullableMap,r}$withCache(e){return this.cacheConfig=e===void 0?{config:{},enable:!0,autoInvalidate:!0}:e===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...e},this}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.all()}};$M(x$,[Sr]);epe=Oy("union",!1),tpe=Oy("union",!0),rpe=Oy("intersect",!1),npe=Oy("except",!1)});var ca;var Cy=w(()=>{Re();aa();Ry();vn();_$();ca=class ca{static[F]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=oe(e,xl)?e:void 0,this.dialectConfig=oe(e,xl)?void 0:e}$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(r);return new Proxy(new pf(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...e){let t=this;function r(n){return new _n({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function o(n){return new _n({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}return{select:r,selectDistinct:o}}select(e){return new _n({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new _n({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){if(!this.dialect)this.dialect=new S$(this.dialectConfig);return this.dialect}}});var Py,E$;var YF=w(()=>{Re();Bo();Yt();jo();sr();br();vl();Cy();Py=class Py{constructor(e,t,r,o){this.table=e,this.session=t,this.dialect=r,this.withList=o}static[F]="SQLiteInsertBuilder";values(e){if(e=Array.isArray(e)?e:[e],e.length===0)throw Error("values() must be called with at least one value");let t=e.map((r)=>{let o={},n=this.table[me.Symbol.Columns];for(let i of Object.keys(r)){let s=r[i];o[i]=oe(s,xe)?s:new Br(s,n[i])}return o});return new E$(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e==="function"?e(new ca):e;if(!oe(t,xe)&&!gf(this.table[by],t._.selectedFields))throw Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new E$(this.table,t,this.session,this.dialect,this.withList,!0)}};E$=class E$ extends Sr{constructor(e,t,r,o,n,i){super();this.session=r,this.dialect=o,this.config={table:e,values:t,withList:n,select:i}}static[F]="SQLiteInsert";config;returning(e=this.config.table[At.Symbol.Columns]){return this.config.returning=rn(e),this}onConflictDoNothing(e={}){if(!this.config.onConflict)this.config.onConflict=[];if(e.target===void 0)this.config.onConflict.push(C` on conflict do nothing`);else{let t=Array.isArray(e.target)?C`${e.target}`:C`${[e.target]}`,r=e.where?C` where ${e.where}`:C``;this.config.onConflict.push(C` on conflict ${t} do nothing${r}`)}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');if(!this.config.onConflict)this.config.onConflict=[];let t=e.where?C` where ${e.where}`:void 0,r=e.targetWhere?C` where ${e.targetWhere}`:void 0,o=e.setWhere?C` where ${e.setWhere}`:void 0,n=Array.isArray(e.target)?C`${e.target}`:C`${[e.target]}`,i=this.dialect.buildUpdateSet(this.config.table,vy(this.config.table,e.set));return this.config.onConflict.push(C` on conflict ${n}${r} do update set ${i}${t}${o}`),this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:xn(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}});var zy,XF;var e3=w(()=>{Re();Bo();aa();jo();vn();sr();br();Do();vl();Ef();zy=class zy{constructor(e,t,r,o){this.table=e,this.session=t,this.dialect=r,this.withList=o}static[F]="SQLiteUpdateBuilder";set(e){return new XF(this.table,vy(this.table,e),this.session,this.dialect,this.withList)}};XF=class XF extends Sr{constructor(e,t,r,o,n){super();this.session=r,this.dialect=o,this.config={set:t,table:e,withList:n,joins:[]}}static[F]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return(t,r)=>{let o=yf(t);if(typeof o==="string"&&this.config.joins.some((n)=>n.alias===o))throw Error(`Alias "${o}" is already used in this query`);if(typeof r==="function"){let n=this.config.from?oe(t,At)?t[me.Symbol.Columns]:oe(t,ft)?t._.selectedFields:oe(t,qo)?t[pt].selectedFields:void 0:void 0;r=r(new Proxy(this.config.table[me.Symbol.Columns],new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),n&&new Proxy(n,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:r,table:t,joinType:e,alias:o}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.table[me.Symbol.Columns],new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];this.config.orderBy=r}else{let t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[At.Symbol.Columns]){return this.config.returning=rn(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:xn(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}});var I$=w(()=>{JF();YF();Cy();_$();e3()});var If;var t3=w(()=>{Re();Yt();If=class If extends xe{constructor(e){super(If.buildEmbeddedCount(e.source,e.filters).queryChunks);this.params=e,this.session=e.session,this.sql=If.buildCount(e.source,e.filters)}sql;static[F]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return C`(select count(*) from ${e}${C.raw(" where ").if(t)}${t})`}static buildCount(e,t){return C`select count(*) from ${e}${C.raw(" where ").if(t)}${t}`}then(e,t){return Promise.resolve(this.session.count(this.sql)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then((t)=>(e?.(),t),(t)=>{throw e?.(),t})}}});var A$,Ny,k$;var r3=w(()=>{Re();Bo();Sf();A$=class A${constructor(e,t,r,o,n,i,s,a){this.mode=e,this.fullSchema=t,this.schema=r,this.tableNamesMap=o,this.table=n,this.tableConfig=i,this.dialect=s,this.session=a}static[F]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return this.mode==="sync"?new k$(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many"):new Ny(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many")}findFirst(e){return this.mode==="sync"?new k$(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new Ny(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}};Ny=class Ny extends Sr{constructor(e,t,r,o,n,i,s,a,c){super();this.fullSchema=e,this.schema=t,this.tableNamesMap=r,this.table=o,this.tableConfig=n,this.dialect=i,this.session=s,this.config=a,this.mode=c}static[F]="SQLiteAsyncRelationalQuery";mode;getSQL(){return this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(e=!1){let{query:t,builtQuery:r}=this._toSQL();return this.session[e?"prepareOneTimeQuery":"prepareQuery"](r,void 0,this.mode==="first"?"get":"all",!0,(o,n)=>{let i=o.map((s)=>Iy(this.schema,this.tableConfig,s,t.selection,n));if(this.mode==="first")return i[0];return i})}prepare(){return this._prepare(!1)}_toSQL(){let e=this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}executeRaw(){if(this.mode==="first")return this._prepare(!1).get();return this._prepare(!1).all()}async execute(){return this.executeRaw()}};k$=class k$ extends Ny{static[F]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}});var _l;var n3=w(()=>{Re();Bo();_l=class _l extends Sr{constructor(e,t,r,o,n){super();this.execute=e,this.getSQL=t,this.dialect=o,this.mapBatchResult=n,this.config={action:r}}static[F]="SQLiteRaw";config;getQuery(){return{...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}});var kf;var Dy=w(()=>{Re();aa();Yt();I$();vn();t3();r3();n3();kf=class kf{constructor(e,t,r,o){this.resultKind=e,this.dialect=t,this.session=r,this._=o?{schema:o.schema,fullSchema:o.fullSchema,tableNamesMap:o.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};let n=this.query;if(this._.schema)for(let[i,s]of Object.entries(this._.schema))n[i]=new A$(e,o.fullSchema,this._.schema,this._.tableNamesMap,o.fullSchema[i],s,t,r);this.$cache={invalidate:async(i)=>{}}}static[F]="BaseSQLiteDatabase";query;$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(new ca(r.dialect));return new Proxy(new pf(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(e,t){return new If({source:e,filters:t,session:this.session})}with(...e){let t=this;function r(a){return new _n({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e})}function o(a){return new _n({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function n(a){return new zy(a,t.session,t.dialect,e)}function i(a){return new Py(a,t.session,t.dialect,e)}function s(a){return new Ty(a,t.session,t.dialect,e)}return{select:r,selectDistinct:o,update:n,insert:i,delete:s}}select(e){return new _n({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new _n({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new zy(e,this.session,this.dialect)}$cache;insert(e){return new Py(e,this.session,this.dialect)}delete(e){return new Ty(e,this.session,this.dialect)}run(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new _l(async()=>this.session.run(t),()=>t,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session));return this.session.run(t)}all(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new _l(async()=>this.session.all(t),()=>t,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session));return this.session.all(t)}get(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new _l(async()=>this.session.get(t),()=>t,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session));return this.session.get(t)}values(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new _l(async()=>this.session.values(t),()=>t,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session));return this.session.values(t)}transaction(e,t){return this.session.transaction(e,t)}}});async function T$(e,t){let r=`${e}-${JSON.stringify(t)}`,n=new TextEncoder().encode(r),i=await crypto.subtle.digest("SHA-256",n);return[...new Uint8Array(i)].map((c)=>c.toString(16).padStart(2,"0")).join("")}var o3,Af;var $$=w(()=>{Re();o3=class o3{static[F]="Cache"};Af=class Af extends o3{strategy(){return"all"}static[F]="NoopCache";async get(e){return}async put(e,t,r,o){}async onMutate(e){}}});var i3=w(()=>{$$()});function Ly(e,t){return new Proxy(e,new sa(t,!1))}var s3=w(()=>{xf()});var a3,R$,O$,C$;var P$=w(()=>{$$();Re();$y();Bo();Dy();a3=class a3 extends Sr{constructor(e){super();this.resultCb=e}static[F]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}};R$=class R${constructor(e,t,r,o,n,i){if(this.mode=e,this.executeMethod=t,this.query=r,this.cache=o,this.queryMetadata=n,this.cacheConfig=i,o&&o.strategy()==="all"&&i===void 0)this.cacheConfig={enable:!0,autoInvalidate:!0};if(!this.cacheConfig?.enable)this.cacheConfig=void 0}static[F]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,r){if(this.cache===void 0||oe(this.cache,Af)||this.queryMetadata===void 0)try{return await r()}catch(o){throw new Uo(e,t,o)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await r()}catch(o){throw new Uo(e,t,o)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[o]=await Promise.all([r(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return o}catch(o){throw new Uo(e,t,o)}if(!this.cacheConfig)try{return await r()}catch(o){throw new Uo(e,t,o)}if(this.queryMetadata.type==="select"){let o=await this.cache.get(this.cacheConfig.tag??await T$(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(o===void 0){let n;try{n=await r()}catch(i){throw new Uo(e,t,i)}return await this.cache.put(this.cacheConfig.tag??await T$(e,t),n,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),n}return o}try{return await r()}catch(o){throw new Uo(e,t,o)}}getQuery(){return this.query}mapRunResult(e,t){return e}mapAllResult(e,t){throw Error("Not implemented")}mapGetResult(e,t){throw Error("Not implemented")}execute(e){if(this.mode==="async")return this[this.executeMethod](e);return new a3(()=>this[this.executeMethod](e))}mapResult(e,t){switch(this.executeMethod){case"run":return this.mapRunResult(e,t);case"all":return this.mapAllResult(e,t);case"get":return this.mapGetResult(e,t)}}};O$=class O${constructor(e){this.dialect=e}static[F]="SQLiteSession";prepareOneTimeQuery(e,t,r,o,n,i,s){return this.prepareQuery(e,t,r,o,n,i,s)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(r){throw new wl({cause:r,message:`Failed to run the query '${t.sql}'`})}}extractRawRunValueFromBatchResult(e){return e}all(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).all()}extractRawAllValueFromBatchResult(e){throw Error("Not implemented")}get(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).get()}extractRawGetValueFromBatchResult(e){throw Error("Not implemented")}values(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).values()}async count(e){return(await this.values(e))[0][0]}extractRawValuesValueFromBatchResult(e){throw Error("Not implemented")}};C$=class C$ extends kf{constructor(e,t,r,o,n=0){super(e,t,r,o);this.schema=o,this.nestedIndex=n}static[F]="SQLiteTransaction";rollback(){throw new g$}}});var z$,ope,ipe,By;var c3=w(()=>{Re();aa();br();Cy();jo();Ef();z$=class z${constructor(e){this.name=e}static[F]="SQLiteViewBuilderCore";config={}};ope=class ope extends z${static[F]="SQLiteViewBuilder";as(e){if(typeof e==="function")e=e(new ca);let t=new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}),r=e.getSelectedFields();return new Proxy(new By({config:{name:this.name,schema:void 0,selectedFields:r,query:e.getSQL().inlineParams()}}),t)}};ipe=class ipe extends z${static[F]="SQLiteManualViewBuilder";columns;constructor(e,t){super(e);this.columns=wy(_f(e,t))}existing(){return new Proxy(new By({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:void 0}}),new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}as(e){return new Proxy(new By({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:e.inlineParams()}}),new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}};By=class By extends qo{static[F]="SQLiteView";constructor({config:e}){super(e)}}});var jy=w(()=>{s3();BF();b$();Dy();Ry();i$();qF();FF();I$();P$();jo();a$();vl();c3()});function l3(e){return Object.keys(e).reduce((t,r)=>{if(Object.prototype.propertyIsEnumerable.call(e,r))t[r]=e[r];return t},{})}function Zy(e){if(typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer){if(typeof Buffer<"u"){if(!(e instanceof Buffer))return Buffer.from(e);return e}if(typeof TextDecoder<"u")return new TextDecoder().decode(e);throw Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.")}return e}var Uy,N$,u3;var D$=w(()=>{i3();Re();xy();Yt();jy();P$();br();Uy=class Uy extends O${constructor(e,t,r,o,n){super(t);this.client=e,this.schema=r,this.options=o,this.tx=n,this.logger=o.logger??new YT,this.cache=o.cache??new Af}static[F]="LibSQLSession";logger;cache;prepareQuery(e,t,r,o,n,i,s){return new u3(this.client,e,this.logger,this.cache,i,s,t,this.tx,r,o,n)}async batch(e){let t=[],r=[];for(let n of e){let i=n._prepare(),s=i.getQuery();t.push(i),r.push({sql:s.sql,args:s.params})}return(await this.client.batch(r)).map((n,i)=>t[i].mapResult(n,!0))}async migrate(e){let t=[],r=[];for(let n of e){let i=n._prepare(),s=i.getQuery();t.push(i),r.push({sql:s.sql,args:s.params})}return(await this.client.migrate(r)).map((n,i)=>t[i].mapResult(n,!0))}async transaction(e,t){let r=await this.client.transaction(),o=new Uy(this.client,this.dialect,this.schema,this.options,r),n=new N$("async",this.dialect,o,this.schema);try{let i=await e(n);return await r.commit(),i}catch(i){throw await r.rollback(),i}}extractRawAllValueFromBatchResult(e){return e.rows}extractRawGetValueFromBatchResult(e){return e.rows[0]}extractRawValuesValueFromBatchResult(e){return e.rows}};N$=class N$ extends C${static[F]="LibSQLTransaction";async transaction(e){let t=`sp${this.nestedIndex}`,r=new N$("async",this.dialect,this.session,this.schema,this.nestedIndex+1);await this.session.run(C.raw(`savepoint ${t}`));try{let o=await e(r);return await this.session.run(C.raw(`release savepoint ${t}`)),o}catch(o){throw await this.session.run(C.raw(`rollback to savepoint ${t}`)),o}}};u3=class u3 extends R${constructor(e,t,r,o,n,i,s,a,c,u,d){super("async",c,t,o,n,i);this.client=e,this.logger=r,this.fields=s,this.tx=a,this._isResponseInArrayMode=u,this.customResultMapper=d,this.customResultMapper=d,this.fields=s}static[F]="LibSQLPreparedQuery";async run(e){let t=hf(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let r={sql:this.query.sql,args:t};return this.tx?this.tx.execute(r):this.client.execute(r)})}async all(e){let{fields:t,logger:r,query:o,tx:n,client:i,customResultMapper:s}=this;if(!t&&!s){let c=hf(o.params,e??{});return r.logQuery(o.sql,c),await this.queryWithCache(o.sql,c,async()=>{let u={sql:o.sql,args:c};return(n?n.execute(u):i.execute(u)).then(({rows:d})=>this.mapAllResult(d))})}let a=await this.values(e);return this.mapAllResult(a)}mapAllResult(e,t){if(t)e=e.rows;if(!this.fields&&!this.customResultMapper)return e.map((r)=>l3(r));if(this.customResultMapper)return this.customResultMapper(e,Zy);return e.map((r)=>WT(this.fields,Array.prototype.slice.call(r).map((o)=>Zy(o)),this.joinsNotNullableMap))}async get(e){let{fields:t,logger:r,query:o,tx:n,client:i,customResultMapper:s}=this;if(!t&&!s){let c=hf(o.params,e??{});return r.logQuery(o.sql,c),await this.queryWithCache(o.sql,c,async()=>{let u={sql:o.sql,args:c};return(n?n.execute(u):i.execute(u)).then(({rows:d})=>this.mapGetResult(d))})}let a=await this.values(e);return this.mapGetResult(a)}mapGetResult(e,t){if(t)e=e.rows;let r=e[0];if(!this.fields&&!this.customResultMapper)return l3(r);if(!r)return;if(this.customResultMapper)return this.customResultMapper(e,Zy);return WT(this.fields,Array.prototype.slice.call(r).map((o)=>Zy(o)),this.joinsNotNullableMap)}async values(e){let t=hf(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let r={sql:this.query.sql,args:t};return(this.tx?this.tx.execute(r):this.client.execute(r)).then(({rows:o})=>o)})}isResponseInArrayMode(){return this._isResponseInArrayMode}}});function El(e,t={}){let r=new v$({casing:t.casing}),o;if(t.logger===!0)o=new QT;else if(t.logger!==!1)o=t.logger;let n;if(t.schema){let a=XM(t.schema,tF);n={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}let i=new Uy(e,r,n,{logger:o,cache:t.cache},void 0),s=new d3("async",r,i,n);if(s.$client=e,s.$cache=t.cache,s.$cache)s.$cache.invalidate=t.cache?.onMutate;return s}var d3;var f3=w(()=>{Re();xy();Sf();Dy();Ry();D$();d3=class d3 extends kf{static[F]="LibSQLDatabase";async batch(e){return this.session.batch(e)}}});function qy(...e){if(typeof e[0]==="string"){let t=gl({url:e[0]});return El(t,e[1])}if(RM(e[0])){let{connection:t,client:r,...o}=e[0];if(r)return El(r,o);let n=typeof t==="string"?gl({url:t}):gl(t);return El(n,o)}return El(e[0],e[1])}var p3=w(()=>{BT();br();f3();((e)=>{function t(r){return El({},r)}e.mock=t})(qy||(qy={}))});var m3=w(()=>{p3();D$()});function spe(){return new Promise((e)=>setTimeout(e,0))}function cpe(){if(L$)return;L$=!0,setTimeout(()=>{L$=!1,B$=performance.now()},0)}async function Tf(e=ape){if(cpe(),performance.now()-B$<e)return;await spe(),B$=performance.now()}var ape=50,B$,L$=!1;var h3=w(()=>{B$=performance.now()});function g3(e){if(e.authToken!==void 0)return e.authToken;if(e.authTokenEnv===void 0)return;return process.env[e.authTokenEnv]}function fpe(e){return e instanceof Ce&&/^SQLITE_(?:BUSY|LOCKED)$/u.test(e.code)}async function My(e,t){let r=Date.now()+(t.budgetMs??lpe),o=async(n)=>{if(t.isClosed())throw new Ce("The client is closed","CLIENT_CLOSED");try{return await e()}catch(i){if(t.isClosed()||!fpe(i))throw i;await t.afterRefusal?.();let s=Math.min(upe*2**(n-1),dpe),a=s/2+Math.random()*(s/2);if(t.isClosed()||Date.now()+a>=r)throw i;if(await new Promise((c)=>setTimeout(c,a)),t.isClosed()||Date.now()>=r)throw i;return o(n+1)}};return o(1)}function j$(e,t={}){let r=gl({...e,...e.url.startsWith("file:")?{timeout:0}:{}});if(e.url.startsWith("file:")&&e.syncUrl===void 0){let o=r.transaction.bind(r),n=()=>r.closed,i=t.contentionRetryBudgetMs,s=r.execute.bind(r),a=r.batch.bind(r),c=r.migrate.bind(r),u={isClosed:n,budgetMs:i,afterRefusal:async()=>{await Promise.resolve(r.reconnect())}};async function d(f,m){return await Tf(),My(()=>typeof f==="string"?s(f,m):s(f),u)}r.execute=d,r.batch=async(f,m)=>(await Tf(),My(()=>a(f,m),u)),r.migrate=async(f)=>(await Tf(),My(()=>c(f),u)),r.transaction=async(f)=>(await Tf(),My(()=>o(f),u))}return r}function Fy(e){let{url:t,schema:r}=e,o=g3(e),n={contentionRetryBudgetMs:e.contentionRetryBudgetMs},i=o?j$({url:t,authToken:o},n):j$({url:t},n);return{db:qy(i,{schema:r}),client:i,url:t}}async function Jy(e,t){if(!t.startsWith("file:"))return;for(let r of["PRAGMA busy_timeout = 0","PRAGMA journal_mode = WAL"])await e.execute(r)}var lpe=5000,upe=5,dpe=40;var Z$=w(()=>{BT();m3();h3()});var y3=w(()=>{XA();Z$()});var U$=w(()=>{Z$();y3()});var q$=w(()=>{xf();hy();Sn();Re();$y();xy();Bo();Sf();y$();vn();sr();br();Do()});var Y,qe;var M$=w(()=>{jy();q$();Zd();Y=_f("job_queue",{id:mt("id").primaryKey().$defaultFn(()=>Ro()),type:mt("type").notNull(),data:mt("data").notNull(),result:mt("result",{mode:"json"}),progress:mt("progress",{mode:"json"}).$type(),source:mt("source"),metadata:mt("metadata",{mode:"json"}).$type().notNull(),status:mt("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:ar("priority").notNull().default(0),retryCount:ar("retryCount").notNull().default(0),maxRetries:ar("maxRetries").notNull().default(3),lastError:mt("lastError"),lastErrorPublic:mt("lastErrorPublic",{mode:"json"}),createdAt:ar("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:ar("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:ar("startedAt"),completedAt:ar("completedAt"),attemptId:mt("attemptId"),workerSlotId:mt("workerSlotId"),workerSessionId:mt("workerSessionId"),leaseExpiresAt:ar("leaseExpiresAt"),attemptHeartbeatAt:ar("attemptHeartbeatAt"),runtimeUpdatedAt:ar("runtimeUpdatedAt"),brainVersion:mt("brainVersion"),brainVersionSortKey:mt("brainVersionSortKey")},(e)=>({queueReadyIdx:Zo("idx_job_queue_ready").on(e.status,e.priority,e.scheduledFor),jobTypeIdx:Zo("idx_job_queue_type").on(e.type,e.status),runtimeUpdatesIdx:Zo("idx_job_queue_runtime_updates").on(e.runtimeUpdatedAt,e.id),jobSourceIdx:Zo("idx_job_queue_source").on(e.source),rootJobIdx:Zo("idx_job_queue_root_job").on(C`json_extract(${e.metadata}, '$.rootJobId')`,e.createdAt,e.id),deduplicationIdx:Zo("idx_job_queue_deduplication").on(e.type,C`json_extract(${e.metadata}, '$.deduplicationKey')`,e.status)})),qe=_f("job_worker_sessions",{slotId:mt("slotId").primaryKey(),sessionId:mt("sessionId").notNull().unique(),startedAt:ar("startedAt").notNull(),heartbeatAt:ar("heartbeatAt").notNull(),expiresAt:ar("expiresAt").notNull().default(0),brainVersion:mt("brainVersion"),brainVersionSortKey:mt("brainVersionSortKey"),stableSlotId:mt("stableSlotId")},(e)=>({heartbeatIdx:Zo("idx_job_worker_sessions_heartbeat").on(e.heartbeatAt),expiresIdx:Zo("idx_job_worker_sessions_expires").on(e.expiresAt)}))});function b3(e){return Fy({url:e.url,schema:{jobQueue:Y,jobWorkerSessions:qe},authToken:e.authToken,authTokenEnv:"JOB_QUEUE_DATABASE_AUTH_TOKEN",contentionRetryBudgetMs:0})}var S3=w(()=>{U$();M$()});class F${declarations=new Map;handlers=new Map;validators=new Map;logger;mode;finalizedRegistrations;constructor(e,t){this.logger=e.child("HandlerRegistry"),this.mode=t}registerHandler(e,t,r){if(this.finalizedRegistrations)throw Error("Job handler registrations are finalized");if(this.declarations.has(e))throw Error(`Job handler is already registered for type: ${e}`);if(this.declarations.set(e,{handler:t,pluginId:r}),this.validators.set(e,t),this.mode!=="validation-only")this.handlers.set(e,t);this.logger.debug("Registered job execution declaration",{type:e,pluginId:r,mode:this.mode})}unregisterHandler(e){this.declarations.delete(e),this.handlers.delete(e),this.validators.delete(e),this.logger.debug("Unregistered job handler",{type:e})}unregisterPluginHandlers(e){let t=[...this.declarations.entries()].filter(([,r])=>r.pluginId===e).map(([r])=>r);for(let r of t)this.declarations.delete(r),this.handlers.delete(r),this.validators.delete(r);if(t.length>0)this.logger.debug("Unregistered plugin handlers",{pluginId:e,count:t.length,types:t})}finalizeRegistrations(){return this.finalizedRegistrations??=Object.freeze([...this.declarations.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>Object.freeze({type:e,pluginId:t.pluginId}))),this.finalizedRegistrations}getExecutionRegistrations(){return this.finalizedRegistrations}getRegisteredTypes(){return[...this.handlers.keys()]}getExclusiveTypes(){return[...this.handlers].filter(([,e])=>e.exclusive===!0).map(([e])=>e)}getHandler(e){return this.handlers.get(e)}getValidator(e){return this.validators.get(e)}}class J${tails=new Map;async run(e,t){let r=this.tails.get(e),o=()=>{},n=new Promise((i)=>{o=i});this.tails.set(e,n),await r;try{return await t()}finally{if(o(),this.tails.get(e)===n)this.tails.delete(e)}}}class K${findDuplicate(e,t,r){if(!t||t==="none")return null;let o=this.filterByDeduplicationKey(e,r).sort((i,s)=>s.createdAt-i.createdAt||s.id.localeCompare(i.id)),n=o.find((i)=>i.status===Oe.PENDING)??null;if(t==="skip"||t==="replace")return n;return n??o[0]??null}filterByDeduplicationKey(e,t){if(!t)return e;return e.filter((r)=>{let o=ppe.safeParse(r.metadata);return o.success&&o.data.deduplicationKey===t})}}var ppe;var v3=w(()=>{he();Oo();ppe=l.looseObject({deduplicationKey:l.string().optional()})});function _3(e){return`${String(e.length).padStart(2,"0")}${e}`}function hpe(e){return mpe.test(e)?`0${_3(e)}`:`1${e}`}function $f(e){let t=w3.exec(e);if(!t)throw Error(`Invalid brain version "${e}"`);let[,r="",o="",n="",i]=t,s=[r,o,n].map(_3).join("");return i===void 0?`${s}~`:`${s}-${i.split(".").map(hpe).join("!")}`}var w3,mpe,x3;var H$=w(()=>{he();w3=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/u,mpe=/^\d+$/u,x3=l.string().regex(w3,"Brain version must be a semver version")});function E3(e){return JSON.stringify(new Ya(e).toJSON())}class V${db;transactionClient;databaseUrl;logger;deduplicator=new K$;writeRetryBudgetMs;constructor(e,t,r,o,n){this.db=e,this.transactionClient=t,this.databaseUrl=r,this.logger=o.child("JobQueueRepository"),this.writeRetryBudgetMs=n?.writeRetryBudgetMs??gpe}async insert(e){await this.write("insert",async()=>this.db.insert(Y).values(e))}async enqueueAtomic(e){return vpe.run(this.databaseUrl,async()=>{let t=Date.now()+this.writeRetryBudgetMs;return this.attemptEnqueue(e,t,1)})}async attemptEnqueue(e,t,r){let o=await this.runEnqueueTransaction(e,t,r);if(o.retry)return this.attemptEnqueue(e,t,r+1);return o.decision}async runEnqueueTransaction(e,t,r){let o=await this.acquireWriteTransaction(e,t),n={prepared:!1},i=!1;try{let s=await this.decideEnqueue(o,e,()=>{n.prepared=!0});return i=!0,await o.commit(),{retry:!1,decision:s}}catch(s){let a=i&&this.isSerializationConflict(s)&&!o.closed,c=!0;if(!o.closed)try{await o.rollback()}catch(u){c=!1,this.logger.error("Failed to roll back atomic enqueue",{type:e.jobData.type,rollbackError:u})}if(n.prepared)e.onInsertRollback?.();if(!a||!c)throw s;return await this.waitForConflictRetry("commit",e,t,r,s),{retry:!0}}finally{o.close()}}async decideEnqueue(e,t,r){let{jobData:o,strategy:n,deduplicationKey:i,beforeInsert:s}=t,a=n??"none",c=async()=>{await s?.(),r()},u=async()=>{await c(),await this.insertJob(e,o)};if(a==="none")return await u(),{kind:"inserted",jobId:o.id};let d=await this.getActiveDeduplicationCandidates(e,o.type,i),f=this.deduplicator.findDuplicate(d,a,i);if(!f)return await u(),{kind:"inserted",jobId:o.id};if(a==="skip")return await this.raiseBrainVersion(e,f.id,o),{kind:"skipped",jobId:f.id};if(a==="coalesce"){if(await this.raiseBrainVersion(e,f.id,o),(await e.execute({sql:"UPDATE `job_queue` SET `scheduledFor` = ? WHERE `id` = ? AND `status` = ?",args:[Date.now(),f.id,f.status]})).rowsAffected!==1)throw Error(`Atomic coalesce lost selected job ${f.id}`);return{kind:"coalesced",jobId:f.id}}await c();let m=Date.now();if((await e.execute({sql:"UPDATE `job_queue`\n SET `status` = ?,\n `lastError` = ?,\n `lastErrorPublic` = ?,\n `completedAt` = ?,\n `runtimeUpdatedAt` = max(?, coalesce((SELECT max(`runtimeUpdatedAt`) FROM `job_queue`), 0) + 1)\n WHERE `id` = ? AND `status` = ?",args:[Oe.FAILED,"Replaced by newer job",E3("cancelled"),m,m,f.id,Oe.PENDING]})).rowsAffected!==1)throw Error(`Atomic replace lost selected job ${f.id}`);return await this.insertJob(e,o),{kind:"replaced",jobId:o.id,replacedJobId:f.id}}async getActiveDeduplicationCandidates(e,t,r){return(await e.execute(r?{sql:"SELECT `id`, `status`, `createdAt`, `metadata`\n FROM `job_queue`\n WHERE `type` = ?\n AND json_extract(`metadata`, '$.deduplicationKey') = ?\n AND `status` IN (?, ?)",args:[t,r,Oe.PENDING,Oe.PROCESSING]}:{sql:"SELECT `id`, `status`, `createdAt`, `metadata`\n FROM `job_queue`\n WHERE `type` = ? AND `status` IN (?, ?)",args:[t,Oe.PENDING,Oe.PROCESSING]})).rows.map((n)=>this.parseDeduplicationCandidate(n))}parseDeduplicationCandidate(e){let{id:t,status:r,createdAt:o,metadata:n}=e;if(typeof t!=="string"||r!==Oe.PENDING&&r!==Oe.PROCESSING||typeof o!=="number"&&typeof o!=="bigint"||typeof n!=="string")throw Error("Invalid active job row returned during atomic enqueue");let i=JSON.parse(n);return{id:t,status:r,createdAt:Number(o),metadata:i}}async raiseBrainVersion(e,t,r){if(!r.brainVersion)return;let o=$f(r.brainVersion);await e.execute({sql:"UPDATE `job_queue`\n SET `brainVersion` = ?, `brainVersionSortKey` = ?\n WHERE `id` = ?\n AND (`brainVersionSortKey` IS NULL OR `brainVersionSortKey` < ?)",args:[r.brainVersion,o,t,o]})}async insertJob(e,t){if((await e.execute({sql:"INSERT INTO `job_queue` (\n `id`, `type`, `data`, `result`, `source`, `metadata`,\n `status`, `priority`, `retryCount`, `maxRetries`,\n `lastError`, `createdAt`, `scheduledFor`, `startedAt`,\n `completedAt`, `brainVersion`, `brainVersionSortKey`\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",args:[t.id,t.type,t.data,this.serializeJson(t.result),t.source,JSON.stringify(t.metadata),t.status,t.priority,t.retryCount,t.maxRetries,t.lastError,t.createdAt,t.scheduledFor,t.startedAt,t.completedAt,t.brainVersion??null,t.brainVersion?$f(t.brainVersion):null]})).rowsAffected!==1)throw Error(`Atomic enqueue did not insert job ${t.id}`)}serializeJson(e){if(e===void 0||e===null)return null;return JSON.stringify(e)}acquireWriteTransaction(e,t){return this.retryOnConflict("acquire",e,()=>this.transactionClient.transaction("write"),(r)=>this.isSerializationConflict(r),t)}async waitForConflictRetry(e,t,r,o,n){let i=Math.min(ype*2**(o-1),bpe),s=i/2+Math.random()*(i/2);if(Date.now()+s>=r)throw this.transactionConflictError(e,t,o,n);await new Promise((a)=>setTimeout(a,s))}async retryOnConflict(e,t,r,o,n=Date.now()+this.writeRetryBudgetMs,i=1){try{return await r()}catch(s){if(!o(s))throw s;return await this.waitForConflictRetry(e,t,n,i,s),this.retryOnConflict(e,t,r,o,n,i+1)}}transactionConflictError(e,t,r,o){if(typeof t==="string")return Error(`Failed job queue write "${t}" within ${this.writeRetryBudgetMs}ms after ${r} attempts`,{cause:o});let n=t.strategy??"none",i=t.deduplicationKey?"present":"absent";return Error(`Failed to ${e} atomic enqueue transaction for type "${t.jobData.type}" within ${this.writeRetryBudgetMs}ms after ${r} attempts (strategy: ${n}, key: ${i})`,{cause:o})}write(e,t){return this.retryOnConflict("write",e,t,(r)=>{let o=new Set;for(let n=r;n!==void 0&&!o.has(n);){if(o.add(n),typeof n==="object"&&n!==null&&"code"in n&&/^SQLITE_(?:BUSY|LOCKED)(?:_|$)/u.test(String(n.code)))return!0;n=n instanceof Error?n.cause:void 0}return!1})}isSerializationConflict(e){for(let t=e;t!==void 0;){let r=typeof t==="object"&&t!==null&&"code"in t?String(t.code):"",o=Ge(t,"");if(/SQLITE_(?:BUSY|LOCKED)/u.test(r)||/SQLITE_(?:BUSY|LOCKED)|database is locked|transaction (?:busy|conflict)/iu.test(o))return!0;t=t instanceof Error?t.cause:void 0}return!1}async startWorkerSession(e,t,r=Date.now(),o=Di,n,i){let s=r+o,a={brainVersion:n??null,brainVersionSortKey:n?$f(n):null,stableSlotId:i??null};await this.write("start worker session",async()=>{await this.db.insert(qe).values({slotId:e,sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:s,...a}).onConflictDoUpdate({target:qe.slotId,set:{sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:s,...a}}),await this.pruneDeadWorkerSessions(r,o)})}async heartbeatWorkerSession(e,t,r=Date.now(),o=Di){return(await this.write("heartbeat worker session",async()=>{let i=await this.db.update(qe).set({heartbeatAt:r,expiresAt:r+o}).where(tt(je(qe.slotId,e),je(qe.sessionId,t))).returning({slotId:qe.slotId});return await this.pruneDeadWorkerSessions(r,o),i})).length===1}async pruneDeadWorkerSessions(e,t){let r=this.db.select({id:Y.id}).from(Y).where(tt(je(Y.workerSlotId,qe.slotId),je(Y.workerSessionId,qe.sessionId),je(Y.status,Oe.PROCESSING),wn(Y.leaseExpiresAt,e)));await this.db.delete(qe).where(tt(Vi(qe.expiresAt,e-t),Gi(r)))}async endWorkerSession(e,t){return(await this.write("end worker session",async()=>this.db.delete(qe).where(tt(je(qe.slotId,e),je(qe.sessionId,t))).returning({slotId:qe.slotId}))).length===1}async complete(e,t,r){let o=Date.now(),i=(await this.write("complete",async()=>this.db.update(Y).set({status:Oe.COMPLETED,result:t,lastError:null,lastErrorPublic:null,completedAt:o,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o)}).where(this.attemptWriteGuard(e,r)).returning({id:Y.id}))).length===1;if(i)this.logger.debug("Job completed",{jobId:e,hasResult:t!==void 0});return i}async update(e,t,r){let n=(await this.write("update",async()=>this.db.update(Y).set({data:JSON.stringify(t)}).where(this.attemptWriteGuard(e,r)).returning({id:Y.id}))).length===1;if(n)this.logger.debug("Job data updated",{jobId:e});return n}async recordAttemptProgress(e,t,r,o=Date.now()){return(await this.write("record progress",async()=>this.db.update(Y).set({attemptHeartbeatAt:o,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o),progress:r}).where(this.attemptWriteGuard(e,t)).returning({id:Y.id}))).length===1}async renewAttemptLease(e,t,r,o){return(await this.write("renew attempt lease",async()=>this.db.update(Y).set({attemptHeartbeatAt:r,leaseExpiresAt:r+o}).where(this.attemptWriteGuard(e,t)).returning({id:Y.id}))).length===1}async fail(e,t,r,o=Date.now()){let i=(await this.db.select({retryCount:Y.retryCount,maxRetries:Y.maxRetries,type:Y.type,scheduledFor:Y.scheduledFor,startedAt:Y.startedAt,runtimeUpdatedAt:Y.runtimeUpdatedAt}).from(Y).where(this.attemptWriteGuard(e,r)).limit(1))[0];if(!i)return!1;let s=i.retryCount<i.maxRetries,a=s?i.retryCount+1:i.retryCount,c=Math.min(1000*2**i.retryCount,60000),u=s?o+c:i.scheduledFor;if((await this.write("fail",async()=>this.db.update(Y).set({status:s?Oe.PENDING:Oe.FAILED,retryCount:a,lastError:t.message,lastErrorPublic:Y_(t).toJSON(),scheduledFor:u,completedAt:s?null:o,runtimeUpdatedAt:s?i.runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o),startedAt:s?null:i.startedAt,attemptId:null,workerSlotId:null,workerSessionId:null,leaseExpiresAt:null,attemptHeartbeatAt:null}).where(tt(this.attemptWriteGuard(e,r),je(Y.retryCount,i.retryCount))).returning({id:Y.id}))).length!==1)return!1;if(s)this.logger.debug("Job scheduled for retry",{jobId:e,retryCount:a,backoffMs:c,scheduledFor:new Date(u).toISOString()});else this.logger.error("Job failed after max retries",{jobId:e,type:i.type,retryCount:i.retryCount,error:t.message});return!0}async retireUnownedActiveJob(e){let t=e.reason.trim();if(t.length===0)throw Error("Retired job reason must not be empty");let o=(await this.write("retire unowned job",async()=>this.db.update(Y).set({status:Oe.FAILED,lastError:t,lastErrorPublic:new Ya("no_handler").toJSON(),completedAt:e.now,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(e.now)}).where(tt(je(Y.id,e.jobId),je(Y.type,e.expectedType),nn(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)),jr(Y.attemptId),jr(Y.workerSlotId),jr(Y.workerSessionId),jr(Y.leaseExpiresAt),jr(Y.attemptHeartbeatAt),jr(Y.progress),jr(Y.result))).returning()))[0]??null;if(o)this.logger.warn("Retired unowned legacy job",{jobId:o.id,type:o.type,reason:t});return o}async getStatus(e){return(await this.db.select().from(Y).where(je(Y.id,e)).limit(1))[0]??null}async getJobsByRootJobId(e){return this.db.select().from(Y).where(C`json_extract(${Y.metadata}, '$.rootJobId') = ${e}`).orderBy(Lo(Y.createdAt),Lo(Y.id))}async getStatusByEntityId(e){return(await this.db.select().from(Y).where(C`json_extract(${Y.data}, '$.id') = ${e}`).orderBy(ia(Y.createdAt)).limit(1))[0]??null}async getStats(){let e=await this.db.select({status:Y.status,count:C`count(*)`}).from(Y).groupBy(Y.status),t={pending:0,processing:0,failed:0,completed:0,total:0};for(let r of e){let o=Number(r.count);t[r.status]=o,t.total+=o}return t}async getDiagnostics(e=Date.now()){let[t,r,o]=await Promise.all([this.db.select({type:Y.type,status:Y.status,count:C`count(*)`}).from(Y).groupBy(Y.type,Y.status),this.db.select({oldestPendingAt:C`min(case when ${Y.status} = ${Oe.PENDING} then ${Y.createdAt} end)`,duePending:C`coalesce(sum(case when ${Y.status} = ${Oe.PENDING} and ${Y.scheduledFor} <= ${e} then 1 else 0 end), 0)`,oldestDuePendingAt:C`min(case when ${Y.status} = ${Oe.PENDING} and ${Y.scheduledFor} <= ${e} then ${Y.scheduledFor} end)`,latestClaimAt:C`max(${Y.startedAt})`,oldestProcessingAt:C`min(case when ${Y.status} = ${Oe.PROCESSING} then ${Y.startedAt} end)`,staleLeaseCount:C`coalesce(sum(case when ${Y.status} = ${Oe.PROCESSING} and ${Y.leaseExpiresAt} is not null and ${Y.leaseExpiresAt} <= ${e} then 1 else 0 end), 0)`}).from(Y),this.db.select({total:C`count(*)`,active:C`coalesce(sum(case when ${qe.expiresAt} > ${e} then 1 else 0 end), 0)`,stale:C`coalesce(sum(case when ${qe.expiresAt} <= ${e} then 1 else 0 end), 0)`,latestHeartbeatAt:C`max(${qe.heartbeatAt})`}).from(qe)]),n={pending:0,processing:0,completed:0,failed:0},i=t.map((u)=>{let d=Number(u.count);return n[u.status]+=d,{type:u.type,status:u.status,count:d}}),s=r[0],a=o[0],c=(u)=>u===null||u===void 0?null:Math.max(0,e-Number(u));return{totals:n,byType:i,oldestPendingAgeMs:c(s?.oldestPendingAt),duePending:Number(s?.duePending??0),oldestDuePendingAgeMs:c(s?.oldestDuePendingAt),latestClaimAgeMs:c(s?.latestClaimAt),oldestProcessingAgeMs:c(s?.oldestProcessingAt),staleLeaseCount:Number(s?.staleLeaseCount??0),workerSessions:{total:Number(a?.total??0),active:Number(a?.active??0),stale:Number(a?.stale??0),latestHeartbeatAgeMs:c(a?.latestHeartbeatAt)}}}async getRuntimeUpdates(e,t){let r=Spe.parse(t);if(r===0)return[];return(await this.db.select().from(Y).where(C`(${Y.runtimeUpdatedAt}, ${Y.id}) > (${e.updatedAt}, ${e.jobId})`).orderBy(Lo(Y.runtimeUpdatedAt),Lo(Y.id)).limit(r)).map((n)=>({job:n,cursor:{updatedAt:n.runtimeUpdatedAt??0,jobId:n.id}}))}async cleanup(e){let t=Date.now()-e;return(await this.write("cleanup",async()=>this.db.delete(Y).where(tt(nn(je(Y.status,Oe.COMPLETED),je(Y.status,Oe.FAILED)),Vi(Y.completedAt,t))))).rowsAffected}async getActiveJobs(e){let t=nn(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)),r=e&&e.length>0?tt(t,Wi(Y.type,e)):t;return this.db.select().from(Y).where(r).orderBy(ia(Y.createdAt))}async getRecentJobs(e,t=20){let r=e&&e.length>0?Wi(Y.type,e):void 0;return this.db.select().from(Y).where(r).orderBy(ia(Y.createdAt)).limit(t)}async getFailedJobs(e){let t=je(Y.status,Oe.FAILED),r=e&&e.length>0?tt(t,Wi(Y.type,e)):t;return this.db.select().from(Y).where(r).orderBy(ia(Y.createdAt))}async claimNextReady(e){let{now:t,attemptId:r,workerSlotId:o,workerSessionId:n,leaseDurationMs:i,executableTypes:s,exclusiveTypes:a=[],brainVersion:c}=e,u=c?this.brainVersionGate(c,t):{admissible:void 0,noNewerWorker:void 0},d=this.db.select({slotId:qe.slotId}).from(qe).where(tt(je(qe.slotId,o),je(qe.sessionId,n),wn(qe.expiresAt,t))),f=this.noNewerLiveInstance(o,n,t),m=this.db.select({slotId:qe.slotId}).from(qe).where(tt(je(qe.slotId,Y.workerSlotId),je(qe.sessionId,Y.workerSessionId))),h=tt(je(Y.status,Oe.PROCESSING),nn(jr(Y.attemptId),Gi(m),Vi(Y.leaseExpiresAt,t))),b=Ly(Y,"running"),y=this.db.select({id:b.id}).from(b).where(tt(je(b.type,Y.type),je(b.status,Oe.PROCESSING),wn(b.leaseExpiresAt,t),C`${b.id} <> ${Y.id}`)),S=a.length===0?void 0:nn(_y(Y.type,[...a]),Gi(y)),x=C`${Y.status} = ${Oe.PROCESSING} AND ${Y.retryCount} + 1 > ${Y.maxRetries}`,_=this.db.select({id:Y.id}).from(Y).where(tt(Wi(Y.type,s),S,u.admissible,nn(tt(je(Y.status,Oe.PENDING),Vi(Y.scheduledFor,t)),h))).orderBy(Lo(Y.priority),Lo(Y.createdAt)).limit(1),O=(await this.write("claim",async()=>this.db.update(Y).set({status:C`CASE WHEN ${x} THEN ${Oe.FAILED} ELSE ${Oe.PROCESSING} END`,retryCount:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN ${Y.retryCount} + 1 ELSE ${Y.retryCount} END`,lastError:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN 'Attempt lease expired' ELSE ${Y.lastError} END`,lastErrorPublic:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN ${E3("deadline_exceeded")} ELSE ${Y.lastErrorPublic} END`,startedAt:C`CASE WHEN ${x} THEN ${Y.startedAt} ELSE ${t} END`,completedAt:C`CASE WHEN ${x} THEN ${t} ELSE NULL END`,attemptId:C`CASE WHEN ${x} THEN ${Y.attemptId} ELSE ${r} END`,workerSlotId:C`CASE WHEN ${x} THEN ${Y.workerSlotId} ELSE ${o} END`,workerSessionId:C`CASE WHEN ${x} THEN ${Y.workerSessionId} ELSE ${n} END`,leaseExpiresAt:C`CASE WHEN ${x} THEN ${Y.leaseExpiresAt} ELSE ${t+i} END`,attemptHeartbeatAt:C`CASE WHEN ${x} THEN ${Y.attemptHeartbeatAt} ELSE ${t} END`,runtimeUpdatedAt:C`CASE WHEN ${x} THEN ${this.nextRuntimeUpdatedAt(t)} ELSE ${Y.runtimeUpdatedAt} END`}).where(tt(Wi(Y.id,_),Ey(d),f,u.noNewerWorker)).returning()))[0];if(!O)return null;if(O.status===Oe.FAILED)return O;return this.logger.debug("Job claimed",{jobId:O.id,attemptId:O.attemptId,workerSlotId:o,workerSessionId:n}),O}noNewerLiveInstance(e,t,r){let o=Ly(qe,"claimer"),n=Ly(qe,"peer"),i=this.db.select({slotId:n.slotId}).from(n).innerJoin(o,tt(je(o.slotId,e),je(o.sessionId,t))).where(tt(je(n.stableSlotId,o.stableSlotId),wn(n.expiresAt,r),nn(wn(n.startedAt,o.startedAt),tt(je(n.startedAt,o.startedAt),wn(n.slotId,o.slotId)))));return Gi(i)}brainVersionGate(e,t){let r=$f(e),o=this.db.select({slotId:qe.slotId}).from(qe).where(tt(wn(qe.expiresAt,t),wn(qe.brainVersionSortKey,r)));return{admissible:nn(jr(Y.brainVersionSortKey),Vi(Y.brainVersionSortKey,r)),noNewerWorker:Gi(o)}}nextRuntimeUpdatedAt(e){return C`max(${e}, coalesce((select max(${Y.runtimeUpdatedAt}) from ${Y}), 0) + 1)`}attemptWriteGuard(e,t){return t?tt(je(Y.id,e),je(Y.status,Oe.PROCESSING),je(Y.attemptId,t)):tt(je(Y.id,e),jr(Y.attemptId),nn(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)))}}var gpe=2000,ype=5,bpe=40,Spe,vpe;var I3=w(()=>{q$();jy();M$();Mt();he();Oo();qd();v3();H$();Spe=l.number().int().min(0).max(1000),vpe=new J$});import{AsyncLocalStorage as wpe}from"async_hooks";class Rf{storage=new wpe;static createFresh(){return new Rf}constructor(){}current(){return this.storage.getStore()}run(e,t,r){if(t.length===0)throw Error("Operation ID must not be empty");let o=ni.parse(e),n=xpe(o);return this.storage.run(Object.freeze({provenance:n,operationId:t}),r)}}function xpe(e){if(Object.freeze(e.projectionLineage),e.sourceEntity)Object.freeze(e.sourceEntity);return Object.freeze(e)}var W$=w(()=>{Mt()});class Of{client;logger;handlerRegistry;repository;walInitialization=null;walInitializationSettled=!1;closeRequested=!1;clientClosed=!1;inFlightEnqueues=0;databaseUrl;operationContext;projectionAdmission;directWorkerSlotId=`direct:${Ro()}`;directWorkerSessionId=Ro();directLeaseDurationMs;directSessionStart=null;brainVersion;close(){this.closeRequested=!0,this.closeClientWhenReady()}static createFresh(e,t,r){return new Of(e,t??kr.getInstance(),r)}constructor(e,t,r){this.brainVersion=e.brainVersion===void 0?void 0:x3.parse(e.brainVersion);let{db:o,client:n,url:i}=b3(e);this.client=n,this.databaseUrl=i,this.logger=t.child("JobQueueService"),this.operationContext=r?.operationContext??Rf.createFresh(),this.projectionAdmission=r?.projectionAdmission,this.handlerRegistry=new F$(this.logger,r?.handlerRegistrationMode??"combined"),this.repository=new V$(o,n,i,this.logger),this.directLeaseDurationMs=e.claimTimeoutMs??300000}initialize(){if(this.closeRequested)return Promise.resolve();return this.walInitialization??=this.initializeWALMode(),this.walInitialization}async initializeWALMode(){try{await Jy(this.client,this.databaseUrl)}catch(e){this.logger.warn("Failed to enable WAL mode (non-fatal)",e)}finally{this.walInitializationSettled=!0,this.closeClientWhenReady()}}closeClientWhenReady(){if(!this.closeRequested||this.inFlightEnqueues>0||this.walInitialization!==null&&!this.walInitializationSettled)return;this.closeClient()}closeClient(){if(this.clientClosed)return;this.clientClosed=!0,this.client.close()}registerHandler(e,t,r){this.handlerRegistry.registerHandler(e,t,r)}unregisterHandler(e){this.handlerRegistry.unregisterHandler(e)}unregisterPluginHandlers(e){this.handlerRegistry.unregisterPluginHandlers(e)}getRegisteredTypes(){return this.handlerRegistry.getRegisteredTypes()}getHandler(e){return this.handlerRegistry.getHandler(e)}getValidator(e){return this.handlerRegistry.getValidator(e)}finalizeHandlerRegistrations(){return this.handlerRegistry.finalizeRegistrations()}getExecutionRegistrations(){return this.handlerRegistry.getExecutionRegistrations()}async enqueue(e){if(this.closeRequested)throw Error("Cannot enqueue a job after the queue service is closed");this.inFlightEnqueues++;try{return await this.enqueueValidated(e)}finally{this.inFlightEnqueues--,this.closeClientWhenReady()}}async enqueueValidated(e){let{type:t,data:r,options:o}=e,n=this.handlerRegistry.getValidator(t);if(!n)throw Error(`No job type declared: ${t}`);let i=n.validateAndParse(r);if(i===null)throw Error(`Invalid job data for type: ${t}`);let s=Date.now(),a=Ro(),c=o?.rootJobId??(o?.detached?a:this.operationContext.current()?.provenance.rootJobId)??a,u=this.createJobProvenance(a,c,o),d=o?.metadata??{operationType:"data_processing"},{provenance:f,...m}=d,h={id:a,type:t,data:JSON.stringify(i),status:Oe.PENDING,priority:o?.priority??0,maxRetries:o?.maxRetries??3,retryCount:0,source:o?.source??null,metadata:{...m,...o?.deduplicationKey&&{deduplicationKey:o.deduplicationKey},rootJobId:c,provenance:u},createdAt:s,scheduledFor:o?.delayMs?s+o.delayMs:s,result:null,lastError:null,startedAt:null,completedAt:null,brainVersion:this.brainVersion},b,y=()=>{b?.rollback(),b=void 0};try{let S=await this.repository.enqueueAtomic({jobData:h,strategy:o?.deduplication,deduplicationKey:o?.deduplicationKey,beforeInsert:async()=>{b=await this.projectionAdmission?.reserveJobAdmission(u)},onInsertRollback:y});if(b?.commit(),b=void 0,S.kind==="skipped")this.logger.debug("Skipping duplicate job (already pending)",{type:t,existingJobId:S.jobId});else if(S.kind==="coalesced")this.logger.debug("Coalescing with existing job",{type:t,existingJobId:S.jobId});else{if(S.kind==="replaced")this.logger.debug("Replacing duplicate job",{type:t,oldJobId:S.replacedJobId});this.logger.debug("Job enqueued",{id:S.jobId,type:t,priority:h.priority,rootJobId:h.metadata.rootJobId})}return S.jobId}catch(S){throw y(),this.logger.error("Failed to enqueue job",{type:t,error:Ge(S)}),S}}createJobProvenance(e,t,r){let o=this.operationContext.current(),n=r?.metadata.provenance??o?.provenance,i=n?.rootJobId===t?n:void 0,s=o?.provenance.rootJobId===t?o.operationId:void 0,a=r?.projection,c=a?[...i?.projectionLineage??[],a.id]:[...i?.projectionLineage??[]],u=a?.id??i?.projectionId;return ni.parse({rootJobId:t,causationId:s??i?.causationId??e,...u?{projectionId:u}:{},projectionLineage:c,...a?.sourceEntity?{sourceEntity:a.sourceEntity}:i?.sourceEntity?{sourceEntity:i.sourceEntity}:{},derivationDepth:c.length})}async dequeue(e){let t=this.handlerRegistry.getRegisteredTypes();if(t.length===0)return null;let{onTerminalReclaim:r,...o}=e??await this.getDirectClaimOptions(),n=Date.now(),i=await this.repository.claimNextReady({...o,workerSlotId:this.sessionSlotId(o.workerSlotId,o.workerSessionId),brainVersion:this.brainVersion,now:n,attemptId:Ro(),executableTypes:t,exclusiveTypes:this.handlerRegistry.getExclusiveTypes()});if(!i)return null;if(i.status===Oe.FAILED)return this.logger.warn("Expired attempt failed terminally on reclaim",{id:i.id,type:i.type,retryCount:i.retryCount}),await r?.(i),null;return this.logger.debug("Job dequeued",{id:i.id,type:i.type,priority:i.priority,retryCount:i.retryCount,attemptId:i.attemptId,workerSlotId:i.workerSlotId,workerSessionId:i.workerSessionId}),i}async startWorkerSession(e,t,r=Di){await this.repository.startWorkerSession(this.sessionSlotId(e,t),t,Date.now(),r,this.brainVersion,this.versionedSlotId(e))}heartbeatWorkerSession(e,t,r=Di){return this.repository.heartbeatWorkerSession(this.sessionSlotId(e,t),t,Date.now(),r)}endWorkerSession(e,t){return this.repository.endWorkerSession(this.sessionSlotId(e,t),t)}versionedSlotId(e){return this.brainVersion?`${e}@${this.brainVersion}`:e}sessionSlotId(e,t){return`${this.versionedSlotId(e)}#${t}`}renewAttemptLease(e,t,r){return this.repository.renewAttemptLease(e,t,Date.now(),r)}recordAttemptProgress(e,t,r){return this.repository.recordAttemptProgress(e,t,r)}complete(e,t,r){return this.repository.complete(e,t,r)}update(e,t,r){return this.repository.update(e,t,r)}fail(e,t,r){return this.repository.fail(e,t,r)}retireUnownedActiveJob(e){return this.repository.retireUnownedActiveJob(e)}async getDirectClaimOptions(){return this.directSessionStart??=this.repository.startWorkerSession(this.sessionSlotId(this.directWorkerSlotId,this.directWorkerSessionId),this.directWorkerSessionId,Date.now(),this.directLeaseDurationMs,this.brainVersion),await this.directSessionStart,{workerSlotId:this.directWorkerSlotId,workerSessionId:this.directWorkerSessionId,leaseDurationMs:this.directLeaseDurationMs}}async getStatus(e){return this.repository.getStatus(e)}async getJobsByRootJobId(e){return this.repository.getJobsByRootJobId(e)}async getStatusByEntityId(e){return this.repository.getStatusByEntityId(e)}async getStats(){return this.repository.getStats()}getDiagnostics(e){return this.repository.getDiagnostics(e)}async waitForIdle(e={}){let t=e.quietMs??250,r=e.pollIntervalMs??25,o=Date.now()+(e.timeoutMs??30000),n=async(i)=>{e.signal?.throwIfAborted();let{totals:s}=await this.getDiagnostics(),c=s.pending===0&&s.processing===0?i??Date.now():null;if(c!==null&&Date.now()-c>=t)return;if(Date.now()>=o)throw Error(`Timed out waiting for the job queue to settle: ${s.pending} pending, ${s.processing} processing`);return await Bun.sleep(r),n(c)};return n(null)}getRuntimeUpdates(e,t=1000){return this.repository.getRuntimeUpdates(e,t)}async cleanup(e){let t=await this.repository.cleanup(e);if(t>0)this.logger.info("Cleaned up old jobs",{deletedCount:t,olderThanMs:e});return t}async getActiveJobs(e){return this.repository.getActiveJobs(e)}async getRecentJobs(e,t){return this.repository.getRecentJobs(e,t)}async getFailedJobs(e){return this.repository.getFailedJobs(e)}}var k3=w(()=>{Zd();XA();qd();Oo();U$();S3();I3();Mt();W$();H$()});var G$=()=>{};var A3=w(()=>{Zd();Oo();qd();Oo();G$();W$()});var T3=w(()=>{Oo();G$()});var X4e;var $3=w(()=>{he();Ud();Oo();X4e=l.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},l.record(l.string(),l.unknown()))});var rqe;var R3=w(()=>{he();rqe=l.record(l.string(),l.unknown())});var O3=w(()=>{Mt();Zd()});var C3=w(()=>{k3();A3();T3();$3();R3();qd();Oo();Ud();O3()});var Q$={};Ut(Q$,{LEGACY_PROJECTION_JOB_TYPES:()=>z3,LEGACY_PROJECTION_RETIREMENT_REASON:()=>D3,legacyProjectionJobTypeSchema:()=>N3,retireLegacyProjectionJob:()=>Cpe});import{existsSync as $pe}from"fs";import{resolve as Rpe}from"path";function P3(e){return{id:e.id,type:e.type,status:e.status,retryCount:e.retryCount,maxRetries:e.maxRetries,createdAt:e.createdAt,startedAt:e.startedAt,completedAt:e.completedAt}}function Ope(e,t){if(e.type!==t)throw Error(`Job ${e.id} has type ${e.type}; expected ${t}`);if(e.status!=="pending"&&e.status!=="processing")throw Error(`Job ${e.id} is already terminal (${e.status})`);if(e.attemptId!==null||e.workerSlotId!==null||e.workerSessionId!==null||e.leaseExpiresAt!==null||e.attemptHeartbeatAt!==null)throw Error(`Job ${e.id} still has attempt ownership`);if(e.progress!==null||e.result!=null)throw Error(`Job ${e.id} contains partial progress or a result`)}async function Cpe(e){let t=Rpe(e.databasePath);if(!$pe(t))throw Error(`Job database does not exist: ${t}`);let r=N3.parse(e.jobType),o=Of.createFresh({url:`file:${t}`});try{let n=await o.getStatus(e.jobId);if(!n)throw Error(`Job not found: ${e.jobId}`);if(Ope(n,r),e.dryRun){if(e.confirmation!==void 0)throw Error("Dry-run recovery must not include confirmation");return{databasePath:t,job:P3(n),retired:!1}}let i=`retire:${n.id}`;if(e.confirmation!==i)throw Error(`Refusing to retire ${n.id}; expected --confirm ${i}`);let s=await o.retireUnownedActiveJob({jobId:n.id,expectedType:r,reason:D3,now:e.now?.()??Date.now()});if(!s)throw Error(`Job ${n.id} changed or acquired ownership before retirement`);return{databasePath:t,job:P3(s),retired:!0}}finally{o.close()}}var z3,N3,D3="Retired legacy projection job superseded by scheduler-owned projections";var Y$=w(()=>{C3();he();z3=["conversation-memory:project","skill:project","swot:derive","topic:project"],N3=l.enum(z3)});function Zt(e,t,r,o,n){return B3.parse({id:e,operation:t,count:r,targetProbeCount:o,settleMs:n})}function eR(e){return Pf.parse(structuredClone(Dpe[e]))}function zf(e){let t=`stress:${e.handle}`;if(e.confirmation!==t)throw Error(`Directory-sync stress requires --confirm ${t}`);let r=/(^|[-_.])smoke($|[-_.])/i;if(!r.test(e.handle)||!r.test(e.domain)||!r.test(e.contentRepo))throw Error("Directory-sync stress is smoke-only; handle, domain, and content repository must all identify smoke")}async function Hy(e,t={}){let r=t.fetchImpl??fetch,o=t.now??(()=>new Date),n=t.timeoutMs??20000,i=o(),s=new AbortController,a=setTimeout(()=>s.abort(),n);try{let c=await r(e,{method:"GET",signal:s.signal});return await c.arrayBuffer(),X$.parse({timestamp:i.toISOString(),endpoint:new URL(e).pathname,status:c.status,durationMs:Math.max(0,o().getTime()-i.getTime()),ok:c.ok})}catch(c){return X$.parse({timestamp:i.toISOString(),endpoint:new URL(e).pathname,status:0,durationMs:Math.max(0,o().getTime()-i.getTime()),ok:!1,error:Lpe(c)})}finally{clearTimeout(a)}}async function tR(e,t){let r=Pf.parse(e),o=[],n,i=await t.prepare(r),s,a;try{try{await t.startMonitoring()}catch(c){n=`monitor: ${Ky(c)}`}if(!n)for(let c of r.phases)try{let u=j3.parse(await t.executePhase(c,i));if(o.push(u),!u.success){n=`${c.id}: ${u.error??"phase failed"}`;break}}catch(u){let d=Ky(u);o.push({id:c.id,operation:c.operation,count:c.count,success:!1,error:d}),n=`${c.id}: ${d}`;break}}finally{try{if(s=Z3.parse(await t.cleanup(i)),!s.success&&!n)n=s.error??"cleanup failed"}catch(c){let u=Ky(c);s={success:!1,probesRemaining:0,error:u},n??=`cleanup: ${u}`}try{a=U3.parse(await t.stopMonitoring())}catch(c){let u=Ky(c);a={health:[],runtime:[]},n??=`monitor: ${u}`}}return n??=M3(a,r.maximumExternalAiCalls??0),q3.parse({profile:r.profile,success:n===void 0&&o.length===r.phases.length&&s.success,baseline:i,phases:o,cleanup:s,metrics:a,...n?{failure:n}:{}})}function M3(e,t=0){let r=e.health.find((i)=>!i.ok);if(r)return`health: ${r.endpoint} unavailable`;let o=e.externalAiCalls??0;if(o>t)return t===0?`external AI: observed ${o} call(s)`:`external AI: observed ${o} call(s), cap ${t}`;if(e.container?.oomKilled)return"container: OOM killed";let n=e.container?.restartCount??0;if(n>0)return`container: restarted ${n} time(s)`;if(e.container&&e.container.status!=="running")return`container: ${e.container.status}`;return}function Lpe(e){if(e instanceof Error)return`${e.name}: ${e.message}`;return String(e)}function Ky(e){return Ge(e)}var Cf,L3,B3,Pf,Ppe,X$,zpe,j3,Z3,Npe,U3,q3,Dpe;var Vy=w(()=>{he();Cf=l.enum(["regression","load","stress"]),L3=l.enum(["add","update","rename","delete"]),B3=l.object({id:l.string().min(1),operation:L3,count:l.number().int().positive().max(700),targetProbeCount:l.number().int().min(0).max(700),settleMs:l.number().int().nonnegative().max(300000)}),Pf=l.object({profile:Cf,maximumProbeCount:l.number().int().positive().max(700),maximumExternalAiCalls:l.number().int().nonnegative().max(1e4).optional(),phases:l.array(B3).min(1)}),Ppe=l.object({entities:l.number().int().nonnegative(),notes:l.number().int().nonnegative(),version:l.string().min(1)}),X$=l.object({timestamp:l.iso.datetime(),endpoint:l.string().startsWith("/"),status:l.number().int().nonnegative(),durationMs:l.number().nonnegative(),ok:l.boolean(),error:l.string().optional()}),zpe=l.object({timestamp:l.iso.datetime(),cpuPercent:l.number().nonnegative(),memoryPercent:l.number().nonnegative(),pids:l.number().int().nonnegative()}),j3=l.object({id:l.string().min(1),operation:L3,count:l.number().int().positive(),success:l.boolean(),commitLatencyMs:l.number().nonnegative().optional(),persistenceLatencyMs:l.number().nonnegative().optional(),error:l.string().optional()}),Z3=l.object({success:l.boolean(),probesRemaining:l.number().int().nonnegative(),finalEntities:l.number().int().nonnegative().optional(),finalNotes:l.number().int().nonnegative().optional(),contentTreeRestored:l.boolean().optional(),error:l.string().optional()}),Npe=l.object({status:l.string(),restartCount:l.number().int().nonnegative(),oomKilled:l.boolean()}),U3=l.object({health:l.array(X$),runtime:l.array(zpe),externalAiCalls:l.number().int().nonnegative().optional(),container:Npe.optional()}),q3=l.object({profile:Cf,success:l.boolean(),baseline:Ppe,phases:l.array(j3),cleanup:Z3,metrics:U3,failure:l.string().optional()}),Dpe={regression:{profile:"regression",maximumProbeCount:20,phases:[Zt("add20","add",20,20,0),Zt("update20","update",20,20,30000),Zt("delete20","delete",20,0,150000)]},load:{profile:"load",maximumProbeCount:350,phases:[Zt("add50","add",50,50,0),Zt("add150","add",100,150,0),Zt("add350","add",200,350,0),Zt("update350a","update",350,350,45000),Zt("rename100","rename",100,350,45000),Zt("update350b","update",350,350,45000),Zt("delete350","delete",350,0,150000)]},stress:{profile:"stress",maximumProbeCount:700,phases:[Zt("add50","add",50,50,0),Zt("add150","add",100,150,0),Zt("add350","add",200,350,0),Zt("add700","add",350,700,0),Zt("update700a","update",700,700,45000),Zt("rename200","rename",200,700,45000),Zt("update700b","update",700,700,45000),Zt("delete700","delete",700,0,150000)]}}});import{spawn as Bpe}from"child_process";async function F3(e,t,r,o){let n=await e(t,r,o);if(n.exitCode!==0)throw eo(t,r,n);return n}function eo(e,t,r){let o=r.stderr.trim()||r.stdout.trim();return Error(`${e} ${t.join(" ")} exited with ${r.exitCode}${o?`: ${o}`:""}`)}var Mo=async(e,t,r={})=>new Promise((o,n)=>{let i=Bpe(e,[...t],{cwd:r.cwd,env:r.env?{...process.env,...r.env}:process.env,stdio:["pipe","pipe","pipe"]}),s="",a="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",(c)=>{s+=c}),i.stderr.on("data",(c)=>{a+=c}),i.on("error",n),i.on("close",(c)=>{o({exitCode:c??1,stdout:s,stderr:a})}),i.stdin.end(r.stdin)});var Nf=()=>{};class Il{#e;#t;dir;constructor(e,t,r){this.#e=e,this.dir=t,this.#t=r}static async clone(e,t,r,o){let n=new Il(e,r,o);return await F3(e,"git",["-c","credential.helper=","-c",`credential.helper=${J3}`,"clone","--branch","main","--single-branch",`https://github.com/${t}.git`,r],{env:n.environment()}),await n.run(["config","--local","credential.helper",J3]),await n.run(["reset","--hard","origin/main"]),n}async run(e,t=!0){let r=await this.#e("git",e,{cwd:this.dir,env:this.environment()});if(t&&r.exitCode!==0)throw eo("git",e,r);return r}async output(e){return(await this.run(e)).stdout.trim()}async sync(e=!1){if(await this.run(["fetch","origin","main"]),e)await this.run(["reset","--hard","origin/main"]);else await this.run(["pull","--rebase","origin","main"])}async commitAll(e){await this.run(["add","-A"]),await this.run(["-c","user.name=brains-ops","-c","user.email=ops@rizom.ai","commit","-m",e])}async pushMainWithRebase(){for(let e=1;e<=5;e+=1){if((await this.run(["push","origin","main"],!1)).exitCode===0)return;await this.run(["pull","--rebase","origin","main"])}throw Error("Unable to push content main after five rebase attempts")}async pruneStressBackupBranches(){let t=(await this.run(["ls-remote","--heads","origin","refs/heads/ops/directory-sync-stress-backup-*"])).stdout.split(/\r?\n/).map((r)=>r.match(/\trefs\/heads\/(ops\/directory-sync-stress-backup-[^\s]+)$/)?.[1]).filter((r)=>r!==void 0).sort();for(let r of t)await this.run(["push","origin","--delete",r]);return t}environment(){return{GH_TOKEN:this.#t,GITHUB_TOKEN:this.#t}}}var J3='!f() { test "$1" = get && echo username=x-access-token && echo "password=$GH_TOKEN"; }; f';var K3=w(()=>{Nf()});function Df(e){return e.entityCounts.find((t)=>t.entityType==="note")?.count??0}class rR{#e;#t=[];#r=[];#n=new Set(["/health/ready"]);#o=!0;#i;#a;#s="";#c=0;#l;constructor(e){this.#e=e}get startedAt(){return this.#s}get error(){return this.#a}get healthSamples(){return this.#t}get runtimeSamples(){return this.#r}gateHealthSamples(){return this.#t.slice(this.#c,this.#l??this.#t.length)}markGateEnd(){this.#l=this.#t.length}async discoverEndpoints(){for(let e of["/health/live","/health/operate"])if((await Hy(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:5000})).status!==404)this.#n.add(e)}start(){this.#o=!1,this.#a=void 0,this.#c=this.#t.length,this.#l=void 0,this.#s=this.#e.now().toISOString(),this.#i=Promise.all([this.#m(),this.#p()]).then(()=>{return}).catch((e)=>{this.#a=e,this.#o=!0})}async stop(){this.#o=!0,await this.#i}async waitForHealthSnapshot(e){return this.waitForEntityBaseline(void 0,void 0,e)}async waitForEntityBaseline(e,t,r){let o=this.#e.now().getTime();while(this.#e.now().getTime()-o<r){let n=await this.fetchHealthPayload();if(this.#f(n,e,t))return n;await this.#e.sleep(5000)}return}async waitForStableEntityBaseline(e,t,r){let o=this.#e.now().getTime(),n=0;while(this.#e.now().getTime()-o<r){let i=await this.fetchHealthPayload();if(this.#f(i,e,t)){if(n+=1,n===2)return i}else n=0;await this.#e.sleep(5000)}return}async fetchHealthPayload(){let e=await this.#d();if(e===void 0)return;let t=await this.#e.readEntityCounts();if(!t)return;return{version:e,entities:t.reduce((r,o)=>r+o.count,0),entityCounts:t}}async#d(){let e=this.#e.now(),t=new AbortController,r=setTimeout(()=>t.abort(),20000);try{let o=await this.#e.fetchImpl(`https://${this.#e.domain}/health/operate`,{signal:t.signal}),n=await o.text();if(this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:o.status,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:o.ok}),!o.ok)return;return jpe.parse(JSON.parse(n)).app.version}catch(o){this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:0,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:!1,error:o instanceof Error?`${o.name}: ${o.message}`:String(o)});return}finally{clearTimeout(r)}}#f(e,t,r){return e!==void 0&&(t===void 0||Df(e)===t)&&(r===void 0||e.entities===r)}async#m(){while(!this.#o){for(let e of this.#n)this.#t.push(await Hy(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:20000}));await this.#e.sleep(4000)}}async#p(){while(!this.#o){let e=await this.#e.sampleRuntime();if(e)this.#r.push(e);await this.#e.sleep(1000)}}}var H3,jpe;var V3=w(()=>{he();Vy();H3=l.array(l.object({entityType:l.string(),count:l.number().int().nonnegative()})),jpe=l.object({status:l.literal("ready"),operationalStatus:l.literal("operational"),app:l.object({version:l.string()})})});var Wy={};Ut(Wy,{applyDirectorySyncStressPhase:()=>t5,cleanupDirectorySyncStress:()=>Y3,listProbeFiles:()=>la,parseStressRuntimeSample:()=>r5,removeProbeFiles:()=>lR,runDeployedDirectorySyncStress:()=>G3,runStressCommand:()=>Mo,verifyDirectorySyncStressAccess:()=>Q3});import{chmod as Zpe,mkdir as oR,mkdtemp as iR,readFile as Upe,readdir as qpe,rename as Mpe,rm as Bf,writeFile as En}from"fs/promises";import{tmpdir as sR}from"os";import{join as ct,resolve as aR}from"path";async function G3(e){let t=e.now??(()=>new Date),r=t().toISOString(),o=uR(r),n=aR(e.artifactsDir??ct(e.rootDir,".brains-ops","stress",o));await oR(n,{recursive:!0});let{pilot:i,user:s}=await cR(e.rootDir,e.handle);zf({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation});let a=Cf.parse(e.profile),c=e.plan?Pf.parse(e.plan):eR(a);if(c.profile!==a)throw Error(`Directory-sync stress plan profile ${c.profile} does not match requested profile ${a}`);if((c.maximumExternalAiCalls??0)===0)e5(s);let u=Fpe.parse(e.env??process.env),d=new X3({runId:o,artifactsDir:n,user:s,githubOrg:i.githubOrg,serverLabel:`${i.contentRepoPrefix}${s.handle}`,environment:u,fetchImpl:e.fetchImpl??fetch,commandRunner:e.commandRunner??Mo,logger:e.logger??console.info,now:t,sleep:e.sleep??Bun.sleep}),f;try{f=await tR(c,d)}finally{await d.dispose()}let m={runId:o,artifactsDir:n,target:{handle:s.handle,domain:s.domain,contentRepo:`${i.githubOrg}/${s.contentRepo}`},startedAt:r,completedAt:t().toISOString(),report:f};return await Gpe(m),m}async function Q3(e){let r=(e.now??(()=>new Date))().toISOString(),o=uR(r),n=aR(e.artifactsDir??ct(e.rootDir,".brains-ops","stress",`access-check-${o}`));await oR(n,{recursive:!0});let{pilot:i,user:s}=await cR(e.rootDir,e.handle);zf({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation}),e5(s);let a=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!a)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let c=await iR(ct(sR(),"brains-ops-directory-sync-access-check-"));try{let u=await Il.clone(e.commandRunner??Mo,`${i.githubOrg}/${s.contentRepo}`,ct(c,"content"),a),d=await u.output(["rev-parse","HEAD"]);await u.run(["push","--dry-run","origin",`HEAD:refs/heads/ops/directory-sync-stress-access-check-${o}`]);let f={success:!0,artifactsDir:n,checkedAt:r,remoteHead:d,target:{handle:s.handle,domain:s.domain,contentRepo:`${i.githubOrg}/${s.contentRepo}`}};return await En(ct(n,"access-check.json"),`${JSON.stringify(f,null,2)}
399
399
  `),f}finally{await Bf(c,{recursive:!0,force:!0})}}async function Y3(e){let t=e.now??(()=>new Date),r=aR(e.artifactsDir??ct(e.rootDir,".brains-ops","stress",`cleanup-${uR(t().toISOString())}`));await oR(r,{recursive:!0});let{pilot:o,user:n}=await cR(e.rootDir,e.handle);zf({handle:n.handle,domain:n.domain,contentRepo:n.contentRepo,confirmation:e.confirmation});let i=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!i)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let s=e.commandRunner??Mo,a=e.logger??console.info,c=await iR(ct(sR(),"brains-ops-directory-sync-cleanup-")),u=ct(c,"content");try{let d=await Il.clone(s,`${o.githubOrg}/${n.contentRepo}`,u,i),f=await lR(d.dir),m;if(f>0)await d.commitAll("test(directory-sync): clean residual stress probes"),await d.pushMainWithRebase(),m=await d.output(["rev-parse","HEAD"]),a(`Removed ${f} directory-sync stress probes`);let h=(await la(d.dir)).length,b=h===0?await d.pruneStressBackupBranches():[],y={success:h===0,artifactsDir:r,probesRemoved:f,probesRemaining:h,backupBranchesDeleted:b,...m?{cleanupCommit:m}:{}};return await En(ct(r,"cleanup.json"),`${JSON.stringify(y,null,2)}
400
- `),y}finally{await Bf(c,{recursive:!0,force:!0})}}class X3{#e;#t;#r;#n;#o;#i;#a;#s;#c;#l;#d;constructor(e){this.#e=e,this.#t=new rR({domain:e.user.domain,fetchImpl:e.fetchImpl,now:e.now,sleep:e.sleep,sampleRuntime:()=>this.#b(),readEntityCounts:()=>this.#y()})}async prepare(e){this.#r=await iR(ct(sR(),"brains-ops-directory-sync-stress-"));let t=ct(this.#r,"content");this.#o=ct(this.#r,"id_ed25519"),this.#i=ct(this.#r,"known_hosts"),this.#a=await this.#m(),await En(this.#o,Vpe(this.#e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await jpe(this.#o,384);let r=await this.#S("ssh-keyscan",["-T","10","-t","ed25519",this.#a]);if(r.exitCode!==0||!r.stdout.trim())throw Error("Unable to resolve smoke SSH host key");await En(this.#i,r.stdout,{mode:384});let o=await this.#h(["docker","ps","--filter","label=service=rover","--filter","label=role=web","--format","{{.Names}}"]);if(this.#s=o.stdout.trim().split(/\r?\n/)[0],!this.#s||!/^[A-Za-z0-9_.-]+$/.test(this.#s))throw Error("Unable to resolve a running smoke container");let n=await Il.clone(this.#e.commandRunner,`${this.#e.githubOrg}/${this.#e.user.contentRepo}`,t,this.#e.environment.CONTENT_REPO_ADMIN_TOKEN);if(this.#n=n,(await la(n.dir)).length>0)throw Error("Directory-sync stress probes already exist");let i=await n.output(["rev-parse","HEAD"]);this.#l=await n.output(["rev-parse","HEAD^{tree}"]),this.#d=await this.#f();let s=await this.#t.waitForHealthSnapshot(60000);if(!s)throw Error("Smoke health was unavailable before stress testing");return this.#c=`ops/directory-sync-stress-backup-${this.#e.runId}`,await n.run(["push","origin",`HEAD:refs/heads/${this.#c}`]),await this.#t.discoverEndpoints(),await En(ct(this.#e.artifactsDir,"state.json"),`${JSON.stringify({runId:this.#e.runId,profile:e.profile,originalHead:i,originalTree:this.#l,backupBranch:this.#c,baseline:{entities:s.entities,notes:Df(s),version:s.version}},null,2)}
400
+ `),y}finally{await Bf(c,{recursive:!0,force:!0})}}class X3{#e;#t;#r;#n;#o;#i;#a;#s;#c;#l;#d;constructor(e){this.#e=e,this.#t=new rR({domain:e.user.domain,fetchImpl:e.fetchImpl,now:e.now,sleep:e.sleep,sampleRuntime:()=>this.#b(),readEntityCounts:()=>this.#y()})}async prepare(e){this.#r=await iR(ct(sR(),"brains-ops-directory-sync-stress-"));let t=ct(this.#r,"content");this.#o=ct(this.#r,"id_ed25519"),this.#i=ct(this.#r,"known_hosts"),this.#a=await this.#m(),await En(this.#o,Wpe(this.#e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await Zpe(this.#o,384);let r=await this.#S("ssh-keyscan",["-T","10","-t","ed25519",this.#a]);if(r.exitCode!==0||!r.stdout.trim())throw Error("Unable to resolve smoke SSH host key");await En(this.#i,r.stdout,{mode:384});let o=await this.#h(["docker","ps","--filter","label=service=rover","--filter","label=role=web","--format","{{.Names}}"]);if(this.#s=o.stdout.trim().split(/\r?\n/)[0],!this.#s||!/^[A-Za-z0-9_.-]+$/.test(this.#s))throw Error("Unable to resolve a running smoke container");let n=await Il.clone(this.#e.commandRunner,`${this.#e.githubOrg}/${this.#e.user.contentRepo}`,t,this.#e.environment.CONTENT_REPO_ADMIN_TOKEN);if(this.#n=n,(await la(n.dir)).length>0)throw Error("Directory-sync stress probes already exist");let i=await n.output(["rev-parse","HEAD"]);this.#l=await n.output(["rev-parse","HEAD^{tree}"]),this.#d=await this.#f();let s=await this.#t.waitForHealthSnapshot(60000);if(!s)throw Error("Smoke health was unavailable before stress testing");return this.#c=`ops/directory-sync-stress-backup-${this.#e.runId}`,await n.run(["push","origin",`HEAD:refs/heads/${this.#c}`]),await this.#t.discoverEndpoints(),await En(ct(this.#e.artifactsDir,"state.json"),`${JSON.stringify({runId:this.#e.runId,profile:e.profile,originalHead:i,originalTree:this.#l,backupBranch:this.#c,baseline:{entities:s.entities,notes:Df(s),version:s.version}},null,2)}
401
401
  `),this.#e.logger(`Prepared ${e.profile} directory-sync stress run for ${this.#e.user.handle}`),{entities:s.entities,notes:Df(s),version:s.version}}async startMonitoring(){this.#v(),this.#t.start()}async executePhase(e,t){this.#v();let r=this.#n;if(!r)throw Error("Directory-sync stress checkout is not prepared");await r.sync();let o=this.#t.healthSamples.length,n=this.#e.now().getTime(),i=await this.#g();if(i?.pending!==0||i.processing!==0)return kl(e,"health did not provide a drained queue before the phase");await t5(r.dir,e),await r.commitAll(`test(directory-sync): stress ${e.id}`),await r.pushMainWithRebase();let s=this.#e.now().getTime(),a=await r.output(["rev-parse","HEAD"]),c=await this.#p(a,900000);if(c===void 0)return kl(e,"runtime did not pull the phase commit");let u;if(e.operation==="rename"){let h=t.notes+e.targetProbeCount;if(e.settleMs>0)await this.#e.sleep(e.settleMs);let b=await this.#t.waitForStableEntityBaseline(h,void 0,1200000);if(u=this.#e.now().getTime()-s,!b)return kl(e,`health did not stabilize at ${h} notes`,c,u)}else if(e.operation==="add"||e.operation==="delete"){let h=t.notes+e.targetProbeCount,b=this.#e.now().getTime(),y=await this.#t.waitForEntityBaseline(h,void 0,1200000);if(u=this.#e.now().getTime()-b,!y)return kl(e,`health did not reach ${h} notes`,c,u)}if(e.operation!=="rename"&&e.settleMs>0)await this.#e.sleep(e.settleMs);let d=e.operation==="delete"?0:Math.ceil(e.count/50);if(!await this.#u(i.completedImports+d,1200000))return kl(e,`health did not observe ${d} completed import job(s) with a drained queue`,c,u);let m=this.#t.healthSamples.slice(o).find((h)=>!h.ok);if(m)return kl(e,`${m.endpoint} unavailable (${m.status===0?m.error??"unknown":m.status})`,c,u);return this.#e.logger(`Completed ${e.id} in ${this.#e.now().getTime()-n}ms`),{id:e.id,operation:e.operation,count:e.count,success:!0,commitLatencyMs:c,...u===void 0?{}:{persistenceLatencyMs:u}}}async cleanup(e){let t=this.#n;if(!t)return{success:!1,probesRemaining:0,error:"stress checkout was not prepared"};try{if(await t.sync(!0),await lR(t.dir)>0)await t.commitAll("test(directory-sync): remove stress probes"),await t.pushMainWithRebase();let o=(await la(t.dir)).length;this.#t.markGateEnd();let n=await this.#t.waitForEntityBaseline(e.notes,e.entities,1200000);await t.sync(!0);let s=await t.output(["rev-parse","HEAD^{tree}"])===this.#l,a=o===0&&n!==void 0&&s;if(a&&this.#c){if((await t.run(["push","origin","--delete",this.#c],!1)).exitCode!==0)this.#e.logger(`Warning: unable to delete backup branch ${this.#c}`)}return{success:a,probesRemaining:o,...n?{finalEntities:n.entities,finalNotes:Df(n)}:{},contentTreeRestored:s,...!a?{error:!n?"entity baseline was not restored before cleanup timeout":!s?"content tree differs from the pre-stress baseline":"stress probes remain after cleanup"}:{}}}catch(r){return{success:!1,probesRemaining:(await la(t.dir)).length,error:Ge(r)}}}async stopMonitoring(){await this.#t.stop(),await En(ct(this.#e.artifactsDir,"health-samples.json"),`${JSON.stringify(this.#t.healthSamples,null,2)}
402
- `);let e=0;if(this.#s&&this.#t.startedAt){let o=await this.#h(["docker","logs","--since",this.#t.startedAt,this.#s],!1),n=`${o.stdout}${o.stderr}`;e=n.match(/\] ai:usage \{/g)?.length??0,await En(ct(this.#e.artifactsDir,"runtime.log"),n)}let t=await this.#f(),r={health:this.#t.gateHealthSamples(),runtime:[...this.#t.runtimeSamples],externalAiCalls:e,...t?{container:t}:{}};if(this.#t.error)throw this.#t.error;return r}async dispose(){if(await this.#t.stop(),this.#r)await Bf(this.#r,{recursive:!0,force:!0})}async#f(){if(!this.#s)return;let e=await this.#h(["docker","inspect",this.#s],!1);if(e.exitCode!==0)throw Error(`docker inspect ${this.#s} exited with code ${e.exitCode}`);let t;try{t=l.array(l.object({RestartCount:l.number().int().nonnegative(),State:l.object({Status:l.string(),OOMKilled:l.boolean(),StartedAt:l.string().min(1)})})).parse(JSON.parse(e.stdout))}catch(i){throw Error(`Could not read docker inspect output for ${this.#s}`,{cause:i})}let r=t[0];if(!r)throw Error("docker inspect reported no such container");let o=Math.max(0,r.RestartCount-(this.#d?.restartCount??0)),n=this.#d!==void 0&&r.State.StartedAt!==this.#d.startedAt;return{status:r.State.Status,restartCount:Math.max(o,n?1:0),oomKilled:r.State.OOMKilled&&!(this.#d?.oomKilled??!1),startedAt:r.State.StartedAt}}async#m(){let e=encodeURIComponent(`brain=${this.#e.serverLabel}`),t=await this.#e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${e}`,{headers:{Authorization:`Bearer ${this.#e.environment.HCLOUD_TOKEN}`}});if(!t.ok)throw Error(`Hetzner server lookup failed with ${t.status}`);let o=Fpe.parse(await t.json()).servers[0];if(o?.status!=="running")throw Error("Smoke server is not running");return o.public_net.ipv4.ip}async#p(e,t){let r=this.#s;if(!r)throw Error("Directory-sync stress container is not prepared");let o=this.#e.now().getTime();while(this.#e.now().getTime()-o<t){if((await this.#h(["docker","exec",r,"git","-C","/app/brain-data","merge-base","--is-ancestor",e,"HEAD"],!1)).exitCode===0)return this.#e.now().getTime()-o;await this.#e.sleep(5000)}return}async#g(){let e=new AbortController,t=setTimeout(()=>e.abort(),20000),r;try{let i=await this.#e.fetchImpl(`https://${this.#e.user.domain}/health/operate`,{method:"GET",signal:e.signal});if(!i.ok)return;r=await i.json()}catch{return}finally{clearTimeout(t)}let o=Jpe.safeParse(r);if(!o.success)throw Error(`Unexpected /health/operate payload from ${this.#e.user.domain}`,{cause:o.error});let n=o.data.resources.queue.byType.filter((i)=>i.type==="directory-sync:directory-import"&&i.status==="completed").reduce((i,s)=>i+s.count,0);return{pending:o.data.resources.queue.totals.pending,processing:o.data.resources.queue.totals.processing,completedImports:n}}async#u(e,t){let r=this.#e.now().getTime(),o=0;while(this.#e.now().getTime()-r<t){let n=await this.#g();if(n?.pending===0&&n.processing===0&&n.completedImports>=e){if(o+=1,o===2)return!0}else o=0;await this.#e.sleep(5000)}return!1}async#y(){let e=this.#s;if(!e)throw Error("Directory-sync stress container is not prepared");let t=await this.#h(["docker","exec",e,"bun","-e",`'${Kpe}'`],!1);if(t.exitCode!==0)return;try{return H3.parse(JSON.parse(t.stdout))}catch(r){throw Error(`Could not read entity counts from ${e}`,{cause:r})}}async#b(){let e=this.#s;if(!e)throw Error("Directory-sync stress container is not prepared");let t=await this.#h(["timeout","15","docker","stats","--no-stream","--format","{{.CPUPerc}},{{.MemPerc}},{{.PIDs}}",e],!1);return r5(t.stdout.trim(),this.#e.now().toISOString())}async#h(e,t=!0){let r=this.#o,o=this.#i,n=this.#a;if(!r||!o||!n)throw Error("Directory-sync stress SSH access is not prepared");let i=await this.#S("ssh",["-i",r,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${o}`,`root@${n}`,...e]);if(t&&i.exitCode!==0)throw eo("ssh",e,i);return i}async#S(e,t,r){return this.#e.commandRunner(e,t,r)}#v(){if(!this.#n||!this.#o||!this.#i||!this.#a||!this.#s)throw Error("Directory-sync stress driver is not prepared")}}function e5(e){if(e.embeddingEnabled!==!1)throw Error("Directory-sync stress requires embeddingEnabled: false for a hermetic smoke workload");if(e.topicExtractionEnabled!==!1)throw Error("Directory-sync stress requires topicExtractionEnabled: false for a hermetic smoke workload");if(e.skillDerivationEnabled!==!1)throw Error("Directory-sync stress requires skillDerivationEnabled: false for a hermetic smoke workload");if(e.swotDerivationEnabled!==!1)throw Error("Directory-sync stress requires swotDerivationEnabled: false for a hermetic smoke workload")}async function cR(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:o}}async function t5(e,t){let r=await la(e);switch(t.operation){case"add":{let o=t.targetProbeCount-r.length;if(o!==t.count)throw Error(`${t.id} expected to add ${t.count} probes from ${r.length}`);let n=r.map(Hpe).filter((s)=>s!==void 0),i=n.length===0?1:Math.max(...n)+1;for(let s=i;s<i+o;s+=1){let a=String(s).padStart(3,"0");await En(ct(e,`directory-sync-stress-${a}.md`),["---",`title: "Directory Sync Stress ${a}"`,"---","",`Deterministic directory-sync stress probe ${a}.`,"Payload: abcdefghijklmnopqrstuvwxyz-0123456789-abcdefghijklmnopqrstuvwxyz.",""].join(`
403
- `))}break}case"update":{if(r.length!==t.count)throw Error(`${t.id} expected ${t.count} probes, found ${r.length}`);for(let o of r){let n=ct(e,o),i=await Zpe(n,"utf8");await En(n,`${i.trimEnd()}
402
+ `);let e=0;if(this.#s&&this.#t.startedAt){let o=await this.#h(["docker","logs","--since",this.#t.startedAt,this.#s],!1),n=`${o.stdout}${o.stderr}`;e=n.match(/\] ai:usage \{/g)?.length??0,await En(ct(this.#e.artifactsDir,"runtime.log"),n)}let t=await this.#f(),r={health:this.#t.gateHealthSamples(),runtime:[...this.#t.runtimeSamples],externalAiCalls:e,...t?{container:t}:{}};if(this.#t.error)throw this.#t.error;return r}async dispose(){if(await this.#t.stop(),this.#r)await Bf(this.#r,{recursive:!0,force:!0})}async#f(){if(!this.#s)return;let e=await this.#h(["docker","inspect",this.#s],!1);if(e.exitCode!==0)throw Error(`docker inspect ${this.#s} exited with code ${e.exitCode}`);let t;try{t=l.array(l.object({RestartCount:l.number().int().nonnegative(),State:l.object({Status:l.string(),OOMKilled:l.boolean(),StartedAt:l.string().min(1)})})).parse(JSON.parse(e.stdout))}catch(i){throw Error(`Could not read docker inspect output for ${this.#s}`,{cause:i})}let r=t[0];if(!r)throw Error("docker inspect reported no such container");let o=Math.max(0,r.RestartCount-(this.#d?.restartCount??0)),n=this.#d!==void 0&&r.State.StartedAt!==this.#d.startedAt;return{status:r.State.Status,restartCount:Math.max(o,n?1:0),oomKilled:r.State.OOMKilled&&!(this.#d?.oomKilled??!1),startedAt:r.State.StartedAt}}async#m(){let e=encodeURIComponent(`brain=${this.#e.serverLabel}`),t=await this.#e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${e}`,{headers:{Authorization:`Bearer ${this.#e.environment.HCLOUD_TOKEN}`}});if(!t.ok)throw Error(`Hetzner server lookup failed with ${t.status}`);let o=Jpe.parse(await t.json()).servers[0];if(o?.status!=="running")throw Error("Smoke server is not running");return o.public_net.ipv4.ip}async#p(e,t){let r=this.#s;if(!r)throw Error("Directory-sync stress container is not prepared");let o=this.#e.now().getTime();while(this.#e.now().getTime()-o<t){if((await this.#h(["docker","exec",r,"git","-C","/app/brain-data","merge-base","--is-ancestor",e,"HEAD"],!1)).exitCode===0)return this.#e.now().getTime()-o;await this.#e.sleep(5000)}return}async#g(){let e=new AbortController,t=setTimeout(()=>e.abort(),20000),r;try{let i=await this.#e.fetchImpl(`https://${this.#e.user.domain}/health/operate`,{method:"GET",signal:e.signal});if(!i.ok)return;r=await i.json()}catch{return}finally{clearTimeout(t)}let o=Kpe.safeParse(r);if(!o.success)throw Error(`Unexpected /health/operate payload from ${this.#e.user.domain}`,{cause:o.error});let n=o.data.resources.queue.byType.filter((i)=>i.type==="directory-sync:directory-import"&&i.status==="completed").reduce((i,s)=>i+s.count,0);return{pending:o.data.resources.queue.totals.pending,processing:o.data.resources.queue.totals.processing,completedImports:n}}async#u(e,t){let r=this.#e.now().getTime(),o=0;while(this.#e.now().getTime()-r<t){let n=await this.#g();if(n?.pending===0&&n.processing===0&&n.completedImports>=e){if(o+=1,o===2)return!0}else o=0;await this.#e.sleep(5000)}return!1}async#y(){let e=this.#s;if(!e)throw Error("Directory-sync stress container is not prepared");let t=await this.#h(["docker","exec",e,"bun","-e",`'${Hpe}'`],!1);if(t.exitCode!==0)return;try{return H3.parse(JSON.parse(t.stdout))}catch(r){throw Error(`Could not read entity counts from ${e}`,{cause:r})}}async#b(){let e=this.#s;if(!e)throw Error("Directory-sync stress container is not prepared");let t=await this.#h(["timeout","15","docker","stats","--no-stream","--format","{{.CPUPerc}},{{.MemPerc}},{{.PIDs}}",e],!1);return r5(t.stdout.trim(),this.#e.now().toISOString())}async#h(e,t=!0){let r=this.#o,o=this.#i,n=this.#a;if(!r||!o||!n)throw Error("Directory-sync stress SSH access is not prepared");let i=await this.#S("ssh",["-i",r,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${o}`,`root@${n}`,...e]);if(t&&i.exitCode!==0)throw eo("ssh",e,i);return i}async#S(e,t,r){return this.#e.commandRunner(e,t,r)}#v(){if(!this.#n||!this.#o||!this.#i||!this.#a||!this.#s)throw Error("Directory-sync stress driver is not prepared")}}function e5(e){if(e.embeddingEnabled!==!1)throw Error("Directory-sync stress requires embeddingEnabled: false for a hermetic smoke workload");if(e.topicExtractionEnabled!==!1)throw Error("Directory-sync stress requires topicExtractionEnabled: false for a hermetic smoke workload");if(e.skillDerivationEnabled!==!1)throw Error("Directory-sync stress requires skillDerivationEnabled: false for a hermetic smoke workload");if(e.swotDerivationEnabled!==!1)throw Error("Directory-sync stress requires swotDerivationEnabled: false for a hermetic smoke workload")}async function cR(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:o}}async function t5(e,t){let r=await la(e);switch(t.operation){case"add":{let o=t.targetProbeCount-r.length;if(o!==t.count)throw Error(`${t.id} expected to add ${t.count} probes from ${r.length}`);let n=r.map(Vpe).filter((s)=>s!==void 0),i=n.length===0?1:Math.max(...n)+1;for(let s=i;s<i+o;s+=1){let a=String(s).padStart(3,"0");await En(ct(e,`directory-sync-stress-${a}.md`),["---",`title: "Directory Sync Stress ${a}"`,"---","",`Deterministic directory-sync stress probe ${a}.`,"Payload: abcdefghijklmnopqrstuvwxyz-0123456789-abcdefghijklmnopqrstuvwxyz.",""].join(`
403
+ `))}break}case"update":{if(r.length!==t.count)throw Error(`${t.id} expected ${t.count} probes, found ${r.length}`);for(let o of r){let n=ct(e,o),i=await Upe(n,"utf8");await En(n,`${i.trimEnd()}
404
404
 
405
405
  Update marker: ${t.id}.
406
- `)}break}case"rename":{let o=r.filter((n)=>/^directory-sync-stress-\d+\.md$/.test(n)).slice(0,t.count);if(o.length!==t.count)throw Error(`${t.id} expected ${t.count} unrenamed probes, found ${o.length}`);for(let n of o)await qpe(ct(e,n),ct(e,n.replace("directory-sync-stress-","directory-sync-stress-renamed-")));break}case"delete":{if(r.length!==t.count)throw Error(`${t.id} expected ${t.count} probes, found ${r.length}`);await Promise.all(r.map((o)=>Bf(ct(e,o),{force:!0})));break}}}async function la(e){return(await Upe(e)).filter((r)=>/^directory-sync-stress-(?:renamed-)?\d+\.md$/.test(r)&&!r.includes("/")).sort()}async function lR(e){let t=await la(e);return await Promise.all(t.map((r)=>Bf(ct(e,r),{force:!0}))),t.length}function Hpe(e){let t=e.match(/(\d+)\.md$/)?.[1];return t?Number.parseInt(t,10):void 0}function kl(e,t,r,o){return{id:e.id,operation:e.operation,count:e.count,success:!1,...r===void 0?{}:{commitLatencyMs:r},...o===void 0?{}:{persistenceLatencyMs:o},error:t}}function r5(e,t){let[r,o,n]=e.split(",");if(!r||!o||!n)return;let i=Number.parseFloat(r.replace("%","")),s=Number.parseFloat(o.replace("%","")),a=Number.parseInt(n,10);if(!Number.isFinite(i)||!Number.isFinite(s)||!Number.isFinite(a))return;return{timestamp:t,cpuPercent:i,memoryPercent:s,pids:a}}function Vpe(e){return`${e.replace(/\r\n/g,`
406
+ `)}break}case"rename":{let o=r.filter((n)=>/^directory-sync-stress-\d+\.md$/.test(n)).slice(0,t.count);if(o.length!==t.count)throw Error(`${t.id} expected ${t.count} unrenamed probes, found ${o.length}`);for(let n of o)await Mpe(ct(e,n),ct(e,n.replace("directory-sync-stress-","directory-sync-stress-renamed-")));break}case"delete":{if(r.length!==t.count)throw Error(`${t.id} expected ${t.count} probes, found ${r.length}`);await Promise.all(r.map((o)=>Bf(ct(e,o),{force:!0})));break}}}async function la(e){return(await qpe(e)).filter((r)=>/^directory-sync-stress-(?:renamed-)?\d+\.md$/.test(r)&&!r.includes("/")).sort()}async function lR(e){let t=await la(e);return await Promise.all(t.map((r)=>Bf(ct(e,r),{force:!0}))),t.length}function Vpe(e){let t=e.match(/(\d+)\.md$/)?.[1];return t?Number.parseInt(t,10):void 0}function kl(e,t,r,o){return{id:e.id,operation:e.operation,count:e.count,success:!1,...r===void 0?{}:{commitLatencyMs:r},...o===void 0?{}:{persistenceLatencyMs:o},error:t}}function r5(e,t){let[r,o,n]=e.split(",");if(!r||!o||!n)return;let i=Number.parseFloat(r.replace("%","")),s=Number.parseFloat(o.replace("%","")),a=Number.parseInt(n,10);if(!Number.isFinite(i)||!Number.isFinite(s)||!Number.isFinite(a))return;return{timestamp:t,cpuPercent:i,memoryPercent:s,pids:a}}function Wpe(e){return`${e.replace(/\r\n/g,`
407
407
  `).replace(/\\n/g,`
408
408
  `).trimEnd()}
409
- `}function uR(e){return e.replace(/[-:.TZ]/g,"").slice(0,14)}async function Wpe(e){await En(ct(e.artifactsDir,"report.json"),`${JSON.stringify(e,null,2)}
410
- `),await En(ct(e.artifactsDir,"report.md"),Gpe(e))}function Gpe(e){let t=e.report.metrics.runtime,r=e.report.metrics.health,o=t.map((a)=>a.cpuPercent).sort((a,c)=>a-c),n=t.map((a)=>a.memoryPercent),i=r.filter((a)=>!a.ok),s=["# Directory-sync stress report","",`- Run: \`${e.runId}\``,`- Target: \`${e.target.handle}\` (${e.target.domain})`,`- Profile: \`${e.report.profile}\``,`- Version: \`${e.report.baseline.version}\``,`- Result: **${e.report.success?"PASS":"FAIL"}**`,`- Started: ${e.startedAt}`,`- Completed: ${e.completedAt}`,"","## Phases","","| Phase | Operation | Count | Result | Pull latency | Persistence latency |","| --- | --- | ---: | --- | ---: | ---: |",...e.report.phases.map((a)=>`| ${a.id} | ${a.operation} | ${a.count} | ${a.success?"pass":`fail: ${a.error??"unknown"}`} | ${W3(a.commitLatencyMs)} | ${W3(a.persistenceLatencyMs)} |`),"","## Runtime","",`- Samples: ${t.length}`,`- CPU p50/p95/p99/max: ${Lf(nR(o,0.5))} / ${Lf(nR(o,0.95))} / ${Lf(nR(o,0.99))} / ${Lf(o.at(-1))}`,`- Memory max: ${Lf(n.length?Math.max(...n):void 0)}`,`- PIDs max: ${t.length?Math.max(...t.map((a)=>a.pids)):"n/a"}`,`- Container status/restarts/OOM: ${e.report.metrics.container?`${e.report.metrics.container.status} / ${e.report.metrics.container.restartCount} / ${e.report.metrics.container.oomKilled}`:"unknown"}`,`- External AI calls: ${e.report.metrics.externalAiCalls??0}`,`- Health samples: ${r.length}`,`- Health failures: ${i.length}`,"","## Cleanup","",`- Result: ${e.report.cleanup.success?"pass":"fail"}`,`- Remaining probes: ${e.report.cleanup.probesRemaining}`,`- Final entities: ${e.report.cleanup.finalEntities??"unknown"}`,`- Final notes: ${e.report.cleanup.finalNotes??"unknown"}`,`- Content tree restored: ${e.report.cleanup.contentTreeRestored??"unknown"}`,""];if(e.report.failure)s.push("## Failure","",e.report.failure,"");return`${s.join(`
409
+ `}function uR(e){return e.replace(/[-:.TZ]/g,"").slice(0,14)}async function Gpe(e){await En(ct(e.artifactsDir,"report.json"),`${JSON.stringify(e,null,2)}
410
+ `),await En(ct(e.artifactsDir,"report.md"),Qpe(e))}function Qpe(e){let t=e.report.metrics.runtime,r=e.report.metrics.health,o=t.map((a)=>a.cpuPercent).sort((a,c)=>a-c),n=t.map((a)=>a.memoryPercent),i=r.filter((a)=>!a.ok),s=["# Directory-sync stress report","",`- Run: \`${e.runId}\``,`- Target: \`${e.target.handle}\` (${e.target.domain})`,`- Profile: \`${e.report.profile}\``,`- Version: \`${e.report.baseline.version}\``,`- Result: **${e.report.success?"PASS":"FAIL"}**`,`- Started: ${e.startedAt}`,`- Completed: ${e.completedAt}`,"","## Phases","","| Phase | Operation | Count | Result | Pull latency | Persistence latency |","| --- | --- | ---: | --- | ---: | ---: |",...e.report.phases.map((a)=>`| ${a.id} | ${a.operation} | ${a.count} | ${a.success?"pass":`fail: ${a.error??"unknown"}`} | ${W3(a.commitLatencyMs)} | ${W3(a.persistenceLatencyMs)} |`),"","## Runtime","",`- Samples: ${t.length}`,`- CPU p50/p95/p99/max: ${Lf(nR(o,0.5))} / ${Lf(nR(o,0.95))} / ${Lf(nR(o,0.99))} / ${Lf(o.at(-1))}`,`- Memory max: ${Lf(n.length?Math.max(...n):void 0)}`,`- PIDs max: ${t.length?Math.max(...t.map((a)=>a.pids)):"n/a"}`,`- Container status/restarts/OOM: ${e.report.metrics.container?`${e.report.metrics.container.status} / ${e.report.metrics.container.restartCount} / ${e.report.metrics.container.oomKilled}`:"unknown"}`,`- External AI calls: ${e.report.metrics.externalAiCalls??0}`,`- Health samples: ${r.length}`,`- Health failures: ${i.length}`,"","## Cleanup","",`- Result: ${e.report.cleanup.success?"pass":"fail"}`,`- Remaining probes: ${e.report.cleanup.probesRemaining}`,`- Final entities: ${e.report.cleanup.finalEntities??"unknown"}`,`- Final notes: ${e.report.cleanup.finalNotes??"unknown"}`,`- Content tree restored: ${e.report.cleanup.contentTreeRestored??"unknown"}`,""];if(e.report.failure)s.push("## Failure","",e.report.failure,"");return`${s.join(`
411
411
  `)}
412
- `}function nR(e,t){if(e.length===0)return;let r=Math.max(0,Math.ceil(e.length*t)-1);return e[r]}function Lf(e){return e===void 0?"n/a":`${e.toFixed(2)}%`}function W3(e){return e===void 0?"n/a":`${(e/1000).toFixed(1)}s`}var Mpe,Fpe,Jpe,Kpe;var jf=w(()=>{he();Vy();Mr();Nf();K3();V3();Nf();Mpe=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1),CONTENT_REPO_ADMIN_TOKEN:l.string().min(1)}),Fpe=l.object({servers:l.array(l.object({id:l.number().int(),status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))}),Jpe=l.object({status:l.literal("ready"),operationalStatus:l.literal("operational"),resources:l.object({queue:l.object({totals:l.object({pending:l.number().int().nonnegative(),processing:l.number().int().nonnegative()}),byType:l.array(l.object({type:l.string(),status:l.string(),count:l.number().int().nonnegative()}))})})}),Kpe=['import { Database } from "bun:sqlite";','const path = (process.env.XDG_DATA_HOME || "./data") + "/brain.db";',"const db = new Database(path, { readonly: true });",'const rows = db.query(`SELECT "entityType" AS "entityType", COUNT(*) AS "count" FROM entities GROUP BY "entityType"`).all();',"process.stdout.write(JSON.stringify(rows));"].join(" ")});var n5=w(()=>{ns()});var Qpe="/usr/local/sbin/brains-health-watchdog",Ype="ai.rizom.brain.watchdog",Xpe="true",dR,o5,Yqe;var i5=w(async()=>{n5();dR=`${Ype}=${Xpe}`,o5=`#!/usr/bin/env bash
412
+ `}function nR(e,t){if(e.length===0)return;let r=Math.max(0,Math.ceil(e.length*t)-1);return e[r]}function Lf(e){return e===void 0?"n/a":`${e.toFixed(2)}%`}function W3(e){return e===void 0?"n/a":`${(e/1000).toFixed(1)}s`}var Fpe,Jpe,Kpe,Hpe;var jf=w(()=>{he();Vy();Mr();Nf();K3();V3();Nf();Fpe=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1),CONTENT_REPO_ADMIN_TOKEN:l.string().min(1)}),Jpe=l.object({servers:l.array(l.object({id:l.number().int(),status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))}),Kpe=l.object({status:l.literal("ready"),operationalStatus:l.literal("operational"),resources:l.object({queue:l.object({totals:l.object({pending:l.number().int().nonnegative(),processing:l.number().int().nonnegative()}),byType:l.array(l.object({type:l.string(),status:l.string(),count:l.number().int().nonnegative()}))})})}),Hpe=['import { Database } from "bun:sqlite";','const path = (process.env.XDG_DATA_HOME || "./data") + "/brain.db";',"const db = new Database(path, { readonly: true });",'const rows = db.query(`SELECT "entityType" AS "entityType", COUNT(*) AS "count" FROM entities GROUP BY "entityType"`).all();',"process.stdout.write(JSON.stringify(rows));"].join(" ")});var n5=w(()=>{ns()});var Ype="/usr/local/sbin/brains-health-watchdog",Xpe="ai.rizom.brain.watchdog",eme="true",dR,o5,Xqe;var i5=w(async()=>{n5();dR=`${Xpe}=${eme}`,o5=`#!/usr/bin/env bash
413
413
  set -euo pipefail
414
414
  umask 077
415
415
 
@@ -468,14 +468,14 @@ while read -r container_id; do
468
468
  logger -t brains-health-watchdog "restarting unhealthy container=$container_name service=$service_name incident=$incident_path"
469
469
  docker restart "$container_id"
470
470
  done < <(docker ps --filter health=unhealthy --filter label=${dR} --format '{{.ID}}')
471
- `,Yqe=`[Unit]
471
+ `,Xqe=`[Unit]
472
472
  Description=Restart persistently unhealthy Brain containers
473
473
  After=docker.service
474
474
  Requires=docker.service
475
475
 
476
476
  [Service]
477
477
  Type=oneshot
478
- ExecStart=${Qpe}
478
+ ExecStart=${Ype}
479
479
  `});var a5=`#!/usr/bin/env bash
480
480
  set -euo pipefail
481
481
  umask 077
@@ -703,51 +703,51 @@ deployed_container_restarted=false
703
703
  EOF
704
704
  pass "fleet watchdog isolation smoke completed"
705
705
  printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
706
- `;var s5=()=>{};var hR={};Ut(hR,{assertHealthWatchdogSmokeTarget:()=>Qy,cleanupHealthWatchdogSmoke:()=>f5,renderHealthWatchdogSmokeRemoteScript:()=>mR,runHealthWatchdogSmoke:()=>d5});import{access as tme,chmod as rme,mkdir as c5,mkdtemp as nme,rm as pR,writeFile as Al}from"fs/promises";import{tmpdir as ome}from"os";import{join as to,resolve as l5}from"path";function Qy(e){let t=`watchdog-smoke:${e.handle}`;if(e.confirmation!==t)throw Error(`Health watchdog smoke requires --confirm ${t}`);if(!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,100}$/.test(e.runId))throw Error("Health watchdog smoke run ID is invalid");let r=/(^|[-_.])smoke($|[-_.])/i;if(!r.test(e.handle)||!r.test(e.domain))throw Error("Health watchdog smoke is smoke-only; handle and domain must both identify smoke")}function mR(){return a5.replace("__WATCHDOG_PAYLOAD_BASE64__",Buffer.from(o5,"utf8").toString("base64")).replace("__WATCHDOG_LABEL_FILTER__",dR)}async function d5(e){let t=l5(e.artifactsDir??to(e.rootDir,".brains-ops","watchdog-smoke",e.runId)),r=await p5(e.rootDir,e.handle);Qy({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await c5(t,{recursive:!0});let o=u5.parse(e.env??process.env),n=e.commandRunner??Mo,i=e.logger??console.info,s=await m5({target:r,environment:o,commandRunner:n,fetchImpl:e.fetchImpl??fetch}),a=`/tmp/brains-health-watchdog-smoke-${e.runId}`,c,u=!1;try{let m=await fR(s,"run",e.runId);if(await Gy(t,"remote",m),m.stdout.trim())i(m.stdout.trim());if(m.exitCode!==0)c=eo("ssh",["watchdog-smoke","run"],m);let h=await sme(s,a,t);if(await Gy(t,"scp",h),h.exitCode===0){if(u=await ame(to(t,"summary.txt")),!u)c??=Error("Health watchdog smoke evidence is missing summary.txt")}else c??=eo("scp",[a,t],h)}catch(m){c=Error(Ge(m,"Health watchdog smoke execution failed"))}let d;try{let m=await fR(s,"cleanup",e.runId);if(await Gy(t,"cleanup",m),m.exitCode!==0)d=eo("ssh",["watchdog-smoke","cleanup"],m)}catch(m){d=Error(Ge(m,"Health watchdog smoke cleanup failed"))}finally{await pR(s.temporaryRoot,{recursive:!0,force:!0})}if(c)throw c;if(d)throw d;if(!u)throw Error("Health watchdog smoke completed without copied evidence");let f={success:!0,runId:e.runId,artifactsDir:t,target:{handle:r.user.handle,domain:r.user.domain,serverIp:s.serverIp}};return await Al(to(t,"result.json"),`${JSON.stringify(f,null,2)}
706
+ `;var s5=()=>{};var hR={};Ut(hR,{assertHealthWatchdogSmokeTarget:()=>Qy,cleanupHealthWatchdogSmoke:()=>f5,renderHealthWatchdogSmokeRemoteScript:()=>mR,runHealthWatchdogSmoke:()=>d5});import{access as rme,chmod as nme,mkdir as c5,mkdtemp as ome,rm as pR,writeFile as Al}from"fs/promises";import{tmpdir as ime}from"os";import{join as to,resolve as l5}from"path";function Qy(e){let t=`watchdog-smoke:${e.handle}`;if(e.confirmation!==t)throw Error(`Health watchdog smoke requires --confirm ${t}`);if(!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,100}$/.test(e.runId))throw Error("Health watchdog smoke run ID is invalid");let r=/(^|[-_.])smoke($|[-_.])/i;if(!r.test(e.handle)||!r.test(e.domain))throw Error("Health watchdog smoke is smoke-only; handle and domain must both identify smoke")}function mR(){return a5.replace("__WATCHDOG_PAYLOAD_BASE64__",Buffer.from(o5,"utf8").toString("base64")).replace("__WATCHDOG_LABEL_FILTER__",dR)}async function d5(e){let t=l5(e.artifactsDir??to(e.rootDir,".brains-ops","watchdog-smoke",e.runId)),r=await p5(e.rootDir,e.handle);Qy({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await c5(t,{recursive:!0});let o=u5.parse(e.env??process.env),n=e.commandRunner??Mo,i=e.logger??console.info,s=await m5({target:r,environment:o,commandRunner:n,fetchImpl:e.fetchImpl??fetch}),a=`/tmp/brains-health-watchdog-smoke-${e.runId}`,c,u=!1;try{let m=await fR(s,"run",e.runId);if(await Gy(t,"remote",m),m.stdout.trim())i(m.stdout.trim());if(m.exitCode!==0)c=eo("ssh",["watchdog-smoke","run"],m);let h=await ame(s,a,t);if(await Gy(t,"scp",h),h.exitCode===0){if(u=await cme(to(t,"summary.txt")),!u)c??=Error("Health watchdog smoke evidence is missing summary.txt")}else c??=eo("scp",[a,t],h)}catch(m){c=Error(Ge(m,"Health watchdog smoke execution failed"))}let d;try{let m=await fR(s,"cleanup",e.runId);if(await Gy(t,"cleanup",m),m.exitCode!==0)d=eo("ssh",["watchdog-smoke","cleanup"],m)}catch(m){d=Error(Ge(m,"Health watchdog smoke cleanup failed"))}finally{await pR(s.temporaryRoot,{recursive:!0,force:!0})}if(c)throw c;if(d)throw d;if(!u)throw Error("Health watchdog smoke completed without copied evidence");let f={success:!0,runId:e.runId,artifactsDir:t,target:{handle:r.user.handle,domain:r.user.domain,serverIp:s.serverIp}};return await Al(to(t,"result.json"),`${JSON.stringify(f,null,2)}
707
707
  `),f}async function f5(e){let t=l5(e.artifactsDir??to(e.rootDir,".brains-ops","watchdog-smoke",`cleanup-${e.runId}`)),r=await p5(e.rootDir,e.handle);Qy({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await c5(t,{recursive:!0});let o=u5.parse(e.env??process.env),n=await m5({target:r,environment:o,commandRunner:e.commandRunner??Mo,fetchImpl:e.fetchImpl??fetch});try{let s=await fR(n,"cleanup",e.runId);if(await Gy(t,"cleanup",s),s.stdout.trim())(e.logger??console.info)(s.stdout.trim());if(s.exitCode!==0)throw eo("ssh",["watchdog-smoke","cleanup"],s)}finally{await pR(n.temporaryRoot,{recursive:!0,force:!0})}let i={success:!0,runId:e.runId,artifactsDir:t,target:{handle:r.user.handle,domain:r.user.domain,serverIp:n.serverIp}};return await Al(to(t,"result.json"),`${JSON.stringify(i,null,2)}
708
- `),i}async function p5(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:o}}async function m5(e){let t=await nme(to(ome(),"brains-ops-watchdog-smoke-")),r=to(t,"id_ed25519"),o=to(t,"known_hosts");try{let n=encodeURIComponent(`brain=${e.target.pilot.contentRepoPrefix}${e.target.user.handle}`),i=await e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${n}`,{headers:{Authorization:`Bearer ${e.environment.HCLOUD_TOKEN}`}});if(!i.ok)throw Error(`Hetzner server lookup failed with ${i.status}`);let s=ime.parse(await i.json());if(s.servers.length!==1)throw Error(`Expected one smoke server, found ${s.servers.length}`);let a=s.servers[0];if(a?.status!=="running")throw Error("Smoke server is not running");await Al(r,cme(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await rme(r,384);let c=await e.commandRunner("ssh-keyscan",["-T","10","-t","ed25519",a.public_net.ipv4.ip]);if(c.exitCode!==0||!c.stdout.trim())throw Error("Unable to resolve watchdog smoke SSH host key");return await Al(o,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:r,knownHostsPath:o,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(n){throw await pR(t,{recursive:!0,force:!0}),n}}async function fR(e,t,r){return e.commandRunner("ssh",[...h5(e),`root@${e.serverIp}`,"bash","-s","--",t,r],{stdin:mR()})}async function sme(e,t,r){return e.commandRunner("scp",[...h5(e),"-r",`root@${e.serverIp}:${t}/.`,r])}function h5(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function ame(e){try{return await tme(e),!0}catch{return!1}}async function Gy(e,t,r){await Promise.all([Al(to(e,`${t}.stdout.log`),r.stdout),Al(to(e,`${t}.stderr.log`),r.stderr)])}function cme(e){return`${e.replace(/\r\n/g,`
708
+ `),i}async function p5(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:o}}async function m5(e){let t=await ome(to(ime(),"brains-ops-watchdog-smoke-")),r=to(t,"id_ed25519"),o=to(t,"known_hosts");try{let n=encodeURIComponent(`brain=${e.target.pilot.contentRepoPrefix}${e.target.user.handle}`),i=await e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${n}`,{headers:{Authorization:`Bearer ${e.environment.HCLOUD_TOKEN}`}});if(!i.ok)throw Error(`Hetzner server lookup failed with ${i.status}`);let s=sme.parse(await i.json());if(s.servers.length!==1)throw Error(`Expected one smoke server, found ${s.servers.length}`);let a=s.servers[0];if(a?.status!=="running")throw Error("Smoke server is not running");await Al(r,lme(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await nme(r,384);let c=await e.commandRunner("ssh-keyscan",["-T","10","-t","ed25519",a.public_net.ipv4.ip]);if(c.exitCode!==0||!c.stdout.trim())throw Error("Unable to resolve watchdog smoke SSH host key");return await Al(o,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:r,knownHostsPath:o,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(n){throw await pR(t,{recursive:!0,force:!0}),n}}async function fR(e,t,r){return e.commandRunner("ssh",[...h5(e),`root@${e.serverIp}`,"bash","-s","--",t,r],{stdin:mR()})}async function ame(e,t,r){return e.commandRunner("scp",[...h5(e),"-r",`root@${e.serverIp}:${t}/.`,r])}function h5(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function cme(e){try{return await rme(e),!0}catch{return!1}}async function Gy(e,t,r){await Promise.all([Al(to(e,`${t}.stdout.log`),r.stdout),Al(to(e,`${t}.stderr.log`),r.stderr)])}function lme(e){return`${e.replace(/\r\n/g,`
709
709
  `).replace(/\\n/g,`
710
710
  `).trimEnd()}
711
- `}var u5,ime;var Yy=w(async()=>{he();s5();Mr();Nf();await i5();u5=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1)}),ime=l.object({servers:l.array(l.object({status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))})});import{access as TN,chmod as uE,mkdir as Bm,readFile as RN,writeFile as $N}from"fs/promises";import{dirname as r7,join as tc}from"path";import{fileURLToPath as n7}from"url";var Zf={name:"@rizom/ops",version:"0.2.0-alpha.671",description:"Operator CLI for managing private brain fleet registry repos",keywords:["brains","ops","cli","deploy","fleet","operator"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{"brains-ops":"./dist/brains-ops.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"@libsql/client":"^0.17.4","age-encryption":"^0.3.0",yaml:"^2.9.0"},devDependencies:{"@brains/contracts":"workspace:*","@brains/deploy-support":"workspace:*","@brains/eslint-config":"workspace:*","@brains/job-queue":"workspace:*","@brains/profile":"workspace:*","@brains/site-composition":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@brains/utils":"workspace:*","@types/bun":"^1.4.0",typescript:"^7.0.2"},engines:{bun:">=1.3.3"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js",bun:"./dist/deploy.js"}},files:["dist","templates"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brains-ops#readme",main:"./dist/index.js",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brains-ops"},scripts:{build:"bun scripts/build.ts",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts",test:"bun test --timeout 20000","test:smoke":"bun run build && RUN_SMOKE_TESTS=1 bun test --timeout 60000",typecheck:"tsc --noEmit"},type:"module",types:"./dist/index.d.ts"};ns();ec();var o7=["pilot.yaml","package.json",".env.schema",".gitignore","cohorts/cohort-1.yaml","users/alice.yaml",".github/actions/varlock-env/action.yml",".github/workflows/build.yml",".github/workflows/deploy.yml",".github/workflows/directory-sync-stress.yml",".github/workflows/health-watchdog-smoke.yml",".github/workflows/offboard.yml",".github/workflows/reconcile.yml",".github/workflows/upgrade.yml","deploy/Dockerfile","deploy/kamal/deploy.yml","deploy/scripts/helpers.ts","deploy/scripts/create-predeploy-backup.ts","deploy/scripts/install-health-watchdog.ts","deploy/scripts/provision-server.ts","deploy/scripts/update-dns.ts","deploy/scripts/write-ssh-key.ts","deploy/scripts/decrypt-user-secrets.ts","deploy/scripts/validate-secrets.ts","deploy/scripts/write-kamal-secrets.ts","deploy/scripts/resolve-user-config.ts","deploy/scripts/resolve-missing-images.ts","deploy/scripts/verify-runtime-image.ts","deploy/scripts/resolve-deploy-handles.ts","deploy/scripts/sync-content-repo.ts",".kamal/hooks/pre-deploy","docs/onboarding-checklist.md","docs/canonical-crossover-record.md","docs/operator-playbook.md","docs/user-onboarding.md","README.md"],dE=new Set([".kamal/hooks/pre-deploy"]),i7=new Set(["cohorts/cohort-1.yaml","users/alice.yaml","docs/canonical-crossover-record.md"]),s7=n7(new URL("../templates/rover-pilot/",import.meta.url));function co(e){return(t)=>t.includes(e)}function a7(e){return ER.find((t)=>e===`deploy/scripts/${t}`)}function fE(e){return e.replace(/\n {2}secret:\n(?: {4}- .*\n)+\nvolumes:\n/,`
711
+ `}var u5,sme;var Yy=w(async()=>{he();s5();Mr();Nf();await i5();u5=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1)}),sme=l.object({servers:l.array(l.object({status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))})});import{access as TN,chmod as uE,mkdir as Bm,readFile as RN,writeFile as $N}from"fs/promises";import{dirname as n7,join as tc}from"path";import{fileURLToPath as o7}from"url";var Zf={name:"@rizom/ops",version:"0.2.0-alpha.673",description:"Operator CLI for managing private brain fleet registry repos",keywords:["brains","ops","cli","deploy","fleet","operator"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{"brains-ops":"./dist/brains-ops.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"@libsql/client":"^0.17.4","age-encryption":"^0.3.0",yaml:"^2.9.0"},devDependencies:{"@brains/contracts":"workspace:*","@brains/deploy-support":"workspace:*","@brains/eslint-config":"workspace:*","@brains/job-queue":"workspace:*","@brains/profile":"workspace:*","@brains/site-composition":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@brains/utils":"workspace:*","@types/bun":"^1.4.0",typescript:"^7.0.2"},engines:{bun:">=1.3.3"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js",bun:"./dist/deploy.js"}},files:["dist","templates"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brains-ops#readme",main:"./dist/index.js",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brains-ops"},scripts:{build:"bun scripts/build.ts",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts",test:"bun test --timeout 20000","test:smoke":"bun run build && RUN_SMOKE_TESTS=1 bun test --timeout 60000",typecheck:"tsc --noEmit"},type:"module",types:"./dist/index.d.ts"};ns();ec();var i7=["pilot.yaml","package.json",".env.schema",".gitignore","cohorts/cohort-1.yaml","users/alice.yaml",".github/actions/varlock-env/action.yml",".github/workflows/build.yml",".github/workflows/deploy.yml",".github/workflows/directory-sync-stress.yml",".github/workflows/health-watchdog-smoke.yml",".github/workflows/offboard.yml",".github/workflows/reconcile.yml",".github/workflows/upgrade.yml","deploy/Dockerfile","deploy/kamal/deploy.yml","deploy/scripts/helpers.ts","deploy/scripts/create-predeploy-backup.ts","deploy/scripts/install-health-watchdog.ts","deploy/scripts/provision-server.ts","deploy/scripts/update-dns.ts","deploy/scripts/write-ssh-key.ts","deploy/scripts/decrypt-user-secrets.ts","deploy/scripts/validate-secrets.ts","deploy/scripts/write-kamal-secrets.ts","deploy/scripts/resolve-user-config.ts","deploy/scripts/resolve-missing-images.ts","deploy/scripts/verify-runtime-image.ts","deploy/scripts/resolve-deploy-handles.ts","deploy/scripts/sync-content-repo.ts",".kamal/hooks/pre-deploy","docs/onboarding-checklist.md","docs/canonical-crossover-record.md","docs/operator-playbook.md","docs/user-onboarding.md","README.md"],dE=new Set([".kamal/hooks/pre-deploy"]),s7=new Set(["cohorts/cohort-1.yaml","users/alice.yaml","docs/canonical-crossover-record.md"]),a7=o7(new URL("../templates/rover-pilot/",import.meta.url));function co(e){return(t)=>t.includes(e)}function c7(e){return ER.find((t)=>e===`deploy/scripts/${t}`)}function fE(e){return e.replace(/\n {2}secret:\n(?: {4}- .*\n)+\nvolumes:\n/,`
712
712
  secret:
713
713
  - __DYNAMIC_SECRETS__
714
714
 
715
715
  volumes:
716
- `)}function c7(e){return TR(e,"rover",fE)}function l7(e){if(e.includes("DISCORD_APPLICATION_ID")&&e.includes("ATPROTO_APP_PASSWORD"))return!1;let t=pa(fE(e)),r=pa(fE(qf({serviceName:"rover"})));return t===r}var u7=[/\n# Stored with the per-user Discord credentials and injected at deploy time\.\n# @sensitive\nDISCORD_PUBLIC_KEY=\n\n# @sensitive\nDISCORD_APPLICATION_ID=\n/,/\n# AT Protocol publishing\/discovery \(optional, per-user\)\n# Comes from the decrypted users\/<handle>\.secrets\.yaml\.age file when configured\.\n# @sensitive\nATPROTO_APP_PASSWORD=\n/];function d7(e,t){let r=(o)=>u7.reduce((n,i)=>n.replace(i,`
717
- `),o);return r(e)===r(t)}var f7=[`writeSecretGitHubEnv("DISCORD_PUBLIC_KEY", secrets["discordPublicKey"]);
716
+ `)}function l7(e){return TR(e,"rover",fE)}function u7(e){if(e.includes("DISCORD_APPLICATION_ID")&&e.includes("ATPROTO_APP_PASSWORD"))return!1;let t=pa(fE(e)),r=pa(fE(qf({serviceName:"rover"})));return t===r}var d7=[/\n# Stored with the per-user Discord credentials and injected at deploy time\.\n# @sensitive\nDISCORD_PUBLIC_KEY=\n\n# @sensitive\nDISCORD_APPLICATION_ID=\n/,/\n# AT Protocol publishing\/discovery \(optional, per-user\)\n# Comes from the decrypted users\/<handle>\.secrets\.yaml\.age file when configured\.\n# @sensitive\nATPROTO_APP_PASSWORD=\n/];function f7(e,t){let r=(o)=>d7.reduce((n,i)=>n.replace(i,`
717
+ `),o);return r(e)===r(t)}var p7=[`writeSecretGitHubEnv("DISCORD_PUBLIC_KEY", secrets["discordPublicKey"]);
718
718
  writeSecretGitHubEnv("DISCORD_APPLICATION_ID", secrets["discordApplicationId"]);
719
719
  `,`writeSecretGitHubEnv("ATPROTO_APP_PASSWORD", secrets["atprotoAppPassword"]);
720
- `];function p7(e,t){let r=(o)=>f7.reduce((n,i)=>n.replace(i,""),o);return r(e)===r(t)}function m7(e){return e.includes('if (eventName !== "push") {')&&e.includes('const currentSha = requireEnv("GITHUB_SHA");')||e.includes("path.match(/^users\\/([^/]+)\\/")&&!e.includes("existsSync(`users/${handle}.yaml`)")}var h7={".env.schema":d7,"deploy/Dockerfile":(e)=>AR(e),"deploy/kamal/deploy.yml":(e)=>c7(e)||l7(e),"deploy/scripts/decrypt-user-secrets.ts":p7,"deploy/scripts/resolve-deploy-handles.ts":(e)=>m7(e),"deploy/scripts/helpers.ts":co('"@rizom/ops/deploy"'),"deploy/scripts/resolve-user-config.ts":co("sitePackagesFor"),"deploy/scripts/resolve-missing-images.ts":co("runResolveMissingImages"),"deploy/scripts/sync-content-repo.ts":co("GIT_SYNC_TOKEN"),".github/workflows/build.yml":co("resolve-missing-images.ts"),".github/workflows/deploy.yml":co("install-health-watchdog.ts"),".github/workflows/offboard.yml":co("user:offboard"),".github/workflows/reconcile.yml":co("brains-ops reconcile"),".github/workflows/upgrade.yml":co("brains-ops upgrade")};function g7(e,t,r){let o=a7(e);if(o&&IR(o,t,r))return!0;return h7[e]?.(t,r)??!1}async function pE(e){await Bm(e,{recursive:!0});let t=tc(e,"views","users.md"),r=!0;try{await TN(t)}catch{r=!1}let o=!0;try{await TN(tc(e,"pilot.yaml"))}catch{o=!1}await Bm(tc(e,"users"),{recursive:!0}),await Bm(tc(e,"cohorts"),{recursive:!0});let n=o7.filter((i)=>!(o&&i7.has(i))).map(async(i)=>{let s=tc(e,i);await Bm(r7(s),{recursive:!0}),await y7(i,s)});if(await Promise.all(n),!r)await ao(e)}async function y7(e,t){let r=await b7(e);try{if(await $N(t,r,{flag:"wx"}),dE.has(e))await uE(t,493);return}catch(n){if(!v7(n,"EEXIST"))throw n}let o=await RN(t,"utf8");if(o===r){if(dE.has(e))await uE(t,493);return}if(!g7(e,o,r))return;if(await $N(t,r),dE.has(e))await uE(t,493)}async function b7(e){if(e===".gitignore")return`node_modules/
720
+ `];function m7(e,t){let r=(o)=>p7.reduce((n,i)=>n.replace(i,""),o);return r(e)===r(t)}function h7(e){return e.includes('if (eventName !== "push") {')&&e.includes('const currentSha = requireEnv("GITHUB_SHA");')||e.includes("path.match(/^users\\/([^/]+)\\/")&&!e.includes("existsSync(`users/${handle}.yaml`)")}var g7={".env.schema":f7,"deploy/Dockerfile":(e)=>AR(e),"deploy/kamal/deploy.yml":(e)=>l7(e)||u7(e),"deploy/scripts/decrypt-user-secrets.ts":m7,"deploy/scripts/resolve-deploy-handles.ts":(e)=>h7(e),"deploy/scripts/helpers.ts":co('"@rizom/ops/deploy"'),"deploy/scripts/resolve-user-config.ts":co("sitePackagesFor"),"deploy/scripts/resolve-missing-images.ts":co("runResolveMissingImages"),"deploy/scripts/sync-content-repo.ts":co("GIT_SYNC_TOKEN"),".github/workflows/build.yml":co("resolve-missing-images.ts"),".github/workflows/deploy.yml":co("install-health-watchdog.ts"),".github/workflows/offboard.yml":co("user:offboard"),".github/workflows/reconcile.yml":co("brains-ops reconcile"),".github/workflows/upgrade.yml":co("brains-ops upgrade")};function y7(e,t,r){let o=c7(e);if(o&&IR(o,t,r))return!0;return g7[e]?.(t,r)??!1}async function pE(e){await Bm(e,{recursive:!0});let t=tc(e,"views","users.md"),r=!0;try{await TN(t)}catch{r=!1}let o=!0;try{await TN(tc(e,"pilot.yaml"))}catch{o=!1}await Bm(tc(e,"users"),{recursive:!0}),await Bm(tc(e,"cohorts"),{recursive:!0});let n=i7.filter((i)=>!(o&&s7.has(i))).map(async(i)=>{let s=tc(e,i);await Bm(n7(s),{recursive:!0}),await b7(i,s)});if(await Promise.all(n),!r)await ao(e)}async function b7(e,t){let r=await S7(e);try{if(await $N(t,r,{flag:"wx"}),dE.has(e))await uE(t,493);return}catch(n){if(!w7(n,"EEXIST"))throw n}let o=await RN(t,"utf8");if(o===r){if(dE.has(e))await uE(t,493);return}if(!y7(e,o,r))return;if(await $N(t,r),dE.has(e))await uE(t,493)}async function S7(e){if(e===".gitignore")return`node_modules/
721
721
  .brains-ops/
722
722
  users/*.secrets.yaml
723
- `;if(e==="deploy/Dockerfile")return kR();if(e==="deploy/kamal/deploy.yml")return qf({serviceName:"rover"});if(e===".kamal/hooks/pre-deploy")return rb({deployConfigPath:"deploy/kamal/deploy.yml",brainYamlPath:"${BRAIN_YAML_PATH:-brain.yaml}"});let t=tc(s7,e),r=await RN(t,"utf8");return S7(r)}function S7(e){return e.replaceAll("__BRAINS_OPS_VERSION__",Zf.version).replaceAll("__BUN_VERSION__",Bun.version)}function v7(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}Mr();Um();RE();ec();no();import{mkdir as ZW,writeFile as UW}from"fs/promises";import{dirname as qW,join as H2}from"path";import{isDeepStrictEqual as MW}from"util";ns();zn();import{mkdtemp as xW,mkdir as _W,readFile as EW,rm as IW,writeFile as kW}from"fs/promises";import{tmpdir as AW}from"os";import{dirname as TW,join as q2}from"path";var $W=["name: Your Name Here","Delete this and write your own"];async function M2(e,t,r,o,n={}){if(o.length===0)return;let i=n.env??process.env,s=on(e),a=Z2(i,s,r.effectiveGitSyncToken),c=n.contentRepoAdminTokenSelector?Z2(i,s,n.contentRepoAdminTokenSelector):void 0,u=OE(r.contentRepo,t),d=n.contentRepoRemoteResolver?.(r,t,a)??CW(u,a);if(!d)return;let f=await xW(q2(AW(),`brains-ops-content-sync-${r.handle}-`)),m=n.runCommand??Lt,h=n.fetchImpl??fetch;try{if(!n.contentRepoRemoteResolver){if(!c)throw Error(`${n.contentRepoAdminTokenSelector??"CONTENT_REPO_ADMIN_TOKEN"} is required to check or create content repos`);await PW(u,c,h)}await m("git",["clone",d,f]),await zW(f,m),await m("git",["config","user.name","brains-ops[bot]"],{cwd:f}),await m("git",["config","user.email","41898282+github-actions[bot]@users.noreply.github.com"],{cwd:f});let b=!1;for(let y of o)if(await RW(f,y))b=!0;if(!b)return;await m("git",["add","."],{cwd:f}),await m("git",["commit","-m",`chore(content): seed ${r.handle} anchor profile`],{cwd:f}),await m("git",["push","origin","HEAD:main"],{cwd:f})}finally{await IW(f,{recursive:!0,force:!0})}}async function RW(e,t){let r=q2(e,t.path),o=await EW(r,"utf8").catch(()=>{return});if(o===t.content)return!1;if(o!==void 0&&!OW(o))return!1;return await _W(TW(r),{recursive:!0}),await kW(r,t.content),!0}function OW(e){return $W.some((t)=>e.includes(t))}function Z2(e,t,r){return Dt(r,e,t)}function CW(e,t){if(!t)return;return`https://x-access-token:${encodeURIComponent(t)}@github.com/${e.org}/${e.name}.git`}async function PW(e,t,r){let{org:o,name:n}=e,s=`https://api.github.com/repos/${`${encodeURIComponent(o)}/${encodeURIComponent(n)}`}`,a={Accept:"application/vnd.github+json",Authorization:`Bearer ${t}`,"User-Agent":"brains-ops","X-GitHub-Api-Version":"2022-11-28"},c=await r(s,{headers:a});if(c.ok)return;if(c.status!==404)throw Error(`Failed to check GitHub repo ${o}/${n}: ${c.status} ${await U2(c)}`);let u=await r(`https://api.github.com/orgs/${encodeURIComponent(o)}/repos`,{method:"POST",headers:a,body:JSON.stringify({name:n,private:!0,auto_init:!1})});if(u.ok){console.log(`Created missing content repo ${o}/${n}`);return}if(u.status===422){if((await r(s,{headers:a})).ok)return}throw Error(`Failed to create GitHub repo ${o}/${n}: ${u.status} ${await U2(u)}`)}async function U2(e){let t=await e.text();return t.trim().length===0?e.statusText:t}async function zW(e,t){try{await t("git",["checkout","-B","main","origin/main"],{cwd:e})}catch{await t("git",["checkout","-B","main"],{cwd:e})}}PE();Mr();async function oc(e,t,r,o,n={}){let i=Qm(t.pilot.githubOrg);for(let s of r){let a={};if(o){let m=await o(s);if(m!==void 0)a=m}let c=await i(s),u=a.brainYaml??c.brainYaml,d=a.envFile??c.envFile,f=a.contentRepoFiles??c.contentRepoFiles??[];if(d)await zE(e,s.handle,".env",d);if(u)await zE(e,s.handle,"brain.yaml",u);await M2(e,t.pilot.githubOrg,s,f,{contentRepoAdminTokenSelector:t.pilot.contentRepoAdminToken,...n});for(let m of f)await zE(e,s.handle,H2("content",m.path),m.content)}}async function zE(e,t,r,o){let n=H2(e,"users",t,r),i=Bun.file(n);if(r==="brain.yaml"&&await i.exists()){let s=sn(await i.text()),a=sn(o);if(s.ok&&a.ok&&MW(s.data,a.data))return}await ZW(qW(n),{recursive:!0}),await UW(n,o)}async function Ym(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown user handle: ${t}`);return{registry:r,user:o}}async function V2(e,t){let r=await ut(e),o=r.cohorts.find((n)=>n.id===t);if(!o)throw Error(`Unknown cohort: ${t}`);return{registry:r,users:r.users.filter((n)=>n.cohort===o.id)}}async function W2(e){let t=await ut(e);return{registry:t,users:t.users}}async function NE(e,t,r,o={}){let{registry:n,user:i}=await Ym(e,t);await oc(e,n,[i],r,o)}no();Pn();import{access as FW,mkdir as G2,readFile as JW,writeFile as Y2}from"fs/promises";import{basename as KW,join as ic}from"path";async function DE(e,t,r){let o=pr.parse(t),n=pr.parse(r.cohort),i=ic(e,"users"),s=ic(e,"cohorts"),a=ic(i,`${o}.yaml`),c=ic(i,`${o}.secrets.yaml`),u=ic(i,`${o}.secrets.yaml.age`),d=ic(s,`${n}.yaml`);await Promise.all([G2(i,{recursive:!0}),G2(s,{recursive:!0})]);let f=r.discord===!0||Boolean(r.anchorId),m=await Q2(a,WW(o,f,r.anchorId)),b=await YW(u)?!1:await Q2(c,GW(o,f)),{addedToCohort:y}=await HW(d,o);return{handle:o,cohort:n,userPath:a,secretsTemplatePath:c,cohortPath:d,createdUser:m,createdSecretsTemplate:b,addedToCohort:y}}async function HW(e,t){let r=await VW(e);if(r.members.includes(t))return{addedToCohort:!1};let o={...r,members:[...r.members,t].sort()};return await Y2(e,QW(o)),{addedToCohort:!0}}async function VW(e){try{let t=await JW(e,"utf8"),r=sn(t,qr);if(!r.ok)throw Error(`${KW(e)}: ${r.error}`);return r.data}catch(t){if(eG(t))return{members:[]};throw t}}function WW(e,t,r){return[`handle: ${e}`,"anchorProfile:",` name: ${tG(e)}`,"discord:",` enabled: ${String(t)}`,...t&&r?[` anchorUserId: ${JSON.stringify(r)}`]:[],""].join(`
724
- `)}function GW(e,t){return["# local per-user secret staging file",`# fill values, run \`bunx brains-ops secrets:encrypt . ${e}\`, then the plaintext file will be removed`,...t?["discordBotToken: "]:[],"atprotoAppPassword: ","# For custom-domain sites, paste PEMs with literal \\n escapes.","certificatePem: ","privateKeyPem: ",""].join(`
725
- `)}function QW(e){return["members:",...e.members.map((t)=>` - ${t}`),...e.brainVersionOverride?[`brainVersionOverride: ${e.brainVersionOverride}`]:[],...e.bundlesOverride?["bundlesOverride:",...e.bundlesOverride.map((t)=>` - ${t}`)]:[],...e.addOverride?["addOverride:",...e.addOverride.map((t)=>` - ${t}`)]:[],...e.removeOverride?["removeOverride:",...e.removeOverride.map((t)=>` - ${t}`)]:[],...e.aiApiKeyOverride?[`aiApiKeyOverride: ${e.aiApiKeyOverride}`]:[],...e.gitSyncTokenOverride?[`gitSyncTokenOverride: ${e.gitSyncTokenOverride}`]:[],""].join(`
726
- `)}async function Q2(e,t){try{return await Y2(e,t,{flag:"wx"}),!0}catch(r){if(XW(r))return!1;throw r}}async function YW(e){try{return await FW(e),!0}catch{return!1}}function XW(e){return X2(e,"EEXIST")}function eG(e){return X2(e,"ENOENT")}function X2(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function tG(e){return e.split("-").filter((t)=>t.length>0).map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}QI();async function YI(e,t,r,o={}){let{registry:n,users:i}=await V2(e,t);await oc(e,n,i,r,o)}async function ed(e,t,r={}){let{registry:o,users:n}=await W2(e);await oc(e,o,n,t,r)}import{parseArgs as cie}from"util";function ot(e){return e}class hB extends Error{constructor(e){super(e);this.name="CliUsageError"}}function lie(e,t){let r={...t};for(let o of e)for(let[n,i]of Object.entries(o.flags??{})){let s=r[n];if(s===void 0){r[n]=i;continue}if(s.type!==i.type||s.short!==i.short||s.default!==i.default)throw Error(`Conflicting definitions for flag --${n}: commands must agree on type, short, and default`)}return r}function uie(e){let t={};for(let[r,o]of Object.entries(e))t[r]={type:o.type,...o.short!==void 0?{short:o.short}:{},...o.default!==void 0?{default:o.default}:{}};return t}function die(e){if(!(e instanceof Error)||!("code"in e))return!1;return e.code==="ERR_PARSE_ARGS_UNKNOWN_OPTION"||e.code==="ERR_PARSE_ARGS_INVALID_OPTION_VALUE"}function gB(e,t){let r=lie(t.commands,t.globalFlags??{}),o,n;try{({values:o,positionals:n}=cie({args:e,options:uie(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(die(s))throw new hB(s.message.split(". ")[0]??s.message);throw s}if("help"in r&&o.help===!0)return{command:"help",args:[],flags:{help:!0}};if("version"in r&&o.version===!0)return{command:"version",args:[],flags:{version:!0}};let i={};for(let[s,a]of Object.entries(r)){let c=o[s];if(typeof c==="string"&&a.type==="string")i[s]=c;else if(typeof c==="boolean"&&a.type==="boolean")i[s]=c}return{command:n[0]??"help",args:n.slice(1),flags:i}}function yB(e){let t=e.reduce((r,o)=>Math.max(r,o.label.length),0);return e.map((r)=>` ${r.label.padEnd(t)} ${r.description}`)}function fie(e){return yB(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function pie(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",o=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${o}`}function bB(e){return yB(Object.entries(e).map(([t,r])=>({label:pie(t,r),description:r.description})))}function SB(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function mie(e){return JSON.stringify(Object.entries(e).map(([t,r])=>[t,r.type,r.short??"",r.description,r.placeholder??"",r.default??""]).sort((t,r)=>String(t[0]).localeCompare(String(r[0]))))}function hie(e){let t=[],r=new Map;for(let n of e){let i=n.flags??{};if(Object.keys(i).length===0)continue;let s=mie(i),a=r.get(s);if(a){a.names.push(n.name);continue}let c={names:[n.name],flags:i};r.set(s,c),t.push(c)}let o=[];for(let n of t)o.push("",`${n.names.join(" / ")} options:`),o.push(...bB(n.flags));return o}function vB(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...fie(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...bB(e.globalFlags));return t.push(...hie(e.commands)),t.join(`
727
- `)}function wB(e){let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate command name: ${r.name}`);t.set(r.name,r)}return t}function nt(e,t){let r=e[t];return typeof r==="string"?r:void 0}function Is(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}import{existsSync as qae,mkdirSync as Mae,readFileSync as jA,writeFileSync as ZA}from"fs";import{dirname as Fae,join as RU}from"path";function XI(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function vt(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw RangeError(`${r}expected integer >= 0, got ${e}`)}}function Ft(e,t,r=""){let o=XI(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function yo(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(vt(e.outputLen),vt(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function vc(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function Mh(e,t){Ft(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function Fh(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function mr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function wc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function dn(e,t){return e<<32-t|e>>>t}function Fe(e,t){return e<<t|e>>>32-t>>>0}var gie=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function yie(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function bie(e){for(let t=0;t<e.length;t++)e[t]=yie(e[t]);return e}var ek=gie?(e)=>e:bie,_B=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Sie=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Jh(e){if(Ft(e),_B)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Sie[e[r]];return t}var go={_0:48,_9:57,A:65,F:70,a:97,f:102};function xB(e){if(e>=go._0&&e<=go._9)return e-go._0;if(e>=go.A&&e<=go.F)return e-(go.A-10);if(e>=go.a&&e<=go.f)return e-(go.a-10);return}function td(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(_B)try{return Uint8Array.fromHex(e)}catch(n){if(n instanceof SyntaxError)throw RangeError(n.message);throw n}let t=e.length,r=t/2;if(t%2)throw RangeError("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=xB(e.charCodeAt(i)),a=xB(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function vie(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function tk(e,t=""){if(typeof e==="string")return vie(e);return Ft(e,void 0,t)}function rk(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Ft(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function Kh(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw TypeError("options must be object or undefined");return Object.assign(e,t)}function nk(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.canXOF=o.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function bo(e=32){vt(e,"bytesLength");let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var ok=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class ik{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(yo(e),Ft(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),mr(o)}update(e){return vc(this),this.iHash.update(e),this}digestInto(e){vc(this),Mh(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Bn=(()=>{let e=(t,r,o)=>new ik(t,r).update(o).digest();return e.create=(t,r)=>new ik(t,r),e})();function rd(e,t,r){if(yo(e),r===void 0)r=new Uint8Array(e.outputLen);return Bn(e,r,t)}var sk=Uint8Array.of(0),EB=Uint8Array.of();function ak(e,t,r,o=32){yo(e),vt(o,"length"),Ft(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=EB;else Ft(r,void 0,"info");let s=new Uint8Array(i*n),a=Bn.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)sk[0]=d+1,c.update(d===0?EB:u).update(r).update(sk).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),mr(u,sk),s.slice(0,o)}var gi=(e,t,r,o,n)=>ak(e,rd(e,t,r),o,n);function IB(e,t,r){return e&t^~e&r}function kB(e,t,r){return e&t^e&r^t&r}class Hh{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=wc(this.buffer)}update(e){vc(this),Ft(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=wc(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){vc(this),Mh(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,mr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=wc(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var So=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Jt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Vh=BigInt(4294967295),AB=BigInt(32);function wie(e,t=!1){if(t)return{h:Number(e&Vh),l:Number(e>>AB&Vh)};return{h:Number(e>>AB&Vh)|0,l:Number(e&Vh)|0}}function TB(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=wie(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var ck=(e,t,r)=>e>>>r,lk=(e,t,r)=>e<<32-r|t>>>r,ks=(e,t,r)=>e>>>r|t<<32-r,As=(e,t,r)=>e<<32-r|t>>>r,nd=(e,t,r)=>e<<64-r|t>>>r-32,od=(e,t,r)=>e>>>r-32|t<<64-r;function jn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var $B=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),RB=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,OB=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),CB=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,PB=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),zB=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var _ie=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),yi=new Uint32Array(64);class NB extends Hh{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)yi[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=yi[d-15],m=yi[d-2],h=dn(f,7)^dn(f,18)^f>>>3,b=dn(m,17)^dn(m,19)^m>>>10;yi[d]=b+yi[d-7]+h+yi[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let f=dn(s,6)^dn(s,11)^dn(s,25),m=u+f+IB(s,a,c)+_ie[d]+yi[d]|0,b=(dn(r,2)^dn(r,13)^dn(r,22))+kB(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){mr(yi)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),mr(this.buffer)}}class DB extends NB{A=So[0]|0;B=So[1]|0;C=So[2]|0;D=So[3]|0;E=So[4]|0;F=So[5]|0;G=So[6]|0;H=So[7]|0;constructor(){super(32)}}var LB=(()=>TB(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e)=>BigInt(e))))(),Eie=(()=>LB[0])(),Iie=(()=>LB[1])(),bi=new Uint32Array(80),Si=new Uint32Array(80);class BB extends Hh{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)bi[_]=e.getUint32(t),Si[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=bi[_-15]|0,O=Si[_-15]|0,L=ks(A,O,1)^ks(A,O,8)^ck(A,O,7),z=As(A,O,1)^As(A,O,8)^lk(A,O,7),K=bi[_-2]|0,P=Si[_-2]|0,W=ks(K,P,19)^nd(K,P,61)^ck(K,P,6),ee=As(K,P,19)^od(K,P,61)^lk(K,P,6),j=OB(z,ee,Si[_-7],Si[_-16]),R=CB(j,L,W,bi[_-7],bi[_-16]);bi[_]=R|0,Si[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=ks(d,f,14)^ks(d,f,18)^nd(d,f,41),O=As(d,f,14)^As(d,f,18)^od(d,f,41),L=d&m^~d&b,z=f&h^~f&y,K=PB(x,O,z,Iie[_],Si[_]),P=zB(K,S,A,L,Eie[_],bi[_]),W=K|0,ee=ks(r,o,28)^nd(r,o,34)^nd(r,o,39),j=As(r,o,28)^od(r,o,34)^od(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=jn(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let I=$B(W,j,B);r=RB(I,P,ee,R),o=I|0}({h:r,l:o}=jn(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=jn(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=jn(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=jn(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:f}=jn(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=jn(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=jn(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=jn(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,f,m,h,b,y,S,x)}roundClean(){mr(bi,Si)}destroy(){this.destroyed=!0,mr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class jB extends BB{Ah=Jt[0]|0;Al=Jt[1]|0;Bh=Jt[2]|0;Bl=Jt[3]|0;Ch=Jt[4]|0;Cl=Jt[5]|0;Dh=Jt[6]|0;Dl=Jt[7]|0;Eh=Jt[8]|0;El=Jt[9]|0;Fh=Jt[10]|0;Fl=Jt[11]|0;Gh=Jt[12]|0;Gl=Jt[13]|0;Hh=Jt[14]|0;Hl=Jt[15]|0;constructor(){super(64)}}var wt=nk(()=>new DB,ok(1));var Wh=nk(()=>new jB,ok(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function eg(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function fk(e){if(!eg(e))throw TypeError("Uint8Array expected")}function FB(e,t){if(!Array.isArray(t))return!1;if(t.length===0)return!0;if(e)return t.every((r)=>typeof r==="string");else return t.every((r)=>Number.isSafeInteger(r))}function JB(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function vi(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function sd(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Qh(e){if(!Array.isArray(e))throw TypeError("array expected")}function Yh(e,t){if(!FB(!0,t))throw TypeError(`${e}: array of strings expected`)}function pk(e,t){if(!FB(!1,t))throw TypeError(`${e}: array of numbers expected`)}function Pr(...e){let t=(i)=>i,r=(i,s)=>(a)=>i(s(a)),o=e.map((i)=>i.encode).reduceRight(r,t),n=e.map((i)=>i.decode).reduce(r,t);return{encode:o,decode:n}}function zr(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Yh("alphabet",t);let o=new Map(t.map((n,i)=>[n,i]));return{encode:(n)=>(Qh(n),n.map((i)=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:(n)=>(Qh(n),n.map((i)=>{vi("alphabet.decode",i);let s=o.get(i);if(s===void 0)throw Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function Nr(e=""){return vi("join",e),{encode:(t)=>(Yh("join.decode",t),t.join(e)),decode:(t)=>(vi("join.decode",t),t.split(e))}}function tg(e,t="="){return sd(e),vi("padding",t),{encode(r){Yh("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Yh("padding.decode",r);let o=r.length;if(o*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function KB(e){return JB(e),{encode:(t)=>t,decode:(t)=>e(t)}}function ZB(e,t,r){if(t<2)throw RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw RangeError(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Qh(e),!e.length)return[];let o=0,n=[],i=Array.from(e,(a)=>{if(sd(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=i.length;while(!0){let a=0,c=!0;for(let u=o;u<s;u++){let d=i[u],f=t*a,m=f+d;if(!Number.isSafeInteger(m)||f/t!==a||m-d!==f)throw Error("convertRadix: carry overflow");let h=m/r;a=m%r;let b=Math.floor(h);if(i[u]=b,!Number.isSafeInteger(b)||b*r+a!==m)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!b)o=u;else c=!1}if(n.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)n.push(0);return n.reverse()}var HB=(e,t)=>t===0?e:HB(t,e%t),Xh=(e,t)=>e+(t-HB(e,t)),Gh=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function uk(e,t,r,o){if(Qh(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Xh(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Xh(t,r)}`);let n=0,i=0,s=Gh[t],a=Gh[r]-1,c=[];for(let u of e){if(sd(u),u>=s)throw Error(`convertRadix2: invalid data word=${u} from=${t}`);if(n=n<<t|u,i+t>32)throw Error(`convertRadix2: carry overflow pos=${i} from=${t}`);i+=t;for(;i>=r;i-=r)c.push((n>>i-r&a)>>>0);let d=Gh[i];if(d===void 0)throw Error("invalid carry");n&=d-1}if(n=n<<r-i&a,!o&&i>=t)throw Error("Excess padding");if(!o&&n>0)throw Error(`Non-zero padding: ${n}`);if(o&&i>0)c.push(n>>>0);return c}function kie(e){sd(e);let t=256;return{encode:(r)=>{if(!eg(r))throw TypeError("radix.encode input should be Uint8Array");return ZB(Array.from(r),t,e)},decode:(r)=>(pk("radix.decode",r),Uint8Array.from(ZB(r,e,t)))}}function Kr(e,t=!1){if(sd(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Xh(8,e)>32||Xh(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!eg(r))throw TypeError("radix2.encode input should be Uint8Array");return uk(Array.from(r),8,e,!t)},decode:(r)=>(pk("radix2.decode",r),Uint8Array.from(uk(r,e,8,t)))}}function UB(e){return JB(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var PTe=Object.freeze(Pr(Kr(4),zr("0123456789ABCDEF"),Nr(""))),zTe=Object.freeze(Pr(Kr(5),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),tg(5),Nr(""))),NTe=Object.freeze(Pr(Kr(5),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Nr(""))),DTe=Object.freeze(Pr(Kr(5),zr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),tg(5),Nr(""))),LTe=Object.freeze(Pr(Kr(5),zr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Nr(""))),BTe=Object.freeze(Pr(Kr(5),zr("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Nr(""),KB((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),VB=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),Aie=/[\t\n\f\r ]/,WB=(e,t)=>{vi("base64",e);let r=t?"base64url":"base64";if(e.length>0&&Aie.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},mk=Object.freeze(VB?{encode(e){return fk(e),e.toBase64()},decode(e){return WB(e,!1)}}:Pr(Kr(6),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),tg(6),Nr(""))),tr=Object.freeze(Pr(Kr(6),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Nr(""))),jTe=Object.freeze(VB?{encode(e){return fk(e),e.toBase64({alphabet:"base64url"})},decode(e){return WB(e,!0)}}:Pr(Kr(6),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),tg(6),Nr(""))),ZTe=Object.freeze(Pr(Kr(6),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Nr(""))),hk=(e)=>Pr(kie(58),zr(e),Nr("")),UTe=Object.freeze(hk("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),qTe=Object.freeze(hk("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),MTe=Object.freeze(hk("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var dk=Pr(zr("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Nr("")),qB=[996825010,642813549,513874426,1027748829,705979059];function id(e){let t=e>>25,r=(e&33554431)<<5;for(let o=0;o<qB.length;o++)if((t>>o&1)===1)r^=qB[o];return r}function MB(e,t,r=1){let o=e.length,n=1;for(let i=0;i<o;i++){let s=e.charCodeAt(i);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=id(n)^s>>5}n=id(n);for(let i=0;i<o;i++)n=id(n)^e.charCodeAt(i)&31;for(let i of t)n=id(n)^i;for(let i=0;i<6;i++)n=id(n);return n^=r,dk.encode(uk([n%Gh[30]],30,5,!1))}function GB(e){let t=e==="bech32"?1:734539939,r=Kr(5),o=r.decode,n=r.encode,i=UB(o);function s(f,m,h=90){if(vi("bech32.encode prefix",f),eg(m))m=Array.from(m);pk("bech32.encode",m);let b=f.length;if(b===0)throw TypeError(`Invalid prefix length ${b}`);let y=b+7+m.length;if(h!==!1&&y>h)throw TypeError(`Length ${y} exceeds limit ${h}`);let S=f.toLowerCase(),x=MB(S,m,t);return`${S}1${dk.encode(m)}${x}`}function a(f,m=90){vi("bech32.decode input",f);let h=f.length;if(h<8||m!==!1&&h>m)throw TypeError(`invalid string length: ${h} (${f}). Expected (8..${m})`);let b=f.toLowerCase();if(f!==b&&f!==f.toUpperCase())throw Error("String must be lowercase or uppercase");let y=b.lastIndexOf("1");if(y===0||y===-1)throw Error('Letter "1" must be present between prefix and data only');let S=b.slice(0,y),x=b.slice(y+1);if(x.length<6)throw Error("Data must be at least 6 characters long");let _=dk.decode(x).slice(0,-6),A=MB(S,_,t);if(!x.endsWith(A))throw Error(`Invalid checksum in ${f}: expected "${A}"`);return{prefix:S,words:_}}let c=UB(a);function u(f){let{prefix:m,words:h}=a(f,!1);return{prefix:m,words:h,bytes:o(h)}}function d(f,m){return s(f,n(m))}return{encode:s,decode:a,encodeFromBytes:d,decodeToBytes:u,decodeUnsafe:c,fromWords:o,fromWordsUnsafe:i,toWords:n}}var Dr=Object.freeze(GB("bech32")),FTe=Object.freeze(GB("bech32m"));var Tie=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),$ie={encode(e){return fk(e),e.toHex()},decode(e){return vi("hex",e),Uint8Array.fromHex(e)}},JTe=Object.freeze(Tie?$ie:Pr(Kr(4),zr("0123456789abcdef"),Nr(""),KB((e)=>{if(typeof e!=="string"||e.length%2!==0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));function Oie(e,t,r,o){yo(e);let n=Kh({dkLen:32,asyncTick:10},o),{c:i,dkLen:s,asyncTick:a}=n;if(vt(i,"c"),vt(s,"dkLen"),vt(a,"asyncTick"),i<1)throw Error("iterations (c) must be >= 1");if(s<1)throw Error('"dkLen" must be >= 1');if(s>4294967295*e.outputLen)throw Error("derived key too long");let c=tk(t,"password"),u=tk(r,"salt"),d=new Uint8Array(s),f=Bn.create(e,c),m=f._cloneInto().update(u);return{c:i,dkLen:s,asyncTick:a,DK:d,PRF:f,PRFSalt:m}}function Cie(e,t,r,o,n){if(e.destroy(),t.destroy(),o)o.destroy();return mr(n),r}function gk(e,t,r,o){let{c:n,dkLen:i,DK:s,PRF:a,PRFSalt:c}=Oie(e,t,r,o),u,d=new Uint8Array(4),f=wc(d),m=new Uint8Array(a.outputLen);for(let h=1,b=0;b<i;h++,b+=a.outputLen){let y=s.subarray(b,b+a.outputLen);f.setInt32(0,h,!1),(u=c._cloneInto(u)).update(d).digestInto(m),y.set(m.subarray(0,y.length));for(let S=1;S<n;S++){a._cloneInto(u).update(m).digestInto(m);for(let x=0;x<y.length;x++)y[x]^=m[x]}}return Cie(a,c,s,u,m)}function QB(e,t,r,o,n,i){let s=e[t++]^r[o++],a=e[t++]^r[o++],c=e[t++]^r[o++],u=e[t++]^r[o++],d=e[t++]^r[o++],f=e[t++]^r[o++],m=e[t++]^r[o++],h=e[t++]^r[o++],b=e[t++]^r[o++],y=e[t++]^r[o++],S=e[t++]^r[o++],x=e[t++]^r[o++],_=e[t++]^r[o++],A=e[t++]^r[o++],O=e[t++]^r[o++],L=e[t++]^r[o++],z=s,K=a,P=c,W=u,ee=d,j=f,R=m,B=h,I=b,T=y,k=S,M=x,N=_,H=A,G=O,re=L;for(let ae=0;ae<8;ae+=2)ee^=Fe(z+N|0,7),I^=Fe(ee+z|0,9),N^=Fe(I+ee|0,13),z^=Fe(N+I|0,18),T^=Fe(j+K|0,7),H^=Fe(T+j|0,9),K^=Fe(H+T|0,13),j^=Fe(K+H|0,18),G^=Fe(k+R|0,7),P^=Fe(G+k|0,9),R^=Fe(P+G|0,13),k^=Fe(R+P|0,18),W^=Fe(re+M|0,7),B^=Fe(W+re|0,9),M^=Fe(B+W|0,13),re^=Fe(M+B|0,18),K^=Fe(z+W|0,7),P^=Fe(K+z|0,9),W^=Fe(P+K|0,13),z^=Fe(W+P|0,18),R^=Fe(j+ee|0,7),B^=Fe(R+j|0,9),ee^=Fe(B+R|0,13),j^=Fe(ee+B|0,18),M^=Fe(k+T|0,7),I^=Fe(M+k|0,9),T^=Fe(I+M|0,13),k^=Fe(T+I|0,18),N^=Fe(re+G|0,7),H^=Fe(N+re|0,9),G^=Fe(H+N|0,13),re^=Fe(G+H|0,18);n[i++]=s+z|0,n[i++]=a+K|0,n[i++]=c+P|0,n[i++]=u+W|0,n[i++]=d+ee|0,n[i++]=f+j|0,n[i++]=m+R|0,n[i++]=h+B|0,n[i++]=b+I|0,n[i++]=y+T|0,n[i++]=S+k|0,n[i++]=x+M|0,n[i++]=_+N|0,n[i++]=A+H|0,n[i++]=O+G|0,n[i++]=L+re|0}function yk(e,t,r,o,n){let i=o+0,s=o+16*n;for(let a=0;a<16;a++)r[s+a]=e[t+(2*n-1)*16+a];for(let a=0;a<n;a++,i+=16,t+=16){if(QB(r,s,e,t,r,i),a>0)s+=16;QB(r,i,e,t+=16,r,s)}}function Pie(e,t,r){let o=Kh({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:i,p:s,dkLen:a,asyncTick:c,maxmem:u,onProgress:d}=o;if(vt(n,"N"),vt(i,"r"),vt(s,"p"),vt(a,"dkLen"),vt(c,"asyncTick"),vt(u,"maxmem"),d!==void 0&&typeof d!=="function")throw Error("progressCb must be a function");let f=128*i,m=f/4,h=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>h)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(h-1)*32/f)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(h-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let b=f*(n+s+1);if(b>u)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+b+", maxmem="+u);let y=gk(wt,e,t,{c:1,dkLen:f*s}),S=Fh(y),x=Fh(new Uint8Array(f*n)),_=Fh(new Uint8Array(f)),A=()=>{};if(d){let O=2*n*s,L=Math.max(Math.floor(O/1e4),1),z=0;A=()=>{if(z++,d&&(!(z%L)||z===O))d(z/O)}}return{N:n,r:i,p:s,dkLen:a,blockSize32:m,V:x,B32:S,B:y,tmp:_,blockMixCb:A,asyncTick:c}}function zie(e,t,r,o,n){let i=gk(wt,e,r,{c:1,dkLen:t});return mr(r,o,n),i}function bk(e,t,r){let{N:o,r:n,p:i,dkLen:s,blockSize32:a,V:c,B32:u,B:d,tmp:f,blockMixCb:m}=Pie(e,t,r);ek(u);for(let h=0;h<i;h++){let b=a*h;for(let y=0;y<a;y++)c[y]=u[b+y];for(let y=0,S=0;y<o-1;y++)yk(c,S,c,S+=a,n),m();yk(c,(o-1)*a,u,b,n),m();for(let y=0;y<o;y++){let S=(u[b+a-16]&o-1)>>>0;for(let x=0;x<a;x++)f[x]=u[b+x]^c[S*a+x];yk(f,0,u,b,n),m()}}return ek(u),zie(e,s,d,c,f)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function Nie(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function rg(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function xc(e){if(typeof e!=="number")throw TypeError("number expected, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError("positive integer expected, got "+e)}function Ot(e,t,r=""){let o=Nie(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function Sk(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function YB(e,t,r=!1){Ot(e,void 0,"output");let o=t.outputLen;if(e.length<o)throw RangeError("digestInto() expects output buffer of length at least "+o);if(r&&!_c(e))throw Error("invalid output, must be aligned")}function Zn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function fn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Die(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var Ts=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),Lie=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var Bie=(e)=>{for(let t=0;t<e.length;t++)e[t]=Lie(e[t]);return e},vo=Ts?(e)=>e:Bie;function XB(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function ej(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function tj(e,t,r){let o=t,n=r||(()=>[]),i=(a,c)=>o(c,...n(a)).update(a).digest(),s=o(new Uint8Array(e),...n(new Uint8Array(0)));return i.outputLen=s.outputLen,i.blockLen=s.blockLen,i.create=(a,...c)=>o(a,...c),i}var rj=(e,t)=>{function r(o,...n){if(Ot(o,void 0,"key"),e.nonceLength!==void 0){let d=n[0];Ot(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let i=e.tagLength;if(i&&n[1]!==void 0)Ot(n[1],void 0,"AAD");let s=t(o,...n),a=(d,f)=>{if(f!==void 0){if(d!==2)throw Error("cipher output not supported");Ot(f,void 0,"output")}},c=!1;return{encrypt(d,f){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Ot(d),a(s.encrypt.length,f),s.encrypt(d,f)},decrypt(d,f){if(Ot(d),i&&d.length<i)throw Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,f),s.decrypt(d,f)}}}return Object.assign(r,e),r};function ad(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Ot(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!_c(t))throw Error("invalid output, must be aligned");return t}function nj(e,t,r){xc(e),xc(t),rg(r);let o=new Uint8Array(16),n=Die(o);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),o}function _c(e){return e.byteOffset%4===0}function Ec(e){return Uint8Array.from(Ot(e))}var ij=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),jie=(()=>vo(Zn(ij("expand 16-byte k"))))(),Zie=(()=>vo(Zn(ij("expand 32-byte k"))))();function Je(e,t){return e<<t|e>>>32-t}var cd=64,Uie=16,vk=(()=>4294967295)(),oj=Uint32Array.of();function qie(e,t,r,o,n,i,s,a){let c=n.length,u=new Uint8Array(cd),d=Zn(u),f=Ts&&_c(n)&&_c(i),m=f?Zn(n):oj,h=f?Zn(i):oj;if(!Ts){for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),vo(d),s>=vk)throw Error("arx: counter overflow");let y=Math.min(cd,c-b);for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}return}for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),s>=vk)throw Error("arx: counter overflow");let y=Math.min(cd,c-b);if(f&&y===cd){let S=b/4;if(b%4!==0)throw Error("arx: invalid block position");for(let x=0,_;x<Uie;x++)_=S+x,h[_]=m[_]^d[x];b+=cd;continue}for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}}function sj(e,t){let{allowShortKeys:r,extendNonceFn:o,counterLength:n,counterRight:i,rounds:s}=XB({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return xc(n),xc(s),rg(i),rg(r),(a,c,u,d,f=0)=>{Ot(a,void 0,"key"),Ot(c,void 0,"nonce"),Ot(u,void 0,"data");let m=u.length;if(d=ad(m,d,!1),xc(f),f<0||f>=vk)throw Error("arx: counter overflow");let h=[],b=a.length,y,S;if(b===32)h.push(y=Ec(a)),S=Zie;else if(b===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),S=jie,h.push(y);else throw Ot(a,32,"arx key"),Error("invalid key size");if(!Ts||!_c(c))h.push(c=Ec(c));let x=Zn(y);if(o){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let O=c.subarray(0,16);if(Ts)o(S,x,Zn(O),x);else{let L=vo(Uint32Array.from(S));o(L,x,Zn(O),x),fn(L),vo(x)}c=c.subarray(16)}else if(!Ts)vo(x);let _=16-n;if(_!==c.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let O=new Uint8Array(12);O.set(c,i?0:12-c.length),c=O,h.push(c)}let A=vo(Zn(c));try{return qie(e,S,x,A,u,d,f,s),d}finally{fn(...h)}}}function Kt(e,t){return e[t++]&255|(e[t++]&255)<<8}class aj{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=Ec(Ot(e,32,"key"));let t=Kt(e,0),r=Kt(e,2),o=Kt(e,4),n=Kt(e,6),i=Kt(e,8),s=Kt(e,10),a=Kt(e,12),c=Kt(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|n<<9)&8191,this.r[4]=(n>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Kt(e,16+2*u)}process(e,t,r=!1){let o=r?0:2048,{h:n,r:i}=this,s=i[0],a=i[1],c=i[2],u=i[3],d=i[4],f=i[5],m=i[6],h=i[7],b=i[8],y=i[9],S=Kt(e,t+0),x=Kt(e,t+2),_=Kt(e,t+4),A=Kt(e,t+6),O=Kt(e,t+8),L=Kt(e,t+10),z=Kt(e,t+12),K=Kt(e,t+14),P=n[0]+(S&8191),W=n[1]+((S>>>13|x<<3)&8191),ee=n[2]+((x>>>10|_<<6)&8191),j=n[3]+((_>>>7|A<<9)&8191),R=n[4]+((A>>>4|O<<12)&8191),B=n[5]+(O>>>1&8191),I=n[6]+((O>>>14|L<<2)&8191),T=n[7]+((L>>>11|z<<5)&8191),k=n[8]+((z>>>8|K<<8)&8191),M=n[9]+(K>>>5|o),N=0,H=N+P*s+W*(5*y)+ee*(5*b)+j*(5*h)+R*(5*m);N=H>>>13,H&=8191,H+=B*(5*f)+I*(5*d)+T*(5*u)+k*(5*c)+M*(5*a),N+=H>>>13,H&=8191;let G=N+P*a+W*s+ee*(5*y)+j*(5*b)+R*(5*h);N=G>>>13,G&=8191,G+=B*(5*m)+I*(5*f)+T*(5*d)+k*(5*u)+M*(5*c),N+=G>>>13,G&=8191;let re=N+P*c+W*a+ee*s+j*(5*y)+R*(5*b);N=re>>>13,re&=8191,re+=B*(5*h)+I*(5*m)+T*(5*f)+k*(5*d)+M*(5*u),N+=re>>>13,re&=8191;let ae=N+P*u+W*c+ee*a+j*s+R*(5*y);N=ae>>>13,ae&=8191,ae+=B*(5*b)+I*(5*h)+T*(5*m)+k*(5*f)+M*(5*d),N+=ae>>>13,ae&=8191;let pe=N+P*d+W*u+ee*c+j*a+R*s;N=pe>>>13,pe&=8191,pe+=B*(5*y)+I*(5*b)+T*(5*h)+k*(5*m)+M*(5*f),N+=pe>>>13,pe&=8191;let be=N+P*f+W*d+ee*u+j*c+R*a;N=be>>>13,be&=8191,be+=B*s+I*(5*y)+T*(5*b)+k*(5*h)+M*(5*m),N+=be>>>13,be&=8191;let ve=N+P*m+W*f+ee*d+j*u+R*c;N=ve>>>13,ve&=8191,ve+=B*a+I*s+T*(5*y)+k*(5*b)+M*(5*h),N+=ve>>>13,ve&=8191;let ke=N+P*h+W*m+ee*f+j*d+R*u;N=ke>>>13,ke&=8191,ke+=B*c+I*a+T*s+k*(5*y)+M*(5*b),N+=ke>>>13,ke&=8191;let Ie=N+P*b+W*h+ee*m+j*f+R*d;N=Ie>>>13,Ie&=8191,Ie+=B*u+I*c+T*a+k*s+M*(5*y),N+=Ie>>>13,Ie&=8191;let we=N+P*y+W*b+ee*h+j*m+R*f;N=we>>>13,we&=8191,we+=B*d+I*u+T*c+k*a+M*s,N+=we>>>13,we&=8191,N=(N<<2)+N|0,N=N+H|0,H=N&8191,N=N>>>13,G+=N,n[0]=H,n[1]=G,n[2]=re,n[3]=ae,n[4]=pe,n[5]=be,n[6]=ve,n[7]=ke,n[8]=Ie,n[9]=we}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),o=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=o,o=e[s]>>>13,e[s]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+o,o=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(o^1)-1;for(let s=0;s<10;s++)r[s]&=n;n=~n;for(let s=0;s<10;s++)e[s]=e[s]&n|r[s];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let i=e[0]+t[0];e[0]=i&65535;for(let s=1;s<8;s++)i=(e[s]+t[s]|0)+(i>>>16)|0,e[s]=i&65535;fn(r)}update(e){Sk(this),Ot(e),e=Ec(e);let{buffer:t,blockLen:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(r-this.pos,o-n);if(i===r){for(;r<=o-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+i),this.pos),this.pos+=i,n+=i,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,fn(this.h,this.r,this.buffer,this.pad)}digestInto(e){Sk(this),YB(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:o}=this;if(o){t[o++]=1;for(;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let i=0;i<8;i++)e[n++]=r[i]>>>0,e[n++]=r[i]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var cj=tj(32,(e)=>new aj(e));function Mie(e,t,r,o,n,i=20){let s=e[0],a=e[1],c=e[2],u=e[3],d=t[0],f=t[1],m=t[2],h=t[3],b=t[4],y=t[5],S=t[6],x=t[7],_=n,A=r[0],O=r[1],L=r[2],z=s,K=a,P=c,W=u,ee=d,j=f,R=m,B=h,I=b,T=y,k=S,M=x,N=_,H=A,G=O,re=L;for(let pe=0;pe<i;pe+=2)z=z+ee|0,N=Je(N^z,16),I=I+N|0,ee=Je(ee^I,12),z=z+ee|0,N=Je(N^z,8),I=I+N|0,ee=Je(ee^I,7),K=K+j|0,H=Je(H^K,16),T=T+H|0,j=Je(j^T,12),K=K+j|0,H=Je(H^K,8),T=T+H|0,j=Je(j^T,7),P=P+R|0,G=Je(G^P,16),k=k+G|0,R=Je(R^k,12),P=P+R|0,G=Je(G^P,8),k=k+G|0,R=Je(R^k,7),W=W+B|0,re=Je(re^W,16),M=M+re|0,B=Je(B^M,12),W=W+B|0,re=Je(re^W,8),M=M+re|0,B=Je(B^M,7),z=z+j|0,re=Je(re^z,16),k=k+re|0,j=Je(j^k,12),z=z+j|0,re=Je(re^z,8),k=k+re|0,j=Je(j^k,7),K=K+R|0,N=Je(N^K,16),M=M+N|0,R=Je(R^M,12),K=K+R|0,N=Je(N^K,8),M=M+N|0,R=Je(R^M,7),P=P+B|0,H=Je(H^P,16),I=I+H|0,B=Je(B^I,12),P=P+B|0,H=Je(H^P,8),I=I+H|0,B=Je(B^I,7),W=W+ee|0,G=Je(G^W,16),T=T+G|0,ee=Je(ee^T,12),W=W+ee|0,G=Je(G^W,8),T=T+G|0,ee=Je(ee^T,7);let ae=0;o[ae++]=s+z|0,o[ae++]=a+K|0,o[ae++]=c+P|0,o[ae++]=u+W|0,o[ae++]=d+ee|0,o[ae++]=f+j|0,o[ae++]=m+R|0,o[ae++]=h+B|0,o[ae++]=b+I|0,o[ae++]=y+T|0,o[ae++]=S+k|0,o[ae++]=x+M|0,o[ae++]=_+N|0,o[ae++]=A+H|0,o[ae++]=O+G|0,o[ae++]=L+re|0}var Fie=sj(Mie,{counterRight:!1,counterLength:4,allowShortKeys:!1});var Jie=new Uint8Array(16),lj=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(Jie.subarray(r))},Kie=new Uint8Array(32);function uj(e,t,r,o,n){if(n!==void 0)Ot(n,void 0,"AAD");let i=e(t,r,Kie),s=nj(o.length,n?n.length:0,!0),a=cj.create(i);if(n)lj(a,n);lj(a,o),a.update(s);let c=a.digest();return fn(i,s),c}var Hie=(e)=>(t,r,o)=>({encrypt(i,s){let a=i.length;s=ad(a+16,s,!1),s.set(i);let c=s.subarray(0,-16);e(t,r,c,c,1);let u=uj(e,t,r,c,o);return s.set(u,a),fn(u),s},decrypt(i,s){s=ad(i.length-16,s,!1);let a=i.subarray(0,-16),c=i.subarray(-16),u=uj(e,t,r,a,o);if(!ej(c,u))throw fn(u),Error("invalid tag");return s.set(i.subarray(0,-16)),e(t,r,s,s,1),fn(u),s}}),Hr=rj({blockSize:64,nonceLength:12,tagLength:16},Hie(Fie));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ic(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Bt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Te(e,t,r=""){let o=Ic(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+c)}return e}function Vr(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Bt(e.outputLen),Bt(e.blockLen)}function xo(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function ng(e,t){Te(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function og(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Er(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ig(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function pn(e,t){return e<<32-t|e>>>t}var Vie=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function Wie(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Gie(e){for(let t=0;t<e.length;t++)e[t]=Wie(e[t]);return e}var wk=Vie?(e)=>e:Gie,fj=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Qie=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function $s(e){if(Te(e),fj)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Qie[e[r]];return t}var wo={_0:48,_9:57,A:65,F:70,a:97,f:102};function dj(e){if(e>=wo._0&&e<=wo._9)return e-wo._0;if(e>=wo.A&&e<=wo.F)return e-(wo.A-10);if(e>=wo.a&&e<=wo.f)return e-(wo.a-10);return}function Rs(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(fj)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=dj(e.charCodeAt(i)),a=dj(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw Error('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function It(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Te(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function kc(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function wi(e=32){let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var xi=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var _k=BigInt(0),xk=BigInt(1);function ld(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function pj(e){if(typeof e==="bigint"){if(!sg(e))throw Error("positive bigint expected, got "+e)}else Bt(e);return e}function ud(e){let t=pj(e).toString(16);return t.length&1?"0"+t:t}function mj(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?_k:BigInt("0x"+e)}function _i(e){return mj($s(e))}function Ei(e){return mj($s(ag(Te(e)).reverse()))}function Ac(e,t){Bt(t),e=pj(e);let r=Rs(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function dd(e,t){return Ac(e,t).reverse()}function ag(e){return Uint8Array.from(e)}function Ii(e){return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var sg=(e)=>typeof e==="bigint"&&_k<=e;function Yie(e,t,r){return sg(e)&&sg(t)&&sg(r)&&t<=e&&e<r}function fd(e,t,r,o){if(!Yie(t,r,o))throw Error("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function Ek(e){let t;for(t=0;e>_k;e>>=xk,t+=1);return t}var pd=(e)=>(xk<<BigInt(e))-xk;function hj(e,t,r){if(Bt(e,"hashLen"),Bt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,f=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,It(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return It(...x)};return(S,x)=>{f(),h(S);let _=void 0;while(!(_=x(b())))h();return f(),_}}function Os(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function o(i,s,a){let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw Error(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}function Ik(e){let t=new WeakMap;return(r,...o)=>{let n=t.get(r);if(n!==void 0)return n;let i=e(r,...o);return t.set(r,i),i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var gr=BigInt(0),rr=BigInt(1),Cs=BigInt(2),bj=BigInt(3),Sj=BigInt(4),vj=BigInt(5),Xie=BigInt(7),wj=BigInt(8),ese=BigInt(9),xj=BigInt(16);function hr(e,t){let r=e%t;return r>=gr?r:t+r}function Wr(e,t,r){let o=e;while(t-- >gr)o*=o,o%=r;return o}function gj(e,t){if(e===gr)throw Error("invert: expected non-zero number");if(t<=gr)throw Error("invert: expected positive modulus, got "+t);let r=hr(e,t),o=t,n=gr,i=rr,s=rr,a=gr;while(r!==gr){let u=o/r,d=o%r,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==rr)throw Error("invert: does not exist");return hr(n,t)}function kk(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function _j(e,t){let r=(e.ORDER+rr)/Sj,o=e.pow(t,r);return kk(e,o,t),o}function tse(e,t){let r=(e.ORDER-vj)/wj,o=e.mul(t,Cs),n=e.pow(o,r),i=e.mul(t,n),s=e.mul(e.mul(i,Cs),n),a=e.mul(i,e.sub(s,e.ONE));return kk(e,a,t),a}function rse(e){let t=cg(e),r=Ej(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+Xie)/xj;return(a,c)=>{let u=a.pow(c,s),d=a.mul(u,o),f=a.mul(u,n),m=a.mul(u,i),h=a.eql(a.sqr(d),c),b=a.eql(a.sqr(f),c);u=a.cmov(u,d,h),d=a.cmov(m,f,b);let y=a.eql(a.sqr(d),c),S=a.cmov(u,d,y);return kk(a,S,c),S}}function Ej(e){if(e<bj)throw Error("sqrt is not defined for small field");let t=e-rr,r=0;while(t%Cs===gr)t/=Cs,r++;let o=Cs,n=cg(e);while(yj(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return _j;let i=n.pow(o,t),s=(t+rr)/Cs;return function(c,u){if(c.is0(u))return u;if(yj(c,u)!==1)throw Error("Cannot find square root");let d=r,f=c.mul(c.ONE,i),m=c.pow(u,t),h=c.pow(u,s);while(!c.eql(m,c.ONE)){if(c.is0(m))return c.ZERO;let b=1,y=c.sqr(m);while(!c.eql(y,c.ONE))if(b++,y=c.sqr(y),b===d)throw Error("Cannot find square root");let S=rr<<BigInt(d-b-1),x=c.pow(f,S);d=b,f=c.sqr(x),m=c.mul(m,f),h=c.mul(h,x)}return h}}function nse(e){if(e%Sj===bj)return _j;if(e%wj===vj)return tse;if(e%xj===ese)return rse(e);return Ej(e)}var ose=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ak(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=ose.reduce((o,n)=>(o[n]="function",o),t);return Os(e,r),e}function ise(e,t,r){if(r<gr)throw Error("invalid exponent, negatives unsupported");if(r===gr)return e.ONE;if(r===rr)return t;let o=e.ONE,n=t;while(r>gr){if(r&rr)o=e.mul(o,n);n=e.sqr(n),r>>=rr}return o}function md(e,t,r=!1){let o=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,c)=>{if(e.is0(a))return s;return o[c]=s,e.mul(s,a)},e.ONE),i=e.inv(n);return t.reduceRight((s,a,c)=>{if(e.is0(a))return s;return o[c]=e.mul(s,o[c]),e.mul(s,a)},i),o}function yj(e,t){let r=(e.ORDER-rr)/Cs,o=e.pow(t,r),n=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),s=e.eql(o,e.neg(e.ONE));if(!n&&!i&&!s)throw Error("invalid Legendre symbol result");return n?1:i?0:-1}function sse(e,t){if(t!==void 0)Bt(t);let r=t!==void 0?t:e.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class Ij{ORDER;BITS;BYTES;isLE;ZERO=gr;ONE=rr;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=gr)throw Error("invalid field: expected ORDER > 0, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")this.sqrt=t.sqrt;if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=t.allowedLengths?.slice();if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=sse(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return hr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return gr<=e&&e<this.ORDER}is0(e){return e===gr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&rr)===rr}neg(e){return hr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return hr(e*e,this.ORDER)}add(e,t){return hr(e+t,this.ORDER)}sub(e,t){return hr(e-t,this.ORDER)}mul(e,t){return hr(e*t,this.ORDER)}pow(e,t){return ise(this,e,t)}div(e,t){return hr(e*gj(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return gj(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=nse(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?dd(e,this.BYTES):Ac(e,this.BYTES)}fromBytes(e,t=!1){Te(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?Ei(e):_i(e);if(s)a=hr(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return md(this,e)}cmov(e,t,r){return r?t:e}}function cg(e,t={}){return new Ij(e,t)}function kj(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function Tk(e){let t=kj(e);return t+Math.ceil(t/2)}function Aj(e,t,r=!1){Te(e);let o=e.length,n=kj(t),i=Tk(t);if(o<16||o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?Ei(e):_i(e),a=hr(s,t-rr)+rr;return r?dd(a,n):Ac(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Tc=BigInt(0),Ps=BigInt(1);function hd(e,t){let r=t.negate();return e?r:t}function Ck(e,t){let r=md(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function Oj(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function $k(e,t){Oj(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=pd(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function Tj(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=Ps;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var Rk=new WeakMap,Cj=new WeakMap;function Ok(e){return Cj.get(e)||1}function $j(e){if(e!==Tc)throw Error("invalid wNAF")}class Pk{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Tc){if(t&Ps)r=r.add(o);o=o.double(),t>>=Ps}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=$k(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=$k(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:f,offsetF:m}=Tj(r,s,i);if(r=a,u)n=n.add(hd(f,t[m]));else o=o.add(hd(d,t[c]))}return $j(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=$k(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Tc)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=Tj(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return $j(r),o}getPrecomputes(e,t,r){let o=Rk.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);Rk.set(t,o)}}return o}cached(e,t,r){let o=Ok(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=Ok(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){Oj(t,this.bits),Cj.set(e,t),Rk.delete(e)}hasCache(e){return Ok(e)!==1}}function Pj(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Tc||o>Tc){if(r&Ps)i=i.add(n);if(o&Ps)s=s.add(n);n=n.double(),r>>=Ps,o>>=Ps}return{p1:i,p2:s}}function Rj(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return Ak(t),t}else return cg(e,{isLE:r})}function zj(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>Tc))throw Error(`CURVE.${c} must be positive bigint`)}let n=Rj(t.p,r.Fp,o),i=Rj(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function lg(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var gd=BigInt(0),$c=BigInt(1),ug=BigInt(2);function ase(e){return Os(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function Nj(e){let t=ase(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s||wi,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?ug**BigInt(254):ug**BigInt(447),b=a?BigInt(8)*ug**BigInt(251)-$c:BigInt(4)*ug**BigInt(445)-$c,y=h+b+$c,S=(I)=>hr(I,r),x=_(f);function _(I){return dd(S(I),d)}function A(I){let T=ag(Te(I,d,"uCoordinate"));if(a)T[31]&=127;return S(Ei(T))}function O(I){return Ei(n(ag(Te(I,d,"scalar"))))}function L(I,T){let k=ee(A(T),O(I));if(k===gd)throw Error("invalid private or public key received");return _(k)}function z(I){return L(I,x)}let K=z,P=L;function W(I,T,k){let M=S(I*(T-k));return T=S(T-M),k=S(k+M),{x_2:T,x_3:k}}function ee(I,T){fd("u",I,gd,r),fd("scalar",T,h,y);let k=T,M=I,N=$c,H=gd,G=I,re=$c,ae=gd;for(let be=BigInt(u-1);be>=gd;be--){let ve=k>>be&$c;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:H,x_3:re}=W(ae,H,re),ae=ve;let ke=N+H,Ie=S(ke*ke),we=N-H,Ue=S(we*we),De=Ie-Ue,Qe=G+re,St=G-re,Tt=S(St*ke),Nt=S(Qe*we),lt=Tt+Nt,$r=Tt-Nt;G=S(lt*lt),re=S(M*S($r*$r)),N=S(Ie*Ue),H=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:H,x_3:re}=W(ae,H,re);let pe=i(H);return S(N*pe)}let j={secretKey:d,publicKey:d,seed:d},R=(I=c(d))=>(Te(I,j.seed,"seed"),I),B={randomSecretKey:R};return Object.freeze({keygen:lg(R,K),getSharedSecret:P,getPublicKey:K,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}class zk{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(Vr(e),Te(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),Er(o)}update(e){return xo(this),this.iHash.update(e),this}digestInto(e){xo(this),Te(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Rc=(e,t,r)=>new zk(e,t).update(r).digest();Rc.create=(e,t)=>new zk(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Dj=(e,t)=>(e+(e>=0?t:-t)/Bj)/t;function cse(e,t,r){let[[o,n],[i,s]]=t,a=Dj(s*e,r),c=Dj(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,f=u<_o,m=d<_o;if(f)u=-u;if(m)d=-d;let h=pd(Math.ceil(Ek(r)/2))+Oc;if(u<_o||u>=h||d<_o||d>=h)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:m,k2:d}}function Dk(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function Nk(e,t){let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(ld(r.lowS,"lowS"),ld(r.prehash,"prehash"),r.format!==void 0)Dk(r.format);return r}class Lj extends Error{constructor(e=""){super(e)}}var ki={Err:Lj,_tlv:{encode:(e,t)=>{let{Err:r}=ki;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=ud(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?ud(n.length/2|128):"";return ud(e)+i+n+t},decode(e,t){let{Err:r}=ki,o=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=ki;if(e<_o)throw new t("integer: negative integers are not allowed");let r=ud(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=ki;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return _i(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=ki,n=Te(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=ki,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}},_o=BigInt(0),Oc=BigInt(1),Bj=BigInt(2),dg=BigInt(3),lse=BigInt(4);function Lk(e,t={}){let r=zj("weierstrass",e,t),{Fp:o,Fn:n}=r,i=r.CURVE,{h:s,n:a}=i;Os(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=Zj(o,n);function d(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function f(R,B,I){let{x:T,y:k}=B.toAffine(),M=o.toBytes(T);if(ld(I,"isCompressed"),I){d();let N=!o.isOdd(k);return It(jj(N),M)}else return It(Uint8Array.of(4),M,o.toBytes(k))}function m(R){Te(R,void 0,"Point");let{publicKey:B,publicKeyUncompressed:I}=u,T=R.length,k=R[0],M=R.subarray(1);if(T===B&&(k===2||k===3)){let N=o.fromBytes(M);if(!o.isValid(N))throw Error("bad point: is not on curve, wrong x");let H=y(N),G;try{G=o.sqrt(H)}catch(pe){let be=pe instanceof Error?": "+pe.message:"";throw Error("bad point: is not on curve, sqrt error"+be)}d();let re=o.isOdd(G);if((k&1)===1!==re)G=o.neg(G);return{x:N,y:G}}else if(T===I&&k===4){let N=o.BYTES,H=o.fromBytes(M.subarray(0,N)),G=o.fromBytes(M.subarray(N,N*2));if(!S(H,G))throw Error("bad point: is not on curve");return{x:H,y:G}}else throw Error(`bad point: got length ${T}, expected compressed=${B} or uncompressed=${I}`)}let h=t.toBytes||f,b=t.fromBytes||m;function y(R){let B=o.sqr(R),I=o.mul(B,R);return o.add(o.add(I,o.mul(R,i.a)),i.b)}function S(R,B){let I=o.sqr(B),T=y(R);return o.eql(I,T)}if(!S(i.Gx,i.Gy))throw Error("bad curve params: generator point");let x=o.mul(o.pow(i.a,dg),lse),_=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(x,_)))throw Error("bad curve params: a or b");function A(R,B,I=!1){if(!o.isValid(B)||I&&o.is0(B))throw Error(`bad point coordinate ${R}`);return B}function O(R){if(!(R instanceof W))throw Error("Weierstrass Point expected")}function L(R){if(!c||!c.basises)throw Error("no endo");return cse(R,c.basises,n.ORDER)}let z=Ik((R,B)=>{let{X:I,Y:T,Z:k}=R;if(o.eql(k,o.ONE))return{x:I,y:T};let M=R.is0();if(B==null)B=M?o.ONE:o.inv(k);let N=o.mul(I,B),H=o.mul(T,B),G=o.mul(k,B);if(M)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:H}}),K=Ik((R)=>{if(R.is0()){if(t.allowInfinityPoint&&!o.is0(R.Y))return;throw Error("bad point: ZERO")}let{x:B,y:I}=R.toAffine();if(!o.isValid(B)||!o.isValid(I))throw Error("bad point: x or y not field elements");if(!S(B,I))throw Error("bad point: equation left != right");if(!R.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function P(R,B,I,T,k){return I=new W(o.mul(I.X,R),I.Y,I.Z),B=hd(T,B),I=hd(k,I),B.add(I)}class W{static BASE=new W(i.Gx,i.Gy,o.ONE);static ZERO=new W(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(R,B,I){this.X=A("x",R),this.Y=A("y",B,!0),this.Z=A("z",I),Object.freeze(this)}static CURVE(){return i}static fromAffine(R){let{x:B,y:I}=R||{};if(!R||!o.isValid(B)||!o.isValid(I))throw Error("invalid affine point");if(R instanceof W)throw Error("projective point not allowed");if(o.is0(B)&&o.is0(I))return W.ZERO;return new W(B,I,o.ONE)}static fromBytes(R){let B=W.fromAffine(b(Te(R,void 0,"point")));return B.assertValidity(),B}static fromHex(R){return W.fromBytes(Rs(R))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(R=8,B=!0){if(j.createCache(this,R),!B)this.multiply(dg);return this}assertValidity(){K(this)}hasEvenY(){let{y:R}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(R)}equals(R){O(R);let{X:B,Y:I,Z:T}=this,{X:k,Y:M,Z:N}=R,H=o.eql(o.mul(B,N),o.mul(k,T)),G=o.eql(o.mul(I,N),o.mul(M,T));return H&&G}negate(){return new W(this.X,o.neg(this.Y),this.Z)}double(){let{a:R,b:B}=i,I=o.mul(B,dg),{X:T,Y:k,Z:M}=this,N=o.ZERO,H=o.ZERO,G=o.ZERO,re=o.mul(T,T),ae=o.mul(k,k),pe=o.mul(M,M),be=o.mul(T,k);return be=o.add(be,be),G=o.mul(T,M),G=o.add(G,G),N=o.mul(R,G),H=o.mul(I,pe),H=o.add(N,H),N=o.sub(ae,H),H=o.add(ae,H),H=o.mul(N,H),N=o.mul(be,N),G=o.mul(I,G),pe=o.mul(R,pe),be=o.sub(re,pe),be=o.mul(R,be),be=o.add(be,G),G=o.add(re,re),re=o.add(G,re),re=o.add(re,pe),re=o.mul(re,be),H=o.add(H,re),pe=o.mul(k,M),pe=o.add(pe,pe),re=o.mul(pe,be),N=o.sub(N,re),G=o.mul(pe,ae),G=o.add(G,G),G=o.add(G,G),new W(N,H,G)}add(R){O(R);let{X:B,Y:I,Z:T}=this,{X:k,Y:M,Z:N}=R,H=o.ZERO,G=o.ZERO,re=o.ZERO,ae=i.a,pe=o.mul(i.b,dg),be=o.mul(B,k),ve=o.mul(I,M),ke=o.mul(T,N),Ie=o.add(B,I),we=o.add(k,M);Ie=o.mul(Ie,we),we=o.add(be,ve),Ie=o.sub(Ie,we),we=o.add(B,T);let Ue=o.add(k,N);return we=o.mul(we,Ue),Ue=o.add(be,ke),we=o.sub(we,Ue),Ue=o.add(I,T),H=o.add(M,N),Ue=o.mul(Ue,H),H=o.add(ve,ke),Ue=o.sub(Ue,H),re=o.mul(ae,we),H=o.mul(pe,ke),re=o.add(H,re),H=o.sub(ve,re),re=o.add(ve,re),G=o.mul(H,re),ve=o.add(be,be),ve=o.add(ve,be),ke=o.mul(ae,ke),we=o.mul(pe,we),ve=o.add(ve,ke),ke=o.sub(be,ke),ke=o.mul(ae,ke),we=o.add(we,ke),be=o.mul(ve,we),G=o.add(G,be),be=o.mul(Ue,we),H=o.mul(Ie,H),H=o.sub(H,be),be=o.mul(Ie,ve),re=o.mul(Ue,re),re=o.add(re,be),new W(H,G,re)}subtract(R){return this.add(R.negate())}is0(){return this.equals(W.ZERO)}multiply(R){let{endo:B}=t;if(!n.isValidNot0(R))throw Error("invalid scalar: out of range");let I,T,k=(M)=>j.cached(this,M,(N)=>Ck(W,N));if(B){let{k1neg:M,k1:N,k2neg:H,k2:G}=L(R),{p:re,f:ae}=k(N),{p:pe,f:be}=k(G);T=ae.add(be),I=P(B.beta,re,pe,M,H)}else{let{p:M,f:N}=k(R);I=M,T=N}return Ck(W,[I,T])[0]}multiplyUnsafe(R){let{endo:B}=t,I=this;if(!n.isValid(R))throw Error("invalid scalar: out of range");if(R===_o||I.is0())return W.ZERO;if(R===Oc)return I;if(j.hasCache(this))return this.multiply(R);if(B){let{k1neg:T,k1:k,k2neg:M,k2:N}=L(R),{p1:H,p2:G}=Pj(W,I,k,N);return P(B.beta,H,G,T,M)}else return j.unsafe(I,R)}toAffine(R){return z(this,R)}isTorsionFree(){let{isTorsionFree:R}=t;if(s===Oc)return!0;if(R)return R(W,this);return j.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:R}=t;if(s===Oc)return this;if(R)return R(W,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(R=!0){return ld(R,"isCompressed"),this.assertValidity(),h(W,this,R)}toHex(R=!0){return $s(this.toBytes(R))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ee=n.BITS,j=new Pk(W,t.endo?Math.ceil(ee/2):ee);return W.BASE.precompute(8),W}function jj(e){return Uint8Array.of(e?2:3)}function Zj(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function use(e,t={}){let{Fn:r}=e,o=t.randomBytes||wi,n=Object.assign(Zj(e.Fp,r),{seed:Tk(r.ORDER)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h=o(n.seed)){return Aj(Te(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n;if(!Ic(h))return;if("_lengths"in r&&r._lengths||b===y)return;let x=Te(h,void 0,"key").length;return x===y||x===S}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=lg(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function Bk(e,t,r={}){Vr(t),Os(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes||wi,n=r.hmac||((I,T)=>Rc(t,I,T)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h}=use(e,r),b={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=a*Bj<i.ORDER;function S(I){let T=a>>Oc;return I>T}function x(I,T){if(!s.isValidNot0(T))throw Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return T}function _(){if(y)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function A(I,T){Dk(T);let k=h.signature,M=T==="compact"?k:T==="recovered"?k+1:void 0;return Te(I,M)}class O{r;s;recovery;constructor(I,T,k){if(this.r=x("r",I),this.s=x("s",T),k!=null){if(_(),![0,1,2,3].includes(k))throw Error("invalid recovery id");this.recovery=k}Object.freeze(this)}static fromBytes(I,T=b.format){A(I,T);let k;if(T==="der"){let{r:G,s:re}=ki.toSig(Te(I));return new O(G,re)}if(T==="recovered")k=I[0],T="compact",I=I.subarray(1);let M=h.signature/2,N=I.subarray(0,M),H=I.subarray(M,M*2);return new O(s.fromBytes(N),s.fromBytes(H),k)}static fromHex(I,T){return this.fromBytes(Rs(I),T)}assertRecovery(){let{recovery:I}=this;if(I==null)throw Error("invalid recovery id: must be present");return I}addRecoveryBit(I){return new O(this.r,this.s,I)}recoverPublicKey(I){let{r:T,s:k}=this,M=this.assertRecovery(),N=M===2||M===3?T+a:T;if(!i.isValid(N))throw Error("invalid recovery id: sig.r+curve.n != R.x");let H=i.toBytes(N),G=e.fromBytes(It(jj((M&1)===0),H)),re=s.inv(N),ae=z(Te(I,void 0,"msgHash")),pe=s.create(-ae*re),be=s.create(k*re),ve=e.BASE.multiplyUnsafe(pe).add(G.multiplyUnsafe(be));if(ve.is0())throw Error("invalid recovery: point at infinify");return ve.assertValidity(),ve}hasHighS(){return S(this.s)}toBytes(I=b.format){if(Dk(I),I==="der")return Rs(ki.hexFromSig(this));let{r:T,s:k}=this,M=s.toBytes(T),N=s.toBytes(k);if(I==="recovered")return _(),It(Uint8Array.of(this.assertRecovery()),M,N);return It(M,N)}toHex(I){return $s(this.toBytes(I))}}let L=r.bits2int||function(T){if(T.length>8192)throw Error("input is too large");let k=_i(T),M=T.length*8-c;return M>0?k>>BigInt(M):k},z=r.bits2int_modN||function(T){return s.create(L(T))},K=pd(c);function P(I){return fd("num < 2^"+c,I,_o,K),s.toBytes(I)}function W(I,T){return Te(I,void 0,"message"),T?Te(t(I),void 0,"prehashed message"):I}function ee(I,T,k){let{lowS:M,prehash:N,extraEntropy:H}=Nk(k,b);I=W(I,N);let G=z(I),re=s.fromBytes(T);if(!s.isValidNot0(re))throw Error("invalid private key");let ae=[P(re),P(G)];if(H!=null&&H!==!1){let ke=H===!0?o(h.secretKey):H;ae.push(Te(ke,void 0,"extraEntropy"))}let pe=It(...ae),be=G;function ve(ke){let Ie=L(ke);if(!s.isValidNot0(Ie))return;let we=s.inv(Ie),Ue=e.BASE.multiply(Ie).toAffine(),De=s.create(Ue.x);if(De===_o)return;let Qe=s.create(we*s.create(be+De*re));if(Qe===_o)return;let St=(Ue.x===De?0:2)|Number(Ue.y&Oc),Tt=Qe;if(M&&S(Qe))Tt=s.neg(Qe),St^=1;return new O(De,Tt,y?void 0:St)}return{seed:pe,k2sig:ve}}function j(I,T,k={}){let{seed:M,k2sig:N}=ee(I,T,k);return hj(t.outputLen,s.BYTES,n)(M,N).toBytes(k.format)}function R(I,T,k,M={}){let{lowS:N,prehash:H,format:G}=Nk(M,b);if(k=Te(k,void 0,"publicKey"),T=W(T,H),!Ic(I)){let re=I instanceof O?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+re)}A(I,G);try{let re=O.fromBytes(I,G),ae=e.fromBytes(k);if(N&&re.hasHighS())return!1;let{r:pe,s:be}=re,ve=z(T),ke=s.inv(be),Ie=s.create(ve*ke),we=s.create(pe*ke),Ue=e.BASE.multiplyUnsafe(Ie).add(ae.multiplyUnsafe(we));if(Ue.is0())return!1;return s.create(Ue.x)===pe}catch(re){return!1}}function B(I,T,k={}){let{prehash:M}=Nk(k,b);return T=W(T,M),O.fromBytes(I,"recovered").recoverPublicKey(T).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h,Point:e,sign:j,verify:R,recoverPublicKey:B,Signature:O,hash:t})}function Uj(e,t,r){return e&t^~e&r}function qj(e,t,r){return e&t^e&r^t&r}class fg{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ig(this.buffer)}update(e){xo(this),Te(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=ig(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){xo(this),ng(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,Er(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=ig(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var Eo=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Ht=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var pg=BigInt(4294967295),Mj=BigInt(32);function dse(e,t=!1){if(t)return{h:Number(e&pg),l:Number(e>>Mj&pg)};return{h:Number(e>>Mj&pg)|0,l:Number(e&pg)|0}}function mg(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=dse(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var jk=(e,t,r)=>e>>>r,Zk=(e,t,r)=>e<<32-r|t>>>r,zs=(e,t,r)=>e>>>r|t<<32-r,Ns=(e,t,r)=>e<<32-r|t>>>r,yd=(e,t,r)=>e<<64-r|t>>>r-32,bd=(e,t,r)=>e>>>r-32|t<<64-r;var Fj=(e,t,r)=>e<<r|t>>>32-r,Jj=(e,t,r)=>t<<r|e>>>32-r,Kj=(e,t,r)=>t<<r-32|e>>>64-r,Hj=(e,t,r)=>e<<r-32|t>>>64-r;function Un(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var Vj=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Wj=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,Gj=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),Qj=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,Yj=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),Xj=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var pse=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ai=new Uint32Array(64);class eZ extends fg{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)Ai[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=Ai[d-15],m=Ai[d-2],h=pn(f,7)^pn(f,18)^f>>>3,b=pn(m,17)^pn(m,19)^m>>>10;Ai[d]=b+Ai[d-7]+h+Ai[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let f=pn(s,6)^pn(s,11)^pn(s,25),m=u+f+Uj(s,a,c)+pse[d]+Ai[d]|0,b=(pn(r,2)^pn(r,13)^pn(r,22))+qj(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){Er(Ai)}destroy(){this.set(0,0,0,0,0,0,0,0),Er(this.buffer)}}class tZ extends eZ{A=Eo[0]|0;B=Eo[1]|0;C=Eo[2]|0;D=Eo[3]|0;E=Eo[4]|0;F=Eo[5]|0;G=Eo[6]|0;H=Eo[7]|0;constructor(){super(32)}}var rZ=(()=>mg(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e)=>BigInt(e))))(),mse=(()=>rZ[0])(),hse=(()=>rZ[1])(),Ti=new Uint32Array(80),$i=new Uint32Array(80);class nZ extends fg{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)Ti[_]=e.getUint32(t),$i[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=Ti[_-15]|0,O=$i[_-15]|0,L=zs(A,O,1)^zs(A,O,8)^jk(A,O,7),z=Ns(A,O,1)^Ns(A,O,8)^Zk(A,O,7),K=Ti[_-2]|0,P=$i[_-2]|0,W=zs(K,P,19)^yd(K,P,61)^jk(K,P,6),ee=Ns(K,P,19)^bd(K,P,61)^Zk(K,P,6),j=Gj(z,ee,$i[_-7],$i[_-16]),R=Qj(j,L,W,Ti[_-7],Ti[_-16]);Ti[_]=R|0,$i[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=zs(d,f,14)^zs(d,f,18)^yd(d,f,41),O=Ns(d,f,14)^Ns(d,f,18)^bd(d,f,41),L=d&m^~d&b,z=f&h^~f&y,K=Yj(x,O,z,hse[_],$i[_]),P=Xj(K,S,A,L,mse[_],Ti[_]),W=K|0,ee=zs(r,o,28)^yd(r,o,34)^yd(r,o,39),j=Ns(r,o,28)^bd(r,o,34)^bd(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=Un(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let I=Vj(W,j,B);r=Wj(I,P,ee,R),o=I|0}({h:r,l:o}=Un(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=Un(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=Un(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=Un(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:f}=Un(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=Un(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=Un(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=Un(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,f,m,h,b,y,S,x)}roundClean(){Er(Ti,$i)}destroy(){Er(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class oZ extends nZ{Ah=Ht[0]|0;Al=Ht[1]|0;Bh=Ht[2]|0;Bl=Ht[3]|0;Ch=Ht[4]|0;Cl=Ht[5]|0;Dh=Ht[6]|0;Dl=Ht[7]|0;Eh=Ht[8]|0;El=Ht[9]|0;Fh=Ht[10]|0;Fl=Ht[11]|0;Gh=Ht[12]|0;Gl=Ht[13]|0;Hh=Ht[14]|0;Hl=Ht[15]|0;constructor(){super(48)}}var hg=kc(()=>new tZ,xi(1));var iZ=kc(()=>new oZ,xi(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var gse=BigInt(1),sZ=BigInt(2),yse=BigInt(3),bse=BigInt(5),V$e=BigInt(8),aZ=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function Sse(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=aZ,a=e*e%i*e%i,c=Wr(a,sZ,i)*a%i,u=Wr(c,gse,i)*e%i,d=Wr(u,bse,i)*u%i,f=Wr(d,t,i)*d%i,m=Wr(f,r,i)*f%i,h=Wr(m,o,i)*m%i,b=Wr(h,n,i)*h%i,y=Wr(b,n,i)*h%i,S=Wr(y,t,i)*d%i;return{pow_p_5_8:Wr(S,sZ,i)*e%i,b2:a}}function vse(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var cZ=(()=>{let e=aZ;return Nj({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=Sse(t);return hr(Wr(r,yse,e)*o,e)},adjustScalarBytes:vse})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var wse=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),xse=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var _se=Lk(wse),Uk=Bk(_se,hg);var Ese=Lk(xse),lZ=Bk(Ese,iZ);function dZ(e,t,r){if(Vr(e),r===void 0)r=new Uint8Array(e.outputLen);return Rc(e,r,t)}var qk=Uint8Array.of(0),uZ=Uint8Array.of();function fZ(e,t,r,o=32){Vr(e),Bt(o,"length");let n=e.outputLen;if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=uZ;else Te(r,void 0,"info");let s=new Uint8Array(i*n),a=Rc.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)qk[0]=d+1,c.update(d===0?uZ:u).update(r).update(qk).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),Er(u,qk),s.slice(0,o)}var Ise=BigInt(0),Sd=BigInt(1),kse=BigInt(2),Ase=BigInt(7),Tse=BigInt(256),$se=BigInt(113),hZ=[],gZ=[],yZ=[];for(let e=0,t=Sd,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],hZ.push(2*(5*o+r)),gZ.push((e+1)*(e+2)/2%64);let n=Ise;for(let i=0;i<7;i++)if(t=(t<<Sd^(t>>Ase)*$se)%Tse,t&kse)n^=Sd<<(Sd<<BigInt(i))-Sd;yZ.push(n)}var bZ=mg(yZ,!0),Rse=bZ[0],Ose=bZ[1],pZ=(e,t,r)=>r>32?Kj(e,t,r):Fj(e,t,r),mZ=(e,t,r)=>r>32?Hj(e,t,r):Jj(e,t,r);function Cse(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let s=0;s<10;s++)r[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,u=r[c],d=r[c+1],f=pZ(u,d,1)^r[a],m=mZ(u,d,1)^r[a+1];for(let h=0;h<50;h+=10)e[s+h]^=f,e[s+h+1]^=m}let n=e[2],i=e[3];for(let s=0;s<24;s++){let a=gZ[s],c=pZ(n,i,a),u=mZ(n,i,a),d=hZ[s];n=e[d],i=e[d+1],e[d]=c,e[d+1]=u}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)r[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=Rse[o],e[1]^=Ose[o]}Er(r)}class gg{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,o=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=o,this.rounds=n,Bt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=og(this.state)}clone(){return this._cloneInto()}keccak(){wk(this.state32),Cse(this.state32,this.rounds),wk(this.state32),this.posOut=0,this.pos=0}update(e){xo(this),Te(e);let{blockLen:t,state:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(t-this.pos,o-n);for(let s=0;s<i;s++)r[this.pos++]^=e[n++];if(this.pos===t)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:o}=this;if(e[r]^=t,(t&128)!==0&&r===o-1)this.keccak();e[o-1]^=128,this.keccak()}writeInto(e){xo(this,!1),Te(e),this.finish();let t=this.state,{blockLen:r}=this;for(let o=0,n=e.length;o<n;){if(this.posOut>=r)this.keccak();let i=Math.min(r-this.posOut,n-o);e.set(t.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Bt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ng(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Er(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:o,rounds:n,enableXOF:i}=this;return e||=new gg(t,r,o,i,n),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}}var SZ=(e,t,r,o={})=>kc(()=>new gg(t,e,r),o);var Ds=SZ(6,136,32,xi(8));var vZ=SZ(6,72,64,xi(10));var wZ=(e,t,r,o={})=>kc((n={})=>new gg(t,e,n.dkLen===void 0?r:n.dkLen,!0),o),xZ=wZ(31,168,16,xi(11)),qn=wZ(31,136,32,xi(12));function Mk(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function EZ(e){return Mk(e),(e&e-1)===0&&e!==0}function Fk(e,t){Mk(e);let r=0;for(let o=0;o<t;o++,e>>>=1)r=r<<1|e&1;return r}function IZ(e){return Mk(e),31-Math.clz32(e)}function _Z(e){let t=e.length;if(t<2||!EZ(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=IZ(t);for(let o=0;o<t;o++){let n=Fk(o,r);if(o<n){let i=e[o];e[o]=e[n],e[n]=i}}return e}var Jk=(e,t)=>{let{N:r,roots:o,dit:n,invertButterflies:i=!1,skipStages:s=0,brp:a=!0}=t,c=IZ(r);if(!EZ(r))throw Error("FFT: Polynomial size should be power of two");let u=n!==i;return(d)=>{if(d.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)_Z(d);for(let f=0,m=1;f<c-s;f++){let h=n?f+1+s:c-f,b=1<<h,y=b>>1,S=r>>h;for(let x=0;x<r;x+=b)for(let _=0,A=m++;_<y;_++){let O=i?n?r-A:A:_*S,L=x+_,z=x+_+y,K=o[O],P=d[z],W=d[L];if(u){let ee=e.mul(P,K);d[L]=e.add(W,ee),d[z]=e.sub(W,ee)}else if(i)d[L]=e.add(P,W),d[z]=e.mul(e.sub(P,W),K);else d[L]=e.add(W,P),d[z]=e.mul(e.sub(W,P),K)}}if(!n&&a)_Z(d);return d}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var Mn=wi;function yg(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function kZ(e){return Uint8Array.from(e)}function Ls(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,o=t.reduce((n,i)=>n+r(i),0);return{bytesLen:o,encode:(n)=>{let i=new Uint8Array(o);for(let s=0,a=0;s<t.length;s++){let c=t[s],u=r(c),d=typeof c==="number"?n[s]:c.encode(n[s]);if(Te(d,u,e),i.set(d,a),typeof c!=="number")d.fill(0);a+=u}return i},decode:(n)=>{Te(n,o,e);let i=[];for(let s of t){let a=r(s),c=n.subarray(0,a);i.push(typeof s==="number"?c:s.decode(c)),n=n.subarray(a)}return i}}}function bg(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(o)=>{if(o.length!==t)throw Error(`vecCoder.encode: wrong length=${o.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let i=0,s=0;i<o.length;i++){let a=e.encode(o[i]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(o)=>{Te(o,r);let n=[];for(let i=0;i<o.length;i+=e.bytesLen)n.push(e.decode(o.subarray(i,i+e.bytesLen)));return n}}}function Ct(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function Kk(e){return(1<<e)-1}var lRe=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var AZ=(e)=>{let{newPoly:t,N:r,Q:o,F:n,ROOT_OF_UNITY:i,brvBits:s,isKyber:a}=e,c=(_,A=o)=>{let O=_%A|0;return(O>=0?O|0:A+O|0)|0},u=(_,A=o)=>{let O=c(_,A)|0;return(O>A>>1?O-A|0:O)|0};function d(){let _=t(r);for(let A=0;A<r;A++){let O=Fk(A,s),L=BigInt(i)**BigInt(O)%BigInt(o);_[A]=Number(L)|0}return _}let f=d(),m={add:(_,A)=>c((_|0)+(A|0))|0,sub:(_,A)=>c((_|0)-(A|0))|0,mul:(_,A)=>c((_|0)*(A|0))|0,inv:(_)=>{throw Error("not implemented")}},h={N:r,roots:f,invertButterflies:!0,skipStages:a?1:0,brp:!1},b=Jk(m,{dit:!1,...h}),y=Jk(m,{dit:!0,...h});return{mod:c,smod:u,nttZetas:f,NTT:{encode:(_)=>b(_),decode:(_)=>{y(_);for(let A=0;A<_.length;A++)_[A]=c(n*_[A]);return _}},bitsCoder:(_,A)=>{let O=Kk(_),L=_*(r/8);return{bytesLen:L,encode:(z)=>{let K=new Uint8Array(L);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=(A.encode(z[P])&O)<<ee,ee+=_;for(;ee>=8;ee-=8,W>>=8)K[j++]=W&Kk(ee)}return K},decode:(z)=>{let K=t(r);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=z[P]<<ee,ee+=8;for(;ee>=_;ee-=_,W>>=_)K[j++]=A.decode(W&O)}return K}}}}},Pse=(e)=>(t,r)=>{if(!r)r=e.blockLen;let o=new Uint8Array(t.length+2);o.set(t);let n=t.length,i=new Uint8Array(r),s=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(u,d)=>(o[n+0]=u,o[n+1]=d,s.destroy(),s=e.create({}).update(o),a++,()=>(c++,s.xofInto(i))),clean:()=>{s.destroy(),Ct(i,o)}}},TZ=Pse(xZ);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var nr=256,Io=3329,zse=3303,Nse=17,{mod:xd,nttZetas:Dse,NTT:Bs,bitsCoder:Lse}=AZ({N:nr,Q:Io,F:zse,ROOT_OF_UNITY:Nse,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),Hk={512:{N:nr,Q:Io,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:nr,Q:Io,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:nr,Q:Io,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},Bse=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Io/2)/Io,decode:(r)=>r*Io+t>>>e}},vd=(e)=>Lse(e,Bse(e));function js(e,t){for(let r=0;r<nr;r++)e[r]=xd(e[r]+t[r])}function jse(e,t){for(let r=0;r<nr;r++)e[r]=xd(e[r]-t[r])}function Zse(e,t,r,o,n){let i=xd(t*o*n+e*r),s=xd(e*o+t*r);return{c0:i,c1:s}}function Sg(e,t){for(let r=0;r<nr/2;r++){let o=Dse[64+(r>>1)];if(r&1)o=-o;let{c0:n,c1:i}=Zse(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],o);e[2*r+0]=n,e[2*r+1]=i}return e}function $Z(e){let t=new Uint16Array(nr);for(let r=0;r<nr;){let o=e();if(o.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<nr&&n+3<=o.length;n+=3){let i=(o[n+0]>>0|o[n+1]<<8)&4095,s=(o[n+1]>>4|o[n+2]<<4)&4095;if(i<Io)t[r++]=i;if(r<nr&&s<Io)t[r++]=s}}return t}function wd(e,t,r,o){let n=e(o*nr/4,t,r),i=new Uint16Array(nr),s=og(n),a=0;for(let c=0,u=0,d=0,f=0;c<s.length;c++){let m=s[c];for(let h=0;h<32;h++)if(d+=m&1,m>>=1,a+=1,a===o)f=d,d=0;else if(a===2*o)i[u++]=xd(f-d),d=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return i}var Use=(e)=>{let{K:t,PRF:r,XOF:o,HASH512:n,ETA1:i,ETA2:s,du:a,dv:c}=e,u=vd(1),d=vd(c),f=vd(a),m=Ls("publicKey",bg(vd(12),t),32),h=bg(vd(12),t),b=Ls("ciphertext",bg(f,t),d),y=Ls("seed",32,32);return{secretCoder:h,lengths:{secretKey:h.bytesLen,publicKey:m.bytesLen,cipherText:b.bytesLen},keygen:(S)=>{Te(S,32,"seed");let x=new Uint8Array(33);x.set(S),x[32]=t;let _=n(x),[A,O]=y.decode(_),L=[],z=[];for(let W=0;W<t;W++)L.push(Bs.encode(wd(r,O,W,i)));let K=o(A);for(let W=0;W<t;W++){let ee=Bs.encode(wd(r,O,t+W,i));for(let j=0;j<t;j++){let R=$Z(K.get(j,W));js(ee,Sg(R,L[j]))}z.push(ee)}K.clean();let P={publicKey:m.encode([z,A]),secretKey:h.encode(L)};return Ct(A,O,L,z,x,_),P},encrypt:(S,x,_)=>{let[A,O]=m.decode(S),L=[];for(let j=0;j<t;j++)L.push(Bs.encode(wd(r,_,j,i)));let z=o(O),K=new Uint16Array(nr),P=[];for(let j=0;j<t;j++){let R=wd(r,_,t+j,s),B=new Uint16Array(nr);for(let I=0;I<t;I++){let T=$Z(z.get(j,I));js(B,Sg(T,L[I]))}js(R,Bs.decode(B)),P.push(R),js(K,Sg(A[j],L[j])),Ct(B)}z.clean();let W=wd(r,_,2*t,s);js(W,Bs.decode(K));let ee=u.decode(x);return js(ee,W),Ct(A,L,K,W),b.encode([P,ee])},decrypt:(S,x)=>{let[_,A]=b.decode(S),O=h.decode(x),L=new Uint16Array(nr);for(let z=0;z<t;z++)js(L,Sg(O[z],Bs.encode(_[z])));return jse(A,Bs.decode(L)),Ct(L,O,_),u.encode(A)}}};function Vk(e){let t=Use(e),{HASH256:r,HASH512:o,KDF:n}=e,{secretCoder:i,lengths:s}=t,a=Ls("secretKey",s.secretKey,s.publicKey,32,32),c=32,u=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(d=Mn(64))=>{Te(d,64,"seed");let{publicKey:f,secretKey:m}=t.keygen(d.subarray(0,32)),h=r(f),b=a.encode([m,f,h,d.subarray(32)]);return Ct(m,h),{publicKey:f,secretKey:b}},getPublicKey:(d)=>{let[f,m,h,b]=a.decode(d);return Uint8Array.from(m)},encapsulate:(d,f=Mn(32))=>{Te(d,s.publicKey,"publicKey"),Te(f,32,"message");let m=d.subarray(0,384*e.K),h=i.encode(i.decode(kZ(m)));if(!yg(h,m))throw Ct(h),Error("ML-KEM.encapsulate: wrong publicKey modulus");Ct(h);let b=o.create().update(f).update(r(d)).digest(),y=t.encrypt(d,f,b.subarray(32,64));return Ct(b.subarray(32)),{cipherText:y,sharedSecret:b.subarray(0,32)}},decapsulate:(d,f)=>{Te(f,a.bytesLen,"secretKey"),Te(d,s.cipherText,"cipherText");let m=a.bytesLen-96,h=m+32,b=r(f.subarray(m/2,h));if(!yg(b,f.subarray(h,h+32)))throw Error("invalid secretKey: hash check failed");let[y,S,x,_]=a.decode(f),A=t.decrypt(d,y),O=o.create().update(A).update(x).digest(),L=O.subarray(0,32),z=t.encrypt(S,A,O.subarray(32,64)),K=yg(d,z),P=n.create({dkLen:32}).update(_).update(d).digest();return Ct(A,z,!K?L:P),K?L:P}}}function qse(e,t,r){return qn.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var Wk={HASH256:Ds,HASH512:vZ,KDF:qn,XOF:TZ,PRF:qse},vRe=Vk({...Wk,...Hk[512]}),_d=Vk({...Wk,...Hk[768]}),RZ=Vk({...Wk,...Hk[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function Mse(e,t=!1){let{lengths:r,keygen:o}=e;if(t){let i=e.Point.Fn;if(!i)throw Error("No Point.Fn");o=(s=Mn(r.seed))=>{Te(s,r.seed,"seed");let a=i.isLE?Ei(s):_i(s),c=i.toBytes(i.create(a));return{secretKey:c,publicKey:e.getPublicKey(c)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:o,getPublicKey:(n)=>e.getPublicKey(n)}}function Gk(e,t=!1){let r=Mse(e,t);if(!e.getSharedSecret)throw Error("wrong curve");return{lengths:{...r.lengths,msg:r.lengths.seed,cipherText:r.lengths.publicKey},keygen:r.keygen,getPublicKey:r.getPublicKey,encapsulate(o,n=Mn(e.lengths.seed)){let i=this.keygen(n).secretKey,s=this.decapsulate(o,i),a=e.getPublicKey(i);return Ct(i),{sharedSecret:s,cipherText:a}},decapsulate(o,n){let i=e.getSharedSecret(n,o);return e.lengths.publicKeyHasPrefix?i.subarray(1):i}}}function Ed(e,t){return Ls(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function Qk(e){return(t,r)=>e(t,{dkLen:r})}function Fse(e,t,...r){let o=Ed(r,"seed"),n=Ed(r,"publicKey");if(e===void 0)e=o.bytesLen;Bt(e);function i(s){Te(s,e);let a=o.decode(t(s,o.bytesLen)),c=r.map((f,m)=>f.keygen(a[m])),u=c.map((f)=>f.secretKey),d=c.map((f)=>f.publicKey);return{secretKey:u,publicKey:d}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=Mn(e)){let{publicKey:a,secretKey:c}=i(s),u=n.encode(a);return Ct(a),Ct(c),{secretKey:s,publicKey:u}},expandDecapsulationKey:i,realSeedLen:e}}function vg(e,t,r,o,...n){let i=Fse(e,r,...n),s=Ed(n,"cipherText"),a=Ed(n,"publicKey"),c=Ed(n,"msg");if(t===void 0)t=c.bytesLen;return Bt(t),{lengths:{...i.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:i.getPublicKey,keygen:i.keygen,encapsulate(u,d=Mn(c.bytesLen)){let f=a.decode(u),m=c.decode(d),h=n.map((x,_)=>x.encapsulate(f[_],m[_])),b=h.map((x)=>x.sharedSecret),y=h.map((x)=>x.cipherText),S={sharedSecret:o(f,y,b),cipherText:s.encode(y)};return Ct(b,y),S},decapsulate(u,d){let f=s.decode(u),{publicKey:m,secretKey:h}=i.expandDecapsulationKey(d),b=n.map((y,S)=>y.decapsulate(f[S],h[S]));return o(m,f,b)}}}function OZ(e,t,r,o,n){return Vr(o),Vr(n),vg(32,32,Qk(o),(i,s,a)=>n(It(a[0],a[1],s[1],i[1],Ii(e))),t,r)}var ORe=OZ("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",_d,Gk(Uk,!0),qn,Ds),CRe=OZ("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",RZ,Gk(lZ,!0),qn,Ds);function Jse(e,t,r,o,n){return Vr(o),Vr(n),vg(32,32,Qk(o),(i,s,a)=>{let c=It(a[0],a[1],s[0],i[0],s[1],i[1],Ii(e)),u=32,d=It(Ii("hybrid_prk"),c),f=dZ(n,d),m=It(Ac(32,2),Ii("shared_secret"),Ii("")),h=fZ(n,f,m,32);return Ct(f,m,d,c),h},t,r)}var CZ=Gk(cZ),PRe=Jse("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",_d,CZ,qn,hg),Kse=(()=>vg(32,32,Qk(qn),(e,t,r)=>Ds(It(r[0],r[1],t[1],e[1],Ii("\\.//^\\"))),_d,CZ))();function Hse(e,t,r,o){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function i(s){let a;for(let d=0,f=t;;d=f,f+=t){if(f>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(d,f),!0),n.isValidNot0(a))break}let c=n.toBytes(n.create(a)),u=e.getPublicKey(c,!1);return{secretKey:c,publicKey:u}}return{lengths:{secretKey:t,publicKey:r,seed:o,msg:o,cipherText:r},keygen(s=Mn(o)){return Te(s,o,"seed"),i(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=Mn(o)){Te(a,o,"rand");let{secretKey:c}=i(a),u=this.decapsulate(s,c),d=e.getPublicKey(c,!1);return Ct(c),{sharedSecret:u,cipherText:d}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function Vse(e,t,r,o){let{secretKey:n,publicKeyUncompressed:i}=r.lengths;if(!n||!i)throw Error("wrong curve");let s=Hse(r,n,i,o),a=64,c=a+o;return vg(32,32,(u)=>{Te(u,32);let d=qn(u,{dkLen:c}),f=d.subarray(0,a),m=d.subarray(a,c);return It(f,m)},(u,d,f)=>Ds(It(f[0],f[1],d[1],u[1],Ii(e))),t,s)}var Wse=(()=>Vse("MLKEM768-P256",_d,Uk,128))();var wg=Kse,PZ=Wse;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var et=(e,t,r)=>Ft(e,t,r),Xk=vt,Cc=Jh,Vt=(...e)=>rk(...e),Pc=(e)=>td(e),zc=XI,Nc=(e)=>bo(e),_g=BigInt(0),Yk=BigInt(1);function ko(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function Eg(e){if(typeof e==="bigint"){if(!xg(e))throw RangeError("positive bigint expected, got "+e)}else Xk(e);return e}function Fn(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw RangeError(r+"expected safe integer, got "+e)}}function Id(e){let t=Eg(e).toString(16);return t.length&1?"0"+t:t}function zZ(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?_g:BigInt("0x"+e)}function Zs(e){return zZ(Jh(e))}function mn(e){return zZ(Jh(Ri(Ft(e)).reverse()))}function Ig(e,t){if(vt(t),t===0)throw RangeError("zero length");e=Eg(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return td(r.padStart(t*2,"0"))}function kd(e,t){return Ig(e,t).reverse()}function NZ(e,t){if(e=et(e),t=et(t),e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function Ri(e){return Uint8Array.from(et(e))}function kg(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var xg=(e)=>typeof e==="bigint"&&_g<=e;function Gse(e,t,r){return xg(e)&&xg(t)&&xg(r)&&t<=e&&e<r}function Ao(e,t,r,o){if(!Gse(t,r,o))throw RangeError("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function Dc(e){if(e<_g)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>_g;e>>=Yk,t+=1);return t}var Ad=(e)=>(Yk<<BigInt(e))-Yk;function DZ(e,t,r){if(vt(e,"hashLen"),vt(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,f=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Vt(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return Vt(...x)};return(S,x)=>{f(),h(S);let _=void 0;while((_=x(b()))===void 0)h();return f(),_}}function Gr(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function o(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,i))throw TypeError(`param "${i}" is invalid: expected own property`);let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}var eA=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Wt=BigInt(0),gt=BigInt(1),Us=BigInt(2),ZZ=BigInt(3),UZ=BigInt(4),qZ=BigInt(5),Qse=BigInt(7),MZ=BigInt(8),Yse=BigInt(9),FZ=BigInt(16);function it(e,t){if(t<=Wt)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Wt?r:t+r}function Qr(e,t,r){if(t<Wt)throw Error("pow2: expected non-negative exponent, got "+t);let o=e;while(t-- >Wt)o*=o,o%=r;return o}function LZ(e,t){if(e===Wt)throw Error("invert: expected non-zero number");if(t<=Wt)throw Error("invert: expected positive modulus, got "+t);let r=it(e,t),o=t,n=Wt,i=gt,s=gt,a=Wt;while(r!==Wt){let u=o/r,d=o-r*u,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==gt)throw Error("invert: does not exist");return it(n,t)}function tA(e,t,r){let o=e;if(!o.eql(o.sqr(t),r))throw Error("Cannot find square root")}function JZ(e,t){let r=e,o=(r.ORDER+gt)/UZ,n=r.pow(t,o);return tA(r,n,t),n}function Xse(e,t){let r=e,o=(r.ORDER-qZ)/MZ,n=r.mul(t,Us),i=r.pow(n,o),s=r.mul(t,i),a=r.mul(r.mul(s,Us),i),c=r.mul(s,r.sub(a,r.ONE));return tA(r,c,t),c}function eae(e){let t=Ag(e),r=KZ(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+Qse)/FZ;return(a,c)=>{let u=a,d=u.pow(c,s),f=u.mul(d,o),m=u.mul(d,n),h=u.mul(d,i),b=u.eql(u.sqr(f),c),y=u.eql(u.sqr(m),c);d=u.cmov(d,f,b),f=u.cmov(h,m,y);let S=u.eql(u.sqr(f),c),x=u.cmov(d,f,S);return tA(u,x,c),x}}function KZ(e){if(e<ZZ)throw Error("sqrt is not defined for small field");let t=e-gt,r=0;while(t%Us===Wt)t/=Us,r++;let o=Us,n=Ag(e);while(BZ(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return JZ;let i=n.pow(o,t),s=(t+gt)/Us;return function(c,u){let d=c;if(d.is0(u))return u;if(BZ(d,u)!==1)throw Error("Cannot find square root");let f=r,m=d.mul(d.ONE,i),h=d.pow(u,t),b=d.pow(u,s);while(!d.eql(h,d.ONE)){if(d.is0(h))return d.ZERO;let y=1,S=d.sqr(h);while(!d.eql(S,d.ONE))if(y++,S=d.sqr(S),y===f)throw Error("Cannot find square root");let x=gt<<BigInt(f-y-1),_=d.pow(m,x);f=y,m=d.sqr(_),h=d.mul(h,m),b=d.mul(b,_)}return b}}function tae(e){if(e%UZ===ZZ)return JZ;if(e%MZ===qZ)return Xse;if(e%FZ===Yse)return eae(e);return KZ(e)}var To=(e,t)=>(it(e,t)&gt)===gt,rae=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function rA(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=rae.reduce((o,n)=>(o[n]="function",o),t);if(Gr(e,r),Fn(e.BYTES,"BYTES"),Fn(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=gt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function nae(e,t,r){let o=e;if(r<Wt)throw Error("invalid exponent, negatives unsupported");if(r===Wt)return o.ONE;if(r===gt)return t;let n=o.ONE,i=t;while(r>Wt){if(r&gt)n=o.mul(n,i);i=o.sqr(i),r>>=gt}return n}function Td(e,t,r=!1){let o=e,n=Array(t.length).fill(r?o.ZERO:void 0),i=t.reduce((a,c,u)=>{if(o.is0(c))return a;return n[u]=a,o.mul(a,c)},o.ONE),s=o.inv(i);return t.reduceRight((a,c,u)=>{if(o.is0(c))return a;return n[u]=o.mul(a,n[u]),o.mul(a,c)},s),n}function BZ(e,t){let r=e,o=(r.ORDER-gt)/Us,n=r.pow(t,o),i=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!i&&!s&&!a)throw Error("invalid Legendre symbol result");return i?1:s?0:-1}function oae(e,t){if(t!==void 0)Xk(t);if(e<=Wt)throw Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw Error("invalid n length: expected positive bit length, got "+t);let r=Dc(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let o=t!==void 0?t:r,n=Math.ceil(o/8);return{nBitLength:o,nByteLength:n}}var jZ=new WeakMap;class nA{ORDER;BITS;BYTES;isLE;ZERO=Wt;ONE=gt;_lengths;_mod;constructor(e,t={}){if(e<=gt)throw Error("invalid field: expected ORDER > 1, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0});if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=Object.freeze(t.allowedLengths.slice());if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=oae(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,Object.freeze(this)}create(e){return it(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return Wt<=e&&e<this.ORDER}is0(e){return e===Wt}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&gt)===gt}neg(e){return it(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return it(e*e,this.ORDER)}add(e,t){return it(e+t,this.ORDER)}sub(e,t){return it(e-t,this.ORDER)}mul(e,t){return it(e*t,this.ORDER)}pow(e,t){return nae(this,e,t)}div(e,t){return it(e*LZ(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return LZ(e,this.ORDER)}sqrt(e){let t=jZ.get(this);if(!t)jZ.set(this,t=tae(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?kd(e,this.BYTES):Ig(e,this.BYTES)}fromBytes(e,t=!1){et(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?mn(e):Zs(e);if(s)a=it(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Td(this,e)}cmov(e,t,r){return ko(r,"condition"),r?t:e}}Object.freeze(nA.prototype);function Ag(e,t={}){return new nA(e,t)}function HZ(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=gt)throw Error("field order must be greater than 1");let t=Dc(e-gt);return Math.ceil(t/8)}function oA(e){let t=HZ(e);return t+Math.ceil(t/2)}function VZ(e,t,r=!1){et(e);let o=e.length,n=HZ(t),i=Math.max(oA(t),16);if(o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?mn(e):Zs(e),a=it(s,t-gt)+gt;return r?kd(a,n):Ig(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Lc=BigInt(0),qs=BigInt(1);function $d(e,t){let r=t.negate();return e?r:t}function Ms(e,t){let r=Td(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function YZ(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function iA(e,t){YZ(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=Ad(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function WZ(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=qs;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var sA=new WeakMap,XZ=new WeakMap;function aA(e){return XZ.get(e)||1}function GZ(e){if(e!==Lc)throw Error("invalid wNAF")}class Rd{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Lc){if(t&qs)r=r.add(o);o=o.double(),t>>=qs}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=iA(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=iA(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:f,offsetF:m}=WZ(r,s,i);if(r=a,u)n=n.add($d(f,t[m]));else o=o.add($d(d,t[c]))}return GZ(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=iA(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Lc)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=WZ(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return GZ(r),o}getPrecomputes(e,t,r){let o=sA.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);sA.set(t,o)}}return o}cached(e,t,r){let o=aA(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=aA(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){YZ(t,this.bits),XZ.set(e,t),sA.delete(e)}hasCache(e){return aA(e)!==1}}function eU(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Lc||o>Lc){if(r&qs)i=i.add(n);if(o&qs)s=s.add(n);n=n.double(),r>>=qs,o>>=qs}return{p1:i,p2:s}}function QZ(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return rA(t),t}else return Ag(e,{isLE:r})}function Tg(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>Lc))throw Error(`CURVE.${c} must be positive bigint`)}let n=QZ(t.p,r.Fp,o),i=QZ(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function Od(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}function Cd(e,t){if(Fn(e),Fn(t),t<0||t>4)throw Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let o=t-1;o>=0;o--)r[o]=e&255,e>>>=8;return new Uint8Array(r)}function iae(e,t){let r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e[o]^t[o];return r}function sae(e){if(!zc(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?kg(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function cA(e,t,r,o){if(et(e),Fn(r),t=sae(t),t.length>255)t=o(Vt(kg("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:i}=o,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=Vt(t,Cd(t.length,1)),c=new Uint8Array(i),u=Cd(r,2),d=Array(s),f=o(Vt(c,e,u,Cd(0,1),a));d[0]=o(Vt(f,Cd(1,1),a));for(let h=1;h<s;h++){let b=[iae(f,d[h-1]),Cd(h+1,1),a];d[h]=o(Vt(...b))}return Vt(...d).slice(0,r)}var tU="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var rU=(e,t)=>(e+(e>=0?t:-t)/oU)/t;function aae(e,t,r){Ao("scalar",e,Jn,r);let[[o,n],[i,s]]=t,a=rU(s*e,r),c=rU(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,f=u<Jn,m=d<Jn;if(f)u=-u;if(m)d=-d;let h=Ad(Math.ceil(Dc(r)/2))+Oi;if(u<Jn||u>=h||d<Jn||d>=h)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:f,k1:u,k2neg:m,k2:d}}function uA(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function lA(e,t){Gr(e);let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(ko(r.lowS,"lowS"),ko(r.prehash,"prehash"),r.format!==void 0)uA(r.format);return r}class nU extends Error{constructor(e=""){super(e)}}var hn={Err:nU,_tlv:{encode:(e,t)=>{let{Err:r}=hn;if(Fn(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!=="string")throw TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=Id(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?Id(n.length/2|128):"";return Id(e)+i+n+t},decode(e,t){let{Err:r}=hn;t=et(t,void 0,"DER data");let o=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=hn;if(Eg(e),e<Jn)throw new t("integer: negative integers are not allowed");let r=Id(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=hn;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Zs(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=hn,n=et(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=hn,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}};Object.freeze(hn._tlv);Object.freeze(hn._int);Object.freeze(hn);var Jn=BigInt(0),Oi=BigInt(1),oU=BigInt(2),$g=BigInt(3),cae=BigInt(4);function iU(e,t={}){let r=Tg("weierstrass",e,t),o=r.Fp,n=r.Fn,i=r.CURVE,{h:s,n:a}=i;Gr(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:u}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let d=aU(o,n);function f(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function m(j,R,B){if(u&&R.is0())return Uint8Array.of(0);let{x:I,y:T}=R.toAffine(),k=o.toBytes(I);if(ko(B,"isCompressed"),B){f();let M=!o.isOdd(T);return Vt(sU(M),k)}else return Vt(Uint8Array.of(4),k,o.toBytes(T))}function h(j){et(j,void 0,"Point");let{publicKey:R,publicKeyUncompressed:B}=d,I=j.length,T=j[0],k=j.subarray(1);if(u&&I===1&&T===0)return{x:o.ZERO,y:o.ZERO};if(I===R&&(T===2||T===3)){let M=o.fromBytes(k);if(!o.isValid(M))throw Error("bad point: is not on curve, wrong x");let N=S(M),H;try{H=o.sqrt(N)}catch(ae){let pe=ae instanceof Error?": "+ae.message:"";throw Error("bad point: is not on curve, sqrt error"+pe)}f();let G=o.isOdd(H);if((T&1)===1!==G)H=o.neg(H);return{x:M,y:H}}else if(I===B&&T===4){let M=o.BYTES,N=o.fromBytes(k.subarray(0,M)),H=o.fromBytes(k.subarray(M,M*2));if(!x(N,H))throw Error("bad point: is not on curve");return{x:N,y:H}}else throw Error(`bad point: got length ${I}, expected compressed=${R} or uncompressed=${B}`)}let b=t.toBytes===void 0?m:t.toBytes,y=t.fromBytes===void 0?h:t.fromBytes;function S(j){let R=o.sqr(j),B=o.mul(R,j);return o.add(o.add(B,o.mul(j,i.a)),i.b)}function x(j,R){let B=o.sqr(R),I=S(j);return o.eql(B,I)}if(!x(i.Gx,i.Gy))throw Error("bad curve params: generator point");let _=o.mul(o.pow(i.a,$g),cae),A=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(_,A)))throw Error("bad curve params: a or b");function O(j,R,B=!1){if(!o.isValid(R)||B&&o.is0(R))throw Error(`bad point coordinate ${j}`);return R}function L(j){if(!(j instanceof P))throw Error("Weierstrass Point expected")}function z(j){if(!c||!c.basises)throw Error("no endo");return aae(j,c.basises,n.ORDER)}function K(j,R,B,I,T){return B=new P(o.mul(B.X,j),B.Y,B.Z),R=$d(I,R),B=$d(T,B),R.add(B)}class P{static BASE=new P(i.Gx,i.Gy,o.ONE);static ZERO=new P(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(j,R,B){this.X=O("x",j),this.Y=O("y",R,!0),this.Z=O("z",B),Object.freeze(this)}static CURVE(){return i}static fromAffine(j){let{x:R,y:B}=j||{};if(!j||!o.isValid(R)||!o.isValid(B))throw Error("invalid affine point");if(j instanceof P)throw Error("projective point not allowed");if(o.is0(R)&&o.is0(B))return P.ZERO;return new P(R,B,o.ONE)}static fromBytes(j){let R=P.fromAffine(y(et(j,void 0,"point")));return R.assertValidity(),R}static fromHex(j){return P.fromBytes(Pc(j))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(j=8,R=!0){if(ee.createCache(this,j),!R)this.multiply($g);return this}assertValidity(){let j=this;if(j.is0()){if(t.allowInfinityPoint&&o.is0(j.X)&&o.eql(j.Y,o.ONE)&&o.is0(j.Z))return;throw Error("bad point: ZERO")}let{x:R,y:B}=j.toAffine();if(!o.isValid(R)||!o.isValid(B))throw Error("bad point: x or y not field elements");if(!x(R,B))throw Error("bad point: equation left != right");if(!j.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:j}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(j)}equals(j){L(j);let{X:R,Y:B,Z:I}=this,{X:T,Y:k,Z:M}=j,N=o.eql(o.mul(R,M),o.mul(T,I)),H=o.eql(o.mul(B,M),o.mul(k,I));return N&&H}negate(){return new P(this.X,o.neg(this.Y),this.Z)}double(){let{a:j,b:R}=i,B=o.mul(R,$g),{X:I,Y:T,Z:k}=this,M=o.ZERO,N=o.ZERO,H=o.ZERO,G=o.mul(I,I),re=o.mul(T,T),ae=o.mul(k,k),pe=o.mul(I,T);return pe=o.add(pe,pe),H=o.mul(I,k),H=o.add(H,H),M=o.mul(j,H),N=o.mul(B,ae),N=o.add(M,N),M=o.sub(re,N),N=o.add(re,N),N=o.mul(M,N),M=o.mul(pe,M),H=o.mul(B,H),ae=o.mul(j,ae),pe=o.sub(G,ae),pe=o.mul(j,pe),pe=o.add(pe,H),H=o.add(G,G),G=o.add(H,G),G=o.add(G,ae),G=o.mul(G,pe),N=o.add(N,G),ae=o.mul(T,k),ae=o.add(ae,ae),G=o.mul(ae,pe),M=o.sub(M,G),H=o.mul(ae,re),H=o.add(H,H),H=o.add(H,H),new P(M,N,H)}add(j){L(j);let{X:R,Y:B,Z:I}=this,{X:T,Y:k,Z:M}=j,N=o.ZERO,H=o.ZERO,G=o.ZERO,re=i.a,ae=o.mul(i.b,$g),pe=o.mul(R,T),be=o.mul(B,k),ve=o.mul(I,M),ke=o.add(R,B),Ie=o.add(T,k);ke=o.mul(ke,Ie),Ie=o.add(pe,be),ke=o.sub(ke,Ie),Ie=o.add(R,I);let we=o.add(T,M);return Ie=o.mul(Ie,we),we=o.add(pe,ve),Ie=o.sub(Ie,we),we=o.add(B,I),N=o.add(k,M),we=o.mul(we,N),N=o.add(be,ve),we=o.sub(we,N),G=o.mul(re,Ie),N=o.mul(ae,ve),G=o.add(N,G),N=o.sub(be,G),G=o.add(be,G),H=o.mul(N,G),be=o.add(pe,pe),be=o.add(be,pe),ve=o.mul(re,ve),Ie=o.mul(ae,Ie),be=o.add(be,ve),ve=o.sub(pe,ve),ve=o.mul(re,ve),Ie=o.add(Ie,ve),pe=o.mul(be,Ie),H=o.add(H,pe),pe=o.mul(we,Ie),N=o.mul(ke,N),N=o.sub(N,pe),pe=o.mul(ke,be),G=o.mul(we,G),G=o.add(G,pe),new P(N,H,G)}subtract(j){return L(j),this.add(j.negate())}is0(){return this.equals(P.ZERO)}multiply(j){let{endo:R}=t;if(!n.isValidNot0(j))throw RangeError("invalid scalar: out of range");let B,I,T=(k)=>ee.cached(this,k,(M)=>Ms(P,M));if(R){let{k1neg:k,k1:M,k2neg:N,k2:H}=z(j),{p:G,f:re}=T(M),{p:ae,f:pe}=T(H);I=re.add(pe),B=K(R.beta,G,ae,k,N)}else{let{p:k,f:M}=T(j);B=k,I=M}return Ms(P,[B,I])[0]}multiplyUnsafe(j){let{endo:R}=t,B=this,I=j;if(!n.isValid(I))throw RangeError("invalid scalar: out of range");if(I===Jn||B.is0())return P.ZERO;if(I===Oi)return B;if(ee.hasCache(this))return this.multiply(I);if(R){let{k1neg:T,k1:k,k2neg:M,k2:N}=z(I),{p1:H,p2:G}=eU(P,B,k,N);return K(R.beta,H,G,T,M)}else return ee.unsafe(B,I)}toAffine(j){let R=this,B=j,{X:I,Y:T,Z:k}=R;if(o.eql(k,o.ONE))return{x:I,y:T};let M=R.is0();if(B==null)B=M?o.ONE:o.inv(k);let N=o.mul(I,B),H=o.mul(T,B),G=o.mul(k,B);if(M)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:H}}isTorsionFree(){let{isTorsionFree:j}=t;if(s===Oi)return!0;if(j)return j(P,this);return ee.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:j}=t;if(s===Oi)return this;if(j)return j(P,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===Oi)return this.is0();return this.clearCofactor().is0()}toBytes(j=!0){return ko(j,"isCompressed"),this.assertValidity(),b(P,this,j)}toHex(j=!0){return Cc(this.toBytes(j))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let W=n.BITS,ee=new Rd(P,t.endo?Math.ceil(W/2):W);if(W>=8)P.BASE.precompute(8);return Object.freeze(P.prototype),Object.freeze(P),P}function sU(e){return Uint8Array.of(e?2:3)}function aU(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function lae(e,t={}){let{Fn:r}=e,o=t.randomBytes===void 0?Nc:t.randomBytes,n=Object.assign(aU(e.Fp,r),{seed:Math.max(oA(r.ORDER),16)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h){return h=h===void 0?o(n.seed):h,VZ(et(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n,x=r._lengths;if(!zc(h))return;let _=et(h,void 0,"key").length,A=_===y||_===S,O=_===b||!!x?.includes(_);if(A&&O)return;return A}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=Od(a,c);return Object.freeze(f),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function cU(e,t,r={}){let o=t;yo(o),Gr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?Nc:r.randomBytes,i=r.hmac===void 0?(T,k)=>Bn(o,T,k):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:u}=a,{keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b}=lae(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=c*oU+Oi<s.ORDER;function x(T){let k=c>>Oi;return T>k}function _(T,k){if(!a.isValidNot0(k))throw Error(`invalid signature ${T}: out of range 1..Point.Fn.ORDER`);return k}function A(){if(S)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(T,k){uA(k);let M=b.signature,N=k==="compact"?M:k==="recovered"?M+1:void 0;return et(T,N)}class L{r;s;recovery;constructor(T,k,M){if(this.r=_("r",T),this.s=_("s",k),M!=null){if(A(),![0,1,2,3].includes(M))throw Error("invalid recovery id");this.recovery=M}Object.freeze(this)}static fromBytes(T,k=y.format){O(T,k);let M;if(k==="der"){let{r:re,s:ae}=hn.toSig(et(T));return new L(re,ae)}if(k==="recovered")M=T[0],k="compact",T=T.subarray(1);let N=b.signature/2,H=T.subarray(0,N),G=T.subarray(N,N*2);return new L(a.fromBytes(H),a.fromBytes(G),M)}static fromHex(T,k){return this.fromBytes(Pc(T),k)}assertRecovery(){let{recovery:T}=this;if(T==null)throw Error("invalid recovery id: must be present");return T}addRecoveryBit(T){return new L(this.r,this.s,T)}recoverPublicKey(T){let{r:k,s:M}=this,N=this.assertRecovery(),H=N===2||N===3?k+c:k;if(!s.isValid(H))throw Error("invalid recovery id: sig.r+curve.n != R.x");let G=s.toBytes(H),re=e.fromBytes(Vt(sU((N&1)===0),G)),ae=a.inv(H),pe=K(et(T,void 0,"msgHash")),be=a.create(-pe*ae),ve=a.create(M*ae),ke=e.BASE.multiplyUnsafe(be).add(re.multiplyUnsafe(ve));if(ke.is0())throw Error("invalid recovery: point at infinify");return ke.assertValidity(),ke}hasHighS(){return x(this.s)}toBytes(T=y.format){if(uA(T),T==="der")return Pc(hn.hexFromSig(this));let{r:k,s:M}=this,N=a.toBytes(k),H=a.toBytes(M);if(T==="recovered")return A(),Vt(Uint8Array.of(this.assertRecovery()),N,H);return Vt(N,H)}toHex(T){return Cc(this.toBytes(T))}}Object.freeze(L.prototype),Object.freeze(L);let z=r.bits2int===void 0?function(k){if(k.length>8192)throw Error("input is too large");let M=Zs(k),N=k.length*8-u;return N>0?M>>BigInt(N):M}:r.bits2int,K=r.bits2int_modN===void 0?function(k){return a.create(z(k))}:r.bits2int_modN,P=Ad(u);function W(T){return Ao("num < 2^"+u,T,Jn,P),a.toBytes(T)}function ee(T,k){return et(T,void 0,"message"),k?et(o(T),void 0,"prehashed message"):T}function j(T,k,M){let{lowS:N,prehash:H,extraEntropy:G}=lA(M,y);T=ee(T,H);let re=K(T),ae=a.fromBytes(k);if(!a.isValidNot0(ae))throw Error("invalid private key");let pe=[W(ae),W(re)];if(G!=null&&G!==!1){let Ie=G===!0?n(b.secretKey):G;pe.push(et(Ie,void 0,"extraEntropy"))}let be=Vt(...pe),ve=re;function ke(Ie){let we=z(Ie);if(!a.isValidNot0(we))return;let Ue=a.inv(we),De=e.BASE.multiply(we).toAffine(),Qe=a.create(De.x);if(Qe===Jn)return;let St=a.create(Ue*a.create(ve+Qe*ae));if(St===Jn)return;let Tt=(De.x===Qe?0:2)|Number(De.y&Oi),Nt=St;if(N&&x(St))Nt=a.neg(St),Tt^=1;return new L(Qe,Nt,S?void 0:Tt)}return{seed:be,k2sig:ke}}function R(T,k,M={}){let{seed:N,k2sig:H}=j(T,k,M);return DZ(o.outputLen,a.BYTES,i)(N,H).toBytes(M.format)}function B(T,k,M,N={}){let{lowS:H,prehash:G,format:re}=lA(N,y);if(M=et(M,void 0,"publicKey"),k=ee(k,G),!zc(T)){let ae=T instanceof L?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ae)}O(T,re);try{let ae=L.fromBytes(T,re),pe=e.fromBytes(M);if(H&&ae.hasHighS())return!1;let{r:be,s:ve}=ae,ke=K(k),Ie=a.inv(ve),we=a.create(ke*Ie),Ue=a.create(be*Ie),De=e.BASE.multiplyUnsafe(we).add(pe.multiplyUnsafe(Ue));if(De.is0())return!1;return a.create(De.x)===be}catch(ae){return!1}}function I(T,k,M={}){let{prehash:N}=lA(M,y);return k=ee(k,N),L.fromBytes(T,"recovered").recoverPublicKey(k).toBytes()}return Object.freeze({keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b,Point:e,sign:R,verify:B,recoverPublicKey:I,Signature:L,hash:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var uae=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var dae=iU(uae),Bc=cU(dae,wt);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ci=BigInt(0),Ir=BigInt(1),dA=BigInt(2),fae=BigInt(8);function pae(e,t,r,o){let n=e.sqr(r),i=e.sqr(o),s=e.add(e.mul(t.a,n),i),a=e.add(e.ONE,e.mul(t.d,e.mul(n,i)));return e.eql(s,a)}function lU(e,t={}){let r=t,o=Tg("edwards",e,r,r.FpFnLE),{Fp:n,Fn:i}=o,s=o.CURVE,{h:a}=s;Gr(r,{},{uvRatio:"function"});let c=dA<<BigInt(i.BYTES*8)-Ir,u=(y)=>n.create(y),d=r.uvRatio===void 0?(y,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(y,S))}}catch(x){return{isValid:!1,value:Ci}}}:r.uvRatio;if(!pae(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function f(y,S,x=!1){let _=x?Ir:Ci;return Ao("coordinate "+y,S,_,c),S}function m(y){if(!(y instanceof h))throw Error("EdwardsPoint expected")}class h{static BASE=new h(s.Gx,s.Gy,Ir,u(s.Gx*s.Gy));static ZERO=new h(Ci,Ir,Ir,Ci);static Fp=n;static Fn=i;X;Y;Z;T;constructor(y,S,x,_){this.X=f("x",y),this.Y=f("y",S),this.Z=f("z",x,!0),this.T=f("t",_),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof h)throw Error("extended point not allowed");let{x:S,y:x}=y||{};return f("x",S),f("y",x),new h(S,x,Ir,u(S*x))}static fromBytes(y,S=!1){let x=n.BYTES,{a:_,d:A}=s;y=Ri(et(y,x,"point")),ko(S,"zip215");let O=Ri(y),L=y[x-1];O[x-1]=L&-129;let z=mn(O),K=S?c:n.ORDER;Ao("point.y",z,Ci,K);let P=u(z*z),W=u(P-Ir),ee=u(A*P-_),{isValid:j,value:R}=d(W,ee);if(!j)throw Error("bad point: invalid y coordinate");let B=(R&Ir)===Ir,I=(L&128)!==0;if(!S&&R===Ci&&I)throw Error("bad point: x=0 and x_0=1");if(I!==B)R=u(-R);return h.fromAffine({x:R,y:z})}static fromHex(y,S=!1){return h.fromBytes(Pc(y),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,S=!0){if(b.createCache(this,y),!S)this.multiply(dA);return this}assertValidity(){let y=this,{a:S,d:x}=s;if(y.is0())throw Error("bad point: ZERO");let{X:_,Y:A,Z:O,T:L}=y,z=u(_*_),K=u(A*A),P=u(O*O),W=u(P*P),ee=u(z*S),j=u(P*u(ee+K)),R=u(W+u(x*u(z*K)));if(j!==R)throw Error("bad point: equation left != right (1)");let B=u(_*A),I=u(O*L);if(B!==I)throw Error("bad point: equation left != right (2)")}equals(y){m(y);let{X:S,Y:x,Z:_}=this,{X:A,Y:O,Z:L}=y,z=u(S*L),K=u(A*_),P=u(x*L),W=u(O*_);return z===K&&P===W}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.X),this.Y,this.Z,u(-this.T))}double(){let{a:y}=s,{X:S,Y:x,Z:_}=this,A=u(S*S),O=u(x*x),L=u(dA*u(_*_)),z=u(y*A),K=S+x,P=u(u(K*K)-A-O),W=z+O,ee=W-L,j=z-O,R=u(P*ee),B=u(W*j),I=u(P*j),T=u(ee*W);return new h(R,B,T,I)}add(y){m(y);let{a:S,d:x}=s,{X:_,Y:A,Z:O,T:L}=this,{X:z,Y:K,Z:P,T:W}=y,ee=u(_*z),j=u(A*K),R=u(L*x*W),B=u(O*P),I=u((_+A)*(z+K)-ee-j),T=B-R,k=B+R,M=u(j-S*ee),N=u(I*T),H=u(k*M),G=u(I*M),re=u(T*k);return new h(N,H,re,G)}subtract(y){return m(y),this.add(y.negate())}multiply(y){if(!i.isValidNot0(y))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:x}=b.cached(this,y,(_)=>Ms(h,_));return Ms(h,[S,x])[0]}multiplyUnsafe(y){if(!i.isValid(y))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(y===Ci)return h.ZERO;if(this.is0()||y===Ir)return this;return b.unsafe(this,y,(S)=>Ms(h,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(y){let S=this,x=y,{X:_,Y:A,Z:O}=S,L=S.is0();if(x==null)x=L?fae:n.inv(O);let z=u(_*x),K=u(A*x),P=n.mul(O,x);if(L)return{x:Ci,y:Ir};if(P!==Ir)throw Error("invZ was invalid");return{x:z,y:K}}clearCofactor(){if(a===Ir)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:y,y:S}=this.toAffine(),x=n.toBytes(S);return x[x.length-1]|=y&Ir?128:0,x}toHex(){return Cc(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new Rd(h,i.BITS);if(i.BITS>=8)h.BASE.precompute(8);return Object.freeze(h.prototype),Object.freeze(h),h}class fA{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){eA()}static fromHex(e){eA()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Cc(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.ep.precompute(e,t),this}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Pd=BigInt(0),jc=BigInt(1),Rg=BigInt(2);function mae(e){return Gr(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function uU(e){let t=mae(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s===void 0?Nc:s,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?Rg**BigInt(254):Rg**BigInt(447),b=a?BigInt(8)*Rg**BigInt(251)-jc:BigInt(4)*Rg**BigInt(445)-jc,y=h+b+jc,S=(I)=>it(I,r),x=_(f);function _(I){return kd(S(I),d)}function A(I){let T=Ri(et(I,d,"uCoordinate"));if(a)T[31]&=127;return S(mn(T))}function O(I){return mn(n(Ri(et(I,d,"scalar"))))}function L(I,T){let k=ee(A(T),O(I));if(k===Pd)throw Error("invalid private or public key received");return _(k)}function z(I){return L(I,x)}let K=z,P=L;function W(I,T,k){let M=S(I*(T-k));return T=S(T-M),k=S(k+M),{x_2:T,x_3:k}}function ee(I,T){Ao("u",I,Pd,r),Ao("scalar",T,h,y);let k=T,M=I,N=jc,H=Pd,G=I,re=jc,ae=Pd;for(let be=BigInt(u-1);be>=Pd;be--){let ve=k>>be&jc;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:H,x_3:re}=W(ae,H,re),ae=ve;let ke=N+H,Ie=S(ke*ke),we=N-H,Ue=S(we*we),De=Ie-Ue,Qe=G+re,St=G-re,Tt=S(St*ke),Nt=S(Qe*we),lt=Tt+Nt,$r=Tt-Nt;G=S(lt*lt),re=S(M*S($r*$r)),N=S(Ie*Ue),H=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:H,x_3:re}=W(ae,H,re);let pe=i(H);return S(N*pe)}let j={secretKey:d,publicKey:d,seed:d},R=(I)=>(I=I===void 0?c(d):I,et(I,j.seed,"seed"),I),B={randomSecretKey:R};return Object.freeze(j),Object.freeze(B),Object.freeze({keygen:Od(R,K),getSharedSecret:P,getPublicKey:K,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var hae=BigInt(0),$o=BigInt(1),dU=BigInt(2),gae=BigInt(3),yae=BigInt(5),bae=BigInt(8),Js=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),gA=(()=>({p:Js,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:bae,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function mU(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=Js,a=e*e%i*e%i,c=Qr(a,dU,i)*a%i,u=Qr(c,$o,i)*e%i,d=Qr(u,yae,i)*u%i,f=Qr(d,t,i)*d%i,m=Qr(f,r,i)*f%i,h=Qr(m,o,i)*m%i,b=Qr(h,n,i)*h%i,y=Qr(b,n,i)*h%i,S=Qr(y,t,i)*d%i;return{pow_p_5_8:Qr(S,dU,i)*e%i,b2:a}}function Sae(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var pA=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function yA(e,t){let r=Js,o=it(t*t*t,r),n=it(o*o*t,r),i=mU(e*n).pow_p_5_8,s=it(e*o*i,r),a=it(t*s*s,r),c=s,u=it(s*pA,r),d=a===e,f=a===it(-e,r),m=a===it(-e*pA,r);if(d)s=c;if(f||m)s=u;if(To(s,r))s=it(-s,r);return{isValid:d||f,value:s}}var Fs=lU(gA,{uvRatio:yA}),Pi=(()=>Fs.Fp)(),hU=(()=>Fs.Fn)();var Og=(()=>{let e=Js;return uU({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=mU(t);return it(Qr(r,gae,e)*o,e)},adjustScalarBytes:Sae})})();var mA=pA,vae=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),wae=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),xae=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),_ae=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),fU=(e)=>yA($o,e),Eae=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),hA=(e)=>Pi.create(mn(e)&Eae);function pU(e){let{d:t}=gA,r=Js,o=(x)=>Pi.create(x),n=o(mA*e*e),i=o((n+$o)*xae),s=BigInt(-1),a=o((s-t*n)*o(n+t)),{isValid:c,value:u}=yA(i,a),d=o(u*e);if(!To(d,r))d=o(-d);if(!c)u=d;if(!c)s=n;let f=o(s*(n-$o)*_ae-a),m=u*u,h=o((u+u)*a),b=o(f*vae),y=o($o-m),S=o($o+m);return new Fs(o(h*S),o(y*b),o(b*S),o(h*y))}class yr extends fA{static BASE=(()=>new yr(Fs.BASE))();static ZERO=(()=>new yr(Fs.ZERO))();static Fp=(()=>Pi)();static Fn=(()=>hU)();constructor(e){super(e)}static fromAffine(e){return new yr(Fs.fromAffine(e))}assertSame(e){if(!(e instanceof yr))throw Error("RistrettoPoint expected")}init(e){return new yr(e)}static fromBytes(e){Ft(e,32);let{a:t,d:r}=gA,o=Js,n=(A)=>Pi.create(A),i=hA(e);if(!NZ(Pi.toBytes(i),e)||To(i,o))throw Error("invalid ristretto255 encoding 1");let s=n(i*i),a=n($o+t*s),c=n($o-t*s),u=n(a*a),d=n(c*c),f=n(t*r*u-d),{isValid:m,value:h}=fU(n(f*d)),b=n(h*c),y=n(h*b*f),S=n((i+i)*b);if(To(S,o))S=n(-S);let x=n(a*y),_=n(S*x);if(!m||To(_,o)||x===hae)throw Error("invalid ristretto255 encoding 2");return new yr(new Fs(S,x,$o,_))}static fromHex(e){return yr.fromBytes(td(e))}toBytes(){let{X:e,Y:t,Z:r,T:o}=this.ep,n=Js,i=(y)=>Pi.create(y),s=i(i(r+t)*i(r-t)),a=i(e*t),c=i(a*a),{value:u}=fU(i(s*c)),d=i(u*s),f=i(u*a),m=i(d*f*o),h;if(To(o*m,n)){let y=i(t*mA),S=i(e*mA);e=y,t=S,h=i(d*wae)}else h=f;if(To(e*m,n))t=i(-t);let b=i((r-t)*h);if(To(b,n))b=i(-b);return Pi.toBytes(b)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:o,Y:n}=e.ep,i=(c)=>Pi.create(c),s=i(t*n)===i(r*o),a=i(r*n)===i(t*o);return s||a}is0(){return this.equals(yr.ZERO)}}Object.freeze(yr.BASE);Object.freeze(yr.ZERO);Object.freeze(yr.prototype);Object.freeze(yr);var Iae=Object.freeze({Point:yr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,o=cA(e,r,64,Wh);return Iae.deriveToCurve(o)},hashToScalar(e,t={DST:tU}){let r=cA(e,t.DST,64,Wh);return hU.create(mn(r))},deriveToCurve(e){Ft(e,64);let t=hA(e.subarray(0,32)),r=pU(t),o=hA(e.subarray(32,64)),n=pU(o);return new yr(r.add(n))}});var gU=!1,kae=!1;async function yU(e,t){if(kae)return await t();try{return await e()}catch(r){if(r instanceof ReferenceError||r instanceof DOMException&&r.name==="NotSupportedError")return await t();else throw r}}async function Cg(e,t){return await yU(async()=>{let r=bA(e)?e:await Tae(e),o=await crypto.subtle.importKey("raw",$ae(t),{name:"X25519"},gU,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:o},r,256))},()=>{if(bA(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Og.scalarMult(e,t)})}async function zd(e){return await yU(async()=>Cg(e,Og.GuBytes),()=>{if(bA(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Og.scalarMultBase(e)})}var Aae=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function Tae(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...Aae,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},gU,["deriveBits"])}function bA(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function $ae(e){return e}class SA{s;transcript=[];buf=new Uint8Array(0);constructor(e){this.s=e.getReader()}async readLine(){let e=[];while(!0){let t=this.buf.indexOf(10);if(t>=0)return e.push(this.buf.subarray(0,t)),this.transcript.push(this.buf.subarray(0,t+1)),this.buf=this.buf.subarray(t+1),Oae(Ks(e));if(this.buf.length>0)e.push(this.buf),this.transcript.push(this.buf);let r=await this.s.read();if(r.done)return this.buf=Ks(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:Ks(this.transcript)}}}function Oae(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function Ks(e){let t=e.reduce((n,i)=>n+i.length,0),r=new Uint8Array(t),o=0;for(let n of e)r.set(n,o),o+=n.length;return r}function Zc(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let o of t)r.enqueue(o)}}))}function Pg(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function vA(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function bU(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function SU(e,t){let r=e.getReader(),o=[],n=0;while(n<t){let{done:c,value:u}=await r.read();if(c)throw Error("stream ended before reading "+t.toString()+" bytes");o.push(u),n+=u.length}r.releaseLock();let i=Ks(o),s=i.subarray(0,t),a=Zc(e,i.subarray(t));return{data:s,rest:a}}class Kn{args;body;constructor(e,t){this.args=e,this.body=t}}async function Cae(e){let t=await e.readLine();if(t===null)throw Error("invalid stanza");let r=t.split(" ");if(r.length<2||r.shift()!=="->")return{next:t};for(let i of r)if(i.length===0)throw Error("invalid stanza");let o=[];for(;;){let i=await e.readLine();if(i===null)throw Error("invalid stanza");let s=tr.decode(i);if(s.length>48)throw Error("invalid stanza");if(o.push(s),s.length<48)break}let n=Ks(o);return{s:new Kn(r,n)}}async function vU(e){let t=new SA(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let o=[];for(;;){let{s:n,next:i}=await Cae(t);if(n!==void 0){o.push(n);continue}if(!i.startsWith("--- "))throw Error("invalid header");let s=tr.decode(i.slice(4)),{rest:a,transcript:c}=t.close(),u=c.slice(0,c.length-1-i.length+3);return{stanzas:o,headerNoMAC:u,MAC:s,headerSize:c.length,rest:Zc(e,a)}}}function wA(e){let t=[];t.push(`age-encryption.org/v1
723
+ `;if(e==="deploy/Dockerfile")return kR();if(e==="deploy/kamal/deploy.yml")return qf({serviceName:"rover"});if(e===".kamal/hooks/pre-deploy")return rb({deployConfigPath:"deploy/kamal/deploy.yml",brainYamlPath:"${BRAIN_YAML_PATH:-brain.yaml}"});let t=tc(a7,e),r=await RN(t,"utf8");return v7(r)}function v7(e){return e.replaceAll("__BRAINS_OPS_VERSION__",Zf.version).replaceAll("__BUN_VERSION__",Bun.version)}function w7(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}Mr();Um();RE();ec();no();import{mkdir as UW,writeFile as qW}from"fs/promises";import{dirname as MW,join as H2}from"path";import{isDeepStrictEqual as FW}from"util";ns();zn();import{mkdtemp as _W,mkdir as EW,readFile as IW,rm as kW,writeFile as AW}from"fs/promises";import{tmpdir as TW}from"os";import{dirname as $W,join as q2}from"path";var RW=["name: Your Name Here","Delete this and write your own"];async function M2(e,t,r,o,n={}){if(o.length===0)return;let i=n.env??process.env,s=on(e),a=Z2(i,s,r.effectiveGitSyncToken),c=n.contentRepoAdminTokenSelector?Z2(i,s,n.contentRepoAdminTokenSelector):void 0,u=OE(r.contentRepo,t),d=n.contentRepoRemoteResolver?.(r,t,a)??PW(u,a);if(!d)return;let f=await _W(q2(TW(),`brains-ops-content-sync-${r.handle}-`)),m=n.runCommand??Lt,h=n.fetchImpl??fetch;try{if(!n.contentRepoRemoteResolver){if(!c)throw Error(`${n.contentRepoAdminTokenSelector??"CONTENT_REPO_ADMIN_TOKEN"} is required to check or create content repos`);await zW(u,c,h)}await m("git",["clone",d,f]),await NW(f,m),await m("git",["config","user.name","brains-ops[bot]"],{cwd:f}),await m("git",["config","user.email","41898282+github-actions[bot]@users.noreply.github.com"],{cwd:f});let b=!1;for(let y of o)if(await OW(f,y))b=!0;if(!b)return;await m("git",["add","."],{cwd:f}),await m("git",["commit","-m",`chore(content): seed ${r.handle} anchor profile`],{cwd:f}),await m("git",["push","origin","HEAD:main"],{cwd:f})}finally{await kW(f,{recursive:!0,force:!0})}}async function OW(e,t){let r=q2(e,t.path),o=await IW(r,"utf8").catch(()=>{return});if(o===t.content)return!1;if(o!==void 0&&!CW(o))return!1;return await EW($W(r),{recursive:!0}),await AW(r,t.content),!0}function CW(e){return RW.some((t)=>e.includes(t))}function Z2(e,t,r){return Dt(r,e,t)}function PW(e,t){if(!t)return;return`https://x-access-token:${encodeURIComponent(t)}@github.com/${e.org}/${e.name}.git`}async function zW(e,t,r){let{org:o,name:n}=e,s=`https://api.github.com/repos/${`${encodeURIComponent(o)}/${encodeURIComponent(n)}`}`,a={Accept:"application/vnd.github+json",Authorization:`Bearer ${t}`,"User-Agent":"brains-ops","X-GitHub-Api-Version":"2022-11-28"},c=await r(s,{headers:a});if(c.ok)return;if(c.status!==404)throw Error(`Failed to check GitHub repo ${o}/${n}: ${c.status} ${await U2(c)}`);let u=await r(`https://api.github.com/orgs/${encodeURIComponent(o)}/repos`,{method:"POST",headers:a,body:JSON.stringify({name:n,private:!0,auto_init:!1})});if(u.ok){console.log(`Created missing content repo ${o}/${n}`);return}if(u.status===422){if((await r(s,{headers:a})).ok)return}throw Error(`Failed to create GitHub repo ${o}/${n}: ${u.status} ${await U2(u)}`)}async function U2(e){let t=await e.text();return t.trim().length===0?e.statusText:t}async function NW(e,t){try{await t("git",["checkout","-B","main","origin/main"],{cwd:e})}catch{await t("git",["checkout","-B","main"],{cwd:e})}}PE();Mr();async function oc(e,t,r,o,n={}){let i=Qm(t.pilot.githubOrg);for(let s of r){let a={};if(o){let m=await o(s);if(m!==void 0)a=m}let c=await i(s),u=a.brainYaml??c.brainYaml,d=a.envFile??c.envFile,f=a.contentRepoFiles??c.contentRepoFiles??[];if(d)await zE(e,s.handle,".env",d);if(u)await zE(e,s.handle,"brain.yaml",u);await M2(e,t.pilot.githubOrg,s,f,{contentRepoAdminTokenSelector:t.pilot.contentRepoAdminToken,...n});for(let m of f)await zE(e,s.handle,H2("content",m.path),m.content)}}async function zE(e,t,r,o){let n=H2(e,"users",t,r),i=Bun.file(n);if(r==="brain.yaml"&&await i.exists()){let s=sn(await i.text()),a=sn(o);if(s.ok&&a.ok&&FW(s.data,a.data))return}await UW(MW(n),{recursive:!0}),await qW(n,o)}async function Ym(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown user handle: ${t}`);return{registry:r,user:o}}async function V2(e,t){let r=await ut(e),o=r.cohorts.find((n)=>n.id===t);if(!o)throw Error(`Unknown cohort: ${t}`);return{registry:r,users:r.users.filter((n)=>n.cohort===o.id)}}async function W2(e){let t=await ut(e);return{registry:t,users:t.users}}async function NE(e,t,r,o={}){let{registry:n,user:i}=await Ym(e,t);await oc(e,n,[i],r,o)}no();Pn();import{access as JW,mkdir as G2,readFile as KW,writeFile as Y2}from"fs/promises";import{basename as HW,join as ic}from"path";async function DE(e,t,r){let o=pr.parse(t),n=pr.parse(r.cohort),i=ic(e,"users"),s=ic(e,"cohorts"),a=ic(i,`${o}.yaml`),c=ic(i,`${o}.secrets.yaml`),u=ic(i,`${o}.secrets.yaml.age`),d=ic(s,`${n}.yaml`);await Promise.all([G2(i,{recursive:!0}),G2(s,{recursive:!0})]);let f=r.discord===!0||Boolean(r.anchorId),m=await Q2(a,GW(o,f,r.anchorId)),b=await XW(u)?!1:await Q2(c,QW(o,f)),{addedToCohort:y}=await VW(d,o);return{handle:o,cohort:n,userPath:a,secretsTemplatePath:c,cohortPath:d,createdUser:m,createdSecretsTemplate:b,addedToCohort:y}}async function VW(e,t){let r=await WW(e);if(r.members.includes(t))return{addedToCohort:!1};let o={...r,members:[...r.members,t].sort()};return await Y2(e,YW(o)),{addedToCohort:!0}}async function WW(e){try{let t=await KW(e,"utf8"),r=sn(t,qr);if(!r.ok)throw Error(`${HW(e)}: ${r.error}`);return r.data}catch(t){if(tG(t))return{members:[]};throw t}}function GW(e,t,r){return[`handle: ${e}`,"anchorProfile:",` name: ${rG(e)}`,"discord:",` enabled: ${String(t)}`,...t&&r?[` anchorUserId: ${JSON.stringify(r)}`]:[],""].join(`
724
+ `)}function QW(e,t){return["# local per-user secret staging file",`# fill values, run \`bunx brains-ops secrets:encrypt . ${e}\`, then the plaintext file will be removed`,...t?["discordBotToken: "]:[],"atprotoAppPassword: ","# For custom-domain sites, paste PEMs with literal \\n escapes.","certificatePem: ","privateKeyPem: ",""].join(`
725
+ `)}function YW(e){return["members:",...e.members.map((t)=>` - ${t}`),...e.brainVersionOverride?[`brainVersionOverride: ${e.brainVersionOverride}`]:[],...e.bundlesOverride?["bundlesOverride:",...e.bundlesOverride.map((t)=>` - ${t}`)]:[],...e.addOverride?["addOverride:",...e.addOverride.map((t)=>` - ${t}`)]:[],...e.removeOverride?["removeOverride:",...e.removeOverride.map((t)=>` - ${t}`)]:[],...e.aiApiKeyOverride?[`aiApiKeyOverride: ${e.aiApiKeyOverride}`]:[],...e.gitSyncTokenOverride?[`gitSyncTokenOverride: ${e.gitSyncTokenOverride}`]:[],""].join(`
726
+ `)}async function Q2(e,t){try{return await Y2(e,t,{flag:"wx"}),!0}catch(r){if(eG(r))return!1;throw r}}async function XW(e){try{return await JW(e),!0}catch{return!1}}function eG(e){return X2(e,"EEXIST")}function tG(e){return X2(e,"ENOENT")}function X2(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function rG(e){return e.split("-").filter((t)=>t.length>0).map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}QI();async function YI(e,t,r,o={}){let{registry:n,users:i}=await V2(e,t);await oc(e,n,i,r,o)}async function ed(e,t,r={}){let{registry:o,users:n}=await W2(e);await oc(e,o,n,t,r)}import{parseArgs as lie}from"util";function ot(e){return e}class hB extends Error{constructor(e){super(e);this.name="CliUsageError"}}function uie(e,t){let r={...t};for(let o of e)for(let[n,i]of Object.entries(o.flags??{})){let s=r[n];if(s===void 0){r[n]=i;continue}if(s.type!==i.type||s.short!==i.short||s.default!==i.default)throw Error(`Conflicting definitions for flag --${n}: commands must agree on type, short, and default`)}return r}function die(e){let t={};for(let[r,o]of Object.entries(e))t[r]={type:o.type,...o.short!==void 0?{short:o.short}:{},...o.default!==void 0?{default:o.default}:{}};return t}function fie(e){if(!(e instanceof Error)||!("code"in e))return!1;return e.code==="ERR_PARSE_ARGS_UNKNOWN_OPTION"||e.code==="ERR_PARSE_ARGS_INVALID_OPTION_VALUE"}function gB(e,t){let r=uie(t.commands,t.globalFlags??{}),o,n;try{({values:o,positionals:n}=lie({args:e,options:die(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(fie(s))throw new hB(s.message.split(". ")[0]??s.message);throw s}if("help"in r&&o.help===!0)return{command:"help",args:[],flags:{help:!0}};if("version"in r&&o.version===!0)return{command:"version",args:[],flags:{version:!0}};let i={};for(let[s,a]of Object.entries(r)){let c=o[s];if(typeof c==="string"&&a.type==="string")i[s]=c;else if(typeof c==="boolean"&&a.type==="boolean")i[s]=c}return{command:n[0]??"help",args:n.slice(1),flags:i}}function yB(e){let t=e.reduce((r,o)=>Math.max(r,o.label.length),0);return e.map((r)=>` ${r.label.padEnd(t)} ${r.description}`)}function pie(e){return yB(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function mie(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",o=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${o}`}function bB(e){return yB(Object.entries(e).map(([t,r])=>({label:mie(t,r),description:r.description})))}function SB(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function hie(e){return JSON.stringify(Object.entries(e).map(([t,r])=>[t,r.type,r.short??"",r.description,r.placeholder??"",r.default??""]).sort((t,r)=>String(t[0]).localeCompare(String(r[0]))))}function gie(e){let t=[],r=new Map;for(let n of e){let i=n.flags??{};if(Object.keys(i).length===0)continue;let s=hie(i),a=r.get(s);if(a){a.names.push(n.name);continue}let c={names:[n.name],flags:i};r.set(s,c),t.push(c)}let o=[];for(let n of t)o.push("",`${n.names.join(" / ")} options:`),o.push(...bB(n.flags));return o}function vB(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...pie(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...bB(e.globalFlags));return t.push(...gie(e.commands)),t.join(`
727
+ `)}function wB(e){let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate command name: ${r.name}`);t.set(r.name,r)}return t}function nt(e,t){let r=e[t];return typeof r==="string"?r:void 0}function Is(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}import{existsSync as Mae,mkdirSync as Fae,readFileSync as jA,writeFileSync as ZA}from"fs";import{dirname as Jae,join as RU}from"path";function XI(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function vt(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw RangeError(`${r}expected integer >= 0, got ${e}`)}}function Ft(e,t,r=""){let o=XI(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function yo(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(vt(e.outputLen),vt(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function vc(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function Mh(e,t){Ft(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function Fh(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function mr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function wc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function dn(e,t){return e<<32-t|e>>>t}function Fe(e,t){return e<<t|e>>>32-t>>>0}var yie=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function bie(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Sie(e){for(let t=0;t<e.length;t++)e[t]=bie(e[t]);return e}var ek=yie?(e)=>e:Sie,_B=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),vie=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Jh(e){if(Ft(e),_B)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=vie[e[r]];return t}var go={_0:48,_9:57,A:65,F:70,a:97,f:102};function xB(e){if(e>=go._0&&e<=go._9)return e-go._0;if(e>=go.A&&e<=go.F)return e-(go.A-10);if(e>=go.a&&e<=go.f)return e-(go.a-10);return}function td(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(_B)try{return Uint8Array.fromHex(e)}catch(n){if(n instanceof SyntaxError)throw RangeError(n.message);throw n}let t=e.length,r=t/2;if(t%2)throw RangeError("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=xB(e.charCodeAt(i)),a=xB(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function wie(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function tk(e,t=""){if(typeof e==="string")return wie(e);return Ft(e,void 0,t)}function rk(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Ft(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function Kh(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw TypeError("options must be object or undefined");return Object.assign(e,t)}function nk(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.canXOF=o.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function bo(e=32){vt(e,"bytesLength");let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var ok=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class ik{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(yo(e),Ft(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),mr(o)}update(e){return vc(this),this.iHash.update(e),this}digestInto(e){vc(this),Mh(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Bn=(()=>{let e=(t,r,o)=>new ik(t,r).update(o).digest();return e.create=(t,r)=>new ik(t,r),e})();function rd(e,t,r){if(yo(e),r===void 0)r=new Uint8Array(e.outputLen);return Bn(e,r,t)}var sk=Uint8Array.of(0),EB=Uint8Array.of();function ak(e,t,r,o=32){yo(e),vt(o,"length"),Ft(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=EB;else Ft(r,void 0,"info");let s=new Uint8Array(i*n),a=Bn.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)sk[0]=d+1,c.update(d===0?EB:u).update(r).update(sk).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),mr(u,sk),s.slice(0,o)}var gi=(e,t,r,o,n)=>ak(e,rd(e,t,r),o,n);function IB(e,t,r){return e&t^~e&r}function kB(e,t,r){return e&t^e&r^t&r}class Hh{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=wc(this.buffer)}update(e){vc(this),Ft(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=wc(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){vc(this),Mh(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,mr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=wc(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var So=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Jt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Vh=BigInt(4294967295),AB=BigInt(32);function xie(e,t=!1){if(t)return{h:Number(e&Vh),l:Number(e>>AB&Vh)};return{h:Number(e>>AB&Vh)|0,l:Number(e&Vh)|0}}function TB(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=xie(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var ck=(e,t,r)=>e>>>r,lk=(e,t,r)=>e<<32-r|t>>>r,ks=(e,t,r)=>e>>>r|t<<32-r,As=(e,t,r)=>e<<32-r|t>>>r,nd=(e,t,r)=>e<<64-r|t>>>r-32,od=(e,t,r)=>e>>>r-32|t<<64-r;function jn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var $B=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),RB=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,OB=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),CB=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,PB=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),zB=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var Eie=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),yi=new Uint32Array(64);class NB extends Hh{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)yi[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=yi[d-15],m=yi[d-2],h=dn(f,7)^dn(f,18)^f>>>3,b=dn(m,17)^dn(m,19)^m>>>10;yi[d]=b+yi[d-7]+h+yi[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let f=dn(s,6)^dn(s,11)^dn(s,25),m=u+f+IB(s,a,c)+Eie[d]+yi[d]|0,b=(dn(r,2)^dn(r,13)^dn(r,22))+kB(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){mr(yi)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),mr(this.buffer)}}class DB extends NB{A=So[0]|0;B=So[1]|0;C=So[2]|0;D=So[3]|0;E=So[4]|0;F=So[5]|0;G=So[6]|0;H=So[7]|0;constructor(){super(32)}}var LB=(()=>TB(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e)=>BigInt(e))))(),Iie=(()=>LB[0])(),kie=(()=>LB[1])(),bi=new Uint32Array(80),Si=new Uint32Array(80);class BB extends Hh{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)bi[_]=e.getUint32(t),Si[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=bi[_-15]|0,O=Si[_-15]|0,L=ks(A,O,1)^ks(A,O,8)^ck(A,O,7),z=As(A,O,1)^As(A,O,8)^lk(A,O,7),K=bi[_-2]|0,P=Si[_-2]|0,W=ks(K,P,19)^nd(K,P,61)^ck(K,P,6),ee=As(K,P,19)^od(K,P,61)^lk(K,P,6),j=OB(z,ee,Si[_-7],Si[_-16]),R=CB(j,L,W,bi[_-7],bi[_-16]);bi[_]=R|0,Si[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=ks(d,f,14)^ks(d,f,18)^nd(d,f,41),O=As(d,f,14)^As(d,f,18)^od(d,f,41),L=d&m^~d&b,z=f&h^~f&y,K=PB(x,O,z,kie[_],Si[_]),P=zB(K,S,A,L,Iie[_],bi[_]),W=K|0,ee=ks(r,o,28)^nd(r,o,34)^nd(r,o,39),j=As(r,o,28)^od(r,o,34)^od(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=jn(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let I=$B(W,j,B);r=RB(I,P,ee,R),o=I|0}({h:r,l:o}=jn(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=jn(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=jn(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=jn(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:f}=jn(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=jn(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=jn(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=jn(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,f,m,h,b,y,S,x)}roundClean(){mr(bi,Si)}destroy(){this.destroyed=!0,mr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class jB extends BB{Ah=Jt[0]|0;Al=Jt[1]|0;Bh=Jt[2]|0;Bl=Jt[3]|0;Ch=Jt[4]|0;Cl=Jt[5]|0;Dh=Jt[6]|0;Dl=Jt[7]|0;Eh=Jt[8]|0;El=Jt[9]|0;Fh=Jt[10]|0;Fl=Jt[11]|0;Gh=Jt[12]|0;Gl=Jt[13]|0;Hh=Jt[14]|0;Hl=Jt[15]|0;constructor(){super(64)}}var wt=nk(()=>new DB,ok(1));var Wh=nk(()=>new jB,ok(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function eg(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function fk(e){if(!eg(e))throw TypeError("Uint8Array expected")}function FB(e,t){if(!Array.isArray(t))return!1;if(t.length===0)return!0;if(e)return t.every((r)=>typeof r==="string");else return t.every((r)=>Number.isSafeInteger(r))}function JB(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function vi(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function sd(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Qh(e){if(!Array.isArray(e))throw TypeError("array expected")}function Yh(e,t){if(!FB(!0,t))throw TypeError(`${e}: array of strings expected`)}function pk(e,t){if(!FB(!1,t))throw TypeError(`${e}: array of numbers expected`)}function Pr(...e){let t=(i)=>i,r=(i,s)=>(a)=>i(s(a)),o=e.map((i)=>i.encode).reduceRight(r,t),n=e.map((i)=>i.decode).reduce(r,t);return{encode:o,decode:n}}function zr(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Yh("alphabet",t);let o=new Map(t.map((n,i)=>[n,i]));return{encode:(n)=>(Qh(n),n.map((i)=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:(n)=>(Qh(n),n.map((i)=>{vi("alphabet.decode",i);let s=o.get(i);if(s===void 0)throw Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function Nr(e=""){return vi("join",e),{encode:(t)=>(Yh("join.decode",t),t.join(e)),decode:(t)=>(vi("join.decode",t),t.split(e))}}function tg(e,t="="){return sd(e),vi("padding",t),{encode(r){Yh("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Yh("padding.decode",r);let o=r.length;if(o*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function KB(e){return JB(e),{encode:(t)=>t,decode:(t)=>e(t)}}function ZB(e,t,r){if(t<2)throw RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw RangeError(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Qh(e),!e.length)return[];let o=0,n=[],i=Array.from(e,(a)=>{if(sd(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=i.length;while(!0){let a=0,c=!0;for(let u=o;u<s;u++){let d=i[u],f=t*a,m=f+d;if(!Number.isSafeInteger(m)||f/t!==a||m-d!==f)throw Error("convertRadix: carry overflow");let h=m/r;a=m%r;let b=Math.floor(h);if(i[u]=b,!Number.isSafeInteger(b)||b*r+a!==m)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!b)o=u;else c=!1}if(n.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)n.push(0);return n.reverse()}var HB=(e,t)=>t===0?e:HB(t,e%t),Xh=(e,t)=>e+(t-HB(e,t)),Gh=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function uk(e,t,r,o){if(Qh(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Xh(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Xh(t,r)}`);let n=0,i=0,s=Gh[t],a=Gh[r]-1,c=[];for(let u of e){if(sd(u),u>=s)throw Error(`convertRadix2: invalid data word=${u} from=${t}`);if(n=n<<t|u,i+t>32)throw Error(`convertRadix2: carry overflow pos=${i} from=${t}`);i+=t;for(;i>=r;i-=r)c.push((n>>i-r&a)>>>0);let d=Gh[i];if(d===void 0)throw Error("invalid carry");n&=d-1}if(n=n<<r-i&a,!o&&i>=t)throw Error("Excess padding");if(!o&&n>0)throw Error(`Non-zero padding: ${n}`);if(o&&i>0)c.push(n>>>0);return c}function Aie(e){sd(e);let t=256;return{encode:(r)=>{if(!eg(r))throw TypeError("radix.encode input should be Uint8Array");return ZB(Array.from(r),t,e)},decode:(r)=>(pk("radix.decode",r),Uint8Array.from(ZB(r,e,t)))}}function Kr(e,t=!1){if(sd(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Xh(8,e)>32||Xh(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!eg(r))throw TypeError("radix2.encode input should be Uint8Array");return uk(Array.from(r),8,e,!t)},decode:(r)=>(pk("radix2.decode",r),Uint8Array.from(uk(r,e,8,t)))}}function UB(e){return JB(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var zTe=Object.freeze(Pr(Kr(4),zr("0123456789ABCDEF"),Nr(""))),NTe=Object.freeze(Pr(Kr(5),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),tg(5),Nr(""))),DTe=Object.freeze(Pr(Kr(5),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Nr(""))),LTe=Object.freeze(Pr(Kr(5),zr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),tg(5),Nr(""))),BTe=Object.freeze(Pr(Kr(5),zr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Nr(""))),jTe=Object.freeze(Pr(Kr(5),zr("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Nr(""),KB((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),VB=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),Tie=/[\t\n\f\r ]/,WB=(e,t)=>{vi("base64",e);let r=t?"base64url":"base64";if(e.length>0&&Tie.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},mk=Object.freeze(VB?{encode(e){return fk(e),e.toBase64()},decode(e){return WB(e,!1)}}:Pr(Kr(6),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),tg(6),Nr(""))),tr=Object.freeze(Pr(Kr(6),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Nr(""))),ZTe=Object.freeze(VB?{encode(e){return fk(e),e.toBase64({alphabet:"base64url"})},decode(e){return WB(e,!0)}}:Pr(Kr(6),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),tg(6),Nr(""))),UTe=Object.freeze(Pr(Kr(6),zr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Nr(""))),hk=(e)=>Pr(Aie(58),zr(e),Nr("")),qTe=Object.freeze(hk("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),MTe=Object.freeze(hk("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),FTe=Object.freeze(hk("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var dk=Pr(zr("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Nr("")),qB=[996825010,642813549,513874426,1027748829,705979059];function id(e){let t=e>>25,r=(e&33554431)<<5;for(let o=0;o<qB.length;o++)if((t>>o&1)===1)r^=qB[o];return r}function MB(e,t,r=1){let o=e.length,n=1;for(let i=0;i<o;i++){let s=e.charCodeAt(i);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=id(n)^s>>5}n=id(n);for(let i=0;i<o;i++)n=id(n)^e.charCodeAt(i)&31;for(let i of t)n=id(n)^i;for(let i=0;i<6;i++)n=id(n);return n^=r,dk.encode(uk([n%Gh[30]],30,5,!1))}function GB(e){let t=e==="bech32"?1:734539939,r=Kr(5),o=r.decode,n=r.encode,i=UB(o);function s(f,m,h=90){if(vi("bech32.encode prefix",f),eg(m))m=Array.from(m);pk("bech32.encode",m);let b=f.length;if(b===0)throw TypeError(`Invalid prefix length ${b}`);let y=b+7+m.length;if(h!==!1&&y>h)throw TypeError(`Length ${y} exceeds limit ${h}`);let S=f.toLowerCase(),x=MB(S,m,t);return`${S}1${dk.encode(m)}${x}`}function a(f,m=90){vi("bech32.decode input",f);let h=f.length;if(h<8||m!==!1&&h>m)throw TypeError(`invalid string length: ${h} (${f}). Expected (8..${m})`);let b=f.toLowerCase();if(f!==b&&f!==f.toUpperCase())throw Error("String must be lowercase or uppercase");let y=b.lastIndexOf("1");if(y===0||y===-1)throw Error('Letter "1" must be present between prefix and data only');let S=b.slice(0,y),x=b.slice(y+1);if(x.length<6)throw Error("Data must be at least 6 characters long");let _=dk.decode(x).slice(0,-6),A=MB(S,_,t);if(!x.endsWith(A))throw Error(`Invalid checksum in ${f}: expected "${A}"`);return{prefix:S,words:_}}let c=UB(a);function u(f){let{prefix:m,words:h}=a(f,!1);return{prefix:m,words:h,bytes:o(h)}}function d(f,m){return s(f,n(m))}return{encode:s,decode:a,encodeFromBytes:d,decodeToBytes:u,decodeUnsafe:c,fromWords:o,fromWordsUnsafe:i,toWords:n}}var Dr=Object.freeze(GB("bech32")),JTe=Object.freeze(GB("bech32m"));var $ie=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Rie={encode(e){return fk(e),e.toHex()},decode(e){return vi("hex",e),Uint8Array.fromHex(e)}},KTe=Object.freeze($ie?Rie:Pr(Kr(4),zr("0123456789abcdef"),Nr(""),KB((e)=>{if(typeof e!=="string"||e.length%2!==0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));function Cie(e,t,r,o){yo(e);let n=Kh({dkLen:32,asyncTick:10},o),{c:i,dkLen:s,asyncTick:a}=n;if(vt(i,"c"),vt(s,"dkLen"),vt(a,"asyncTick"),i<1)throw Error("iterations (c) must be >= 1");if(s<1)throw Error('"dkLen" must be >= 1');if(s>4294967295*e.outputLen)throw Error("derived key too long");let c=tk(t,"password"),u=tk(r,"salt"),d=new Uint8Array(s),f=Bn.create(e,c),m=f._cloneInto().update(u);return{c:i,dkLen:s,asyncTick:a,DK:d,PRF:f,PRFSalt:m}}function Pie(e,t,r,o,n){if(e.destroy(),t.destroy(),o)o.destroy();return mr(n),r}function gk(e,t,r,o){let{c:n,dkLen:i,DK:s,PRF:a,PRFSalt:c}=Cie(e,t,r,o),u,d=new Uint8Array(4),f=wc(d),m=new Uint8Array(a.outputLen);for(let h=1,b=0;b<i;h++,b+=a.outputLen){let y=s.subarray(b,b+a.outputLen);f.setInt32(0,h,!1),(u=c._cloneInto(u)).update(d).digestInto(m),y.set(m.subarray(0,y.length));for(let S=1;S<n;S++){a._cloneInto(u).update(m).digestInto(m);for(let x=0;x<y.length;x++)y[x]^=m[x]}}return Pie(a,c,s,u,m)}function QB(e,t,r,o,n,i){let s=e[t++]^r[o++],a=e[t++]^r[o++],c=e[t++]^r[o++],u=e[t++]^r[o++],d=e[t++]^r[o++],f=e[t++]^r[o++],m=e[t++]^r[o++],h=e[t++]^r[o++],b=e[t++]^r[o++],y=e[t++]^r[o++],S=e[t++]^r[o++],x=e[t++]^r[o++],_=e[t++]^r[o++],A=e[t++]^r[o++],O=e[t++]^r[o++],L=e[t++]^r[o++],z=s,K=a,P=c,W=u,ee=d,j=f,R=m,B=h,I=b,T=y,k=S,M=x,N=_,H=A,G=O,re=L;for(let ae=0;ae<8;ae+=2)ee^=Fe(z+N|0,7),I^=Fe(ee+z|0,9),N^=Fe(I+ee|0,13),z^=Fe(N+I|0,18),T^=Fe(j+K|0,7),H^=Fe(T+j|0,9),K^=Fe(H+T|0,13),j^=Fe(K+H|0,18),G^=Fe(k+R|0,7),P^=Fe(G+k|0,9),R^=Fe(P+G|0,13),k^=Fe(R+P|0,18),W^=Fe(re+M|0,7),B^=Fe(W+re|0,9),M^=Fe(B+W|0,13),re^=Fe(M+B|0,18),K^=Fe(z+W|0,7),P^=Fe(K+z|0,9),W^=Fe(P+K|0,13),z^=Fe(W+P|0,18),R^=Fe(j+ee|0,7),B^=Fe(R+j|0,9),ee^=Fe(B+R|0,13),j^=Fe(ee+B|0,18),M^=Fe(k+T|0,7),I^=Fe(M+k|0,9),T^=Fe(I+M|0,13),k^=Fe(T+I|0,18),N^=Fe(re+G|0,7),H^=Fe(N+re|0,9),G^=Fe(H+N|0,13),re^=Fe(G+H|0,18);n[i++]=s+z|0,n[i++]=a+K|0,n[i++]=c+P|0,n[i++]=u+W|0,n[i++]=d+ee|0,n[i++]=f+j|0,n[i++]=m+R|0,n[i++]=h+B|0,n[i++]=b+I|0,n[i++]=y+T|0,n[i++]=S+k|0,n[i++]=x+M|0,n[i++]=_+N|0,n[i++]=A+H|0,n[i++]=O+G|0,n[i++]=L+re|0}function yk(e,t,r,o,n){let i=o+0,s=o+16*n;for(let a=0;a<16;a++)r[s+a]=e[t+(2*n-1)*16+a];for(let a=0;a<n;a++,i+=16,t+=16){if(QB(r,s,e,t,r,i),a>0)s+=16;QB(r,i,e,t+=16,r,s)}}function zie(e,t,r){let o=Kh({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:i,p:s,dkLen:a,asyncTick:c,maxmem:u,onProgress:d}=o;if(vt(n,"N"),vt(i,"r"),vt(s,"p"),vt(a,"dkLen"),vt(c,"asyncTick"),vt(u,"maxmem"),d!==void 0&&typeof d!=="function")throw Error("progressCb must be a function");let f=128*i,m=f/4,h=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>h)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(h-1)*32/f)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(h-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let b=f*(n+s+1);if(b>u)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+b+", maxmem="+u);let y=gk(wt,e,t,{c:1,dkLen:f*s}),S=Fh(y),x=Fh(new Uint8Array(f*n)),_=Fh(new Uint8Array(f)),A=()=>{};if(d){let O=2*n*s,L=Math.max(Math.floor(O/1e4),1),z=0;A=()=>{if(z++,d&&(!(z%L)||z===O))d(z/O)}}return{N:n,r:i,p:s,dkLen:a,blockSize32:m,V:x,B32:S,B:y,tmp:_,blockMixCb:A,asyncTick:c}}function Nie(e,t,r,o,n){let i=gk(wt,e,r,{c:1,dkLen:t});return mr(r,o,n),i}function bk(e,t,r){let{N:o,r:n,p:i,dkLen:s,blockSize32:a,V:c,B32:u,B:d,tmp:f,blockMixCb:m}=zie(e,t,r);ek(u);for(let h=0;h<i;h++){let b=a*h;for(let y=0;y<a;y++)c[y]=u[b+y];for(let y=0,S=0;y<o-1;y++)yk(c,S,c,S+=a,n),m();yk(c,(o-1)*a,u,b,n),m();for(let y=0;y<o;y++){let S=(u[b+a-16]&o-1)>>>0;for(let x=0;x<a;x++)f[x]=u[b+x]^c[S*a+x];yk(f,0,u,b,n),m()}}return ek(u),Nie(e,s,d,c,f)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function Die(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function rg(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function xc(e){if(typeof e!=="number")throw TypeError("number expected, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError("positive integer expected, got "+e)}function Ot(e,t,r=""){let o=Die(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function Sk(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function YB(e,t,r=!1){Ot(e,void 0,"output");let o=t.outputLen;if(e.length<o)throw RangeError("digestInto() expects output buffer of length at least "+o);if(r&&!_c(e))throw Error("invalid output, must be aligned")}function Zn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function fn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Lie(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var Ts=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),Bie=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var jie=(e)=>{for(let t=0;t<e.length;t++)e[t]=Bie(e[t]);return e},vo=Ts?(e)=>e:jie;function XB(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function ej(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function tj(e,t,r){let o=t,n=r||(()=>[]),i=(a,c)=>o(c,...n(a)).update(a).digest(),s=o(new Uint8Array(e),...n(new Uint8Array(0)));return i.outputLen=s.outputLen,i.blockLen=s.blockLen,i.create=(a,...c)=>o(a,...c),i}var rj=(e,t)=>{function r(o,...n){if(Ot(o,void 0,"key"),e.nonceLength!==void 0){let d=n[0];Ot(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let i=e.tagLength;if(i&&n[1]!==void 0)Ot(n[1],void 0,"AAD");let s=t(o,...n),a=(d,f)=>{if(f!==void 0){if(d!==2)throw Error("cipher output not supported");Ot(f,void 0,"output")}},c=!1;return{encrypt(d,f){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Ot(d),a(s.encrypt.length,f),s.encrypt(d,f)},decrypt(d,f){if(Ot(d),i&&d.length<i)throw Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,f),s.decrypt(d,f)}}}return Object.assign(r,e),r};function ad(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Ot(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!_c(t))throw Error("invalid output, must be aligned");return t}function nj(e,t,r){xc(e),xc(t),rg(r);let o=new Uint8Array(16),n=Lie(o);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),o}function _c(e){return e.byteOffset%4===0}function Ec(e){return Uint8Array.from(Ot(e))}var ij=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),Zie=(()=>vo(Zn(ij("expand 16-byte k"))))(),Uie=(()=>vo(Zn(ij("expand 32-byte k"))))();function Je(e,t){return e<<t|e>>>32-t}var cd=64,qie=16,vk=(()=>4294967295)(),oj=Uint32Array.of();function Mie(e,t,r,o,n,i,s,a){let c=n.length,u=new Uint8Array(cd),d=Zn(u),f=Ts&&_c(n)&&_c(i),m=f?Zn(n):oj,h=f?Zn(i):oj;if(!Ts){for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),vo(d),s>=vk)throw Error("arx: counter overflow");let y=Math.min(cd,c-b);for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}return}for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),s>=vk)throw Error("arx: counter overflow");let y=Math.min(cd,c-b);if(f&&y===cd){let S=b/4;if(b%4!==0)throw Error("arx: invalid block position");for(let x=0,_;x<qie;x++)_=S+x,h[_]=m[_]^d[x];b+=cd;continue}for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}}function sj(e,t){let{allowShortKeys:r,extendNonceFn:o,counterLength:n,counterRight:i,rounds:s}=XB({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return xc(n),xc(s),rg(i),rg(r),(a,c,u,d,f=0)=>{Ot(a,void 0,"key"),Ot(c,void 0,"nonce"),Ot(u,void 0,"data");let m=u.length;if(d=ad(m,d,!1),xc(f),f<0||f>=vk)throw Error("arx: counter overflow");let h=[],b=a.length,y,S;if(b===32)h.push(y=Ec(a)),S=Uie;else if(b===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),S=Zie,h.push(y);else throw Ot(a,32,"arx key"),Error("invalid key size");if(!Ts||!_c(c))h.push(c=Ec(c));let x=Zn(y);if(o){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let O=c.subarray(0,16);if(Ts)o(S,x,Zn(O),x);else{let L=vo(Uint32Array.from(S));o(L,x,Zn(O),x),fn(L),vo(x)}c=c.subarray(16)}else if(!Ts)vo(x);let _=16-n;if(_!==c.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let O=new Uint8Array(12);O.set(c,i?0:12-c.length),c=O,h.push(c)}let A=vo(Zn(c));try{return Mie(e,S,x,A,u,d,f,s),d}finally{fn(...h)}}}function Kt(e,t){return e[t++]&255|(e[t++]&255)<<8}class aj{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=Ec(Ot(e,32,"key"));let t=Kt(e,0),r=Kt(e,2),o=Kt(e,4),n=Kt(e,6),i=Kt(e,8),s=Kt(e,10),a=Kt(e,12),c=Kt(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|n<<9)&8191,this.r[4]=(n>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Kt(e,16+2*u)}process(e,t,r=!1){let o=r?0:2048,{h:n,r:i}=this,s=i[0],a=i[1],c=i[2],u=i[3],d=i[4],f=i[5],m=i[6],h=i[7],b=i[8],y=i[9],S=Kt(e,t+0),x=Kt(e,t+2),_=Kt(e,t+4),A=Kt(e,t+6),O=Kt(e,t+8),L=Kt(e,t+10),z=Kt(e,t+12),K=Kt(e,t+14),P=n[0]+(S&8191),W=n[1]+((S>>>13|x<<3)&8191),ee=n[2]+((x>>>10|_<<6)&8191),j=n[3]+((_>>>7|A<<9)&8191),R=n[4]+((A>>>4|O<<12)&8191),B=n[5]+(O>>>1&8191),I=n[6]+((O>>>14|L<<2)&8191),T=n[7]+((L>>>11|z<<5)&8191),k=n[8]+((z>>>8|K<<8)&8191),M=n[9]+(K>>>5|o),N=0,H=N+P*s+W*(5*y)+ee*(5*b)+j*(5*h)+R*(5*m);N=H>>>13,H&=8191,H+=B*(5*f)+I*(5*d)+T*(5*u)+k*(5*c)+M*(5*a),N+=H>>>13,H&=8191;let G=N+P*a+W*s+ee*(5*y)+j*(5*b)+R*(5*h);N=G>>>13,G&=8191,G+=B*(5*m)+I*(5*f)+T*(5*d)+k*(5*u)+M*(5*c),N+=G>>>13,G&=8191;let re=N+P*c+W*a+ee*s+j*(5*y)+R*(5*b);N=re>>>13,re&=8191,re+=B*(5*h)+I*(5*m)+T*(5*f)+k*(5*d)+M*(5*u),N+=re>>>13,re&=8191;let ae=N+P*u+W*c+ee*a+j*s+R*(5*y);N=ae>>>13,ae&=8191,ae+=B*(5*b)+I*(5*h)+T*(5*m)+k*(5*f)+M*(5*d),N+=ae>>>13,ae&=8191;let pe=N+P*d+W*u+ee*c+j*a+R*s;N=pe>>>13,pe&=8191,pe+=B*(5*y)+I*(5*b)+T*(5*h)+k*(5*m)+M*(5*f),N+=pe>>>13,pe&=8191;let be=N+P*f+W*d+ee*u+j*c+R*a;N=be>>>13,be&=8191,be+=B*s+I*(5*y)+T*(5*b)+k*(5*h)+M*(5*m),N+=be>>>13,be&=8191;let ve=N+P*m+W*f+ee*d+j*u+R*c;N=ve>>>13,ve&=8191,ve+=B*a+I*s+T*(5*y)+k*(5*b)+M*(5*h),N+=ve>>>13,ve&=8191;let ke=N+P*h+W*m+ee*f+j*d+R*u;N=ke>>>13,ke&=8191,ke+=B*c+I*a+T*s+k*(5*y)+M*(5*b),N+=ke>>>13,ke&=8191;let Ie=N+P*b+W*h+ee*m+j*f+R*d;N=Ie>>>13,Ie&=8191,Ie+=B*u+I*c+T*a+k*s+M*(5*y),N+=Ie>>>13,Ie&=8191;let we=N+P*y+W*b+ee*h+j*m+R*f;N=we>>>13,we&=8191,we+=B*d+I*u+T*c+k*a+M*s,N+=we>>>13,we&=8191,N=(N<<2)+N|0,N=N+H|0,H=N&8191,N=N>>>13,G+=N,n[0]=H,n[1]=G,n[2]=re,n[3]=ae,n[4]=pe,n[5]=be,n[6]=ve,n[7]=ke,n[8]=Ie,n[9]=we}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),o=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=o,o=e[s]>>>13,e[s]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+o,o=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(o^1)-1;for(let s=0;s<10;s++)r[s]&=n;n=~n;for(let s=0;s<10;s++)e[s]=e[s]&n|r[s];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let i=e[0]+t[0];e[0]=i&65535;for(let s=1;s<8;s++)i=(e[s]+t[s]|0)+(i>>>16)|0,e[s]=i&65535;fn(r)}update(e){Sk(this),Ot(e),e=Ec(e);let{buffer:t,blockLen:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(r-this.pos,o-n);if(i===r){for(;r<=o-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+i),this.pos),this.pos+=i,n+=i,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,fn(this.h,this.r,this.buffer,this.pad)}digestInto(e){Sk(this),YB(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:o}=this;if(o){t[o++]=1;for(;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let i=0;i<8;i++)e[n++]=r[i]>>>0,e[n++]=r[i]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var cj=tj(32,(e)=>new aj(e));function Fie(e,t,r,o,n,i=20){let s=e[0],a=e[1],c=e[2],u=e[3],d=t[0],f=t[1],m=t[2],h=t[3],b=t[4],y=t[5],S=t[6],x=t[7],_=n,A=r[0],O=r[1],L=r[2],z=s,K=a,P=c,W=u,ee=d,j=f,R=m,B=h,I=b,T=y,k=S,M=x,N=_,H=A,G=O,re=L;for(let pe=0;pe<i;pe+=2)z=z+ee|0,N=Je(N^z,16),I=I+N|0,ee=Je(ee^I,12),z=z+ee|0,N=Je(N^z,8),I=I+N|0,ee=Je(ee^I,7),K=K+j|0,H=Je(H^K,16),T=T+H|0,j=Je(j^T,12),K=K+j|0,H=Je(H^K,8),T=T+H|0,j=Je(j^T,7),P=P+R|0,G=Je(G^P,16),k=k+G|0,R=Je(R^k,12),P=P+R|0,G=Je(G^P,8),k=k+G|0,R=Je(R^k,7),W=W+B|0,re=Je(re^W,16),M=M+re|0,B=Je(B^M,12),W=W+B|0,re=Je(re^W,8),M=M+re|0,B=Je(B^M,7),z=z+j|0,re=Je(re^z,16),k=k+re|0,j=Je(j^k,12),z=z+j|0,re=Je(re^z,8),k=k+re|0,j=Je(j^k,7),K=K+R|0,N=Je(N^K,16),M=M+N|0,R=Je(R^M,12),K=K+R|0,N=Je(N^K,8),M=M+N|0,R=Je(R^M,7),P=P+B|0,H=Je(H^P,16),I=I+H|0,B=Je(B^I,12),P=P+B|0,H=Je(H^P,8),I=I+H|0,B=Je(B^I,7),W=W+ee|0,G=Je(G^W,16),T=T+G|0,ee=Je(ee^T,12),W=W+ee|0,G=Je(G^W,8),T=T+G|0,ee=Je(ee^T,7);let ae=0;o[ae++]=s+z|0,o[ae++]=a+K|0,o[ae++]=c+P|0,o[ae++]=u+W|0,o[ae++]=d+ee|0,o[ae++]=f+j|0,o[ae++]=m+R|0,o[ae++]=h+B|0,o[ae++]=b+I|0,o[ae++]=y+T|0,o[ae++]=S+k|0,o[ae++]=x+M|0,o[ae++]=_+N|0,o[ae++]=A+H|0,o[ae++]=O+G|0,o[ae++]=L+re|0}var Jie=sj(Fie,{counterRight:!1,counterLength:4,allowShortKeys:!1});var Kie=new Uint8Array(16),lj=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(Kie.subarray(r))},Hie=new Uint8Array(32);function uj(e,t,r,o,n){if(n!==void 0)Ot(n,void 0,"AAD");let i=e(t,r,Hie),s=nj(o.length,n?n.length:0,!0),a=cj.create(i);if(n)lj(a,n);lj(a,o),a.update(s);let c=a.digest();return fn(i,s),c}var Vie=(e)=>(t,r,o)=>({encrypt(i,s){let a=i.length;s=ad(a+16,s,!1),s.set(i);let c=s.subarray(0,-16);e(t,r,c,c,1);let u=uj(e,t,r,c,o);return s.set(u,a),fn(u),s},decrypt(i,s){s=ad(i.length-16,s,!1);let a=i.subarray(0,-16),c=i.subarray(-16),u=uj(e,t,r,a,o);if(!ej(c,u))throw fn(u),Error("invalid tag");return s.set(i.subarray(0,-16)),e(t,r,s,s,1),fn(u),s}}),Hr=rj({blockSize:64,nonceLength:12,tagLength:16},Vie(Jie));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ic(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Bt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Te(e,t,r=""){let o=Ic(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+c)}return e}function Vr(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Bt(e.outputLen),Bt(e.blockLen)}function xo(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function ng(e,t){Te(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function og(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Er(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ig(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function pn(e,t){return e<<32-t|e>>>t}var Wie=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function Gie(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Qie(e){for(let t=0;t<e.length;t++)e[t]=Gie(e[t]);return e}var wk=Wie?(e)=>e:Qie,fj=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Yie=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function $s(e){if(Te(e),fj)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Yie[e[r]];return t}var wo={_0:48,_9:57,A:65,F:70,a:97,f:102};function dj(e){if(e>=wo._0&&e<=wo._9)return e-wo._0;if(e>=wo.A&&e<=wo.F)return e-(wo.A-10);if(e>=wo.a&&e<=wo.f)return e-(wo.a-10);return}function Rs(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(fj)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=dj(e.charCodeAt(i)),a=dj(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw Error('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function It(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Te(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function kc(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function wi(e=32){let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var xi=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var _k=BigInt(0),xk=BigInt(1);function ld(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function pj(e){if(typeof e==="bigint"){if(!sg(e))throw Error("positive bigint expected, got "+e)}else Bt(e);return e}function ud(e){let t=pj(e).toString(16);return t.length&1?"0"+t:t}function mj(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?_k:BigInt("0x"+e)}function _i(e){return mj($s(e))}function Ei(e){return mj($s(ag(Te(e)).reverse()))}function Ac(e,t){Bt(t),e=pj(e);let r=Rs(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function dd(e,t){return Ac(e,t).reverse()}function ag(e){return Uint8Array.from(e)}function Ii(e){return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var sg=(e)=>typeof e==="bigint"&&_k<=e;function Xie(e,t,r){return sg(e)&&sg(t)&&sg(r)&&t<=e&&e<r}function fd(e,t,r,o){if(!Xie(t,r,o))throw Error("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function Ek(e){let t;for(t=0;e>_k;e>>=xk,t+=1);return t}var pd=(e)=>(xk<<BigInt(e))-xk;function hj(e,t,r){if(Bt(e,"hashLen"),Bt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,f=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,It(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return It(...x)};return(S,x)=>{f(),h(S);let _=void 0;while(!(_=x(b())))h();return f(),_}}function Os(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function o(i,s,a){let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw Error(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}function Ik(e){let t=new WeakMap;return(r,...o)=>{let n=t.get(r);if(n!==void 0)return n;let i=e(r,...o);return t.set(r,i),i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var gr=BigInt(0),rr=BigInt(1),Cs=BigInt(2),bj=BigInt(3),Sj=BigInt(4),vj=BigInt(5),ese=BigInt(7),wj=BigInt(8),tse=BigInt(9),xj=BigInt(16);function hr(e,t){let r=e%t;return r>=gr?r:t+r}function Wr(e,t,r){let o=e;while(t-- >gr)o*=o,o%=r;return o}function gj(e,t){if(e===gr)throw Error("invert: expected non-zero number");if(t<=gr)throw Error("invert: expected positive modulus, got "+t);let r=hr(e,t),o=t,n=gr,i=rr,s=rr,a=gr;while(r!==gr){let u=o/r,d=o%r,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==rr)throw Error("invert: does not exist");return hr(n,t)}function kk(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function _j(e,t){let r=(e.ORDER+rr)/Sj,o=e.pow(t,r);return kk(e,o,t),o}function rse(e,t){let r=(e.ORDER-vj)/wj,o=e.mul(t,Cs),n=e.pow(o,r),i=e.mul(t,n),s=e.mul(e.mul(i,Cs),n),a=e.mul(i,e.sub(s,e.ONE));return kk(e,a,t),a}function nse(e){let t=cg(e),r=Ej(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+ese)/xj;return(a,c)=>{let u=a.pow(c,s),d=a.mul(u,o),f=a.mul(u,n),m=a.mul(u,i),h=a.eql(a.sqr(d),c),b=a.eql(a.sqr(f),c);u=a.cmov(u,d,h),d=a.cmov(m,f,b);let y=a.eql(a.sqr(d),c),S=a.cmov(u,d,y);return kk(a,S,c),S}}function Ej(e){if(e<bj)throw Error("sqrt is not defined for small field");let t=e-rr,r=0;while(t%Cs===gr)t/=Cs,r++;let o=Cs,n=cg(e);while(yj(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return _j;let i=n.pow(o,t),s=(t+rr)/Cs;return function(c,u){if(c.is0(u))return u;if(yj(c,u)!==1)throw Error("Cannot find square root");let d=r,f=c.mul(c.ONE,i),m=c.pow(u,t),h=c.pow(u,s);while(!c.eql(m,c.ONE)){if(c.is0(m))return c.ZERO;let b=1,y=c.sqr(m);while(!c.eql(y,c.ONE))if(b++,y=c.sqr(y),b===d)throw Error("Cannot find square root");let S=rr<<BigInt(d-b-1),x=c.pow(f,S);d=b,f=c.sqr(x),m=c.mul(m,f),h=c.mul(h,x)}return h}}function ose(e){if(e%Sj===bj)return _j;if(e%wj===vj)return rse;if(e%xj===tse)return nse(e);return Ej(e)}var ise=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ak(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=ise.reduce((o,n)=>(o[n]="function",o),t);return Os(e,r),e}function sse(e,t,r){if(r<gr)throw Error("invalid exponent, negatives unsupported");if(r===gr)return e.ONE;if(r===rr)return t;let o=e.ONE,n=t;while(r>gr){if(r&rr)o=e.mul(o,n);n=e.sqr(n),r>>=rr}return o}function md(e,t,r=!1){let o=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,c)=>{if(e.is0(a))return s;return o[c]=s,e.mul(s,a)},e.ONE),i=e.inv(n);return t.reduceRight((s,a,c)=>{if(e.is0(a))return s;return o[c]=e.mul(s,o[c]),e.mul(s,a)},i),o}function yj(e,t){let r=(e.ORDER-rr)/Cs,o=e.pow(t,r),n=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),s=e.eql(o,e.neg(e.ONE));if(!n&&!i&&!s)throw Error("invalid Legendre symbol result");return n?1:i?0:-1}function ase(e,t){if(t!==void 0)Bt(t);let r=t!==void 0?t:e.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class Ij{ORDER;BITS;BYTES;isLE;ZERO=gr;ONE=rr;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=gr)throw Error("invalid field: expected ORDER > 0, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")this.sqrt=t.sqrt;if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=t.allowedLengths?.slice();if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=ase(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return hr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return gr<=e&&e<this.ORDER}is0(e){return e===gr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&rr)===rr}neg(e){return hr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return hr(e*e,this.ORDER)}add(e,t){return hr(e+t,this.ORDER)}sub(e,t){return hr(e-t,this.ORDER)}mul(e,t){return hr(e*t,this.ORDER)}pow(e,t){return sse(this,e,t)}div(e,t){return hr(e*gj(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return gj(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=ose(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?dd(e,this.BYTES):Ac(e,this.BYTES)}fromBytes(e,t=!1){Te(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?Ei(e):_i(e);if(s)a=hr(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return md(this,e)}cmov(e,t,r){return r?t:e}}function cg(e,t={}){return new Ij(e,t)}function kj(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function Tk(e){let t=kj(e);return t+Math.ceil(t/2)}function Aj(e,t,r=!1){Te(e);let o=e.length,n=kj(t),i=Tk(t);if(o<16||o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?Ei(e):_i(e),a=hr(s,t-rr)+rr;return r?dd(a,n):Ac(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Tc=BigInt(0),Ps=BigInt(1);function hd(e,t){let r=t.negate();return e?r:t}function Ck(e,t){let r=md(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function Oj(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function $k(e,t){Oj(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=pd(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function Tj(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=Ps;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var Rk=new WeakMap,Cj=new WeakMap;function Ok(e){return Cj.get(e)||1}function $j(e){if(e!==Tc)throw Error("invalid wNAF")}class Pk{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Tc){if(t&Ps)r=r.add(o);o=o.double(),t>>=Ps}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=$k(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=$k(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:f,offsetF:m}=Tj(r,s,i);if(r=a,u)n=n.add(hd(f,t[m]));else o=o.add(hd(d,t[c]))}return $j(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=$k(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Tc)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=Tj(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return $j(r),o}getPrecomputes(e,t,r){let o=Rk.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);Rk.set(t,o)}}return o}cached(e,t,r){let o=Ok(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=Ok(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){Oj(t,this.bits),Cj.set(e,t),Rk.delete(e)}hasCache(e){return Ok(e)!==1}}function Pj(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Tc||o>Tc){if(r&Ps)i=i.add(n);if(o&Ps)s=s.add(n);n=n.double(),r>>=Ps,o>>=Ps}return{p1:i,p2:s}}function Rj(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return Ak(t),t}else return cg(e,{isLE:r})}function zj(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>Tc))throw Error(`CURVE.${c} must be positive bigint`)}let n=Rj(t.p,r.Fp,o),i=Rj(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function lg(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var gd=BigInt(0),$c=BigInt(1),ug=BigInt(2);function cse(e){return Os(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function Nj(e){let t=cse(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s||wi,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?ug**BigInt(254):ug**BigInt(447),b=a?BigInt(8)*ug**BigInt(251)-$c:BigInt(4)*ug**BigInt(445)-$c,y=h+b+$c,S=(I)=>hr(I,r),x=_(f);function _(I){return dd(S(I),d)}function A(I){let T=ag(Te(I,d,"uCoordinate"));if(a)T[31]&=127;return S(Ei(T))}function O(I){return Ei(n(ag(Te(I,d,"scalar"))))}function L(I,T){let k=ee(A(T),O(I));if(k===gd)throw Error("invalid private or public key received");return _(k)}function z(I){return L(I,x)}let K=z,P=L;function W(I,T,k){let M=S(I*(T-k));return T=S(T-M),k=S(k+M),{x_2:T,x_3:k}}function ee(I,T){fd("u",I,gd,r),fd("scalar",T,h,y);let k=T,M=I,N=$c,H=gd,G=I,re=$c,ae=gd;for(let be=BigInt(u-1);be>=gd;be--){let ve=k>>be&$c;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:H,x_3:re}=W(ae,H,re),ae=ve;let ke=N+H,Ie=S(ke*ke),we=N-H,Ue=S(we*we),De=Ie-Ue,Qe=G+re,St=G-re,Tt=S(St*ke),Nt=S(Qe*we),lt=Tt+Nt,$r=Tt-Nt;G=S(lt*lt),re=S(M*S($r*$r)),N=S(Ie*Ue),H=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:H,x_3:re}=W(ae,H,re);let pe=i(H);return S(N*pe)}let j={secretKey:d,publicKey:d,seed:d},R=(I=c(d))=>(Te(I,j.seed,"seed"),I),B={randomSecretKey:R};return Object.freeze({keygen:lg(R,K),getSharedSecret:P,getPublicKey:K,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}class zk{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(Vr(e),Te(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),Er(o)}update(e){return xo(this),this.iHash.update(e),this}digestInto(e){xo(this),Te(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Rc=(e,t,r)=>new zk(e,t).update(r).digest();Rc.create=(e,t)=>new zk(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Dj=(e,t)=>(e+(e>=0?t:-t)/Bj)/t;function lse(e,t,r){let[[o,n],[i,s]]=t,a=Dj(s*e,r),c=Dj(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,f=u<_o,m=d<_o;if(f)u=-u;if(m)d=-d;let h=pd(Math.ceil(Ek(r)/2))+Oc;if(u<_o||u>=h||d<_o||d>=h)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:m,k2:d}}function Dk(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function Nk(e,t){let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(ld(r.lowS,"lowS"),ld(r.prehash,"prehash"),r.format!==void 0)Dk(r.format);return r}class Lj extends Error{constructor(e=""){super(e)}}var ki={Err:Lj,_tlv:{encode:(e,t)=>{let{Err:r}=ki;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=ud(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?ud(n.length/2|128):"";return ud(e)+i+n+t},decode(e,t){let{Err:r}=ki,o=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=ki;if(e<_o)throw new t("integer: negative integers are not allowed");let r=ud(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=ki;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return _i(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=ki,n=Te(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=ki,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}},_o=BigInt(0),Oc=BigInt(1),Bj=BigInt(2),dg=BigInt(3),use=BigInt(4);function Lk(e,t={}){let r=zj("weierstrass",e,t),{Fp:o,Fn:n}=r,i=r.CURVE,{h:s,n:a}=i;Os(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=Zj(o,n);function d(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function f(R,B,I){let{x:T,y:k}=B.toAffine(),M=o.toBytes(T);if(ld(I,"isCompressed"),I){d();let N=!o.isOdd(k);return It(jj(N),M)}else return It(Uint8Array.of(4),M,o.toBytes(k))}function m(R){Te(R,void 0,"Point");let{publicKey:B,publicKeyUncompressed:I}=u,T=R.length,k=R[0],M=R.subarray(1);if(T===B&&(k===2||k===3)){let N=o.fromBytes(M);if(!o.isValid(N))throw Error("bad point: is not on curve, wrong x");let H=y(N),G;try{G=o.sqrt(H)}catch(pe){let be=pe instanceof Error?": "+pe.message:"";throw Error("bad point: is not on curve, sqrt error"+be)}d();let re=o.isOdd(G);if((k&1)===1!==re)G=o.neg(G);return{x:N,y:G}}else if(T===I&&k===4){let N=o.BYTES,H=o.fromBytes(M.subarray(0,N)),G=o.fromBytes(M.subarray(N,N*2));if(!S(H,G))throw Error("bad point: is not on curve");return{x:H,y:G}}else throw Error(`bad point: got length ${T}, expected compressed=${B} or uncompressed=${I}`)}let h=t.toBytes||f,b=t.fromBytes||m;function y(R){let B=o.sqr(R),I=o.mul(B,R);return o.add(o.add(I,o.mul(R,i.a)),i.b)}function S(R,B){let I=o.sqr(B),T=y(R);return o.eql(I,T)}if(!S(i.Gx,i.Gy))throw Error("bad curve params: generator point");let x=o.mul(o.pow(i.a,dg),use),_=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(x,_)))throw Error("bad curve params: a or b");function A(R,B,I=!1){if(!o.isValid(B)||I&&o.is0(B))throw Error(`bad point coordinate ${R}`);return B}function O(R){if(!(R instanceof W))throw Error("Weierstrass Point expected")}function L(R){if(!c||!c.basises)throw Error("no endo");return lse(R,c.basises,n.ORDER)}let z=Ik((R,B)=>{let{X:I,Y:T,Z:k}=R;if(o.eql(k,o.ONE))return{x:I,y:T};let M=R.is0();if(B==null)B=M?o.ONE:o.inv(k);let N=o.mul(I,B),H=o.mul(T,B),G=o.mul(k,B);if(M)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:H}}),K=Ik((R)=>{if(R.is0()){if(t.allowInfinityPoint&&!o.is0(R.Y))return;throw Error("bad point: ZERO")}let{x:B,y:I}=R.toAffine();if(!o.isValid(B)||!o.isValid(I))throw Error("bad point: x or y not field elements");if(!S(B,I))throw Error("bad point: equation left != right");if(!R.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function P(R,B,I,T,k){return I=new W(o.mul(I.X,R),I.Y,I.Z),B=hd(T,B),I=hd(k,I),B.add(I)}class W{static BASE=new W(i.Gx,i.Gy,o.ONE);static ZERO=new W(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(R,B,I){this.X=A("x",R),this.Y=A("y",B,!0),this.Z=A("z",I),Object.freeze(this)}static CURVE(){return i}static fromAffine(R){let{x:B,y:I}=R||{};if(!R||!o.isValid(B)||!o.isValid(I))throw Error("invalid affine point");if(R instanceof W)throw Error("projective point not allowed");if(o.is0(B)&&o.is0(I))return W.ZERO;return new W(B,I,o.ONE)}static fromBytes(R){let B=W.fromAffine(b(Te(R,void 0,"point")));return B.assertValidity(),B}static fromHex(R){return W.fromBytes(Rs(R))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(R=8,B=!0){if(j.createCache(this,R),!B)this.multiply(dg);return this}assertValidity(){K(this)}hasEvenY(){let{y:R}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(R)}equals(R){O(R);let{X:B,Y:I,Z:T}=this,{X:k,Y:M,Z:N}=R,H=o.eql(o.mul(B,N),o.mul(k,T)),G=o.eql(o.mul(I,N),o.mul(M,T));return H&&G}negate(){return new W(this.X,o.neg(this.Y),this.Z)}double(){let{a:R,b:B}=i,I=o.mul(B,dg),{X:T,Y:k,Z:M}=this,N=o.ZERO,H=o.ZERO,G=o.ZERO,re=o.mul(T,T),ae=o.mul(k,k),pe=o.mul(M,M),be=o.mul(T,k);return be=o.add(be,be),G=o.mul(T,M),G=o.add(G,G),N=o.mul(R,G),H=o.mul(I,pe),H=o.add(N,H),N=o.sub(ae,H),H=o.add(ae,H),H=o.mul(N,H),N=o.mul(be,N),G=o.mul(I,G),pe=o.mul(R,pe),be=o.sub(re,pe),be=o.mul(R,be),be=o.add(be,G),G=o.add(re,re),re=o.add(G,re),re=o.add(re,pe),re=o.mul(re,be),H=o.add(H,re),pe=o.mul(k,M),pe=o.add(pe,pe),re=o.mul(pe,be),N=o.sub(N,re),G=o.mul(pe,ae),G=o.add(G,G),G=o.add(G,G),new W(N,H,G)}add(R){O(R);let{X:B,Y:I,Z:T}=this,{X:k,Y:M,Z:N}=R,H=o.ZERO,G=o.ZERO,re=o.ZERO,ae=i.a,pe=o.mul(i.b,dg),be=o.mul(B,k),ve=o.mul(I,M),ke=o.mul(T,N),Ie=o.add(B,I),we=o.add(k,M);Ie=o.mul(Ie,we),we=o.add(be,ve),Ie=o.sub(Ie,we),we=o.add(B,T);let Ue=o.add(k,N);return we=o.mul(we,Ue),Ue=o.add(be,ke),we=o.sub(we,Ue),Ue=o.add(I,T),H=o.add(M,N),Ue=o.mul(Ue,H),H=o.add(ve,ke),Ue=o.sub(Ue,H),re=o.mul(ae,we),H=o.mul(pe,ke),re=o.add(H,re),H=o.sub(ve,re),re=o.add(ve,re),G=o.mul(H,re),ve=o.add(be,be),ve=o.add(ve,be),ke=o.mul(ae,ke),we=o.mul(pe,we),ve=o.add(ve,ke),ke=o.sub(be,ke),ke=o.mul(ae,ke),we=o.add(we,ke),be=o.mul(ve,we),G=o.add(G,be),be=o.mul(Ue,we),H=o.mul(Ie,H),H=o.sub(H,be),be=o.mul(Ie,ve),re=o.mul(Ue,re),re=o.add(re,be),new W(H,G,re)}subtract(R){return this.add(R.negate())}is0(){return this.equals(W.ZERO)}multiply(R){let{endo:B}=t;if(!n.isValidNot0(R))throw Error("invalid scalar: out of range");let I,T,k=(M)=>j.cached(this,M,(N)=>Ck(W,N));if(B){let{k1neg:M,k1:N,k2neg:H,k2:G}=L(R),{p:re,f:ae}=k(N),{p:pe,f:be}=k(G);T=ae.add(be),I=P(B.beta,re,pe,M,H)}else{let{p:M,f:N}=k(R);I=M,T=N}return Ck(W,[I,T])[0]}multiplyUnsafe(R){let{endo:B}=t,I=this;if(!n.isValid(R))throw Error("invalid scalar: out of range");if(R===_o||I.is0())return W.ZERO;if(R===Oc)return I;if(j.hasCache(this))return this.multiply(R);if(B){let{k1neg:T,k1:k,k2neg:M,k2:N}=L(R),{p1:H,p2:G}=Pj(W,I,k,N);return P(B.beta,H,G,T,M)}else return j.unsafe(I,R)}toAffine(R){return z(this,R)}isTorsionFree(){let{isTorsionFree:R}=t;if(s===Oc)return!0;if(R)return R(W,this);return j.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:R}=t;if(s===Oc)return this;if(R)return R(W,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(R=!0){return ld(R,"isCompressed"),this.assertValidity(),h(W,this,R)}toHex(R=!0){return $s(this.toBytes(R))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ee=n.BITS,j=new Pk(W,t.endo?Math.ceil(ee/2):ee);return W.BASE.precompute(8),W}function jj(e){return Uint8Array.of(e?2:3)}function Zj(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function dse(e,t={}){let{Fn:r}=e,o=t.randomBytes||wi,n=Object.assign(Zj(e.Fp,r),{seed:Tk(r.ORDER)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h=o(n.seed)){return Aj(Te(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n;if(!Ic(h))return;if("_lengths"in r&&r._lengths||b===y)return;let x=Te(h,void 0,"key").length;return x===y||x===S}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=lg(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function Bk(e,t,r={}){Vr(t),Os(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes||wi,n=r.hmac||((I,T)=>Rc(t,I,T)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h}=dse(e,r),b={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=a*Bj<i.ORDER;function S(I){let T=a>>Oc;return I>T}function x(I,T){if(!s.isValidNot0(T))throw Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return T}function _(){if(y)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function A(I,T){Dk(T);let k=h.signature,M=T==="compact"?k:T==="recovered"?k+1:void 0;return Te(I,M)}class O{r;s;recovery;constructor(I,T,k){if(this.r=x("r",I),this.s=x("s",T),k!=null){if(_(),![0,1,2,3].includes(k))throw Error("invalid recovery id");this.recovery=k}Object.freeze(this)}static fromBytes(I,T=b.format){A(I,T);let k;if(T==="der"){let{r:G,s:re}=ki.toSig(Te(I));return new O(G,re)}if(T==="recovered")k=I[0],T="compact",I=I.subarray(1);let M=h.signature/2,N=I.subarray(0,M),H=I.subarray(M,M*2);return new O(s.fromBytes(N),s.fromBytes(H),k)}static fromHex(I,T){return this.fromBytes(Rs(I),T)}assertRecovery(){let{recovery:I}=this;if(I==null)throw Error("invalid recovery id: must be present");return I}addRecoveryBit(I){return new O(this.r,this.s,I)}recoverPublicKey(I){let{r:T,s:k}=this,M=this.assertRecovery(),N=M===2||M===3?T+a:T;if(!i.isValid(N))throw Error("invalid recovery id: sig.r+curve.n != R.x");let H=i.toBytes(N),G=e.fromBytes(It(jj((M&1)===0),H)),re=s.inv(N),ae=z(Te(I,void 0,"msgHash")),pe=s.create(-ae*re),be=s.create(k*re),ve=e.BASE.multiplyUnsafe(pe).add(G.multiplyUnsafe(be));if(ve.is0())throw Error("invalid recovery: point at infinify");return ve.assertValidity(),ve}hasHighS(){return S(this.s)}toBytes(I=b.format){if(Dk(I),I==="der")return Rs(ki.hexFromSig(this));let{r:T,s:k}=this,M=s.toBytes(T),N=s.toBytes(k);if(I==="recovered")return _(),It(Uint8Array.of(this.assertRecovery()),M,N);return It(M,N)}toHex(I){return $s(this.toBytes(I))}}let L=r.bits2int||function(T){if(T.length>8192)throw Error("input is too large");let k=_i(T),M=T.length*8-c;return M>0?k>>BigInt(M):k},z=r.bits2int_modN||function(T){return s.create(L(T))},K=pd(c);function P(I){return fd("num < 2^"+c,I,_o,K),s.toBytes(I)}function W(I,T){return Te(I,void 0,"message"),T?Te(t(I),void 0,"prehashed message"):I}function ee(I,T,k){let{lowS:M,prehash:N,extraEntropy:H}=Nk(k,b);I=W(I,N);let G=z(I),re=s.fromBytes(T);if(!s.isValidNot0(re))throw Error("invalid private key");let ae=[P(re),P(G)];if(H!=null&&H!==!1){let ke=H===!0?o(h.secretKey):H;ae.push(Te(ke,void 0,"extraEntropy"))}let pe=It(...ae),be=G;function ve(ke){let Ie=L(ke);if(!s.isValidNot0(Ie))return;let we=s.inv(Ie),Ue=e.BASE.multiply(Ie).toAffine(),De=s.create(Ue.x);if(De===_o)return;let Qe=s.create(we*s.create(be+De*re));if(Qe===_o)return;let St=(Ue.x===De?0:2)|Number(Ue.y&Oc),Tt=Qe;if(M&&S(Qe))Tt=s.neg(Qe),St^=1;return new O(De,Tt,y?void 0:St)}return{seed:pe,k2sig:ve}}function j(I,T,k={}){let{seed:M,k2sig:N}=ee(I,T,k);return hj(t.outputLen,s.BYTES,n)(M,N).toBytes(k.format)}function R(I,T,k,M={}){let{lowS:N,prehash:H,format:G}=Nk(M,b);if(k=Te(k,void 0,"publicKey"),T=W(T,H),!Ic(I)){let re=I instanceof O?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+re)}A(I,G);try{let re=O.fromBytes(I,G),ae=e.fromBytes(k);if(N&&re.hasHighS())return!1;let{r:pe,s:be}=re,ve=z(T),ke=s.inv(be),Ie=s.create(ve*ke),we=s.create(pe*ke),Ue=e.BASE.multiplyUnsafe(Ie).add(ae.multiplyUnsafe(we));if(Ue.is0())return!1;return s.create(Ue.x)===pe}catch(re){return!1}}function B(I,T,k={}){let{prehash:M}=Nk(k,b);return T=W(T,M),O.fromBytes(I,"recovered").recoverPublicKey(T).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h,Point:e,sign:j,verify:R,recoverPublicKey:B,Signature:O,hash:t})}function Uj(e,t,r){return e&t^~e&r}function qj(e,t,r){return e&t^e&r^t&r}class fg{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ig(this.buffer)}update(e){xo(this),Te(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=ig(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){xo(this),ng(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,Er(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=ig(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var Eo=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Ht=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var pg=BigInt(4294967295),Mj=BigInt(32);function fse(e,t=!1){if(t)return{h:Number(e&pg),l:Number(e>>Mj&pg)};return{h:Number(e>>Mj&pg)|0,l:Number(e&pg)|0}}function mg(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=fse(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var jk=(e,t,r)=>e>>>r,Zk=(e,t,r)=>e<<32-r|t>>>r,zs=(e,t,r)=>e>>>r|t<<32-r,Ns=(e,t,r)=>e<<32-r|t>>>r,yd=(e,t,r)=>e<<64-r|t>>>r-32,bd=(e,t,r)=>e>>>r-32|t<<64-r;var Fj=(e,t,r)=>e<<r|t>>>32-r,Jj=(e,t,r)=>t<<r|e>>>32-r,Kj=(e,t,r)=>t<<r-32|e>>>64-r,Hj=(e,t,r)=>e<<r-32|t>>>64-r;function Un(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var Vj=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Wj=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,Gj=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),Qj=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,Yj=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),Xj=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var mse=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ai=new Uint32Array(64);class eZ extends fg{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)Ai[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=Ai[d-15],m=Ai[d-2],h=pn(f,7)^pn(f,18)^f>>>3,b=pn(m,17)^pn(m,19)^m>>>10;Ai[d]=b+Ai[d-7]+h+Ai[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let f=pn(s,6)^pn(s,11)^pn(s,25),m=u+f+Uj(s,a,c)+mse[d]+Ai[d]|0,b=(pn(r,2)^pn(r,13)^pn(r,22))+qj(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){Er(Ai)}destroy(){this.set(0,0,0,0,0,0,0,0),Er(this.buffer)}}class tZ extends eZ{A=Eo[0]|0;B=Eo[1]|0;C=Eo[2]|0;D=Eo[3]|0;E=Eo[4]|0;F=Eo[5]|0;G=Eo[6]|0;H=Eo[7]|0;constructor(){super(32)}}var rZ=(()=>mg(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e)=>BigInt(e))))(),hse=(()=>rZ[0])(),gse=(()=>rZ[1])(),Ti=new Uint32Array(80),$i=new Uint32Array(80);class nZ extends fg{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)Ti[_]=e.getUint32(t),$i[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=Ti[_-15]|0,O=$i[_-15]|0,L=zs(A,O,1)^zs(A,O,8)^jk(A,O,7),z=Ns(A,O,1)^Ns(A,O,8)^Zk(A,O,7),K=Ti[_-2]|0,P=$i[_-2]|0,W=zs(K,P,19)^yd(K,P,61)^jk(K,P,6),ee=Ns(K,P,19)^bd(K,P,61)^Zk(K,P,6),j=Gj(z,ee,$i[_-7],$i[_-16]),R=Qj(j,L,W,Ti[_-7],Ti[_-16]);Ti[_]=R|0,$i[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=zs(d,f,14)^zs(d,f,18)^yd(d,f,41),O=Ns(d,f,14)^Ns(d,f,18)^bd(d,f,41),L=d&m^~d&b,z=f&h^~f&y,K=Yj(x,O,z,gse[_],$i[_]),P=Xj(K,S,A,L,hse[_],Ti[_]),W=K|0,ee=zs(r,o,28)^yd(r,o,34)^yd(r,o,39),j=Ns(r,o,28)^bd(r,o,34)^bd(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=Un(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let I=Vj(W,j,B);r=Wj(I,P,ee,R),o=I|0}({h:r,l:o}=Un(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=Un(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=Un(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=Un(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:f}=Un(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=Un(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=Un(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=Un(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,f,m,h,b,y,S,x)}roundClean(){Er(Ti,$i)}destroy(){Er(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class oZ extends nZ{Ah=Ht[0]|0;Al=Ht[1]|0;Bh=Ht[2]|0;Bl=Ht[3]|0;Ch=Ht[4]|0;Cl=Ht[5]|0;Dh=Ht[6]|0;Dl=Ht[7]|0;Eh=Ht[8]|0;El=Ht[9]|0;Fh=Ht[10]|0;Fl=Ht[11]|0;Gh=Ht[12]|0;Gl=Ht[13]|0;Hh=Ht[14]|0;Hl=Ht[15]|0;constructor(){super(48)}}var hg=kc(()=>new tZ,xi(1));var iZ=kc(()=>new oZ,xi(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var yse=BigInt(1),sZ=BigInt(2),bse=BigInt(3),Sse=BigInt(5),W$e=BigInt(8),aZ=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function vse(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=aZ,a=e*e%i*e%i,c=Wr(a,sZ,i)*a%i,u=Wr(c,yse,i)*e%i,d=Wr(u,Sse,i)*u%i,f=Wr(d,t,i)*d%i,m=Wr(f,r,i)*f%i,h=Wr(m,o,i)*m%i,b=Wr(h,n,i)*h%i,y=Wr(b,n,i)*h%i,S=Wr(y,t,i)*d%i;return{pow_p_5_8:Wr(S,sZ,i)*e%i,b2:a}}function wse(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var cZ=(()=>{let e=aZ;return Nj({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=vse(t);return hr(Wr(r,bse,e)*o,e)},adjustScalarBytes:wse})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var xse=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),_se=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var Ese=Lk(xse),Uk=Bk(Ese,hg);var Ise=Lk(_se),lZ=Bk(Ise,iZ);function dZ(e,t,r){if(Vr(e),r===void 0)r=new Uint8Array(e.outputLen);return Rc(e,r,t)}var qk=Uint8Array.of(0),uZ=Uint8Array.of();function fZ(e,t,r,o=32){Vr(e),Bt(o,"length");let n=e.outputLen;if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=uZ;else Te(r,void 0,"info");let s=new Uint8Array(i*n),a=Rc.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)qk[0]=d+1,c.update(d===0?uZ:u).update(r).update(qk).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),Er(u,qk),s.slice(0,o)}var kse=BigInt(0),Sd=BigInt(1),Ase=BigInt(2),Tse=BigInt(7),$se=BigInt(256),Rse=BigInt(113),hZ=[],gZ=[],yZ=[];for(let e=0,t=Sd,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],hZ.push(2*(5*o+r)),gZ.push((e+1)*(e+2)/2%64);let n=kse;for(let i=0;i<7;i++)if(t=(t<<Sd^(t>>Tse)*Rse)%$se,t&Ase)n^=Sd<<(Sd<<BigInt(i))-Sd;yZ.push(n)}var bZ=mg(yZ,!0),Ose=bZ[0],Cse=bZ[1],pZ=(e,t,r)=>r>32?Kj(e,t,r):Fj(e,t,r),mZ=(e,t,r)=>r>32?Hj(e,t,r):Jj(e,t,r);function Pse(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let s=0;s<10;s++)r[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,u=r[c],d=r[c+1],f=pZ(u,d,1)^r[a],m=mZ(u,d,1)^r[a+1];for(let h=0;h<50;h+=10)e[s+h]^=f,e[s+h+1]^=m}let n=e[2],i=e[3];for(let s=0;s<24;s++){let a=gZ[s],c=pZ(n,i,a),u=mZ(n,i,a),d=hZ[s];n=e[d],i=e[d+1],e[d]=c,e[d+1]=u}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)r[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=Ose[o],e[1]^=Cse[o]}Er(r)}class gg{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,o=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=o,this.rounds=n,Bt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=og(this.state)}clone(){return this._cloneInto()}keccak(){wk(this.state32),Pse(this.state32,this.rounds),wk(this.state32),this.posOut=0,this.pos=0}update(e){xo(this),Te(e);let{blockLen:t,state:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(t-this.pos,o-n);for(let s=0;s<i;s++)r[this.pos++]^=e[n++];if(this.pos===t)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:o}=this;if(e[r]^=t,(t&128)!==0&&r===o-1)this.keccak();e[o-1]^=128,this.keccak()}writeInto(e){xo(this,!1),Te(e),this.finish();let t=this.state,{blockLen:r}=this;for(let o=0,n=e.length;o<n;){if(this.posOut>=r)this.keccak();let i=Math.min(r-this.posOut,n-o);e.set(t.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Bt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ng(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Er(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:o,rounds:n,enableXOF:i}=this;return e||=new gg(t,r,o,i,n),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}}var SZ=(e,t,r,o={})=>kc(()=>new gg(t,e,r),o);var Ds=SZ(6,136,32,xi(8));var vZ=SZ(6,72,64,xi(10));var wZ=(e,t,r,o={})=>kc((n={})=>new gg(t,e,n.dkLen===void 0?r:n.dkLen,!0),o),xZ=wZ(31,168,16,xi(11)),qn=wZ(31,136,32,xi(12));function Mk(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function EZ(e){return Mk(e),(e&e-1)===0&&e!==0}function Fk(e,t){Mk(e);let r=0;for(let o=0;o<t;o++,e>>>=1)r=r<<1|e&1;return r}function IZ(e){return Mk(e),31-Math.clz32(e)}function _Z(e){let t=e.length;if(t<2||!EZ(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=IZ(t);for(let o=0;o<t;o++){let n=Fk(o,r);if(o<n){let i=e[o];e[o]=e[n],e[n]=i}}return e}var Jk=(e,t)=>{let{N:r,roots:o,dit:n,invertButterflies:i=!1,skipStages:s=0,brp:a=!0}=t,c=IZ(r);if(!EZ(r))throw Error("FFT: Polynomial size should be power of two");let u=n!==i;return(d)=>{if(d.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)_Z(d);for(let f=0,m=1;f<c-s;f++){let h=n?f+1+s:c-f,b=1<<h,y=b>>1,S=r>>h;for(let x=0;x<r;x+=b)for(let _=0,A=m++;_<y;_++){let O=i?n?r-A:A:_*S,L=x+_,z=x+_+y,K=o[O],P=d[z],W=d[L];if(u){let ee=e.mul(P,K);d[L]=e.add(W,ee),d[z]=e.sub(W,ee)}else if(i)d[L]=e.add(P,W),d[z]=e.mul(e.sub(P,W),K);else d[L]=e.add(W,P),d[z]=e.mul(e.sub(W,P),K)}}if(!n&&a)_Z(d);return d}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var Mn=wi;function yg(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function kZ(e){return Uint8Array.from(e)}function Ls(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,o=t.reduce((n,i)=>n+r(i),0);return{bytesLen:o,encode:(n)=>{let i=new Uint8Array(o);for(let s=0,a=0;s<t.length;s++){let c=t[s],u=r(c),d=typeof c==="number"?n[s]:c.encode(n[s]);if(Te(d,u,e),i.set(d,a),typeof c!=="number")d.fill(0);a+=u}return i},decode:(n)=>{Te(n,o,e);let i=[];for(let s of t){let a=r(s),c=n.subarray(0,a);i.push(typeof s==="number"?c:s.decode(c)),n=n.subarray(a)}return i}}}function bg(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(o)=>{if(o.length!==t)throw Error(`vecCoder.encode: wrong length=${o.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let i=0,s=0;i<o.length;i++){let a=e.encode(o[i]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(o)=>{Te(o,r);let n=[];for(let i=0;i<o.length;i+=e.bytesLen)n.push(e.decode(o.subarray(i,i+e.bytesLen)));return n}}}function Ct(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function Kk(e){return(1<<e)-1}var uRe=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var AZ=(e)=>{let{newPoly:t,N:r,Q:o,F:n,ROOT_OF_UNITY:i,brvBits:s,isKyber:a}=e,c=(_,A=o)=>{let O=_%A|0;return(O>=0?O|0:A+O|0)|0},u=(_,A=o)=>{let O=c(_,A)|0;return(O>A>>1?O-A|0:O)|0};function d(){let _=t(r);for(let A=0;A<r;A++){let O=Fk(A,s),L=BigInt(i)**BigInt(O)%BigInt(o);_[A]=Number(L)|0}return _}let f=d(),m={add:(_,A)=>c((_|0)+(A|0))|0,sub:(_,A)=>c((_|0)-(A|0))|0,mul:(_,A)=>c((_|0)*(A|0))|0,inv:(_)=>{throw Error("not implemented")}},h={N:r,roots:f,invertButterflies:!0,skipStages:a?1:0,brp:!1},b=Jk(m,{dit:!1,...h}),y=Jk(m,{dit:!0,...h});return{mod:c,smod:u,nttZetas:f,NTT:{encode:(_)=>b(_),decode:(_)=>{y(_);for(let A=0;A<_.length;A++)_[A]=c(n*_[A]);return _}},bitsCoder:(_,A)=>{let O=Kk(_),L=_*(r/8);return{bytesLen:L,encode:(z)=>{let K=new Uint8Array(L);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=(A.encode(z[P])&O)<<ee,ee+=_;for(;ee>=8;ee-=8,W>>=8)K[j++]=W&Kk(ee)}return K},decode:(z)=>{let K=t(r);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=z[P]<<ee,ee+=8;for(;ee>=_;ee-=_,W>>=_)K[j++]=A.decode(W&O)}return K}}}}},zse=(e)=>(t,r)=>{if(!r)r=e.blockLen;let o=new Uint8Array(t.length+2);o.set(t);let n=t.length,i=new Uint8Array(r),s=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(u,d)=>(o[n+0]=u,o[n+1]=d,s.destroy(),s=e.create({}).update(o),a++,()=>(c++,s.xofInto(i))),clean:()=>{s.destroy(),Ct(i,o)}}},TZ=zse(xZ);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var nr=256,Io=3329,Nse=3303,Dse=17,{mod:xd,nttZetas:Lse,NTT:Bs,bitsCoder:Bse}=AZ({N:nr,Q:Io,F:Nse,ROOT_OF_UNITY:Dse,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),Hk={512:{N:nr,Q:Io,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:nr,Q:Io,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:nr,Q:Io,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},jse=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Io/2)/Io,decode:(r)=>r*Io+t>>>e}},vd=(e)=>Bse(e,jse(e));function js(e,t){for(let r=0;r<nr;r++)e[r]=xd(e[r]+t[r])}function Zse(e,t){for(let r=0;r<nr;r++)e[r]=xd(e[r]-t[r])}function Use(e,t,r,o,n){let i=xd(t*o*n+e*r),s=xd(e*o+t*r);return{c0:i,c1:s}}function Sg(e,t){for(let r=0;r<nr/2;r++){let o=Lse[64+(r>>1)];if(r&1)o=-o;let{c0:n,c1:i}=Use(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],o);e[2*r+0]=n,e[2*r+1]=i}return e}function $Z(e){let t=new Uint16Array(nr);for(let r=0;r<nr;){let o=e();if(o.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<nr&&n+3<=o.length;n+=3){let i=(o[n+0]>>0|o[n+1]<<8)&4095,s=(o[n+1]>>4|o[n+2]<<4)&4095;if(i<Io)t[r++]=i;if(r<nr&&s<Io)t[r++]=s}}return t}function wd(e,t,r,o){let n=e(o*nr/4,t,r),i=new Uint16Array(nr),s=og(n),a=0;for(let c=0,u=0,d=0,f=0;c<s.length;c++){let m=s[c];for(let h=0;h<32;h++)if(d+=m&1,m>>=1,a+=1,a===o)f=d,d=0;else if(a===2*o)i[u++]=xd(f-d),d=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return i}var qse=(e)=>{let{K:t,PRF:r,XOF:o,HASH512:n,ETA1:i,ETA2:s,du:a,dv:c}=e,u=vd(1),d=vd(c),f=vd(a),m=Ls("publicKey",bg(vd(12),t),32),h=bg(vd(12),t),b=Ls("ciphertext",bg(f,t),d),y=Ls("seed",32,32);return{secretCoder:h,lengths:{secretKey:h.bytesLen,publicKey:m.bytesLen,cipherText:b.bytesLen},keygen:(S)=>{Te(S,32,"seed");let x=new Uint8Array(33);x.set(S),x[32]=t;let _=n(x),[A,O]=y.decode(_),L=[],z=[];for(let W=0;W<t;W++)L.push(Bs.encode(wd(r,O,W,i)));let K=o(A);for(let W=0;W<t;W++){let ee=Bs.encode(wd(r,O,t+W,i));for(let j=0;j<t;j++){let R=$Z(K.get(j,W));js(ee,Sg(R,L[j]))}z.push(ee)}K.clean();let P={publicKey:m.encode([z,A]),secretKey:h.encode(L)};return Ct(A,O,L,z,x,_),P},encrypt:(S,x,_)=>{let[A,O]=m.decode(S),L=[];for(let j=0;j<t;j++)L.push(Bs.encode(wd(r,_,j,i)));let z=o(O),K=new Uint16Array(nr),P=[];for(let j=0;j<t;j++){let R=wd(r,_,t+j,s),B=new Uint16Array(nr);for(let I=0;I<t;I++){let T=$Z(z.get(j,I));js(B,Sg(T,L[I]))}js(R,Bs.decode(B)),P.push(R),js(K,Sg(A[j],L[j])),Ct(B)}z.clean();let W=wd(r,_,2*t,s);js(W,Bs.decode(K));let ee=u.decode(x);return js(ee,W),Ct(A,L,K,W),b.encode([P,ee])},decrypt:(S,x)=>{let[_,A]=b.decode(S),O=h.decode(x),L=new Uint16Array(nr);for(let z=0;z<t;z++)js(L,Sg(O[z],Bs.encode(_[z])));return Zse(A,Bs.decode(L)),Ct(L,O,_),u.encode(A)}}};function Vk(e){let t=qse(e),{HASH256:r,HASH512:o,KDF:n}=e,{secretCoder:i,lengths:s}=t,a=Ls("secretKey",s.secretKey,s.publicKey,32,32),c=32,u=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(d=Mn(64))=>{Te(d,64,"seed");let{publicKey:f,secretKey:m}=t.keygen(d.subarray(0,32)),h=r(f),b=a.encode([m,f,h,d.subarray(32)]);return Ct(m,h),{publicKey:f,secretKey:b}},getPublicKey:(d)=>{let[f,m,h,b]=a.decode(d);return Uint8Array.from(m)},encapsulate:(d,f=Mn(32))=>{Te(d,s.publicKey,"publicKey"),Te(f,32,"message");let m=d.subarray(0,384*e.K),h=i.encode(i.decode(kZ(m)));if(!yg(h,m))throw Ct(h),Error("ML-KEM.encapsulate: wrong publicKey modulus");Ct(h);let b=o.create().update(f).update(r(d)).digest(),y=t.encrypt(d,f,b.subarray(32,64));return Ct(b.subarray(32)),{cipherText:y,sharedSecret:b.subarray(0,32)}},decapsulate:(d,f)=>{Te(f,a.bytesLen,"secretKey"),Te(d,s.cipherText,"cipherText");let m=a.bytesLen-96,h=m+32,b=r(f.subarray(m/2,h));if(!yg(b,f.subarray(h,h+32)))throw Error("invalid secretKey: hash check failed");let[y,S,x,_]=a.decode(f),A=t.decrypt(d,y),O=o.create().update(A).update(x).digest(),L=O.subarray(0,32),z=t.encrypt(S,A,O.subarray(32,64)),K=yg(d,z),P=n.create({dkLen:32}).update(_).update(d).digest();return Ct(A,z,!K?L:P),K?L:P}}}function Mse(e,t,r){return qn.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var Wk={HASH256:Ds,HASH512:vZ,KDF:qn,XOF:TZ,PRF:Mse},wRe=Vk({...Wk,...Hk[512]}),_d=Vk({...Wk,...Hk[768]}),RZ=Vk({...Wk,...Hk[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function Fse(e,t=!1){let{lengths:r,keygen:o}=e;if(t){let i=e.Point.Fn;if(!i)throw Error("No Point.Fn");o=(s=Mn(r.seed))=>{Te(s,r.seed,"seed");let a=i.isLE?Ei(s):_i(s),c=i.toBytes(i.create(a));return{secretKey:c,publicKey:e.getPublicKey(c)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:o,getPublicKey:(n)=>e.getPublicKey(n)}}function Gk(e,t=!1){let r=Fse(e,t);if(!e.getSharedSecret)throw Error("wrong curve");return{lengths:{...r.lengths,msg:r.lengths.seed,cipherText:r.lengths.publicKey},keygen:r.keygen,getPublicKey:r.getPublicKey,encapsulate(o,n=Mn(e.lengths.seed)){let i=this.keygen(n).secretKey,s=this.decapsulate(o,i),a=e.getPublicKey(i);return Ct(i),{sharedSecret:s,cipherText:a}},decapsulate(o,n){let i=e.getSharedSecret(n,o);return e.lengths.publicKeyHasPrefix?i.subarray(1):i}}}function Ed(e,t){return Ls(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function Qk(e){return(t,r)=>e(t,{dkLen:r})}function Jse(e,t,...r){let o=Ed(r,"seed"),n=Ed(r,"publicKey");if(e===void 0)e=o.bytesLen;Bt(e);function i(s){Te(s,e);let a=o.decode(t(s,o.bytesLen)),c=r.map((f,m)=>f.keygen(a[m])),u=c.map((f)=>f.secretKey),d=c.map((f)=>f.publicKey);return{secretKey:u,publicKey:d}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=Mn(e)){let{publicKey:a,secretKey:c}=i(s),u=n.encode(a);return Ct(a),Ct(c),{secretKey:s,publicKey:u}},expandDecapsulationKey:i,realSeedLen:e}}function vg(e,t,r,o,...n){let i=Jse(e,r,...n),s=Ed(n,"cipherText"),a=Ed(n,"publicKey"),c=Ed(n,"msg");if(t===void 0)t=c.bytesLen;return Bt(t),{lengths:{...i.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:i.getPublicKey,keygen:i.keygen,encapsulate(u,d=Mn(c.bytesLen)){let f=a.decode(u),m=c.decode(d),h=n.map((x,_)=>x.encapsulate(f[_],m[_])),b=h.map((x)=>x.sharedSecret),y=h.map((x)=>x.cipherText),S={sharedSecret:o(f,y,b),cipherText:s.encode(y)};return Ct(b,y),S},decapsulate(u,d){let f=s.decode(u),{publicKey:m,secretKey:h}=i.expandDecapsulationKey(d),b=n.map((y,S)=>y.decapsulate(f[S],h[S]));return o(m,f,b)}}}function OZ(e,t,r,o,n){return Vr(o),Vr(n),vg(32,32,Qk(o),(i,s,a)=>n(It(a[0],a[1],s[1],i[1],Ii(e))),t,r)}var CRe=OZ("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",_d,Gk(Uk,!0),qn,Ds),PRe=OZ("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",RZ,Gk(lZ,!0),qn,Ds);function Kse(e,t,r,o,n){return Vr(o),Vr(n),vg(32,32,Qk(o),(i,s,a)=>{let c=It(a[0],a[1],s[0],i[0],s[1],i[1],Ii(e)),u=32,d=It(Ii("hybrid_prk"),c),f=dZ(n,d),m=It(Ac(32,2),Ii("shared_secret"),Ii("")),h=fZ(n,f,m,32);return Ct(f,m,d,c),h},t,r)}var CZ=Gk(cZ),zRe=Kse("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",_d,CZ,qn,hg),Hse=(()=>vg(32,32,Qk(qn),(e,t,r)=>Ds(It(r[0],r[1],t[1],e[1],Ii("\\.//^\\"))),_d,CZ))();function Vse(e,t,r,o){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function i(s){let a;for(let d=0,f=t;;d=f,f+=t){if(f>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(d,f),!0),n.isValidNot0(a))break}let c=n.toBytes(n.create(a)),u=e.getPublicKey(c,!1);return{secretKey:c,publicKey:u}}return{lengths:{secretKey:t,publicKey:r,seed:o,msg:o,cipherText:r},keygen(s=Mn(o)){return Te(s,o,"seed"),i(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=Mn(o)){Te(a,o,"rand");let{secretKey:c}=i(a),u=this.decapsulate(s,c),d=e.getPublicKey(c,!1);return Ct(c),{sharedSecret:u,cipherText:d}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function Wse(e,t,r,o){let{secretKey:n,publicKeyUncompressed:i}=r.lengths;if(!n||!i)throw Error("wrong curve");let s=Vse(r,n,i,o),a=64,c=a+o;return vg(32,32,(u)=>{Te(u,32);let d=qn(u,{dkLen:c}),f=d.subarray(0,a),m=d.subarray(a,c);return It(f,m)},(u,d,f)=>Ds(It(f[0],f[1],d[1],u[1],Ii(e))),t,s)}var Gse=(()=>Wse("MLKEM768-P256",_d,Uk,128))();var wg=Hse,PZ=Gse;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var et=(e,t,r)=>Ft(e,t,r),Xk=vt,Cc=Jh,Vt=(...e)=>rk(...e),Pc=(e)=>td(e),zc=XI,Nc=(e)=>bo(e),_g=BigInt(0),Yk=BigInt(1);function ko(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function Eg(e){if(typeof e==="bigint"){if(!xg(e))throw RangeError("positive bigint expected, got "+e)}else Xk(e);return e}function Fn(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw RangeError(r+"expected safe integer, got "+e)}}function Id(e){let t=Eg(e).toString(16);return t.length&1?"0"+t:t}function zZ(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?_g:BigInt("0x"+e)}function Zs(e){return zZ(Jh(e))}function mn(e){return zZ(Jh(Ri(Ft(e)).reverse()))}function Ig(e,t){if(vt(t),t===0)throw RangeError("zero length");e=Eg(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return td(r.padStart(t*2,"0"))}function kd(e,t){return Ig(e,t).reverse()}function NZ(e,t){if(e=et(e),t=et(t),e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function Ri(e){return Uint8Array.from(et(e))}function kg(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var xg=(e)=>typeof e==="bigint"&&_g<=e;function Qse(e,t,r){return xg(e)&&xg(t)&&xg(r)&&t<=e&&e<r}function Ao(e,t,r,o){if(!Qse(t,r,o))throw RangeError("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function Dc(e){if(e<_g)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>_g;e>>=Yk,t+=1);return t}var Ad=(e)=>(Yk<<BigInt(e))-Yk;function DZ(e,t,r){if(vt(e,"hashLen"),vt(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,f=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Vt(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return Vt(...x)};return(S,x)=>{f(),h(S);let _=void 0;while((_=x(b()))===void 0)h();return f(),_}}function Gr(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function o(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,i))throw TypeError(`param "${i}" is invalid: expected own property`);let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}var eA=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Wt=BigInt(0),gt=BigInt(1),Us=BigInt(2),ZZ=BigInt(3),UZ=BigInt(4),qZ=BigInt(5),Yse=BigInt(7),MZ=BigInt(8),Xse=BigInt(9),FZ=BigInt(16);function it(e,t){if(t<=Wt)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Wt?r:t+r}function Qr(e,t,r){if(t<Wt)throw Error("pow2: expected non-negative exponent, got "+t);let o=e;while(t-- >Wt)o*=o,o%=r;return o}function LZ(e,t){if(e===Wt)throw Error("invert: expected non-zero number");if(t<=Wt)throw Error("invert: expected positive modulus, got "+t);let r=it(e,t),o=t,n=Wt,i=gt,s=gt,a=Wt;while(r!==Wt){let u=o/r,d=o-r*u,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==gt)throw Error("invert: does not exist");return it(n,t)}function tA(e,t,r){let o=e;if(!o.eql(o.sqr(t),r))throw Error("Cannot find square root")}function JZ(e,t){let r=e,o=(r.ORDER+gt)/UZ,n=r.pow(t,o);return tA(r,n,t),n}function eae(e,t){let r=e,o=(r.ORDER-qZ)/MZ,n=r.mul(t,Us),i=r.pow(n,o),s=r.mul(t,i),a=r.mul(r.mul(s,Us),i),c=r.mul(s,r.sub(a,r.ONE));return tA(r,c,t),c}function tae(e){let t=Ag(e),r=KZ(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+Yse)/FZ;return(a,c)=>{let u=a,d=u.pow(c,s),f=u.mul(d,o),m=u.mul(d,n),h=u.mul(d,i),b=u.eql(u.sqr(f),c),y=u.eql(u.sqr(m),c);d=u.cmov(d,f,b),f=u.cmov(h,m,y);let S=u.eql(u.sqr(f),c),x=u.cmov(d,f,S);return tA(u,x,c),x}}function KZ(e){if(e<ZZ)throw Error("sqrt is not defined for small field");let t=e-gt,r=0;while(t%Us===Wt)t/=Us,r++;let o=Us,n=Ag(e);while(BZ(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return JZ;let i=n.pow(o,t),s=(t+gt)/Us;return function(c,u){let d=c;if(d.is0(u))return u;if(BZ(d,u)!==1)throw Error("Cannot find square root");let f=r,m=d.mul(d.ONE,i),h=d.pow(u,t),b=d.pow(u,s);while(!d.eql(h,d.ONE)){if(d.is0(h))return d.ZERO;let y=1,S=d.sqr(h);while(!d.eql(S,d.ONE))if(y++,S=d.sqr(S),y===f)throw Error("Cannot find square root");let x=gt<<BigInt(f-y-1),_=d.pow(m,x);f=y,m=d.sqr(_),h=d.mul(h,m),b=d.mul(b,_)}return b}}function rae(e){if(e%UZ===ZZ)return JZ;if(e%MZ===qZ)return eae;if(e%FZ===Xse)return tae(e);return KZ(e)}var To=(e,t)=>(it(e,t)&gt)===gt,nae=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function rA(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=nae.reduce((o,n)=>(o[n]="function",o),t);if(Gr(e,r),Fn(e.BYTES,"BYTES"),Fn(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=gt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function oae(e,t,r){let o=e;if(r<Wt)throw Error("invalid exponent, negatives unsupported");if(r===Wt)return o.ONE;if(r===gt)return t;let n=o.ONE,i=t;while(r>Wt){if(r&gt)n=o.mul(n,i);i=o.sqr(i),r>>=gt}return n}function Td(e,t,r=!1){let o=e,n=Array(t.length).fill(r?o.ZERO:void 0),i=t.reduce((a,c,u)=>{if(o.is0(c))return a;return n[u]=a,o.mul(a,c)},o.ONE),s=o.inv(i);return t.reduceRight((a,c,u)=>{if(o.is0(c))return a;return n[u]=o.mul(a,n[u]),o.mul(a,c)},s),n}function BZ(e,t){let r=e,o=(r.ORDER-gt)/Us,n=r.pow(t,o),i=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!i&&!s&&!a)throw Error("invalid Legendre symbol result");return i?1:s?0:-1}function iae(e,t){if(t!==void 0)Xk(t);if(e<=Wt)throw Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw Error("invalid n length: expected positive bit length, got "+t);let r=Dc(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let o=t!==void 0?t:r,n=Math.ceil(o/8);return{nBitLength:o,nByteLength:n}}var jZ=new WeakMap;class nA{ORDER;BITS;BYTES;isLE;ZERO=Wt;ONE=gt;_lengths;_mod;constructor(e,t={}){if(e<=gt)throw Error("invalid field: expected ORDER > 1, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0});if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=Object.freeze(t.allowedLengths.slice());if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=iae(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,Object.freeze(this)}create(e){return it(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return Wt<=e&&e<this.ORDER}is0(e){return e===Wt}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&gt)===gt}neg(e){return it(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return it(e*e,this.ORDER)}add(e,t){return it(e+t,this.ORDER)}sub(e,t){return it(e-t,this.ORDER)}mul(e,t){return it(e*t,this.ORDER)}pow(e,t){return oae(this,e,t)}div(e,t){return it(e*LZ(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return LZ(e,this.ORDER)}sqrt(e){let t=jZ.get(this);if(!t)jZ.set(this,t=rae(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?kd(e,this.BYTES):Ig(e,this.BYTES)}fromBytes(e,t=!1){et(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?mn(e):Zs(e);if(s)a=it(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Td(this,e)}cmov(e,t,r){return ko(r,"condition"),r?t:e}}Object.freeze(nA.prototype);function Ag(e,t={}){return new nA(e,t)}function HZ(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=gt)throw Error("field order must be greater than 1");let t=Dc(e-gt);return Math.ceil(t/8)}function oA(e){let t=HZ(e);return t+Math.ceil(t/2)}function VZ(e,t,r=!1){et(e);let o=e.length,n=HZ(t),i=Math.max(oA(t),16);if(o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?mn(e):Zs(e),a=it(s,t-gt)+gt;return r?kd(a,n):Ig(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Lc=BigInt(0),qs=BigInt(1);function $d(e,t){let r=t.negate();return e?r:t}function Ms(e,t){let r=Td(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function YZ(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function iA(e,t){YZ(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=Ad(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function WZ(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=qs;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var sA=new WeakMap,XZ=new WeakMap;function aA(e){return XZ.get(e)||1}function GZ(e){if(e!==Lc)throw Error("invalid wNAF")}class Rd{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Lc){if(t&qs)r=r.add(o);o=o.double(),t>>=qs}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=iA(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=iA(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:f,offsetF:m}=WZ(r,s,i);if(r=a,u)n=n.add($d(f,t[m]));else o=o.add($d(d,t[c]))}return GZ(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=iA(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Lc)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=WZ(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return GZ(r),o}getPrecomputes(e,t,r){let o=sA.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);sA.set(t,o)}}return o}cached(e,t,r){let o=aA(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=aA(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){YZ(t,this.bits),XZ.set(e,t),sA.delete(e)}hasCache(e){return aA(e)!==1}}function eU(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Lc||o>Lc){if(r&qs)i=i.add(n);if(o&qs)s=s.add(n);n=n.double(),r>>=qs,o>>=qs}return{p1:i,p2:s}}function QZ(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return rA(t),t}else return Ag(e,{isLE:r})}function Tg(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>Lc))throw Error(`CURVE.${c} must be positive bigint`)}let n=QZ(t.p,r.Fp,o),i=QZ(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function Od(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}function Cd(e,t){if(Fn(e),Fn(t),t<0||t>4)throw Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let o=t-1;o>=0;o--)r[o]=e&255,e>>>=8;return new Uint8Array(r)}function sae(e,t){let r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e[o]^t[o];return r}function aae(e){if(!zc(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?kg(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function cA(e,t,r,o){if(et(e),Fn(r),t=aae(t),t.length>255)t=o(Vt(kg("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:i}=o,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=Vt(t,Cd(t.length,1)),c=new Uint8Array(i),u=Cd(r,2),d=Array(s),f=o(Vt(c,e,u,Cd(0,1),a));d[0]=o(Vt(f,Cd(1,1),a));for(let h=1;h<s;h++){let b=[sae(f,d[h-1]),Cd(h+1,1),a];d[h]=o(Vt(...b))}return Vt(...d).slice(0,r)}var tU="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var rU=(e,t)=>(e+(e>=0?t:-t)/oU)/t;function cae(e,t,r){Ao("scalar",e,Jn,r);let[[o,n],[i,s]]=t,a=rU(s*e,r),c=rU(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,f=u<Jn,m=d<Jn;if(f)u=-u;if(m)d=-d;let h=Ad(Math.ceil(Dc(r)/2))+Oi;if(u<Jn||u>=h||d<Jn||d>=h)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:f,k1:u,k2neg:m,k2:d}}function uA(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function lA(e,t){Gr(e);let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(ko(r.lowS,"lowS"),ko(r.prehash,"prehash"),r.format!==void 0)uA(r.format);return r}class nU extends Error{constructor(e=""){super(e)}}var hn={Err:nU,_tlv:{encode:(e,t)=>{let{Err:r}=hn;if(Fn(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!=="string")throw TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=Id(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?Id(n.length/2|128):"";return Id(e)+i+n+t},decode(e,t){let{Err:r}=hn;t=et(t,void 0,"DER data");let o=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=hn;if(Eg(e),e<Jn)throw new t("integer: negative integers are not allowed");let r=Id(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=hn;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Zs(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=hn,n=et(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=hn,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}};Object.freeze(hn._tlv);Object.freeze(hn._int);Object.freeze(hn);var Jn=BigInt(0),Oi=BigInt(1),oU=BigInt(2),$g=BigInt(3),lae=BigInt(4);function iU(e,t={}){let r=Tg("weierstrass",e,t),o=r.Fp,n=r.Fn,i=r.CURVE,{h:s,n:a}=i;Gr(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:u}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let d=aU(o,n);function f(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function m(j,R,B){if(u&&R.is0())return Uint8Array.of(0);let{x:I,y:T}=R.toAffine(),k=o.toBytes(I);if(ko(B,"isCompressed"),B){f();let M=!o.isOdd(T);return Vt(sU(M),k)}else return Vt(Uint8Array.of(4),k,o.toBytes(T))}function h(j){et(j,void 0,"Point");let{publicKey:R,publicKeyUncompressed:B}=d,I=j.length,T=j[0],k=j.subarray(1);if(u&&I===1&&T===0)return{x:o.ZERO,y:o.ZERO};if(I===R&&(T===2||T===3)){let M=o.fromBytes(k);if(!o.isValid(M))throw Error("bad point: is not on curve, wrong x");let N=S(M),H;try{H=o.sqrt(N)}catch(ae){let pe=ae instanceof Error?": "+ae.message:"";throw Error("bad point: is not on curve, sqrt error"+pe)}f();let G=o.isOdd(H);if((T&1)===1!==G)H=o.neg(H);return{x:M,y:H}}else if(I===B&&T===4){let M=o.BYTES,N=o.fromBytes(k.subarray(0,M)),H=o.fromBytes(k.subarray(M,M*2));if(!x(N,H))throw Error("bad point: is not on curve");return{x:N,y:H}}else throw Error(`bad point: got length ${I}, expected compressed=${R} or uncompressed=${B}`)}let b=t.toBytes===void 0?m:t.toBytes,y=t.fromBytes===void 0?h:t.fromBytes;function S(j){let R=o.sqr(j),B=o.mul(R,j);return o.add(o.add(B,o.mul(j,i.a)),i.b)}function x(j,R){let B=o.sqr(R),I=S(j);return o.eql(B,I)}if(!x(i.Gx,i.Gy))throw Error("bad curve params: generator point");let _=o.mul(o.pow(i.a,$g),lae),A=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(_,A)))throw Error("bad curve params: a or b");function O(j,R,B=!1){if(!o.isValid(R)||B&&o.is0(R))throw Error(`bad point coordinate ${j}`);return R}function L(j){if(!(j instanceof P))throw Error("Weierstrass Point expected")}function z(j){if(!c||!c.basises)throw Error("no endo");return cae(j,c.basises,n.ORDER)}function K(j,R,B,I,T){return B=new P(o.mul(B.X,j),B.Y,B.Z),R=$d(I,R),B=$d(T,B),R.add(B)}class P{static BASE=new P(i.Gx,i.Gy,o.ONE);static ZERO=new P(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(j,R,B){this.X=O("x",j),this.Y=O("y",R,!0),this.Z=O("z",B),Object.freeze(this)}static CURVE(){return i}static fromAffine(j){let{x:R,y:B}=j||{};if(!j||!o.isValid(R)||!o.isValid(B))throw Error("invalid affine point");if(j instanceof P)throw Error("projective point not allowed");if(o.is0(R)&&o.is0(B))return P.ZERO;return new P(R,B,o.ONE)}static fromBytes(j){let R=P.fromAffine(y(et(j,void 0,"point")));return R.assertValidity(),R}static fromHex(j){return P.fromBytes(Pc(j))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(j=8,R=!0){if(ee.createCache(this,j),!R)this.multiply($g);return this}assertValidity(){let j=this;if(j.is0()){if(t.allowInfinityPoint&&o.is0(j.X)&&o.eql(j.Y,o.ONE)&&o.is0(j.Z))return;throw Error("bad point: ZERO")}let{x:R,y:B}=j.toAffine();if(!o.isValid(R)||!o.isValid(B))throw Error("bad point: x or y not field elements");if(!x(R,B))throw Error("bad point: equation left != right");if(!j.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:j}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(j)}equals(j){L(j);let{X:R,Y:B,Z:I}=this,{X:T,Y:k,Z:M}=j,N=o.eql(o.mul(R,M),o.mul(T,I)),H=o.eql(o.mul(B,M),o.mul(k,I));return N&&H}negate(){return new P(this.X,o.neg(this.Y),this.Z)}double(){let{a:j,b:R}=i,B=o.mul(R,$g),{X:I,Y:T,Z:k}=this,M=o.ZERO,N=o.ZERO,H=o.ZERO,G=o.mul(I,I),re=o.mul(T,T),ae=o.mul(k,k),pe=o.mul(I,T);return pe=o.add(pe,pe),H=o.mul(I,k),H=o.add(H,H),M=o.mul(j,H),N=o.mul(B,ae),N=o.add(M,N),M=o.sub(re,N),N=o.add(re,N),N=o.mul(M,N),M=o.mul(pe,M),H=o.mul(B,H),ae=o.mul(j,ae),pe=o.sub(G,ae),pe=o.mul(j,pe),pe=o.add(pe,H),H=o.add(G,G),G=o.add(H,G),G=o.add(G,ae),G=o.mul(G,pe),N=o.add(N,G),ae=o.mul(T,k),ae=o.add(ae,ae),G=o.mul(ae,pe),M=o.sub(M,G),H=o.mul(ae,re),H=o.add(H,H),H=o.add(H,H),new P(M,N,H)}add(j){L(j);let{X:R,Y:B,Z:I}=this,{X:T,Y:k,Z:M}=j,N=o.ZERO,H=o.ZERO,G=o.ZERO,re=i.a,ae=o.mul(i.b,$g),pe=o.mul(R,T),be=o.mul(B,k),ve=o.mul(I,M),ke=o.add(R,B),Ie=o.add(T,k);ke=o.mul(ke,Ie),Ie=o.add(pe,be),ke=o.sub(ke,Ie),Ie=o.add(R,I);let we=o.add(T,M);return Ie=o.mul(Ie,we),we=o.add(pe,ve),Ie=o.sub(Ie,we),we=o.add(B,I),N=o.add(k,M),we=o.mul(we,N),N=o.add(be,ve),we=o.sub(we,N),G=o.mul(re,Ie),N=o.mul(ae,ve),G=o.add(N,G),N=o.sub(be,G),G=o.add(be,G),H=o.mul(N,G),be=o.add(pe,pe),be=o.add(be,pe),ve=o.mul(re,ve),Ie=o.mul(ae,Ie),be=o.add(be,ve),ve=o.sub(pe,ve),ve=o.mul(re,ve),Ie=o.add(Ie,ve),pe=o.mul(be,Ie),H=o.add(H,pe),pe=o.mul(we,Ie),N=o.mul(ke,N),N=o.sub(N,pe),pe=o.mul(ke,be),G=o.mul(we,G),G=o.add(G,pe),new P(N,H,G)}subtract(j){return L(j),this.add(j.negate())}is0(){return this.equals(P.ZERO)}multiply(j){let{endo:R}=t;if(!n.isValidNot0(j))throw RangeError("invalid scalar: out of range");let B,I,T=(k)=>ee.cached(this,k,(M)=>Ms(P,M));if(R){let{k1neg:k,k1:M,k2neg:N,k2:H}=z(j),{p:G,f:re}=T(M),{p:ae,f:pe}=T(H);I=re.add(pe),B=K(R.beta,G,ae,k,N)}else{let{p:k,f:M}=T(j);B=k,I=M}return Ms(P,[B,I])[0]}multiplyUnsafe(j){let{endo:R}=t,B=this,I=j;if(!n.isValid(I))throw RangeError("invalid scalar: out of range");if(I===Jn||B.is0())return P.ZERO;if(I===Oi)return B;if(ee.hasCache(this))return this.multiply(I);if(R){let{k1neg:T,k1:k,k2neg:M,k2:N}=z(I),{p1:H,p2:G}=eU(P,B,k,N);return K(R.beta,H,G,T,M)}else return ee.unsafe(B,I)}toAffine(j){let R=this,B=j,{X:I,Y:T,Z:k}=R;if(o.eql(k,o.ONE))return{x:I,y:T};let M=R.is0();if(B==null)B=M?o.ONE:o.inv(k);let N=o.mul(I,B),H=o.mul(T,B),G=o.mul(k,B);if(M)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:H}}isTorsionFree(){let{isTorsionFree:j}=t;if(s===Oi)return!0;if(j)return j(P,this);return ee.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:j}=t;if(s===Oi)return this;if(j)return j(P,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===Oi)return this.is0();return this.clearCofactor().is0()}toBytes(j=!0){return ko(j,"isCompressed"),this.assertValidity(),b(P,this,j)}toHex(j=!0){return Cc(this.toBytes(j))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let W=n.BITS,ee=new Rd(P,t.endo?Math.ceil(W/2):W);if(W>=8)P.BASE.precompute(8);return Object.freeze(P.prototype),Object.freeze(P),P}function sU(e){return Uint8Array.of(e?2:3)}function aU(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function uae(e,t={}){let{Fn:r}=e,o=t.randomBytes===void 0?Nc:t.randomBytes,n=Object.assign(aU(e.Fp,r),{seed:Math.max(oA(r.ORDER),16)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h){return h=h===void 0?o(n.seed):h,VZ(et(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n,x=r._lengths;if(!zc(h))return;let _=et(h,void 0,"key").length,A=_===y||_===S,O=_===b||!!x?.includes(_);if(A&&O)return;return A}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=Od(a,c);return Object.freeze(f),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function cU(e,t,r={}){let o=t;yo(o),Gr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?Nc:r.randomBytes,i=r.hmac===void 0?(T,k)=>Bn(o,T,k):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:u}=a,{keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b}=uae(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=c*oU+Oi<s.ORDER;function x(T){let k=c>>Oi;return T>k}function _(T,k){if(!a.isValidNot0(k))throw Error(`invalid signature ${T}: out of range 1..Point.Fn.ORDER`);return k}function A(){if(S)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(T,k){uA(k);let M=b.signature,N=k==="compact"?M:k==="recovered"?M+1:void 0;return et(T,N)}class L{r;s;recovery;constructor(T,k,M){if(this.r=_("r",T),this.s=_("s",k),M!=null){if(A(),![0,1,2,3].includes(M))throw Error("invalid recovery id");this.recovery=M}Object.freeze(this)}static fromBytes(T,k=y.format){O(T,k);let M;if(k==="der"){let{r:re,s:ae}=hn.toSig(et(T));return new L(re,ae)}if(k==="recovered")M=T[0],k="compact",T=T.subarray(1);let N=b.signature/2,H=T.subarray(0,N),G=T.subarray(N,N*2);return new L(a.fromBytes(H),a.fromBytes(G),M)}static fromHex(T,k){return this.fromBytes(Pc(T),k)}assertRecovery(){let{recovery:T}=this;if(T==null)throw Error("invalid recovery id: must be present");return T}addRecoveryBit(T){return new L(this.r,this.s,T)}recoverPublicKey(T){let{r:k,s:M}=this,N=this.assertRecovery(),H=N===2||N===3?k+c:k;if(!s.isValid(H))throw Error("invalid recovery id: sig.r+curve.n != R.x");let G=s.toBytes(H),re=e.fromBytes(Vt(sU((N&1)===0),G)),ae=a.inv(H),pe=K(et(T,void 0,"msgHash")),be=a.create(-pe*ae),ve=a.create(M*ae),ke=e.BASE.multiplyUnsafe(be).add(re.multiplyUnsafe(ve));if(ke.is0())throw Error("invalid recovery: point at infinify");return ke.assertValidity(),ke}hasHighS(){return x(this.s)}toBytes(T=y.format){if(uA(T),T==="der")return Pc(hn.hexFromSig(this));let{r:k,s:M}=this,N=a.toBytes(k),H=a.toBytes(M);if(T==="recovered")return A(),Vt(Uint8Array.of(this.assertRecovery()),N,H);return Vt(N,H)}toHex(T){return Cc(this.toBytes(T))}}Object.freeze(L.prototype),Object.freeze(L);let z=r.bits2int===void 0?function(k){if(k.length>8192)throw Error("input is too large");let M=Zs(k),N=k.length*8-u;return N>0?M>>BigInt(N):M}:r.bits2int,K=r.bits2int_modN===void 0?function(k){return a.create(z(k))}:r.bits2int_modN,P=Ad(u);function W(T){return Ao("num < 2^"+u,T,Jn,P),a.toBytes(T)}function ee(T,k){return et(T,void 0,"message"),k?et(o(T),void 0,"prehashed message"):T}function j(T,k,M){let{lowS:N,prehash:H,extraEntropy:G}=lA(M,y);T=ee(T,H);let re=K(T),ae=a.fromBytes(k);if(!a.isValidNot0(ae))throw Error("invalid private key");let pe=[W(ae),W(re)];if(G!=null&&G!==!1){let Ie=G===!0?n(b.secretKey):G;pe.push(et(Ie,void 0,"extraEntropy"))}let be=Vt(...pe),ve=re;function ke(Ie){let we=z(Ie);if(!a.isValidNot0(we))return;let Ue=a.inv(we),De=e.BASE.multiply(we).toAffine(),Qe=a.create(De.x);if(Qe===Jn)return;let St=a.create(Ue*a.create(ve+Qe*ae));if(St===Jn)return;let Tt=(De.x===Qe?0:2)|Number(De.y&Oi),Nt=St;if(N&&x(St))Nt=a.neg(St),Tt^=1;return new L(Qe,Nt,S?void 0:Tt)}return{seed:be,k2sig:ke}}function R(T,k,M={}){let{seed:N,k2sig:H}=j(T,k,M);return DZ(o.outputLen,a.BYTES,i)(N,H).toBytes(M.format)}function B(T,k,M,N={}){let{lowS:H,prehash:G,format:re}=lA(N,y);if(M=et(M,void 0,"publicKey"),k=ee(k,G),!zc(T)){let ae=T instanceof L?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ae)}O(T,re);try{let ae=L.fromBytes(T,re),pe=e.fromBytes(M);if(H&&ae.hasHighS())return!1;let{r:be,s:ve}=ae,ke=K(k),Ie=a.inv(ve),we=a.create(ke*Ie),Ue=a.create(be*Ie),De=e.BASE.multiplyUnsafe(we).add(pe.multiplyUnsafe(Ue));if(De.is0())return!1;return a.create(De.x)===be}catch(ae){return!1}}function I(T,k,M={}){let{prehash:N}=lA(M,y);return k=ee(k,N),L.fromBytes(T,"recovered").recoverPublicKey(k).toBytes()}return Object.freeze({keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b,Point:e,sign:R,verify:B,recoverPublicKey:I,Signature:L,hash:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var dae=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var fae=iU(dae),Bc=cU(fae,wt);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ci=BigInt(0),Ir=BigInt(1),dA=BigInt(2),pae=BigInt(8);function mae(e,t,r,o){let n=e.sqr(r),i=e.sqr(o),s=e.add(e.mul(t.a,n),i),a=e.add(e.ONE,e.mul(t.d,e.mul(n,i)));return e.eql(s,a)}function lU(e,t={}){let r=t,o=Tg("edwards",e,r,r.FpFnLE),{Fp:n,Fn:i}=o,s=o.CURVE,{h:a}=s;Gr(r,{},{uvRatio:"function"});let c=dA<<BigInt(i.BYTES*8)-Ir,u=(y)=>n.create(y),d=r.uvRatio===void 0?(y,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(y,S))}}catch(x){return{isValid:!1,value:Ci}}}:r.uvRatio;if(!mae(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function f(y,S,x=!1){let _=x?Ir:Ci;return Ao("coordinate "+y,S,_,c),S}function m(y){if(!(y instanceof h))throw Error("EdwardsPoint expected")}class h{static BASE=new h(s.Gx,s.Gy,Ir,u(s.Gx*s.Gy));static ZERO=new h(Ci,Ir,Ir,Ci);static Fp=n;static Fn=i;X;Y;Z;T;constructor(y,S,x,_){this.X=f("x",y),this.Y=f("y",S),this.Z=f("z",x,!0),this.T=f("t",_),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof h)throw Error("extended point not allowed");let{x:S,y:x}=y||{};return f("x",S),f("y",x),new h(S,x,Ir,u(S*x))}static fromBytes(y,S=!1){let x=n.BYTES,{a:_,d:A}=s;y=Ri(et(y,x,"point")),ko(S,"zip215");let O=Ri(y),L=y[x-1];O[x-1]=L&-129;let z=mn(O),K=S?c:n.ORDER;Ao("point.y",z,Ci,K);let P=u(z*z),W=u(P-Ir),ee=u(A*P-_),{isValid:j,value:R}=d(W,ee);if(!j)throw Error("bad point: invalid y coordinate");let B=(R&Ir)===Ir,I=(L&128)!==0;if(!S&&R===Ci&&I)throw Error("bad point: x=0 and x_0=1");if(I!==B)R=u(-R);return h.fromAffine({x:R,y:z})}static fromHex(y,S=!1){return h.fromBytes(Pc(y),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,S=!0){if(b.createCache(this,y),!S)this.multiply(dA);return this}assertValidity(){let y=this,{a:S,d:x}=s;if(y.is0())throw Error("bad point: ZERO");let{X:_,Y:A,Z:O,T:L}=y,z=u(_*_),K=u(A*A),P=u(O*O),W=u(P*P),ee=u(z*S),j=u(P*u(ee+K)),R=u(W+u(x*u(z*K)));if(j!==R)throw Error("bad point: equation left != right (1)");let B=u(_*A),I=u(O*L);if(B!==I)throw Error("bad point: equation left != right (2)")}equals(y){m(y);let{X:S,Y:x,Z:_}=this,{X:A,Y:O,Z:L}=y,z=u(S*L),K=u(A*_),P=u(x*L),W=u(O*_);return z===K&&P===W}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.X),this.Y,this.Z,u(-this.T))}double(){let{a:y}=s,{X:S,Y:x,Z:_}=this,A=u(S*S),O=u(x*x),L=u(dA*u(_*_)),z=u(y*A),K=S+x,P=u(u(K*K)-A-O),W=z+O,ee=W-L,j=z-O,R=u(P*ee),B=u(W*j),I=u(P*j),T=u(ee*W);return new h(R,B,T,I)}add(y){m(y);let{a:S,d:x}=s,{X:_,Y:A,Z:O,T:L}=this,{X:z,Y:K,Z:P,T:W}=y,ee=u(_*z),j=u(A*K),R=u(L*x*W),B=u(O*P),I=u((_+A)*(z+K)-ee-j),T=B-R,k=B+R,M=u(j-S*ee),N=u(I*T),H=u(k*M),G=u(I*M),re=u(T*k);return new h(N,H,re,G)}subtract(y){return m(y),this.add(y.negate())}multiply(y){if(!i.isValidNot0(y))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:x}=b.cached(this,y,(_)=>Ms(h,_));return Ms(h,[S,x])[0]}multiplyUnsafe(y){if(!i.isValid(y))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(y===Ci)return h.ZERO;if(this.is0()||y===Ir)return this;return b.unsafe(this,y,(S)=>Ms(h,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(y){let S=this,x=y,{X:_,Y:A,Z:O}=S,L=S.is0();if(x==null)x=L?pae:n.inv(O);let z=u(_*x),K=u(A*x),P=n.mul(O,x);if(L)return{x:Ci,y:Ir};if(P!==Ir)throw Error("invZ was invalid");return{x:z,y:K}}clearCofactor(){if(a===Ir)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:y,y:S}=this.toAffine(),x=n.toBytes(S);return x[x.length-1]|=y&Ir?128:0,x}toHex(){return Cc(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new Rd(h,i.BITS);if(i.BITS>=8)h.BASE.precompute(8);return Object.freeze(h.prototype),Object.freeze(h),h}class fA{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){eA()}static fromHex(e){eA()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Cc(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.ep.precompute(e,t),this}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Pd=BigInt(0),jc=BigInt(1),Rg=BigInt(2);function hae(e){return Gr(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function uU(e){let t=hae(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s===void 0?Nc:s,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?Rg**BigInt(254):Rg**BigInt(447),b=a?BigInt(8)*Rg**BigInt(251)-jc:BigInt(4)*Rg**BigInt(445)-jc,y=h+b+jc,S=(I)=>it(I,r),x=_(f);function _(I){return kd(S(I),d)}function A(I){let T=Ri(et(I,d,"uCoordinate"));if(a)T[31]&=127;return S(mn(T))}function O(I){return mn(n(Ri(et(I,d,"scalar"))))}function L(I,T){let k=ee(A(T),O(I));if(k===Pd)throw Error("invalid private or public key received");return _(k)}function z(I){return L(I,x)}let K=z,P=L;function W(I,T,k){let M=S(I*(T-k));return T=S(T-M),k=S(k+M),{x_2:T,x_3:k}}function ee(I,T){Ao("u",I,Pd,r),Ao("scalar",T,h,y);let k=T,M=I,N=jc,H=Pd,G=I,re=jc,ae=Pd;for(let be=BigInt(u-1);be>=Pd;be--){let ve=k>>be&jc;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:H,x_3:re}=W(ae,H,re),ae=ve;let ke=N+H,Ie=S(ke*ke),we=N-H,Ue=S(we*we),De=Ie-Ue,Qe=G+re,St=G-re,Tt=S(St*ke),Nt=S(Qe*we),lt=Tt+Nt,$r=Tt-Nt;G=S(lt*lt),re=S(M*S($r*$r)),N=S(Ie*Ue),H=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:H,x_3:re}=W(ae,H,re);let pe=i(H);return S(N*pe)}let j={secretKey:d,publicKey:d,seed:d},R=(I)=>(I=I===void 0?c(d):I,et(I,j.seed,"seed"),I),B={randomSecretKey:R};return Object.freeze(j),Object.freeze(B),Object.freeze({keygen:Od(R,K),getSharedSecret:P,getPublicKey:K,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var gae=BigInt(0),$o=BigInt(1),dU=BigInt(2),yae=BigInt(3),bae=BigInt(5),Sae=BigInt(8),Js=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),gA=(()=>({p:Js,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Sae,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function mU(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=Js,a=e*e%i*e%i,c=Qr(a,dU,i)*a%i,u=Qr(c,$o,i)*e%i,d=Qr(u,bae,i)*u%i,f=Qr(d,t,i)*d%i,m=Qr(f,r,i)*f%i,h=Qr(m,o,i)*m%i,b=Qr(h,n,i)*h%i,y=Qr(b,n,i)*h%i,S=Qr(y,t,i)*d%i;return{pow_p_5_8:Qr(S,dU,i)*e%i,b2:a}}function vae(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var pA=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function yA(e,t){let r=Js,o=it(t*t*t,r),n=it(o*o*t,r),i=mU(e*n).pow_p_5_8,s=it(e*o*i,r),a=it(t*s*s,r),c=s,u=it(s*pA,r),d=a===e,f=a===it(-e,r),m=a===it(-e*pA,r);if(d)s=c;if(f||m)s=u;if(To(s,r))s=it(-s,r);return{isValid:d||f,value:s}}var Fs=lU(gA,{uvRatio:yA}),Pi=(()=>Fs.Fp)(),hU=(()=>Fs.Fn)();var Og=(()=>{let e=Js;return uU({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=mU(t);return it(Qr(r,yae,e)*o,e)},adjustScalarBytes:vae})})();var mA=pA,wae=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),xae=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),_ae=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Eae=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),fU=(e)=>yA($o,e),Iae=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),hA=(e)=>Pi.create(mn(e)&Iae);function pU(e){let{d:t}=gA,r=Js,o=(x)=>Pi.create(x),n=o(mA*e*e),i=o((n+$o)*_ae),s=BigInt(-1),a=o((s-t*n)*o(n+t)),{isValid:c,value:u}=yA(i,a),d=o(u*e);if(!To(d,r))d=o(-d);if(!c)u=d;if(!c)s=n;let f=o(s*(n-$o)*Eae-a),m=u*u,h=o((u+u)*a),b=o(f*wae),y=o($o-m),S=o($o+m);return new Fs(o(h*S),o(y*b),o(b*S),o(h*y))}class yr extends fA{static BASE=(()=>new yr(Fs.BASE))();static ZERO=(()=>new yr(Fs.ZERO))();static Fp=(()=>Pi)();static Fn=(()=>hU)();constructor(e){super(e)}static fromAffine(e){return new yr(Fs.fromAffine(e))}assertSame(e){if(!(e instanceof yr))throw Error("RistrettoPoint expected")}init(e){return new yr(e)}static fromBytes(e){Ft(e,32);let{a:t,d:r}=gA,o=Js,n=(A)=>Pi.create(A),i=hA(e);if(!NZ(Pi.toBytes(i),e)||To(i,o))throw Error("invalid ristretto255 encoding 1");let s=n(i*i),a=n($o+t*s),c=n($o-t*s),u=n(a*a),d=n(c*c),f=n(t*r*u-d),{isValid:m,value:h}=fU(n(f*d)),b=n(h*c),y=n(h*b*f),S=n((i+i)*b);if(To(S,o))S=n(-S);let x=n(a*y),_=n(S*x);if(!m||To(_,o)||x===gae)throw Error("invalid ristretto255 encoding 2");return new yr(new Fs(S,x,$o,_))}static fromHex(e){return yr.fromBytes(td(e))}toBytes(){let{X:e,Y:t,Z:r,T:o}=this.ep,n=Js,i=(y)=>Pi.create(y),s=i(i(r+t)*i(r-t)),a=i(e*t),c=i(a*a),{value:u}=fU(i(s*c)),d=i(u*s),f=i(u*a),m=i(d*f*o),h;if(To(o*m,n)){let y=i(t*mA),S=i(e*mA);e=y,t=S,h=i(d*xae)}else h=f;if(To(e*m,n))t=i(-t);let b=i((r-t)*h);if(To(b,n))b=i(-b);return Pi.toBytes(b)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:o,Y:n}=e.ep,i=(c)=>Pi.create(c),s=i(t*n)===i(r*o),a=i(r*n)===i(t*o);return s||a}is0(){return this.equals(yr.ZERO)}}Object.freeze(yr.BASE);Object.freeze(yr.ZERO);Object.freeze(yr.prototype);Object.freeze(yr);var kae=Object.freeze({Point:yr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,o=cA(e,r,64,Wh);return kae.deriveToCurve(o)},hashToScalar(e,t={DST:tU}){let r=cA(e,t.DST,64,Wh);return hU.create(mn(r))},deriveToCurve(e){Ft(e,64);let t=hA(e.subarray(0,32)),r=pU(t),o=hA(e.subarray(32,64)),n=pU(o);return new yr(r.add(n))}});var gU=!1,Aae=!1;async function yU(e,t){if(Aae)return await t();try{return await e()}catch(r){if(r instanceof ReferenceError||r instanceof DOMException&&r.name==="NotSupportedError")return await t();else throw r}}async function Cg(e,t){return await yU(async()=>{let r=bA(e)?e:await $ae(e),o=await crypto.subtle.importKey("raw",Rae(t),{name:"X25519"},gU,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:o},r,256))},()=>{if(bA(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Og.scalarMult(e,t)})}async function zd(e){return await yU(async()=>Cg(e,Og.GuBytes),()=>{if(bA(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Og.scalarMultBase(e)})}var Tae=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function $ae(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...Tae,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},gU,["deriveBits"])}function bA(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function Rae(e){return e}class SA{s;transcript=[];buf=new Uint8Array(0);constructor(e){this.s=e.getReader()}async readLine(){let e=[];while(!0){let t=this.buf.indexOf(10);if(t>=0)return e.push(this.buf.subarray(0,t)),this.transcript.push(this.buf.subarray(0,t+1)),this.buf=this.buf.subarray(t+1),Cae(Ks(e));if(this.buf.length>0)e.push(this.buf),this.transcript.push(this.buf);let r=await this.s.read();if(r.done)return this.buf=Ks(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:Ks(this.transcript)}}}function Cae(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function Ks(e){let t=e.reduce((n,i)=>n+i.length,0),r=new Uint8Array(t),o=0;for(let n of e)r.set(n,o),o+=n.length;return r}function Zc(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let o of t)r.enqueue(o)}}))}function Pg(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function vA(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function bU(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function SU(e,t){let r=e.getReader(),o=[],n=0;while(n<t){let{done:c,value:u}=await r.read();if(c)throw Error("stream ended before reading "+t.toString()+" bytes");o.push(u),n+=u.length}r.releaseLock();let i=Ks(o),s=i.subarray(0,t),a=Zc(e,i.subarray(t));return{data:s,rest:a}}class Kn{args;body;constructor(e,t){this.args=e,this.body=t}}async function Pae(e){let t=await e.readLine();if(t===null)throw Error("invalid stanza");let r=t.split(" ");if(r.length<2||r.shift()!=="->")return{next:t};for(let i of r)if(i.length===0)throw Error("invalid stanza");let o=[];for(;;){let i=await e.readLine();if(i===null)throw Error("invalid stanza");let s=tr.decode(i);if(s.length>48)throw Error("invalid stanza");if(o.push(s),s.length<48)break}let n=Ks(o);return{s:new Kn(r,n)}}async function vU(e){let t=new SA(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let o=[];for(;;){let{s:n,next:i}=await Pae(t);if(n!==void 0){o.push(n);continue}if(!i.startsWith("--- "))throw Error("invalid header");let s=tr.decode(i.slice(4)),{rest:a,transcript:c}=t.close(),u=c.slice(0,c.length-1-i.length+3);return{stanzas:o,headerNoMAC:u,MAC:s,headerSize:c.length,rest:Zc(e,a)}}}function wA(e){let t=[];t.push(`age-encryption.org/v1
728
728
  `);for(let r of e){t.push("-> "+r.args.join(" ")+`
729
729
  `);for(let o=0;o<r.body.length;o+=48){let n=o+48;if(n>r.body.length)n=r.body.length;t.push(tr.encode(r.body.subarray(o,n))+`
730
730
  `)}if(r.body.length%48===0)t.push(`
731
731
  `)}return t.push("---"),new TextEncoder().encode(t.join(""))}function wU(e,t){return Ks([wA(e),new TextEncoder().encode(" "+tr.encode(t)+`
732
- `)])}function EA(){return xU()}function xU(){let e=bo(32),t=Dr.encodeFromBytes("AGE-SECRET-KEY-",e).toUpperCase();return Promise.resolve(t)}async function Ng(e){let t;if(EU(e))t=e;else if(e.startsWith("AGE-SECRET-KEY-PQ-1")){let o=Dr.decodeToBytes(e);if(o.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||o.bytes.length!==32)throw Error("invalid identity");let n=wg.getPublicKey(o.bytes);return Dr.encode("age1pq",Dr.toWords(n),!1)}else{let o=Dr.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||o.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||o.bytes.length!==32)throw Error("invalid identity");t=o.bytes}let r=await zd(t);return Dr.encodeFromBytes("age",r)}class IA{recipient;constructor(e){let t=Dr.decodeToBytes(e);if(!e.startsWith("age1pq1")||t.prefix.toLowerCase()!=="age1pq"||t.bytes.length!==1216)throw Error("invalid recipient");this.recipient=t.bytes}wrapFileKey(e){let{cipherText:t,sharedSecret:r}=wg.encapsulate(this.recipient),o=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:n,nonce:i}=Dg(_U,r,o),s=Hr(n,i).encrypt(e);return[new Kn(["mlkem768x25519",tr.encode(t)],s)]}}class kA{identity;constructor(e){let t=Dr.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-PQ-1")||t.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||t.bytes.length!==32)throw Error("invalid identity");this.identity=t.bytes}unwrapFileKey(e){for(let t of e){if(t.args.length<1||t.args[0]!=="mlkem768x25519")continue;if(t.args.length!==2)throw Error("invalid mlkem768x25519 stanza");let r=tr.decode(t.args[1]);if(r.length!==1120)throw Error("invalid mlkem768x25519 stanza");if(t.body.length!==32)throw Error("invalid mlkem768x25519 stanza");let o=wg.decapsulate(r,this.identity),n=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:i,nonce:s}=Dg(_U,o,n);try{return Hr(i,s).decrypt(t.body)}catch{continue}}return null}}var _U=25722,Pae=80,xA=16;function Dg(e,t,r){let o=zae(e),n=zg(o,void 0,"psk_id_hash",new Uint8Array(0)),i=zg(o,void 0,"info_hash",r),s=new Uint8Array(1+n.length+i.length);s[0]=0,s.set(n,1),s.set(i,1+n.length);let a=zg(o,t,"secret",new Uint8Array(0)),c=_A(o,a,"key",s,32),u=_A(o,a,"base_nonce",s,12);return{key:c,nonce:u}}function zae(e){let t=new Uint8Array(10);return t.set(new TextEncoder().encode("HPKE"),0),t[4]=e>>8&255,t[5]=e&255,t[6]=0,t[7]=1,t[8]=0,t[9]=3,t}function zg(e,t,r,o){let n=new Uint8Array(7+e.length+r.length+o.length),i=0;return n.set(new TextEncoder().encode("HPKE-v1"),i),i+=7,n.set(e,i),i+=e.length,n.set(new TextEncoder().encode(r),i),i+=r.length,n.set(o,i),rd(wt,n,t)}function _A(e,t,r,o,n){let i=new Uint8Array(9+e.length+r.length+o.length),s=0;return i[s]=n>>8&255,i[s+1]=n&255,s+=2,i.set(new TextEncoder().encode("HPKE-v1"),s),s+=7,i.set(e,s),s+=e.length,i.set(new TextEncoder().encode(r),s),s+=r.length,i.set(o,s),ak(wt,t,i,n)}function Nae(e){if(e.length!==Bc.lengths.publicKeyUncompressed)e=Bc.Point.fromBytes(e).toBytes(!1);let t=Bc.utils.randomSecretKey(),r=Bc.getPublicKey(t,!1),o=Bc.getSharedSecret(t,e,!0).subarray(1),n=new Uint8Array(r.length+e.length);n.set(r,0),n.set(e,r.length);let i=new Uint8Array(5);i.set(new TextEncoder().encode("KEM"),0),i[3]=xA>>8,i[4]=xA&255;let s=zg(i,void 0,"eae_prk",o),a=_A(i,s,"shared_secret",n,32);return{encapsulatedKey:r,sharedSecret:a}}class AA{recipient;constructor(e){let t=Dr.decodeToBytes(e);if(!e.startsWith("age1tag1")||t.prefix.toLowerCase()!=="age1tag"||t.bytes.length!==33)throw Error("invalid recipient");this.recipient=t.bytes}wrapFileKey(e){let{encapsulatedKey:t,sharedSecret:r}=Nae(this.recipient),o=new TextEncoder().encode("age-encryption.org/p256tag"),n=(()=>{let c=wt(this.recipient).subarray(0,4),u=new Uint8Array(t.length+c.length);return u.set(t,0),u.set(c,t.length),rd(wt,u,o).subarray(0,4)})(),{key:i,nonce:s}=Dg(xA,r,o),a=Hr(i,s).encrypt(e);return[new Kn(["p256tag",tr.encode(n),tr.encode(t)],a)]}}class TA{recipient;constructor(e){let t=Dr.decodeToBytes(e);if(!e.startsWith("age1tagpq1")||t.prefix.toLowerCase()!=="age1tagpq"||t.bytes.length!==1249)throw Error("invalid recipient");this.recipient=t.bytes}wrapFileKey(e){let{cipherText:t,sharedSecret:r}=PZ.encapsulate(this.recipient),o=new TextEncoder().encode("age-encryption.org/mlkem768p256tag"),n=(()=>{let c=wt(this.recipient.subarray(1184)).subarray(0,4),u=new Uint8Array(t.length+c.length);return u.set(t,0),u.set(c,t.length),rd(wt,u,o).subarray(0,4)})(),{key:i,nonce:s}=Dg(Pae,r,o),a=Hr(i,s).encrypt(e);return[new Kn(["mlkem768p256tag",tr.encode(n),tr.encode(t)],a)]}}class $A{recipient;constructor(e){let t=Dr.decodeToBytes(e);if(!e.startsWith("age1")||t.prefix.toLowerCase()!=="age"||t.bytes.length!==32)throw Error("invalid recipient");this.recipient=t.bytes}async wrapFileKey(e){let t=bo(32),r=await zd(t),o=await Cg(t,this.recipient),n=new Uint8Array(r.length+this.recipient.length);n.set(r),n.set(this.recipient,r.length);let i=new TextEncoder().encode("age-encryption.org/v1/X25519"),s=gi(wt,o,n,i,32);return[new Kn(["X25519",tr.encode(r)],CA(e,s))]}}class Lg{identity;recipient;constructor(e){if(EU(e)){this.identity=e,this.recipient=zd(e);return}let t=Dr.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||t.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||t.bytes.length!==32)throw Error("invalid identity");this.identity=t.bytes,this.recipient=zd(t.bytes)}async unwrapFileKey(e){for(let t of e){if(t.args.length<1||t.args[0]!=="X25519")continue;if(t.args.length!==2)throw Error("invalid X25519 stanza");let r=tr.decode(t.args[1]);if(r.length!==32)throw Error("invalid X25519 stanza");let o=await Cg(this.identity,r),n=await this.recipient,i=new Uint8Array(r.length+n.length);i.set(r),i.set(n,r.length);let s=new TextEncoder().encode("age-encryption.org/v1/X25519"),a=gi(wt,o,i,s,32),c=PA(t.body,a);if(c!==null)return c}return null}}class RA{passphrase;logN;constructor(e,t){this.passphrase=e,this.logN=t}wrapFileKey(e){let t=bo(16),r="age-encryption.org/v1/scrypt",o=new Uint8Array(44);o.set(new TextEncoder().encode("age-encryption.org/v1/scrypt")),o.set(t,28);let n=bk(this.passphrase,o,{N:2**this.logN,r:8,p:1,dkLen:32});return[new Kn(["scrypt",tr.encode(t),this.logN.toString()],CA(e,n))]}}class OA{passphrase;constructor(e){this.passphrase=e}unwrapFileKey(e){for(let t of e){if(t.args.length<1||t.args[0]!=="scrypt")continue;if(e.length!==1)throw Error("scrypt recipient is not the only one in the header");if(t.args.length!==3)throw Error("invalid scrypt stanza");if(!/^[1-9][0-9]*$/.test(t.args[2]))throw Error("invalid scrypt stanza");let r=tr.decode(t.args[1]);if(r.length!==16)throw Error("invalid scrypt stanza");let o=Number(t.args[2]);if(o>20)throw Error("scrypt work factor is too high");let n="age-encryption.org/v1/scrypt",i=new Uint8Array(n.length+16);i.set(new TextEncoder().encode(n)),i.set(r,n.length);let s=bk(this.passphrase,i,{N:2**o,r:8,p:1,dkLen:32}),a=PA(t.body,s);if(a!==null)return a}return null}}function CA(e,t){let r=new Uint8Array(12);return Hr(t,r).encrypt(e)}function PA(e,t){if(e.length!==32)throw Error("invalid stanza");let r=new Uint8Array(12);try{return Hr(t,r).decrypt(e)}catch{return null}}function EU(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var Hs=16,NA=(()=>65536)(),zA=(()=>NA+Hs)();function IU(e){let t=new Uint8Array(12),r=()=>{for(let s=t.length-2;s>=0;s--)if(t[s]++,t[s]!==0)break},o=!0,n=new Uint8Array(zA),i=0;return new TransformStream({transform(s,a){while(s.length>0){if(i===n.length){let u=Hr(e,t).decrypt(n);a.enqueue(u),r(),i=0,o=!1}let c=Math.min(n.length-i,s.length);n.set(s.subarray(0,c),i),i+=c,s=s.subarray(c)}},flush(s){t[11]=1;let a=Hr(e,t).decrypt(n.subarray(0,i));if(!o&&a.length===0)throw Error("final chunk is empty");s.enqueue(a)}})}function kU(e){if(e<Hs)throw Error("ciphertext is too small");if(e===Hs)return 0;let t=Math.floor(e/zA),r=e%zA;if(0<r&&r<=Hs)throw Error("ciphertext size is invalid");let o=e;return o-=t*Hs,o-=r>0?Hs:0,o}function AU(e){let t=new Uint8Array(12),r=()=>{for(let i=t.length-2;i>=0;i--)if(t[i]++,t[i]!==0)break},o=new Uint8Array(NA),n=0;return new TransformStream({transform(i,s){while(i.length>0){if(n===o.length){let c=Hr(e,t).encrypt(o);s.enqueue(c),r(),n=0}let a=Math.min(o.length-n,i.length);o.set(i.subarray(0,a),n),n+=a,i=i.subarray(a)}},flush(i){t[11]=1;let s=Hr(e,t).encrypt(o.subarray(0,n));i.enqueue(s)}})}function TU(e){let t=Math.max(1,Math.ceil(e/NA));return e+Hs*t}var Nd={};Ut(Nd,{decode:()=>Lae,encode:()=>Dae});function Dae(e){let t=[];t.push(`-----BEGIN AGE ENCRYPTED FILE-----
732
+ `)])}function EA(){return xU()}function xU(){let e=bo(32),t=Dr.encodeFromBytes("AGE-SECRET-KEY-",e).toUpperCase();return Promise.resolve(t)}async function Ng(e){let t;if(EU(e))t=e;else if(e.startsWith("AGE-SECRET-KEY-PQ-1")){let o=Dr.decodeToBytes(e);if(o.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||o.bytes.length!==32)throw Error("invalid identity");let n=wg.getPublicKey(o.bytes);return Dr.encode("age1pq",Dr.toWords(n),!1)}else{let o=Dr.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||o.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||o.bytes.length!==32)throw Error("invalid identity");t=o.bytes}let r=await zd(t);return Dr.encodeFromBytes("age",r)}class IA{recipient;constructor(e){let t=Dr.decodeToBytes(e);if(!e.startsWith("age1pq1")||t.prefix.toLowerCase()!=="age1pq"||t.bytes.length!==1216)throw Error("invalid recipient");this.recipient=t.bytes}wrapFileKey(e){let{cipherText:t,sharedSecret:r}=wg.encapsulate(this.recipient),o=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:n,nonce:i}=Dg(_U,r,o),s=Hr(n,i).encrypt(e);return[new Kn(["mlkem768x25519",tr.encode(t)],s)]}}class kA{identity;constructor(e){let t=Dr.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-PQ-1")||t.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||t.bytes.length!==32)throw Error("invalid identity");this.identity=t.bytes}unwrapFileKey(e){for(let t of e){if(t.args.length<1||t.args[0]!=="mlkem768x25519")continue;if(t.args.length!==2)throw Error("invalid mlkem768x25519 stanza");let r=tr.decode(t.args[1]);if(r.length!==1120)throw Error("invalid mlkem768x25519 stanza");if(t.body.length!==32)throw Error("invalid mlkem768x25519 stanza");let o=wg.decapsulate(r,this.identity),n=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:i,nonce:s}=Dg(_U,o,n);try{return Hr(i,s).decrypt(t.body)}catch{continue}}return null}}var _U=25722,zae=80,xA=16;function Dg(e,t,r){let o=Nae(e),n=zg(o,void 0,"psk_id_hash",new Uint8Array(0)),i=zg(o,void 0,"info_hash",r),s=new Uint8Array(1+n.length+i.length);s[0]=0,s.set(n,1),s.set(i,1+n.length);let a=zg(o,t,"secret",new Uint8Array(0)),c=_A(o,a,"key",s,32),u=_A(o,a,"base_nonce",s,12);return{key:c,nonce:u}}function Nae(e){let t=new Uint8Array(10);return t.set(new TextEncoder().encode("HPKE"),0),t[4]=e>>8&255,t[5]=e&255,t[6]=0,t[7]=1,t[8]=0,t[9]=3,t}function zg(e,t,r,o){let n=new Uint8Array(7+e.length+r.length+o.length),i=0;return n.set(new TextEncoder().encode("HPKE-v1"),i),i+=7,n.set(e,i),i+=e.length,n.set(new TextEncoder().encode(r),i),i+=r.length,n.set(o,i),rd(wt,n,t)}function _A(e,t,r,o,n){let i=new Uint8Array(9+e.length+r.length+o.length),s=0;return i[s]=n>>8&255,i[s+1]=n&255,s+=2,i.set(new TextEncoder().encode("HPKE-v1"),s),s+=7,i.set(e,s),s+=e.length,i.set(new TextEncoder().encode(r),s),s+=r.length,i.set(o,s),ak(wt,t,i,n)}function Dae(e){if(e.length!==Bc.lengths.publicKeyUncompressed)e=Bc.Point.fromBytes(e).toBytes(!1);let t=Bc.utils.randomSecretKey(),r=Bc.getPublicKey(t,!1),o=Bc.getSharedSecret(t,e,!0).subarray(1),n=new Uint8Array(r.length+e.length);n.set(r,0),n.set(e,r.length);let i=new Uint8Array(5);i.set(new TextEncoder().encode("KEM"),0),i[3]=xA>>8,i[4]=xA&255;let s=zg(i,void 0,"eae_prk",o),a=_A(i,s,"shared_secret",n,32);return{encapsulatedKey:r,sharedSecret:a}}class AA{recipient;constructor(e){let t=Dr.decodeToBytes(e);if(!e.startsWith("age1tag1")||t.prefix.toLowerCase()!=="age1tag"||t.bytes.length!==33)throw Error("invalid recipient");this.recipient=t.bytes}wrapFileKey(e){let{encapsulatedKey:t,sharedSecret:r}=Dae(this.recipient),o=new TextEncoder().encode("age-encryption.org/p256tag"),n=(()=>{let c=wt(this.recipient).subarray(0,4),u=new Uint8Array(t.length+c.length);return u.set(t,0),u.set(c,t.length),rd(wt,u,o).subarray(0,4)})(),{key:i,nonce:s}=Dg(xA,r,o),a=Hr(i,s).encrypt(e);return[new Kn(["p256tag",tr.encode(n),tr.encode(t)],a)]}}class TA{recipient;constructor(e){let t=Dr.decodeToBytes(e);if(!e.startsWith("age1tagpq1")||t.prefix.toLowerCase()!=="age1tagpq"||t.bytes.length!==1249)throw Error("invalid recipient");this.recipient=t.bytes}wrapFileKey(e){let{cipherText:t,sharedSecret:r}=PZ.encapsulate(this.recipient),o=new TextEncoder().encode("age-encryption.org/mlkem768p256tag"),n=(()=>{let c=wt(this.recipient.subarray(1184)).subarray(0,4),u=new Uint8Array(t.length+c.length);return u.set(t,0),u.set(c,t.length),rd(wt,u,o).subarray(0,4)})(),{key:i,nonce:s}=Dg(zae,r,o),a=Hr(i,s).encrypt(e);return[new Kn(["mlkem768p256tag",tr.encode(n),tr.encode(t)],a)]}}class $A{recipient;constructor(e){let t=Dr.decodeToBytes(e);if(!e.startsWith("age1")||t.prefix.toLowerCase()!=="age"||t.bytes.length!==32)throw Error("invalid recipient");this.recipient=t.bytes}async wrapFileKey(e){let t=bo(32),r=await zd(t),o=await Cg(t,this.recipient),n=new Uint8Array(r.length+this.recipient.length);n.set(r),n.set(this.recipient,r.length);let i=new TextEncoder().encode("age-encryption.org/v1/X25519"),s=gi(wt,o,n,i,32);return[new Kn(["X25519",tr.encode(r)],CA(e,s))]}}class Lg{identity;recipient;constructor(e){if(EU(e)){this.identity=e,this.recipient=zd(e);return}let t=Dr.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||t.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||t.bytes.length!==32)throw Error("invalid identity");this.identity=t.bytes,this.recipient=zd(t.bytes)}async unwrapFileKey(e){for(let t of e){if(t.args.length<1||t.args[0]!=="X25519")continue;if(t.args.length!==2)throw Error("invalid X25519 stanza");let r=tr.decode(t.args[1]);if(r.length!==32)throw Error("invalid X25519 stanza");let o=await Cg(this.identity,r),n=await this.recipient,i=new Uint8Array(r.length+n.length);i.set(r),i.set(n,r.length);let s=new TextEncoder().encode("age-encryption.org/v1/X25519"),a=gi(wt,o,i,s,32),c=PA(t.body,a);if(c!==null)return c}return null}}class RA{passphrase;logN;constructor(e,t){this.passphrase=e,this.logN=t}wrapFileKey(e){let t=bo(16),r="age-encryption.org/v1/scrypt",o=new Uint8Array(44);o.set(new TextEncoder().encode("age-encryption.org/v1/scrypt")),o.set(t,28);let n=bk(this.passphrase,o,{N:2**this.logN,r:8,p:1,dkLen:32});return[new Kn(["scrypt",tr.encode(t),this.logN.toString()],CA(e,n))]}}class OA{passphrase;constructor(e){this.passphrase=e}unwrapFileKey(e){for(let t of e){if(t.args.length<1||t.args[0]!=="scrypt")continue;if(e.length!==1)throw Error("scrypt recipient is not the only one in the header");if(t.args.length!==3)throw Error("invalid scrypt stanza");if(!/^[1-9][0-9]*$/.test(t.args[2]))throw Error("invalid scrypt stanza");let r=tr.decode(t.args[1]);if(r.length!==16)throw Error("invalid scrypt stanza");let o=Number(t.args[2]);if(o>20)throw Error("scrypt work factor is too high");let n="age-encryption.org/v1/scrypt",i=new Uint8Array(n.length+16);i.set(new TextEncoder().encode(n)),i.set(r,n.length);let s=bk(this.passphrase,i,{N:2**o,r:8,p:1,dkLen:32}),a=PA(t.body,s);if(a!==null)return a}return null}}function CA(e,t){let r=new Uint8Array(12);return Hr(t,r).encrypt(e)}function PA(e,t){if(e.length!==32)throw Error("invalid stanza");let r=new Uint8Array(12);try{return Hr(t,r).decrypt(e)}catch{return null}}function EU(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var Hs=16,NA=(()=>65536)(),zA=(()=>NA+Hs)();function IU(e){let t=new Uint8Array(12),r=()=>{for(let s=t.length-2;s>=0;s--)if(t[s]++,t[s]!==0)break},o=!0,n=new Uint8Array(zA),i=0;return new TransformStream({transform(s,a){while(s.length>0){if(i===n.length){let u=Hr(e,t).decrypt(n);a.enqueue(u),r(),i=0,o=!1}let c=Math.min(n.length-i,s.length);n.set(s.subarray(0,c),i),i+=c,s=s.subarray(c)}},flush(s){t[11]=1;let a=Hr(e,t).decrypt(n.subarray(0,i));if(!o&&a.length===0)throw Error("final chunk is empty");s.enqueue(a)}})}function kU(e){if(e<Hs)throw Error("ciphertext is too small");if(e===Hs)return 0;let t=Math.floor(e/zA),r=e%zA;if(0<r&&r<=Hs)throw Error("ciphertext size is invalid");let o=e;return o-=t*Hs,o-=r>0?Hs:0,o}function AU(e){let t=new Uint8Array(12),r=()=>{for(let i=t.length-2;i>=0;i--)if(t[i]++,t[i]!==0)break},o=new Uint8Array(NA),n=0;return new TransformStream({transform(i,s){while(i.length>0){if(n===o.length){let c=Hr(e,t).encrypt(o);s.enqueue(c),r(),n=0}let a=Math.min(o.length-n,i.length);o.set(i.subarray(0,a),n),n+=a,i=i.subarray(a)}},flush(i){t[11]=1;let s=Hr(e,t).encrypt(o.subarray(0,n));i.enqueue(s)}})}function TU(e){let t=Math.max(1,Math.ceil(e/NA));return e+Hs*t}var Nd={};Ut(Nd,{decode:()=>Bae,encode:()=>Lae});function Lae(e){let t=[];t.push(`-----BEGIN AGE ENCRYPTED FILE-----
733
733
  `);for(let r=0;r<e.length;r+=48){let o=r+48;if(o>e.length)o=e.length;t.push(mk.encode(e.subarray(r,o))+`
734
734
  `)}return t.push(`-----END AGE ENCRYPTED FILE-----
735
- `),t.join("")}function Lae(e){let t=e.trim().replaceAll(`\r
735
+ `),t.join("")}function Bae(e){let t=e.trim().replaceAll(`\r
736
736
  `,`
737
737
  `).split(`
738
- `);if(t.shift()!=="-----BEGIN AGE ENCRYPTED FILE-----")throw Error("invalid header");if(t.pop()!=="-----END AGE ENCRYPTED FILE-----")throw Error("invalid footer");function r(o,n){if(o===t.length-1)return n.length>0&&n.length<=64&&n.length%4===0;return n.length===64}if(!t.every((o,n)=>r(n,o)))throw Error("invalid line length");if(!t.every((o)=>/^[A-Za-z0-9+/=]+$/.test(o)))throw Error("invalid base64");return mk.decode(t.join(""))}class DA{passphrase=null;scryptWorkFactor=18;recipients=[];setPassphrase(e){if(this.passphrase!==null)throw Error("can encrypt to at most one passphrase");if(this.recipients.length!==0)throw Error("can't encrypt to both recipients and passphrases");this.passphrase=e}setScryptWorkFactor(e){this.scryptWorkFactor=e}addRecipient(e){if(this.passphrase!==null)throw Error("can't encrypt to both recipients and passphrases");if(typeof e==="string")if(e.startsWith("age1pq1"))this.recipients.push(new IA(e));else if(e.startsWith("age1tag1"))this.recipients.push(new AA(e));else if(e.startsWith("age1tagpq1"))this.recipients.push(new TA(e));else if(e.startsWith("age1"))this.recipients.push(new $A(e));else throw Error("unrecognized recipient type");else this.recipients.push(e)}async encrypt(e){let t=bo(16),r=[],o=this.recipients;if(this.passphrase!==null)o=[new RA(this.passphrase,this.scryptWorkFactor)];for(let m of o)r.push(...await m.wrapFileKey(t));let n=new TextEncoder().encode("header"),i=gi(wt,t,void 0,n,32),s=Bn(wt,i,wA(r)),a=wU(r,s),c=bo(16),u=new TextEncoder().encode("payload"),d=gi(wt,t,c,u,32),f=AU(d);if(!(e instanceof ReadableStream)){if(typeof e==="string")e=new TextEncoder().encode(e);return await vA(Zc(Pg(e).pipeThrough(f),a,c))}return Object.assign(Zc(e.pipeThrough(f),a,c),{size:(m)=>TU(m)+a.length+c.length})}}class LA{identities=[];addPassphrase(e){this.identities.push(new OA(e))}addIdentity(e){if(Uae(e))this.identities.push(new Lg(e));else if(typeof e==="string")if(e.startsWith("AGE-SECRET-KEY-1"))this.identities.push(new Lg(e));else if(e.startsWith("AGE-SECRET-KEY-PQ-1"))this.identities.push(new kA(e));else throw Error("unrecognized identity type");else this.identities.push(e)}async decrypt(e,t){let r=e instanceof ReadableStream?e:Pg(e),{fileKey:o,headerSize:n,rest:i}=await this.decryptHeaderInternal(r),{data:s,rest:a}=await SU(i,16),c=new TextEncoder().encode("payload"),u=gi(wt,o,s,c,32),d=IU(u),f=a.pipeThrough(d),m=Object.assign(f,{size:(h)=>kU(h-n-s.length)});if(e instanceof ReadableStream)return m;if(t==="text")return await bU(f);return await vA(f)}async decryptHeader(e){return(await this.decryptHeaderInternal(Pg(e))).fileKey}async decryptHeaderInternal(e){let t=await vU(e),r=await this.unwrapFileKey(t.stanzas);if(r===null)throw Error("no identity matched any of the file's recipients");let o=new TextEncoder().encode("header"),n=gi(wt,r,void 0,o,32),i=Bn(wt,n,t.headerNoMAC);if(!Zae(t.MAC,i))throw Error("invalid header HMAC");return{fileKey:r,headerSize:t.headerSize,rest:t.rest}}async unwrapFileKey(e){for(let t of this.identities){let r=await t.unwrapFileKey(e);if(r!==null)return r}return null}}function Zae(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function Uae(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}zn();function $U(e,t,r){if(r.length===0)return;e(`${t} (${r.length}):`);for(let o of r)e(` - ${o}`)}function BA(e,t,r){let o=t.filter((i)=>r(i)),n=t.filter((i)=>!r(i));$U(e,"Required before first deploy",o),$U(e,"Safe to ignore for now",n)}async function zi(e,t={}){let r=t.runCommand??Lt;(t.logger??console.log)(`Pushing ${e.length} secrets to GitHub Secrets...`),await Promise.all(e.map(([n,i])=>r("gh",["secret","set",n],{stdin:i})))}function Uc(e){let t=e?.trim().toLowerCase();if(!t)return;if(t==="gh"||t==="github")return"gh";if(t==="bw"||t==="bitwarden")return"bitwarden";throw Error(`Unsupported --push-to value: ${e}`)}zn();async function UA(e,t={}){try{let r=await OU(e,t);return{success:!0,message:r.createdLocalKey?`Age key ready at ${r.identityPath}`:`Age key already ready at ${r.identityPath}`}}catch(r){return{success:!1,message:Ge(r,"Age key bootstrap failed")}}}async function OU(e,t={}){let r=t.logger??console.log,o=RU(e,".brains-ops","age","identity.txt"),n=!1,i,s;if(qae(o))i=qc(jA(o,"utf8")),s=await Ng(i);else Mae(Fae(o),{recursive:!0,mode:448}),i=await EA(),s=await Ng(i),ZA(o,Kae(i,s),{encoding:"utf8",mode:384}),n=!0;Jae(RU(e,"pilot.yaml"),s);let a=Uc(t.pushTo);if(a)await zi([["AGE_SECRET_KEY",jA(o,"utf8")]],{logger:r,runCommand:t.runCommand??Lt});if(r(n?`Created ${o}`:`Reusing ${o}`),r(`Configured pilot.yaml agePublicKey ${s}`),a)r(`Pushed AGE_SECRET_KEY to ${a}`);return{createdLocalKey:n,identityPath:o,agePublicKey:s}}function Jae(e,t){let r=jA(e,"utf8"),o=r.match(/^agePublicKey:\s*(.+)$/m),n=o?.[1]?.trim().replace(/^['"]|['"]$/g,"");if(n===t)return;if(n&&n!=="age1replace-with-your-public-key")throw Error(`pilot.yaml agePublicKey does not match local age identity (${n} !== ${t})`);if(o){ZA(e,r.replace(/^agePublicKey:\s*.+$/m,`agePublicKey: ${t}`),"utf8");return}let i=r.endsWith(`
738
+ `);if(t.shift()!=="-----BEGIN AGE ENCRYPTED FILE-----")throw Error("invalid header");if(t.pop()!=="-----END AGE ENCRYPTED FILE-----")throw Error("invalid footer");function r(o,n){if(o===t.length-1)return n.length>0&&n.length<=64&&n.length%4===0;return n.length===64}if(!t.every((o,n)=>r(n,o)))throw Error("invalid line length");if(!t.every((o)=>/^[A-Za-z0-9+/=]+$/.test(o)))throw Error("invalid base64");return mk.decode(t.join(""))}class DA{passphrase=null;scryptWorkFactor=18;recipients=[];setPassphrase(e){if(this.passphrase!==null)throw Error("can encrypt to at most one passphrase");if(this.recipients.length!==0)throw Error("can't encrypt to both recipients and passphrases");this.passphrase=e}setScryptWorkFactor(e){this.scryptWorkFactor=e}addRecipient(e){if(this.passphrase!==null)throw Error("can't encrypt to both recipients and passphrases");if(typeof e==="string")if(e.startsWith("age1pq1"))this.recipients.push(new IA(e));else if(e.startsWith("age1tag1"))this.recipients.push(new AA(e));else if(e.startsWith("age1tagpq1"))this.recipients.push(new TA(e));else if(e.startsWith("age1"))this.recipients.push(new $A(e));else throw Error("unrecognized recipient type");else this.recipients.push(e)}async encrypt(e){let t=bo(16),r=[],o=this.recipients;if(this.passphrase!==null)o=[new RA(this.passphrase,this.scryptWorkFactor)];for(let m of o)r.push(...await m.wrapFileKey(t));let n=new TextEncoder().encode("header"),i=gi(wt,t,void 0,n,32),s=Bn(wt,i,wA(r)),a=wU(r,s),c=bo(16),u=new TextEncoder().encode("payload"),d=gi(wt,t,c,u,32),f=AU(d);if(!(e instanceof ReadableStream)){if(typeof e==="string")e=new TextEncoder().encode(e);return await vA(Zc(Pg(e).pipeThrough(f),a,c))}return Object.assign(Zc(e.pipeThrough(f),a,c),{size:(m)=>TU(m)+a.length+c.length})}}class LA{identities=[];addPassphrase(e){this.identities.push(new OA(e))}addIdentity(e){if(qae(e))this.identities.push(new Lg(e));else if(typeof e==="string")if(e.startsWith("AGE-SECRET-KEY-1"))this.identities.push(new Lg(e));else if(e.startsWith("AGE-SECRET-KEY-PQ-1"))this.identities.push(new kA(e));else throw Error("unrecognized identity type");else this.identities.push(e)}async decrypt(e,t){let r=e instanceof ReadableStream?e:Pg(e),{fileKey:o,headerSize:n,rest:i}=await this.decryptHeaderInternal(r),{data:s,rest:a}=await SU(i,16),c=new TextEncoder().encode("payload"),u=gi(wt,o,s,c,32),d=IU(u),f=a.pipeThrough(d),m=Object.assign(f,{size:(h)=>kU(h-n-s.length)});if(e instanceof ReadableStream)return m;if(t==="text")return await bU(f);return await vA(f)}async decryptHeader(e){return(await this.decryptHeaderInternal(Pg(e))).fileKey}async decryptHeaderInternal(e){let t=await vU(e),r=await this.unwrapFileKey(t.stanzas);if(r===null)throw Error("no identity matched any of the file's recipients");let o=new TextEncoder().encode("header"),n=gi(wt,r,void 0,o,32),i=Bn(wt,n,t.headerNoMAC);if(!Uae(t.MAC,i))throw Error("invalid header HMAC");return{fileKey:r,headerSize:t.headerSize,rest:t.rest}}async unwrapFileKey(e){for(let t of this.identities){let r=await t.unwrapFileKey(e);if(r!==null)return r}return null}}function Uae(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function qae(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}zn();function $U(e,t,r){if(r.length===0)return;e(`${t} (${r.length}):`);for(let o of r)e(` - ${o}`)}function BA(e,t,r){let o=t.filter((i)=>r(i)),n=t.filter((i)=>!r(i));$U(e,"Required before first deploy",o),$U(e,"Safe to ignore for now",n)}async function zi(e,t={}){let r=t.runCommand??Lt;(t.logger??console.log)(`Pushing ${e.length} secrets to GitHub Secrets...`),await Promise.all(e.map(([n,i])=>r("gh",["secret","set",n],{stdin:i})))}function Uc(e){let t=e?.trim().toLowerCase();if(!t)return;if(t==="gh"||t==="github")return"gh";if(t==="bw"||t==="bitwarden")return"bitwarden";throw Error(`Unsupported --push-to value: ${e}`)}zn();async function UA(e,t={}){try{let r=await OU(e,t);return{success:!0,message:r.createdLocalKey?`Age key ready at ${r.identityPath}`:`Age key already ready at ${r.identityPath}`}}catch(r){return{success:!1,message:Ge(r,"Age key bootstrap failed")}}}async function OU(e,t={}){let r=t.logger??console.log,o=RU(e,".brains-ops","age","identity.txt"),n=!1,i,s;if(Mae(o))i=qc(jA(o,"utf8")),s=await Ng(i);else Fae(Jae(o),{recursive:!0,mode:448}),i=await EA(),s=await Ng(i),ZA(o,Hae(i,s),{encoding:"utf8",mode:384}),n=!0;Kae(RU(e,"pilot.yaml"),s);let a=Uc(t.pushTo);if(a)await zi([["AGE_SECRET_KEY",jA(o,"utf8")]],{logger:r,runCommand:t.runCommand??Lt});if(r(n?`Created ${o}`:`Reusing ${o}`),r(`Configured pilot.yaml agePublicKey ${s}`),a)r(`Pushed AGE_SECRET_KEY to ${a}`);return{createdLocalKey:n,identityPath:o,agePublicKey:s}}function Kae(e,t){let r=jA(e,"utf8"),o=r.match(/^agePublicKey:\s*(.+)$/m),n=o?.[1]?.trim().replace(/^['"]|['"]$/g,"");if(n===t)return;if(n&&n!=="age1replace-with-your-public-key")throw Error(`pilot.yaml agePublicKey does not match local age identity (${n} !== ${t})`);if(o){ZA(e,r.replace(/^agePublicKey:\s*.+$/m,`agePublicKey: ${t}`),"utf8");return}let i=r.endsWith(`
739
739
  `)?`${r}agePublicKey: ${t}
740
740
  `:`${r}
741
741
  agePublicKey: ${t}
742
- `;ZA(e,i,"utf8")}function qc(e){let t=e.split(/\r?\n/).map((r)=>r.trim()).find((r)=>r.startsWith("AGE-SECRET-KEY-"));if(!t)throw Error("Missing AGE-SECRET-KEY in age identity file");return t}function Kae(e,t){return["# generated by brains-ops age-key:bootstrap",`# public key: ${t}`,e,""].join(`
743
- `)}ns();import{writeFile as Sce}from"fs/promises";import{join as MU}from"path";import{createSign as Wae,generateKeyPairSync as Gae}from"crypto";import{mkdir as Qae,writeFile as CU}from"fs/promises";import{join as PU}from"path";async function Hae(e){let t=await e.text();if(!t.trim())return;try{return JSON.parse(t)}catch{return t}}async function Mc(e,t,r){let o=await Hae(e),n=t.safeParse(o);if(!e.ok||!n.success){let i=r.formatError??Vae;throw Error(`${r.label}${i(e,o)}`)}return n.data}function Vae(e,t){let r=t===void 0?"":`: ${typeof t==="string"?t:JSON.stringify(t)}`;return` (${e.status} ${e.statusText}${r})`}he();var Yae="2.5.4.3",Xae="1.2.840.113549.1.1.11",DU="https://api.cloudflare.com/client/v4",ece="origin-rsa",tce=5475,LU=15000;function BU(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}var zU=l.looseObject({message:l.string().optional()}),rce=l.looseObject({errors:l.array(zU).optional(),messages:l.array(zU).optional()}),nce=l.looseObject({certificate:l.string().min(1),expires_on:l.string().optional()}),oce=l.looseObject({success:l.literal(!0),result:nce}),ice=l.looseObject({success:l.literal(!0)});function sce(){let{privateKey:e,publicKey:t}=Gae("rsa",{modulusLength:2048,privateKeyEncoding:{type:"pkcs8",format:"pem"},publicKeyEncoding:{type:"spki",format:"der"}});return{privateKeyPem:e,publicKeyDer:Buffer.from(t)}}function ace(e,t){let r=Dd(mce(Dd(NU(Yae),dce(e)))),o=Dd(uce(0),r,Buffer.from(t.publicKeyDer),hce(0,Buffer.alloc(0))),n=Wae("sha256").update(o).sign(t.privateKeyPem),i=Dd(o,Dd(NU(Xae),pce()),fce(n));return{csrPem:lce("CERTIFICATE REQUEST",i),certificationRequestInfoDer:o,signature:n}}async function cce(e,t,r,o){let n=await e(`${DU}/certificates`,{method:"POST",headers:BU(t),body:JSON.stringify({hostnames:[o,`*.${o}`],requested_validity:tce,request_type:ece,csr:r}),signal:AbortSignal.timeout(LU)}),i=await Mc(n,oce,{label:"Cloudflare Origin CA request failed",formatError:ZU}),a={certificatePem:`${i.result.certificate.trim()}
744
- `};if(i.result.expires_on)a.expiresOn=i.result.expires_on;return a}async function jU(e,t,r){let o=await e(`${DU}/zones/${r}/settings/ssl`,{method:"PATCH",headers:BU(t),body:JSON.stringify({value:"strict"}),signal:AbortSignal.timeout(LU)});await Mc(o,ice,{label:"Cloudflare zone SSL update failed",formatError:ZU})}function lce(e,t){let o=t.toString("base64").match(/.{1,64}/g)??[];return[`-----BEGIN ${e}-----`,...o,`-----END ${e}-----`,""].join(`
745
- `)}function uce(e){if(e!==0)throw Error("Only zero-valued INTEGER encoding is currently supported");return Buffer.from([2,1,0])}function NU(e){let t=e.split(".").map((s)=>Number(s));if(t.length<2||t.some((s)=>Number.isNaN(s)))throw Error(`Invalid OID: ${e}`);let r=t[0],o=t[1];if(r===void 0||o===void 0)throw Error(`Invalid OID: ${e}`);let i=[r*40+o];for(let s of t.slice(2)){let a=yce(s);i.push(...a)}return Fc(6,Buffer.from(i))}function dce(e){return Fc(12,Buffer.from(e,"utf8"))}function fce(e){return Fc(3,Buffer.concat([Buffer.from([0]),e]))}function pce(){return Buffer.from([5,0])}function Dd(...e){return Fc(48,Buffer.concat(e))}function mce(...e){return Fc(49,Buffer.concat(e))}function hce(e,t){return Fc(160+e,t)}function Fc(e,t){return Buffer.concat([Buffer.from([e]),gce(t.length),t])}function gce(e){if(e<128)return Buffer.from([e]);let t=[],r=e;while(r>0)t.unshift(r&255),r>>=8;return Buffer.from([128|t.length,...t])}function yce(e){if(!Number.isInteger(e)||e<0)throw Error(`Invalid OID component: ${e}`);if(e===0)return[0];let t=[],r=e;while(r>0)t.unshift(r&127),r>>=7;for(let o=0;o<t.length-1;o+=1)t[o]=(t[o]??0)|128;return t}function ZU(e,t){let r=bce(t),o=r.length>0?`: ${r.join("; ")}`:"";return` (${e.status} ${e.statusText}${o})`}function bce(e){let t=rce.safeParse(e);if(!t.success)return[];return[...t.data.errors??[],...t.data.messages??[]].map((r)=>r.message).filter((r)=>typeof r==="string"&&r.length>0)}async function UU(e,t,r){let o=sce(),{csrPem:n}=ace(r,o),i=await cce(e,t,n,r);return{certificatePem:i.certificatePem,privateKeyPem:o.privateKeyPem,...i.expiresOn!==void 0&&{expiresOn:i.expiresOn}}}async function qU(e,t){let r=PU(e,"origin.pem"),o=PU(e,"origin.key");return await Qae(e,{recursive:!0}),await Promise.all([CU(r,t.certificatePem,"utf-8"),CU(o,t.privateKeyPem,{encoding:"utf-8",mode:384})]),{certificatePath:r,privateKeyPath:o}}Mr();zn();async function qA(e,t={}){try{return await JU(e,t),{success:!0}}catch(r){return{success:!1,message:Ge(r,"Certificate bootstrap failed")}}}async function JU(e,t={}){let r=await ut(e),o=wce(r,t.handle),n=o.domain,i=t.env??process.env,s=on(e),a=t.cfApiToken??Dt("CF_API_TOKEN",i,s),c=t.cfZoneId??o.cloudflareZoneId??Dt("CF_ZONE_ID",i,s);if(!a)throw Error("Missing CF_API_TOKEN");if(!c)throw Error("Missing CF_ZONE_ID");let u=t.fetchImpl??fetch,d=t.logger??console.log,f=await UU(u,a,n),m=MU(e,".brains-ops","certs",o.id),{certificatePath:h,privateKeyPath:b}=await qU(m,f),y=MU(m,"secrets.yaml");await Sce(y,vce(f.certificatePem,f.privateKeyPem),"utf-8"),await jU(u,a,c);let S=Uc(t.pushTo);if(S)await zi([["CERTIFICATE_PEM",f.certificatePem],["PRIVATE_KEY_PEM",f.privateKeyPem]],{logger:d,runCommand:t.runCommand??Lt});if(d(`Issued ${o.id} Origin CA cert for ${n} and *.${n}`),d(`Wrote ${h}`),d(`Wrote ${b}`),d(`Wrote ${y}`),f.expiresOn)d(`Expires on ${f.expiresOn}`);if(d("Cloudflare zone SSL mode set to Full (strict)"),S)d(`Pushed CERTIFICATE_PEM and PRIVATE_KEY_PEM to ${S}`);return{domain:n,certificatePath:h,privateKeyPath:b,certificatePem:f.certificatePem,secretsSnippetPath:y}}function vce(e,t){return[`certificatePem: ${FU(e)}`,`privateKeyPem: ${FU(t)}`,""].join(`
746
- `)}function FU(e){return`"${e.replace(/"/g,"\\\"").replace(/\n/g,"\\n")}"`}function wce(e,t){if(!t)return{id:"shared",domain:xce(e.pilot.domainSuffix)};let r=e.users.find((o)=>o.handle===t);if(!r)throw Error(`Unknown user handle: ${t}`);return{id:t,domain:r.domain,...r.cloudflareZoneId?{cloudflareZoneId:r.cloudflareZoneId}:{}}}function xce(e){let t=e.trim().replace(/^\./,"").replace(/\.$/,"");if(!t||t.includes("*"))throw Error(`Invalid pilot domainSuffix: ${e}`);return t}Mr();Um();bE();Pn();import{lookup as _ce}from"dns/promises";function HU(e={}){let t=e.fetchImpl??fetch,r=e.lookupHost??_ce;return async function(n){let i=await Ece(n.domain,r),[s,a,c]=await Promise.all([KU(n.domain,"/health/ready",t),KU(n.domain,"/health/operate",t),Ice(n.domain,t)]);return{dnsStatus:i,serverStatus:s,deployStatus:a,mcpStatus:c}}}async function Ece(e,t){try{return(await t(e)).address?"ready":"failed"}catch{return"failed"}}async function KU(e,t,r){try{return(await VU(r,`https://${e}${t}`,{method:"GET"})).ok?"ready":"failed"}catch{return"failed"}}async function Ice(e,t){try{let r=await VU(t,`https://${e}/mcp`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{}})});return r.status===401||r.ok?"ready":"failed"}catch{return"failed"}}async function VU(e,t,r){let o=new AbortController,n=setTimeout(()=>o.abort(),5000);try{return await e(t,{...r,signal:o.signal})}finally{clearTimeout(n)}}import{createHash as kce}from"crypto";import{cp as Ace,lstat as Tce,mkdtemp as $ce,readFile as Rce,readdir as Oce,readlink as Cce,rm as Pce}from"fs/promises";import{tmpdir as zce}from"os";import{basename as Nce,join as Ld,relative as Dce,resolve as Lce,sep as Bce}from"path";var jce=new Set([".git",".operator",".brains-ops",".turbo","dist","node_modules"]);async function QU(e){let t=Lce(e),r=await $ce(Ld(zce(),"brains-ops-reconcile-")),o=Ld(r,"repo");try{await Ace(t,o,{recursive:!0,errorOnExist:!0,force:!1,filter:(a)=>Zce(t,a)});let n=await MA(o);await WU(o);let i=await MA(o);await WU(o);let s=await MA(o);return{firstPassChangedFiles:GU(n,i),secondPassChangedFiles:GU(i,s)}}finally{await Pce(r,{recursive:!0,force:!0})}}function Zce(e,t){let r=Dce(e,t);if(r.length===0)return!0;if(r.split(Bce).some((n)=>jce.has(n)))return!1;if(r===".env"||r===".env.local")return!1;return!Nce(r).endsWith(".secrets.yaml")}async function WU(e){await ed(e,void 0,{env:{},contentRepoRemoteResolver:()=>{return},fetchImpl:async()=>{throw Error("Dry-run reconcile attempted external HTTP access")},runCommand:async()=>{throw Error("Dry-run reconcile attempted a subprocess")}})}async function MA(e){let t=new Map;return await YU(e,"",t),t}async function YU(e,t,r){let o=Ld(e,t),n=await Oce(o,{withFileTypes:!0});n.sort((i,s)=>i.name.localeCompare(s.name));for(let i of n){let s=Ld(t,i.name),a=Ld(e,s);if(i.isDirectory()){await YU(e,s,r);continue}let u=(await Tce(a)).isSymbolicLink()?`symlink:${await Cce(a)}`:await Rce(a);r.set(s,kce("sha256").update(u).digest("hex"))}}function GU(e,t){return[...new Set([...e.keys(),...t.keys()])].filter((o)=>e.get(o)!==t.get(o)).sort()}ec();import{readFileSync as Bd}from"fs";import{access as Uce,rm as qce,writeFile as o6}from"fs/promises";import{join as FA,relative as e6}from"path";ns();no();function XU(e){return Object.keys(e)}he();var i6=l.strictObject({gitSyncToken:l.string().min(1).optional(),discordBotToken:l.string().min(1).optional(),discordPublicKey:l.string().min(1).optional(),discordApplicationId:l.string().min(1).optional(),aiApiKey:l.string().min(1).optional(),atprotoAppPassword:l.string().min(1).optional(),certificatePem:l.string().min(1).optional(),privateKeyPem:l.string().min(1).optional()});async function JA(e,t,r={}){let{registry:o,user:n}=await Ym(e,t),i=r.env??process.env,s=r.logger??console.log,a=on(e),c=FA(e,"users",`${t}.secrets.yaml.age`),u=FA(e,"users",`${t}.secrets.yaml`),d=n6(e6(e,c)),f=n6(e6(e,u)),m=Jce(u),h=await Kce(c,e,i,a),b=await s6(u),y={sharedAiApiKeySelector:o.pilot.aiApiKey,sharedGitSyncTokenSelector:o.pilot.gitSyncToken,effectiveAiApiKeySelector:n.effectiveAiApiKey,effectiveGitSyncTokenSelector:n.effectiveGitSyncToken,discordEnabled:n.discordEnabled},S;try{S=Mce(e,i,a,m,h,y)}catch(z){if(!r.dryRun&&m===void 0&&z instanceof Error){let K=Wce(y);if(K.length>0)throw await Gce(u,K),Error(`Missing required secrets for ${t}. Created ${f}; fill it in and rerun secrets:encrypt. ${z.message}`,{cause:z})}throw z}let x=`${ba(S).trimEnd()}
747
- `;Vce(x,S);let _=XU(S);if(r.dryRun){if(s(`Dry run: would encrypt ${_.length} secrets to ${d}.`),s(_.length>0?`Keys: ${_.join(", ")}`:"Keys: (none \u2014 shared defaults only)"),b)s(`Would remove plaintext file ${f}.`);return{encryptedPath:d,plaintextPath:f,deletedPlaintext:b,encryptedKeys:_,dryRun:!0}}let A=new DA;A.addRecipient(o.pilot.agePublicKey);let O=await A.encrypt(x),L=Nd.encode(O);if(await o6(c,L),await qce(u,{force:!0}),s(`Encrypted ${_.length} secrets to ${d}.`),b)s(`Removed plaintext file ${f}.`);return{encryptedPath:d,plaintextPath:f,deletedPlaintext:b,encryptedKeys:_}}function Mce(e,t,r,o,n,i){let s=t6(e,t,r,o,n,"aiApiKey",i.effectiveAiApiKeySelector,i.sharedAiApiKeySelector),a=t6(e,t,r,o,n,"gitSyncToken",i.effectiveGitSyncTokenSelector,i.sharedGitSyncTokenSelector),c=i.discordEnabled?Bg(e,t,r,o,n,"discordBotToken","DISCORD_BOT_TOKEN"):void 0,u=i.discordEnabled?Bg(e,t,r,o,n,"discordPublicKey","DISCORD_PUBLIC_KEY"):void 0,d=i.discordEnabled?Bg(e,t,r,o,n,"discordApplicationId","DISCORD_APPLICATION_ID"):void 0,f=jg(e,t,r,o,n,"atprotoAppPassword","ATPROTO_APP_PASSWORD"),m=r6(jg(e,t,r,o,n,"certificatePem","CERTIFICATE_PEM")),h=r6(jg(e,t,r,o,n,"privateKeyPem","PRIVATE_KEY_PEM"));return i6.parse({...s?{aiApiKey:s}:{},...a?{gitSyncToken:a}:{},...c?{discordBotToken:c}:{},...u?{discordPublicKey:u}:{},...d?{discordApplicationId:d}:{},...f?{atprotoAppPassword:f}:{},...m?{certificatePem:m}:{},...h?{privateKeyPem:h}:{}})}function t6(e,t,r,o,n,i,s,a){if(s===a)return;return Bg(e,t,r,o,n,i,s)}function Bg(e,t,r,o,n,i,s){let a=jg(e,t,r,o,n,i,s);if(a===void 0||a.trim().length===0)throw Error(`Missing required secret value for ${String(i)}. Set it in users/<handle>.secrets.yaml or fall back to ${s}/${s}_FILE before running secrets:encrypt.`);return a}function r6(e){return e?.replace(/\r\n?|\n/g,"\\n")}function jg(e,t,r,o,n,i,s){return Fce(o,n,i,s,t,r,e)}function Fce(e,t,r,o,n,i,s){let a=e?.[r];if(a!==void 0&&a.trim().length>0)return a;let c=Dt(`${o}_FILE`,n,i);if(c&&c.trim().length>0)return Bd(Jo(c,s),"utf8");let u=Dt(o,n,i);if(u!==void 0&&u.trim().length>0)return u;let d=t?.[r];if(d!==void 0&&d.trim().length>0)return d;return}function Jce(e){let t;try{t=Bd(e,"utf8")}catch{return}try{return KA(t)}catch(r){throw Error(`Unable to parse plaintext secrets file ${e}: ${Ge(r)}`,{cause:r})}}async function Kce(e,t,r,o){if(!await s6(e))return;let n=Hce(t,r,o);if(!n)return;let i;try{let s=Bd(e,"utf8"),a=Nd.decode(s),c=new LA;c.addIdentity(n),i=await c.decrypt(a,"text")}catch{return}try{return KA(i)}catch(s){throw Error(`Unable to parse decrypted secrets from ${e}: ${Ge(s)}`,{cause:s})}}function Hce(e,t,r){let o=Dt("AGE_SECRET_KEY_FILE",t,r);if(o&&o.trim().length>0)return qc(Bd(Jo(o,e),"utf8"));let n=Dt("AGE_SECRET_KEY",t,r);if(n&&n.trim().length>0)return qc(n);try{return qc(Bd(FA(e,".brains-ops","age","identity.txt"),"utf8"))}catch{return}}function KA(e){let t=bO(e),r={};if(t!==null&&typeof t==="object"&&!Array.isArray(t)){for(let[o,n]of Object.entries(t))if(typeof n==="string")r[o]=n}return i6.partial().parse(r)}function Vce(e,t){let r={...t},o={...KA(e)},n=new Set([...Object.keys(r),...Object.keys(o)]);for(let i of n)if(r[i]!==o[i])throw Error(`secrets:encrypt round-trip verification failed for ${i}; refusing to write a corrupted encrypted payload`)}function Wce(e){return[...e.effectiveAiApiKeySelector!==e.sharedAiApiKeySelector?["aiApiKey"]:[],...e.effectiveGitSyncTokenSelector!==e.sharedGitSyncTokenSelector?["gitSyncToken"]:[],...e.discordEnabled?["discordBotToken","discordPublicKey","discordApplicationId"]:[]]}async function Gce(e,t){let r=["# local per-user secret staging file","# fill values, run `bunx brains-ops secrets:encrypt . <handle>`, then the plaintext file will be removed",...t.map((o)=>`${o}: `),""].join(`
748
- `);await o6(e,r,{flag:"wx"})}async function s6(e){try{return await Uce(e),!0}catch{return!1}}function n6(e){return e.replaceAll("\\","/")}ns();import{readFileSync as Qce}from"fs";zn();async function HA(e,t={}){let r=t.env??process.env,o=t.logger??console.log,n=on(e),i=ob(`${e}/.env.schema`),s=Xce(i),a=[],c=[],u=new Map;for(let f of s){u.set(f.key,f.required);let m=ele(f.key,r,n,e);if(m===void 0||m.trim().length===0){c.push(f.key);continue}a.push([f.key,m])}if(a.length===0)throw Error("No pushable local secrets found for this pilot repo");let d=(f)=>u.get(f)??!1;if(t.dryRun)return o(`Dry run: would push ${a.length} secrets to GitHub Secrets.`),o(`Secrets: ${a.map(([f])=>f).join(", ")}`),BA(o,c,d),{pushedKeys:a.map(([f])=>f),skippedKeys:c,dryRun:!0};return await zi(a,{logger:o,runCommand:t.runCommand??Lt}),BA(o,c,d),{pushedKeys:a.map(([f])=>f),skippedKeys:c}}var Yce=new Set(["DISCORD_BOT_TOKEN","DISCORD_PUBLIC_KEY","DISCORD_APPLICATION_ID"]);function Xce(e){return e.filter((t)=>!Yce.has(t.key)).map((t)=>({key:t.key,required:t.required}))}function ele(e,t,r,o){let n=Dt(`${e}_FILE`,t,r);if(n&&n.trim().length>0)return Qce(Jo(n,o),"utf8");let i=Dt(e,t,r);if(i===void 0||i.trim().length===0)return;return i}he();import{execFileSync as a6}from"child_process";import{chmodSync as tle,existsSync as rle,mkdirSync as nle,readFileSync as c6,writeFileSync as ole}from"fs";import{dirname as ile,join as sle}from"path";import{homedir as ale}from"os";sb();zn();var l6=l.object({id:l.number(),name:l.string(),public_key:l.string()}),cle=l.object({ssh_keys:l.array(l6)}),lle={createEd25519KeyPair(e,t){a6("ssh-keygen",["-t","ed25519","-f",e,"-C",t,"-N",""],{stdio:"ignore"})},derivePublicKey(e){return a6("ssh-keygen",["-y","-f",e],{encoding:"utf-8",stdio:["ignore","pipe","inherit"]}).trim()}};async function Zg(e,t={}){try{let r=await VA(e,t);return{success:!0,message:r.createdLocalKey?`SSH deploy key ready at ${r.privateKeyPath}`:`SSH deploy key already ready at ${r.privateKeyPath}`}}catch(r){return{success:!1,message:Ge(r,"SSH key bootstrap failed")}}}async function VA(e,t={}){let r=t.env??process.env,o=on(e),n=t.logger??console.log,i=t.fetchImpl??fetch,s=t.sshKeygen??lle,a=Dt("HCLOUD_TOKEN",r,o);if(!a)throw Error("Missing HCLOUD_TOKEN");let c=Dt("HCLOUD_SSH_KEY_NAME",r,o);if(!c)throw Error("Missing HCLOUD_SSH_KEY_NAME");let u=Dt("KAMAL_SSH_PRIVATE_KEY_FILE",r,o),d=u?Jo(u,e):sle(ale(),".ssh",`${dle(c)}_ed25519`),f=`${d}.pub`,m=!1;if(!rle(d))nle(ile(d),{recursive:!0,mode:448}),s.createEd25519KeyPair(d,c),m=!0;tle(d,384);let h;if(m)h=c6(f,"utf-8").trim();else h=s.derivePublicKey(d),ole(f,`${h}
749
- `,"utf-8");if(h.length===0)throw Error(`Unable to derive a public key from ${d}`);let b=await ule({fetchImpl:i,hcloudToken:a,publicKey:h,sshKeyName:c}),y=Uc(t.pushTo);if(y)await zi([["KAMAL_SSH_PRIVATE_KEY",c6(d,"utf-8")]],{logger:n,runCommand:t.runCommand??Lt});if(n(m?`Created ${d}`:`Reusing ${d}`),n(b?`Registered Hetzner SSH key ${c}`:`Hetzner SSH key ${c} already exists`),y)n(`Pushed KAMAL_SSH_PRIVATE_KEY to ${y}`);return{createdHetznerKey:b,createdLocalKey:m,privateKeyPath:d,publicKeyPath:f,sshKeyName:c}}async function ule(e){let t=new URL("https://api.hetzner.cloud/v1/ssh_keys");t.searchParams.set("name",e.sshKeyName);let r=await e.fetchImpl(t.toString(),{headers:{Authorization:`Bearer ${e.hcloudToken}`,"Content-Type":"application/json"}}),{ssh_keys:o}=await Mc(r,cle,{label:"Hetzner SSH key lookup failed"}),[n]=o;if(n){if(n.public_key.trim()!==e.publicKey)throw Error(`Existing Hetzner SSH key ${e.sshKeyName} does not match the local public key`);return!1}let i=await e.fetchImpl("https://api.hetzner.cloud/v1/ssh_keys",{method:"POST",headers:{Authorization:`Bearer ${e.hcloudToken}`,"Content-Type":"application/json"},body:JSON.stringify({name:e.sshKeyName,public_key:e.publicKey})});return await Mc(i,l.object({ssh_key:l6}),{label:"Hetzner SSH key create failed"}),!0}function dle(e){return e.replace(/[^A-Za-z0-9._-]+/g,"_")}he();Mr();var fle=l.looseObject({status:l.string(),operationalStatus:l.string(),checks:l.array(l.looseObject({name:l.string(),status:l.string(),message:l.string().optional()})).default([]),app:l.looseObject({daemons:l.array(l.looseObject({name:l.string().optional(),status:l.string().optional(),health:l.looseObject({status:l.string().optional(),message:l.string().optional()}).optional()})).default([])}).default({daemons:[]})});async function WA(e,t,r={}){let o=r.fetchImpl??fetch,i=(await ut(e)).users.find((m)=>m.handle===t);if(!i)throw Error(`Unknown pilot user: ${t}`);let s=`https://${i.domain}`,a=[],c=[],u=l.number().int().positive().max(30).parse(r.operationalRetryAttempts??6),d=l.number().int().nonnegative().max(60000).parse(r.operationalRetryDelayMs??1e4),f=r.sleep??((m)=>new Promise((h)=>setTimeout(h,m)));if(await Ug("health",()=>ple(o,s,u,d,f),a,c),await Ug("mcp-auth-gate",()=>gle(o,s),a,c),i.bundles.includes("site"))await Ug("site",()=>u6(o,`${s}/`,"site"),a,c),await Ug("studio",()=>u6(o,`${s}/studio`,"studio"),a,c),r.logger?.("WARN Manual check still required: passkey setup/handoff completed from the setup email.");return{handle:i.handle,bundles:i.bundles,domain:i.domain,contentRepo:i.contentRepo,checks:a,failedChecks:c}}async function Ug(e,t,r,o){try{await t(),r.push(e)}catch(n){o.push({name:e,message:Ge(n)})}}async function ple(e,t,r,o,n){let i;for(let s=1;s<=r;s++)try{await mle(e,t);return}catch(a){if(i=a,s<r)await n(o)}throw i}async function mle(e,t){let o=await GA(e,`${t}/health/operate`,{method:"GET"}),n=await o.json().catch(()=>null),i=fle.safeParse(n);if(!o.ok){let a=i.success?i.data.checks.filter((c)=>c.status!=="healthy").slice(0,10).map((c)=>`${c.name}: ${hle(c.message??c.status)}`):[];throw Error(`/health/operate returned ${o.status}, expected 200${a.length>0?` (${a.join("; ")})`:""}`)}if(!i.success)throw Error(`/health/operate response did not match expected shape: ${i.error.message}`);let s=i.data;if(s.status!=="ready")throw Error(`/health/operate status is ${s.status}, expected ready`);if(s.operationalStatus!=="operational")throw Error(`/health/operate operationalStatus is ${s.operationalStatus}, expected operational`);for(let a of s.app.daemons){let c=a.status??"unknown",u=a.health?.status;if(c==="error"||u==="unhealthy")throw Error(`daemon ${a.name??"unknown"} is unhealthy (${c}/${u??"unknown"})`)}}function hle(e){let t=e.replaceAll(/\s+/g," ").trim();return t.length<=300?t:`${t.slice(0,297)}...`}async function gle(e,t){let r=await GA(e,`${t}/mcp`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize"})});if(r.status<400||r.status>=500)throw Error(`unauthenticated POST /mcp returned ${r.status}, expected a 4xx auth failure`)}async function u6(e,t,r){let o=await GA(e,t,{method:"GET"});if(o.status>=400)throw Error(`${r} ${t} returned ${o.status}, expected < 400`)}async function GA(e,t,r){let o=new AbortController,n=setTimeout(()=>o.abort(),20000);try{return await e(t,{...r,redirect:"follow",signal:o.signal})}finally{clearTimeout(n)}}var y5="brains-ops",gR={type:"string",placeholder:"<target>",description:"Push target (`gh` or `github`)"},Xy={type:"boolean",description:"Show what would happen without writing anything"};function bt(e){return{success:!1,message:SB(y5,e)}}var b5=ot({name:"init",usage:"<repo>",description:"Create a pilot repo skeleton",run:async({args:e})=>{let t=e[0];if(!t)return bt(b5);return await pE(t),{success:!0,message:`Initialized ${t}`}}}),S5=ot({name:"upgrade",usage:"<repo>",description:"Bump @rizom/ops and refresh the generated scaffold",flags:{to:{type:"string",placeholder:"<version>",description:"Explicit @rizom/ops version (`latest` by default)"}},run:async({args:e,flags:t})=>{let r=e[0];if(!r)return bt(S5);let o=nt(t,"to"),{upgradePilotRepo:n}=await Promise.resolve().then(() => (p6(),f6)),{from:i,to:s}=await n(r,{...o&&o!=="latest"?{version:o}:{}});return{success:!0,message:i===s?`Already at @rizom/ops@${s}; scaffold refreshed`:`Upgraded @rizom/ops ${i} -> ${s}; scaffold refreshed`}}}),v5=ot({name:"images:lock",usage:"<repo> [--brain-version <version>] [--site-packages <pins>]",description:"Create immutable runtime dependency locks for operator review (no build or deploy)",flags:{"brain-version":{type:"string",placeholder:"<version>",description:"Lock one exact Brain version instead of the declared fleet"},"site-packages":{type:"string",placeholder:"<pins>",description:"Exact site/theme pins for an explicit Brain version"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=nt(t,"brain-version"),i=nt(t,"site-packages");if(!o||i!==void 0&&!n)return bt(v5);if(n!==void 0)$t.parse(n);let{users:s}=await ut(o),a=await Zm({users:s,brainVersionInput:n,sitePackagesInput:i,imageExists:async()=>!1,verifyImage:async()=>{throw Error("Lock generation must not inspect images")}}),c=[];for(let u of a){let d=await MN(o,u,r.imageLockRunCommand);c.push(`${d}: ${u.tag}`)}return{success:!0,message:["Review and commit runtime dependency locks before building:",...c].join(`
742
+ `;ZA(e,i,"utf8")}function qc(e){let t=e.split(/\r?\n/).map((r)=>r.trim()).find((r)=>r.startsWith("AGE-SECRET-KEY-"));if(!t)throw Error("Missing AGE-SECRET-KEY in age identity file");return t}function Hae(e,t){return["# generated by brains-ops age-key:bootstrap",`# public key: ${t}`,e,""].join(`
743
+ `)}ns();import{writeFile as vce}from"fs/promises";import{join as MU}from"path";import{createSign as Gae,generateKeyPairSync as Qae}from"crypto";import{mkdir as Yae,writeFile as CU}from"fs/promises";import{join as PU}from"path";async function Vae(e){let t=await e.text();if(!t.trim())return;try{return JSON.parse(t)}catch{return t}}async function Mc(e,t,r){let o=await Vae(e),n=t.safeParse(o);if(!e.ok||!n.success){let i=r.formatError??Wae;throw Error(`${r.label}${i(e,o)}`)}return n.data}function Wae(e,t){let r=t===void 0?"":`: ${typeof t==="string"?t:JSON.stringify(t)}`;return` (${e.status} ${e.statusText}${r})`}he();var Xae="2.5.4.3",ece="1.2.840.113549.1.1.11",DU="https://api.cloudflare.com/client/v4",tce="origin-rsa",rce=5475,LU=15000;function BU(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}var zU=l.looseObject({message:l.string().optional()}),nce=l.looseObject({errors:l.array(zU).optional(),messages:l.array(zU).optional()}),oce=l.looseObject({certificate:l.string().min(1),expires_on:l.string().optional()}),ice=l.looseObject({success:l.literal(!0),result:oce}),sce=l.looseObject({success:l.literal(!0)});function ace(){let{privateKey:e,publicKey:t}=Qae("rsa",{modulusLength:2048,privateKeyEncoding:{type:"pkcs8",format:"pem"},publicKeyEncoding:{type:"spki",format:"der"}});return{privateKeyPem:e,publicKeyDer:Buffer.from(t)}}function cce(e,t){let r=Dd(hce(Dd(NU(Xae),fce(e)))),o=Dd(dce(0),r,Buffer.from(t.publicKeyDer),gce(0,Buffer.alloc(0))),n=Gae("sha256").update(o).sign(t.privateKeyPem),i=Dd(o,Dd(NU(ece),mce()),pce(n));return{csrPem:uce("CERTIFICATE REQUEST",i),certificationRequestInfoDer:o,signature:n}}async function lce(e,t,r,o){let n=await e(`${DU}/certificates`,{method:"POST",headers:BU(t),body:JSON.stringify({hostnames:[o,`*.${o}`],requested_validity:rce,request_type:tce,csr:r}),signal:AbortSignal.timeout(LU)}),i=await Mc(n,ice,{label:"Cloudflare Origin CA request failed",formatError:ZU}),a={certificatePem:`${i.result.certificate.trim()}
744
+ `};if(i.result.expires_on)a.expiresOn=i.result.expires_on;return a}async function jU(e,t,r){let o=await e(`${DU}/zones/${r}/settings/ssl`,{method:"PATCH",headers:BU(t),body:JSON.stringify({value:"strict"}),signal:AbortSignal.timeout(LU)});await Mc(o,sce,{label:"Cloudflare zone SSL update failed",formatError:ZU})}function uce(e,t){let o=t.toString("base64").match(/.{1,64}/g)??[];return[`-----BEGIN ${e}-----`,...o,`-----END ${e}-----`,""].join(`
745
+ `)}function dce(e){if(e!==0)throw Error("Only zero-valued INTEGER encoding is currently supported");return Buffer.from([2,1,0])}function NU(e){let t=e.split(".").map((s)=>Number(s));if(t.length<2||t.some((s)=>Number.isNaN(s)))throw Error(`Invalid OID: ${e}`);let r=t[0],o=t[1];if(r===void 0||o===void 0)throw Error(`Invalid OID: ${e}`);let i=[r*40+o];for(let s of t.slice(2)){let a=bce(s);i.push(...a)}return Fc(6,Buffer.from(i))}function fce(e){return Fc(12,Buffer.from(e,"utf8"))}function pce(e){return Fc(3,Buffer.concat([Buffer.from([0]),e]))}function mce(){return Buffer.from([5,0])}function Dd(...e){return Fc(48,Buffer.concat(e))}function hce(...e){return Fc(49,Buffer.concat(e))}function gce(e,t){return Fc(160+e,t)}function Fc(e,t){return Buffer.concat([Buffer.from([e]),yce(t.length),t])}function yce(e){if(e<128)return Buffer.from([e]);let t=[],r=e;while(r>0)t.unshift(r&255),r>>=8;return Buffer.from([128|t.length,...t])}function bce(e){if(!Number.isInteger(e)||e<0)throw Error(`Invalid OID component: ${e}`);if(e===0)return[0];let t=[],r=e;while(r>0)t.unshift(r&127),r>>=7;for(let o=0;o<t.length-1;o+=1)t[o]=(t[o]??0)|128;return t}function ZU(e,t){let r=Sce(t),o=r.length>0?`: ${r.join("; ")}`:"";return` (${e.status} ${e.statusText}${o})`}function Sce(e){let t=nce.safeParse(e);if(!t.success)return[];return[...t.data.errors??[],...t.data.messages??[]].map((r)=>r.message).filter((r)=>typeof r==="string"&&r.length>0)}async function UU(e,t,r){let o=ace(),{csrPem:n}=cce(r,o),i=await lce(e,t,n,r);return{certificatePem:i.certificatePem,privateKeyPem:o.privateKeyPem,...i.expiresOn!==void 0&&{expiresOn:i.expiresOn}}}async function qU(e,t){let r=PU(e,"origin.pem"),o=PU(e,"origin.key");return await Yae(e,{recursive:!0}),await Promise.all([CU(r,t.certificatePem,"utf-8"),CU(o,t.privateKeyPem,{encoding:"utf-8",mode:384})]),{certificatePath:r,privateKeyPath:o}}Mr();zn();async function qA(e,t={}){try{return await JU(e,t),{success:!0}}catch(r){return{success:!1,message:Ge(r,"Certificate bootstrap failed")}}}async function JU(e,t={}){let r=await ut(e),o=xce(r,t.handle),n=o.domain,i=t.env??process.env,s=on(e),a=t.cfApiToken??Dt("CF_API_TOKEN",i,s),c=t.cfZoneId??o.cloudflareZoneId??Dt("CF_ZONE_ID",i,s);if(!a)throw Error("Missing CF_API_TOKEN");if(!c)throw Error("Missing CF_ZONE_ID");let u=t.fetchImpl??fetch,d=t.logger??console.log,f=await UU(u,a,n),m=MU(e,".brains-ops","certs",o.id),{certificatePath:h,privateKeyPath:b}=await qU(m,f),y=MU(m,"secrets.yaml");await vce(y,wce(f.certificatePem,f.privateKeyPem),"utf-8"),await jU(u,a,c);let S=Uc(t.pushTo);if(S)await zi([["CERTIFICATE_PEM",f.certificatePem],["PRIVATE_KEY_PEM",f.privateKeyPem]],{logger:d,runCommand:t.runCommand??Lt});if(d(`Issued ${o.id} Origin CA cert for ${n} and *.${n}`),d(`Wrote ${h}`),d(`Wrote ${b}`),d(`Wrote ${y}`),f.expiresOn)d(`Expires on ${f.expiresOn}`);if(d("Cloudflare zone SSL mode set to Full (strict)"),S)d(`Pushed CERTIFICATE_PEM and PRIVATE_KEY_PEM to ${S}`);return{domain:n,certificatePath:h,privateKeyPath:b,certificatePem:f.certificatePem,secretsSnippetPath:y}}function wce(e,t){return[`certificatePem: ${FU(e)}`,`privateKeyPem: ${FU(t)}`,""].join(`
746
+ `)}function FU(e){return`"${e.replace(/"/g,"\\\"").replace(/\n/g,"\\n")}"`}function xce(e,t){if(!t)return{id:"shared",domain:_ce(e.pilot.domainSuffix)};let r=e.users.find((o)=>o.handle===t);if(!r)throw Error(`Unknown user handle: ${t}`);return{id:t,domain:r.domain,...r.cloudflareZoneId?{cloudflareZoneId:r.cloudflareZoneId}:{}}}function _ce(e){let t=e.trim().replace(/^\./,"").replace(/\.$/,"");if(!t||t.includes("*"))throw Error(`Invalid pilot domainSuffix: ${e}`);return t}Mr();Um();bE();Pn();import{lookup as Ece}from"dns/promises";function HU(e={}){let t=e.fetchImpl??fetch,r=e.lookupHost??Ece;return async function(n){let i=await Ice(n.domain,r),[s,a,c]=await Promise.all([KU(n.domain,"/health/ready",t),KU(n.domain,"/health/operate",t),kce(n.domain,t)]);return{dnsStatus:i,serverStatus:s,deployStatus:a,mcpStatus:c}}}async function Ice(e,t){try{return(await t(e)).address?"ready":"failed"}catch{return"failed"}}async function KU(e,t,r){try{return(await VU(r,`https://${e}${t}`,{method:"GET"})).ok?"ready":"failed"}catch{return"failed"}}async function kce(e,t){try{let r=await VU(t,`https://${e}/mcp`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{}})});return r.status===401||r.ok?"ready":"failed"}catch{return"failed"}}async function VU(e,t,r){let o=new AbortController,n=setTimeout(()=>o.abort(),5000);try{return await e(t,{...r,signal:o.signal})}finally{clearTimeout(n)}}import{createHash as Ace}from"crypto";import{cp as Tce,lstat as $ce,mkdtemp as Rce,readFile as Oce,readdir as Cce,readlink as Pce,rm as zce}from"fs/promises";import{tmpdir as Nce}from"os";import{basename as Dce,join as Ld,relative as Lce,resolve as Bce,sep as jce}from"path";var Zce=new Set([".git",".operator",".brains-ops",".turbo","dist","node_modules"]);async function QU(e){let t=Bce(e),r=await Rce(Ld(Nce(),"brains-ops-reconcile-")),o=Ld(r,"repo");try{await Tce(t,o,{recursive:!0,errorOnExist:!0,force:!1,filter:(a)=>Uce(t,a)});let n=await MA(o);await WU(o);let i=await MA(o);await WU(o);let s=await MA(o);return{firstPassChangedFiles:GU(n,i),secondPassChangedFiles:GU(i,s)}}finally{await zce(r,{recursive:!0,force:!0})}}function Uce(e,t){let r=Lce(e,t);if(r.length===0)return!0;if(r.split(jce).some((n)=>Zce.has(n)))return!1;if(r===".env"||r===".env.local")return!1;return!Dce(r).endsWith(".secrets.yaml")}async function WU(e){await ed(e,void 0,{env:{},contentRepoRemoteResolver:()=>{return},fetchImpl:async()=>{throw Error("Dry-run reconcile attempted external HTTP access")},runCommand:async()=>{throw Error("Dry-run reconcile attempted a subprocess")}})}async function MA(e){let t=new Map;return await YU(e,"",t),t}async function YU(e,t,r){let o=Ld(e,t),n=await Cce(o,{withFileTypes:!0});n.sort((i,s)=>i.name.localeCompare(s.name));for(let i of n){let s=Ld(t,i.name),a=Ld(e,s);if(i.isDirectory()){await YU(e,s,r);continue}let u=(await $ce(a)).isSymbolicLink()?`symlink:${await Pce(a)}`:await Oce(a);r.set(s,Ace("sha256").update(u).digest("hex"))}}function GU(e,t){return[...new Set([...e.keys(),...t.keys()])].filter((o)=>e.get(o)!==t.get(o)).sort()}ec();import{readFileSync as Bd}from"fs";import{access as qce,rm as Mce,writeFile as o6}from"fs/promises";import{join as FA,relative as e6}from"path";ns();no();function XU(e){return Object.keys(e)}he();var i6=l.strictObject({gitSyncToken:l.string().min(1).optional(),discordBotToken:l.string().min(1).optional(),discordPublicKey:l.string().min(1).optional(),discordApplicationId:l.string().min(1).optional(),aiApiKey:l.string().min(1).optional(),atprotoAppPassword:l.string().min(1).optional(),certificatePem:l.string().min(1).optional(),privateKeyPem:l.string().min(1).optional()});async function JA(e,t,r={}){let{registry:o,user:n}=await Ym(e,t),i=r.env??process.env,s=r.logger??console.log,a=on(e),c=FA(e,"users",`${t}.secrets.yaml.age`),u=FA(e,"users",`${t}.secrets.yaml`),d=n6(e6(e,c)),f=n6(e6(e,u)),m=Kce(u),h=await Hce(c,e,i,a),b=await s6(u),y={sharedAiApiKeySelector:o.pilot.aiApiKey,sharedGitSyncTokenSelector:o.pilot.gitSyncToken,effectiveAiApiKeySelector:n.effectiveAiApiKey,effectiveGitSyncTokenSelector:n.effectiveGitSyncToken,discordEnabled:n.discordEnabled},S;try{S=Fce(e,i,a,m,h,y)}catch(z){if(!r.dryRun&&m===void 0&&z instanceof Error){let K=Gce(y);if(K.length>0)throw await Qce(u,K),Error(`Missing required secrets for ${t}. Created ${f}; fill it in and rerun secrets:encrypt. ${z.message}`,{cause:z})}throw z}let x=`${ba(S).trimEnd()}
747
+ `;Wce(x,S);let _=XU(S);if(r.dryRun){if(s(`Dry run: would encrypt ${_.length} secrets to ${d}.`),s(_.length>0?`Keys: ${_.join(", ")}`:"Keys: (none \u2014 shared defaults only)"),b)s(`Would remove plaintext file ${f}.`);return{encryptedPath:d,plaintextPath:f,deletedPlaintext:b,encryptedKeys:_,dryRun:!0}}let A=new DA;A.addRecipient(o.pilot.agePublicKey);let O=await A.encrypt(x),L=Nd.encode(O);if(await o6(c,L),await Mce(u,{force:!0}),s(`Encrypted ${_.length} secrets to ${d}.`),b)s(`Removed plaintext file ${f}.`);return{encryptedPath:d,plaintextPath:f,deletedPlaintext:b,encryptedKeys:_}}function Fce(e,t,r,o,n,i){let s=t6(e,t,r,o,n,"aiApiKey",i.effectiveAiApiKeySelector,i.sharedAiApiKeySelector),a=t6(e,t,r,o,n,"gitSyncToken",i.effectiveGitSyncTokenSelector,i.sharedGitSyncTokenSelector),c=i.discordEnabled?Bg(e,t,r,o,n,"discordBotToken","DISCORD_BOT_TOKEN"):void 0,u=i.discordEnabled?Bg(e,t,r,o,n,"discordPublicKey","DISCORD_PUBLIC_KEY"):void 0,d=i.discordEnabled?Bg(e,t,r,o,n,"discordApplicationId","DISCORD_APPLICATION_ID"):void 0,f=jg(e,t,r,o,n,"atprotoAppPassword","ATPROTO_APP_PASSWORD"),m=r6(jg(e,t,r,o,n,"certificatePem","CERTIFICATE_PEM")),h=r6(jg(e,t,r,o,n,"privateKeyPem","PRIVATE_KEY_PEM"));return i6.parse({...s?{aiApiKey:s}:{},...a?{gitSyncToken:a}:{},...c?{discordBotToken:c}:{},...u?{discordPublicKey:u}:{},...d?{discordApplicationId:d}:{},...f?{atprotoAppPassword:f}:{},...m?{certificatePem:m}:{},...h?{privateKeyPem:h}:{}})}function t6(e,t,r,o,n,i,s,a){if(s===a)return;return Bg(e,t,r,o,n,i,s)}function Bg(e,t,r,o,n,i,s){let a=jg(e,t,r,o,n,i,s);if(a===void 0||a.trim().length===0)throw Error(`Missing required secret value for ${String(i)}. Set it in users/<handle>.secrets.yaml or fall back to ${s}/${s}_FILE before running secrets:encrypt.`);return a}function r6(e){return e?.replace(/\r\n?|\n/g,"\\n")}function jg(e,t,r,o,n,i,s){return Jce(o,n,i,s,t,r,e)}function Jce(e,t,r,o,n,i,s){let a=e?.[r];if(a!==void 0&&a.trim().length>0)return a;let c=Dt(`${o}_FILE`,n,i);if(c&&c.trim().length>0)return Bd(Jo(c,s),"utf8");let u=Dt(o,n,i);if(u!==void 0&&u.trim().length>0)return u;let d=t?.[r];if(d!==void 0&&d.trim().length>0)return d;return}function Kce(e){let t;try{t=Bd(e,"utf8")}catch{return}try{return KA(t)}catch(r){throw Error(`Unable to parse plaintext secrets file ${e}: ${Ge(r)}`,{cause:r})}}async function Hce(e,t,r,o){if(!await s6(e))return;let n=Vce(t,r,o);if(!n)return;let i;try{let s=Bd(e,"utf8"),a=Nd.decode(s),c=new LA;c.addIdentity(n),i=await c.decrypt(a,"text")}catch{return}try{return KA(i)}catch(s){throw Error(`Unable to parse decrypted secrets from ${e}: ${Ge(s)}`,{cause:s})}}function Vce(e,t,r){let o=Dt("AGE_SECRET_KEY_FILE",t,r);if(o&&o.trim().length>0)return qc(Bd(Jo(o,e),"utf8"));let n=Dt("AGE_SECRET_KEY",t,r);if(n&&n.trim().length>0)return qc(n);try{return qc(Bd(FA(e,".brains-ops","age","identity.txt"),"utf8"))}catch{return}}function KA(e){let t=bO(e),r={};if(t!==null&&typeof t==="object"&&!Array.isArray(t)){for(let[o,n]of Object.entries(t))if(typeof n==="string")r[o]=n}return i6.partial().parse(r)}function Wce(e,t){let r={...t},o={...KA(e)},n=new Set([...Object.keys(r),...Object.keys(o)]);for(let i of n)if(r[i]!==o[i])throw Error(`secrets:encrypt round-trip verification failed for ${i}; refusing to write a corrupted encrypted payload`)}function Gce(e){return[...e.effectiveAiApiKeySelector!==e.sharedAiApiKeySelector?["aiApiKey"]:[],...e.effectiveGitSyncTokenSelector!==e.sharedGitSyncTokenSelector?["gitSyncToken"]:[],...e.discordEnabled?["discordBotToken","discordPublicKey","discordApplicationId"]:[]]}async function Qce(e,t){let r=["# local per-user secret staging file","# fill values, run `bunx brains-ops secrets:encrypt . <handle>`, then the plaintext file will be removed",...t.map((o)=>`${o}: `),""].join(`
748
+ `);await o6(e,r,{flag:"wx"})}async function s6(e){try{return await qce(e),!0}catch{return!1}}function n6(e){return e.replaceAll("\\","/")}ns();import{readFileSync as Yce}from"fs";zn();async function HA(e,t={}){let r=t.env??process.env,o=t.logger??console.log,n=on(e),i=ob(`${e}/.env.schema`),s=ele(i),a=[],c=[],u=new Map;for(let f of s){u.set(f.key,f.required);let m=tle(f.key,r,n,e);if(m===void 0||m.trim().length===0){c.push(f.key);continue}a.push([f.key,m])}if(a.length===0)throw Error("No pushable local secrets found for this pilot repo");let d=(f)=>u.get(f)??!1;if(t.dryRun)return o(`Dry run: would push ${a.length} secrets to GitHub Secrets.`),o(`Secrets: ${a.map(([f])=>f).join(", ")}`),BA(o,c,d),{pushedKeys:a.map(([f])=>f),skippedKeys:c,dryRun:!0};return await zi(a,{logger:o,runCommand:t.runCommand??Lt}),BA(o,c,d),{pushedKeys:a.map(([f])=>f),skippedKeys:c}}var Xce=new Set(["DISCORD_BOT_TOKEN","DISCORD_PUBLIC_KEY","DISCORD_APPLICATION_ID"]);function ele(e){return e.filter((t)=>!Xce.has(t.key)).map((t)=>({key:t.key,required:t.required}))}function tle(e,t,r,o){let n=Dt(`${e}_FILE`,t,r);if(n&&n.trim().length>0)return Yce(Jo(n,o),"utf8");let i=Dt(e,t,r);if(i===void 0||i.trim().length===0)return;return i}he();import{execFileSync as a6}from"child_process";import{chmodSync as rle,existsSync as nle,mkdirSync as ole,readFileSync as c6,writeFileSync as ile}from"fs";import{dirname as sle,join as ale}from"path";import{homedir as cle}from"os";sb();zn();var l6=l.object({id:l.number(),name:l.string(),public_key:l.string()}),lle=l.object({ssh_keys:l.array(l6)}),ule={createEd25519KeyPair(e,t){a6("ssh-keygen",["-t","ed25519","-f",e,"-C",t,"-N",""],{stdio:"ignore"})},derivePublicKey(e){return a6("ssh-keygen",["-y","-f",e],{encoding:"utf-8",stdio:["ignore","pipe","inherit"]}).trim()}};async function Zg(e,t={}){try{let r=await VA(e,t);return{success:!0,message:r.createdLocalKey?`SSH deploy key ready at ${r.privateKeyPath}`:`SSH deploy key already ready at ${r.privateKeyPath}`}}catch(r){return{success:!1,message:Ge(r,"SSH key bootstrap failed")}}}async function VA(e,t={}){let r=t.env??process.env,o=on(e),n=t.logger??console.log,i=t.fetchImpl??fetch,s=t.sshKeygen??ule,a=Dt("HCLOUD_TOKEN",r,o);if(!a)throw Error("Missing HCLOUD_TOKEN");let c=Dt("HCLOUD_SSH_KEY_NAME",r,o);if(!c)throw Error("Missing HCLOUD_SSH_KEY_NAME");let u=Dt("KAMAL_SSH_PRIVATE_KEY_FILE",r,o),d=u?Jo(u,e):ale(cle(),".ssh",`${fle(c)}_ed25519`),f=`${d}.pub`,m=!1;if(!nle(d))ole(sle(d),{recursive:!0,mode:448}),s.createEd25519KeyPair(d,c),m=!0;rle(d,384);let h;if(m)h=c6(f,"utf-8").trim();else h=s.derivePublicKey(d),ile(f,`${h}
749
+ `,"utf-8");if(h.length===0)throw Error(`Unable to derive a public key from ${d}`);let b=await dle({fetchImpl:i,hcloudToken:a,publicKey:h,sshKeyName:c}),y=Uc(t.pushTo);if(y)await zi([["KAMAL_SSH_PRIVATE_KEY",c6(d,"utf-8")]],{logger:n,runCommand:t.runCommand??Lt});if(n(m?`Created ${d}`:`Reusing ${d}`),n(b?`Registered Hetzner SSH key ${c}`:`Hetzner SSH key ${c} already exists`),y)n(`Pushed KAMAL_SSH_PRIVATE_KEY to ${y}`);return{createdHetznerKey:b,createdLocalKey:m,privateKeyPath:d,publicKeyPath:f,sshKeyName:c}}async function dle(e){let t=new URL("https://api.hetzner.cloud/v1/ssh_keys");t.searchParams.set("name",e.sshKeyName);let r=await e.fetchImpl(t.toString(),{headers:{Authorization:`Bearer ${e.hcloudToken}`,"Content-Type":"application/json"}}),{ssh_keys:o}=await Mc(r,lle,{label:"Hetzner SSH key lookup failed"}),[n]=o;if(n){if(n.public_key.trim()!==e.publicKey)throw Error(`Existing Hetzner SSH key ${e.sshKeyName} does not match the local public key`);return!1}let i=await e.fetchImpl("https://api.hetzner.cloud/v1/ssh_keys",{method:"POST",headers:{Authorization:`Bearer ${e.hcloudToken}`,"Content-Type":"application/json"},body:JSON.stringify({name:e.sshKeyName,public_key:e.publicKey})});return await Mc(i,l.object({ssh_key:l6}),{label:"Hetzner SSH key create failed"}),!0}function fle(e){return e.replace(/[^A-Za-z0-9._-]+/g,"_")}he();Mr();var ple=l.looseObject({status:l.string(),operationalStatus:l.string(),checks:l.array(l.looseObject({name:l.string(),status:l.string(),message:l.string().optional()})).default([]),app:l.looseObject({daemons:l.array(l.looseObject({name:l.string().optional(),status:l.string().optional(),health:l.looseObject({status:l.string().optional(),message:l.string().optional()}).optional()})).default([])}).default({daemons:[]})});async function WA(e,t,r={}){let o=r.fetchImpl??fetch,i=(await ut(e)).users.find((m)=>m.handle===t);if(!i)throw Error(`Unknown pilot user: ${t}`);let s=`https://${i.domain}`,a=[],c=[],u=l.number().int().positive().max(30).parse(r.operationalRetryAttempts??6),d=l.number().int().nonnegative().max(60000).parse(r.operationalRetryDelayMs??1e4),f=r.sleep??((m)=>new Promise((h)=>setTimeout(h,m)));if(await Ug("health",()=>mle(o,s,u,d,f),a,c),await Ug("mcp-auth-gate",()=>yle(o,s),a,c),i.bundles.includes("site"))await Ug("site",()=>u6(o,`${s}/`,"site"),a,c),await Ug("studio",()=>u6(o,`${s}/studio`,"studio"),a,c),r.logger?.("WARN Manual check still required: passkey setup/handoff completed from the setup email.");return{handle:i.handle,bundles:i.bundles,domain:i.domain,contentRepo:i.contentRepo,checks:a,failedChecks:c}}async function Ug(e,t,r,o){try{await t(),r.push(e)}catch(n){o.push({name:e,message:Ge(n)})}}async function mle(e,t,r,o,n){let i;for(let s=1;s<=r;s++)try{await hle(e,t);return}catch(a){if(i=a,s<r)await n(o)}throw i}async function hle(e,t){let o=await GA(e,`${t}/health/operate`,{method:"GET"}),n=await o.json().catch(()=>null),i=ple.safeParse(n);if(!o.ok){let a=i.success?i.data.checks.filter((c)=>c.status!=="healthy").slice(0,10).map((c)=>`${c.name}: ${gle(c.message??c.status)}`):[];throw Error(`/health/operate returned ${o.status}, expected 200${a.length>0?` (${a.join("; ")})`:""}`)}if(!i.success)throw Error(`/health/operate response did not match expected shape: ${i.error.message}`);let s=i.data;if(s.status!=="ready")throw Error(`/health/operate status is ${s.status}, expected ready`);if(s.operationalStatus!=="operational")throw Error(`/health/operate operationalStatus is ${s.operationalStatus}, expected operational`);for(let a of s.app.daemons){let c=a.status??"unknown",u=a.health?.status;if(c==="error"||u==="unhealthy")throw Error(`daemon ${a.name??"unknown"} is unhealthy (${c}/${u??"unknown"})`)}}function gle(e){let t=e.replaceAll(/\s+/g," ").trim();return t.length<=300?t:`${t.slice(0,297)}...`}async function yle(e,t){let r=await GA(e,`${t}/mcp`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize"})});if(r.status<400||r.status>=500)throw Error(`unauthenticated POST /mcp returned ${r.status}, expected a 4xx auth failure`)}async function u6(e,t,r){let o=await GA(e,t,{method:"GET"});if(o.status>=400)throw Error(`${r} ${t} returned ${o.status}, expected < 400`)}async function GA(e,t,r){let o=new AbortController,n=setTimeout(()=>o.abort(),20000);try{return await e(t,{...r,redirect:"follow",signal:o.signal})}finally{clearTimeout(n)}}var y5="brains-ops",gR={type:"string",placeholder:"<target>",description:"Push target (`gh` or `github`)"},Xy={type:"boolean",description:"Show what would happen without writing anything"};function bt(e){return{success:!1,message:SB(y5,e)}}var b5=ot({name:"init",usage:"<repo>",description:"Create a pilot repo skeleton",run:async({args:e})=>{let t=e[0];if(!t)return bt(b5);return await pE(t),{success:!0,message:`Initialized ${t}`}}}),S5=ot({name:"upgrade",usage:"<repo>",description:"Bump @rizom/ops and refresh the generated scaffold",flags:{to:{type:"string",placeholder:"<version>",description:"Explicit @rizom/ops version (`latest` by default)"}},run:async({args:e,flags:t})=>{let r=e[0];if(!r)return bt(S5);let o=nt(t,"to"),{upgradePilotRepo:n}=await Promise.resolve().then(() => (p6(),f6)),{from:i,to:s}=await n(r,{...o&&o!=="latest"?{version:o}:{}});return{success:!0,message:i===s?`Already at @rizom/ops@${s}; scaffold refreshed`:`Upgraded @rizom/ops ${i} -> ${s}; scaffold refreshed`}}}),v5=ot({name:"images:lock",usage:"<repo> [--brain-version <version>] [--site-packages <pins>]",description:"Create immutable runtime dependency locks for operator review (no build or deploy)",flags:{"brain-version":{type:"string",placeholder:"<version>",description:"Lock one exact Brain version instead of the declared fleet"},"site-packages":{type:"string",placeholder:"<pins>",description:"Exact site/theme pins for an explicit Brain version"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=nt(t,"brain-version"),i=nt(t,"site-packages");if(!o||i!==void 0&&!n)return bt(v5);if(n!==void 0)$t.parse(n);let{users:s}=await ut(o),a=await Zm({users:s,brainVersionInput:n,sitePackagesInput:i,imageExists:async()=>!1,verifyImage:async()=>{throw Error("Lock generation must not inspect images")}}),c=[];for(let u of a){let d=await MN(o,u,r.imageLockRunCommand);c.push(`${d}: ${u.tag}`)}return{success:!0,message:["Review and commit runtime dependency locks before building:",...c].join(`
750
750
  `)}}}),w5=ot({name:"crossover:stage",usage:"<source-repo> <output-dir> <bundle-review.yaml> [site-pins.yaml]",description:"Stage a reviewed capability-bundle crossover copy",run:async({args:e})=>{let t=e[0],r=e[1],o=e[2],n=e[3];if(!t||!r||!o)return bt(w5);let{loadCapabilityBundleReview:i,loadReviewedSitePins:s,stageLegacyCrossover:a}=await Promise.resolve().then(() => (L6(),D6)),c=await i(o),u=n?await s(n):void 0,d=await a(t,r,{bundleReview:c,sitePins:u});return{success:!0,message:`Staged ${d.changedFiles.length} reviewed crossover files in ${d.outputDir}`}}}),x5=ot({name:"render",usage:"<repo>",description:"Render the observed users table to views/users.md",run:async({args:e},t)=>{let r=e[0];if(!r)return bt(x5);let o=t.resolveStatus??HU({...t.fetchImpl?{fetchImpl:t.fetchImpl}:{},...t.lookupHost?{lookupHost:t.lookupHost}:{}});return await ao(r,{resolveStatus:o}),{success:!0,message:`Rendered ${r}/views/users.md`}}}),_5=ot({name:"user:add",usage:"<repo> <handle> --cohort <cohort> [--discord] [--anchor-id <id>]",description:"Add a user to a cohort",flags:{cohort:{type:"string",placeholder:"<cohort>",description:"Cohort the user joins"},discord:{type:"boolean",description:"Enable Discord for the user (browser chat is the default)"},"anchor-id":{type:"string",placeholder:"<id>",description:"Discord anchor user id stored on the user record (implies --discord)"}},run:async({args:e,flags:t})=>{let r=e[0],o=e[1],n=nt(t,"cohort");if(!r||!o||!n)return bt(_5);let i=nt(t,"anchor-id");return await DE(r,o,{cohort:n,...Is(t,"discord")?{discord:!0}:{},...i?{anchorId:i}:{}}),{success:!0,message:`Added ${o} to ${n}`}}}),E5=ot({name:"user:offboard",usage:"<repo> <handle>... [--apply --confirm sunset:<sorted-comma-separated-handles>]",description:"Archive content and remove pilot users, DNS, and servers",flags:{apply:{type:"boolean",description:"Apply the plan (defaults to a read-only dry run)"},confirm:{type:"string",placeholder:"<confirmation>",description:"Exact batch confirmation required with --apply"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=e.slice(1);if(!o||n.length===0)return bt(E5);let i=Is(t,"apply")??!1,s=nt(t,"confirm"),{offboardPilotUsers:a}=await Promise.resolve().then(() => (QI(),mB)),c=await a(o,{handles:n,dryRun:!i,...s?{confirmation:s}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{},...r.pilotOffboardDriver?{driver:r.pilotOffboardDriver}:{}});return{success:!0,message:c.dryRun?`Dry run: ${c.handles.length} pilot user(s); apply with --apply --confirm ${c.confirmation}`:`Offboarded ${c.handles.length} pilot user(s)`}}}),I5=ot({name:"onboard",usage:"<repo> <handle>",description:"Generate a user's brain.yaml and .env",run:async({args:e},t)=>{let r=e[0],o=e[1];if(!r||!o)return bt(I5);return await NE(r,o,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Onboarded ${o}`}}}),k5=ot({name:"age-key:bootstrap",usage:"<repo>",description:"Generate the pilot age key and optional GitHub secret",flags:{"push-to":gR},run:async({args:e,flags:t},r)=>{let o=e[0];if(!o)return bt(k5);let n=nt(t,"push-to");return UA(o,{...r.logger?{logger:r.logger}:{},...n?{pushTo:n}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{}})}}),A5=ot({name:"ssh-key:bootstrap",usage:"<repo>",description:"Bootstrap a deploy SSH key and optional GitHub secret",flags:{"push-to":gR},run:async({args:e,flags:t},r)=>{let o=e[0];if(!o)return bt(A5);let n=nt(t,"push-to");return Zg(o,{...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{},...n?{pushTo:n}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{},...r.sshKeygen?{sshKeygen:r.sshKeygen}:{}})}}),T5=ot({name:"cert:bootstrap",usage:"<repo>",description:"Issue Cloudflare Origin CA certificates for pilot users",flags:{handle:{type:"string",placeholder:"<handle>",description:"Only issue the certificate for this user handle"},"push-to":gR},run:async({args:e,flags:t},r)=>{let o=e[0];if(!o)return bt(T5);let n=nt(t,"handle"),i=nt(t,"push-to");return qA(o,{...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{},...n?{handle:n}:{},...i?{pushTo:i}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{}})}}),$5=ot({name:"secrets:push",usage:"<repo>",description:"Push env-backed local secrets to GitHub Secrets",flags:{"dry-run":Xy},run:async({args:e,flags:t},r)=>{let o=e[0];if(!o)return bt($5);let n=await HA(o,{env:r.env,logger:r.logger,dryRun:Is(t,"dry-run")});return{success:!0,message:n.dryRun?`Dry run: would push ${n.pushedKeys.length} secrets`:`Pushed ${n.pushedKeys.length} secrets`}}}),R5=ot({name:"secrets:encrypt",usage:"<repo> <handle>",description:"Encrypt pilot secrets for a user with age",flags:{"dry-run":Xy},run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1];if(!o||!n)return bt(R5);let i=await JA(o,n,{env:r.env,logger:r.logger,dryRun:Is(t,"dry-run")});return{success:!0,message:i.dryRun?`Dry run: would encrypt ${i.encryptedKeys.length} secrets for ${n}`:`Encrypted ${i.encryptedKeys.length} secrets for ${n}`}}}),O5=ot({name:"recover:retire-legacy-projection-job",usage:"<database> <job-id> --type <legacy-type> (--dry-run | --confirm retire:<job-id>)",description:"Retire one exact unowned pre-scheduler projection job",flags:{type:{type:"string",placeholder:"<legacy-type>",description:"Exact retired projection job type"},confirm:{type:"string",placeholder:"retire:<job-id>",description:"Exact job retirement confirmation"},"dry-run":Xy},run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=nt(t,"type"),s=nt(t,"confirm"),a=Is(t,"dry-run")??!1;if(!o||!n||!i||a===(s!==void 0))return bt(O5);let{legacyProjectionJobTypeSchema:c}=await Promise.resolve().then(() => (Y$(),Q$)),u=c.safeParse(i);if(!u.success)return{success:!1,message:`Unsupported legacy projection job type: ${i}`};let d=r.legacyProjectionJobRecoveryRunner??(await Promise.resolve().then(() => (Y$(),Q$))).retireLegacyProjectionJob;try{let f=await d({databasePath:o,jobId:n,jobType:u.data,...s?{confirmation:s}:{},dryRun:a});return{success:!0,message:f.retired?`Retired unowned legacy projection job ${f.job.id} (${f.job.type})`:`Dry run: legacy projection job ${f.job.id} (${f.job.type}) is unowned and retirable`}}catch(f){return{success:!1,message:`Legacy projection job recovery failed: ${Ge(f)}`}}}}),C5=ot({name:"stress:directory-sync",usage:"<repo> <handle> --profile <regression|load|stress> --confirm stress:<handle> [--artifacts-dir <path>]",description:"Run a smoke-only directory-sync stress profile",flags:{profile:{type:"string",placeholder:"<profile>",description:"Stress profile (`regression`, `load`, or `stress`)"},confirm:{type:"string",placeholder:"stress:<handle>",description:"Explicit smoke target confirmation"},"artifacts-dir":{type:"string",placeholder:"<path>",description:"Directory for JSON, Markdown, samples, and logs"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=nt(t,"profile"),s=nt(t,"confirm");if(!o||!n||!s||i!=="regression"&&i!=="load"&&i!=="stress")return bt(C5);let a=r.directorySyncStressRunner??(await Promise.resolve().then(() => (jf(),Wy))).runDeployedDirectorySyncStress,c=nt(t,"artifacts-dir"),u=await a({rootDir:o,handle:n,profile:i,confirmation:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:u.report.success,message:`${u.report.success?"Passed":"Failed"} ${i} directory-sync stress for ${n}; artifacts: ${u.artifactsDir}`}}}),P5=ot({name:"stress:directory-sync:verify-access",usage:"<repo> <handle> --confirm stress:<handle> [--artifacts-dir <path>]",description:"Verify smoke stress credentials without remote writes",flags:{confirm:{type:"string",placeholder:"stress:<handle>",description:"Explicit smoke target confirmation"},"artifacts-dir":{type:"string",placeholder:"<path>",description:"Directory for the access-check result"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=nt(t,"confirm");if(!o||!n||!i)return bt(P5);let s=r.directorySyncStressAccessRunner??(await Promise.resolve().then(() => (jf(),Wy))).verifyDirectorySyncStressAccess,a=nt(t,"artifacts-dir"),c=await s({rootDir:o,handle:n,confirmation:i,...a?{artifactsDir:a}:{},...r.env?{env:r.env}:{}});return{success:c.success,message:`Verified directory-sync stress access for ${n} at ${c.remoteHead}; artifacts: ${c.artifactsDir}`}}}),z5=ot({name:"stress:directory-sync:cleanup",usage:"<repo> <handle> --confirm stress:<handle> [--artifacts-dir <path>]",description:"Remove residual smoke directory-sync stress probes",flags:{confirm:{type:"string",placeholder:"stress:<handle>",description:"Explicit smoke target confirmation"},"artifacts-dir":{type:"string",placeholder:"<path>",description:"Directory for the cleanup result"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=nt(t,"confirm");if(!o||!n||!i)return bt(z5);let s=r.directorySyncStressCleanupRunner??(await Promise.resolve().then(() => (jf(),Wy))).cleanupDirectorySyncStress,a=nt(t,"artifacts-dir"),c=await s({rootDir:o,handle:n,confirmation:i,...a?{artifactsDir:a}:{},...r.env?{env:r.env}:{},...r.logger?{logger:r.logger}:{}});return{success:c.success,message:`${c.success?"Cleaned":"Failed to clean"} directory-sync stress probes for ${n}; removed ${c.probesRemoved}, remaining ${c.probesRemaining}`}}}),N5={confirm:{type:"string",placeholder:"watchdog-smoke:<handle>",description:"Explicit smoke target confirmation"},"run-id":{type:"string",placeholder:"<id>",description:"Stable workflow run identifier used for cleanup"},"artifacts-dir":{type:"string",placeholder:"<path>",description:"Directory for remote smoke evidence"}},D5=ot({name:"smoke:health-watchdog",usage:"<repo> <handle> --confirm watchdog-smoke:<handle> --run-id <id> [--artifacts-dir <path>]",description:"Run the smoke-fleet host watchdog isolation check",flags:N5,run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=nt(t,"confirm"),s=nt(t,"run-id");if(!o||!n||!i||!s)return bt(D5);let a=r.healthWatchdogSmokeRunner??(await Yy().then(() => hR)).runHealthWatchdogSmoke,c=nt(t,"artifacts-dir"),u=await a({rootDir:o,handle:n,confirmation:i,runId:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:u.success,message:`Passed health watchdog smoke for ${n}; artifacts: ${u.artifactsDir}`}}}),L5=ot({name:"smoke:health-watchdog:cleanup",usage:"<repo> <handle> --confirm watchdog-smoke:<handle> --run-id <id> [--artifacts-dir <path>]",description:"Remove residual smoke-fleet watchdog fixtures",flags:N5,run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=nt(t,"confirm"),s=nt(t,"run-id");if(!o||!n||!i||!s)return bt(L5);let a=r.healthWatchdogSmokeCleanupRunner??(await Yy().then(() => hR)).cleanupHealthWatchdogSmoke,c=nt(t,"artifacts-dir"),u=await a({rootDir:o,handle:n,confirmation:i,runId:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:u.success,message:`Cleaned health watchdog smoke fixtures for ${n}; artifacts: ${u.artifactsDir}`}}}),B5=ot({name:"verify-user",usage:"<repo> <handle>",description:"Probe a deployed user's endpoints",run:async({args:e},t)=>{let r=e[0],o=e[1];if(!r||!o)return bt(B5);let n=await WA(r,o,{...t.fetchImpl?{fetchImpl:t.fetchImpl}:{},...t.logger?{logger:t.logger}:{},...t.verificationRetryAttempts!==void 0?{operationalRetryAttempts:t.verificationRetryAttempts}:{},...t.verificationRetryDelayMs!==void 0?{operationalRetryDelayMs:t.verificationRetryDelayMs}:{},...t.sleep?{sleep:t.sleep}:{}}),i=n.checks.length>0?n.checks.join(", "):"none";if(n.failedChecks.length>0){let s=n.failedChecks.map((a)=>` ${a.name}: ${a.message}`).join(`
751
751
  `);return{success:!1,message:`Verified ${n.handle} (${n.bundles.join(",")}) at https://${n.domain}: passed ${i}; failed:
752
752
  ${s}`}}return{success:!0,message:`Verified ${n.handle} (${n.bundles.join(",")}) at https://${n.domain}: ${i}`}}}),j5=ot({name:"reconcile-cohort",usage:"<repo> <cohort>",description:"Reconcile all users in a cohort",run:async({args:e},t)=>{let r=e[0],o=e[1];if(!r||!o)return bt(j5);return await YI(r,o,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Reconciled cohort ${o}`}}});function g5(e,t){return[e,...t.length===0?["- (none)"]:t.map((r)=>`- ${r}`)]}var Z5=ot({name:"reconcile-all",usage:"<repo> [--dry-run]",description:"Reconcile every cohort",flags:{"dry-run":Xy},run:async({args:e,flags:t},r)=>{let o=e[0];if(!o)return bt(Z5);if(Is(t,"dry-run")){let n=await QU(o),i=n.firstPassChangedFiles.length,s=n.secondPassChangedFiles.length;return{success:s===0,message:[`Dry-run reconcile found ${i} first-pass changed file(s); second pass ${s===0?"converged with zero drift":`still changed ${s} file(s)`}`,...g5("First-pass changed files:",n.firstPassChangedFiles),...g5("Second-pass changed files:",n.secondPassChangedFiles)].join(`
753
- `)}}return await ed(o,r.runner,{...r.env?{env:r.env}:{}}),{success:!0,message:"Reconciled all cohorts"}}}),lme=ot({name:"help",description:"Show this help message",run:()=>({success:!0,message:vB({cliName:y5,intro:"brains-ops \u2014 operator CLI for private brain fleet repos",commands:eb,globalFlags:yR})})}),ume=ot({name:"version",description:"Show version",run:()=>({success:!0,message:`brains-ops ${Zf.version}`})}),yR={help:{type:"boolean",short:"h",description:"Show help"},version:{type:"boolean",short:"v",description:"Show version"}},eb=[b5,S5,v5,w5,x5,_5,E5,I5,k5,A5,T5,$5,R5,O5,C5,P5,z5,D5,L5,B5,j5,Z5,lme,ume],dme=wB(eb);async function fme(e,t={}){let r=dme.get(e.command);if(!r)return{success:!1,message:`Unknown command: ${e.command}`};return r.run({args:e.args,flags:e.flags},t)}function pme(e){return gB(e,{commands:eb,globalFlags:yR})}Vy();jf();Pn();await Yy();export{ii as CAPABILITY_BUNDLE_CONTRACT,DE as addPilotUser,zf as assertDirectorySyncStressTarget,Qy as assertHealthWatchdogSmokeTarget,GI as assertPilotUsersRemoved,OU as bootstrapPilotAgeKey,JU as bootstrapPilotOriginCertificate,VA as bootstrapPilotSshKey,Dm as canonicalBundleIdSchema,Y3 as cleanupDirectorySyncStress,f5 as cleanupHealthWatchdogSmoke,qr as cohortSchema,WI as createPilotOffboardDriver,$E as derivePreviewDomain,Pf as directorySyncStressPlanSchema,Cf as directorySyncStressProfileSchema,q3 as directorySyncStressReportSchema,JA as encryptPilotSecrets,qc as extractAgeIdentity,pE as initPilotRepo,ut as loadPilotRegistry,uB as offboardPilotUsers,NE as onboardUser,pme as parseArgs,si as pilotSchema,HA as pushPilotSecrets,ed as reconcileAll,YI as reconcileCohort,mR as renderHealthWatchdogSmokeRemoteScript,JN as requiredImages,eR as resolveDirectorySyncStressPlan,Zm as resolveImageBuilds,fme as runCommand,G3 as runDeployedDirectorySyncStress,tR as runDirectorySyncStressPlan,d5 as runHealthWatchdogSmoke,UA as runPilotAgeKeyBootstrap,qA as runPilotCertBootstrap,Zg as runPilotSshKeyBootstrap,R7 as runResolveMissingImages,Iu as runtimeImageTag,Hy as sampleStressHealth,jm as sitePackagesFor,M3 as stressMetricsFailure,Q3 as verifyDirectorySyncStressAccess,WA as verifyPilotUser,ao as writeUsersTable};
753
+ `)}}return await ed(o,r.runner,{...r.env?{env:r.env}:{}}),{success:!0,message:"Reconciled all cohorts"}}}),ume=ot({name:"help",description:"Show this help message",run:()=>({success:!0,message:vB({cliName:y5,intro:"brains-ops \u2014 operator CLI for private brain fleet repos",commands:eb,globalFlags:yR})})}),dme=ot({name:"version",description:"Show version",run:()=>({success:!0,message:`brains-ops ${Zf.version}`})}),yR={help:{type:"boolean",short:"h",description:"Show help"},version:{type:"boolean",short:"v",description:"Show version"}},eb=[b5,S5,v5,w5,x5,_5,E5,I5,k5,A5,T5,$5,R5,O5,C5,P5,z5,D5,L5,B5,j5,Z5,ume,dme],fme=wB(eb);async function pme(e,t={}){let r=fme.get(e.command);if(!r)return{success:!1,message:`Unknown command: ${e.command}`};return r.run({args:e.args,flags:e.flags},t)}function mme(e){return gB(e,{commands:eb,globalFlags:yR})}Vy();jf();Pn();await Yy();export{ii as CAPABILITY_BUNDLE_CONTRACT,DE as addPilotUser,zf as assertDirectorySyncStressTarget,Qy as assertHealthWatchdogSmokeTarget,GI as assertPilotUsersRemoved,OU as bootstrapPilotAgeKey,JU as bootstrapPilotOriginCertificate,VA as bootstrapPilotSshKey,Dm as canonicalBundleIdSchema,Y3 as cleanupDirectorySyncStress,f5 as cleanupHealthWatchdogSmoke,qr as cohortSchema,WI as createPilotOffboardDriver,$E as derivePreviewDomain,Pf as directorySyncStressPlanSchema,Cf as directorySyncStressProfileSchema,q3 as directorySyncStressReportSchema,JA as encryptPilotSecrets,qc as extractAgeIdentity,pE as initPilotRepo,ut as loadPilotRegistry,uB as offboardPilotUsers,NE as onboardUser,mme as parseArgs,si as pilotSchema,HA as pushPilotSecrets,ed as reconcileAll,YI as reconcileCohort,mR as renderHealthWatchdogSmokeRemoteScript,JN as requiredImages,eR as resolveDirectorySyncStressPlan,Zm as resolveImageBuilds,pme as runCommand,G3 as runDeployedDirectorySyncStress,tR as runDirectorySyncStressPlan,d5 as runHealthWatchdogSmoke,UA as runPilotAgeKeyBootstrap,qA as runPilotCertBootstrap,Zg as runPilotSshKeyBootstrap,O7 as runResolveMissingImages,Iu as runtimeImageTag,Hy as sampleStressHealth,jm as sitePackagesFor,M3 as stressMetricsFailure,Q3 as verifyDirectorySyncStressAccess,WA as verifyPilotUser,ao as writeUsersTable};