tempest.games 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/app/assets/{index-CGlDykR1.js → index-BG6T8CzE.js} +13 -13
- package/app/index.html +1 -1
- package/bin/backend.bun.js +194 -193
- package/bin/backend.worker.tribunal.bun.js +88 -87
- package/bin/frontend.bun.js +31 -30
- package/bin/setup-db.bun.js +377 -202
- package/drizzle/0018_curved_wallop.sql +36 -0
- package/drizzle/0019_lively_boomer.sql +4 -0
- package/drizzle/0020_magenta_stark_industries.sql +8 -0
- package/drizzle/meta/0018_snapshot.json +535 -0
- package/drizzle/meta/0019_snapshot.json +539 -0
- package/drizzle/meta/0020_snapshot.json +487 -0
- package/drizzle/meta/_journal.json +21 -0
- package/package.json +12 -11
|
@@ -1,73 +1,73 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var HA=Object.create;var{getPrototypeOf:FA,defineProperty:dU,getOwnPropertyNames:QA}=Object;var ZA=Object.prototype.hasOwnProperty;var DA=($,T,W)=>{W=$!=null?HA(FA($)):{};let X=T||!$||!$.__esModule?dU(W,"default",{value:$,enumerable:!0}):W;for(let Y of QA($))if(!ZA.call(X,Y))dU(X,Y,{get:()=>$[Y],enumerable:!0});return X};var OA=($,T)=>()=>(T||$((T={exports:{}}).exports,T),T.exports);var M1=($,T)=>{for(var W in T)dU($,W,{get:T[W],enumerable:!0,configurable:!0,set:(X)=>T[W]=()=>X})};var Xj=($,T)=>()=>($&&(T=$($=0)),T);var y5=import.meta.require;var ZF=OA((ch,QF)=>{var oW=y5("os"),lW=y5("path");function FF($){let T=process.env.XDG_CACHE_HOME||lW.join(oW.homedir(),".cache");return lW.join(T,$)}function zR($){return lW.join(oW.homedir(),"Library","Caches",$)}function _R($){let T=process.env.LOCALAPPDATA||lW.join(oW.homedir(),"AppData","Local");return lW.join(T,$,"Cache")}var HR=function(){switch(oW.platform()){case"darwin":return zR;case"win32":return _R;case"aix":case"android":case"freebsd":case"linux":case"netbsd":case"openbsd":case"sunos":return FF;default:return console.error(`(node:${process.pid}) [cachedir] Warning: the platform "${oW.platform()}" is not currently supported by node-cachedir, falling back to "posix". Please file an issue with your platform here: https://github.com/LinusU/node-cachedir/issues/new`),FF}}();QF.exports=function $(T){if(typeof T!=="string")throw new TypeError("id is not a string");if(T.length===0)throw new Error("id cannot be empty");if(/[^0-9a-zA-Z-]/.test(T))throw new Error("id cannot contain special characters");return HR(T)}});class TW extends Promise{fate;resolve;reject;done=!1;constructor($){let T,W;super((X,Y)=>{T=X,W=Y});this.resolve=T,this.reject=W,this.use($ instanceof Promise?$:new Promise($))}pass($,T){if($===this.fate)this.resolve(T),this.done=!0}fail($,T){if($===this.fate)this.reject(T),this.done=!0}use($){if($ instanceof Promise){let T=$;this.fate=T,T.then((W)=>{this.pass(T,W)},(W)=>{this.fail(T,W)})}else this.resolve($),this.fate=void 0}}var Jj=($,T,W=g5.STORE)=>{return h5(W,{key:`${$.key}:JSON`,get:({get:X})=>T.toJson(X($)),set:({set:X},Y)=>{X($,T.fromJson(Y))}})};function _j($,T,W){return oU($,{key:`${T.key}:JSON`,get:(Y)=>({get:U})=>{let G=U(T,Y);return W.toJson(G)},set:(Y)=>({set:U},G)=>{U(T,Y,W.fromJson(G))}},["mutable","json"])}var WW=($)=>JSON.parse($),R4=($)=>JSON.stringify($),Fj=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function s($){while($.child!==null)$=$.child;return $}class bX{_buffer;_index=0;constructor($){let T;if(typeof $==="number")T=$;else T=$.length;this._buffer=Array.from({length:T})}get buffer(){return this._buffer}get index(){return this._index}add($){this._buffer[this._index]=$,this._index=(this._index+1)%this._buffer.length}copy(){let $=new bX([...this._buffer]);return $._index=this._index,$}}var VA={atom_family:"atom",molecule_family:"molecule",mutable_atom_family:"mutable_atom",readonly_held_selector_family:"readonly_held_selector",readonly_pure_selector_family:"readonly_pure_selector",writable_held_selector_family:"writable_held_selector",writable_pure_selector_family:"writable_pure_selector"};function m5($,T){let W=R4(T),X=`${$.key}(${W})`,Y=VA[$.type],U={key:X,type:Y};return Object.assign(U,{family:{key:$.key,subKey:W}}),Object.assign(U,{counterfeit:!0}),U}function XW($){let T={key:$.key,type:$.type};if("family"in $)T.family=$.family;return T}var lU=($)=>(T,W,X,Y,...U)=>{console[$](`${T} ${W} "${X}" ${Y}`,...U)},KA={error:lU("error"),info:lU("info"),warn:lU("warn")};class rU{logLevel;filter;logger;constructor($,T,W=KA){this.logLevel=$,this.filter=T,this.logger=W}error=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel!==null){if(T===!0)this.logger.error(...$);else if(T!==!1)this.logger.error(...T)}};info=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel==="info"){if(T===!0)this.logger.info(...$);else if(T!==!1)this.logger.info(...T)}};warn=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel!=="error"&&this.logLevel!==null){if(T===!0)this.logger.warn(...$);else if(T!==!1)this.logger.warn(...T)}}}class P6{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=($,T)=>`${$}:${T}`;warn;getRelatedKeys($){return this.relations.get($)}addRelation($,T){let W=this.relations.get($),X=this.relations.get(T);if(W)W.add(T);else W=new Set([T]),this.relations.set($,W);if(X)X.add($);else X=new Set([$]),this.relations.set(T,X)}deleteRelation($,T){let W=this.relations.get($);if(W){if(W.delete(T),W.size===0)this.relations.delete($);let X=this.relations.get(T);if(X){if(X.delete($),X.size===0)this.relations.delete(T)}}}replaceRelationsUnsafely($,T){this.relations.set($,new Set(T));for(let W of T){let X=new Set().add($);this.relations.set(W,X)}}replaceRelationsSafely($,T){let W=this.relations.get($),X=this.isAType?.($)?$:void 0,Y=X===void 0?$:void 0;if(W)for(let U of W){X??=U,Y??=U;let G=this.relations.get(U);if(G){if(G.size===1)this.relations.delete(U);else G.delete($);this.contents.delete(this.makeContentKey(X,Y))}}this.relations.set($,new Set(T));for(let U of T){let G=this.relations.get(U);if(G)G.add($);else G=new Set().add($),this.relations.set(U,G)}}getContentInternal($){return this.contents.get($)}setContent($,T){this.contents.set($,T)}deleteContent($){this.contents.delete($)}constructor($,T){if(this.a=$.between[0],this.b=$.between[1],this.cardinality=$.cardinality,!T?.externalStore)this.relations=new Map($.relations?.map(([W,X])=>[W,new Set(X)])),this.contents=new Map($.contents);if(this.isAType=T?.isAType??null,this.isBType=T?.isBType??null,this.isContent=T?.isContent??null,T?.makeContentKey)this.makeContentKey=T.makeContentKey;if(T?.externalStore){let W=T.externalStore;if(this.has=(X,Y)=>W.has(X,Y),this.addRelation=(X,Y)=>{W.addRelation(X,Y)},this.deleteRelation=(X,Y)=>{W.deleteRelation(X,Y)},this.replaceRelationsSafely=(X,Y)=>{W.replaceRelationsSafely(X,Y)},this.replaceRelationsUnsafely=(X,Y)=>{W.replaceRelationsUnsafely(X,Y)},this.getRelatedKeys=(X)=>W.getRelatedKeys(X),W.getContent)this.getContentInternal=(X)=>{return W.getContent(X)},this.setContent=(X,Y)=>{W.setContent(X,Y)},this.deleteContent=(X)=>{W.deleteContent(X)};for(let[X,Y]of $.relations??[]){let U=this.isAType?.(X)?X:void 0,G=U===void 0?X:void 0;for(let J of Y)U??=J,G??=J,this.addRelation(U,G)}for(let[X,Y]of $.contents??[])this.setContent(X,Y)}if(T?.warn)this.warn=T.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([$,T])=>[$,[...T]]),contents:[...this.contents.entries()]}}set(...$){let T,W,X;switch($.length){case 1:{let Y=$[0];T=Y[this.a],W=Y[this.b],X=void 0;break}case 2:{let Y=$[0];if(typeof Y==="string")[T,W]=$;else T=Y[this.a],W=Y[this.b],X=$[1];break}default:{T=$[0],W=$[1],X=$[2];break}}switch(this.cardinality){case"1:1":{let Y=this.getRelatedKey(T);if(Y&&Y!==W)this.delete(T,Y)}case"1:n":{let Y=this.getRelatedKey(W);if(Y&&Y!==T)this.delete(Y,W)}break;case"n:n":}if(X){let Y=this.makeContentKey(T,W);this.setContent(Y,X)}return this.addRelation(T,W),this}delete($,T){T=typeof T==="string"?T:$[this.b];let W=typeof $==="string"?$:$[this.a];if(W===void 0&&typeof T==="string"){let X=this.getRelatedKeys(T);if(X)for(let Y of X)this.delete(Y,T)}if(typeof W==="string"&&T===void 0){let X=this.getRelatedKeys(W);if(X)for(let Y of X)this.delete(W,Y)}if(typeof W==="string"&&typeof T==="string"){this.deleteRelation(W,T);let X=this.makeContentKey(W,T);this.deleteContent(X)}return this}getRelatedKey($){let T=this.getRelatedKeys($);if(T){if(T.size>1)this.warn?.(`${T.size} related keys were found for key "${$}": (${[...T].map((X)=>`"${X}"`).join(", ")}). Only one related key was expected.`);let W;for(let X of T){W=X;break}return W}}replaceRelations($,T,W){let X=!Array.isArray(T),Y=X?Object.keys(T):T;if(W?.reckless)this.replaceRelationsUnsafely($,Y);else this.replaceRelationsSafely($,Y);if(X)for(let U of Y){let G=this.makeContentKey($,U),J=T[U];this.setContent(G,J)}return this}getContent($,T){let W=this.makeContentKey($,T);return this.getContentInternal(W)}getRelationEntries($){let T=$[this.a],W=$[this.b];if(T!==void 0&&W===void 0){let X=this.getRelatedKeys(T);if(X)return[...X].map((Y)=>{return[Y,this.getContent(T,Y)]})}if(T===void 0&&W!==void 0){let X=this.getRelatedKeys(W);if(X)return[...X].map((Y)=>{return[Y,this.getContent(Y,W)]})}return[]}has($,T){if(T)return this.getRelatedKeys($)?.has(T)??!1;return this.relations.has($)}}class K${Subscriber;subscribers=new Map;subscribe($,T){return this.subscribers.set($,T),()=>{this.unsubscribe($)}}unsubscribe($){this.subscribers.delete($)}next($){let T=this.subscribers.values();for(let W of T)W($)}}class iU extends K${state;constructor($){super();this.state=$}next($){this.state=$,super.next($)}}function A1($){return"epoch"in $.transactionMeta}function l4($){return"phase"in $.transactionMeta}function c5($){return $[0].toUpperCase()+$.slice(1)}function fX($){return $.type.split("_").map(c5).join(" ")}class YW extends Error{constructor($,T){super(`${fX($)} ${R4($.key)} not found in store "${T.config.name}".`)}}var u0=($)=>(T)=>$ instanceof Function?$(T):$;var N1=($,T)=>{if($.valueMap.has(T.key))return $.logger.info("\uD83D\uDCD6",T.type,T.key,"reading cached value"),u5(T,$);switch(T.type){case"readonly_held_selector":case"readonly_pure_selector":case"writable_held_selector":case"writable_pure_selector":return $.logger.info("\uD83E\uDDEE",T.type,T.key,"computing value"),T.get();case"atom":case"mutable_atom":{let W=T.default,X;if(W instanceof Function)X=W();else X=W;return $.logger.info("\uD83D\uDC81","atom",T.key,"could not find cached value; using default",X),X}}};var p5=($,T)=>{if($.operation.open){let W=performance.now();return $.logger.info("\u2757",T.type,T.key,`deferring setState at T-${W} until setState for "${$.operation.token.key}" is done`),W}$.operation={open:!0,done:new Set,prev:new Map,time:Date.now(),token:T},$.logger.info("\u2B55",T.type,T.key,`operation start in store "${$.config.name}"${!l4($)?"":` ${$.transactionMeta.phase} "${$.transactionMeta.update.key}"`}`)},d5=($)=>{if($.operation.open)$.logger.info("\uD83D\uDD34",$.operation.token.type,$.operation.token.key,`operation done in store "${$.config.name}"`);$.operation={open:!1},$.on.operationClose.next($.operation)},o5=($,T)=>{if(!$.operation.open)return $.logger.error("\uD83D\uDC1E","unknown",T,"isDone called outside of an operation. This is probably a bug in AtomIO."),!0;return $.operation.done.has(T)},L1=($,T)=>{if(!$.operation.open){$.logger.error("\uD83D\uDC1E","unknown",T,"markDone called outside of an operation. This is probably a bug in AtomIO.");return}$.operation.done.add(T)};var l5=($,T,W)=>{switch(T.type){case"mutable_atom":$.logger.info("\uD83D\uDCE2",T.type,T.key,"is now (",W.newValue,") subscribers:",T.subject.subscribers);break;case"atom":case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":$.logger.info("\uD83D\uDCE2",T.type,T.key,"went (",W.oldValue,"->",W.newValue,") subscribers:",T.subject.subscribers)}T.subject.next(W)};var nU=($,T)=>{let W=s($),X=W.selectorAtoms.getRelatedKeys(T.key);if(W.logger.info("\uD83E\uDDF9",T.type,T.key,X?`evicting ${X.size} states downstream:`:"no downstream states",X??"to evict"),X){if(W.operation.open)W.logger.info("\uD83E\uDDF9",T.type,T.key,`[ ${[...W.operation.done].join(", ")} ] already done`);for(let Y of X){if(o5(W,Y))continue;r5(Y,W),L1(W,Y)}}};var i5=($,T,W)=>{let X=N1($,T),Y=X;if(T.type==="mutable_atom"&&l4($)){let{parent:G}=$;Y=UW($,T,G)}if(Y=u0(W)(Y),$.logger.info("\uD83D\uDCDD","atom",T.key,"set to",Y),Y=I4($,T.key,Y,T.subject),t5($,T.key))a5($,T.key);L1($,T.key),nU($,T);let U={oldValue:X,newValue:Y};if(!l4($)){l5($,T,U);return}if($.on.transactionApplying.state===null){let{key:G}=T;if(n5(U.newValue))return;let J={type:"atom_update",key:G,...U};if(T.family)J.family=T.family;$.transactionMeta.update.updates.push(J),$.logger.info("\uD83D\uDCC1","atom",G,"stowed (",U.oldValue,"->",U.newValue,")")}else if(T.key.startsWith("*")){let G=T.key.slice(1),J=$.atoms.get(G),z=$.valueMap.get(G);if(J.type==="mutable_atom"&&l4($)){let{parent:H}=$;z=UW($,J,H)}if(z.do(U.newValue)===null)nU($,J)}};var yX=($,T,W)=>{switch(T.type){case"atom":case"mutable_atom":i5($,T,W);break;case"writable_pure_selector":case"writable_held_selector":T.set(W);break}};var hX=($,T)=>s($).atoms.has(T),EA=($,T)=>s($).writableSelectors.has(T),MA=($,T)=>s($).readonlySelectors.has(T),s5=($,T)=>hX($,T)||EA($,T)||MA($,T);var gX=($,T)=>{return s($).selectorGraph.getRelationEntries({downstreamSelectorKey:T}).filter(([X,{source:Y}])=>Y!==T).map(([X,{source:Y}])=>Y).filter((X)=>s5($,X))};var tU=($,T,W)=>{let X=[],Y=gX($,T);while(Y.length>0){let U=Y.shift();if(W.has(U))continue;if(W.add(U),!hX($,U))Y.push(...gX($,U));else if(!X.includes(U))X.push(U)}return X},e5=($,T)=>{let W=$.key,X=gX(T,W),Y=new Set;return X.flatMap((U)=>hX(T,U)?U:tU(T,U,Y))};var $3=($,T,W,X,Y)=>{let U=s($),{type:G,key:J}=X;if(G==="atom"||G==="mutable_atom")U.selectorAtoms.set({selectorKey:W,atomKey:J}),$.logger.info("\uD83D\uDD0D",T,W,`discovers root atom "${J}"`);else{let z=tU($,J,Y);$.logger.info("\uD83D\uDD0D",T,W,`discovers root atoms: [ ${z.map((w)=>`"${w}"`).join(", ")} ]`);for(let w of z)U.selectorAtoms=U.selectorAtoms.set({selectorKey:W,atomKey:w})}Y.add(J)};var S1=($,T,W,X)=>({get:(...Y)=>{let U=s($),G;if(Y.length===2){let[H,_]=Y;G=r4($,H,_)}else[G]=Y;let J=j4($,G),z=N1($,J),w=G.key;return $.logger.info("\uD83D\uDD0C",T,W,`registers dependency ( "${w}" =`,z,")"),U.selectorGraph.set({upstreamSelectorKey:w,downstreamSelectorKey:W},{source:G.key}),$3($,T,W,G,X),z},set:(...Y)=>{let U,G;if(Y.length===2)U=Y[0],G=Y[1];else{let w=Y[0],H=Y[1];G=Y[2],U=r4($,w,H)}let J=s($),z=j4(J,U);yX(J,z,G)},find:(...Y)=>r4($,...Y),json:(Y)=>p0($,Y)});var aU=($,T,W)=>{let X=s($),Y=new K$,U=new Set,{key:G,const:J}=T,z="readonly_held_selector",{get:w,find:H,json:_}=S1(X,"readonly_held_selector",G,U),D={...T,type:"readonly_held_selector",subject:Y,install:(E)=>aU(E,T,W),get:()=>{return T.get({get:w,find:H,json:_},J),I4(s($),G,J,Y),U.clear(),J},...W&&{family:W}};X.readonlySelectors.set(G,D),$.logger.info("\u2728","readonly_held_selector",G,"=",J);let V={key:G,type:"readonly_held_selector"};if(W)V.family=W;return V};var sU=($,T,W)=>{let X=s($),Y=new K$,U=new Set,G=T.key,J="readonly_pure_selector",{get:z,find:w,json:H}=S1(X,"readonly_pure_selector",G,U),_=()=>{let E=T.get({get:z,find:w,json:H});return I4(s($),G,E,Y),U.clear(),E},F={...T,type:"readonly_pure_selector",subject:Y,install:(E)=>sU(E,T,W),get:_,...W&&{family:W}};X.readonlySelectors.set(G,F);let D=_();$.logger.info("\u2728","readonly_pure_selector",G,"=",D);let V={key:G,type:"readonly_pure_selector"};if(W)V.family=W;return V};var eU=($,T,W)=>{let X=s($),Y=new K$,U=new Set,{key:G,const:J}=T,z="writable_held_selector",w=S1(X,"writable_held_selector",G,U),{find:H,get:_,json:F}=w,D={find:H,get:_,json:F},V=(N=T.get,k=s($))=>{return N(D,J),I4(k,G,J,Y),U.clear(),J},R={...T,type:"writable_held_selector",subject:Y,install:(N)=>eU(N,T,W),get:V,set:(N)=>{let k=s($),y=V(T.get,k),x=u0(N)(y);if($.logger.info("\uD83D\uDCDD","writable_held_selector",G,"set (",y,"->",x,")"),I4(k,G,x,Y),L1(k,G),A1(k))Y.next({newValue:x,oldValue:y});T.set(w,x)},...W&&{family:W}};X.writableSelectors.set(G,R);let P=V();$.logger.info("\u2728","writable_held_selector",G,"=",P);let A={key:G,type:"writable_held_selector"};if(W)A.family=W;return A};var GW=($,T,W)=>{let X=s($),Y=new K$,U=new Set,G=T.key,J="writable_pure_selector",z=S1(X,"writable_pure_selector",G,U),{find:w,get:H,json:_}=z,F={find:w,get:H,json:_},D=(A=T.get,N=s($))=>{let k=A(F);return I4(N,G,k,Y),U.clear(),k},E={...T,type:"writable_pure_selector",subject:Y,install:(A)=>GW(A,T,W),get:D,set:(A)=>{let N=s($),k=D(T.get,N),y=u0(A)(k);if($.logger.info("\uD83D\uDCDD","writable_pure_selector",G,"set (",k,"->",y,")"),I4(N,T.key,y,Y),L1(N,T.key),A1(N))Y.next({newValue:y,oldValue:k});T.set(z,y)},...W&&{family:W}};X.writableSelectors.set(G,E);let R=D();$.logger.info("\u2728",E.type,E.key,"=",R);let P={key:G,type:"writable_pure_selector"};if(W)P.family=W;return P};function h5($,T){let W="set"in T,X="const"in T;if(X&&W){let U=eU($,T,void 0);return $.on.selectorCreation.next(U),U}if(X){let U=aU($,T,void 0);return $.on.selectorCreation.next(U),U}if(W){let U=GW($,T,void 0);return $.on.selectorCreation.next(U),U}let Y=sU($,T,void 0);return $.on.selectorCreation.next(Y),Y}function oU($,T,W){let X=T.key,Y="writable_pure_selector_family",U={key:X,type:"writable_pure_selector_family"},G=$.families.get(X);if(G)$.logger.error("\u2757","writable_pure_selector_family",X,`Overwriting an existing ${fX(G)} "${G.key}" in store "${$.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);let J=new K$,w=Object.assign((H)=>{let _=R4(H),F={key:X,subKey:_},D=`${X}(${_})`,V=s($),E=GW(V,{key:D,get:T.get(H),set:T.set(H)},F);return J.next({type:"state_creation",token:E}),E},U,{internalRoles:W,subject:J,install:(H)=>oU(H,T),default:(H)=>{return T.get(H)({get:(...F)=>JW($,...F),find:(...F)=>r4($,...F),json:(F)=>p0($,F)})}});return $.families.set(X,w),U}function T3($,T,W){let X=$.families.get(T.key);if(X===void 0)throw new YW(T,$);let Y=X(W),U=s($);if(Y.family){if(A1(U))switch(Y.type){case"atom":case"mutable_atom":$.on.atomCreation.next(Y);break;case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":$.on.selectorCreation.next(Y);break}else if(l4(U)&&U.on.transactionApplying.state===null)U.transactionMeta.update.updates.push({type:"state_creation",token:Y})}return Y}function W3($,T,W){let X=R4(W),Y=`${T.key}(${X})`,U=s($),G;switch(T.type){case"atom_family":case"mutable_atom_family":G=U.atoms.get(Y);break;case"writable_held_selector_family":case"writable_pure_selector_family":G=U.writableSelectors.get(Y);break;case"readonly_held_selector_family":case"readonly_pure_selector_family":G=U.readonlySelectors.get(Y);break}if(G)return XW(G);return G}function r4($,T,W){let X=W3($,T,W);if(X)return X;let Y=R4(W),U=$.molecules.get(Y);if(!U&&$.config.lifespan==="immortal"){let G=m5(T,W);return $.logger.error("\u274C",G.type,G.key,`was not found in store "${$.config.name}"; returned a counterfeit token.`),G}if(X=T3($,T,W),U)s($).moleculeData.set(Y,T.key);return X}function X3($,T){if(T.family){let W=$.families.get(T.family.key);if(W)return W}}function B1($,...T){let W,X,Y,U;if(T.length===2){if(W=T[0],U=T[1],X=X3($,W)??null,X)Y=W.family?WW(W.family.subKey):null,W=r4($,X,Y)}else X=T[0],Y=T[1],U=T[2],W=r4($,X,Y);if("counterfeit"in W&&"family"in W){let z=W.family.subKey,w=$.disposalTraces.buffer.find((H)=>H?.key===z);$.logger.error("\u274C",W.type,W.key,`could not be set because it was not found in the store "${$.config.name}".`,w?`This state was previously disposed:
|
|
4
|
-
${
|
|
5
|
-
${G.trace}`:"No previous disposal trace was found."),X.type){case"atom_family":case"mutable_atom_family":return $.defaults.get(X.key);case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if($.defaults.has(X.key))return $.defaults.get(W.family.key);let J=j4($,X).default(U);return $.defaults.set(X.key,J),J}}}return N1($,j4($,W))}class Y3{parent=null;child=null;valueMap=new Map;defaults=new Map;atoms=new Map;writableSelectors=new Map;readonlySelectors=new Map;atomsThatAreDefault=new Set;selectorAtoms=new P6({between:["selectorKey","atomKey"],cardinality:"n:n"});selectorGraph=new P6({between:["upstreamSelectorKey","downstreamSelectorKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});trackers=new Map;families=new Map;joins=new Map;transactions=new Map;transactionMeta={epoch:new Map,actionContinuities:new P6({between:["continuity","action"],cardinality:"1:n"})};timelines=new Map;timelineTopics=new P6({between:["timelineKey","topicKey"],cardinality:"1:n"});disposalTraces=new bX(100);molecules=new Map;moleculeJoins=new P6({between:["moleculeKey","joinKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});moleculeGraph=new P6({between:["upstreamMoleculeKey","downstreamMoleculeKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});moleculeData=new P6({between:["moleculeKey","stateFamilyKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});miscResources=new Map;on={atomCreation:new K$,atomDisposal:new K$,selectorCreation:new K$,selectorDisposal:new K$,timelineCreation:new K$,transactionCreation:new K$,transactionApplying:new iU(null),operationClose:new K$,moleculeCreation:new K$,moleculeDisposal:new K$};operation={open:!1};config={name:"IMPLICIT_STORE",lifespan:"ephemeral"};loggers=[new rU("warn",($,T,W)=>!G3(W))];logger={error:(...$)=>{for(let T of this.loggers)T.error(...$)},info:(...$)=>{for(let T of this.loggers)T.info(...$)},warn:(...$)=>{for(let T of this.loggers)T.warn(...$)}};constructor($,T=null){if(this.config={...T?.config,...$},T!==null){if(this.valueMap=new Map(T?.valueMap),this.operation={...T?.operation},A1(T))this.transactionMeta={epoch:new Map(T?.transactionMeta.epoch),actionContinuities:new P6(T?.transactionMeta.actionContinuities.toJSON())};for(let[,X]of T.families){if(X.internalRoles?.includes("mutable")||X.internalRoles?.includes("join"))continue;X.install(this)}let W=new Set;for(let[,X]of T.atoms){if(W.has(X.key))continue;if(X.install(this),X.type==="mutable_atom"){let Y=p0(T,X),U=U3(X);W.add(Y.key),W.add(U.key)}}for(let[,X]of T.readonlySelectors)X.install(this);for(let[,X]of T.writableSelectors){if(W.has(X.key))continue;X.install(this)}for(let[,X]of T.transactions)X.install(this);for(let[,X]of T.timelines)X.install(this)}}}var g5={get STORE(){return globalThis.ATOM_IO_IMPLICIT_STORE??=new Y3({name:"IMPLICIT_STORE",lifespan:"ephemeral"}),globalThis.ATOM_IO_IMPLICIT_STORE}};function j4($,T){let W,X=$;while(X!==null){switch(T.type){case"atom":case"mutable_atom":W=X.atoms.get(T.key);break;case"writable_pure_selector":case"writable_held_selector":W=X.writableSelectors.get(T.key);break;case"readonly_pure_selector":case"readonly_held_selector":W=X.readonlySelectors.get(T.key);break;case"atom_family":case"mutable_atom_family":case"writable_pure_selector_family":case"readonly_pure_selector_family":case"writable_held_selector_family":case"readonly_held_selector_family":W=X.families.get(T.key);break;case"timeline":W=X.timelines.get(T.key);break;case"transaction":W=X.transactions.get(T.key);break}if(W)return W;X=X.child}throw new YW(T,$)}var J3=($,T)=>{let W=s($);if(W.operation.open)return W.operation.prev.get(T.key);return W.valueMap.get(T.key)};var $G=($,T)=>{let W=s($);return e5(T,$).map((Y)=>{let U=W.atoms.get(Y);if(U===void 0)throw new Error(`Atom "${Y}", a dependency of selector "${T.key}", not found in store "${$.config.name}".`);return U.subject.subscribe(`${T.type}:${T.key}`,(G)=>{$.logger.info("\uD83D\uDCE2",T.type,T.key,"root",Y,"went",G.oldValue,"->",G.newValue);let J=J3(W,T),z=N1(W,T);$.logger.info("\u2728",T.type,T.key,"went",J,"->",z),T.subject.next({newValue:z,oldValue:J})})})};function wW($,T,W,X){function Y(_){if($.operation.open){let F=$.on.operationClose.subscribe(`state subscription ${W}`,()=>{F(),X(_)})}else X(_)}let U=j4($,T);$.logger.info("\uD83D\uDC40",U.type,U.key,`Adding subscription "${W}"`);let G=U.type==="writable_pure_selector"||U.type==="readonly_pure_selector",J=null,z=Y;if(G)J=$G($,U),z=(_)=>{if(J)J.length=0,J.push(...$G($,U));Y(_)};let w=U.subject.subscribe(W,z);return()=>{if($.logger.info("\uD83D\uDE48",U.type,U.key,`Removing subscription "${W}"`),w(),J)for(let _ of J)_()}}var w3=($,T,W,X)=>{let Y=j4($,T);$.logger.info("\uD83D\uDC40","timeline",T.key,`Adding subscription "${W}"`);let U=Y.subject.subscribe(W,X);return()=>{$.logger.info("\uD83D\uDE48","timeline",T.key,`Removing subscription "${W}" from timeline`),U()}};class TG{initializeState($,T){let W=`*${$.key}`;T.atoms.delete(W),T.valueMap.delete(W);let X=$.family?{key:`*${$.family.key}`,subKey:$.family.subKey}:void 0,Y=WG(T,{key:W,default:null},X);if(T.parent?.valueMap.has(W)){let U=T.parent.valueMap.get(W);T.valueMap.set(W,U)}return Y}unsubscribeFromInnerValue;unsubscribeFromState;observeCore($,T,W){let X=`tracker:${W.config.name}:${l4(W)?W.transactionMeta.update.key:"main"}:${$.key}`,Y=JW(W,$);this.unsubscribeFromInnerValue=Y.subscribe(X,(U)=>{B1(W,T,U)}),this.unsubscribeFromState=wW(W,$,X,(U)=>{if(U.newValue!==U.oldValue)this.unsubscribeFromInnerValue(),this.unsubscribeFromInnerValue=U.newValue.subscribe(X,(G)=>{B1(W,T,G)})})}updateCore($,T,W){let X=`tracker:${W.config.name}:${l4(W)?W.transactionMeta.update.key:"main"}:${$.key}`;wW(W,T,X,({newValue:Y,oldValue:U})=>{let G=W.timelineTopics.getRelatedKey(T.key);if(G){if(W.timelines.get(G)?.timeTraveling){let w=w3(W,{key:G,type:"timeline"},X,(H)=>{w(),B1(W,$,(_)=>{if(H==="redo"&&Y)_.do(Y);else if(H==="undo"&&U)_.undo(U);return _})});return}}let J=W.on.operationClose.subscribe(X,()=>{J();let z=JW(W,$),w=Y===null?-1:z.getUpdateNumber(Y),H=w-z.cacheUpdateNumber;if(Y&&H===1)B1(W,$,(_)=>(_.do(Y),_));else W.logger.info("\u274C","mutable_atom",$.key,`could not be updated. Expected update number ${z.cacheUpdateNumber+1}, but got ${w}`)})})}mutableState;latestUpdateState;[Symbol.dispose];constructor($,T){this.mutableState=$;let W=s(T);this.latestUpdateState=this.initializeState($,W),this.observeCore($,this.latestUpdateState,W),this.updateCore($,this.latestUpdateState,W),W.trackers.set($.key,this),this[Symbol.dispose]=()=>{this.unsubscribeFromInnerValue(),this.unsubscribeFromState(),W.trackers.delete($.key)}}}var p0=($,T)=>{if(T.family){let X=s($),U={key:`${T.family.key}:JSON`,type:"writable_pure_selector_family"},G=j4(X,U),J=JSON.parse(T.family.subKey);return r4($,G,J)}return{type:"writable_pure_selector",key:`${T.key}:JSON`}};var U3=($)=>{let W={type:"atom",key:`*${$.key}`};if($.family)W.family={key:`*${$.family.key}`,subKey:$.family.subKey};return W};function n5($){return typeof $==="object"&&$!==null&&"do"in $&&"undo"in $&&"subscribe"in $}function UW($,T,W){let X=W.valueMap.get(T.key),Y=$.valueMap.get(T.key);if(X!==Y)return Y;if(X===void 0)return T.default();W.logger.info("\uD83D\uDCC3","atom",T.key,"copying");let U=T.toJson(X),G=T.fromJson(U);return $.valueMap.set(T.key,G),new TG(T,W),G}function I4($,T,W,X){let Y=$.valueMap.get(T);if(Y instanceof TW)Y.use(W);if(W instanceof Promise){let U=new TW(W);return $.valueMap.set(T,U),U.then((G)=>{I4($,T,G,X),X.next({newValue:G,oldValue:U})}).catch((G)=>{$.logger.error("\uD83D\uDCA5","state",T,"rejected:",G)}),U}return $.valueMap.set(T,W),W}var u5=($,T)=>{let W=T.valueMap.get($.key);if($.type==="mutable_atom"&&l4(T)){let{parent:X}=T;W=UW(T,$,X)}return W},r5=($,T)=>{let W=T.valueMap.get($);if(W instanceof TW){let X=W,Y=T.writableSelectors.get($)??T.readonlySelectors.get($);if(Y)X.use(Y.get());return}if(T.operation.open)T.operation.prev.set($,W);T.valueMap.delete($),T.logger.info("\uD83D\uDDD1","state",$,"evicted")};var t5=($,T)=>{return s($).atomsThatAreDefault.has(T)},z3=($,T)=>{let W=s($);W.atomsThatAreDefault=new Set(W.atomsThatAreDefault).add(T)},a5=($,T)=>{let W=s($);W.atomsThatAreDefault=new Set(s($).atomsThatAreDefault),W.atomsThatAreDefault.delete(T)};function WG($,T,W){let{key:Y,default:U}=T;$.logger.info("\uD83D\uDD28","atom",Y,`creating in store "${$.config.name}"`);let G=s($),J=G.atoms.get(Y);if(J&&J.type==="atom")return $.logger.error("\u274C","atom",Y,"Tried to create atom, but it already exists in the store."),XW(J);let z=new K$,w={...T,type:"atom",install:(F)=>{return F.logger.info("\uD83D\uDEE0\uFE0F","atom",Y,`installing in store "${F.config.name}"`),WG(F,T,W)},subject:z};if(W)w.family=W;let H=U;if(U instanceof Function)H=U();G.atoms.set(Y,w),z3($,Y),I4(G,Y,H,z);let _=XW(w);if(T.effects){let F=0,D=[];for(let V of T.effects){let E=V({setSelf:(R)=>{B1($,_,R)},onSet:(R)=>wW($,_,`effect[${F}]`,R)});if(E)D.push(E);++F}w.cleanup=()=>{for(let V of D)V()}}return _}class d0 extends Set{mode="record";subject=new K$;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor($,T=0){super($);if($ instanceof d0)this.parent=$,this.cacheUpdateNumber=$.cacheUpdateNumber;if(T)this.cacheLimit=T,this.cache=new Array(T),this.subscribe("auto cache",(W)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=W})}toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON($){let T=new d0($.members,$.cacheLimit);return T.cache=$.cache,T.cacheIdx=$.cacheIdx,T.cacheUpdateNumber=$.cacheUpdateNumber,T}add($){let T=super.add($);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${R4($)}`);return T}clear(){let $=this.mode==="record"?[...this]:null;if(super.clear(),$)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify($)}`)}delete($){let T=super.delete($);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${R4($)}`);return T}parent=null;child=null;transactionUpdates=null;transaction($){this.mode="transaction",this.transactionUpdates=[],this.child=new d0(this);let T=this.child._subscribe("transaction",(W)=>{this.transactionUpdates?.push(W)});try{if($(this.child)){for(let X of this.transactionUpdates)this.doStep(X);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(W){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",W),W}finally{T(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe($,T){return this.subject.subscribe($,T)}subscribe($,T){return this.subject.subscribe($,(W)=>{T(`${this.cacheUpdateNumber}=${W}`)})}emit($){this.subject.next($)}doStep($){let T=$.indexOf(":"),W=$.substring(0,T),X=$.substring(T+1);switch(W){case"add":this.add(JSON.parse(X));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(X));break;case"tx":for(let Y of X.split(";"))this.doStep(Y)}}getUpdateNumber($){let T=$.indexOf("=");return Number($.substring(0,T))}do($){let T=$.indexOf("="),W=Number($.substring(0,T)),X=W-this.cacheUpdateNumber;if(X>0){if(X===1){this.mode="playback";let U=$.substring(T+1);return this.doStep(U),this.mode="record",this.cacheUpdateNumber=W,null}return this.cacheUpdateNumber+1}if(Math.abs(X)<this.cacheLimit){let U=this.cacheIdx+X;if(this.cache[U]===$)return null;this.mode="playback";let J=!1;while(!J){this.cacheIdx%=this.cacheLimit;let w=this.cache[this.cacheIdx];if(this.cacheIdx--,!w)return"OUT_OF_RANGE";this.undo(w),J=this.cacheIdx===U-1}let z=$.substring(T+1);return this.doStep(z),this.mode="record",this.cacheUpdateNumber=W,null}return"OUT_OF_RANGE"}undoStep($){let T=$.indexOf(":"),W=$.substring(0,T),X=$.substring(T+1);switch(W){case"add":this.delete(JSON.parse(X));break;case"del":this.add(JSON.parse(X));break;case"clear":{let Y=JSON.parse(X);for(let U of Y)this.add(U);break}case"tx":{let Y=X.split(";");for(let U=Y.length-1;U>=0;U--)this.undoStep(Y[U])}}}undo($){let T=$.indexOf("=");if(Number($.substring(0,T))===this.cacheUpdateNumber){this.mode="playback";let X=$.substring(T+1);return this.undoStep(X),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}}function G3($){return $.startsWith("\uD83D\uDD0D ")}class mX{listeners;globalListeners;handleEvent($,...T){for(let X of this.globalListeners)X($,...T);let W=this.listeners.get($);if(W)for(let X of W)X(...T)}id="no_id_retrieved";emit;constructor($){this.emit=$,this.listeners=new Map,this.globalListeners=new Set}on($,T){let W=this.listeners.get($);if(W)W.add(T);else this.listeners.set($,new Set([T]));return this}onAny($){return this.globalListeners.add($),this}off($,T){let W=this.listeners.get($);if(W)if(T)W.delete(T);else this.listeners.delete($);return this}offAny($){return this.globalListeners.delete($),this}}class _3 extends mX{in;out;id="no_id_retrieved";disposalFunctions=[];constructor($){super((...T)=>{return this.out.next(T),this});this.id=$,this.in=new K$,this.out=new K$,this.in.subscribe("socket",(T)=>{this.handleEvent(...T)})}dispose(){for(let $ of this.disposalFunctions)$()}}class XG extends mX{incompleteData="";unprocessedEvents=[];relays;relayServices;process;id="#####";log(...$){this.process.stderr.write(R4($.map((T)=>T instanceof d0?`{ ${T.toJSON().members.join(" | ")} }`:T))+"\x03")}logger={info:(...$)=>{this.log("i",...$)},warn:(...$)=>{this.log("w",...$)},error:(...$)=>{this.log("e",...$)}};constructor(){super(($,...T)=>{let W=JSON.stringify([$,...T]);return this.process.stdout.write(W+"\x03"),this});if(this.process=process,this.process.stdin.resume(),this.relays=new Map,this.relayServices=[],this.process.stdin.on("data",($)=>{let T=$.toString();this.unprocessedEvents.push(...T.split("\x03"));let W=this.unprocessedEvents.shift();this.incompleteData+=W??"";try{let X=WW(this.incompleteData);this.logger.info("\uD83C\uDFB0","received",X),this.handleEvent(...X);while(this.unprocessedEvents.length>0){let Y=this.unprocessedEvents.shift();if(Y){if(this.unprocessedEvents.length===0)this.incompleteData=Y;let U=WW(Y);this.handleEvent(...U)}}this.incompleteData=""}catch(X){if(X instanceof Error)this.logger.error("\u2757",X.message,X.cause,X.stack)}}),this.on("exit",()=>{this.logger.info("\uD83D\uDD25",this.id,'received "exit"'),process.exit(0)}),process.on("exit",($)=>{this.logger.info("\uD83D\uDD25",this.id,`exited with code ${$}`)}),process.on("end",()=>{this.logger.info("\uD83D\uDD25",this.id,"ended"),process.exit(0)}),process.on("SIGTERM",()=>{this.logger.error("\uD83D\uDD25",this.id,"terminated"),process.exit(0)}),process.on("SIGINT",()=>{this.logger.error("\uD83D\uDD25",this.id,"interrupted"),process.exit(0)}),process.pid)this.id=process.pid?.toString();this.on("user-joins",($)=>{this.logger.info("\uD83D\uDC64","user",$,"joined");let T=new _3(`user:${$}`);this.relays.set($,T),this.logger.info("\uD83D\uDD17","attaching services:",`[${[...this.relayServices.keys()].join(", ")}]`);for(let W of this.relayServices){let X=W(T);if(X)T.disposalFunctions.push(X)}this.on(`user:${$}`,(...W)=>{T.in.next(W)}),T.out.subscribe("socket",(W)=>{this.emit(...W)})}),this.on("user-leaves",($)=>{let T=this.relays.get($);if(this.off(`relay:${$}`),T)T.dispose(),this.relays.delete($)}),process.stdout.write("ALIVE")}relay($){this.logger.info("\uD83D\uDD17","running relay method"),this.relayServices.push($)}}var cY={};M1(cY,{xid:()=>DB,void:()=>bB,uuidv7:()=>wB,uuidv6:()=>JB,uuidv4:()=>GB,uuid:()=>UB,url:()=>zB,uppercase:()=>CW,unknown:()=>jY,union:()=>gY,undefined:()=>jB,ulid:()=>ZB,uint64:()=>CB,uint32:()=>kB,tuple:()=>uB,trim:()=>yW,treeifyError:()=>DG,transform:()=>Oz,toUpperCase:()=>gW,toLowerCase:()=>hW,toJSONSchema:()=>bw,templateLiteral:()=>aB,symbol:()=>vB,superRefine:()=>zF,success:()=>nB,stringbool:()=>TR,string:()=>ow,strictObject:()=>gB,startsWith:()=>jW,size:()=>kW,setErrorMap:()=>JR,set:()=>oB,safeParseAsync:()=>pw,safeParse:()=>uw,registry:()=>GY,regexes:()=>s1,regex:()=>qW,refine:()=>wF,record:()=>yH,readonly:()=>WF,property:()=>qw,promise:()=>sB,prettifyError:()=>OG,preprocess:()=>XR,prefault:()=>nH,positive:()=>Bw,pipe:()=>fY,partialRecord:()=>pB,parseAsync:()=>cw,parse:()=>mw,overwrite:()=>o6,optional:()=>xY,object:()=>hB,number:()=>LH,nullish:()=>iB,nullable:()=>bY,null:()=>kH,normalize:()=>fW,nonpositive:()=>Iw,nonoptional:()=>tH,nonnegative:()=>kw,never:()=>yY,negative:()=>Rw,nativeEnum:()=>lB,nanoid:()=>HB,nan:()=>tB,multipleOf:()=>$0,minSize:()=>T0,minLength:()=>I1,mime:()=>bW,maxSize:()=>r0,maxLength:()=>i0,map:()=>dB,lte:()=>U6,lt:()=>p6,lowercase:()=>PW,looseObject:()=>mB,locales:()=>BW,literal:()=>uH,length:()=>n0,lazy:()=>UF,ksuid:()=>OB,keyof:()=>yB,jwt:()=>SB,json:()=>WR,iso:()=>qY,ipv6:()=>KB,ipv4:()=>VB,intersection:()=>bH,int64:()=>PB,int32:()=>IB,int:()=>lw,instanceof:()=>$R,includes:()=>vW,guid:()=>YB,gte:()=>b4,gt:()=>d6,globalRegistry:()=>v6,getErrorMap:()=>wR,function:()=>xw,formatError:()=>EW,float64:()=>RB,float32:()=>BB,flattenError:()=>KW,file:()=>rB,enum:()=>mH,endsWith:()=>xW,emoji:()=>_B,email:()=>XB,e164:()=>LB,discriminatedUnion:()=>cB,date:()=>fB,custom:()=>eB,cuid2:()=>QB,cuid:()=>FB,core:()=>l6,config:()=>n$,coerce:()=>dw,clone:()=>i4,cidrv6:()=>MB,cidrv4:()=>EB,check:()=>JF,catch:()=>eH,boolean:()=>SH,bigint:()=>qB,base64url:()=>NB,base64:()=>AB,array:()=>Qz,any:()=>xB,_default:()=>rH,_ZodString:()=>rw,ZodXID:()=>Tz,ZodVoid:()=>CH,ZodUnknown:()=>Fz,ZodUnion:()=>Zz,ZodUndefined:()=>RH,ZodUUID:()=>r6,ZodURL:()=>nw,ZodULID:()=>$z,ZodType:()=>z$,ZodTuple:()=>fH,ZodTransform:()=>dH,ZodTemplateLiteral:()=>XF,ZodSymbol:()=>BH,ZodSuccess:()=>aH,ZodStringFormat:()=>f$,ZodString:()=>PY,ZodSet:()=>gH,ZodRecord:()=>Dz,ZodRealError:()=>a0,ZodReadonly:()=>TF,ZodPromise:()=>GF,ZodPrefault:()=>iH,ZodPipe:()=>Ez,ZodOptional:()=>Vz,ZodObject:()=>hY,ZodNumberFormat:()=>s0,ZodNumber:()=>cW,ZodNullable:()=>oH,ZodNull:()=>IH,ZodNonOptional:()=>Kz,ZodNever:()=>PH,ZodNanoID:()=>aw,ZodNaN:()=>$F,ZodMap:()=>hH,ZodLiteral:()=>cH,ZodLazy:()=>YF,ZodKSUID:()=>Wz,ZodJWT:()=>_z,ZodIssueCode:()=>YR,ZodIntersection:()=>xH,ZodIPv6:()=>Yz,ZodIPv4:()=>Xz,ZodGUID:()=>vY,ZodFile:()=>pH,ZodError:()=>tS,ZodEnum:()=>dW,ZodEmoji:()=>tw,ZodEmail:()=>iw,ZodE164:()=>zz,ZodDiscriminatedUnion:()=>jH,ZodDefault:()=>lH,ZodDate:()=>CY,ZodCustom:()=>mY,ZodCatch:()=>sH,ZodCUID2:()=>ew,ZodCUID:()=>sw,ZodCIDRv6:()=>Gz,ZodCIDRv4:()=>Uz,ZodBoolean:()=>uW,ZodBigIntFormat:()=>Hz,ZodBigInt:()=>pW,ZodBase64URL:()=>wz,ZodBase64:()=>Jz,ZodArray:()=>vH,ZodAny:()=>qH,NEVER:()=>GR,$output:()=>i9,$input:()=>n9,$brand:()=>YG});var l6={};M1(l6,{version:()=>_J,util:()=>g,treeifyError:()=>DG,toJSONSchema:()=>bw,toDotPath:()=>Q3,safeParseAsync:()=>KG,safeParse:()=>VG,registry:()=>GY,regexes:()=>s1,prettifyError:()=>OG,parseAsync:()=>lX,parse:()=>dX,locales:()=>BW,isValidJWT:()=>C3,isValidBase64URL:()=>P3,isValidBase64:()=>CJ,globalRegistry:()=>v6,globalConfig:()=>zW,function:()=>xw,formatError:()=>EW,flattenError:()=>KW,config:()=>n$,clone:()=>i4,_xid:()=>KY,_void:()=>Aw,_uuidv7:()=>HY,_uuidv6:()=>_Y,_uuidv4:()=>zY,_uuid:()=>wY,_url:()=>FY,_uppercase:()=>CW,_unknown:()=>Ew,_union:()=>RS,_undefined:()=>Ow,_ulid:()=>VY,_uint64:()=>Zw,_uint32:()=>ww,_tuple:()=>Cw,_trim:()=>yW,_transform:()=>bS,_toUpperCase:()=>gW,_toLowerCase:()=>hW,_templateLiteral:()=>dS,_symbol:()=>Dw,_success:()=>mS,_stringbool:()=>jw,_string:()=>t9,_startsWith:()=>jW,_size:()=>kW,_set:()=>CS,_safeParseAsync:()=>iX,_safeParse:()=>rX,_regex:()=>qW,_refine:()=>rS,_record:()=>qS,_readonly:()=>pS,_property:()=>qw,_promise:()=>lS,_positive:()=>Bw,_pipe:()=>uS,_parseAsync:()=>oX,_parse:()=>pX,_overwrite:()=>o6,_optional:()=>fS,_number:()=>Ww,_nullable:()=>yS,_null:()=>Vw,_normalize:()=>fW,_nonpositive:()=>Iw,_nonoptional:()=>gS,_nonnegative:()=>kw,_never:()=>Mw,_negative:()=>Rw,_nativeEnum:()=>jS,_nanoid:()=>ZY,_nan:()=>Sw,_multipleOf:()=>$0,_minSize:()=>T0,_minLength:()=>I1,_min:()=>b4,_mime:()=>bW,_maxSize:()=>r0,_maxLength:()=>i0,_max:()=>U6,_map:()=>PS,_lte:()=>U6,_lt:()=>p6,_lowercase:()=>PW,_literal:()=>xS,_length:()=>n0,_lazy:()=>oS,_ksuid:()=>EY,_jwt:()=>IY,_isoTime:()=>$w,_isoDuration:()=>Tw,_isoDateTime:()=>s9,_isoDate:()=>e9,_ipv6:()=>AY,_ipv4:()=>MY,_intersection:()=>kS,_int64:()=>Qw,_int32:()=>Jw,_int:()=>Yw,_includes:()=>vW,_guid:()=>IW,_gte:()=>b4,_gt:()=>d6,_float64:()=>Gw,_float32:()=>Uw,_file:()=>vw,_enum:()=>vS,_endsWith:()=>xW,_emoji:()=>QY,_email:()=>JY,_e164:()=>RY,_discriminatedUnion:()=>IS,_default:()=>hS,_date:()=>Nw,_custom:()=>mW,_cuid2:()=>OY,_cuid:()=>DY,_coercedString:()=>a9,_coercedNumber:()=>Xw,_coercedDate:()=>Lw,_coercedBoolean:()=>_w,_coercedBigint:()=>Fw,_cidrv6:()=>LY,_cidrv4:()=>NY,_catch:()=>cS,_boolean:()=>zw,_bigint:()=>Hw,_base64url:()=>BY,_base64:()=>SY,_array:()=>Pw,_any:()=>Kw,JSONSchemaGenerator:()=>kY,JSONSchema:()=>OH,Doc:()=>$Y,$output:()=>i9,$input:()=>n9,$constructor:()=>K,$brand:()=>YG,$ZodXID:()=>AJ,$ZodVoid:()=>pJ,$ZodUnknown:()=>NW,$ZodUnion:()=>UY,$ZodUndefined:()=>gJ,$ZodUUID:()=>QJ,$ZodURL:()=>DJ,$ZodULID:()=>MJ,$ZodType:()=>W$,$ZodTuple:()=>e1,$ZodTransform:()=>T9,$ZodTemplateLiteral:()=>H9,$ZodSymbol:()=>hJ,$ZodSuccess:()=>J9,$ZodStringFormat:()=>q$,$ZodString:()=>MW,$ZodSet:()=>aJ,$ZodRegistry:()=>RW,$ZodRecord:()=>nJ,$ZodRealError:()=>o0,$ZodReadonly:()=>_9,$ZodPromise:()=>F9,$ZodPrefault:()=>U9,$ZodPipe:()=>LW,$ZodOptional:()=>W9,$ZodObject:()=>lJ,$ZodNumberFormat:()=>fJ,$ZodNumber:()=>XY,$ZodNullable:()=>X9,$ZodNull:()=>mJ,$ZodNonOptional:()=>G9,$ZodNever:()=>uJ,$ZodNanoID:()=>VJ,$ZodNaN:()=>z9,$ZodMap:()=>tJ,$ZodLiteral:()=>eJ,$ZodLazy:()=>Q9,$ZodKSUID:()=>NJ,$ZodJWT:()=>bJ,$ZodIntersection:()=>iJ,$ZodISOTime:()=>BJ,$ZodISODuration:()=>RJ,$ZodISODateTime:()=>LJ,$ZodISODate:()=>SJ,$ZodIPv6:()=>kJ,$ZodIPv4:()=>IJ,$ZodGUID:()=>FJ,$ZodFunction:()=>t0,$ZodFile:()=>$9,$ZodError:()=>VW,$ZodEnum:()=>sJ,$ZodEmoji:()=>OJ,$ZodEmail:()=>ZJ,$ZodE164:()=>xJ,$ZodDiscriminatedUnion:()=>rJ,$ZodDefault:()=>Y9,$ZodDate:()=>dJ,$ZodCustom:()=>Z9,$ZodCheckUpperCase:()=>XJ,$ZodCheckStringFormat:()=>l0,$ZodCheckStartsWith:()=>UJ,$ZodCheckSizeEquals:()=>aG,$ZodCheckRegex:()=>TJ,$ZodCheckProperty:()=>JJ,$ZodCheckOverwrite:()=>zJ,$ZodCheckNumberFormat:()=>rG,$ZodCheckMultipleOf:()=>lG,$ZodCheckMinSize:()=>tG,$ZodCheckMinLength:()=>eG,$ZodCheckMimeType:()=>wJ,$ZodCheckMaxSize:()=>nG,$ZodCheckMaxLength:()=>sG,$ZodCheckLowerCase:()=>WJ,$ZodCheckLessThan:()=>sX,$ZodCheckLengthEquals:()=>$J,$ZodCheckIncludes:()=>YJ,$ZodCheckGreaterThan:()=>eX,$ZodCheckEndsWith:()=>GJ,$ZodCheckBigIntFormat:()=>iG,$ZodCheck:()=>u$,$ZodCatch:()=>w9,$ZodCUID2:()=>EJ,$ZodCUID:()=>KJ,$ZodCIDRv6:()=>PJ,$ZodCIDRv4:()=>qJ,$ZodBoolean:()=>AW,$ZodBigIntFormat:()=>yJ,$ZodBigInt:()=>YY,$ZodBase64URL:()=>jJ,$ZodBase64:()=>vJ,$ZodAsyncError:()=>u6,$ZodArray:()=>oJ,$ZodAny:()=>cJ});function K($,T,W){function X(J,z){var w;Object.defineProperty(J,"_zod",{value:J._zod??{},enumerable:!1}),(w=J._zod).traits??(w.traits=new Set),J._zod.traits.add($),T(J,z);for(let H in G.prototype)Object.defineProperty(J,H,{value:G.prototype[H].bind(J)});J._zod.constr=G,J._zod.def=z}let Y=W?.Parent??Object;class U extends Y{}Object.defineProperty(U,"name",{value:$});function G(J){var z;let w=W?.Parent?new U:this;X(w,J),(z=w._zod).deferred??(z.deferred=[]);for(let H of w._zod.deferred)H();return w}return Object.defineProperty(G,"init",{value:X}),Object.defineProperty(G,Symbol.hasInstance,{value:(J)=>{if(W?.Parent&&J instanceof W.Parent)return!0;return J?._zod?.traits?.has($)}}),Object.defineProperty(G,"name",{value:$}),G}var YG=Symbol("zod_brand");class u6 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}var zW={};function n$($){if($)Object.assign(zW,$);return zW}var g={};M1(g,{unwrapMessage:()=>_W,stringifyPrimitive:()=>u,required:()=>yA,randomString:()=>cX,propertyKeyTypes:()=>ZW,promiseAllObject:()=>kA,primitiveTypes:()=>_G,prefixIssues:()=>x4,pick:()=>vA,partial:()=>fA,optionalKeys:()=>HG,omit:()=>jA,numKeys:()=>qA,nullish:()=>R1,normalizeParams:()=>j,merge:()=>bA,jsonStringifyReplacer:()=>GG,joinValues:()=>q,issue:()=>ZG,isPlainObject:()=>QW,isObject:()=>uX,getValidEnumValues:()=>RA,getSizableOrigin:()=>DW,getParsedType:()=>PA,getLengthableOrigin:()=>OW,getElementAtPath:()=>IA,floatSafeRemainder:()=>JG,finalizeIssue:()=>n4,extend:()=>xA,escapeRegex:()=>C6,esc:()=>n1,defineLazy:()=>N$,createTransparentProxy:()=>CA,clone:()=>i4,cleanRegex:()=>FW,cleanEnum:()=>hA,cached:()=>HW,assignProp:()=>wG,assertNotEqual:()=>NA,assertNever:()=>SA,assertIs:()=>LA,assertEqual:()=>AA,assert:()=>BA,allowsEval:()=>zG,aborted:()=>t1,NUMBER_FORMAT_RANGES:()=>FG,Class:()=>H3,BIGINT_FORMAT_RANGES:()=>QG});function AA($){return $}function NA($){return $}function LA($){}function SA($){throw new Error}function BA($){}function RA($){let T=Object.keys($).filter((X)=>typeof $[$[X]]!=="number"),W={};for(let X of T)W[X]=$[X];return Object.values(W)}function q($,T="|"){return $.map((W)=>u(W)).join(T)}function GG($,T){if(typeof T==="bigint")return T.toString();return T}function HW($){return{get value(){{let W=$();return Object.defineProperty(this,"value",{value:W}),W}throw new Error("cached value already set")}}}function R1($){return $===null||$===void 0}function FW($){let T=$.startsWith("^")?1:0,W=$.endsWith("$")?$.length-1:$.length;return $.slice(T,W)}function JG($,T){let W=($.toString().split(".")[1]||"").length,X=(T.toString().split(".")[1]||"").length,Y=W>X?W:X,U=Number.parseInt($.toFixed(Y).replace(".","")),G=Number.parseInt(T.toFixed(Y).replace(".",""));return U%G/10**Y}function N$($,T,W){Object.defineProperty($,T,{get(){{let Y=W();return $[T]=Y,Y}throw new Error("cached value already set")},set(Y){Object.defineProperty($,T,{value:Y})},configurable:!0})}function wG($,T,W){Object.defineProperty($,T,{value:W,writable:!0,enumerable:!0,configurable:!0})}function IA($,T){if(!T)return $;return T.reduce((W,X)=>W?.[X],$)}function kA($){let T=Object.keys($),W=T.map((X)=>$[X]);return Promise.all(W).then((X)=>{let Y={};for(let U=0;U<T.length;U++)Y[T[U]]=X[U];return Y})}function cX($=10){let W="";for(let X=0;X<$;X++)W+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return W}function n1($){return JSON.stringify($)}function uX($){return typeof $==="object"&&$!==null}var zG=HW(()=>{try{return new Function(""),!0}catch($){return!1}});function QW($){return typeof $==="object"&&$!==null&&Object.getPrototypeOf($)===Object.prototype}function qA($){let T=0;for(let W in $)if(Object.prototype.hasOwnProperty.call($,W))T++;return T}var PA=($)=>{let T=typeof $;switch(T){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN($)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray($))return"array";if($===null)return"null";if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return"promise";if(typeof Map!=="undefined"&&$ instanceof Map)return"map";if(typeof Set!=="undefined"&&$ instanceof Set)return"set";if(typeof Date!=="undefined"&&$ instanceof Date)return"date";if(typeof File!=="undefined"&&$ instanceof File)return"file";return"object";default:throw new Error(`Unknown data type: ${T}`)}},ZW=new Set(["string","number","symbol"]),_G=new Set(["string","number","bigint","boolean","symbol","undefined"]);function C6($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i4($,T,W){let X=new $._zod.constr(T??$._zod.def);if(!T||W?.parent)X._zod.parent=$;return X}function j($){let T=$;if(!T)return{};if(typeof T==="string")return{error:()=>T};if(T?.message!==void 0){if(T?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");T.error=T.message}if(delete T.message,typeof T.error==="string")return{...T,error:()=>T.error};return T}function CA($){let T;return new Proxy({},{get(W,X,Y){return T??(T=$()),Reflect.get(T,X,Y)},set(W,X,Y,U){return T??(T=$()),Reflect.set(T,X,Y,U)},has(W,X){return T??(T=$()),Reflect.has(T,X)},deleteProperty(W,X){return T??(T=$()),Reflect.deleteProperty(T,X)},ownKeys(W){return T??(T=$()),Reflect.ownKeys(T)},getOwnPropertyDescriptor(W,X){return T??(T=$()),Reflect.getOwnPropertyDescriptor(T,X)},defineProperty(W,X,Y){return T??(T=$()),Reflect.defineProperty(T,X,Y)}})}function u($){if(typeof $==="bigint")return $.toString()+"n";if(typeof $==="string")return`"${$}"`;return`${$}`}function HG($){return Object.keys($).filter((T)=>{return $[T]._zod.optin==="optional"})}var FG={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},QG={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function vA($,T){let W={},X=$._zod.def;for(let Y in T){if(!(Y in X.shape))throw new Error(`Unrecognized key: "${Y}"`);if(!T[Y])continue;W[Y]=X.shape[Y]}return i4($,{...$._zod.def,shape:W,checks:[]})}function jA($,T){let W={...$._zod.def.shape},X=$._zod.def;for(let Y in T){if(!(Y in X.shape))throw new Error(`Unrecognized key: "${Y}"`);if(!T[Y])continue;delete W[Y]}return i4($,{...$._zod.def,shape:W,checks:[]})}function xA($,T){let W={...$._zod.def,get shape(){let X={...$._zod.def.shape,...T};return wG(this,"shape",X),X},checks:[]};return i4($,W)}function bA($,T){return i4($,{...$._zod.def,get shape(){let W={...$._zod.def.shape,...T._zod.def.shape};return wG(this,"shape",W),W},catchall:T._zod.def.catchall,checks:[]})}function fA($,T,W){let X=T._zod.def.shape,Y={...X};if(W)for(let U in W){if(!(U in X))throw new Error(`Unrecognized key: "${U}"`);if(!W[U])continue;Y[U]=$?new $({type:"optional",innerType:X[U]}):X[U]}else for(let U in X)Y[U]=$?new $({type:"optional",innerType:X[U]}):X[U];return i4(T,{...T._zod.def,shape:Y,checks:[]})}function yA($,T,W){let X=T._zod.def.shape,Y={...X};if(W)for(let U in W){if(!(U in Y))throw new Error(`Unrecognized key: "${U}"`);if(!W[U])continue;Y[U]=new $({type:"nonoptional",innerType:X[U]})}else for(let U in X)Y[U]=new $({type:"nonoptional",innerType:X[U]});return i4(T,{...T._zod.def,shape:Y,checks:[]})}function t1($,T=0){for(let W=T;W<$.issues.length;W++)if($.issues[W].continue!==!0)return!0;return!1}function x4($,T){return T.map((W)=>{var X;return(X=W).path??(X.path=[]),W.path.unshift($),W})}function _W($){return typeof $==="string"?$:$?.message}function n4($,T,W){let X={...$,path:$.path??[]};if(!$.message){let Y=_W($.inst?._zod.def?.error?.($))??_W(T?.error?.($))??_W(W.customError?.($))??_W(W.localeError?.($))??"Invalid input";X.message=Y}if(delete X.inst,delete X.continue,!T?.reportInput)delete X.input;return X}function DW($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function OW($){if(Array.isArray($))return"array";if(typeof $==="string")return"string";return"unknown"}function ZG(...$){let[T,W,X]=$;if(typeof T==="string")return{message:T,code:"custom",input:W,inst:X};return{...T}}function hA($){return Object.entries($).filter(([T,W])=>{return Number.isNaN(Number.parseInt(T,10))}).map((T)=>T[1])}class H3{constructor(...$){}}var F3=($,T)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:T,enumerable:!1}),Object.defineProperty($,"message",{get(){return JSON.stringify(T,GG,2)},enumerable:!0})},VW=K("$ZodError",F3),o0=K("$ZodError",F3,{Parent:Error});function KW($,T=(W)=>W.message){let W={},X=[];for(let Y of $.issues)if(Y.path.length>0)W[Y.path[0]]=W[Y.path[0]]||[],W[Y.path[0]].push(T(Y));else X.push(T(Y));return{formErrors:X,fieldErrors:W}}function EW($,T){let W=T||function(U){return U.message},X={_errors:[]},Y=(U)=>{for(let G of U.issues)if(G.code==="invalid_union")G.errors.map((J)=>Y({issues:J}));else if(G.code==="invalid_key")Y({issues:G.issues});else if(G.code==="invalid_element")Y({issues:G.issues});else if(G.path.length===0)X._errors.push(W(G));else{let J=X,z=0;while(z<G.path.length){let w=G.path[z];if(z!==G.path.length-1)J[w]=J[w]||{_errors:[]};else J[w]=J[w]||{_errors:[]},J[w]._errors.push(W(G));J=J[w],z++}}};return Y($),X}function DG($,T){let W=T||function(U){return U.message},X={errors:[]},Y=(U,G=[])=>{var J,z;for(let w of U.issues)if(w.code==="invalid_union")w.errors.map((H)=>Y({issues:H},w.path));else if(w.code==="invalid_key")Y({issues:w.issues},w.path);else if(w.code==="invalid_element")Y({issues:w.issues},w.path);else{let H=[...G,...w.path];if(H.length===0){X.errors.push(W(w));continue}let _=X,F=0;while(F<H.length){let D=H[F],V=F===H.length-1;if(typeof D==="string")_.properties??(_.properties={}),(J=_.properties)[D]??(J[D]={errors:[]}),_=_.properties[D];else _.items??(_.items=[]),(z=_.items)[D]??(z[D]={errors:[]}),_=_.items[D];if(V)_.errors.push(W(w));F++}}};return Y($),X}function Q3($){let T=[];for(let W of $)if(typeof W==="number")T.push(`[${W}]`);else if(typeof W==="symbol")T.push(`[${JSON.stringify(String(W))}]`);else if(/[^\w$]/.test(W))T.push(`[${JSON.stringify(W)}]`);else{if(T.length)T.push(".");T.push(W)}return T.join("")}function OG($){let T=[],W=[...$.issues].sort((X,Y)=>X.path.length-Y.path.length);for(let X of W)if(T.push(`\u2716 ${X.message}`),X.path?.length)T.push(` \u2192 at ${Q3(X.path)}`);return T.join(`
|
|
6
|
-
`)}var pX=($)=>(T,W,X,Y)=>{let U=X?Object.assign(X,{async:!1}):{async:!1},G=T._zod.run({value:W,issues:[]},U);if(G instanceof Promise)throw new u6;if(G.issues.length){let J=new(Y?.Err??$)(G.issues.map((z)=>n4(z,U,n$())));throw Error.captureStackTrace(J,Y?.callee),J}return G.value},dX=pX(o0),oX=($)=>async(T,W,X,Y)=>{let U=X?Object.assign(X,{async:!0}):{async:!0},G=T._zod.run({value:W,issues:[]},U);if(G instanceof Promise)G=await G;if(G.issues.length){let J=new(Y?.Err??$)(G.issues.map((z)=>n4(z,U,n$())));throw Error.captureStackTrace(J,Y?.callee),J}return G.value},lX=oX(o0),rX=($)=>(T,W,X)=>{let Y=X?{...X,async:!1}:{async:!1},U=T._zod.run({value:W,issues:[]},Y);if(U instanceof Promise)throw new u6;return U.issues.length?{success:!1,error:new($??VW)(U.issues.map((G)=>n4(G,Y,n$())))}:{success:!0,data:U.value}},VG=rX(o0),iX=($)=>async(T,W,X)=>{let Y=X?Object.assign(X,{async:!0}):{async:!0},U=T._zod.run({value:W,issues:[]},Y);if(U instanceof Promise)U=await U;return U.issues.length?{success:!1,error:new $(U.issues.map((G)=>n4(G,Y,n$())))}:{success:!0,data:U.value}},KG=iX(o0);var s1={};M1(s1,{xid:()=>NG,uuid7:()=>pA,uuid6:()=>uA,uuid4:()=>cA,uuid:()=>a1,uppercase:()=>oG,unicodeEmail:()=>lA,undefined:()=>pG,ulid:()=>AG,time:()=>bG,string:()=>yG,rfc5322Email:()=>oA,number:()=>mG,null:()=>uG,nanoid:()=>SG,lowercase:()=>dG,ksuid:()=>LG,ipv6:()=>tX,ipv4:()=>nX,ip:()=>nA,integer:()=>gG,html5Email:()=>dA,hostname:()=>vG,guid:()=>RG,extendedDuration:()=>mA,emoji:()=>kG,email:()=>IG,e164:()=>jG,duration:()=>BG,domain:()=>tA,datetime:()=>fG,date:()=>xG,cuid2:()=>MG,cuid:()=>EG,cidrv6:()=>PG,cidrv4:()=>qG,browserEmail:()=>rA,boolean:()=>cG,bigint:()=>hG,base64url:()=>aX,base64:()=>CG,_emoji:()=>iA});var EG=/^[cC][^\s-]{8,}$/,MG=/^[0-9a-z]+$/,AG=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,NG=/^[0-9a-vA-V]{20}$/,LG=/^[A-Za-z0-9]{27}$/,SG=/^[a-zA-Z0-9_-]{21}$/,BG=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,mA=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,RG=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,a1=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},cA=a1(4),uA=a1(6),pA=a1(7),IG=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,dA=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,oA=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,lA=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,rA=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,iA="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function kG(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var nX=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,tX=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,qG=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,PG=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nA=new RegExp(`(${nX.source})|(${tX.source})`),CG=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,aX=/^[A-Za-z0-9_-]*$/,vG=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,tA=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,jG=/^\+(?:[0-9]){6,14}[0-9]$/,Z3="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",xG=new RegExp(`^${Z3}$`);function D3($){let T="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)T=`${T}\\.\\d{${$.precision}}`;else if($.precision==null)T=`${T}(\\.\\d+)?`;return T}function bG($){return new RegExp(`^${D3($)}$`)}function fG($){let T=`${Z3}T${D3($)}`,W=[];if(W.push($.local?"Z?":"Z"),$.offset)W.push("([+-]\\d{2}:?\\d{2})");return T=`${T}(${W.join("|")})`,new RegExp(`^${T}$`)}var yG=($)=>{let T=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${T}$`)},hG=/^\d+n?$/,gG=/^\d+$/,mG=/^-?\d+(?:\.\d+)?/i,cG=/true|false/i,uG=/null/i;var pG=/undefined/i;var dG=/^[^A-Z]*$/,oG=/^[^a-z]*$/;var u$=K("$ZodCheck",($,T)=>{var W;$._zod??($._zod={}),$._zod.def=T,(W=$._zod).onattach??(W.onattach=[])}),V3={number:"number",bigint:"bigint",object:"date"},sX=K("$ZodCheckLessThan",($,T)=>{u$.init($,T);let W=V3[typeof T.value];$._zod.onattach.push((X)=>{let Y=X._zod.bag,U=(T.inclusive?Y.maximum:Y.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(T.value<U)if(T.inclusive)Y.maximum=T.value;else Y.exclusiveMaximum=T.value}),$._zod.check=(X)=>{if(T.inclusive?X.value<=T.value:X.value<T.value)return;X.issues.push({origin:W,code:"too_big",maximum:T.value,input:X.value,inclusive:T.inclusive,inst:$,continue:!T.abort})}}),eX=K("$ZodCheckGreaterThan",($,T)=>{u$.init($,T);let W=V3[typeof T.value];$._zod.onattach.push((X)=>{let Y=X._zod.bag,U=(T.inclusive?Y.minimum:Y.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(T.value>U)if(T.inclusive)Y.minimum=T.value;else Y.exclusiveMinimum=T.value}),$._zod.check=(X)=>{if(T.inclusive?X.value>=T.value:X.value>T.value)return;X.issues.push({origin:W,code:"too_small",minimum:T.value,input:X.value,inclusive:T.inclusive,inst:$,continue:!T.abort})}}),lG=K("$ZodCheckMultipleOf",($,T)=>{u$.init($,T),$._zod.onattach.push((W)=>{var X;(X=W._zod.bag).multipleOf??(X.multipleOf=T.value)}),$._zod.check=(W)=>{if(typeof W.value!==typeof T.value)throw new Error("Cannot mix number and bigint in multiple_of check.");if(typeof W.value==="bigint"?W.value%T.value===BigInt(0):JG(W.value,T.value)===0)return;W.issues.push({origin:typeof W.value,code:"not_multiple_of",divisor:T.value,input:W.value,inst:$,continue:!T.abort})}}),rG=K("$ZodCheckNumberFormat",($,T)=>{u$.init($,T),T.format=T.format||"float64";let W=T.format?.includes("int"),X=W?"int":"number",[Y,U]=FG[T.format];$._zod.onattach.push((G)=>{let J=G._zod.bag;if(J.format=T.format,J.minimum=Y,J.maximum=U,W)J.pattern=gG}),$._zod.check=(G)=>{let J=G.value;if(W){if(!Number.isInteger(J)){G.issues.push({expected:X,format:T.format,code:"invalid_type",input:J,inst:$});return}if(!Number.isSafeInteger(J)){if(J>0)G.issues.push({input:J,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:X,continue:!T.abort});else G.issues.push({input:J,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:X,continue:!T.abort});return}}if(J<Y)G.issues.push({origin:"number",input:J,code:"too_small",minimum:Y,inclusive:!0,inst:$,continue:!T.abort});if(J>U)G.issues.push({origin:"number",input:J,code:"too_big",maximum:U,inst:$})}}),iG=K("$ZodCheckBigIntFormat",($,T)=>{u$.init($,T);let[W,X]=QG[T.format];$._zod.onattach.push((Y)=>{let U=Y._zod.bag;U.format=T.format,U.minimum=W,U.maximum=X}),$._zod.check=(Y)=>{let U=Y.value;if(U<W)Y.issues.push({origin:"bigint",input:U,code:"too_small",minimum:W,inclusive:!0,inst:$,continue:!T.abort});if(U>X)Y.issues.push({origin:"bigint",input:U,code:"too_big",maximum:X,inst:$})}}),nG=K("$ZodCheckMaxSize",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!R1(X)&&X.size!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(T.maximum<X)W._zod.bag.maximum=T.maximum}),$._zod.check=(W)=>{let X=W.value;if(X.size<=T.maximum)return;W.issues.push({origin:DW(X),code:"too_big",maximum:T.maximum,input:X,inst:$,continue:!T.abort})}}),tG=K("$ZodCheckMinSize",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!R1(X)&&X.size!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(T.minimum>X)W._zod.bag.minimum=T.minimum}),$._zod.check=(W)=>{let X=W.value;if(X.size>=T.minimum)return;W.issues.push({origin:DW(X),code:"too_small",minimum:T.minimum,input:X,inst:$,continue:!T.abort})}}),aG=K("$ZodCheckSizeEquals",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!R1(X)&&X.size!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag;X.minimum=T.size,X.maximum=T.size,X.size=T.size}),$._zod.check=(W)=>{let X=W.value,Y=X.size;if(Y===T.size)return;let U=Y>T.size;W.issues.push({origin:DW(X),...U?{code:"too_big",maximum:T.size}:{code:"too_small",minimum:T.size},input:W.value,inst:$,continue:!T.abort})}}),sG=K("$ZodCheckMaxLength",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!R1(X)&&X.length!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(T.maximum<X)W._zod.bag.maximum=T.maximum}),$._zod.check=(W)=>{let X=W.value;if(X.length<=T.maximum)return;let U=OW(X);W.issues.push({origin:U,code:"too_big",maximum:T.maximum,input:X,inst:$,continue:!T.abort})}}),eG=K("$ZodCheckMinLength",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!R1(X)&&X.length!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(T.minimum>X)W._zod.bag.minimum=T.minimum}),$._zod.check=(W)=>{let X=W.value;if(X.length>=T.minimum)return;let U=OW(X);W.issues.push({origin:U,code:"too_small",minimum:T.minimum,input:X,inst:$,continue:!T.abort})}}),$J=K("$ZodCheckLengthEquals",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!R1(X)&&X.length!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag;X.minimum=T.length,X.maximum=T.length,X.length=T.length}),$._zod.check=(W)=>{let X=W.value,Y=X.length;if(Y===T.length)return;let U=OW(X),G=Y>T.length;W.issues.push({origin:U,...G?{code:"too_big",maximum:T.length}:{code:"too_small",minimum:T.length},input:W.value,inst:$,continue:!T.abort})}}),l0=K("$ZodCheckStringFormat",($,T)=>{var W;u$.init($,T),$._zod.onattach.push((X)=>{if(X._zod.bag.format=T.format,T.pattern)X._zod.bag.pattern=T.pattern}),(W=$._zod).check??(W.check=(X)=>{if(!T.pattern)throw new Error("Not implemented.");if(T.pattern.lastIndex=0,T.pattern.test(X.value))return;X.issues.push({origin:"string",code:"invalid_format",format:T.format,input:X.value,...T.pattern?{pattern:T.pattern.toString()}:{},inst:$,continue:!T.abort})})}),TJ=K("$ZodCheckRegex",($,T)=>{l0.init($,T),$._zod.check=(W)=>{if(T.pattern.lastIndex=0,T.pattern.test(W.value))return;W.issues.push({origin:"string",code:"invalid_format",format:"regex",input:W.value,pattern:T.pattern.toString(),inst:$,continue:!T.abort})}}),WJ=K("$ZodCheckLowerCase",($,T)=>{T.pattern??(T.pattern=dG),l0.init($,T)}),XJ=K("$ZodCheckUpperCase",($,T)=>{T.pattern??(T.pattern=oG),l0.init($,T)}),YJ=K("$ZodCheckIncludes",($,T)=>{u$.init($,T);let W=new RegExp(C6(T.includes));T.pattern=W,$._zod.onattach.push((X)=>{X._zod.bag.pattern=W}),$._zod.check=(X)=>{if(X.value.includes(T.includes,T.position))return;X.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:T.includes,input:X.value,inst:$,continue:!T.abort})}}),UJ=K("$ZodCheckStartsWith",($,T)=>{u$.init($,T);let W=new RegExp(`^${C6(T.prefix)}.*`);T.pattern??(T.pattern=W),$._zod.onattach.push((X)=>{X._zod.bag.pattern=W}),$._zod.check=(X)=>{if(X.value.startsWith(T.prefix))return;X.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:T.prefix,input:X.value,inst:$,continue:!T.abort})}}),GJ=K("$ZodCheckEndsWith",($,T)=>{u$.init($,T);let W=new RegExp(`.*${C6(T.suffix)}$`);T.pattern??(T.pattern=W),$._zod.onattach.push((X)=>{X._zod.bag.pattern=new RegExp(`.*${C6(T.suffix)}$`)}),$._zod.check=(X)=>{if(X.value.endsWith(T.suffix))return;X.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:T.suffix,input:X.value,inst:$,continue:!T.abort})}});function O3($,T,W){if($.issues.length)T.issues.push(...x4(W,$.issues))}var JJ=K("$ZodCheckProperty",($,T)=>{u$.init($,T),$._zod.check=(W)=>{let X=T.schema._zod.run({value:W.value[T.property],issues:[]},{});if(X instanceof Promise)return X.then((Y)=>O3(Y,W,T.property));O3(X,W,T.property);return}}),wJ=K("$ZodCheckMimeType",($,T)=>{u$.init($,T);let W=new Set(T.mime);$._zod.onattach.push((X)=>{X._zod.bag.mime=T.mime}),$._zod.check=(X)=>{if(W.has(X.value.type))return;X.issues.push({code:"invalid_value",values:T.mime,input:X.value.type,path:["type"],inst:$})}}),zJ=K("$ZodCheckOverwrite",($,T)=>{u$.init($,T),$._zod.check=(W)=>{W.value=T.tx(W.value)}});class $Y{constructor($=[]){if(this.content=[],this.indent=0,this)this.args=$}indented($){this.indent+=1,$(this),this.indent-=1}write($){if(typeof $==="function"){$(this,{execution:"sync"}),$(this,{execution:"async"});return}let W=$.split(`
|
|
7
|
-
`).filter((
|
|
8
|
-
`))}}var
|
|
9
|
-
if (${
|
|
10
|
-
if (input[${
|
|
11
|
-
if (${
|
|
12
|
-
newResult[${
|
|
3
|
+
var DP=Object.create;var{getPrototypeOf:VP,defineProperty:iz,getOwnPropertyNames:KP}=Object;var EP=Object.prototype.hasOwnProperty;var AP=($,T,W)=>{W=$!=null?DP(VP($)):{};let U=T||!$||!$.__esModule?iz(W,"default",{value:$,enumerable:!0}):W;for(let X of KP($))if(!EP.call(U,X))iz(U,X,{get:()=>$[X],enumerable:!0});return U};var MP=($,T)=>()=>(T||$((T={exports:{}}).exports,T),T.exports);var wT=($,T)=>{for(var W in T)iz($,W,{get:T[W],enumerable:!0,configurable:!0,set:(U)=>T[W]=()=>U})};var Yc=($,T)=>()=>($&&(T=$($=0)),T);var ID=import.meta.require;var DE=MP((il,ZE)=>{var kX=ID("os"),vX=ID("path");function QE($){let T=process.env.XDG_CACHE_HOME||vX.join(kX.homedir(),".cache");return vX.join(T,$)}function Rx($){return vX.join(kX.homedir(),"Library","Caches",$)}function kx($){let T=process.env.LOCALAPPDATA||vX.join(kX.homedir(),"AppData","Local");return vX.join(T,$,"Cache")}var vx=function(){switch(kX.platform()){case"darwin":return Rx;case"win32":return kx;case"aix":case"android":case"freebsd":case"linux":case"netbsd":case"openbsd":case"sunos":return QE;default:return console.error(`(node:${process.pid}) [cachedir] Warning: the platform "${kX.platform()}" is not currently supported by node-cachedir, falling back to "posix". Please file an issue with your platform here: https://github.com/LinusU/node-cachedir/issues/new`),QE}}();ZE.exports=function $(T){if(typeof T!=="string")throw new TypeError("id is not a string");if(T.length===0)throw new Error("id cannot be empty");if(/[^0-9a-zA-Z-]/.test(T))throw new Error("id cannot contain special characters");return vx(T)}});class bU extends Promise{fate;resolve;reject;done=!1;constructor($){let T,W;super((U,X)=>{T=U,W=X});this.resolve=T,this.reject=W,this.use($ instanceof Promise?$:new Promise($))}pass($,T){if($===this.fate)this.resolve(T),this.done=!0}fail($,T){if($===this.fate)this.reject(T),this.done=!0}use($){if($ instanceof Promise){let T=$;this.fate=T,T.then((W)=>{this.pass(T,W)},(W)=>{this.fail(T,W)})}else this.resolve($),this.fate=void 0}}var Hc=($,T,W=fD.STORE)=>{return bD(W,{key:`${$.key}:JSON`,get:({get:U})=>T.toJson(U($)),set:({set:U},X)=>{U($,T.fromJson(X))}})};function Qc($,T,W){return tz($,{key:`${T.key}:JSON`,get:(X)=>({get:Y})=>{let w=Y(T,X);return W.toJson(w)},set:(X)=>({set:Y},w)=>{Y(T,X,W.fromJson(w))}},["mutable","json"])}var fU=($)=>JSON.parse($),w6=($)=>JSON.stringify($),Dc=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function H$($){while($.child!==null)$=$.child;return $}class Xw{_buffer;_index=0;constructor($){let T;if(typeof $==="number")T=$;else T=$.length;this._buffer=Array.from({length:T})}get buffer(){return this._buffer}get index(){return this._index}add($){this._buffer[this._index]=$,this._index=(this._index+1)%this._buffer.length}copy(){let $=new Xw([...this._buffer]);return $._index=this._index,$}}var NP={atom_family:"atom",molecule_family:"molecule",mutable_atom_family:"mutable_atom",readonly_held_selector_family:"readonly_held_selector",readonly_pure_selector_family:"readonly_pure_selector",writable_held_selector_family:"writable_held_selector",writable_pure_selector_family:"writable_pure_selector"};function yD($,T){let W=w6(T),U=`${$.key}(${W})`,X=NP[$.type],Y={key:U,type:X};return Object.assign(Y,{family:{key:$.key,subKey:W}}),Object.assign(Y,{counterfeit:!0}),Y}function yU($){let T={key:$.key,type:$.type};if("family"in $)T.family=$.family;return T}var az=($)=>(T,W,U,X,...Y)=>{console[$](`${T} ${W} "${U}" ${X}`,...Y)},LP={error:az("error"),info:az("info"),warn:az("warn")};class sz{logLevel;filter;logger;constructor($,T,W=LP){this.logLevel=$,this.filter=T,this.logger=W}error=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel!==null){if(T===!0)this.logger.error(...$);else if(T!==!1)this.logger.error(...T)}};info=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel==="info"){if(T===!0)this.logger.info(...$);else if(T!==!1)this.logger.info(...T)}};warn=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel!=="error"&&this.logLevel!==null){if(T===!0)this.logger.warn(...$);else if(T!==!1)this.logger.warn(...T)}}}class r1{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=($,T)=>`${$}:${T}`;warn;getRelatedKeys($){return this.relations.get($)}addRelation($,T){let W=this.relations.get($),U=this.relations.get(T);if(W)W.add(T);else W=new Set([T]),this.relations.set($,W);if(U)U.add($);else U=new Set([$]),this.relations.set(T,U)}deleteRelation($,T){let W=this.relations.get($);if(W){if(W.delete(T),W.size===0)this.relations.delete($);let U=this.relations.get(T);if(U){if(U.delete($),U.size===0)this.relations.delete(T)}}}replaceRelationsUnsafely($,T){this.relations.set($,new Set(T));for(let W of T){let U=new Set().add($);this.relations.set(W,U)}}replaceRelationsSafely($,T){let W=this.relations.get($),U=this.isAType?.($)?$:void 0,X=U===void 0?$:void 0;if(W)for(let Y of W){U??=Y,X??=Y;let w=this.relations.get(Y);if(w){if(w.size===1)this.relations.delete(Y);else w.delete($);this.contents.delete(this.makeContentKey(U,X))}}this.relations.set($,new Set(T));for(let Y of T){let w=this.relations.get(Y);if(w)w.add($);else w=new Set().add($),this.relations.set(Y,w)}}getContentInternal($){return this.contents.get($)}setContent($,T){this.contents.set($,T)}deleteContent($){this.contents.delete($)}constructor($,T){if(this.a=$.between[0],this.b=$.between[1],this.cardinality=$.cardinality,!T?.externalStore)this.relations=new Map($.relations?.map(([W,U])=>[W,new Set(U)])),this.contents=new Map($.contents);if(this.isAType=T?.isAType??null,this.isBType=T?.isBType??null,this.isContent=T?.isContent??null,T?.makeContentKey)this.makeContentKey=T.makeContentKey;if(T?.externalStore){let W=T.externalStore;if(this.has=(U,X)=>W.has(U,X),this.addRelation=(U,X)=>{W.addRelation(U,X)},this.deleteRelation=(U,X)=>{W.deleteRelation(U,X)},this.replaceRelationsSafely=(U,X)=>{W.replaceRelationsSafely(U,X)},this.replaceRelationsUnsafely=(U,X)=>{W.replaceRelationsUnsafely(U,X)},this.getRelatedKeys=(U)=>W.getRelatedKeys(U),W.getContent)this.getContentInternal=(U)=>{return W.getContent(U)},this.setContent=(U,X)=>{W.setContent(U,X)},this.deleteContent=(U)=>{W.deleteContent(U)};for(let[U,X]of $.relations??[]){let Y=this.isAType?.(U)?U:void 0,w=Y===void 0?U:void 0;for(let G of X)Y??=G,w??=G,this.addRelation(Y,w)}for(let[U,X]of $.contents??[])this.setContent(U,X)}if(T?.warn)this.warn=T.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([$,T])=>[$,[...T]]),contents:[...this.contents.entries()]}}set(...$){let T,W,U;switch($.length){case 1:{let X=$[0];T=X[this.a],W=X[this.b],U=void 0;break}case 2:{let X=$[0];if(typeof X==="string")[T,W]=$;else T=X[this.a],W=X[this.b],U=$[1];break}default:{T=$[0],W=$[1],U=$[2];break}}switch(this.cardinality){case"1:1":{let X=this.getRelatedKey(T);if(X&&X!==W)this.delete(T,X)}case"1:n":{let X=this.getRelatedKey(W);if(X&&X!==T)this.delete(X,W)}break;case"n:n":}if(U){let X=this.makeContentKey(T,W);this.setContent(X,U)}return this.addRelation(T,W),this}delete($,T){T=typeof T==="string"?T:$[this.b];let W=typeof $==="string"?$:$[this.a];if(W===void 0&&typeof T==="string"){let U=this.getRelatedKeys(T);if(U)for(let X of U)this.delete(X,T)}if(typeof W==="string"&&T===void 0){let U=this.getRelatedKeys(W);if(U)for(let X of U)this.delete(W,X)}if(typeof W==="string"&&typeof T==="string"){this.deleteRelation(W,T);let U=this.makeContentKey(W,T);this.deleteContent(U)}return this}getRelatedKey($){let T=this.getRelatedKeys($);if(T){if(T.size>1)this.warn?.(`${T.size} related keys were found for key "${$}": (${[...T].map((U)=>`"${U}"`).join(", ")}). Only one related key was expected.`);let W;for(let U of T){W=U;break}return W}}replaceRelations($,T,W){let U=!Array.isArray(T),X=U?Object.keys(T):T;if(W?.reckless)this.replaceRelationsUnsafely($,X);else this.replaceRelationsSafely($,X);if(U)for(let Y of X){let w=this.makeContentKey($,Y),G=T[Y];this.setContent(w,G)}return this}getContent($,T){let W=this.makeContentKey($,T);return this.getContentInternal(W)}getRelationEntries($){let T=$[this.a],W=$[this.b];if(T!==void 0&&W===void 0){let U=this.getRelatedKeys(T);if(U)return[...U].map((X)=>{return[X,this.getContent(T,X)]})}if(T===void 0&&W!==void 0){let U=this.getRelatedKeys(W);if(U)return[...U].map((X)=>{return[X,this.getContent(X,W)]})}return[]}has($,T){if(T)return this.getRelatedKeys($)?.has(T)??!1;return this.relations.has($)}}class I${Subscriber;subscribers=new Map;subscribe($,T){return this.subscribers.set($,T),()=>{this.unsubscribe($)}}unsubscribe($){this.subscribers.delete($)}next($){let T=this.subscribers.values();for(let W of T)W($)}}class ez extends I${state;constructor($){super();this.state=$}next($){this.state=$,super.next($)}}function GT($){return"epoch"in $.transactionMeta}function i6($){return"phase"in $.transactionMeta}function hD($){return $[0].toUpperCase()+$.slice(1)}function Yw($){return $.type.split("_").map(hD).join(" ")}class hU extends Error{constructor($,T){super(`${Yw($)} ${w6($.key)} not found in store "${T.config.name}".`)}}var eW=($)=>(T)=>$ instanceof Function?$(T):$;var zT=($,T)=>{if($.valueMap.has(T.key))return $.logger.info("\uD83D\uDCD6",T.type,T.key,"reading cached value"),gD(T,$);switch(T.type){case"readonly_held_selector":case"readonly_pure_selector":case"writable_held_selector":case"writable_pure_selector":return $.logger.info("\uD83E\uDDEE",T.type,T.key,"computing value"),T.get();case"atom":case"mutable_atom":{let W=T.default,U;if(W instanceof Function)U=W();else U=W;return $.logger.info("\uD83D\uDC81","atom",T.key,"could not find cached value; using default",U),U}}};var mD=($,T)=>{if($.operation.open){let W=performance.now();return $.logger.info("\u2757",T.type,T.key,`deferring setState at T-${W} until setState for "${$.operation.token.key}" is done`),W}$.operation={open:!0,done:new Set,prev:new Map,time:Date.now(),token:T},$.logger.info("\u2B55",T.type,T.key,`operation start in store "${$.config.name}"${!i6($)?"":` ${$.transactionMeta.phase} "${$.transactionMeta.update.key}"`}`)},cD=($)=>{if($.operation.open)$.logger.info("\uD83D\uDD34",$.operation.token.type,$.operation.token.key,`operation done in store "${$.config.name}"`);$.operation={open:!1},$.on.operationClose.next($.operation)},uD=($,T)=>{if(!$.operation.open)return $.logger.error("\uD83D\uDC1E","unknown",T,"isDone called outside of an operation. This is probably a bug in AtomIO."),!0;return $.operation.done.has(T)},HT=($,T)=>{if(!$.operation.open){$.logger.error("\uD83D\uDC1E","unknown",T,"markDone called outside of an operation. This is probably a bug in AtomIO.");return}$.operation.done.add(T)};var pD=($,T,W)=>{switch(T.type){case"mutable_atom":$.logger.info("\uD83D\uDCE2",T.type,T.key,"is now (",W.newValue,") subscribers:",T.subject.subscribers);break;case"atom":case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":$.logger.info("\uD83D\uDCE2",T.type,T.key,"went (",W.oldValue,"->",W.newValue,") subscribers:",T.subject.subscribers)}T.subject.next(W)};var $5=($,T)=>{let W=H$($),U=W.selectorAtoms.getRelatedKeys(T.key);if(W.logger.info("\uD83E\uDDF9",T.type,T.key,U?`evicting ${U.size} states downstream:`:"no downstream states",U??"to evict"),U){if(W.operation.open)W.logger.info("\uD83E\uDDF9",T.type,T.key,`[ ${[...W.operation.done].join(", ")} ] already done`);for(let X of U){if(uD(W,X))continue;dD(X,W),HT(W,X)}}};var oD=($,T,W)=>{let U=zT($,T),X=U;if(T.type==="mutable_atom"&&i6($)){let{parent:w}=$;X=gU($,T,w)}if(X=eW(W)(X),$.logger.info("\uD83D\uDCDD","atom",T.key,"set to",X),X=G6($,T.key,X,T.subject),rD($,T.key))nD($,T.key);HT($,T.key),$5($,T);let Y={oldValue:U,newValue:X};if(!i6($)){pD($,T,Y);return}if($.on.transactionApplying.state===null){let{key:w}=T;if(lD(Y.newValue))return;let G={type:"atom_update",key:w,...Y};if(T.family)G.family=T.family;$.transactionMeta.update.updates.push(G),$.logger.info("\uD83D\uDCC1","atom",w,"stowed (",Y.oldValue,"->",Y.newValue,")")}else if(T.key.startsWith("*")){let w=T.key.slice(1),G=$.atoms.get(w),H=$.valueMap.get(w);if(G.type==="mutable_atom"&&i6($)){let{parent:F}=$;H=gU($,G,F)}if(H.do(Y.newValue)===null)$5($,G)}};var ww=($,T,W)=>{switch(T.type){case"atom":case"mutable_atom":oD($,T,W);break;case"writable_pure_selector":case"writable_held_selector":T.set(W);break}};var Gw=($,T)=>H$($).atoms.has(T),JP=($,T)=>H$($).writableSelectors.has(T),_P=($,T)=>H$($).readonlySelectors.has(T),iD=($,T)=>Gw($,T)||JP($,T)||_P($,T);var zw=($,T)=>{return H$($).selectorGraph.getRelationEntries({downstreamSelectorKey:T}).filter(([U,{source:X}])=>X!==T).map(([U,{source:X}])=>X).filter((U)=>iD($,U))};var T5=($,T,W)=>{let U=[],X=zw($,T);while(X.length>0){let Y=X.shift();if(W.has(Y))continue;if(W.add(Y),!Gw($,Y))X.push(...zw($,Y));else if(!U.includes(Y))U.push(Y)}return U},tD=($,T)=>{let W=$.key,U=zw(T,W),X=new Set;return U.flatMap((Y)=>Gw(T,Y)?Y:T5(T,Y,X))};var aD=($,T,W,U,X)=>{let Y=H$($),{type:w,key:G}=U;if(w==="atom"||w==="mutable_atom")Y.selectorAtoms.set({selectorKey:W,atomKey:G}),$.logger.info("\uD83D\uDD0D",T,W,`discovers root atom "${G}"`);else{let H=T5($,G,X);$.logger.info("\uD83D\uDD0D",T,W,`discovers root atoms: [ ${H.map((z)=>`"${z}"`).join(", ")} ]`);for(let z of H)Y.selectorAtoms=Y.selectorAtoms.set({selectorKey:W,atomKey:z})}X.add(G)};var FT=($,T,W,U)=>({get:(...X)=>{let Y=H$($),w;if(X.length===2){let[F,O]=X;w=t6($,F,O)}else[w]=X;let G=C6($,w),H=zT($,G),z=w.key;return $.logger.info("\uD83D\uDD0C",T,W,`registers dependency ( "${z}" =`,H,")"),Y.selectorGraph.set({upstreamSelectorKey:z,downstreamSelectorKey:W},{source:w.key}),aD($,T,W,w,U),H},set:(...X)=>{let Y,w;if(X.length===2)Y=X[0],w=X[1];else{let z=X[0],F=X[1];w=X[2],Y=t6($,z,F)}let G=H$($),H=C6(G,Y);ww(G,H,w)},find:(...X)=>t6($,...X),json:(X)=>$2($,X)});var W5=($,T,W)=>{let U=H$($),X=new I$,Y=new Set,{key:w,const:G}=T,H="readonly_held_selector",{get:z,find:F,json:O}=FT(U,"readonly_held_selector",w,Y),Z={...T,type:"readonly_held_selector",subject:X,install:(E)=>W5(E,T,W),get:()=>{return T.get({get:z,find:F,json:O},G),G6(H$($),w,G,X),Y.clear(),G},...W&&{family:W}};U.readonlySelectors.set(w,Z),$.logger.info("\u2728","readonly_held_selector",w,"=",G);let V={key:w,type:"readonly_held_selector"};if(W)V.family=W;return V};var U5=($,T,W)=>{let U=H$($),X=new I$,Y=new Set,w=T.key,G="readonly_pure_selector",{get:H,find:z,json:F}=FT(U,"readonly_pure_selector",w,Y),O=()=>{let E=T.get({get:H,find:z,json:F});return G6(H$($),w,E,X),Y.clear(),E},Q={...T,type:"readonly_pure_selector",subject:X,install:(E)=>U5(E,T,W),get:O,...W&&{family:W}};U.readonlySelectors.set(w,Q);let Z=O();$.logger.info("\u2728","readonly_pure_selector",w,"=",Z);let V={key:w,type:"readonly_pure_selector"};if(W)V.family=W;return V};var X5=($,T,W)=>{let U=H$($),X=new I$,Y=new Set,{key:w,const:G}=T,H="writable_held_selector",z=FT(U,"writable_held_selector",w,Y),{find:F,get:O,json:Q}=z,Z={find:F,get:O,json:Q},V=(R=T.get,P=H$($))=>{return R(Z,G),G6(P,w,G,X),Y.clear(),G},N={...T,type:"writable_held_selector",subject:X,install:(R)=>X5(R,T,W),get:V,set:(R)=>{let P=H$($),x=V(T.get,P),f=eW(R)(x);if($.logger.info("\uD83D\uDCDD","writable_held_selector",w,"set (",x,"->",f,")"),G6(P,w,f,X),HT(P,w),GT(P))X.next({newValue:f,oldValue:x});T.set(z,f)},...W&&{family:W}};U.writableSelectors.set(w,N);let J=V();$.logger.info("\u2728","writable_held_selector",w,"=",J);let _={key:w,type:"writable_held_selector"};if(W)_.family=W;return _};var mU=($,T,W)=>{let U=H$($),X=new I$,Y=new Set,w=T.key,G="writable_pure_selector",H=FT(U,"writable_pure_selector",w,Y),{find:z,get:F,json:O}=H,Q={find:z,get:F,json:O},Z=(_=T.get,R=H$($))=>{let P=_(Q);return G6(R,w,P,X),Y.clear(),P},E={...T,type:"writable_pure_selector",subject:X,install:(_)=>mU(_,T,W),get:Z,set:(_)=>{let R=H$($),P=Z(T.get,R),x=eW(_)(P);if($.logger.info("\uD83D\uDCDD","writable_pure_selector",w,"set (",P,"->",x,")"),G6(R,T.key,x,X),HT(R,T.key),GT(R))X.next({newValue:x,oldValue:P});T.set(H,x)},...W&&{family:W}};U.writableSelectors.set(w,E);let N=Z();$.logger.info("\u2728",E.type,E.key,"=",N);let J={key:w,type:"writable_pure_selector"};if(W)J.family=W;return J};function bD($,T){let W="set"in T,U="const"in T;if(U&&W){let Y=X5($,T,void 0);return $.on.selectorCreation.next(Y),Y}if(U){let Y=W5($,T,void 0);return $.on.selectorCreation.next(Y),Y}if(W){let Y=mU($,T,void 0);return $.on.selectorCreation.next(Y),Y}let X=U5($,T,void 0);return $.on.selectorCreation.next(X),X}function tz($,T,W){let U=T.key,X="writable_pure_selector_family",Y={key:U,type:"writable_pure_selector_family"},w=$.families.get(U);if(w)$.logger.error("\u2757","writable_pure_selector_family",U,`Overwriting an existing ${Yw(w)} "${w.key}" in store "${$.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);let G=new I$,z=Object.assign((F)=>{let O=w6(F),Q={key:U,subKey:O},Z=`${U}(${O})`,V=H$($),E=mU(V,{key:Z,get:T.get(F),set:T.set(F)},Q);return G.next({type:"state_creation",token:E}),E},Y,{internalRoles:W,subject:G,install:(F)=>tz(F,T),default:(F)=>{return T.get(F)({get:(...Q)=>cU($,...Q),find:(...Q)=>t6($,...Q),json:(Q)=>$2($,Q)})}});return $.families.set(U,z),Y}function sD($,T,W){let U=$.families.get(T.key);if(U===void 0)throw new hU(T,$);let X=U(W),Y=H$($);if(X.family){if(GT(Y))switch(X.type){case"atom":case"mutable_atom":$.on.atomCreation.next(X);break;case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":$.on.selectorCreation.next(X);break}else if(i6(Y)&&Y.on.transactionApplying.state===null)Y.transactionMeta.update.updates.push({type:"state_creation",token:X})}return X}function eD($,T,W){let U=w6(W),X=`${T.key}(${U})`,Y=H$($),w;switch(T.type){case"atom_family":case"mutable_atom_family":w=Y.atoms.get(X);break;case"writable_held_selector_family":case"writable_pure_selector_family":w=Y.writableSelectors.get(X);break;case"readonly_held_selector_family":case"readonly_pure_selector_family":w=Y.readonlySelectors.get(X);break}if(w)return yU(w);return w}function t6($,T,W){let U=eD($,T,W);if(U)return U;let X=w6(W),Y=$.molecules.get(X);if(!Y&&$.config.lifespan==="immortal"){let w=yD(T,W);return $.logger.error("\u274C",w.type,w.key,`was not found in store "${$.config.name}"; returned a counterfeit token.`),w}if(U=sD($,T,W),Y)H$($).moleculeData.set(X,T.key);return U}function $V($,T){if(T.family){let W=$.families.get(T.family.key);if(W)return W}}function OT($,...T){let W,U,X,Y;if(T.length===2){if(W=T[0],Y=T[1],U=$V($,W)??null,U)X=W.family?fU(W.family.subKey):null,W=t6($,U,X)}else U=T[0],X=T[1],Y=T[2],W=t6($,U,X);if("counterfeit"in W&&"family"in W){let H=W.family.subKey,z=$.disposalTraces.buffer.find((F)=>F?.key===H);$.logger.error("\u274C",W.type,W.key,`could not be set because it was not found in the store "${$.config.name}".`,z?`This state was previously disposed:
|
|
4
|
+
${z.trace}`:"No previous disposal trace was found.");return}let w=mD($,W);if(w){let H=$.on.operationClose.subscribe(`waiting to set "${W.key}" at T-${w}`,()=>{H(),$.logger.info("\uD83D\uDFE2",W.type,W.key,`resuming deferred setState from T-${w}`),OT($,W,Y)});return}let G=C6($,W);ww($,G,Y),cD($)}function cU($,...T){let W,U,X;if(T.length===1)W=T[0];else U=T[0],X=T[1],W=t6($,U,X);if("counterfeit"in W&&"family"in W){U=$.families.get(W.family.key);let Y=W.family.subKey,w=$.disposalTraces.buffer.find((G)=>G?.key===Y);switch($.logger.error("\u274C",W.type,W.key,`could not be retrieved because it was not found in the store "${$.config.name}".`,w?`This state was previously disposed:
|
|
5
|
+
${w.trace}`:"No previous disposal trace was found."),U.type){case"atom_family":case"mutable_atom_family":return $.defaults.get(U.key);case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if($.defaults.has(U.key))return $.defaults.get(W.family.key);let G=C6($,U).default(Y);return $.defaults.set(U.key,G),G}}}return zT($,C6($,W))}class TV{parent=null;child=null;valueMap=new Map;defaults=new Map;atoms=new Map;writableSelectors=new Map;readonlySelectors=new Map;atomsThatAreDefault=new Set;selectorAtoms=new r1({between:["selectorKey","atomKey"],cardinality:"n:n"});selectorGraph=new r1({between:["upstreamSelectorKey","downstreamSelectorKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});trackers=new Map;families=new Map;joins=new Map;transactions=new Map;transactionMeta={epoch:new Map,actionContinuities:new r1({between:["continuity","action"],cardinality:"1:n"})};timelines=new Map;timelineTopics=new r1({between:["timelineKey","topicKey"],cardinality:"1:n"});disposalTraces=new Xw(100);molecules=new Map;moleculeJoins=new r1({between:["moleculeKey","joinKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});moleculeGraph=new r1({between:["upstreamMoleculeKey","downstreamMoleculeKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});moleculeData=new r1({between:["moleculeKey","stateFamilyKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});miscResources=new Map;on={atomCreation:new I$,atomDisposal:new I$,selectorCreation:new I$,selectorDisposal:new I$,timelineCreation:new I$,transactionCreation:new I$,transactionApplying:new ez(null),operationClose:new I$,moleculeCreation:new I$,moleculeDisposal:new I$};operation={open:!1};config={name:"IMPLICIT_STORE",lifespan:"ephemeral"};loggers=[new sz("warn",($,T,W)=>!UV(W))];logger={error:(...$)=>{for(let T of this.loggers)T.error(...$)},info:(...$)=>{for(let T of this.loggers)T.info(...$)},warn:(...$)=>{for(let T of this.loggers)T.warn(...$)}};constructor($,T=null){if(this.config={...T?.config,...$},T!==null){if(this.valueMap=new Map(T?.valueMap),this.operation={...T?.operation},GT(T))this.transactionMeta={epoch:new Map(T?.transactionMeta.epoch),actionContinuities:new r1(T?.transactionMeta.actionContinuities.toJSON())};for(let[,U]of T.families){if(U.internalRoles?.includes("mutable")||U.internalRoles?.includes("join"))continue;U.install(this)}let W=new Set;for(let[,U]of T.atoms){if(W.has(U.key))continue;if(U.install(this),U.type==="mutable_atom"){let X=$2(T,U),Y=WV(U);W.add(X.key),W.add(Y.key)}}for(let[,U]of T.readonlySelectors)U.install(this);for(let[,U]of T.writableSelectors){if(W.has(U.key))continue;U.install(this)}for(let[,U]of T.transactions)U.install(this);for(let[,U]of T.timelines)U.install(this)}}}var fD={get STORE(){return globalThis.ATOM_IO_IMPLICIT_STORE??=new TV({name:"IMPLICIT_STORE",lifespan:"ephemeral"}),globalThis.ATOM_IO_IMPLICIT_STORE}};function C6($,T){let W,U=$;while(U!==null){switch(T.type){case"atom":case"mutable_atom":W=U.atoms.get(T.key);break;case"writable_pure_selector":case"writable_held_selector":W=U.writableSelectors.get(T.key);break;case"readonly_pure_selector":case"readonly_held_selector":W=U.readonlySelectors.get(T.key);break;case"atom_family":case"mutable_atom_family":case"writable_pure_selector_family":case"readonly_pure_selector_family":case"writable_held_selector_family":case"readonly_held_selector_family":W=U.families.get(T.key);break;case"timeline":W=U.timelines.get(T.key);break;case"transaction":W=U.transactions.get(T.key);break}if(W)return W;U=U.child}throw new hU(T,$)}var XV=($,T)=>{let W=H$($);if(W.operation.open)return W.operation.prev.get(T.key);return W.valueMap.get(T.key)};var Y5=($,T)=>{let W=H$($);return tD(T,$).map((X)=>{let Y=W.atoms.get(X);if(Y===void 0)throw new Error(`Atom "${X}", a dependency of selector "${T.key}", not found in store "${$.config.name}".`);return Y.subject.subscribe(`${T.type}:${T.key}`,(w)=>{$.logger.info("\uD83D\uDCE2",T.type,T.key,"root",X,"went",w.oldValue,"->",w.newValue);let G=XV(W,T),H=zT(W,T);$.logger.info("\u2728",T.type,T.key,"went",G,"->",H),T.subject.next({newValue:H,oldValue:G})})})};function uU($,T,W,U){function X(O){if($.operation.open){let Q=$.on.operationClose.subscribe(`state subscription ${W}`,()=>{Q(),U(O)})}else U(O)}let Y=C6($,T);$.logger.info("\uD83D\uDC40",Y.type,Y.key,`Adding subscription "${W}"`);let w=Y.type==="writable_pure_selector"||Y.type==="readonly_pure_selector",G=null,H=X;if(w)G=Y5($,Y),H=(O)=>{if(G)G.length=0,G.push(...Y5($,Y));X(O)};let z=Y.subject.subscribe(W,H);return()=>{if($.logger.info("\uD83D\uDE48",Y.type,Y.key,`Removing subscription "${W}"`),z(),G)for(let O of G)O()}}var YV=($,T,W,U)=>{let X=C6($,T);$.logger.info("\uD83D\uDC40","timeline",T.key,`Adding subscription "${W}"`);let Y=X.subject.subscribe(W,U);return()=>{$.logger.info("\uD83D\uDE48","timeline",T.key,`Removing subscription "${W}" from timeline`),Y()}};class w5{initializeState($,T){let W=`*${$.key}`;T.atoms.delete(W),T.valueMap.delete(W);let U=$.family?{key:`*${$.family.key}`,subKey:$.family.subKey}:void 0,X=G5(T,{key:W,default:null},U);if(T.parent?.valueMap.has(W)){let Y=T.parent.valueMap.get(W);T.valueMap.set(W,Y)}return X}unsubscribeFromInnerValue;unsubscribeFromState;observeCore($,T,W){let U=`tracker:${W.config.name}:${i6(W)?W.transactionMeta.update.key:"main"}:${$.key}`,X=cU(W,$);this.unsubscribeFromInnerValue=X.subscribe(U,(Y)=>{OT(W,T,Y)}),this.unsubscribeFromState=uU(W,$,U,(Y)=>{if(Y.newValue!==Y.oldValue)this.unsubscribeFromInnerValue(),this.unsubscribeFromInnerValue=Y.newValue.subscribe(U,(w)=>{OT(W,T,w)})})}updateCore($,T,W){let U=`tracker:${W.config.name}:${i6(W)?W.transactionMeta.update.key:"main"}:${$.key}`;uU(W,T,U,({newValue:X,oldValue:Y})=>{let w=W.timelineTopics.getRelatedKey(T.key);if(w){if(W.timelines.get(w)?.timeTraveling){let z=YV(W,{key:w,type:"timeline"},U,(F)=>{z(),OT(W,$,(O)=>{if(F==="redo"&&X)O.do(X);else if(F==="undo"&&Y)O.undo(Y);return O})});return}}let G=W.on.operationClose.subscribe(U,()=>{G();let H=cU(W,$),z=X===null?-1:H.getUpdateNumber(X),F=z-H.cacheUpdateNumber;if(X&&F===1)OT(W,$,(O)=>(O.do(X),O));else W.logger.info("\u274C","mutable_atom",$.key,`could not be updated. Expected update number ${H.cacheUpdateNumber+1}, but got ${z}`)})})}mutableState;latestUpdateState;[Symbol.dispose];constructor($,T){this.mutableState=$;let W=H$(T);this.latestUpdateState=this.initializeState($,W),this.observeCore($,this.latestUpdateState,W),this.updateCore($,this.latestUpdateState,W),W.trackers.set($.key,this),this[Symbol.dispose]=()=>{this.unsubscribeFromInnerValue(),this.unsubscribeFromState(),W.trackers.delete($.key)}}}var $2=($,T)=>{if(T.family){let U=H$($),Y={key:`${T.family.key}:JSON`,type:"writable_pure_selector_family"},w=C6(U,Y),G=JSON.parse(T.family.subKey);return t6($,w,G)}return{type:"writable_pure_selector",key:`${T.key}:JSON`}};var WV=($)=>{let W={type:"atom",key:`*${$.key}`};if($.family)W.family={key:`*${$.family.key}`,subKey:$.family.subKey};return W};function lD($){return typeof $==="object"&&$!==null&&"do"in $&&"undo"in $&&"subscribe"in $}function gU($,T,W){let U=W.valueMap.get(T.key),X=$.valueMap.get(T.key);if(U!==X)return X;if(U===void 0)return T.default();W.logger.info("\uD83D\uDCC3","atom",T.key,"copying");let Y=T.toJson(U),w=T.fromJson(Y);return $.valueMap.set(T.key,w),new w5(T,W),w}function G6($,T,W,U){let X=$.valueMap.get(T);if(X instanceof bU)X.use(W);if(W instanceof Promise){let Y=new bU(W);return $.valueMap.set(T,Y),Y.then((w)=>{G6($,T,w,U),U.next({newValue:w,oldValue:Y})}).catch((w)=>{$.logger.error("\uD83D\uDCA5","state",T,"rejected:",w)}),Y}return $.valueMap.set(T,W),W}var gD=($,T)=>{let W=T.valueMap.get($.key);if($.type==="mutable_atom"&&i6(T)){let{parent:U}=T;W=gU(T,$,U)}return W},dD=($,T)=>{let W=T.valueMap.get($);if(W instanceof bU){let U=W,X=T.writableSelectors.get($)??T.readonlySelectors.get($);if(X)U.use(X.get());return}if(T.operation.open)T.operation.prev.set($,W);T.valueMap.delete($),T.logger.info("\uD83D\uDDD1","state",$,"evicted")};var rD=($,T)=>{return H$($).atomsThatAreDefault.has(T)},wV=($,T)=>{let W=H$($);W.atomsThatAreDefault=new Set(W.atomsThatAreDefault).add(T)},nD=($,T)=>{let W=H$($);W.atomsThatAreDefault=new Set(H$($).atomsThatAreDefault),W.atomsThatAreDefault.delete(T)};function G5($,T,W){let{key:X,default:Y}=T;$.logger.info("\uD83D\uDD28","atom",X,`creating in store "${$.config.name}"`);let w=H$($),G=w.atoms.get(X);if(G&&G.type==="atom")return $.logger.error("\u274C","atom",X,"Tried to create atom, but it already exists in the store."),yU(G);let H=new I$,z={...T,type:"atom",install:(Q)=>{return Q.logger.info("\uD83D\uDEE0\uFE0F","atom",X,`installing in store "${Q.config.name}"`),G5(Q,T,W)},subject:H};if(W)z.family=W;let F=Y;if(Y instanceof Function)F=Y();w.atoms.set(X,z),wV($,X),G6(w,X,F,H);let O=yU(z);if(T.effects){let Q=0,Z=[];for(let V of T.effects){let E=V({setSelf:(N)=>{OT($,O,N)},onSet:(N)=>uU($,O,`effect[${Q}]`,N)});if(E)Z.push(E);++Q}z.cleanup=()=>{for(let V of Z)V()}}return O}class T2 extends Set{mode="record";subject=new I$;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor($,T=0){super($);if($ instanceof T2)this.parent=$,this.cacheUpdateNumber=$.cacheUpdateNumber;if(T)this.cacheLimit=T,this.cache=new Array(T),this.subscribe("auto cache",(W)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=W})}toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON($){let T=new T2($.members,$.cacheLimit);return T.cache=$.cache,T.cacheIdx=$.cacheIdx,T.cacheUpdateNumber=$.cacheUpdateNumber,T}add($){let T=super.add($);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${w6($)}`);return T}clear(){let $=this.mode==="record"?[...this]:null;if(super.clear(),$)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify($)}`)}delete($){let T=super.delete($);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${w6($)}`);return T}parent=null;child=null;transactionUpdates=null;transaction($){this.mode="transaction",this.transactionUpdates=[],this.child=new T2(this);let T=this.child._subscribe("transaction",(W)=>{this.transactionUpdates?.push(W)});try{if($(this.child)){for(let U of this.transactionUpdates)this.doStep(U);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(W){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",W),W}finally{T(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe($,T){return this.subject.subscribe($,T)}subscribe($,T){return this.subject.subscribe($,(W)=>{T(`${this.cacheUpdateNumber}=${W}`)})}emit($){this.subject.next($)}doStep($){let T=$.indexOf(":"),W=$.substring(0,T),U=$.substring(T+1);switch(W){case"add":this.add(JSON.parse(U));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(U));break;case"tx":for(let X of U.split(";"))this.doStep(X)}}getUpdateNumber($){let T=$.indexOf("=");return Number($.substring(0,T))}do($){let T=$.indexOf("="),W=Number($.substring(0,T)),U=W-this.cacheUpdateNumber;if(U>0){if(U===1){this.mode="playback";let Y=$.substring(T+1);return this.doStep(Y),this.mode="record",this.cacheUpdateNumber=W,null}return this.cacheUpdateNumber+1}if(Math.abs(U)<this.cacheLimit){let Y=this.cacheIdx+U;if(this.cache[Y]===$)return null;this.mode="playback";let G=!1;while(!G){this.cacheIdx%=this.cacheLimit;let z=this.cache[this.cacheIdx];if(this.cacheIdx--,!z)return"OUT_OF_RANGE";this.undo(z),G=this.cacheIdx===Y-1}let H=$.substring(T+1);return this.doStep(H),this.mode="record",this.cacheUpdateNumber=W,null}return"OUT_OF_RANGE"}undoStep($){let T=$.indexOf(":"),W=$.substring(0,T),U=$.substring(T+1);switch(W){case"add":this.delete(JSON.parse(U));break;case"del":this.add(JSON.parse(U));break;case"clear":{let X=JSON.parse(U);for(let Y of X)this.add(Y);break}case"tx":{let X=U.split(";");for(let Y=X.length-1;Y>=0;Y--)this.undoStep(X[Y])}}}undo($){let T=$.indexOf("=");if(Number($.substring(0,T))===this.cacheUpdateNumber){this.mode="playback";let U=$.substring(T+1);return this.undoStep(U),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}}function UV($){return $.startsWith("\uD83D\uDD0D ")}class Hw{listeners;globalListeners;handleEvent($,...T){for(let U of this.globalListeners)U($,...T);let W=this.listeners.get($);if(W)for(let U of W)U(...T)}id="no_id_retrieved";emit;constructor($){this.emit=$,this.listeners=new Map,this.globalListeners=new Set}on($,T){let W=this.listeners.get($);if(W)W.add(T);else this.listeners.set($,new Set([T]));return this}onAny($){return this.globalListeners.add($),this}off($,T){let W=this.listeners.get($);if(W)if(T)W.delete(T);else this.listeners.delete($);return this}offAny($){return this.globalListeners.delete($),this}}class GV extends Hw{in;out;id="no_id_retrieved";disposalFunctions=[];constructor($){super((...T)=>{return this.out.next(T),this});this.id=$,this.in=new I$,this.out=new I$,this.in.subscribe("socket",(T)=>{this.handleEvent(...T)})}dispose(){for(let $ of this.disposalFunctions)$()}}class z5 extends Hw{incompleteData="";unprocessedEvents=[];relays;relayServices;process;id="#####";log(...$){this.process.stderr.write(w6($.map((T)=>T instanceof T2?`{ ${T.toJSON().members.join(" | ")} }`:T))+"\x03")}logger={info:(...$)=>{this.log("i",...$)},warn:(...$)=>{this.log("w",...$)},error:(...$)=>{this.log("e",...$)}};constructor(){super(($,...T)=>{let W=JSON.stringify([$,...T]);return this.process.stdout.write(W+"\x03"),this});if(this.process=process,this.process.stdin.resume(),this.relays=new Map,this.relayServices=[],this.process.stdin.on("data",($)=>{let T=$.toString();this.unprocessedEvents.push(...T.split("\x03"));let W=this.unprocessedEvents.shift();this.incompleteData+=W??"";try{let U=fU(this.incompleteData);this.logger.info("\uD83C\uDFB0","received",U),this.handleEvent(...U);while(this.unprocessedEvents.length>0){let X=this.unprocessedEvents.shift();if(X){if(this.unprocessedEvents.length===0)this.incompleteData=X;let Y=fU(X);this.handleEvent(...Y)}}this.incompleteData=""}catch(U){if(U instanceof Error)this.logger.error("\u2757",U.message,U.cause,U.stack)}}),this.on("exit",()=>{this.logger.info("\uD83D\uDD25",this.id,'received "exit"'),process.exit(0)}),process.on("exit",($)=>{this.logger.info("\uD83D\uDD25",this.id,`exited with code ${$}`)}),process.on("end",()=>{this.logger.info("\uD83D\uDD25",this.id,"ended"),process.exit(0)}),process.on("SIGTERM",()=>{this.logger.error("\uD83D\uDD25",this.id,"terminated"),process.exit(0)}),process.on("SIGINT",()=>{this.logger.error("\uD83D\uDD25",this.id,"interrupted"),process.exit(0)}),process.pid)this.id=process.pid?.toString();this.on("user-joins",($)=>{this.logger.info("\uD83D\uDC64","user",$,"joined");let T=new GV(`user:${$}`);this.relays.set($,T),this.logger.info("\uD83D\uDD17","attaching services:",`[${[...this.relayServices.keys()].join(", ")}]`);for(let W of this.relayServices){let U=W(T);if(U)T.disposalFunctions.push(U)}this.on(`user:${$}`,(...W)=>{T.in.next(W)}),T.out.subscribe("socket",(W)=>{this.emit(...W)})}),this.on("user-leaves",($)=>{let T=this.relays.get($);if(this.off(`relay:${$}`),T)T.dispose(),this.relays.delete($)}),process.stdout.write("ALIVE")}relay($){this.logger.info("\uD83D\uDD17","running relay method"),this.relayServices.push($)}}var FG={};wT(FG,{xid:()=>SB,void:()=>tB,uuidv7:()=>_B,uuidv6:()=>JB,uuidv4:()=>LB,uuid:()=>NB,url:()=>RB,uppercase:()=>OX,unknown:()=>WG,union:()=>zG,undefined:()=>nB,ulid:()=>CB,uint64:()=>lB,uint32:()=>pB,tuple:()=>Ux,trim:()=>EX,treeifyError:()=>N5,transform:()=>RF,toUpperCase:()=>MX,toLowerCase:()=>AX,toJSONSchema:()=>pH,templateLiteral:()=>Qx,symbol:()=>rB,superRefine:()=>HE,success:()=>Fx,stringbool:()=>Kx,string:()=>eH,strictObject:()=>$x,startsWith:()=>ZX,size:()=>zX,setErrorMap:()=>Jx,set:()=>wx,safeParseAsync:()=>aH,safeParse:()=>tH,registry:()=>Cw,regexes:()=>tT,regex:()=>HX,refine:()=>zE,record:()=>yK,readonly:()=>WE,property:()=>yH,promise:()=>Zx,prettifyError:()=>L5,preprocess:()=>Ax,prefault:()=>iK,positive:()=>xH,pipe:()=>YG,partialRecord:()=>Xx,parseAsync:()=>iH,parse:()=>nH,overwrite:()=>E0,optional:()=>UG,object:()=>eB,number:()=>_K,nullish:()=>Hx,nullable:()=>XG,null:()=>PK,normalize:()=>KX,nonpositive:()=>bH,nonoptional:()=>tK,nonnegative:()=>fH,never:()=>wG,negative:()=>IH,nativeEnum:()=>Gx,nanoid:()=>vB,nan:()=>Ox,multipleOf:()=>sT,minSize:()=>eT,minLength:()=>ZT,mime:()=>VX,maxSize:()=>X2,maxLength:()=>Y2,map:()=>Yx,lte:()=>D1,lt:()=>V0,lowercase:()=>FX,looseObject:()=>Tx,locales:()=>YX,literal:()=>uK,length:()=>w2,lazy:()=>YE,ksuid:()=>jB,keyof:()=>sB,jwt:()=>gB,json:()=>Ex,iso:()=>sw,ipv6:()=>xB,ipv4:()=>BB,intersection:()=>bK,int64:()=>oB,int32:()=>uB,int:()=>$F,instanceof:()=>Vx,includes:()=>QX,guid:()=>MB,gte:()=>j6,gt:()=>K0,globalRegistry:()=>n1,getErrorMap:()=>_x,function:()=>uH,formatError:()=>eU,float64:()=>cB,float32:()=>mB,flattenError:()=>sU,file:()=>zx,enum:()=>mK,endsWith:()=>DX,emoji:()=>kB,email:()=>AB,e164:()=>hB,discriminatedUnion:()=>Wx,date:()=>aB,custom:()=>Dx,cuid2:()=>PB,cuid:()=>qB,core:()=>A0,config:()=>N4,coerce:()=>sH,clone:()=>a6,cidrv6:()=>bB,cidrv4:()=>IB,check:()=>GE,catch:()=>eK,boolean:()=>RK,bigint:()=>dB,base64url:()=>yB,base64:()=>fB,array:()=>LF,any:()=>iB,_default:()=>rK,_ZodString:()=>TF,ZodXID:()=>HF,ZodVoid:()=>jK,ZodUnknown:()=>NF,ZodUnion:()=>JF,ZodUndefined:()=>vK,ZodUUID:()=>M0,ZodURL:()=>UF,ZodULID:()=>zF,ZodType:()=>J$,ZodTuple:()=>fK,ZodTransform:()=>dK,ZodTemplateLiteral:()=>UE,ZodSymbol:()=>kK,ZodSuccess:()=>aK,ZodStringFormat:()=>T4,ZodString:()=>ew,ZodSet:()=>gK,ZodRecord:()=>_F,ZodRealError:()=>z2,ZodReadonly:()=>TE,ZodPromise:()=>wE,ZodPrefault:()=>nK,ZodPipe:()=>qF,ZodOptional:()=>kF,ZodObject:()=>GG,ZodNumberFormat:()=>H2,ZodNumber:()=>LX,ZodNullable:()=>oK,ZodNull:()=>qK,ZodNonOptional:()=>vF,ZodNever:()=>SK,ZodNanoID:()=>YF,ZodNaN:()=>$E,ZodMap:()=>hK,ZodLiteral:()=>cK,ZodLazy:()=>XE,ZodKSUID:()=>FF,ZodJWT:()=>AF,ZodIssueCode:()=>Mx,ZodIntersection:()=>IK,ZodIPv6:()=>QF,ZodIPv4:()=>OF,ZodGUID:()=>TG,ZodFile:()=>pK,ZodError:()=>OB,ZodEnum:()=>RX,ZodEmoji:()=>XF,ZodEmail:()=>WF,ZodE164:()=>EF,ZodDiscriminatedUnion:()=>xK,ZodDefault:()=>lK,ZodDate:()=>$G,ZodCustom:()=>HG,ZodCatch:()=>sK,ZodCUID2:()=>GF,ZodCUID:()=>wF,ZodCIDRv6:()=>DF,ZodCIDRv4:()=>ZF,ZodBoolean:()=>JX,ZodBigIntFormat:()=>MF,ZodBigInt:()=>_X,ZodBase64URL:()=>KF,ZodBase64:()=>VF,ZodArray:()=>BK,ZodAny:()=>CK,NEVER:()=>Lx,$output:()=>WH,$input:()=>UH,$brand:()=>H5});var A0={};wT(A0,{version:()=>V7,util:()=>d,treeifyError:()=>N5,toJSONSchema:()=>pH,toDotPath:()=>FV,safeParseAsync:()=>_5,safeParse:()=>J5,registry:()=>Cw,regexes:()=>tT,prettifyError:()=>L5,parseAsync:()=>Vw,parse:()=>Zw,locales:()=>YX,isValidJWT:()=>PV,isValidBase64URL:()=>qV,isValidBase64:()=>f7,globalRegistry:()=>n1,globalConfig:()=>pU,function:()=>uH,formatError:()=>eU,flattenError:()=>sU,config:()=>N4,clone:()=>a6,_xid:()=>cw,_void:()=>CH,_uuidv7:()=>Iw,_uuidv6:()=>xw,_uuidv4:()=>Bw,_uuid:()=>jw,_url:()=>bw,_uppercase:()=>OX,_unknown:()=>qH,_union:()=>cj,_undefined:()=>RH,_ulid:()=>mw,_uint64:()=>JH,_uint32:()=>KH,_tuple:()=>gH,_trim:()=>EX,_transform:()=>tj,_toUpperCase:()=>MX,_toLowerCase:()=>AX,_templateLiteral:()=>YB,_symbol:()=>_H,_success:()=>TB,_stringbool:()=>cH,_string:()=>XH,_startsWith:()=>ZX,_size:()=>zX,_set:()=>lj,_safeParseAsync:()=>Ew,_safeParse:()=>Kw,_regex:()=>HX,_refine:()=>zB,_record:()=>dj,_readonly:()=>XB,_property:()=>yH,_promise:()=>GB,_positive:()=>xH,_pipe:()=>UB,_parseAsync:()=>Dw,_parse:()=>Qw,_overwrite:()=>E0,_optional:()=>aj,_number:()=>FH,_nullable:()=>sj,_null:()=>kH,_normalize:()=>KX,_nonpositive:()=>bH,_nonoptional:()=>$B,_nonnegative:()=>fH,_never:()=>PH,_negative:()=>IH,_nativeEnum:()=>nj,_nanoid:()=>yw,_nan:()=>BH,_multipleOf:()=>sT,_minSize:()=>eT,_minLength:()=>ZT,_min:()=>j6,_mime:()=>VX,_maxSize:()=>X2,_maxLength:()=>Y2,_max:()=>D1,_map:()=>oj,_lte:()=>D1,_lt:()=>V0,_lowercase:()=>FX,_literal:()=>ij,_length:()=>w2,_lazy:()=>wB,_ksuid:()=>uw,_jwt:()=>tw,_isoTime:()=>zH,_isoDuration:()=>HH,_isoDateTime:()=>wH,_isoDate:()=>GH,_ipv6:()=>dw,_ipv4:()=>pw,_intersection:()=>pj,_int64:()=>LH,_int32:()=>VH,_int:()=>QH,_includes:()=>QX,_guid:()=>GX,_gte:()=>j6,_gt:()=>K0,_float64:()=>DH,_float32:()=>ZH,_file:()=>mH,_enum:()=>rj,_endsWith:()=>DX,_emoji:()=>fw,_email:()=>Sw,_e164:()=>iw,_discriminatedUnion:()=>uj,_default:()=>ej,_date:()=>SH,_custom:()=>NX,_cuid2:()=>gw,_cuid:()=>hw,_coercedString:()=>YH,_coercedNumber:()=>OH,_coercedDate:()=>jH,_coercedBoolean:()=>AH,_coercedBigint:()=>NH,_cidrv6:()=>lw,_cidrv4:()=>ow,_catch:()=>WB,_boolean:()=>EH,_bigint:()=>MH,_base64url:()=>nw,_base64:()=>rw,_array:()=>hH,_any:()=>vH,JSONSchemaGenerator:()=>aw,JSONSchema:()=>KK,Doc:()=>_w,$output:()=>WH,$input:()=>UH,$constructor:()=>k,$brand:()=>H5,$ZodXID:()=>v7,$ZodVoid:()=>n7,$ZodUnknown:()=>WX,$ZodUnion:()=>Pw,$ZodUndefined:()=>d7,$ZodUUID:()=>A7,$ZodURL:()=>N7,$ZodULID:()=>k7,$ZodType:()=>Q$,$ZodTuple:()=>aT,$ZodTransform:()=>w3,$ZodTemplateLiteral:()=>K3,$ZodSymbol:()=>p7,$ZodSuccess:()=>Q3,$ZodStringFormat:()=>l$,$ZodString:()=>$X,$ZodSet:()=>W3,$ZodRegistry:()=>wX,$ZodRecord:()=>$3,$ZodRealError:()=>W2,$ZodReadonly:()=>V3,$ZodPromise:()=>E3,$ZodPrefault:()=>F3,$ZodPipe:()=>UX,$ZodOptional:()=>G3,$ZodObject:()=>a7,$ZodNumberFormat:()=>c7,$ZodNumber:()=>vw,$ZodNullable:()=>z3,$ZodNull:()=>o7,$ZodNonOptional:()=>O3,$ZodNever:()=>r7,$ZodNanoID:()=>J7,$ZodNaN:()=>D3,$ZodMap:()=>T3,$ZodLiteral:()=>X3,$ZodLazy:()=>A3,$ZodKSUID:()=>q7,$ZodJWT:()=>m7,$ZodIntersection:()=>e7,$ZodISOTime:()=>S7,$ZodISODuration:()=>j7,$ZodISODateTime:()=>P7,$ZodISODate:()=>C7,$ZodIPv6:()=>x7,$ZodIPv4:()=>B7,$ZodGUID:()=>E7,$ZodFunction:()=>G2,$ZodFile:()=>Y3,$ZodError:()=>aU,$ZodEnum:()=>U3,$ZodEmoji:()=>L7,$ZodEmail:()=>M7,$ZodE164:()=>g7,$ZodDiscriminatedUnion:()=>s7,$ZodDefault:()=>H3,$ZodDate:()=>i7,$ZodCustom:()=>M3,$ZodCheckUpperCase:()=>z7,$ZodCheckStringFormat:()=>U2,$ZodCheckStartsWith:()=>F7,$ZodCheckSizeEquals:()=>W7,$ZodCheckRegex:()=>w7,$ZodCheckProperty:()=>Q7,$ZodCheckOverwrite:()=>D7,$ZodCheckNumberFormat:()=>s5,$ZodCheckMultipleOf:()=>a5,$ZodCheckMinSize:()=>T7,$ZodCheckMinLength:()=>X7,$ZodCheckMimeType:()=>Z7,$ZodCheckMaxSize:()=>$7,$ZodCheckMaxLength:()=>U7,$ZodCheckLowerCase:()=>G7,$ZodCheckLessThan:()=>Lw,$ZodCheckLengthEquals:()=>Y7,$ZodCheckIncludes:()=>H7,$ZodCheckGreaterThan:()=>Jw,$ZodCheckEndsWith:()=>O7,$ZodCheckBigIntFormat:()=>e5,$ZodCheck:()=>G4,$ZodCatch:()=>Z3,$ZodCUID2:()=>R7,$ZodCUID:()=>_7,$ZodCIDRv6:()=>b7,$ZodCIDRv4:()=>I7,$ZodBoolean:()=>TX,$ZodBigIntFormat:()=>u7,$ZodBigInt:()=>qw,$ZodBase64URL:()=>h7,$ZodBase64:()=>y7,$ZodAsyncError:()=>Z0,$ZodArray:()=>t7,$ZodAny:()=>l7});function k($,T,W){function U(G,H){var z;Object.defineProperty(G,"_zod",{value:G._zod??{},enumerable:!1}),(z=G._zod).traits??(z.traits=new Set),G._zod.traits.add($),T(G,H);for(let F in w.prototype)Object.defineProperty(G,F,{value:w.prototype[F].bind(G)});G._zod.constr=w,G._zod.def=H}let X=W?.Parent??Object;class Y extends X{}Object.defineProperty(Y,"name",{value:$});function w(G){var H;let z=W?.Parent?new Y:this;U(z,G),(H=z._zod).deferred??(H.deferred=[]);for(let F of z._zod.deferred)F();return z}return Object.defineProperty(w,"init",{value:U}),Object.defineProperty(w,Symbol.hasInstance,{value:(G)=>{if(W?.Parent&&G instanceof W.Parent)return!0;return G?._zod?.traits?.has($)}}),Object.defineProperty(w,"name",{value:$}),w}var H5=Symbol("zod_brand");class Z0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}var pU={};function N4($){if($)Object.assign(pU,$);return pU}var d={};wT(d,{unwrapMessage:()=>dU,stringifyPrimitive:()=>r,required:()=>mP,randomString:()=>Fw,propertyKeyTypes:()=>nU,promiseAllObject:()=>jP,primitiveTypes:()=>V5,prefixIssues:()=>S6,pick:()=>bP,partial:()=>gP,optionalKeys:()=>K5,omit:()=>fP,numKeys:()=>BP,nullish:()=>QT,normalizeParams:()=>c,merge:()=>hP,jsonStringifyReplacer:()=>O5,joinValues:()=>I,issue:()=>M5,isPlainObject:()=>rU,isObject:()=>Ow,getValidEnumValues:()=>CP,getSizableOrigin:()=>iU,getParsedType:()=>xP,getLengthableOrigin:()=>tU,getElementAtPath:()=>SP,floatSafeRemainder:()=>Q5,finalizeIssue:()=>s6,extend:()=>yP,escapeRegex:()=>D0,esc:()=>rT,defineLazy:()=>g$,createTransparentProxy:()=>IP,clone:()=>a6,cleanRegex:()=>lU,cleanEnum:()=>cP,cached:()=>oU,assignProp:()=>Z5,assertNotEqual:()=>kP,assertNever:()=>qP,assertIs:()=>vP,assertEqual:()=>RP,assert:()=>PP,allowsEval:()=>D5,aborted:()=>nT,NUMBER_FORMAT_RANGES:()=>E5,Class:()=>zV,BIGINT_FORMAT_RANGES:()=>A5});function RP($){return $}function kP($){return $}function vP($){}function qP($){throw new Error}function PP($){}function CP($){let T=Object.keys($).filter((U)=>typeof $[$[U]]!=="number"),W={};for(let U of T)W[U]=$[U];return Object.values(W)}function I($,T="|"){return $.map((W)=>r(W)).join(T)}function O5($,T){if(typeof T==="bigint")return T.toString();return T}function oU($){return{get value(){{let W=$();return Object.defineProperty(this,"value",{value:W}),W}throw new Error("cached value already set")}}}function QT($){return $===null||$===void 0}function lU($){let T=$.startsWith("^")?1:0,W=$.endsWith("$")?$.length-1:$.length;return $.slice(T,W)}function Q5($,T){let W=($.toString().split(".")[1]||"").length,U=(T.toString().split(".")[1]||"").length,X=W>U?W:U,Y=Number.parseInt($.toFixed(X).replace(".","")),w=Number.parseInt(T.toFixed(X).replace(".",""));return Y%w/10**X}function g$($,T,W){Object.defineProperty($,T,{get(){{let X=W();return $[T]=X,X}throw new Error("cached value already set")},set(X){Object.defineProperty($,T,{value:X})},configurable:!0})}function Z5($,T,W){Object.defineProperty($,T,{value:W,writable:!0,enumerable:!0,configurable:!0})}function SP($,T){if(!T)return $;return T.reduce((W,U)=>W?.[U],$)}function jP($){let T=Object.keys($),W=T.map((U)=>$[U]);return Promise.all(W).then((U)=>{let X={};for(let Y=0;Y<T.length;Y++)X[T[Y]]=U[Y];return X})}function Fw($=10){let W="";for(let U=0;U<$;U++)W+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return W}function rT($){return JSON.stringify($)}function Ow($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var D5=oU(()=>{try{return new Function(""),!0}catch($){return!1}});function rU($){return typeof $==="object"&&$!==null&&Object.getPrototypeOf($)===Object.prototype}function BP($){let T=0;for(let W in $)if(Object.prototype.hasOwnProperty.call($,W))T++;return T}var xP=($)=>{let T=typeof $;switch(T){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN($)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray($))return"array";if($===null)return"null";if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return"promise";if(typeof Map!=="undefined"&&$ instanceof Map)return"map";if(typeof Set!=="undefined"&&$ instanceof Set)return"set";if(typeof Date!=="undefined"&&$ instanceof Date)return"date";if(typeof File!=="undefined"&&$ instanceof File)return"file";return"object";default:throw new Error(`Unknown data type: ${T}`)}},nU=new Set(["string","number","symbol"]),V5=new Set(["string","number","bigint","boolean","symbol","undefined"]);function D0($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function a6($,T,W){let U=new $._zod.constr(T??$._zod.def);if(!T||W?.parent)U._zod.parent=$;return U}function c($){let T=$;if(!T)return{};if(typeof T==="string")return{error:()=>T};if(T?.message!==void 0){if(T?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");T.error=T.message}if(delete T.message,typeof T.error==="string")return{...T,error:()=>T.error};return T}function IP($){let T;return new Proxy({},{get(W,U,X){return T??(T=$()),Reflect.get(T,U,X)},set(W,U,X,Y){return T??(T=$()),Reflect.set(T,U,X,Y)},has(W,U){return T??(T=$()),Reflect.has(T,U)},deleteProperty(W,U){return T??(T=$()),Reflect.deleteProperty(T,U)},ownKeys(W){return T??(T=$()),Reflect.ownKeys(T)},getOwnPropertyDescriptor(W,U){return T??(T=$()),Reflect.getOwnPropertyDescriptor(T,U)},defineProperty(W,U,X){return T??(T=$()),Reflect.defineProperty(T,U,X)}})}function r($){if(typeof $==="bigint")return $.toString()+"n";if(typeof $==="string")return`"${$}"`;return`${$}`}function K5($){return Object.keys($).filter((T)=>{return $[T]._zod.optin==="optional"&&$[T]._zod.optout==="optional"})}var E5={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},A5={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function bP($,T){let W={},U=$._zod.def;for(let X in T){if(!(X in U.shape))throw new Error(`Unrecognized key: "${X}"`);if(!T[X])continue;W[X]=U.shape[X]}return a6($,{...$._zod.def,shape:W,checks:[]})}function fP($,T){let W={...$._zod.def.shape},U=$._zod.def;for(let X in T){if(!(X in U.shape))throw new Error(`Unrecognized key: "${X}"`);if(!T[X])continue;delete W[X]}return a6($,{...$._zod.def,shape:W,checks:[]})}function yP($,T){let W={...$._zod.def,get shape(){let U={...$._zod.def.shape,...T};return Z5(this,"shape",U),U},checks:[]};return a6($,W)}function hP($,T){return a6($,{...$._zod.def,get shape(){let W={...$._zod.def.shape,...T._zod.def.shape};return Z5(this,"shape",W),W},catchall:T._zod.def.catchall,checks:[]})}function gP($,T,W){let U=T._zod.def.shape,X={...U};if(W)for(let Y in W){if(!(Y in U))throw new Error(`Unrecognized key: "${Y}"`);if(!W[Y])continue;X[Y]=$?new $({type:"optional",innerType:U[Y]}):U[Y]}else for(let Y in U)X[Y]=$?new $({type:"optional",innerType:U[Y]}):U[Y];return a6(T,{...T._zod.def,shape:X,checks:[]})}function mP($,T,W){let U=T._zod.def.shape,X={...U};if(W)for(let Y in W){if(!(Y in X))throw new Error(`Unrecognized key: "${Y}"`);if(!W[Y])continue;X[Y]=new $({type:"nonoptional",innerType:U[Y]})}else for(let Y in U)X[Y]=new $({type:"nonoptional",innerType:U[Y]});return a6(T,{...T._zod.def,shape:X,checks:[]})}function nT($,T=0){for(let W=T;W<$.issues.length;W++)if($.issues[W].continue!==!0)return!0;return!1}function S6($,T){return T.map((W)=>{var U;return(U=W).path??(U.path=[]),W.path.unshift($),W})}function dU($){return typeof $==="string"?$:$?.message}function s6($,T,W){let U={...$,path:$.path??[]};if(!$.message){let X=dU($.inst?._zod.def?.error?.($))??dU(T?.error?.($))??dU(W.customError?.($))??dU(W.localeError?.($))??"Invalid input";U.message=X}if(delete U.inst,delete U.continue,!T?.reportInput)delete U.input;return U}function iU($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function tU($){if(Array.isArray($))return"array";if(typeof $==="string")return"string";return"unknown"}function M5(...$){let[T,W,U]=$;if(typeof T==="string")return{message:T,code:"custom",input:W,inst:U};return{...T}}function cP($){return Object.entries($).filter(([T,W])=>{return Number.isNaN(Number.parseInt(T,10))}).map((T)=>T[1])}class zV{constructor(...$){}}var HV=($,T)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:T,enumerable:!1}),Object.defineProperty($,"message",{get(){return JSON.stringify(T,O5,2)},enumerable:!0})},aU=k("$ZodError",HV),W2=k("$ZodError",HV,{Parent:Error});function sU($,T=(W)=>W.message){let W={},U=[];for(let X of $.issues)if(X.path.length>0)W[X.path[0]]=W[X.path[0]]||[],W[X.path[0]].push(T(X));else U.push(T(X));return{formErrors:U,fieldErrors:W}}function eU($,T){let W=T||function(Y){return Y.message},U={_errors:[]},X=(Y)=>{for(let w of Y.issues)if(w.code==="invalid_union")w.errors.map((G)=>X({issues:G}));else if(w.code==="invalid_key")X({issues:w.issues});else if(w.code==="invalid_element")X({issues:w.issues});else if(w.path.length===0)U._errors.push(W(w));else{let G=U,H=0;while(H<w.path.length){let z=w.path[H];if(H!==w.path.length-1)G[z]=G[z]||{_errors:[]};else G[z]=G[z]||{_errors:[]},G[z]._errors.push(W(w));G=G[z],H++}}};return X($),U}function N5($,T){let W=T||function(Y){return Y.message},U={errors:[]},X=(Y,w=[])=>{var G,H;for(let z of Y.issues)if(z.code==="invalid_union")z.errors.map((F)=>X({issues:F},z.path));else if(z.code==="invalid_key")X({issues:z.issues},z.path);else if(z.code==="invalid_element")X({issues:z.issues},z.path);else{let F=[...w,...z.path];if(F.length===0){U.errors.push(W(z));continue}let O=U,Q=0;while(Q<F.length){let Z=F[Q],V=Q===F.length-1;if(typeof Z==="string")O.properties??(O.properties={}),(G=O.properties)[Z]??(G[Z]={errors:[]}),O=O.properties[Z];else O.items??(O.items=[]),(H=O.items)[Z]??(H[Z]={errors:[]}),O=O.items[Z];if(V)O.errors.push(W(z));Q++}}};return X($),U}function FV($){let T=[];for(let W of $)if(typeof W==="number")T.push(`[${W}]`);else if(typeof W==="symbol")T.push(`[${JSON.stringify(String(W))}]`);else if(/[^\w$]/.test(W))T.push(`[${JSON.stringify(W)}]`);else{if(T.length)T.push(".");T.push(W)}return T.join("")}function L5($){let T=[],W=[...$.issues].sort((U,X)=>U.path.length-X.path.length);for(let U of W)if(T.push(`\u2716 ${U.message}`),U.path?.length)T.push(` \u2192 at ${FV(U.path)}`);return T.join(`
|
|
6
|
+
`)}var Qw=($)=>(T,W,U,X)=>{let Y=U?Object.assign(U,{async:!1}):{async:!1},w=T._zod.run({value:W,issues:[]},Y);if(w instanceof Promise)throw new Z0;if(w.issues.length){let G=new(X?.Err??$)(w.issues.map((H)=>s6(H,Y,N4())));throw Error.captureStackTrace(G,X?.callee),G}return w.value},Zw=Qw(W2),Dw=($)=>async(T,W,U,X)=>{let Y=U?Object.assign(U,{async:!0}):{async:!0},w=T._zod.run({value:W,issues:[]},Y);if(w instanceof Promise)w=await w;if(w.issues.length){let G=new(X?.Err??$)(w.issues.map((H)=>s6(H,Y,N4())));throw Error.captureStackTrace(G,X?.callee),G}return w.value},Vw=Dw(W2),Kw=($)=>(T,W,U)=>{let X=U?{...U,async:!1}:{async:!1},Y=T._zod.run({value:W,issues:[]},X);if(Y instanceof Promise)throw new Z0;return Y.issues.length?{success:!1,error:new($??aU)(Y.issues.map((w)=>s6(w,X,N4())))}:{success:!0,data:Y.value}},J5=Kw(W2),Ew=($)=>async(T,W,U)=>{let X=U?Object.assign(U,{async:!0}):{async:!0},Y=T._zod.run({value:W,issues:[]},X);if(Y instanceof Promise)Y=await Y;return Y.issues.length?{success:!1,error:new $(Y.issues.map((w)=>s6(w,X,N4())))}:{success:!0,data:Y.value}},_5=Ew(W2);var tT={};wT(tT,{xid:()=>q5,uuid7:()=>lP,uuid6:()=>oP,uuid4:()=>dP,uuid:()=>iT,uppercase:()=>t5,unicodeEmail:()=>iP,undefined:()=>n5,ulid:()=>v5,time:()=>m5,string:()=>u5,rfc5322Email:()=>nP,number:()=>o5,null:()=>r5,nanoid:()=>C5,lowercase:()=>i5,ksuid:()=>P5,ipv6:()=>Mw,ipv4:()=>Aw,ip:()=>sP,integer:()=>d5,html5Email:()=>rP,hostname:()=>y5,guid:()=>j5,extendedDuration:()=>pP,emoji:()=>x5,email:()=>B5,e164:()=>h5,duration:()=>S5,domain:()=>eP,datetime:()=>c5,date:()=>g5,cuid2:()=>k5,cuid:()=>R5,cidrv6:()=>b5,cidrv4:()=>I5,browserEmail:()=>tP,boolean:()=>l5,bigint:()=>p5,base64url:()=>Nw,base64:()=>f5,_emoji:()=>aP});var R5=/^[cC][^\s-]{8,}$/,k5=/^[0-9a-z]+$/,v5=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,q5=/^[0-9a-vA-V]{20}$/,P5=/^[A-Za-z0-9]{27}$/,C5=/^[a-zA-Z0-9_-]{21}$/,S5=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,pP=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,j5=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,iT=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},dP=iT(4),oP=iT(6),lP=iT(7),B5=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,rP=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,nP=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,iP=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,tP=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,aP="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function x5(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var Aw=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Mw=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,I5=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,b5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,sP=new RegExp(`(${Aw.source})|(${Mw.source})`),f5=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Nw=/^[A-Za-z0-9_-]*$/,y5=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,eP=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,h5=/^\+(?:[0-9]){6,14}[0-9]$/,OV="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",g5=new RegExp(`^${OV}$`);function QV($){let T="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)T=`${T}\\.\\d{${$.precision}}`;else if($.precision==null)T=`${T}(\\.\\d+)?`;return T}function m5($){return new RegExp(`^${QV($)}$`)}function c5($){let T=`${OV}T${QV($)}`,W=[];if(W.push($.local?"Z?":"Z"),$.offset)W.push("([+-]\\d{2}:?\\d{2})");return T=`${T}(${W.join("|")})`,new RegExp(`^${T}$`)}var u5=($)=>{let T=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${T}$`)},p5=/^\d+n?$/,d5=/^\d+$/,o5=/^-?\d+(?:\.\d+)?/i,l5=/true|false/i,r5=/null/i;var n5=/undefined/i;var i5=/^[^A-Z]*$/,t5=/^[^a-z]*$/;var G4=k("$ZodCheck",($,T)=>{var W;$._zod??($._zod={}),$._zod.def=T,(W=$._zod).onattach??(W.onattach=[])}),DV={number:"number",bigint:"bigint",object:"date"},Lw=k("$ZodCheckLessThan",($,T)=>{G4.init($,T);let W=DV[typeof T.value];$._zod.onattach.push((U)=>{let X=U._zod.bag,Y=(T.inclusive?X.maximum:X.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(T.value<Y)if(T.inclusive)X.maximum=T.value;else X.exclusiveMaximum=T.value}),$._zod.check=(U)=>{if(T.inclusive?U.value<=T.value:U.value<T.value)return;U.issues.push({origin:W,code:"too_big",maximum:T.value,input:U.value,inclusive:T.inclusive,inst:$,continue:!T.abort})}}),Jw=k("$ZodCheckGreaterThan",($,T)=>{G4.init($,T);let W=DV[typeof T.value];$._zod.onattach.push((U)=>{let X=U._zod.bag,Y=(T.inclusive?X.minimum:X.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(T.value>Y)if(T.inclusive)X.minimum=T.value;else X.exclusiveMinimum=T.value}),$._zod.check=(U)=>{if(T.inclusive?U.value>=T.value:U.value>T.value)return;U.issues.push({origin:W,code:"too_small",minimum:T.value,input:U.value,inclusive:T.inclusive,inst:$,continue:!T.abort})}}),a5=k("$ZodCheckMultipleOf",($,T)=>{G4.init($,T),$._zod.onattach.push((W)=>{var U;(U=W._zod.bag).multipleOf??(U.multipleOf=T.value)}),$._zod.check=(W)=>{if(typeof W.value!==typeof T.value)throw new Error("Cannot mix number and bigint in multiple_of check.");if(typeof W.value==="bigint"?W.value%T.value===BigInt(0):Q5(W.value,T.value)===0)return;W.issues.push({origin:typeof W.value,code:"not_multiple_of",divisor:T.value,input:W.value,inst:$,continue:!T.abort})}}),s5=k("$ZodCheckNumberFormat",($,T)=>{G4.init($,T),T.format=T.format||"float64";let W=T.format?.includes("int"),U=W?"int":"number",[X,Y]=E5[T.format];$._zod.onattach.push((w)=>{let G=w._zod.bag;if(G.format=T.format,G.minimum=X,G.maximum=Y,W)G.pattern=d5}),$._zod.check=(w)=>{let G=w.value;if(W){if(!Number.isInteger(G)){w.issues.push({expected:U,format:T.format,code:"invalid_type",input:G,inst:$});return}if(!Number.isSafeInteger(G)){if(G>0)w.issues.push({input:G,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:U,continue:!T.abort});else w.issues.push({input:G,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:U,continue:!T.abort});return}}if(G<X)w.issues.push({origin:"number",input:G,code:"too_small",minimum:X,inclusive:!0,inst:$,continue:!T.abort});if(G>Y)w.issues.push({origin:"number",input:G,code:"too_big",maximum:Y,inst:$})}}),e5=k("$ZodCheckBigIntFormat",($,T)=>{G4.init($,T);let[W,U]=A5[T.format];$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.format=T.format,Y.minimum=W,Y.maximum=U}),$._zod.check=(X)=>{let Y=X.value;if(Y<W)X.issues.push({origin:"bigint",input:Y,code:"too_small",minimum:W,inclusive:!0,inst:$,continue:!T.abort});if(Y>U)X.issues.push({origin:"bigint",input:Y,code:"too_big",maximum:U,inst:$})}}),$7=k("$ZodCheckMaxSize",($,T)=>{G4.init($,T),$._zod.when=(W)=>{let U=W.value;return!QT(U)&&U.size!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(T.maximum<U)W._zod.bag.maximum=T.maximum}),$._zod.check=(W)=>{let U=W.value;if(U.size<=T.maximum)return;W.issues.push({origin:iU(U),code:"too_big",maximum:T.maximum,input:U,inst:$,continue:!T.abort})}}),T7=k("$ZodCheckMinSize",($,T)=>{G4.init($,T),$._zod.when=(W)=>{let U=W.value;return!QT(U)&&U.size!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(T.minimum>U)W._zod.bag.minimum=T.minimum}),$._zod.check=(W)=>{let U=W.value;if(U.size>=T.minimum)return;W.issues.push({origin:iU(U),code:"too_small",minimum:T.minimum,input:U,inst:$,continue:!T.abort})}}),W7=k("$ZodCheckSizeEquals",($,T)=>{G4.init($,T),$._zod.when=(W)=>{let U=W.value;return!QT(U)&&U.size!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag;U.minimum=T.size,U.maximum=T.size,U.size=T.size}),$._zod.check=(W)=>{let U=W.value,X=U.size;if(X===T.size)return;let Y=X>T.size;W.issues.push({origin:iU(U),...Y?{code:"too_big",maximum:T.size}:{code:"too_small",minimum:T.size},input:W.value,inst:$,continue:!T.abort})}}),U7=k("$ZodCheckMaxLength",($,T)=>{G4.init($,T),$._zod.when=(W)=>{let U=W.value;return!QT(U)&&U.length!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(T.maximum<U)W._zod.bag.maximum=T.maximum}),$._zod.check=(W)=>{let U=W.value;if(U.length<=T.maximum)return;let Y=tU(U);W.issues.push({origin:Y,code:"too_big",maximum:T.maximum,input:U,inst:$,continue:!T.abort})}}),X7=k("$ZodCheckMinLength",($,T)=>{G4.init($,T),$._zod.when=(W)=>{let U=W.value;return!QT(U)&&U.length!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(T.minimum>U)W._zod.bag.minimum=T.minimum}),$._zod.check=(W)=>{let U=W.value;if(U.length>=T.minimum)return;let Y=tU(U);W.issues.push({origin:Y,code:"too_small",minimum:T.minimum,input:U,inst:$,continue:!T.abort})}}),Y7=k("$ZodCheckLengthEquals",($,T)=>{G4.init($,T),$._zod.when=(W)=>{let U=W.value;return!QT(U)&&U.length!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag;U.minimum=T.length,U.maximum=T.length,U.length=T.length}),$._zod.check=(W)=>{let U=W.value,X=U.length;if(X===T.length)return;let Y=tU(U),w=X>T.length;W.issues.push({origin:Y,...w?{code:"too_big",maximum:T.length}:{code:"too_small",minimum:T.length},input:W.value,inst:$,continue:!T.abort})}}),U2=k("$ZodCheckStringFormat",($,T)=>{var W;G4.init($,T),$._zod.onattach.push((U)=>{let X=U._zod.bag;if(X.format=T.format,T.pattern)X.patterns??(X.patterns=new Set),X.patterns.add(T.pattern)}),(W=$._zod).check??(W.check=(U)=>{if(!T.pattern)throw new Error("Not implemented.");if(T.pattern.lastIndex=0,T.pattern.test(U.value))return;U.issues.push({origin:"string",code:"invalid_format",format:T.format,input:U.value,...T.pattern?{pattern:T.pattern.toString()}:{},inst:$,continue:!T.abort})})}),w7=k("$ZodCheckRegex",($,T)=>{U2.init($,T),$._zod.check=(W)=>{if(T.pattern.lastIndex=0,T.pattern.test(W.value))return;W.issues.push({origin:"string",code:"invalid_format",format:"regex",input:W.value,pattern:T.pattern.toString(),inst:$,continue:!T.abort})}}),G7=k("$ZodCheckLowerCase",($,T)=>{T.pattern??(T.pattern=i5),U2.init($,T)}),z7=k("$ZodCheckUpperCase",($,T)=>{T.pattern??(T.pattern=t5),U2.init($,T)}),H7=k("$ZodCheckIncludes",($,T)=>{G4.init($,T);let W=new RegExp(D0(T.includes));T.pattern=W,$._zod.onattach.push((U)=>{let X=U._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(W)}),$._zod.check=(U)=>{if(U.value.includes(T.includes,T.position))return;U.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:T.includes,input:U.value,inst:$,continue:!T.abort})}}),F7=k("$ZodCheckStartsWith",($,T)=>{G4.init($,T);let W=new RegExp(`^${D0(T.prefix)}.*`);T.pattern??(T.pattern=W),$._zod.onattach.push((U)=>{let X=U._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(W)}),$._zod.check=(U)=>{if(U.value.startsWith(T.prefix))return;U.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:T.prefix,input:U.value,inst:$,continue:!T.abort})}}),O7=k("$ZodCheckEndsWith",($,T)=>{G4.init($,T);let W=new RegExp(`.*${D0(T.suffix)}$`);T.pattern??(T.pattern=W),$._zod.onattach.push((U)=>{let X=U._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(W)}),$._zod.check=(U)=>{if(U.value.endsWith(T.suffix))return;U.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:T.suffix,input:U.value,inst:$,continue:!T.abort})}});function ZV($,T,W){if($.issues.length)T.issues.push(...S6(W,$.issues))}var Q7=k("$ZodCheckProperty",($,T)=>{G4.init($,T),$._zod.check=(W)=>{let U=T.schema._zod.run({value:W.value[T.property],issues:[]},{});if(U instanceof Promise)return U.then((X)=>ZV(X,W,T.property));ZV(U,W,T.property);return}}),Z7=k("$ZodCheckMimeType",($,T)=>{G4.init($,T);let W=new Set(T.mime);$._zod.onattach.push((U)=>{U._zod.bag.mime=T.mime}),$._zod.check=(U)=>{if(W.has(U.value.type))return;U.issues.push({code:"invalid_value",values:T.mime,input:U.value.type,path:["type"],inst:$})}}),D7=k("$ZodCheckOverwrite",($,T)=>{G4.init($,T),$._zod.check=(W)=>{W.value=T.tx(W.value)}});class _w{constructor($=[]){if(this.content=[],this.indent=0,this)this.args=$}indented($){this.indent+=1,$(this),this.indent-=1}write($){if(typeof $==="function"){$(this,{execution:"sync"}),$(this,{execution:"async"});return}let W=$.split(`
|
|
7
|
+
`).filter((Y)=>Y),U=Math.min(...W.map((Y)=>Y.length-Y.trimStart().length)),X=W.map((Y)=>Y.slice(U)).map((Y)=>" ".repeat(this.indent*2)+Y);for(let Y of X)this.content.push(Y)}compile(){let $=Function,T=this?.args,U=[...(this?.content??[""]).map((X)=>` ${X}`)];return new $(...T,U.join(`
|
|
8
|
+
`))}}var V7={major:4,minor:0,patch:0};var Q$=k("$ZodType",($,T)=>{var W;$??($={}),$._zod.id=T.type+"_"+Fw(10),$._zod.def=T,$._zod.bag=$._zod.bag||{},$._zod.version=V7;let U=[...$._zod.def.checks??[]];if($._zod.traits.has("$ZodCheck"))U.unshift($);for(let X of U)for(let Y of X._zod.onattach)Y($);if(U.length===0)(W=$._zod).deferred??(W.deferred=[]),$._zod.deferred?.push(()=>{$._zod.run=$._zod.parse});else{let X=(Y,w,G)=>{let H=nT(Y),z;for(let F of w){if(F._zod.when){if(!F._zod.when(Y))continue}else if(H)continue;let O=Y.issues.length,Q=F._zod.check(Y);if(Q instanceof Promise&&G?.async===!1)throw new Z0;if(z||Q instanceof Promise)z=(z??Promise.resolve()).then(async()=>{if(await Q,Y.issues.length===O)return;if(!H)H=nT(Y,O)});else{if(Y.issues.length===O)continue;if(!H)H=nT(Y,O)}}if(z)return z.then(()=>{return Y});return Y};$._zod.run=(Y,w)=>{let G=$._zod.parse(Y,w);if(G instanceof Promise){if(w.async===!1)throw new Z0;return G.then((H)=>X(H,U,w))}return X(G,U,w)}}$["~standard"]={validate:(X)=>{try{let Y=J5($,X);return Y.success?{value:Y.data}:{issues:Y.error?.issues}}catch(Y){return _5($,X).then((w)=>w.success?{value:w.data}:{issues:w.error?.issues})}},vendor:"zod",version:1}}),$X=k("$ZodString",($,T)=>{Q$.init($,T),$._zod.pattern=[...$?._zod.bag?.patterns??[]].pop()??u5($._zod.bag),$._zod.parse=(W,U)=>{if(T.coerce)try{W.value=String(W.value)}catch(X){}if(typeof W.value==="string")return W;return W.issues.push({expected:"string",code:"invalid_type",input:W.value,inst:$}),W}}),l$=k("$ZodStringFormat",($,T)=>{U2.init($,T),$X.init($,T)}),E7=k("$ZodGUID",($,T)=>{T.pattern??(T.pattern=j5),l$.init($,T)}),A7=k("$ZodUUID",($,T)=>{if(T.version){let U={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[T.version];if(U===void 0)throw new Error(`Invalid UUID version: "${T.version}"`);T.pattern??(T.pattern=iT(U))}else T.pattern??(T.pattern=iT());l$.init($,T)}),M7=k("$ZodEmail",($,T)=>{T.pattern??(T.pattern=B5),l$.init($,T)}),N7=k("$ZodURL",($,T)=>{l$.init($,T),$._zod.check=(W)=>{try{let U=new URL(W.value);if(T.hostname){if(T.hostname.lastIndex=0,!T.hostname.test(U.hostname))W.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:y5.source,input:W.value,inst:$})}if(T.protocol){if(T.protocol.lastIndex=0,!T.protocol.test(U.protocol.endsWith(":")?U.protocol.slice(0,-1):U.protocol))W.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:T.protocol.source,input:W.value,inst:$})}return}catch(U){W.issues.push({code:"invalid_format",format:"url",input:W.value,inst:$})}}}),L7=k("$ZodEmoji",($,T)=>{T.pattern??(T.pattern=x5()),l$.init($,T)}),J7=k("$ZodNanoID",($,T)=>{T.pattern??(T.pattern=C5),l$.init($,T)}),_7=k("$ZodCUID",($,T)=>{T.pattern??(T.pattern=R5),l$.init($,T)}),R7=k("$ZodCUID2",($,T)=>{T.pattern??(T.pattern=k5),l$.init($,T)}),k7=k("$ZodULID",($,T)=>{T.pattern??(T.pattern=v5),l$.init($,T)}),v7=k("$ZodXID",($,T)=>{T.pattern??(T.pattern=q5),l$.init($,T)}),q7=k("$ZodKSUID",($,T)=>{T.pattern??(T.pattern=P5),l$.init($,T)}),P7=k("$ZodISODateTime",($,T)=>{T.pattern??(T.pattern=c5(T)),l$.init($,T)}),C7=k("$ZodISODate",($,T)=>{T.pattern??(T.pattern=g5),l$.init($,T)}),S7=k("$ZodISOTime",($,T)=>{T.pattern??(T.pattern=m5(T)),l$.init($,T)}),j7=k("$ZodISODuration",($,T)=>{T.pattern??(T.pattern=S5),l$.init($,T)}),B7=k("$ZodIPv4",($,T)=>{T.pattern??(T.pattern=Aw),l$.init($,T),$._zod.onattach.push((W)=>{let U=W._zod.bag;U.format="ipv4"})}),x7=k("$ZodIPv6",($,T)=>{T.pattern??(T.pattern=Mw),l$.init($,T),$._zod.onattach.push((W)=>{let U=W._zod.bag;U.format="ipv6"}),$._zod.check=(W)=>{try{new URL(`http://[${W.value}]`)}catch{W.issues.push({code:"invalid_format",format:"ipv6",input:W.value,inst:$})}}}),I7=k("$ZodCIDRv4",($,T)=>{T.pattern??(T.pattern=I5),l$.init($,T)}),b7=k("$ZodCIDRv6",($,T)=>{T.pattern??(T.pattern=b5),l$.init($,T),$._zod.check=(W)=>{let[U,X]=W.value.split("/");try{if(!X)throw new Error;let Y=Number(X);if(`${Y}`!==X)throw new Error;if(Y<0||Y>128)throw new Error;new URL(`http://[${U}]`)}catch{W.issues.push({code:"invalid_format",format:"cidrv6",input:W.value,inst:$})}}});function f7($){if($==="")return!0;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}var y7=k("$ZodBase64",($,T)=>{T.pattern??(T.pattern=f5),l$.init($,T),$._zod.onattach.push((W)=>{W._zod.bag.contentEncoding="base64"}),$._zod.check=(W)=>{if(f7(W.value))return;W.issues.push({code:"invalid_format",format:"base64",input:W.value,inst:$})}});function qV($){if(!Nw.test($))return!1;let T=$.replace(/[-_]/g,(U)=>U==="-"?"+":"/"),W=T.padEnd(Math.ceil(T.length/4)*4,"=");return f7(W)}var h7=k("$ZodBase64URL",($,T)=>{T.pattern??(T.pattern=Nw),l$.init($,T),$._zod.onattach.push((W)=>{W._zod.bag.contentEncoding="base64url"}),$._zod.check=(W)=>{if(qV(W.value))return;W.issues.push({code:"invalid_format",format:"base64url",input:W.value,inst:$})}}),g7=k("$ZodE164",($,T)=>{T.pattern??(T.pattern=h5),l$.init($,T)});function PV($,T=null){try{let W=$.split(".");if(W.length!==3)return!1;let[U]=W,X=JSON.parse(atob(U));if("typ"in X&&X?.typ!=="JWT")return!1;if(!X.alg)return!1;if(T&&(!("alg"in X)||X.alg!==T))return!1;return!0}catch{return!1}}var m7=k("$ZodJWT",($,T)=>{l$.init($,T),$._zod.check=(W)=>{if(PV(W.value,T.alg))return;W.issues.push({code:"invalid_format",format:"jwt",input:W.value,inst:$})}}),vw=k("$ZodNumber",($,T)=>{Q$.init($,T),$._zod.pattern=$._zod.bag.pattern??o5,$._zod.parse=(W,U)=>{if(T.coerce)try{W.value=Number(W.value)}catch(w){}let X=W.value;if(typeof X==="number"&&!Number.isNaN(X)&&Number.isFinite(X))return W;let Y=typeof X==="number"?Number.isNaN(X)?"NaN":!Number.isFinite(X)?"Infinity":void 0:void 0;return W.issues.push({expected:"number",code:"invalid_type",input:X,inst:$,...Y?{received:Y}:{}}),W}}),c7=k("$ZodNumber",($,T)=>{s5.init($,T),vw.init($,T)}),TX=k("$ZodBoolean",($,T)=>{Q$.init($,T),$._zod.pattern=l5,$._zod.parse=(W,U)=>{if(T.coerce)try{W.value=Boolean(W.value)}catch(Y){}let X=W.value;if(typeof X==="boolean")return W;return W.issues.push({expected:"boolean",code:"invalid_type",input:X,inst:$}),W}}),qw=k("$ZodBigInt",($,T)=>{Q$.init($,T),$._zod.pattern=p5,$._zod.parse=(W,U)=>{if(T.coerce)try{W.value=BigInt(W.value)}catch(Y){}let{value:X}=W;if(typeof X==="bigint")return W;return W.issues.push({expected:"bigint",code:"invalid_type",input:X,inst:$}),W}}),u7=k("$ZodBigInt",($,T)=>{e5.init($,T),qw.init($,T)}),p7=k("$ZodSymbol",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{let{value:X}=W;if(typeof X==="symbol")return W;return W.issues.push({expected:"symbol",code:"invalid_type",input:X,inst:$}),W}}),d7=k("$ZodUndefined",($,T)=>{Q$.init($,T),$._zod.pattern=n5,$._zod.values=new Set([void 0]),$._zod.parse=(W,U)=>{let{value:X}=W;if(typeof X==="undefined")return W;return W.issues.push({expected:"undefined",code:"invalid_type",input:X,inst:$}),W}}),o7=k("$ZodNull",($,T)=>{Q$.init($,T),$._zod.pattern=r5,$._zod.values=new Set([null]),$._zod.parse=(W,U)=>{let{value:X}=W;if(X===null)return W;return W.issues.push({expected:"null",code:"invalid_type",input:X,inst:$}),W}}),l7=k("$ZodAny",($,T)=>{Q$.init($,T),$._zod.parse=(W)=>W}),WX=k("$ZodUnknown",($,T)=>{Q$.init($,T),$._zod.parse=(W)=>W}),r7=k("$ZodNever",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{return W.issues.push({expected:"never",code:"invalid_type",input:W.value,inst:$}),W}}),n7=k("$ZodVoid",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{let{value:X}=W;if(typeof X==="undefined")return W;return W.issues.push({expected:"void",code:"invalid_type",input:X,inst:$}),W}}),i7=k("$ZodDate",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{if(T.coerce)try{W.value=new Date(W.value)}catch(G){}let X=W.value,Y=X instanceof Date;if(Y&&!Number.isNaN(X.getTime()))return W;return W.issues.push({expected:"date",code:"invalid_type",input:X,...Y?{received:"Invalid Date"}:{},inst:$}),W}});function KV($,T,W){if($.issues.length)T.issues.push(...S6(W,$.issues));T.value[W]=$.value}var t7=k("$ZodArray",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{let X=W.value;if(!Array.isArray(X))return W.issues.push({expected:"array",code:"invalid_type",input:X,inst:$}),W;W.value=Array(X.length);let Y=[];for(let w=0;w<X.length;w++){let G=X[w],H=T.element._zod.run({value:G,issues:[]},U);if(H instanceof Promise)Y.push(H.then((z)=>KV(z,W,w)));else KV(H,W,w)}if(Y.length)return Promise.all(Y).then(()=>W);return W}});function Rw($,T,W){if($.issues.length)T.issues.push(...S6(W,$.issues));T.value[W]=$.value}function EV($,T,W,U){if($.issues.length)if(U[W]===void 0)if(W in U)T.value[W]=void 0;else T.value[W]=$.value;else T.issues.push(...S6(W,$.issues));else if($.value===void 0){if(W in U)T.value[W]=void 0}else T.value[W]=$.value}var a7=k("$ZodObject",($,T)=>{Q$.init($,T);let W=oU(()=>{let O=Object.keys(T.shape);for(let Z of O)if(!(T.shape[Z]instanceof Q$))throw new Error(`Invalid element at key "${Z}": expected a Zod schema`);let Q=K5(T.shape);return{shape:T.shape,keys:O,keySet:new Set(O),numKeys:O.length,optionalKeys:new Set(Q)}});g$($._zod,"disc",()=>{let O=T.shape,Q=new Map,Z=!1;for(let V in O){let E=O[V]._zod;if(E.values||E.disc){Z=!0;let N={values:new Set(E.values??[]),maps:E.disc?[E.disc]:[]};Q.set(V,N)}}if(!Z)return;return Q});let U=(O)=>{let Q=new _w(["shape","payload","ctx"]),{keys:Z,optionalKeys:V}=W.value,E=(_)=>{let R=rT(_);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};Q.write("const input = payload.value;");let N=Object.create(null);for(let _ of Z)N[_]=Fw(15);Q.write("const newResult = {}");for(let _ of Z)if(V.has(_)){let R=N[_];Q.write(`const ${R} = ${E(_)};`);let P=rT(_);Q.write(`
|
|
9
|
+
if (${R}.issues.length) {
|
|
10
|
+
if (input[${P}] === undefined) {
|
|
11
|
+
if (${P} in input) {
|
|
12
|
+
newResult[${P}] = undefined;
|
|
13
13
|
}
|
|
14
14
|
} else {
|
|
15
15
|
payload.issues = payload.issues.concat(
|
|
16
|
-
${
|
|
16
|
+
${R}.issues.map((iss) => ({
|
|
17
17
|
...iss,
|
|
18
|
-
path: iss.path ? [${
|
|
18
|
+
path: iss.path ? [${P}, ...iss.path] : [${P}],
|
|
19
19
|
}))
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
|
-
} else if (${
|
|
23
|
-
if (${
|
|
22
|
+
} else if (${R}.value === undefined) {
|
|
23
|
+
if (${P} in input) newResult[${P}] = undefined;
|
|
24
24
|
} else {
|
|
25
|
-
newResult[${
|
|
25
|
+
newResult[${P}] = ${R}.value;
|
|
26
26
|
}
|
|
27
|
-
`)}else{let N
|
|
28
|
-
if (${
|
|
27
|
+
`)}else{let R=N[_];Q.write(`const ${R} = ${E(_)};`),Q.write(`
|
|
28
|
+
if (${R}.issues.length) payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
|
|
29
29
|
...iss,
|
|
30
|
-
path: iss.path ? [${
|
|
31
|
-
})));`),F.write(`newResult[${n1(A)}] = ${N}.value`)}F.write("payload.value = newResult;"),F.write("return payload;");let P=F.compile();return(A,N)=>P(_,A,N)},Y,U=uX,G=!zW.jitless,z=G&&zG.value,{catchall:w}=T,H;$._zod.parse=(_,F)=>{H??(H=W.value);let D=_.value;if(!U(D))return _.issues.push({expected:"object",code:"invalid_type",input:D,inst:$}),_;let V=[];if(G&&z&&F?.async===!1&&F.jitless!==!0){if(!Y)Y=X(T.shape);_=Y(_,F)}else{_.value={};let N=H.shape;for(let k of H.keys){let y=N[k],x=y._zod.run({value:D[k],issues:[]},F),m=y._zod.optin==="optional";if(x instanceof Promise)V.push(x.then((J$)=>m?M3(J$,_,k,D):TY(J$,_,k)));else if(m)M3(x,_,k,D);else TY(x,_,k)}}if(!w)return V.length?Promise.all(V).then(()=>_):_;let E=[],R=H.keySet,P=w._zod,A=P.def.type;for(let N of Object.keys(D)){if(R.has(N))continue;if(A==="never"){E.push(N);continue}let k=P.run({value:D[N],issues:[]},F);if(k instanceof Promise)V.push(k.then((y)=>TY(y,_,N)));else TY(k,_,N)}if(E.length)_.issues.push({code:"unrecognized_keys",keys:E,input:D,inst:$});if(!V.length)return _;return Promise.all(V).then(()=>{return _})}});function A3($,T,W,X){for(let Y of $)if(Y.issues.length===0)return T.value=Y.value,T;return T.issues.push({code:"invalid_union",input:T.value,inst:W,errors:$.map((Y)=>Y.issues.map((U)=>n4(U,X,n$())))}),T}var UY=K("$ZodUnion",($,T)=>{W$.init($,T),N$($._zod,"values",()=>{if(T.options.every((W)=>W._zod.values))return new Set(T.options.flatMap((W)=>Array.from(W._zod.values)));return}),N$($._zod,"pattern",()=>{if(T.options.every((W)=>W._zod.pattern)){let W=T.options.map((X)=>X._zod.pattern);return new RegExp(`^(${W.map((X)=>FW(X.source)).join("|")})$`)}return}),$._zod.parse=(W,X)=>{let Y=!1,U=[];for(let G of T.options){let J=G._zod.run({value:W.value,issues:[]},X);if(J instanceof Promise)U.push(J),Y=!0;else{if(J.issues.length===0)return J;U.push(J)}}if(!Y)return A3(U,W,$,X);return Promise.all(U).then((G)=>{return A3(G,W,$,X)})}});function v3($,T,W){let X=!0,Y=$?.[T];if(W.values.size&&!W.values.has(Y))X=!1;if(W.maps.length>0){for(let U of W.maps)if(!aA(Y,U))X=!1}return X}function aA($,T){let W=!0;for(let[X,Y]of T)if(!v3($,X,Y))W=!1;return W}var rJ=K("$ZodDiscriminatedUnion",($,T)=>{UY.init($,T);let W=$._zod.parse;N$($._zod,"disc",()=>{let Y=new Map;for(let U of T.options){let G=U._zod.disc;if(!G)throw new Error(`Invalid discriminated union option at index "${T.options.indexOf(U)}"`);for(let[J,z]of G){if(!Y.has(J))Y.set(J,{values:new Set,maps:[]});let w=Y.get(J);for(let H of z.values)w.values.add(H);for(let H of z.maps)w.maps.push(H)}}return Y});let X=HW(()=>{let Y=new Map;for(let U of T.options){let G=U._zod.disc?.get(T.discriminator);if(!G)throw new Error("Invalid discriminated union option");Y.set(U,G)}return Y});$._zod.parse=(Y,U)=>{let G=Y.value;if(!uX(G))return Y.issues.push({code:"invalid_type",expected:"object",input:G,inst:$}),Y;let J=[],z=X.value;for(let w of T.options){let H=z.get(w);if(v3(G,T.discriminator,H))J.push(w)}if(J.length===1)return J[0]._zod.run(Y,U);if(T.unionFallback)return W(Y,U);return Y.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:G,path:[T.discriminator],inst:$}),Y}}),iJ=K("$ZodIntersection",($,T)=>{W$.init($,T),$._zod.parse=(W,X)=>{let{value:Y}=W,U=T.left._zod.run({value:Y,issues:[]},X),G=T.right._zod.run({value:Y,issues:[]},X);if(U instanceof Promise||G instanceof Promise)return Promise.all([U,G]).then(([z,w])=>{return N3(W,z,w)});return N3(W,U,G)}});function HJ($,T){if($===T)return{valid:!0,data:$};if($ instanceof Date&&T instanceof Date&&+$===+T)return{valid:!0,data:$};if(QW($)&&QW(T)){let W=Object.keys(T),X=Object.keys($).filter((U)=>W.indexOf(U)!==-1),Y={...$,...T};for(let U of X){let G=HJ($[U],T[U]);if(!G.valid)return{valid:!1,mergeErrorPath:[U,...G.mergeErrorPath]};Y[U]=G.data}return{valid:!0,data:Y}}if(Array.isArray($)&&Array.isArray(T)){if($.length!==T.length)return{valid:!1,mergeErrorPath:[]};let W=[];for(let X=0;X<$.length;X++){let Y=$[X],U=T[X],G=HJ(Y,U);if(!G.valid)return{valid:!1,mergeErrorPath:[X,...G.mergeErrorPath]};W.push(G.data)}return{valid:!0,data:W}}return{valid:!1,mergeErrorPath:[]}}function N3($,T,W){if(T.issues.length)$.issues.push(...T.issues);if(W.issues.length)$.issues.push(...W.issues);if(t1($))return $;let X=HJ(T.value,W.value);if(!X.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(X.mergeErrorPath)}`);return $.value=X.data,$}var e1=K("$ZodTuple",($,T)=>{W$.init($,T);let W=T.items,X=W.length-[...W].reverse().findIndex((Y)=>Y._zod.optin!=="optional");$._zod.parse=(Y,U)=>{let G=Y.value;if(!Array.isArray(G))return Y.issues.push({input:G,inst:$,expected:"tuple",code:"invalid_type"}),Y;Y.value=[];let J=[];if(!T.rest){let w=G.length>W.length,H=G.length<X-1;if(w||H)return Y.issues.push({input:G,inst:$,origin:"array",...w?{code:"too_big",maximum:W.length}:{code:"too_small",minimum:W.length}}),Y}let z=-1;for(let w of W){if(z++,z>=G.length){if(z>=X)continue}let H=w._zod.run({value:G[z],issues:[]},U);if(H instanceof Promise)J.push(H.then((_)=>WY(_,Y,z)));else WY(H,Y,z)}if(T.rest){let w=G.slice(W.length);for(let H of w){z++;let _=T.rest._zod.run({value:H,issues:[]},U);if(_ instanceof Promise)J.push(_.then((F)=>WY(F,Y,z)));else WY(_,Y,z)}}if(J.length)return Promise.all(J).then(()=>Y);return Y}});function WY($,T,W){if($.issues.length)T.issues.push(...x4(W,$.issues));T.value[W]=$.value}var nJ=K("$ZodRecord",($,T)=>{W$.init($,T),$._zod.parse=(W,X)=>{let Y=W.value;if(!QW(Y))return W.issues.push({expected:"record",code:"invalid_type",input:Y,inst:$}),W;let U=[];if(T.keyType._zod.values){let G=T.keyType._zod.values;W.value={};for(let z of G)if(typeof z==="string"||typeof z==="number"||typeof z==="symbol"){let w=T.valueType._zod.run({value:Y[z],issues:[]},X);if(w instanceof Promise)U.push(w.then((H)=>{if(H.issues.length)W.issues.push(...x4(z,H.issues));W.value[z]=H.value}));else{if(w.issues.length)W.issues.push(...x4(z,w.issues));W.value[z]=w.value}}let J;for(let z in Y)if(!G.has(z))J=J??[],J.push(z);if(J&&J.length>0)W.issues.push({code:"unrecognized_keys",input:Y,inst:$,keys:J})}else{W.value={};for(let G of Reflect.ownKeys(Y)){if(G==="__proto__")continue;let J=T.keyType._zod.run({value:G,issues:[]},X);if(J instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(J.issues.length){W.issues.push({origin:"record",code:"invalid_key",issues:J.issues.map((w)=>n4(w,X,n$())),input:G,path:[G],inst:$}),W.value[J.value]=J.value;continue}let z=T.valueType._zod.run({value:Y[G],issues:[]},X);if(z instanceof Promise)U.push(z.then((w)=>{if(w.issues.length)W.issues.push(...x4(G,w.issues));W.value[J.value]=w.value}));else{if(z.issues.length)W.issues.push(...x4(G,z.issues));W.value[J.value]=z.value}}}if(U.length)return Promise.all(U).then(()=>W);return W}}),tJ=K("$ZodMap",($,T)=>{W$.init($,T),$._zod.parse=(W,X)=>{let Y=W.value;if(!(Y instanceof Map))return W.issues.push({expected:"map",code:"invalid_type",input:Y,inst:$}),W;let U=[];W.value=new Map;for(let[G,J]of Y){let z=T.keyType._zod.run({value:G,issues:[]},X),w=T.valueType._zod.run({value:J,issues:[]},X);if(z instanceof Promise||w instanceof Promise)U.push(Promise.all([z,w]).then(([H,_])=>{L3(H,_,W,G,Y,$,X)}));else L3(z,w,W,G,Y,$,X)}if(U.length)return Promise.all(U).then(()=>W);return W}});function L3($,T,W,X,Y,U,G){if($.issues.length)if(ZW.has(typeof X))W.issues.push(...x4(X,$.issues));else W.issues.push({origin:"map",code:"invalid_key",input:Y,inst:U,issues:$.issues.map((J)=>n4(J,G,n$()))});if(T.issues.length)if(ZW.has(typeof X))W.issues.push(...x4(X,T.issues));else W.issues.push({origin:"map",code:"invalid_element",input:Y,inst:U,key:X,issues:T.issues.map((J)=>n4(J,G,n$()))});W.value.set($.value,T.value)}var aJ=K("$ZodSet",($,T)=>{W$.init($,T),$._zod.parse=(W,X)=>{let Y=W.value;if(!(Y instanceof Set))return W.issues.push({input:Y,inst:$,expected:"set",code:"invalid_type"}),W;let U=[];W.value=new Set;for(let G of Y){let J=T.valueType._zod.run({value:G,issues:[]},X);if(J instanceof Promise)U.push(J.then((z)=>S3(z,W)));else S3(J,W)}if(U.length)return Promise.all(U).then(()=>W);return W}});function S3($,T){if($.issues.length)T.issues.push(...$.issues);T.value.add($.value)}var sJ=K("$ZodEnum",($,T)=>{W$.init($,T);let W=Object.values(T.entries).filter((Y)=>typeof Y==="number"),X=Object.entries(T.entries).filter(([Y,U])=>W.indexOf(+Y)===-1).map(([Y,U])=>U);$._zod.values=new Set(X),$._zod.pattern=new RegExp(`^(${X.filter((Y)=>ZW.has(typeof Y)).map((Y)=>typeof Y==="string"?C6(Y):Y.toString()).join("|")})$`),$._zod.parse=(Y,U)=>{let G=Y.value;if($._zod.values.has(G))return Y;return Y.issues.push({code:"invalid_value",values:X,input:G,inst:$}),Y}}),eJ=K("$ZodLiteral",($,T)=>{W$.init($,T),$._zod.values=new Set(T.values),$._zod.pattern=new RegExp(`^(${T.values.map((W)=>typeof W==="string"?C6(W):W?W.toString():String(W)).join("|")})$`),$._zod.parse=(W,X)=>{let Y=W.value;if($._zod.values.has(Y))return W;return W.issues.push({code:"invalid_value",values:T.values,input:Y,inst:$}),W}}),$9=K("$ZodFile",($,T)=>{W$.init($,T),$._zod.parse=(W,X)=>{let Y=W.value;if(Y instanceof File)return W;return W.issues.push({expected:"file",code:"invalid_type",input:Y,inst:$}),W}}),T9=K("$ZodTransform",($,T)=>{W$.init($,T),$._zod.parse=(W,X)=>{let Y=T.transform(W.value,W);if(X.async)return(Y instanceof Promise?Y:Promise.resolve(Y)).then((G)=>{return W.value=G,W});if(Y instanceof Promise)throw new u6;return W.value=Y,W}}),W9=K("$ZodOptional",($,T)=>{W$.init($,T),$._zod.optin="optional",$._zod.optout="optional",N$($._zod,"values",()=>{return T.innerType._zod.values?new Set([...T.innerType._zod.values,void 0]):void 0}),N$($._zod,"pattern",()=>{let W=T.innerType._zod.pattern;return W?new RegExp(`^(${FW(W.source)})?$`):void 0}),$._zod.parse=(W,X)=>{if(W.value===void 0)return W;return T.innerType._zod.run(W,X)}}),X9=K("$ZodNullable",($,T)=>{W$.init($,T),N$($._zod,"optin",()=>T.innerType._zod.optin),N$($._zod,"optout",()=>T.innerType._zod.optout),N$($._zod,"pattern",()=>{let W=T.innerType._zod.pattern;return W?new RegExp(`^(${FW(W.source)}|null)$`):void 0}),N$($._zod,"values",()=>{return T.innerType._zod.values?new Set([...T.innerType._zod.values,null]):void 0}),$._zod.parse=(W,X)=>{if(W.value===null)return W;return T.innerType._zod.run(W,X)}}),Y9=K("$ZodDefault",($,T)=>{W$.init($,T),$._zod.optin="optional",N$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,X)=>{if(W.value===void 0)return W.value=T.defaultValue,W;let Y=T.innerType._zod.run(W,X);if(Y instanceof Promise)return Y.then((U)=>B3(U,T));return B3(Y,T)}});function B3($,T){if($.value===void 0)$.value=T.defaultValue;return $}var U9=K("$ZodPrefault",($,T)=>{W$.init($,T),$._zod.optin="optional",N$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,X)=>{if(W.value===void 0)W.value=T.defaultValue;return T.innerType._zod.run(W,X)}}),G9=K("$ZodNonOptional",($,T)=>{W$.init($,T),N$($._zod,"values",()=>{let W=T.innerType._zod.values;return W?new Set([...W].filter((X)=>X!==void 0)):void 0}),$._zod.parse=(W,X)=>{let Y=T.innerType._zod.run(W,X);if(Y instanceof Promise)return Y.then((U)=>R3(U,$));return R3(Y,$)}});function R3($,T){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:T});return $}var J9=K("$ZodSuccess",($,T)=>{W$.init($,T),$._zod.parse=(W,X)=>{let Y=T.innerType._zod.run(W,X);if(Y instanceof Promise)return Y.then((U)=>{return W.value=U.issues.length===0,W});return W.value=Y.issues.length===0,W}}),w9=K("$ZodCatch",($,T)=>{W$.init($,T),N$($._zod,"optin",()=>T.innerType._zod.optin),N$($._zod,"optout",()=>T.innerType._zod.optout),N$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,X)=>{let Y=T.innerType._zod.run(W,X);if(Y instanceof Promise)return Y.then((U)=>{if(W.value=U.value,U.issues.length)W.value=T.catchValue({...W,error:{issues:U.issues.map((G)=>n4(G,X,n$()))},input:W.value}),W.issues=[];return W});if(W.value=Y.value,Y.issues.length)W.value=T.catchValue({...W,error:{issues:Y.issues.map((U)=>n4(U,X,n$()))},input:W.value}),W.issues=[];return W}}),z9=K("$ZodNaN",($,T)=>{W$.init($,T),$._zod.parse=(W,X)=>{if(typeof W.value!=="number"||!Number.isNaN(W.value))return W.issues.push({input:W.value,inst:$,expected:"nan",code:"invalid_type"}),W;return W}}),LW=K("$ZodPipe",($,T)=>{W$.init($,T),N$($._zod,"values",()=>T.in._zod.values),N$($._zod,"optin",()=>T.in._zod.optin),N$($._zod,"optout",()=>T.out._zod.optout),$._zod.parse=(W,X)=>{let Y=T.in._zod.run(W,X);if(Y instanceof Promise)return Y.then((U)=>I3(U,T,X));return I3(Y,T,X)}});function I3($,T,W){if(t1($))return $;return T.out._zod.run({value:$.value,issues:$.issues},W)}var _9=K("$ZodReadonly",($,T)=>{W$.init($,T),N$($._zod,"disc",()=>T.innerType._zod.disc),N$($._zod,"optin",()=>T.innerType._zod.optin),N$($._zod,"optout",()=>T.innerType._zod.optout),$._zod.parse=(W,X)=>{let Y=T.innerType._zod.run(W,X);if(Y instanceof Promise)return Y.then(k3);return k3(Y)}});function k3($){return $.value=Object.freeze($.value),$}var H9=K("$ZodTemplateLiteral",($,T)=>{W$.init($,T);let W=[];for(let X of T.parts)if(X instanceof W$){if(!X._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...X._zod.traits].shift()}`);let Y=X._zod.pattern instanceof RegExp?X._zod.pattern.source:X._zod.pattern;if(!Y)throw new Error(`Invalid template literal part: ${X._zod.traits}`);let U=Y.startsWith("^")?1:0,G=Y.endsWith("$")?Y.length-1:Y.length;W.push(Y.slice(U,G))}else if(X===null||_G.has(typeof X))W.push(C6(`${X}`));else throw new Error(`Invalid template literal part: ${X}`);$._zod.pattern=new RegExp(`^${W.join("")}$`),$._zod.parse=(X,Y)=>{if(typeof X.value!=="string")return X.issues.push({input:X.value,inst:$,expected:"template_literal",code:"invalid_type"}),X;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(X.value))return X.issues.push({input:X.value,inst:$,code:"invalid_format",format:"template_literal",pattern:$._zod.pattern.source}),X;return X}}),F9=K("$ZodPromise",($,T)=>{W$.init($,T),$._zod.parse=(W,X)=>{return Promise.resolve(W.value).then((Y)=>T.innerType._zod.run({value:Y,issues:[]},X))}}),Q9=K("$ZodLazy",($,T)=>{W$.init($,T),N$($._zod,"innerType",()=>T.getter()),N$($._zod,"pattern",()=>$._zod.innerType._zod.pattern),N$($._zod,"disc",()=>$._zod.innerType._zod.disc),N$($._zod,"optin",()=>$._zod.innerType._zod.optin),N$($._zod,"optout",()=>$._zod.innerType._zod.optout),$._zod.parse=(W,X)=>{return $._zod.innerType._zod.run(W,X)}}),Z9=K("$ZodCustom",($,T)=>{u$.init($,T),W$.init($,T),$._zod.parse=(W,X)=>{return W},$._zod.check=(W)=>{let X=W.value,Y=T.fn(X);if(Y instanceof Promise)return Y.then((U)=>q3(U,W,X,$));q3(Y,W,X,$);return}});function q3($,T,W,X){if(!$){let Y={code:"custom",input:W,inst:X,path:[...X._zod.def.path??[]],continue:!X._zod.def.abort};if(X._zod.def.params)Y.params=X._zod.def.params;T.issues.push(ZG(Y))}}var BW={};M1(BW,{zhTW:()=>r9,zhCN:()=>l9,vi:()=>o9,ur:()=>d9,ua:()=>p9,tr:()=>u9,th:()=>c9,ta:()=>m9,sl:()=>g9,ru:()=>h9,pt:()=>y9,pl:()=>f9,ota:()=>b9,no:()=>x9,ms:()=>j9,mk:()=>v9,ko:()=>C9,ja:()=>P9,it:()=>q9,id:()=>k9,hu:()=>I9,he:()=>R9,frCA:()=>B9,fr:()=>S9,fi:()=>L9,fa:()=>N9,es:()=>A9,en:()=>SW,de:()=>M9,cs:()=>E9,ca:()=>K9,be:()=>V9,az:()=>O9,ar:()=>D9});var sA={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 x3($){return sA[$]??null}var eA=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},$N={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"},TN=($)=>{switch($.code){case"invalid_type":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 ${$.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${eA($.input)}`;case"invalid_value":if($.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 ${u($.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($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=x3($.origin);if(W)return` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${$.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${T} ${$.maximum.toString()} ${W.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 ${$.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=x3($.origin);if(W)return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${$.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${T} ${$.minimum.toString()} ${W.unit}`;return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${$.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${$.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`${$N[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${$.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${$.keys.length>1?"\u0629":""}: ${q($.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${$.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 ${$.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}};function D9(){return{localeError:TN}}var WN={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 b3($){return WN[$]??null}var XN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},YN={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"},UN=($)=>{switch($.code){case"invalid_type":return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${$.expected}, daxil olan ${XN($.input)}`;case"invalid_value":if($.values.length===1)return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${u($.values[0])}`;return`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=b3($.origin);if(W)return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${$.origin??"d\u0259y\u0259r"} ${T}${$.maximum.toString()} ${W.unit??"element"}`;return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${$.origin??"d\u0259y\u0259r"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=b3($.origin);if(W)return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${$.origin} ${T}${$.minimum.toString()} ${W.unit}`;return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Yanl\u0131\u015F m\u0259tn: "${T.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`;if(T.format==="ends_with")return`Yanl\u0131\u015F m\u0259tn: "${T.suffix}" il\u0259 bitm\u0259lidir`;if(T.format==="includes")return`Yanl\u0131\u015F m\u0259tn: "${T.includes}" daxil olmal\u0131d\u0131r`;if(T.format==="regex")return`Yanl\u0131\u015F m\u0259tn: ${T.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`;return`Yanl\u0131\u015F ${YN[T.format]??$.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${$.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${$.keys.length>1?"lar":""}: ${q($.keys,", ")}`;case"invalid_key":return`${$.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${$.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}};function O9(){return{localeError:UN}}function f3($,T,W,X){let Y=Math.abs($),U=Y%10,G=Y%100;if(G>=11&&G<=19)return X;if(U===1)return T;if(U>=2&&U<=4)return W;return X}var GN={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 y3($){return GN[$]??null}var JN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u043B\u0456\u043A";case"object":{if(Array.isArray($))return"\u043C\u0430\u0441\u0456\u045E";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},wN={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"},zN=($)=>{switch($.code){case"invalid_type":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${$.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${JN($.input)}`;case"invalid_value":if($.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 ${u($.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($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=y3($.origin);if(W){let X=Number($.maximum),Y=f3(X,W.unit.one,W.unit.few,W.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 ${$.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${W.verb} ${T}${$.maximum.toString()} ${Y}`}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 ${$.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=y3($.origin);if(W){let X=Number($.minimum),Y=f3(X,W.unit.one,W.unit.few,W.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 ${$.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${W.verb} ${T}${$.minimum.toString()} ${Y}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${$.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${wN[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${$.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${q($.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${$.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 ${$.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}};function V9(){return{localeError:zN}}var _N={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function h3($){return _N[$]??null}var HN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},FN={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"},QN=($)=>{switch($.code){case"invalid_type":return`Tipus inv\xE0lid: s'esperava ${$.expected}, s'ha rebut ${HN($.input)}`;case"invalid_value":if($.values.length===1)return`Valor inv\xE0lid: s'esperava ${u($.values[0])}`;return`Opci\xF3 inv\xE0lida: s'esperava una de ${q($.values," o ")}`;case"too_big":{let T=$.inclusive?"com a m\xE0xim":"menys de",W=h3($.origin);if(W)return`Massa gran: s'esperava que ${$.origin??"el valor"} contingu\xE9s ${T} ${$.maximum.toString()} ${W.unit??"elements"}`;return`Massa gran: s'esperava que ${$.origin??"el valor"} fos ${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?"com a m\xEDnim":"m\xE9s de",W=h3($.origin);if(W)return`Massa petit: s'esperava que ${$.origin} contingu\xE9s ${T} ${$.minimum.toString()} ${W.unit}`;return`Massa petit: s'esperava que ${$.origin} fos ${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Format inv\xE0lid: ha de comen\xE7ar amb "${T.prefix}"`;if(T.format==="ends_with")return`Format inv\xE0lid: ha d'acabar amb "${T.suffix}"`;if(T.format==="includes")return`Format inv\xE0lid: ha d'incloure "${T.includes}"`;if(T.format==="regex")return`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${T.pattern}`;return`Format inv\xE0lid per a ${FN[T.format]??$.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${$.divisor}`;case"unrecognized_keys":return`Clau${$.keys.length>1?"s":""} no reconeguda${$.keys.length>1?"s":""}: ${q($.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${$.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${$.origin}`;default:return"Entrada inv\xE0lida"}};function K9(){return{localeError:QN}}var ZN={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 g3($){return ZN[$]??null}var DN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u010D\xEDslo";case"string":return"\u0159et\u011Bzec";case"boolean":return"boolean";case"bigint":return"bigint";case"function":return"funkce";case"symbol":return"symbol";case"undefined":return"undefined";case"object":{if(Array.isArray($))return"pole";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},ON={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"},VN=($)=>{switch($.code){case"invalid_type":return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${$.expected}, obdr\u017Eeno ${DN($.input)}`;case"invalid_value":if($.values.length===1)return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${u($.values[0])}`;return`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=g3($.origin);if(W)return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${$.origin??"hodnota"} mus\xED m\xEDt ${T}${$.maximum.toString()} ${W.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${$.origin??"hodnota"} mus\xED b\xFDt ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=g3($.origin);if(W)return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${$.origin??"hodnota"} mus\xED m\xEDt ${T}${$.minimum.toString()} ${W.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${$.origin??"hodnota"} mus\xED b\xFDt ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${T.prefix}"`;if(T.format==="ends_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${T.suffix}"`;if(T.format==="includes")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${T.includes}"`;if(T.format==="regex")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${T.pattern}`;return`Neplatn\xFD form\xE1t ${ON[T.format]??$.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${$.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${q($.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${$.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${$.origin}`;default:return"Neplatn\xFD vstup"}};function E9(){return{localeError:VN}}var KN={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 m3($){return KN[$]??null}var EN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"Zahl";case"object":{if(Array.isArray($))return"Array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},MN={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"},AN=($)=>{switch($.code){case"invalid_type":return`Ung\xFCltige Eingabe: erwartet ${$.expected}, erhalten ${EN($.input)}`;case"invalid_value":if($.values.length===1)return`Ung\xFCltige Eingabe: erwartet ${u($.values[0])}`;return`Ung\xFCltige Option: erwartet eine von ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=m3($.origin);if(W)return`Zu gro\xDF: erwartet, dass ${$.origin??"Wert"} ${T}${$.maximum.toString()} ${W.unit??"Elemente"} hat`;return`Zu gro\xDF: erwartet, dass ${$.origin??"Wert"} ${T}${$.maximum.toString()} ist`}case"too_small":{let T=$.inclusive?">=":">",W=m3($.origin);if(W)return`Zu klein: erwartet, dass ${$.origin} ${T}${$.minimum.toString()} ${W.unit} hat`;return`Zu klein: erwartet, dass ${$.origin} ${T}${$.minimum.toString()} ist`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ung\xFCltiger String: muss mit "${T.prefix}" beginnen`;if(T.format==="ends_with")return`Ung\xFCltiger String: muss mit "${T.suffix}" enden`;if(T.format==="includes")return`Ung\xFCltiger String: muss "${T.includes}" enthalten`;if(T.format==="regex")return`Ung\xFCltiger String: muss dem Muster ${T.pattern} entsprechen`;return`Ung\xFCltig: ${MN[T.format]??$.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${$.divisor} sein`;case"unrecognized_keys":return`${$.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${q($.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${$.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${$.origin}`;default:return"Ung\xFCltige Eingabe"}};function M9(){return{localeError:AN}}var NN={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function c3($){return NN[$]??null}var LN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},SN={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"},BN=($)=>{switch($.code){case"invalid_type":return`Invalid input: expected ${$.expected}, received ${LN($.input)}`;case"invalid_value":if($.values.length===1)return`Invalid input: expected ${u($.values[0])}`;return`Invalid option: expected one of ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=c3($.origin);if(W)return`Too big: expected ${$.origin??"value"} to have ${T}${$.maximum.toString()} ${W.unit??"elements"}`;return`Too big: expected ${$.origin??"value"} to be ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=c3($.origin);if(W)return`Too small: expected ${$.origin} to have ${T}${$.minimum.toString()} ${W.unit}`;return`Too small: expected ${$.origin} to be ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Invalid string: must start with "${T.prefix}"`;if(T.format==="ends_with")return`Invalid string: must end with "${T.suffix}"`;if(T.format==="includes")return`Invalid string: must include "${T.includes}"`;if(T.format==="regex")return`Invalid string: must match pattern ${T.pattern}`;return`Invalid ${SN[T.format]??$.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${$.divisor}`;case"unrecognized_keys":return`Unrecognized key${$.keys.length>1?"s":""}: ${q($.keys,", ")}`;case"invalid_key":return`Invalid key in ${$.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${$.origin}`;default:return"Invalid input"}};function SW(){return{localeError:BN}}var RN={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function u3($){return RN[$]??null}var IN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"n\xFAmero";case"object":{if(Array.isArray($))return"arreglo";if($===null)return"nulo";if(Object.getPrototypeOf($)!==Object.prototype)return $.constructor.name}}return T},kN={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"},qN=($)=>{switch($.code){case"invalid_type":return`Entrada inv\xE1lida: se esperaba ${$.expected}, recibido ${IN($.input)}`;case"invalid_value":if($.values.length===1)return`Entrada inv\xE1lida: se esperaba ${u($.values[0])}`;return`Opci\xF3n inv\xE1lida: se esperaba una de ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=u3($.origin);if(W)return`Demasiado grande: se esperaba que ${$.origin??"valor"} tuviera ${T}${$.maximum.toString()} ${W.unit??"elementos"}`;return`Demasiado grande: se esperaba que ${$.origin??"valor"} fuera ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=u3($.origin);if(W)return`Demasiado peque\xF1o: se esperaba que ${$.origin} tuviera ${T}${$.minimum.toString()} ${W.unit}`;return`Demasiado peque\xF1o: se esperaba que ${$.origin} fuera ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Cadena inv\xE1lida: debe comenzar con "${T.prefix}"`;if(T.format==="ends_with")return`Cadena inv\xE1lida: debe terminar en "${T.suffix}"`;if(T.format==="includes")return`Cadena inv\xE1lida: debe incluir "${T.includes}"`;if(T.format==="regex")return`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${T.pattern}`;return`Inv\xE1lido ${kN[T.format]??$.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${$.divisor}`;case"unrecognized_keys":return`Llave${$.keys.length>1?"s":""} desconocida${$.keys.length>1?"s":""}: ${q($.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${$.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${$.origin}`;default:return"Entrada inv\xE1lida"}};function A9(){return{localeError:qN}}var PN={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 p3($){return PN[$]??null}var CN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0639\u062F\u062F";case"object":{if(Array.isArray($))return"\u0622\u0631\u0627\u06CC\u0647";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},vN={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"},jN=($)=>{switch($.code){case"invalid_type":return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${$.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${CN($.input)} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`;case"invalid_value":if($.values.length===1)return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${u($.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($.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let T=$.inclusive?"<=":"<",W=p3($.origin);if(W)return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${$.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${T}${$.maximum.toString()} ${W.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${$.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${T}${$.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let T=$.inclusive?">=":">",W=p3($.origin);if(W)return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${$.origin} \u0628\u0627\u06CC\u062F ${T}${$.minimum.toString()} ${W.unit} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${$.origin} \u0628\u0627\u06CC\u062F ${T}${$.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${T.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`;if(T.format==="ends_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${T.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`;if(T.format==="includes")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${T.includes}" \u0628\u0627\u0634\u062F`;if(T.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 ${T.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`;return`${vN[T.format]??$.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 ${$.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${$.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${q($.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${$.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 ${$.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}};function N9(){return{localeError:jN}}var xN={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 d3($){return xN[$]??null}var bN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},fN={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"},yN=($)=>{switch($.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${$.expected}, oli ${bN($.input)}`;case"invalid_value":if($.values.length===1)return`Virheellinen sy\xF6te: t\xE4ytyy olla ${u($.values[0])}`;return`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=d3($.origin);if(W)return`Liian suuri: ${W.subject} t\xE4ytyy olla ${T}${$.maximum.toString()} ${W.unit}`.trim();return`Liian suuri: arvon t\xE4ytyy olla ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=d3($.origin);if(W)return`Liian pieni: ${W.subject} t\xE4ytyy olla ${T}${$.minimum.toString()} ${W.unit}`.trim();return`Liian pieni: arvon t\xE4ytyy olla ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${T.prefix}"`;if(T.format==="ends_with")return`Virheellinen sy\xF6te: t\xE4ytyy loppua "${T.suffix}"`;if(T.format==="includes")return`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${T.includes}"`;if(T.format==="regex")return`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${T.pattern}`;return`Virheellinen ${fN[T.format]??$.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${$.divisor} monikerta`;case"unrecognized_keys":return`${$.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${q($.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"}};function L9(){return{localeError:yN}}var hN={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function o3($){return hN[$]??null}var gN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"nombre";case"object":{if(Array.isArray($))return"tableau";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},mN={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"},cN=($)=>{switch($.code){case"invalid_type":return`Entr\xE9e invalide : ${$.expected} attendu, ${gN($.input)} re\xE7u`;case"invalid_value":if($.values.length===1)return`Entr\xE9e invalide : ${u($.values[0])} attendu`;return`Option invalide : une valeur parmi ${q($.values,"|")} attendue`;case"too_big":{let T=$.inclusive?"<=":"<",W=o3($.origin);if(W)return`Trop grand : ${$.origin??"valeur"} doit ${W.verb} ${T}${$.maximum.toString()} ${W.unit??"\xE9l\xE9ment(s)"}`;return`Trop grand : ${$.origin??"valeur"} doit \xEAtre ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=o3($.origin);if(W)return`Trop petit : ${$.origin} doit ${W.verb} ${T}${$.minimum.toString()} ${W.unit}`;return`Trop petit : ${$.origin} doit \xEAtre ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${T.prefix}"`;if(T.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${T.suffix}"`;if(T.format==="includes")return`Cha\xEEne invalide : doit inclure "${T.includes}"`;if(T.format==="regex")return`Cha\xEEne invalide : doit correspondre au mod\xE8le ${T.pattern}`;return`${mN[T.format]??$.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${$.divisor}`;case"unrecognized_keys":return`Cl\xE9${$.keys.length>1?"s":""} non reconnue${$.keys.length>1?"s":""} : ${q($.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${$.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${$.origin}`;default:return"Entr\xE9e invalide"}};function S9(){return{localeError:cN}}var uN={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function l3($){return uN[$]??null}var pN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},dN={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"},oN=($)=>{switch($.code){case"invalid_type":return`Entr\xE9e invalide : attendu ${$.expected}, re\xE7u ${pN($.input)}`;case"invalid_value":if($.values.length===1)return`Entr\xE9e invalide : attendu ${u($.values[0])}`;return`Option invalide : attendu l'une des valeurs suivantes ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"\u2264":"<",W=l3($.origin);if(W)return`Trop grand : attendu que ${$.origin??"la valeur"} ait ${T}${$.maximum.toString()} ${W.unit}`;return`Trop grand : attendu que ${$.origin??"la valeur"} soit ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?"\u2265":">",W=l3($.origin);if(W)return`Trop petit : attendu que ${$.origin} ait ${T}${$.minimum.toString()} ${W.unit}`;return`Trop petit : attendu que ${$.origin} soit ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${T.prefix}"`;if(T.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${T.suffix}"`;if(T.format==="includes")return`Cha\xEEne invalide : doit inclure "${T.includes}"`;if(T.format==="regex")return`Cha\xEEne invalide : doit correspondre au motif ${T.pattern}`;return`${dN[T.format]??$.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${$.divisor}`;case"unrecognized_keys":return`Cl\xE9${$.keys.length>1?"s":""} non reconnue${$.keys.length>1?"s":""} : ${q($.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${$.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${$.origin}`;default:return"Entr\xE9e invalide"}};function B9(){return{localeError:oN}}var lN={string:{unit:"\u05D0\u05D5\u05EA\u05D9\u05D5\u05EA",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"}};function r3($){return lN[$]??null}var rN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},iN={regex:"\u05E7\u05DC\u05D8",email:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",url:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",emoji:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",date:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",time:"\u05D6\u05DE\u05DF ISO",duration:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",ipv4:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",ipv6:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",cidrv4:"\u05D8\u05D5\u05D5\u05D7 IPv4",cidrv6:"\u05D8\u05D5\u05D5\u05D7 IPv6",base64:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",base64url:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",json_string:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",e164:"\u05DE\u05E1\u05E4\u05E8 E.164",jwt:"JWT",template_literal:"\u05E7\u05DC\u05D8"},nN=($)=>{switch($.code){case"invalid_type":return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${$.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${rN($.input)}`;case"invalid_value":if($.values.length===1)return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${u($.values[0])}`;return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05D0\u05D7\u05EA \u05DE\u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=r3($.origin);if(W)return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${$.origin??"value"} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.maximum.toString()} ${W.unit??"elements"}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${$.origin??"value"} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=r3($.origin);if(W)return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${$.origin} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.minimum.toString()} ${W.unit}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${$.origin} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1"${T.prefix}"`;if(T.format==="ends_with")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${T.suffix}"`;if(T.format==="includes")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${T.includes}"`;if(T.format==="regex")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${T.pattern}`;return`${iN[T.format]??$.format} \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF`}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 ${$.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${$.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${$.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${q($.keys,", ")}`;case"invalid_key":return`\u05DE\u05E4\u05EA\u05D7 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${$.origin}`;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${$.origin}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}};function R9(){return{localeError:nN}}var tN={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function i3($){return tN[$]??null}var aN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"sz\xE1m";case"object":{if(Array.isArray($))return"t\xF6mb";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},sN={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"},eN=($)=>{switch($.code){case"invalid_type":return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${$.expected}, a kapott \xE9rt\xE9k ${aN($.input)}`;case"invalid_value":if($.values.length===1)return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${u($.values[0])}`;return`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=i3($.origin);if(W)return`T\xFAl nagy: ${$.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${T}${$.maximum.toString()} ${W.unit??"elem"}`;return`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${$.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=i3($.origin);if(W)return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${$.origin} m\xE9rete t\xFAl kicsi ${T}${$.minimum.toString()} ${W.unit}`;return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${$.origin} t\xFAl kicsi ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\xC9rv\xE9nytelen string: "${T.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`;if(T.format==="ends_with")return`\xC9rv\xE9nytelen string: "${T.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`;if(T.format==="includes")return`\xC9rv\xE9nytelen string: "${T.includes}" \xE9rt\xE9ket kell tartalmaznia`;if(T.format==="regex")return`\xC9rv\xE9nytelen string: ${T.pattern} mint\xE1nak kell megfelelnie`;return`\xC9rv\xE9nytelen ${sN[T.format]??$.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${$.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${$.keys.length>1?"s":""}: ${q($.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${$.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${$.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}};function I9(){return{localeError:eN}}var $L={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function n3($){return $L[$]??null}var TL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},WL={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"},XL=($)=>{switch($.code){case"invalid_type":return`Input tidak valid: diharapkan ${$.expected}, diterima ${TL($.input)}`;case"invalid_value":if($.values.length===1)return`Input tidak valid: diharapkan ${u($.values[0])}`;return`Pilihan tidak valid: diharapkan salah satu dari ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=n3($.origin);if(W)return`Terlalu besar: diharapkan ${$.origin??"value"} memiliki ${T}${$.maximum.toString()} ${W.unit??"elemen"}`;return`Terlalu besar: diharapkan ${$.origin??"value"} menjadi ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=n3($.origin);if(W)return`Terlalu kecil: diharapkan ${$.origin} memiliki ${T}${$.minimum.toString()} ${W.unit}`;return`Terlalu kecil: diharapkan ${$.origin} menjadi ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`String tidak valid: harus dimulai dengan "${T.prefix}"`;if(T.format==="ends_with")return`String tidak valid: harus berakhir dengan "${T.suffix}"`;if(T.format==="includes")return`String tidak valid: harus menyertakan "${T.includes}"`;if(T.format==="regex")return`String tidak valid: harus sesuai pola ${T.pattern}`;return`${WL[T.format]??$.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${$.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${$.keys.length>1?"s":""}: ${q($.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${$.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${$.origin}`;default:return"Input tidak valid"}};function k9(){return{localeError:XL}}var YL={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t3($){return YL[$]??null}var UL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"numero";case"object":{if(Array.isArray($))return"vettore";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},GL={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"},JL=($)=>{switch($.code){case"invalid_type":return`Input non valido: atteso ${$.expected}, ricevuto ${UL($.input)}`;case"invalid_value":if($.values.length===1)return`Input non valido: atteso ${u($.values[0])}`;return`Opzione non valida: atteso uno tra ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=t3($.origin);if(W)return`Troppo grande: ${$.origin??"valore"} deve avere ${T}${$.maximum.toString()} ${W.unit??"elementi"}`;return`Troppo grande: ${$.origin??"valore"} deve essere ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=t3($.origin);if(W)return`Troppo piccolo: ${$.origin} deve avere ${T}${$.minimum.toString()} ${W.unit}`;return`Troppo piccolo: ${$.origin} deve essere ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Stringa non valida: deve iniziare con "${T.prefix}"`;if(T.format==="ends_with")return`Stringa non valida: deve terminare con "${T.suffix}"`;if(T.format==="includes")return`Stringa non valida: deve includere "${T.includes}"`;if(T.format==="regex")return`Stringa non valida: deve corrispondere al pattern ${T.pattern}`;return`Invalid ${GL[T.format]??$.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${$.divisor}`;case"unrecognized_keys":return`Chiav${$.keys.length>1?"i":"e"} non riconosciut${$.keys.length>1?"e":"a"}: ${q($.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${$.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${$.origin}`;default:return"Input non valido"}};function q9(){return{localeError:JL}}var wL={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 a3($){return wL[$]??null}var zL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u6570\u5024";case"object":{if(Array.isArray($))return"\u914D\u5217";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},_L={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"},HL=($)=>{switch($.code){case"invalid_type":return`\u7121\u52B9\u306A\u5165\u529B: ${$.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${zL($.input)}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`;case"invalid_value":if($.values.length===1)return`\u7121\u52B9\u306A\u5165\u529B: ${u($.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`;return`\u7121\u52B9\u306A\u9078\u629E: ${q($.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let T=$.inclusive?"<=":"<",W=a3($.origin);if(W)return`\u5927\u304D\u3059\u304E\u308B\u5024: ${$.origin??"\u5024"}\u306F${$.maximum.toString()}${W.unit??"\u8981\u7D20"}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5927\u304D\u3059\u304E\u308B\u5024: ${$.origin??"\u5024"}\u306F${$.maximum.toString()}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let T=$.inclusive?">=":">",W=a3($.origin);if(W)return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${$.origin}\u306F${$.minimum.toString()}${W.unit}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${$.origin}\u306F${$.minimum.toString()}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${T.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(T.format==="ends_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${T.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(T.format==="includes")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${T.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(T.format==="regex")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${T.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u7121\u52B9\u306A${_L[T.format]??$.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${$.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${$.keys.length>1?"\u7FA4":""}: ${q($.keys,"\u3001")}`;case"invalid_key":return`${$.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${$.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}};function P9(){return{localeError:HL}}var FL={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 s3($){return FL[$]??null}var QL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},ZL={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"},DL=($)=>{switch($.code){case"invalid_type":return`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${$.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${QL($.input)}\uC785\uB2C8\uB2E4`;case"invalid_value":if($.values.length===1)return`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${u($.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C \uC635\uC158: ${q($.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let T=$.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",W=T==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",X=s3($.origin),Y=X?.unit??"\uC694\uC18C";if(X)return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${$.maximum.toString()}${Y} ${T}${W}`;return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${$.maximum.toString()} ${T}${W}`}case"too_small":{let T=$.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",W=T==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",X=s3($.origin),Y=X?.unit??"\uC694\uC18C";if(X)return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${$.minimum.toString()}${Y} ${T}${W}`;return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${$.minimum.toString()} ${T}${W}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${T.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`;if(T.format==="ends_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${T.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`;if(T.format==="includes")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${T.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`;if(T.format==="regex")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${T.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C ${ZL[T.format]??$.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${$.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${q($.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${$.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${$.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}};function C9(){return{localeError:DL}}var OL={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 e3($){return OL[$]??null}var VL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0431\u0440\u043E\u0458";case"object":{if(Array.isArray($))return"\u043D\u0438\u0437\u0430";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},KL={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"},EL=($)=>{switch($.code){case"invalid_type":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${VL($.input)}`;case"invalid_value":if($.values.length===1)return`Invalid input: expected ${u($.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($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=e3($.origin);if(W)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${T}${$.maximum.toString()} ${W.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 ${$.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=e3($.origin);if(W)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.origin} \u0434\u0430 \u0438\u043C\u0430 ${T}${$.minimum.toString()} ${W.unit}`;return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`Invalid ${KL[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`${$.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($.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${$.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 ${$.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}};function v9(){return{localeError:EL}}var ML={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function $H($){return ML[$]??null}var AL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"nombor";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},NL={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"},LL=($)=>{switch($.code){case"invalid_type":return`Input tidak sah: dijangka ${$.expected}, diterima ${AL($.input)}`;case"invalid_value":if($.values.length===1)return`Input tidak sah: dijangka ${u($.values[0])}`;return`Pilihan tidak sah: dijangka salah satu daripada ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=$H($.origin);if(W)return`Terlalu besar: dijangka ${$.origin??"nilai"} ${W.verb} ${T}${$.maximum.toString()} ${W.unit??"elemen"}`;return`Terlalu besar: dijangka ${$.origin??"nilai"} adalah ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=$H($.origin);if(W)return`Terlalu kecil: dijangka ${$.origin} ${W.verb} ${T}${$.minimum.toString()} ${W.unit}`;return`Terlalu kecil: dijangka ${$.origin} adalah ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`String tidak sah: mesti bermula dengan "${T.prefix}"`;if(T.format==="ends_with")return`String tidak sah: mesti berakhir dengan "${T.suffix}"`;if(T.format==="includes")return`String tidak sah: mesti mengandungi "${T.includes}"`;if(T.format==="regex")return`String tidak sah: mesti sepadan dengan corak ${T.pattern}`;return`${NL[T.format]??$.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${$.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${q($.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${$.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${$.origin}`;default:return"Input tidak sah"}};function j9(){return{localeError:LL}}var SL={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 TH($){return SL[$]??null}var BL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"tall";case"object":{if(Array.isArray($))return"liste";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},RL={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"},IL=($)=>{switch($.code){case"invalid_type":return`Ugyldig input: forventet ${$.expected}, fikk ${BL($.input)}`;case"invalid_value":if($.values.length===1)return`Ugyldig verdi: forventet ${u($.values[0])}`;return`Ugyldig valg: forventet en av ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=TH($.origin);if(W)return`For stor(t): forventet ${$.origin??"value"} til \xE5 ha ${T}${$.maximum.toString()} ${W.unit??"elementer"}`;return`For stor(t): forventet ${$.origin??"value"} til \xE5 ha ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=TH($.origin);if(W)return`For lite(n): forventet ${$.origin} til \xE5 ha ${T}${$.minimum.toString()} ${W.unit}`;return`For lite(n): forventet ${$.origin} til \xE5 ha ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ugyldig streng: m\xE5 starte med "${T.prefix}"`;if(T.format==="ends_with")return`Ugyldig streng: m\xE5 ende med "${T.suffix}"`;if(T.format==="includes")return`Ugyldig streng: m\xE5 inneholde "${T.includes}"`;if(T.format==="regex")return`Ugyldig streng: m\xE5 matche m\xF8nsteret ${T.pattern}`;return`Ugyldig ${RL[T.format]??$.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${$.divisor}`;case"unrecognized_keys":return`${$.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${q($.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${$.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${$.origin}`;default:return"Ugyldig input"}};function x9(){return{localeError:IL}}var kL={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 WH($){return kL[$]??null}var qL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"numara";case"object":{if(Array.isArray($))return"saf";if($===null)return"gayb";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},PL={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"},CL=($)=>{switch($.code){case"invalid_type":return`F\xE2sit giren: umulan ${$.expected}, al\u0131nan ${qL($.input)}`;case"invalid_value":if($.values.length===1)return`F\xE2sit giren: umulan ${u($.values[0])}`;return`F\xE2sit tercih: m\xFBteberler ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=WH($.origin);if(W)return`Fazla b\xFCy\xFCk: ${$.origin??"value"}, ${T}${$.maximum.toString()} ${W.unit??"elements"} sahip olmal\u0131yd\u0131.`;return`Fazla b\xFCy\xFCk: ${$.origin??"value"}, ${T}${$.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let T=$.inclusive?">=":">",W=WH($.origin);if(W)return`Fazla k\xFC\xE7\xFCk: ${$.origin}, ${T}${$.minimum.toString()} ${W.unit} sahip olmal\u0131yd\u0131.`;return`Fazla k\xFC\xE7\xFCk: ${$.origin}, ${T}${$.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`F\xE2sit metin: "${T.prefix}" ile ba\u015Flamal\u0131.`;if(T.format==="ends_with")return`F\xE2sit metin: "${T.suffix}" ile bitmeli.`;if(T.format==="includes")return`F\xE2sit metin: "${T.includes}" ihtiv\xE2 etmeli.`;if(T.format==="regex")return`F\xE2sit metin: ${T.pattern} nak\u015F\u0131na uymal\u0131.`;return`F\xE2sit ${PL[T.format]??$.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${$.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${$.keys.length>1?"s":""}: ${q($.keys,", ")}`;case"invalid_key":return`${$.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${$.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}};function b9(){return{localeError:CL}}var vL={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 XH($){return vL[$]??null}var jL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"liczba";case"object":{if(Array.isArray($))return"tablica";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},xL={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"},bL=($)=>{switch($.code){case"invalid_type":return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${$.expected}, otrzymano ${jL($.input)}`;case"invalid_value":if($.values.length===1)return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${u($.values[0])}`;return`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=XH($.origin);if(W)return`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${T}${$.maximum.toString()} ${W.unit??"element\xF3w"}`;return`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=XH($.origin);if(W)return`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${T}${$.minimum.toString()} ${W.unit??"element\xF3w"}`;return`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${T.prefix}"`;if(T.format==="ends_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${T.suffix}"`;if(T.format==="includes")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${T.includes}"`;if(T.format==="regex")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${T.pattern}`;return`Nieprawid\u0142ow(y/a/e) ${xL[T.format]??$.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${$.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${$.keys.length>1?"s":""}: ${q($.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${$.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${$.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}};function f9(){return{localeError:bL}}var fL={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function YH($){return fL[$]??null}var yL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"n\xFAmero";case"object":{if(Array.isArray($))return"array";if($===null)return"nulo";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},hL={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"},gL=($)=>{switch($.code){case"invalid_type":return`Tipo inv\xE1lido: esperado ${$.expected}, recebido ${yL($.input)}`;case"invalid_value":if($.values.length===1)return`Entrada inv\xE1lida: esperado ${u($.values[0])}`;return`Op\xE7\xE3o inv\xE1lida: esperada uma das ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=YH($.origin);if(W)return`Muito grande: esperado que ${$.origin??"valor"} tivesse ${T}${$.maximum.toString()} ${W.unit??"elementos"}`;return`Muito grande: esperado que ${$.origin??"valor"} fosse ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=YH($.origin);if(W)return`Muito pequeno: esperado que ${$.origin} tivesse ${T}${$.minimum.toString()} ${W.unit}`;return`Muito pequeno: esperado que ${$.origin} fosse ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Texto inv\xE1lido: deve come\xE7ar com "${T.prefix}"`;if(T.format==="ends_with")return`Texto inv\xE1lido: deve terminar com "${T.suffix}"`;if(T.format==="includes")return`Texto inv\xE1lido: deve incluir "${T.includes}"`;if(T.format==="regex")return`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${T.pattern}`;return`${hL[T.format]??$.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${$.divisor}`;case"unrecognized_keys":return`Chave${$.keys.length>1?"s":""} desconhecida${$.keys.length>1?"s":""}: ${q($.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${$.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${$.origin}`;default:return"Campo inv\xE1lido"}};function y9(){return{localeError:gL}}function UH($,T,W,X){let Y=Math.abs($),U=Y%10,G=Y%100;if(G>=11&&G<=19)return X;if(U===1)return T;if(U>=2&&U<=4)return W;return X}var mL={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 GH($){return mL[$]??null}var cL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0447\u0438\u0441\u043B\u043E";case"object":{if(Array.isArray($))return"\u043C\u0430\u0441\u0441\u0438\u0432";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},uL={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"},pL=($)=>{switch($.code){case"invalid_type":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${$.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${cL($.input)}`;case"invalid_value":if($.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 ${u($.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($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=GH($.origin);if(W){let X=Number($.maximum),Y=UH(X,W.unit.one,W.unit.few,W.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 ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${T}${$.maximum.toString()} ${Y}`}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 ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=GH($.origin);if(W){let X=Number($.minimum),Y=UH(X,W.unit.one,W.unit.few,W.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 ${$.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${T}${$.minimum.toString()} ${Y}`}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 ${$.origin} \u0431\u0443\u0434\u0435\u0442 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${uL[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${$.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${$.keys.length>1?"\u0438":""}: ${q($.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${$.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 ${$.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}};function h9(){return{localeError:pL}}var dL={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function JH($){return dL[$]??null}var oL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0161tevilo";case"object":{if(Array.isArray($))return"tabela";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},lL={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"},rL=($)=>{switch($.code){case"invalid_type":return`Neveljaven vnos: pri\u010Dakovano ${$.expected}, prejeto ${oL($.input)}`;case"invalid_value":if($.values.length===1)return`Neveljaven vnos: pri\u010Dakovano ${u($.values[0])}`;return`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=JH($.origin);if(W)return`Preveliko: pri\u010Dakovano, da bo ${$.origin??"vrednost"} imelo ${T}${$.maximum.toString()} ${W.unit??"elementov"}`;return`Preveliko: pri\u010Dakovano, da bo ${$.origin??"vrednost"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=JH($.origin);if(W)return`Premajhno: pri\u010Dakovano, da bo ${$.origin} imelo ${T}${$.minimum.toString()} ${W.unit}`;return`Premajhno: pri\u010Dakovano, da bo ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Neveljaven niz: mora se za\u010Deti z "${T.prefix}"`;if(T.format==="ends_with")return`Neveljaven niz: mora se kon\u010Dati z "${T.suffix}"`;if(T.format==="includes")return`Neveljaven niz: mora vsebovati "${T.includes}"`;if(T.format==="regex")return`Neveljaven niz: mora ustrezati vzorcu ${T.pattern}`;return`Neveljaven ${lL[T.format]??$.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${$.divisor}`;case"unrecognized_keys":return`Neprepoznan${$.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${q($.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${$.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${$.origin}`;default:return"Neveljaven vnos"}};function g9(){return{localeError:rL}}var iL={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 wH($){return iL[$]??null}var nL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u0B8E\u0BA3\u0BCD \u0B85\u0BB2\u0BCD\u0BB2\u0BBE\u0BA4\u0BA4\u0BC1":"\u0B8E\u0BA3\u0BCD";case"object":{if(Array.isArray($))return"\u0B85\u0BA3\u0BBF";if($===null)return"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},tL={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"},aL=($)=>{switch($.code){case"invalid_type":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 ${$.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${nL($.input)}`;case"invalid_value":if($.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 ${u($.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($.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let T=$.inclusive?"<=":"<",W=wH($.origin);if(W)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 ${$.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${T}${$.maximum.toString()} ${W.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 ${$.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${T}${$.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let T=$.inclusive?">=":">",W=wH($.origin);if(W)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 ${$.origin} ${T}${$.minimum.toString()} ${W.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 ${$.origin} ${T}${$.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${T.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(T.format==="ends_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${T.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(T.format==="includes")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${T.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(T.format==="regex")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${T.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 ${tL[T.format]??$.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${$.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${$.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${q($.keys,", ")}`;case"invalid_key":return`${$.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`${$.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"}};function m9(){return{localeError:aL}}var sL={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 zH($){return sL[$]??null}var eL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u0E44\u0E21\u0E48\u0E43\u0E0A\u0E48\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02 (NaN)":"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02";case"object":{if(Array.isArray($))return"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)";if($===null)return"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},$S={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"},TS=($)=>{switch($.code){case"invalid_type":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 ${$.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${eL($.input)}`;case"invalid_value":if($.values.length===1)return`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${u($.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($.values,"|")}`;case"too_big":{let T=$.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",W=zH($.origin);if(W)return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.maximum.toString()} ${W.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`;return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",W=zH($.origin);if(W)return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.minimum.toString()} ${W.unit}`;return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`;if(T.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 ${T.pattern}`;return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${$S[T.format]??$.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 ${$.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($.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${$.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 ${$.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}};function c9(){return{localeError:TS}}var WS={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 _H($){return WS[$]??null}var XS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},YS={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"},US=($)=>{switch($.code){case"invalid_type":return`Ge\xE7ersiz de\u011Fer: beklenen ${$.expected}, al\u0131nan ${XS($.input)}`;case"invalid_value":if($.values.length===1)return`Ge\xE7ersiz de\u011Fer: beklenen ${u($.values[0])}`;return`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=_H($.origin);if(W)return`\xC7ok b\xFCy\xFCk: beklenen ${$.origin??"de\u011Fer"} ${T}${$.maximum.toString()} ${W.unit??"\xF6\u011Fe"}`;return`\xC7ok b\xFCy\xFCk: beklenen ${$.origin??"de\u011Fer"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=_H($.origin);if(W)return`\xC7ok k\xFC\xE7\xFCk: beklenen ${$.origin} ${T}${$.minimum.toString()} ${W.unit}`;return`\xC7ok k\xFC\xE7\xFCk: beklenen ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ge\xE7ersiz metin: "${T.prefix}" ile ba\u015Flamal\u0131`;if(T.format==="ends_with")return`Ge\xE7ersiz metin: "${T.suffix}" ile bitmeli`;if(T.format==="includes")return`Ge\xE7ersiz metin: "${T.includes}" i\xE7ermeli`;if(T.format==="regex")return`Ge\xE7ersiz metin: ${T.pattern} desenine uymal\u0131`;return`Ge\xE7ersiz ${YS[T.format]??$.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${$.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${$.keys.length>1?"lar":""}: ${q($.keys,", ")}`;case"invalid_key":return`${$.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${$.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}};function u9(){return{localeError:US}}var GS={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 HH($){return GS[$]??null}var JS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0447\u0438\u0441\u043B\u043E";case"object":{if(Array.isArray($))return"\u043C\u0430\u0441\u0438\u0432";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},wS={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"},zS=($)=>{switch($.code){case"invalid_type":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 ${$.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${JS($.input)}`;case"invalid_value":if($.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 ${u($.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($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=HH($.origin);if(W)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 ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${W.verb} ${T}${$.maximum.toString()} ${W.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 ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=HH($.origin);if(W)return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${$.origin} ${W.verb} ${T}${$.minimum.toString()} ${W.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 ${$.origin} \u0431\u0443\u0434\u0435 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${wS[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${$.keys.length>1?"\u0456":""}: ${q($.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${$.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 ${$.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}};function p9(){return{localeError:zS}}var _S={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 FH($){return _S[$]??null}var HS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0646\u0645\u0628\u0631";case"object":{if(Array.isArray($))return"\u0622\u0631\u06D2";if($===null)return"\u0646\u0644";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},FS={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"},QS=($)=>{switch($.code){case"invalid_type":return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${$.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${HS($.input)} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`;case"invalid_value":if($.values.length===1)return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${u($.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;return`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${q($.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let T=$.inclusive?"<=":"<",W=FH($.origin);if(W)return`\u0628\u06C1\u062A \u0628\u0691\u0627: ${$.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${T}${$.maximum.toString()} ${W.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: ${$.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${T}${$.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let T=$.inclusive?">=":">",W=FH($.origin);if(W)return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${$.origin} \u06A9\u06D2 ${T}${$.minimum.toString()} ${W.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`;return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${$.origin} \u06A9\u0627 ${T}${$.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${T.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(T.format==="ends_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${T.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(T.format==="includes")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${T.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(T.format==="regex")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${T.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;return`\u063A\u0644\u0637 ${FS[T.format]??$.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${$.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${$.keys.length>1?"\u0632":""}: ${q($.keys,"\u060C ")}`;case"invalid_key":return`${$.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${$.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}};function d9(){return{localeError:QS}}var ZS={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 QH($){return ZS[$]??null}var DS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"s\u1ED1";case"object":{if(Array.isArray($))return"m\u1EA3ng";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},OS={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"},VS=($)=>{switch($.code){case"invalid_type":return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${$.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${DS($.input)}`;case"invalid_value":if($.values.length===1)return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${u($.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($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=QH($.origin);if(W)return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${$.origin??"gi\xE1 tr\u1ECB"} ${W.verb} ${T}${$.maximum.toString()} ${W.unit??"ph\u1EA7n t\u1EED"}`;return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${$.origin??"gi\xE1 tr\u1ECB"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=QH($.origin);if(W)return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${$.origin} ${W.verb} ${T}${$.minimum.toString()} ${W.unit}`;return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${T.prefix}"`;if(T.format==="ends_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${T.suffix}"`;if(T.format==="includes")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${T.includes}"`;if(T.format==="regex")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${T.pattern}`;return`${OS[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${q($.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${$.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 ${$.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}};function o9(){return{localeError:VS}}var KS={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 ZH($){return KS[$]??null}var ES=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u975E\u6570\u5B57(NaN)":"\u6570\u5B57";case"object":{if(Array.isArray($))return"\u6570\u7EC4";if($===null)return"\u7A7A\u503C(null)";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},MS={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"},AS=($)=>{switch($.code){case"invalid_type":return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${$.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${ES($.input)}`;case"invalid_value":if($.values.length===1)return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${u($.values[0])}`;return`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=ZH($.origin);if(W)return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${$.origin??"\u503C"} ${T}${$.maximum.toString()} ${W.unit??"\u4E2A\u5143\u7D20"}`;return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${$.origin??"\u503C"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=ZH($.origin);if(W)return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${$.origin} ${T}${$.minimum.toString()} ${W.unit}`;return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${T.prefix}" \u5F00\u5934`;if(T.format==="ends_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${T.suffix}" \u7ED3\u5C3E`;if(T.format==="includes")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${T.includes}"`;if(T.format==="regex")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${T.pattern}`;return`\u65E0\u6548${MS[T.format]??$.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${$.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${q($.keys,", ")}`;case"invalid_key":return`${$.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${$.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}};function l9(){return{localeError:AS}}var NS={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 DH($){return NS[$]??null}var LS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},SS={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"},BS=($)=>{switch($.code){case"invalid_type":return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${$.expected}\uFF0C\u4F46\u6536\u5230 ${LS($.input)}`;case"invalid_value":if($.values.length===1)return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${u($.values[0])}`;return`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=DH($.origin);if(W)return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${$.origin??"\u503C"} \u61C9\u70BA ${T}${$.maximum.toString()} ${W.unit??"\u500B\u5143\u7D20"}`;return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${$.origin??"\u503C"} \u61C9\u70BA ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=DH($.origin);if(W)return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${$.origin} \u61C9\u70BA ${T}${$.minimum.toString()} ${W.unit}`;return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${$.origin} \u61C9\u70BA ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${T.prefix}" \u958B\u982D`;if(T.format==="ends_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${T.suffix}" \u7D50\u5C3E`;if(T.format==="includes")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${T.includes}"`;if(T.format==="regex")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${T.pattern}`;return`\u7121\u6548\u7684 ${SS[T.format]??$.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${$.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${$.keys.length>1?"\u5011":""}\uFF1A${q($.keys,"\u3001")}`;case"invalid_key":return`${$.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${$.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}};function r9(){return{localeError:BS}}var i9=Symbol("ZodOutput"),n9=Symbol("ZodInput");class RW{constructor(){this._map=new WeakMap,this._idmap=new Map}add($,...T){let W=T[0];if(this._map.set($,W),W&&typeof W==="object"&&"id"in W){if(this._idmap.has(W.id))throw new Error(`ID ${W.id} already exists in the registry`);this._idmap.set(W.id,$)}return this}remove($){return this._map.delete($),this}get($){let T=$._zod.parent;if(T){let W={...this.get(T)??{}};return delete W.id,{...W,...this._map.get($)}}return this._map.get($)}has($){return this._map.has($)}}function GY(){return new RW}var v6=GY();function t9($,T){return new $({type:"string",...j(T)})}function a9($,T){return new $({type:"string",coerce:!0,...j(T)})}function JY($,T){return new $({type:"string",format:"email",check:"string_format",abort:!1,...j(T)})}function IW($,T){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...j(T)})}function wY($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...j(T)})}function zY($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...j(T)})}function _Y($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...j(T)})}function HY($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...j(T)})}function FY($,T){return new $({type:"string",format:"url",check:"string_format",abort:!1,...j(T)})}function QY($,T){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...j(T)})}function ZY($,T){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...j(T)})}function DY($,T){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...j(T)})}function OY($,T){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...j(T)})}function VY($,T){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...j(T)})}function KY($,T){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...j(T)})}function EY($,T){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...j(T)})}function MY($,T){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...j(T)})}function AY($,T){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...j(T)})}function NY($,T){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...j(T)})}function LY($,T){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...j(T)})}function SY($,T){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...j(T)})}function BY($,T){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...j(T)})}function RY($,T){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...j(T)})}function IY($,T){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...j(T)})}function s9($,T){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...j(T)})}function e9($,T){return new $({type:"string",format:"date",check:"string_format",...j(T)})}function $w($,T){return new $({type:"string",format:"time",check:"string_format",precision:null,...j(T)})}function Tw($,T){return new $({type:"string",format:"duration",check:"string_format",...j(T)})}function Ww($,T){return new $({type:"number",checks:[],...j(T)})}function Xw($,T){return new $({type:"number",coerce:!0,checks:[],...j(T)})}function Yw($,T){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...j(T)})}function Uw($,T){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...j(T)})}function Gw($,T){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...j(T)})}function Jw($,T){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...j(T)})}function ww($,T){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...j(T)})}function zw($,T){return new $({type:"boolean",...j(T)})}function _w($,T){return new $({type:"boolean",coerce:!0,...j(T)})}function Hw($,T){return new $({type:"bigint",...j(T)})}function Fw($,T){return new $({type:"bigint",coerce:!0,...j(T)})}function Qw($,T){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...j(T)})}function Zw($,T){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...j(T)})}function Dw($,T){return new $({type:"symbol",...j(T)})}function Ow($,T){return new $({type:"undefined",...j(T)})}function Vw($,T){return new $({type:"null",...j(T)})}function Kw($){return new $({type:"any"})}function Ew($){return new $({type:"unknown"})}function Mw($,T){return new $({type:"never",...j(T)})}function Aw($,T){return new $({type:"void",...j(T)})}function Nw($,T){return new $({type:"date",...j(T)})}function Lw($,T){return new $({type:"date",coerce:!0,...j(T)})}function Sw($,T){return new $({type:"nan",...j(T)})}function p6($,T){return new sX({check:"less_than",...j(T),value:$,inclusive:!1})}function U6($,T){return new sX({check:"less_than",...j(T),value:$,inclusive:!0})}function d6($,T){return new eX({check:"greater_than",...j(T),value:$,inclusive:!1})}function b4($,T){return new eX({check:"greater_than",...j(T),value:$,inclusive:!0})}function Bw($){return d6(0,$)}function Rw($){return p6(0,$)}function Iw($){return U6(0,$)}function kw($){return b4(0,$)}function $0($,T){return new lG({check:"multiple_of",...j(T),value:$})}function r0($,T){return new nG({check:"max_size",...j(T),maximum:$})}function T0($,T){return new tG({check:"min_size",...j(T),minimum:$})}function kW($,T){return new aG({check:"size_equals",...j(T),size:$})}function i0($,T){return new sG({check:"max_length",...j(T),maximum:$})}function I1($,T){return new eG({check:"min_length",...j(T),minimum:$})}function n0($,T){return new $J({check:"length_equals",...j(T),length:$})}function qW($,T){return new TJ({check:"string_format",format:"regex",...j(T),pattern:$})}function PW($){return new WJ({check:"string_format",format:"lowercase",...j($)})}function CW($){return new XJ({check:"string_format",format:"uppercase",...j($)})}function vW($,T){return new YJ({check:"string_format",format:"includes",...j(T),includes:$})}function jW($,T){return new UJ({check:"string_format",format:"starts_with",...j(T),prefix:$})}function xW($,T){return new GJ({check:"string_format",format:"ends_with",...j(T),suffix:$})}function qw($,T,W){return new JJ({check:"property",property:$,schema:T,...j(W)})}function bW($,T){return new wJ({check:"mime_type",mime:$,...j(T)})}function o6($){return new zJ({check:"overwrite",tx:$})}function fW($){return o6((T)=>T.normalize($))}function yW(){return o6(($)=>$.trim())}function hW(){return o6(($)=>$.toLowerCase())}function gW(){return o6(($)=>$.toUpperCase())}function Pw($,T,W){return new $({type:"array",element:T,...j(W)})}function RS($,T,W){return new $({type:"union",options:T,...j(W)})}function IS($,T,W,X){return new $({type:"union",options:W,discriminator:T,...j(X)})}function kS($,T,W){return new $({type:"intersection",left:T,right:W})}function Cw($,T,W,X){let Y=W instanceof W$;return new $({type:"tuple",items:T,rest:Y?W:null,...j(Y?X:W)})}function qS($,T,W,X){return new $({type:"record",keyType:T,valueType:W,...j(X)})}function PS($,T,W,X){return new $({type:"map",keyType:T,valueType:W,...j(X)})}function CS($,T,W){return new $({type:"set",valueType:T,...j(W)})}function vS($,T,W){let X=Array.isArray(T)?Object.fromEntries(T.map((Y)=>[Y,Y])):T;return new $({type:"enum",entries:X,...j(W)})}function jS($,T,W){return new $({type:"enum",entries:T,...j(W)})}function xS($,T,W){return new $({type:"literal",values:Array.isArray(T)?T:[T],...j(W)})}function vw($,T){return new $({type:"file",...j(T)})}function bS($,T){return new $({type:"transform",transform:T})}function fS($,T){return new $({type:"optional",innerType:T})}function yS($,T){return new $({type:"nullable",innerType:T})}function hS($,T,W){return new $({type:"default",innerType:T,get defaultValue(){return typeof W==="function"?W():W}})}function gS($,T,W){return new $({type:"nonoptional",innerType:T,...j(W)})}function mS($,T){return new $({type:"success",innerType:T})}function cS($,T,W){return new $({type:"catch",innerType:T,catchValue:typeof W==="function"?W:()=>W})}function uS($,T,W){return new $({type:"pipe",in:T,out:W})}function pS($,T){return new $({type:"readonly",innerType:T})}function dS($,T,W){return new $({type:"template_literal",parts:T,...j(W)})}function oS($,T){return new $({type:"lazy",getter:T})}function lS($,T){return new $({type:"promise",innerType:T})}function mW($,T,W){return new $({type:"custom",check:"custom",fn:T,...j(W)})}function rS($,T,W={}){return mW($,T,W)}function jw($,T){let W=j(T),X=new Set(W?.truthy??["true","1","yes","on","y","enabled"]),Y=new Set(W?.falsy??["false","0","no","off","n","disabled"]),U=$.Pipe??LW,G=$.Boolean??AW,z=new($.Unknown??NW)({type:"unknown",checks:[{_zod:{check:(w)=>{if(typeof w.value==="string"){let H=w.value;if(W?.case!=="sensitive")H=H.toLowerCase();if(X.has(H))w.value=!0;else if(Y.has(H))w.value=!1;else w.issues.push({code:"invalid_value",expected:"stringbool",values:[...X,...Y],input:w.value,inst:z})}else w.issues.push({code:"invalid_type",expected:"string",input:w.value})},def:{check:"custom"},onattach:[]}}]});return new U({type:"pipe",in:z,out:new G({type:"boolean"})})}class t0{constructor($){this._def=$,this.def=$}implement($){if(typeof $!=="function")throw new Error("implement() must be called with a function");let T=(...W)=>{let X=this._def.input?dX(this._def.input,W,void 0,{callee:T}):W;if(!Array.isArray(X))throw new Error("Invalid arguments schema: not an array or tuple schema.");let Y=$(...X);return this._def.output?dX(this._def.output,Y,void 0,{callee:T}):Y};return T}implementAsync($){if(typeof $!=="function")throw new Error("implement() must be called with a function");let T=async(...W)=>{let X=this._def.input?await lX(this._def.input,W,void 0,{callee:T}):W;if(!Array.isArray(X))throw new Error("Invalid arguments schema: not an array or tuple schema.");let Y=await $(...X);return this._def.output?lX(this._def.output,Y,void 0,{callee:T}):Y};return T}input(...$){if(Array.isArray($[0]))return new t0({type:"function",input:new e1({type:"tuple",items:$[0],rest:$[1]}),output:this._def.output});return new t0({type:"function",input:$[0],output:this._def.output})}output($){return new t0({type:"function",input:this._def.input,output:$})}}function xw($){return new t0({type:"function",input:Array.isArray($?.input)?Cw(e1,$?.input):$?.input??null,output:$?.output??null})}var iS={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"};class kY{constructor($){this.counter=0,this.metadataRegistry=$?.metadata??v6,this.target=$?.target??"draft-2020-12",this.unrepresentable=$?.unrepresentable??"throw",this.override=$?.override??(()=>{}),this.io=$?.io??"output",this.seen=new Map}process($,T={path:[],schemaPath:[]}){var W;let X=$._zod.def,Y=this.seen.get($);if(Y){if(Y.count++,T.schemaPath.includes($))Y.cycle=T.path;return Y.count++,Y.schema}let U={schema:{},count:1,cycle:void 0};if(this.seen.set($,U),$._zod.toJSONSchema)U.schema=$._zod.toJSONSchema();let G={...T,schemaPath:[...T.schemaPath,$],path:T.path},J=$._zod.parent;if(J)U.ref=J,this.process(J,G),this.seen.get(J).isParent=!0;else{let H=U.schema;switch(X.type){case"string":{let _=H;_.type="string";let{minimum:F,maximum:D,format:V,pattern:E,contentEncoding:R}=$._zod.bag;if(typeof F==="number")_.minLength=F;if(typeof D==="number")_.maxLength=D;if(V)_.format=iS[V]??V;if(E)_.pattern=E.source;if(R)_.contentEncoding=R;break}case"number":{let _=H,{minimum:F,maximum:D,format:V,multipleOf:E,exclusiveMaximum:R,exclusiveMinimum:P}=$._zod.bag;if(typeof V==="string"&&V.includes("int"))_.type="integer";else _.type="number";if(typeof P==="number")_.exclusiveMinimum=P;if(typeof F==="number"){if(_.minimum=F,typeof P==="number")if(P>=F)delete _.minimum;else delete _.exclusiveMinimum}if(typeof R==="number")_.exclusiveMaximum=R;if(typeof D==="number"){if(_.maximum=D,typeof R==="number")if(R<=D)delete _.maximum;else delete _.exclusiveMaximum}if(typeof E==="number")_.multipleOf=E;break}case"boolean":{let _=H;_.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"undefined":{let _=H;_.type="null";break}case"null":{H.type="null";break}case"any":break;case"unknown":break;case"never":{H.not={};break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let _=H,{minimum:F,maximum:D}=$._zod.bag;if(typeof F==="number")_.minItems=F;if(typeof D==="number")_.maxItems=D;_.type="array",_.items=this.process(X.element,{...G,path:[...G.path,"items"]});break}case"object":{let _=H;_.type="object",_.properties={};let F=X.shape;for(let E in F)_.properties[E]=this.process(F[E],{...G,path:[...G.path,"properties",E]});let D=new Set(Object.keys(F)),V=new Set([...D].filter((E)=>{let R=X.shape[E]._zod;if(this.io==="input")return R.optin===void 0;else return R.optout===void 0}));if(_.required=Array.from(V),X.catchall?._zod.def.type==="never")_.additionalProperties=!1;else if(!X.catchall){if(this.io==="output")_.additionalProperties=!1}else if(X.catchall)_.additionalProperties=this.process(X.catchall,{...G,path:[...G.path,"additionalProperties"]});break}case"union":{let _=H;_.anyOf=X.options.map((F,D)=>this.process(F,{...G,path:[...G.path,"anyOf",D]}));break}case"intersection":{let _=H;_.allOf=[this.process(X.left,{...G,path:[...G.path,"allOf",0]}),this.process(X.right,{...G,path:[...G.path,"allOf",1]})];break}case"tuple":{let _=H;_.type="array";let F=X.items.map((E,R)=>this.process(E,{...G,path:[...G.path,"prefixItems",R]}));if(this.target==="draft-2020-12")_.prefixItems=F;else _.items=F;if(X.rest){let E=this.process(X.rest,{...G,path:[...G.path,"items"]});if(this.target==="draft-2020-12")_.items=E;else _.additionalItems=E}if(X.rest)_.items=this.process(X.rest,{...G,path:[...G.path,"items"]});let{minimum:D,maximum:V}=$._zod.bag;if(typeof D==="number")_.minItems=D;if(typeof V==="number")_.maxItems=V;break}case"record":{let _=H;_.type="object",_.propertyNames=this.process(X.keyType,{...G,path:[...G.path,"propertyNames"]}),_.additionalProperties=this.process(X.valueType,{...G,path:[...G.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let _=H;_.enum=Object.values(X.entries);break}case"literal":{let _=H,F=[];for(let D of X.values)if(D===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof D==="bigint")if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");else F.push(Number(D));else F.push(D);if(F.length===0);else if(F.length===1){let D=F[0];_.const=D}else _.enum=F;break}case"file":{if(this.unrepresentable==="throw")throw new Error("File cannot be represented in JSON Schema");break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let _=this.process(X.innerType,G);H.anyOf=[_,{type:"null"}];break}case"nonoptional":{this.process(X.innerType,G),U.ref=X.innerType;break}case"success":{let _=H;_.type="boolean";break}case"default":{this.process(X.innerType,G),U.ref=X.innerType,H.default=X.defaultValue;break}case"prefault":{if(this.process(X.innerType,G),U.ref=X.innerType,this.io==="input")H._prefault=X.defaultValue;break}case"catch":{this.process(X.innerType,G),U.ref=X.innerType;let _;try{_=X.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}H.default=_;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let _=H,F=$._zod.pattern;if(!F)throw new Error("Pattern not found in template literal");_.type="string",_.pattern=F.source;break}case"pipe":{let _=this.io==="input"?X.in:X.out;this.process(_,G),U.ref=_;break}case"readonly":{this.process(X.innerType,G),U.ref=X.innerType,H.readOnly=!0;break}case"promise":{this.process(X.innerType,G),U.ref=X.innerType;break}case"optional":{this.process(X.innerType,G),U.ref=X.innerType;break}case"lazy":{let _=$._zod.innerType;this.process(_,G),U.ref=_;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}let z=this.metadataRegistry.get($);if(z)Object.assign(U.schema,z);if(this.io==="input"&&X.type==="pipe"){if(delete U.schema.examples,delete U.schema.default,U.schema._prefault)U.schema.default=U.schema._prefault}if(this.io==="input"&&U.schema._prefault)(W=U.schema).default??(W.default=U.schema._prefault);return delete U.schema._prefault,this.seen.get($).schema}emit($,T){let W={cycles:T?.cycles??"ref",reused:T?.reused??"inline",external:T?.external??void 0},X=this.seen.get($);if(!X)throw new Error("Unprocessed schema. This is a bug in Zod.");let Y=(w)=>{let H=this.target==="draft-2020-12"?"$defs":"definitions";if(W.external){let V=W.external.registry.get(w[0])?.id;if(V)return{ref:W.external.uri(V)};let E=w[1].defId??w[1].schema.id??`schema${this.counter++}`;return w[1].defId=E,{defId:E,ref:`${W.external.uri("__shared")}#/${H}/${E}`}}if(w[1]===X)return{ref:"#"};let F=`${"#"}/${H}/`,D=w[1].schema.id??`__schema${this.counter++}`;return{defId:D,ref:F+D}},U=(w)=>{if(w[1].schema.$ref)return;let H=w[1],{ref:_,defId:F}=Y(w);if(H.def={...H.schema},F)H.defId=F;let D=H.schema;for(let V in D)delete D[V],D.$ref=_};for(let w of this.seen.entries()){let H=w[1];if($===w[0]){U(w);continue}if(W.external){let F=W.external.registry.get(w[0])?.id;if($!==w[0]&&F){U(w);continue}}if(this.metadataRegistry.get(w[0])?.id){U(w);continue}if(H.cycle){if(W.cycles==="throw")throw new Error(`Cycle detected: #/${H.cycle?.join("/")}/<root>
|
|
30
|
+
path: iss.path ? [${rT(_)}, ...iss.path] : [${rT(_)}]
|
|
31
|
+
})));`),Q.write(`newResult[${rT(_)}] = ${R}.value`)}Q.write("payload.value = newResult;"),Q.write("return payload;");let J=Q.compile();return(_,R)=>J(O,_,R)},X,Y=Ow,w=!pU.jitless,H=w&&D5.value,{catchall:z}=T,F;$._zod.parse=(O,Q)=>{F??(F=W.value);let Z=O.value;if(!Y(Z))return O.issues.push({expected:"object",code:"invalid_type",input:Z,inst:$}),O;let V=[];if(w&&H&&Q?.async===!1&&Q.jitless!==!0){if(!X)X=U(T.shape);O=X(O,Q)}else{O.value={};let R=F.shape;for(let P of F.keys){let x=R[P],f=x._zod.run({value:Z[P],issues:[]},Q),h=x._zod.optin==="optional"&&x._zod.optout==="optional";if(f instanceof Promise)V.push(f.then((a)=>h?EV(a,O,P,Z):Rw(a,O,P)));else if(h)EV(f,O,P,Z);else Rw(f,O,P)}}if(!z)return V.length?Promise.all(V).then(()=>O):O;let E=[],N=F.keySet,J=z._zod,_=J.def.type;for(let R of Object.keys(Z)){if(N.has(R))continue;if(_==="never"){E.push(R);continue}let P=J.run({value:Z[R],issues:[]},Q);if(P instanceof Promise)V.push(P.then((x)=>Rw(x,O,R)));else Rw(P,O,R)}if(E.length)O.issues.push({code:"unrecognized_keys",keys:E,input:Z,inst:$});if(!V.length)return O;return Promise.all(V).then(()=>{return O})}});function AV($,T,W,U){for(let X of $)if(X.issues.length===0)return T.value=X.value,T;return T.issues.push({code:"invalid_union",input:T.value,inst:W,errors:$.map((X)=>X.issues.map((Y)=>s6(Y,U,N4())))}),T}var Pw=k("$ZodUnion",($,T)=>{Q$.init($,T),g$($._zod,"values",()=>{if(T.options.every((W)=>W._zod.values))return new Set(T.options.flatMap((W)=>Array.from(W._zod.values)));return}),g$($._zod,"pattern",()=>{if(T.options.every((W)=>W._zod.pattern)){let W=T.options.map((U)=>U._zod.pattern);return new RegExp(`^(${W.map((U)=>lU(U.source)).join("|")})$`)}return}),$._zod.parse=(W,U)=>{let X=!1,Y=[];for(let w of T.options){let G=w._zod.run({value:W.value,issues:[]},U);if(G instanceof Promise)Y.push(G),X=!0;else{if(G.issues.length===0)return G;Y.push(G)}}if(!X)return AV(Y,W,$,U);return Promise.all(Y).then((w)=>{return AV(w,W,$,U)})}});function CV($,T,W){let U=!0,X=$?.[T];if(W.values.size&&!W.values.has(X))U=!1;if(W.maps.length>0){for(let Y of W.maps)if(!$C(X,Y))U=!1}return U}function $C($,T){let W=!0;for(let[U,X]of T)if(!CV($,U,X))W=!1;return W}var s7=k("$ZodDiscriminatedUnion",($,T)=>{Pw.init($,T);let W=$._zod.parse;g$($._zod,"disc",()=>{let X=new Map;for(let Y of T.options){let w=Y._zod.disc;if(!w)throw new Error(`Invalid discriminated union option at index "${T.options.indexOf(Y)}"`);for(let[G,H]of w){if(!X.has(G))X.set(G,{values:new Set,maps:[]});let z=X.get(G);for(let F of H.values)z.values.add(F);for(let F of H.maps)z.maps.push(F)}}return X});let U=oU(()=>{let X=new Map;for(let Y of T.options){let w=Y._zod.disc?.get(T.discriminator);if(!w)throw new Error("Invalid discriminated union option");X.set(Y,w)}return X});$._zod.parse=(X,Y)=>{let w=X.value;if(!Ow(w))return X.issues.push({code:"invalid_type",expected:"object",input:w,inst:$}),X;let G=[],H=U.value;for(let z of T.options){let F=H.get(z);if(CV(w,T.discriminator,F))G.push(z)}if(G.length===1)return G[0]._zod.run(X,Y);if(T.unionFallback)return W(X,Y);return X.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:w,path:[T.discriminator],inst:$}),X}}),e7=k("$ZodIntersection",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{let{value:X}=W,Y=T.left._zod.run({value:X,issues:[]},U),w=T.right._zod.run({value:X,issues:[]},U);if(Y instanceof Promise||w instanceof Promise)return Promise.all([Y,w]).then(([H,z])=>{return MV(W,H,z)});return MV(W,Y,w)}});function K7($,T){if($===T)return{valid:!0,data:$};if($ instanceof Date&&T instanceof Date&&+$===+T)return{valid:!0,data:$};if(rU($)&&rU(T)){let W=Object.keys(T),U=Object.keys($).filter((Y)=>W.indexOf(Y)!==-1),X={...$,...T};for(let Y of U){let w=K7($[Y],T[Y]);if(!w.valid)return{valid:!1,mergeErrorPath:[Y,...w.mergeErrorPath]};X[Y]=w.data}return{valid:!0,data:X}}if(Array.isArray($)&&Array.isArray(T)){if($.length!==T.length)return{valid:!1,mergeErrorPath:[]};let W=[];for(let U=0;U<$.length;U++){let X=$[U],Y=T[U],w=K7(X,Y);if(!w.valid)return{valid:!1,mergeErrorPath:[U,...w.mergeErrorPath]};W.push(w.data)}return{valid:!0,data:W}}return{valid:!1,mergeErrorPath:[]}}function MV($,T,W){if(T.issues.length)$.issues.push(...T.issues);if(W.issues.length)$.issues.push(...W.issues);if(nT($))return $;let U=K7(T.value,W.value);if(!U.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(U.mergeErrorPath)}`);return $.value=U.data,$}var aT=k("$ZodTuple",($,T)=>{Q$.init($,T);let W=T.items,U=W.length-[...W].reverse().findIndex((X)=>X._zod.optin!=="optional");$._zod.parse=(X,Y)=>{let w=X.value;if(!Array.isArray(w))return X.issues.push({input:w,inst:$,expected:"tuple",code:"invalid_type"}),X;X.value=[];let G=[];if(!T.rest){let z=w.length>W.length,F=w.length<U-1;if(z||F)return X.issues.push({input:w,inst:$,origin:"array",...z?{code:"too_big",maximum:W.length}:{code:"too_small",minimum:W.length}}),X}let H=-1;for(let z of W){if(H++,H>=w.length){if(H>=U)continue}let F=z._zod.run({value:w[H],issues:[]},Y);if(F instanceof Promise)G.push(F.then((O)=>kw(O,X,H)));else kw(F,X,H)}if(T.rest){let z=w.slice(W.length);for(let F of z){H++;let O=T.rest._zod.run({value:F,issues:[]},Y);if(O instanceof Promise)G.push(O.then((Q)=>kw(Q,X,H)));else kw(O,X,H)}}if(G.length)return Promise.all(G).then(()=>X);return X}});function kw($,T,W){if($.issues.length)T.issues.push(...S6(W,$.issues));T.value[W]=$.value}var $3=k("$ZodRecord",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{let X=W.value;if(!rU(X))return W.issues.push({expected:"record",code:"invalid_type",input:X,inst:$}),W;let Y=[];if(T.keyType._zod.values){let w=T.keyType._zod.values;W.value={};for(let H of w)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let z=T.valueType._zod.run({value:X[H],issues:[]},U);if(z instanceof Promise)Y.push(z.then((F)=>{if(F.issues.length)W.issues.push(...S6(H,F.issues));W.value[H]=F.value}));else{if(z.issues.length)W.issues.push(...S6(H,z.issues));W.value[H]=z.value}}let G;for(let H in X)if(!w.has(H))G=G??[],G.push(H);if(G&&G.length>0)W.issues.push({code:"unrecognized_keys",input:X,inst:$,keys:G})}else{W.value={};for(let w of Reflect.ownKeys(X)){if(w==="__proto__")continue;let G=T.keyType._zod.run({value:w,issues:[]},U);if(G instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(G.issues.length){W.issues.push({origin:"record",code:"invalid_key",issues:G.issues.map((z)=>s6(z,U,N4())),input:w,path:[w],inst:$}),W.value[G.value]=G.value;continue}let H=T.valueType._zod.run({value:X[w],issues:[]},U);if(H instanceof Promise)Y.push(H.then((z)=>{if(z.issues.length)W.issues.push(...S6(w,z.issues));W.value[G.value]=z.value}));else{if(H.issues.length)W.issues.push(...S6(w,H.issues));W.value[G.value]=H.value}}}if(Y.length)return Promise.all(Y).then(()=>W);return W}}),T3=k("$ZodMap",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{let X=W.value;if(!(X instanceof Map))return W.issues.push({expected:"map",code:"invalid_type",input:X,inst:$}),W;let Y=[];W.value=new Map;for(let[w,G]of X){let H=T.keyType._zod.run({value:w,issues:[]},U),z=T.valueType._zod.run({value:G,issues:[]},U);if(H instanceof Promise||z instanceof Promise)Y.push(Promise.all([H,z]).then(([F,O])=>{NV(F,O,W,w,X,$,U)}));else NV(H,z,W,w,X,$,U)}if(Y.length)return Promise.all(Y).then(()=>W);return W}});function NV($,T,W,U,X,Y,w){if($.issues.length)if(nU.has(typeof U))W.issues.push(...S6(U,$.issues));else W.issues.push({origin:"map",code:"invalid_key",input:X,inst:Y,issues:$.issues.map((G)=>s6(G,w,N4()))});if(T.issues.length)if(nU.has(typeof U))W.issues.push(...S6(U,T.issues));else W.issues.push({origin:"map",code:"invalid_element",input:X,inst:Y,key:U,issues:T.issues.map((G)=>s6(G,w,N4()))});W.value.set($.value,T.value)}var W3=k("$ZodSet",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{let X=W.value;if(!(X instanceof Set))return W.issues.push({input:X,inst:$,expected:"set",code:"invalid_type"}),W;let Y=[];W.value=new Set;for(let w of X){let G=T.valueType._zod.run({value:w,issues:[]},U);if(G instanceof Promise)Y.push(G.then((H)=>LV(H,W)));else LV(G,W)}if(Y.length)return Promise.all(Y).then(()=>W);return W}});function LV($,T){if($.issues.length)T.issues.push(...$.issues);T.value.add($.value)}var U3=k("$ZodEnum",($,T)=>{Q$.init($,T);let W=Object.values(T.entries).filter((X)=>typeof X==="number"),U=Object.entries(T.entries).filter(([X,Y])=>W.indexOf(+X)===-1).map(([X,Y])=>Y);$._zod.values=new Set(U),$._zod.pattern=new RegExp(`^(${U.filter((X)=>nU.has(typeof X)).map((X)=>typeof X==="string"?D0(X):X.toString()).join("|")})$`),$._zod.parse=(X,Y)=>{let w=X.value;if($._zod.values.has(w))return X;return X.issues.push({code:"invalid_value",values:U,input:w,inst:$}),X}}),X3=k("$ZodLiteral",($,T)=>{Q$.init($,T),$._zod.values=new Set(T.values),$._zod.pattern=new RegExp(`^(${T.values.map((W)=>typeof W==="string"?D0(W):W?W.toString():String(W)).join("|")})$`),$._zod.parse=(W,U)=>{let X=W.value;if($._zod.values.has(X))return W;return W.issues.push({code:"invalid_value",values:T.values,input:X,inst:$}),W}}),Y3=k("$ZodFile",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{let X=W.value;if(X instanceof File)return W;return W.issues.push({expected:"file",code:"invalid_type",input:X,inst:$}),W}}),w3=k("$ZodTransform",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{let X=T.transform(W.value,W);if(U.async)return(X instanceof Promise?X:Promise.resolve(X)).then((w)=>{return W.value=w,W});if(X instanceof Promise)throw new Z0;return W.value=X,W}}),G3=k("$ZodOptional",($,T)=>{Q$.init($,T),$._zod.optin="optional",$._zod.optout="optional",g$($._zod,"values",()=>{return T.innerType._zod.values?new Set([...T.innerType._zod.values,void 0]):void 0}),g$($._zod,"pattern",()=>{let W=T.innerType._zod.pattern;return W?new RegExp(`^(${lU(W.source)})?$`):void 0}),$._zod.parse=(W,U)=>{if(W.value===void 0)return W;return T.innerType._zod.run(W,U)}}),z3=k("$ZodNullable",($,T)=>{Q$.init($,T),g$($._zod,"optin",()=>T.innerType._zod.optin),g$($._zod,"optout",()=>T.innerType._zod.optout),g$($._zod,"pattern",()=>{let W=T.innerType._zod.pattern;return W?new RegExp(`^(${lU(W.source)}|null)$`):void 0}),g$($._zod,"values",()=>{return T.innerType._zod.values?new Set([...T.innerType._zod.values,null]):void 0}),$._zod.parse=(W,U)=>{if(W.value===null)return W;return T.innerType._zod.run(W,U)}}),H3=k("$ZodDefault",($,T)=>{Q$.init($,T),$._zod.optin="optional",g$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,U)=>{if(W.value===void 0)return W.value=T.defaultValue,W;let X=T.innerType._zod.run(W,U);if(X instanceof Promise)return X.then((Y)=>JV(Y,T));return JV(X,T)}});function JV($,T){if($.value===void 0)$.value=T.defaultValue;return $}var F3=k("$ZodPrefault",($,T)=>{Q$.init($,T),$._zod.optin="optional",g$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,U)=>{if(W.value===void 0)W.value=T.defaultValue;return T.innerType._zod.run(W,U)}}),O3=k("$ZodNonOptional",($,T)=>{Q$.init($,T),g$($._zod,"values",()=>{let W=T.innerType._zod.values;return W?new Set([...W].filter((U)=>U!==void 0)):void 0}),$._zod.parse=(W,U)=>{let X=T.innerType._zod.run(W,U);if(X instanceof Promise)return X.then((Y)=>_V(Y,$));return _V(X,$)}});function _V($,T){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:T});return $}var Q3=k("$ZodSuccess",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{let X=T.innerType._zod.run(W,U);if(X instanceof Promise)return X.then((Y)=>{return W.value=Y.issues.length===0,W});return W.value=X.issues.length===0,W}}),Z3=k("$ZodCatch",($,T)=>{Q$.init($,T),g$($._zod,"optin",()=>T.innerType._zod.optin),g$($._zod,"optout",()=>T.innerType._zod.optout),g$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,U)=>{let X=T.innerType._zod.run(W,U);if(X instanceof Promise)return X.then((Y)=>{if(W.value=Y.value,Y.issues.length)W.value=T.catchValue({...W,error:{issues:Y.issues.map((w)=>s6(w,U,N4()))},input:W.value}),W.issues=[];return W});if(W.value=X.value,X.issues.length)W.value=T.catchValue({...W,error:{issues:X.issues.map((Y)=>s6(Y,U,N4()))},input:W.value}),W.issues=[];return W}}),D3=k("$ZodNaN",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{if(typeof W.value!=="number"||!Number.isNaN(W.value))return W.issues.push({input:W.value,inst:$,expected:"nan",code:"invalid_type"}),W;return W}}),UX=k("$ZodPipe",($,T)=>{Q$.init($,T),g$($._zod,"values",()=>T.in._zod.values),g$($._zod,"optin",()=>T.in._zod.optin),g$($._zod,"optout",()=>T.out._zod.optout),$._zod.parse=(W,U)=>{let X=T.in._zod.run(W,U);if(X instanceof Promise)return X.then((Y)=>RV(Y,T,U));return RV(X,T,U)}});function RV($,T,W){if(nT($))return $;return T.out._zod.run({value:$.value,issues:$.issues},W)}var V3=k("$ZodReadonly",($,T)=>{Q$.init($,T),g$($._zod,"disc",()=>T.innerType._zod.disc),g$($._zod,"optin",()=>T.innerType._zod.optin),g$($._zod,"optout",()=>T.innerType._zod.optout),$._zod.parse=(W,U)=>{let X=T.innerType._zod.run(W,U);if(X instanceof Promise)return X.then(kV);return kV(X)}});function kV($){return $.value=Object.freeze($.value),$}var K3=k("$ZodTemplateLiteral",($,T)=>{Q$.init($,T);let W=[];for(let U of T.parts)if(U instanceof Q$){if(!U._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...U._zod.traits].shift()}`);let X=U._zod.pattern instanceof RegExp?U._zod.pattern.source:U._zod.pattern;if(!X)throw new Error(`Invalid template literal part: ${U._zod.traits}`);let Y=X.startsWith("^")?1:0,w=X.endsWith("$")?X.length-1:X.length;W.push(X.slice(Y,w))}else if(U===null||V5.has(typeof U))W.push(D0(`${U}`));else throw new Error(`Invalid template literal part: ${U}`);$._zod.pattern=new RegExp(`^${W.join("")}$`),$._zod.parse=(U,X)=>{if(typeof U.value!=="string")return U.issues.push({input:U.value,inst:$,expected:"template_literal",code:"invalid_type"}),U;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(U.value))return U.issues.push({input:U.value,inst:$,code:"invalid_format",format:"template_literal",pattern:$._zod.pattern.source}),U;return U}}),E3=k("$ZodPromise",($,T)=>{Q$.init($,T),$._zod.parse=(W,U)=>{return Promise.resolve(W.value).then((X)=>T.innerType._zod.run({value:X,issues:[]},U))}}),A3=k("$ZodLazy",($,T)=>{Q$.init($,T),g$($._zod,"innerType",()=>T.getter()),g$($._zod,"pattern",()=>$._zod.innerType._zod.pattern),g$($._zod,"disc",()=>$._zod.innerType._zod.disc),g$($._zod,"optin",()=>$._zod.innerType._zod.optin),g$($._zod,"optout",()=>$._zod.innerType._zod.optout),$._zod.parse=(W,U)=>{return $._zod.innerType._zod.run(W,U)}}),M3=k("$ZodCustom",($,T)=>{G4.init($,T),Q$.init($,T),$._zod.parse=(W,U)=>{return W},$._zod.check=(W)=>{let U=W.value,X=T.fn(U);if(X instanceof Promise)return X.then((Y)=>vV(Y,W,U,$));vV(X,W,U,$);return}});function vV($,T,W,U){if(!$){let X={code:"custom",input:W,inst:U,path:[...U._zod.def.path??[]],continue:!U._zod.def.abort};if(U._zod.def.params)X.params=U._zod.def.params;T.issues.push(M5(X))}}var YX={};wT(YX,{zhTW:()=>TH,zhCN:()=>$H,vi:()=>e3,ur:()=>s3,ua:()=>a3,tr:()=>t3,th:()=>i3,ta:()=>n3,sv:()=>r3,sl:()=>l3,ru:()=>o3,pt:()=>d3,pl:()=>p3,ota:()=>u3,no:()=>c3,nl:()=>m3,ms:()=>g3,mk:()=>h3,ko:()=>y3,kh:()=>f3,ja:()=>b3,it:()=>I3,id:()=>x3,hu:()=>B3,he:()=>j3,frCA:()=>S3,fr:()=>C3,fi:()=>P3,fa:()=>q3,es:()=>v3,en:()=>XX,de:()=>k3,cs:()=>R3,ca:()=>_3,be:()=>J3,az:()=>L3,ar:()=>N3});var TC={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 jV($){return TC[$]??null}var WC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},UC={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"},XC=($)=>{switch($.code){case"invalid_type":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 ${$.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${WC($.input)}`;case"invalid_value":if($.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 ${r($.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: ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=jV($.origin);if(W)return` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${$.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${T} ${$.maximum.toString()} ${W.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 ${$.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=jV($.origin);if(W)return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${$.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${T} ${$.minimum.toString()} ${W.unit}`;return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${$.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${$.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`${UC[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${$.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${$.keys.length>1?"\u0629":""}: ${I($.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${$.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 ${$.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}};function N3(){return{localeError:XC}}var YC={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 BV($){return YC[$]??null}var wC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},GC={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"},zC=($)=>{switch($.code){case"invalid_type":return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${$.expected}, daxil olan ${wC($.input)}`;case"invalid_value":if($.values.length===1)return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${r($.values[0])}`;return`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=BV($.origin);if(W)return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${$.origin??"d\u0259y\u0259r"} ${T}${$.maximum.toString()} ${W.unit??"element"}`;return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${$.origin??"d\u0259y\u0259r"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=BV($.origin);if(W)return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${$.origin} ${T}${$.minimum.toString()} ${W.unit}`;return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Yanl\u0131\u015F m\u0259tn: "${T.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`;if(T.format==="ends_with")return`Yanl\u0131\u015F m\u0259tn: "${T.suffix}" il\u0259 bitm\u0259lidir`;if(T.format==="includes")return`Yanl\u0131\u015F m\u0259tn: "${T.includes}" daxil olmal\u0131d\u0131r`;if(T.format==="regex")return`Yanl\u0131\u015F m\u0259tn: ${T.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`;return`Yanl\u0131\u015F ${GC[T.format]??$.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${$.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${$.keys.length>1?"lar":""}: ${I($.keys,", ")}`;case"invalid_key":return`${$.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${$.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}};function L3(){return{localeError:zC}}function xV($,T,W,U){let X=Math.abs($),Y=X%10,w=X%100;if(w>=11&&w<=19)return U;if(Y===1)return T;if(Y>=2&&Y<=4)return W;return U}var HC={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 IV($){return HC[$]??null}var FC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u043B\u0456\u043A";case"object":{if(Array.isArray($))return"\u043C\u0430\u0441\u0456\u045E";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},OC={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"},QC=($)=>{switch($.code){case"invalid_type":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${$.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${FC($.input)}`;case"invalid_value":if($.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 ${r($.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 ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=IV($.origin);if(W){let U=Number($.maximum),X=xV(U,W.unit.one,W.unit.few,W.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 ${$.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${W.verb} ${T}${$.maximum.toString()} ${X}`}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 ${$.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=IV($.origin);if(W){let U=Number($.minimum),X=xV(U,W.unit.one,W.unit.few,W.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 ${$.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${W.verb} ${T}${$.minimum.toString()} ${X}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${$.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${OC[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${$.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${I($.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${$.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 ${$.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}};function J3(){return{localeError:QC}}var ZC={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function bV($){return ZC[$]??null}var DC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},VC={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"},KC=($)=>{switch($.code){case"invalid_type":return`Tipus inv\xE0lid: s'esperava ${$.expected}, s'ha rebut ${DC($.input)}`;case"invalid_value":if($.values.length===1)return`Valor inv\xE0lid: s'esperava ${r($.values[0])}`;return`Opci\xF3 inv\xE0lida: s'esperava una de ${I($.values," o ")}`;case"too_big":{let T=$.inclusive?"com a m\xE0xim":"menys de",W=bV($.origin);if(W)return`Massa gran: s'esperava que ${$.origin??"el valor"} contingu\xE9s ${T} ${$.maximum.toString()} ${W.unit??"elements"}`;return`Massa gran: s'esperava que ${$.origin??"el valor"} fos ${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?"com a m\xEDnim":"m\xE9s de",W=bV($.origin);if(W)return`Massa petit: s'esperava que ${$.origin} contingu\xE9s ${T} ${$.minimum.toString()} ${W.unit}`;return`Massa petit: s'esperava que ${$.origin} fos ${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Format inv\xE0lid: ha de comen\xE7ar amb "${T.prefix}"`;if(T.format==="ends_with")return`Format inv\xE0lid: ha d'acabar amb "${T.suffix}"`;if(T.format==="includes")return`Format inv\xE0lid: ha d'incloure "${T.includes}"`;if(T.format==="regex")return`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${T.pattern}`;return`Format inv\xE0lid per a ${VC[T.format]??$.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${$.divisor}`;case"unrecognized_keys":return`Clau${$.keys.length>1?"s":""} no reconeguda${$.keys.length>1?"s":""}: ${I($.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${$.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${$.origin}`;default:return"Entrada inv\xE0lida"}};function _3(){return{localeError:KC}}var EC={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 fV($){return EC[$]??null}var AC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u010D\xEDslo";case"string":return"\u0159et\u011Bzec";case"boolean":return"boolean";case"bigint":return"bigint";case"function":return"funkce";case"symbol":return"symbol";case"undefined":return"undefined";case"object":{if(Array.isArray($))return"pole";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},MC={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"},NC=($)=>{switch($.code){case"invalid_type":return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${$.expected}, obdr\u017Eeno ${AC($.input)}`;case"invalid_value":if($.values.length===1)return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${r($.values[0])}`;return`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=fV($.origin);if(W)return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${$.origin??"hodnota"} mus\xED m\xEDt ${T}${$.maximum.toString()} ${W.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${$.origin??"hodnota"} mus\xED b\xFDt ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=fV($.origin);if(W)return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${$.origin??"hodnota"} mus\xED m\xEDt ${T}${$.minimum.toString()} ${W.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${$.origin??"hodnota"} mus\xED b\xFDt ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${T.prefix}"`;if(T.format==="ends_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${T.suffix}"`;if(T.format==="includes")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${T.includes}"`;if(T.format==="regex")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${T.pattern}`;return`Neplatn\xFD form\xE1t ${MC[T.format]??$.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${$.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${I($.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${$.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${$.origin}`;default:return"Neplatn\xFD vstup"}};function R3(){return{localeError:NC}}var LC={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 yV($){return LC[$]??null}var JC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"Zahl";case"object":{if(Array.isArray($))return"Array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},_C={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"},RC=($)=>{switch($.code){case"invalid_type":return`Ung\xFCltige Eingabe: erwartet ${$.expected}, erhalten ${JC($.input)}`;case"invalid_value":if($.values.length===1)return`Ung\xFCltige Eingabe: erwartet ${r($.values[0])}`;return`Ung\xFCltige Option: erwartet eine von ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=yV($.origin);if(W)return`Zu gro\xDF: erwartet, dass ${$.origin??"Wert"} ${T}${$.maximum.toString()} ${W.unit??"Elemente"} hat`;return`Zu gro\xDF: erwartet, dass ${$.origin??"Wert"} ${T}${$.maximum.toString()} ist`}case"too_small":{let T=$.inclusive?">=":">",W=yV($.origin);if(W)return`Zu klein: erwartet, dass ${$.origin} ${T}${$.minimum.toString()} ${W.unit} hat`;return`Zu klein: erwartet, dass ${$.origin} ${T}${$.minimum.toString()} ist`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ung\xFCltiger String: muss mit "${T.prefix}" beginnen`;if(T.format==="ends_with")return`Ung\xFCltiger String: muss mit "${T.suffix}" enden`;if(T.format==="includes")return`Ung\xFCltiger String: muss "${T.includes}" enthalten`;if(T.format==="regex")return`Ung\xFCltiger String: muss dem Muster ${T.pattern} entsprechen`;return`Ung\xFCltig: ${_C[T.format]??$.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${$.divisor} sein`;case"unrecognized_keys":return`${$.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${I($.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${$.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${$.origin}`;default:return"Ung\xFCltige Eingabe"}};function k3(){return{localeError:RC}}var kC={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function hV($){return kC[$]??null}var vC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},qC={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"},PC=($)=>{switch($.code){case"invalid_type":return`Invalid input: expected ${$.expected}, received ${vC($.input)}`;case"invalid_value":if($.values.length===1)return`Invalid input: expected ${r($.values[0])}`;return`Invalid option: expected one of ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=hV($.origin);if(W)return`Too big: expected ${$.origin??"value"} to have ${T}${$.maximum.toString()} ${W.unit??"elements"}`;return`Too big: expected ${$.origin??"value"} to be ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=hV($.origin);if(W)return`Too small: expected ${$.origin} to have ${T}${$.minimum.toString()} ${W.unit}`;return`Too small: expected ${$.origin} to be ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Invalid string: must start with "${T.prefix}"`;if(T.format==="ends_with")return`Invalid string: must end with "${T.suffix}"`;if(T.format==="includes")return`Invalid string: must include "${T.includes}"`;if(T.format==="regex")return`Invalid string: must match pattern ${T.pattern}`;return`Invalid ${qC[T.format]??$.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${$.divisor}`;case"unrecognized_keys":return`Unrecognized key${$.keys.length>1?"s":""}: ${I($.keys,", ")}`;case"invalid_key":return`Invalid key in ${$.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${$.origin}`;default:return"Invalid input"}};function XX(){return{localeError:PC}}var CC={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function gV($){return CC[$]??null}var SC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"n\xFAmero";case"object":{if(Array.isArray($))return"arreglo";if($===null)return"nulo";if(Object.getPrototypeOf($)!==Object.prototype)return $.constructor.name}}return T},jC={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"},BC=($)=>{switch($.code){case"invalid_type":return`Entrada inv\xE1lida: se esperaba ${$.expected}, recibido ${SC($.input)}`;case"invalid_value":if($.values.length===1)return`Entrada inv\xE1lida: se esperaba ${r($.values[0])}`;return`Opci\xF3n inv\xE1lida: se esperaba una de ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=gV($.origin);if(W)return`Demasiado grande: se esperaba que ${$.origin??"valor"} tuviera ${T}${$.maximum.toString()} ${W.unit??"elementos"}`;return`Demasiado grande: se esperaba que ${$.origin??"valor"} fuera ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=gV($.origin);if(W)return`Demasiado peque\xF1o: se esperaba que ${$.origin} tuviera ${T}${$.minimum.toString()} ${W.unit}`;return`Demasiado peque\xF1o: se esperaba que ${$.origin} fuera ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Cadena inv\xE1lida: debe comenzar con "${T.prefix}"`;if(T.format==="ends_with")return`Cadena inv\xE1lida: debe terminar en "${T.suffix}"`;if(T.format==="includes")return`Cadena inv\xE1lida: debe incluir "${T.includes}"`;if(T.format==="regex")return`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${T.pattern}`;return`Inv\xE1lido ${jC[T.format]??$.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${$.divisor}`;case"unrecognized_keys":return`Llave${$.keys.length>1?"s":""} desconocida${$.keys.length>1?"s":""}: ${I($.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${$.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${$.origin}`;default:return"Entrada inv\xE1lida"}};function v3(){return{localeError:BC}}var xC={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 mV($){return xC[$]??null}var IC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0639\u062F\u062F";case"object":{if(Array.isArray($))return"\u0622\u0631\u0627\u06CC\u0647";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},bC={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"},fC=($)=>{switch($.code){case"invalid_type":return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${$.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${IC($.input)} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`;case"invalid_value":if($.values.length===1)return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${r($.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 ${I($.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let T=$.inclusive?"<=":"<",W=mV($.origin);if(W)return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${$.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${T}${$.maximum.toString()} ${W.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${$.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${T}${$.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let T=$.inclusive?">=":">",W=mV($.origin);if(W)return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${$.origin} \u0628\u0627\u06CC\u062F ${T}${$.minimum.toString()} ${W.unit} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${$.origin} \u0628\u0627\u06CC\u062F ${T}${$.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${T.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`;if(T.format==="ends_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${T.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`;if(T.format==="includes")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${T.includes}" \u0628\u0627\u0634\u062F`;if(T.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 ${T.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`;return`${bC[T.format]??$.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 ${$.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${$.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${I($.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${$.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 ${$.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}};function q3(){return{localeError:fC}}var yC={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 cV($){return yC[$]??null}var hC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},gC={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"},mC=($)=>{switch($.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${$.expected}, oli ${hC($.input)}`;case"invalid_value":if($.values.length===1)return`Virheellinen sy\xF6te: t\xE4ytyy olla ${r($.values[0])}`;return`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=cV($.origin);if(W)return`Liian suuri: ${W.subject} t\xE4ytyy olla ${T}${$.maximum.toString()} ${W.unit}`.trim();return`Liian suuri: arvon t\xE4ytyy olla ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=cV($.origin);if(W)return`Liian pieni: ${W.subject} t\xE4ytyy olla ${T}${$.minimum.toString()} ${W.unit}`.trim();return`Liian pieni: arvon t\xE4ytyy olla ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${T.prefix}"`;if(T.format==="ends_with")return`Virheellinen sy\xF6te: t\xE4ytyy loppua "${T.suffix}"`;if(T.format==="includes")return`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${T.includes}"`;if(T.format==="regex")return`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${T.pattern}`;return`Virheellinen ${gC[T.format]??$.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${$.divisor} monikerta`;case"unrecognized_keys":return`${$.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${I($.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"}};function P3(){return{localeError:mC}}var cC={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function uV($){return cC[$]??null}var uC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"nombre";case"object":{if(Array.isArray($))return"tableau";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},pC={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"},dC=($)=>{switch($.code){case"invalid_type":return`Entr\xE9e invalide : ${$.expected} attendu, ${uC($.input)} re\xE7u`;case"invalid_value":if($.values.length===1)return`Entr\xE9e invalide : ${r($.values[0])} attendu`;return`Option invalide : une valeur parmi ${I($.values,"|")} attendue`;case"too_big":{let T=$.inclusive?"<=":"<",W=uV($.origin);if(W)return`Trop grand : ${$.origin??"valeur"} doit ${W.verb} ${T}${$.maximum.toString()} ${W.unit??"\xE9l\xE9ment(s)"}`;return`Trop grand : ${$.origin??"valeur"} doit \xEAtre ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=uV($.origin);if(W)return`Trop petit : ${$.origin} doit ${W.verb} ${T}${$.minimum.toString()} ${W.unit}`;return`Trop petit : ${$.origin} doit \xEAtre ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${T.prefix}"`;if(T.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${T.suffix}"`;if(T.format==="includes")return`Cha\xEEne invalide : doit inclure "${T.includes}"`;if(T.format==="regex")return`Cha\xEEne invalide : doit correspondre au mod\xE8le ${T.pattern}`;return`${pC[T.format]??$.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${$.divisor}`;case"unrecognized_keys":return`Cl\xE9${$.keys.length>1?"s":""} non reconnue${$.keys.length>1?"s":""} : ${I($.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${$.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${$.origin}`;default:return"Entr\xE9e invalide"}};function C3(){return{localeError:dC}}var oC={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function pV($){return oC[$]??null}var lC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},rC={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"},nC=($)=>{switch($.code){case"invalid_type":return`Entr\xE9e invalide : attendu ${$.expected}, re\xE7u ${lC($.input)}`;case"invalid_value":if($.values.length===1)return`Entr\xE9e invalide : attendu ${r($.values[0])}`;return`Option invalide : attendu l'une des valeurs suivantes ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"\u2264":"<",W=pV($.origin);if(W)return`Trop grand : attendu que ${$.origin??"la valeur"} ait ${T}${$.maximum.toString()} ${W.unit}`;return`Trop grand : attendu que ${$.origin??"la valeur"} soit ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?"\u2265":">",W=pV($.origin);if(W)return`Trop petit : attendu que ${$.origin} ait ${T}${$.minimum.toString()} ${W.unit}`;return`Trop petit : attendu que ${$.origin} soit ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${T.prefix}"`;if(T.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${T.suffix}"`;if(T.format==="includes")return`Cha\xEEne invalide : doit inclure "${T.includes}"`;if(T.format==="regex")return`Cha\xEEne invalide : doit correspondre au motif ${T.pattern}`;return`${rC[T.format]??$.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${$.divisor}`;case"unrecognized_keys":return`Cl\xE9${$.keys.length>1?"s":""} non reconnue${$.keys.length>1?"s":""} : ${I($.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${$.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${$.origin}`;default:return"Entr\xE9e invalide"}};function S3(){return{localeError:nC}}var iC={string:{unit:"\u05D0\u05D5\u05EA\u05D9\u05D5\u05EA",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"}};function dV($){return iC[$]??null}var tC=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},aC={regex:"\u05E7\u05DC\u05D8",email:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",url:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",emoji:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",date:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",time:"\u05D6\u05DE\u05DF ISO",duration:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",ipv4:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",ipv6:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",cidrv4:"\u05D8\u05D5\u05D5\u05D7 IPv4",cidrv6:"\u05D8\u05D5\u05D5\u05D7 IPv6",base64:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",base64url:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",json_string:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",e164:"\u05DE\u05E1\u05E4\u05E8 E.164",jwt:"JWT",template_literal:"\u05E7\u05DC\u05D8"},sC=($)=>{switch($.code){case"invalid_type":return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${$.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${tC($.input)}`;case"invalid_value":if($.values.length===1)return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${r($.values[0])}`;return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05D0\u05D7\u05EA \u05DE\u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=dV($.origin);if(W)return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${$.origin??"value"} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.maximum.toString()} ${W.unit??"elements"}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${$.origin??"value"} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=dV($.origin);if(W)return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${$.origin} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.minimum.toString()} ${W.unit}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${$.origin} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1"${T.prefix}"`;if(T.format==="ends_with")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${T.suffix}"`;if(T.format==="includes")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${T.includes}"`;if(T.format==="regex")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${T.pattern}`;return`${aC[T.format]??$.format} \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF`}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 ${$.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${$.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${$.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${I($.keys,", ")}`;case"invalid_key":return`\u05DE\u05E4\u05EA\u05D7 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${$.origin}`;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${$.origin}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}};function j3(){return{localeError:sC}}var eC={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function oV($){return eC[$]??null}var $S=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"sz\xE1m";case"object":{if(Array.isArray($))return"t\xF6mb";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},TS={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"},WS=($)=>{switch($.code){case"invalid_type":return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${$.expected}, a kapott \xE9rt\xE9k ${$S($.input)}`;case"invalid_value":if($.values.length===1)return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${r($.values[0])}`;return`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=oV($.origin);if(W)return`T\xFAl nagy: ${$.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${T}${$.maximum.toString()} ${W.unit??"elem"}`;return`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${$.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=oV($.origin);if(W)return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${$.origin} m\xE9rete t\xFAl kicsi ${T}${$.minimum.toString()} ${W.unit}`;return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${$.origin} t\xFAl kicsi ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\xC9rv\xE9nytelen string: "${T.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`;if(T.format==="ends_with")return`\xC9rv\xE9nytelen string: "${T.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`;if(T.format==="includes")return`\xC9rv\xE9nytelen string: "${T.includes}" \xE9rt\xE9ket kell tartalmaznia`;if(T.format==="regex")return`\xC9rv\xE9nytelen string: ${T.pattern} mint\xE1nak kell megfelelnie`;return`\xC9rv\xE9nytelen ${TS[T.format]??$.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${$.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${$.keys.length>1?"s":""}: ${I($.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${$.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${$.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}};function B3(){return{localeError:WS}}var US={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function lV($){return US[$]??null}var XS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},YS={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"},wS=($)=>{switch($.code){case"invalid_type":return`Input tidak valid: diharapkan ${$.expected}, diterima ${XS($.input)}`;case"invalid_value":if($.values.length===1)return`Input tidak valid: diharapkan ${r($.values[0])}`;return`Pilihan tidak valid: diharapkan salah satu dari ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=lV($.origin);if(W)return`Terlalu besar: diharapkan ${$.origin??"value"} memiliki ${T}${$.maximum.toString()} ${W.unit??"elemen"}`;return`Terlalu besar: diharapkan ${$.origin??"value"} menjadi ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=lV($.origin);if(W)return`Terlalu kecil: diharapkan ${$.origin} memiliki ${T}${$.minimum.toString()} ${W.unit}`;return`Terlalu kecil: diharapkan ${$.origin} menjadi ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`String tidak valid: harus dimulai dengan "${T.prefix}"`;if(T.format==="ends_with")return`String tidak valid: harus berakhir dengan "${T.suffix}"`;if(T.format==="includes")return`String tidak valid: harus menyertakan "${T.includes}"`;if(T.format==="regex")return`String tidak valid: harus sesuai pola ${T.pattern}`;return`${YS[T.format]??$.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${$.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${$.keys.length>1?"s":""}: ${I($.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${$.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${$.origin}`;default:return"Input tidak valid"}};function x3(){return{localeError:wS}}var GS={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function rV($){return GS[$]??null}var zS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"numero";case"object":{if(Array.isArray($))return"vettore";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},HS={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"},FS=($)=>{switch($.code){case"invalid_type":return`Input non valido: atteso ${$.expected}, ricevuto ${zS($.input)}`;case"invalid_value":if($.values.length===1)return`Input non valido: atteso ${r($.values[0])}`;return`Opzione non valida: atteso uno tra ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=rV($.origin);if(W)return`Troppo grande: ${$.origin??"valore"} deve avere ${T}${$.maximum.toString()} ${W.unit??"elementi"}`;return`Troppo grande: ${$.origin??"valore"} deve essere ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=rV($.origin);if(W)return`Troppo piccolo: ${$.origin} deve avere ${T}${$.minimum.toString()} ${W.unit}`;return`Troppo piccolo: ${$.origin} deve essere ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Stringa non valida: deve iniziare con "${T.prefix}"`;if(T.format==="ends_with")return`Stringa non valida: deve terminare con "${T.suffix}"`;if(T.format==="includes")return`Stringa non valida: deve includere "${T.includes}"`;if(T.format==="regex")return`Stringa non valida: deve corrispondere al pattern ${T.pattern}`;return`Invalid ${HS[T.format]??$.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${$.divisor}`;case"unrecognized_keys":return`Chiav${$.keys.length>1?"i":"e"} non riconosciut${$.keys.length>1?"e":"a"}: ${I($.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${$.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${$.origin}`;default:return"Input non valido"}};function I3(){return{localeError:FS}}var OS={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 nV($){return OS[$]??null}var QS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u6570\u5024";case"object":{if(Array.isArray($))return"\u914D\u5217";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},ZS={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"},DS=($)=>{switch($.code){case"invalid_type":return`\u7121\u52B9\u306A\u5165\u529B: ${$.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${QS($.input)}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`;case"invalid_value":if($.values.length===1)return`\u7121\u52B9\u306A\u5165\u529B: ${r($.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`;return`\u7121\u52B9\u306A\u9078\u629E: ${I($.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let T=$.inclusive?"<=":"<",W=nV($.origin);if(W)return`\u5927\u304D\u3059\u304E\u308B\u5024: ${$.origin??"\u5024"}\u306F${$.maximum.toString()}${W.unit??"\u8981\u7D20"}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5927\u304D\u3059\u304E\u308B\u5024: ${$.origin??"\u5024"}\u306F${$.maximum.toString()}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let T=$.inclusive?">=":">",W=nV($.origin);if(W)return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${$.origin}\u306F${$.minimum.toString()}${W.unit}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${$.origin}\u306F${$.minimum.toString()}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${T.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(T.format==="ends_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${T.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(T.format==="includes")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${T.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(T.format==="regex")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${T.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u7121\u52B9\u306A${ZS[T.format]??$.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${$.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${$.keys.length>1?"\u7FA4":""}: ${I($.keys,"\u3001")}`;case"invalid_key":return`${$.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${$.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}};function b3(){return{localeError:DS}}var VS={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 iV($){return VS[$]??null}var KS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u1798\u17B7\u1793\u1798\u17C2\u1793\u1787\u17B6\u179B\u17C1\u1781 (NaN)":"\u179B\u17C1\u1781";case"object":{if(Array.isArray($))return"\u17A2\u17B6\u179A\u17C1 (Array)";if($===null)return"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},ES={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"},AS=($)=>{switch($.code){case"invalid_type":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 ${$.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${KS($.input)}`;case"invalid_value":if($.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 ${r($.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 ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=iV($.origin);if(W)return`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${$.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${T} ${$.maximum.toString()} ${W.unit??"\u1792\u17B6\u178F\u17BB"}`;return`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${$.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=iV($.origin);if(W)return`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${$.origin} ${T} ${$.minimum.toString()} ${W.unit}`;return`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${$.origin} ${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${ES[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${I($.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 ${$.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 ${$.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}};function f3(){return{localeError:AS}}var MS={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 tV($){return MS[$]??null}var NS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},LS={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"},JS=($)=>{switch($.code){case"invalid_type":return`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${$.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${NS($.input)}\uC785\uB2C8\uB2E4`;case"invalid_value":if($.values.length===1)return`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${r($.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C \uC635\uC158: ${I($.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let T=$.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",W=T==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",U=tV($.origin),X=U?.unit??"\uC694\uC18C";if(U)return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${$.maximum.toString()}${X} ${T}${W}`;return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${$.maximum.toString()} ${T}${W}`}case"too_small":{let T=$.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",W=T==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",U=tV($.origin),X=U?.unit??"\uC694\uC18C";if(U)return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${$.minimum.toString()}${X} ${T}${W}`;return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${$.minimum.toString()} ${T}${W}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${T.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`;if(T.format==="ends_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${T.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`;if(T.format==="includes")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${T.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`;if(T.format==="regex")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${T.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C ${LS[T.format]??$.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${$.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${I($.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${$.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${$.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}};function y3(){return{localeError:JS}}var _S={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 aV($){return _S[$]??null}var RS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0431\u0440\u043E\u0458";case"object":{if(Array.isArray($))return"\u043D\u0438\u0437\u0430";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},kS={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"},vS=($)=>{switch($.code){case"invalid_type":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${RS($.input)}`;case"invalid_value":if($.values.length===1)return`Invalid input: expected ${r($.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 ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=aV($.origin);if(W)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${T}${$.maximum.toString()} ${W.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 ${$.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=aV($.origin);if(W)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.origin} \u0434\u0430 \u0438\u043C\u0430 ${T}${$.minimum.toString()} ${W.unit}`;return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`Invalid ${kS[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`${$.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"}: ${I($.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${$.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 ${$.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}};function h3(){return{localeError:vS}}var qS={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function sV($){return qS[$]??null}var PS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"nombor";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},CS={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"},SS=($)=>{switch($.code){case"invalid_type":return`Input tidak sah: dijangka ${$.expected}, diterima ${PS($.input)}`;case"invalid_value":if($.values.length===1)return`Input tidak sah: dijangka ${r($.values[0])}`;return`Pilihan tidak sah: dijangka salah satu daripada ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=sV($.origin);if(W)return`Terlalu besar: dijangka ${$.origin??"nilai"} ${W.verb} ${T}${$.maximum.toString()} ${W.unit??"elemen"}`;return`Terlalu besar: dijangka ${$.origin??"nilai"} adalah ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=sV($.origin);if(W)return`Terlalu kecil: dijangka ${$.origin} ${W.verb} ${T}${$.minimum.toString()} ${W.unit}`;return`Terlalu kecil: dijangka ${$.origin} adalah ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`String tidak sah: mesti bermula dengan "${T.prefix}"`;if(T.format==="ends_with")return`String tidak sah: mesti berakhir dengan "${T.suffix}"`;if(T.format==="includes")return`String tidak sah: mesti mengandungi "${T.includes}"`;if(T.format==="regex")return`String tidak sah: mesti sepadan dengan corak ${T.pattern}`;return`${CS[T.format]??$.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${$.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${I($.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${$.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${$.origin}`;default:return"Input tidak sah"}};function g3(){return{localeError:SS}}var jS={string:{unit:"tekens"},file:{unit:"bytes"},array:{unit:"elementen"},set:{unit:"elementen"}};function eV($){return jS[$]??null}var BS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"getal";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},xS={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"},IS=($)=>{switch($.code){case"invalid_type":return`Ongeldige invoer: verwacht ${$.expected}, ontving ${BS($.input)}`;case"invalid_value":if($.values.length===1)return`Ongeldige invoer: verwacht ${r($.values[0])}`;return`Ongeldige optie: verwacht \xE9\xE9n van ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=eV($.origin);if(W)return`Te lang: verwacht dat ${$.origin??"waarde"} ${T}${$.maximum.toString()} ${W.unit??"elementen"} bevat`;return`Te lang: verwacht dat ${$.origin??"waarde"} ${T}${$.maximum.toString()} is`}case"too_small":{let T=$.inclusive?">=":">",W=eV($.origin);if(W)return`Te kort: verwacht dat ${$.origin} ${T}${$.minimum.toString()} ${W.unit} bevat`;return`Te kort: verwacht dat ${$.origin} ${T}${$.minimum.toString()} is`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ongeldige tekst: moet met "${T.prefix}" beginnen`;if(T.format==="ends_with")return`Ongeldige tekst: moet op "${T.suffix}" eindigen`;if(T.format==="includes")return`Ongeldige tekst: moet "${T.includes}" bevatten`;if(T.format==="regex")return`Ongeldige tekst: moet overeenkomen met patroon ${T.pattern}`;return`Ongeldig: ${xS[T.format]??$.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${$.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${$.keys.length>1?"s":""}: ${I($.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${$.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${$.origin}`;default:return"Ongeldige invoer"}};function m3(){return{localeError:IS}}var bS={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 $K($){return bS[$]??null}var fS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"tall";case"object":{if(Array.isArray($))return"liste";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},yS={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"},hS=($)=>{switch($.code){case"invalid_type":return`Ugyldig input: forventet ${$.expected}, fikk ${fS($.input)}`;case"invalid_value":if($.values.length===1)return`Ugyldig verdi: forventet ${r($.values[0])}`;return`Ugyldig valg: forventet en av ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=$K($.origin);if(W)return`For stor(t): forventet ${$.origin??"value"} til \xE5 ha ${T}${$.maximum.toString()} ${W.unit??"elementer"}`;return`For stor(t): forventet ${$.origin??"value"} til \xE5 ha ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=$K($.origin);if(W)return`For lite(n): forventet ${$.origin} til \xE5 ha ${T}${$.minimum.toString()} ${W.unit}`;return`For lite(n): forventet ${$.origin} til \xE5 ha ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ugyldig streng: m\xE5 starte med "${T.prefix}"`;if(T.format==="ends_with")return`Ugyldig streng: m\xE5 ende med "${T.suffix}"`;if(T.format==="includes")return`Ugyldig streng: m\xE5 inneholde "${T.includes}"`;if(T.format==="regex")return`Ugyldig streng: m\xE5 matche m\xF8nsteret ${T.pattern}`;return`Ugyldig ${yS[T.format]??$.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${$.divisor}`;case"unrecognized_keys":return`${$.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${I($.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${$.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${$.origin}`;default:return"Ugyldig input"}};function c3(){return{localeError:hS}}var gS={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 TK($){return gS[$]??null}var mS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"numara";case"object":{if(Array.isArray($))return"saf";if($===null)return"gayb";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},cS={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"},uS=($)=>{switch($.code){case"invalid_type":return`F\xE2sit giren: umulan ${$.expected}, al\u0131nan ${mS($.input)}`;case"invalid_value":if($.values.length===1)return`F\xE2sit giren: umulan ${r($.values[0])}`;return`F\xE2sit tercih: m\xFBteberler ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=TK($.origin);if(W)return`Fazla b\xFCy\xFCk: ${$.origin??"value"}, ${T}${$.maximum.toString()} ${W.unit??"elements"} sahip olmal\u0131yd\u0131.`;return`Fazla b\xFCy\xFCk: ${$.origin??"value"}, ${T}${$.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let T=$.inclusive?">=":">",W=TK($.origin);if(W)return`Fazla k\xFC\xE7\xFCk: ${$.origin}, ${T}${$.minimum.toString()} ${W.unit} sahip olmal\u0131yd\u0131.`;return`Fazla k\xFC\xE7\xFCk: ${$.origin}, ${T}${$.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`F\xE2sit metin: "${T.prefix}" ile ba\u015Flamal\u0131.`;if(T.format==="ends_with")return`F\xE2sit metin: "${T.suffix}" ile bitmeli.`;if(T.format==="includes")return`F\xE2sit metin: "${T.includes}" ihtiv\xE2 etmeli.`;if(T.format==="regex")return`F\xE2sit metin: ${T.pattern} nak\u015F\u0131na uymal\u0131.`;return`F\xE2sit ${cS[T.format]??$.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${$.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${$.keys.length>1?"s":""}: ${I($.keys,", ")}`;case"invalid_key":return`${$.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${$.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}};function u3(){return{localeError:uS}}var pS={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 WK($){return pS[$]??null}var dS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"liczba";case"object":{if(Array.isArray($))return"tablica";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},oS={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"},lS=($)=>{switch($.code){case"invalid_type":return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${$.expected}, otrzymano ${dS($.input)}`;case"invalid_value":if($.values.length===1)return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${r($.values[0])}`;return`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=WK($.origin);if(W)return`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${T}${$.maximum.toString()} ${W.unit??"element\xF3w"}`;return`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=WK($.origin);if(W)return`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${T}${$.minimum.toString()} ${W.unit??"element\xF3w"}`;return`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${T.prefix}"`;if(T.format==="ends_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${T.suffix}"`;if(T.format==="includes")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${T.includes}"`;if(T.format==="regex")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${T.pattern}`;return`Nieprawid\u0142ow(y/a/e) ${oS[T.format]??$.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${$.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${$.keys.length>1?"s":""}: ${I($.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${$.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${$.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}};function p3(){return{localeError:lS}}var rS={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function UK($){return rS[$]??null}var nS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"n\xFAmero";case"object":{if(Array.isArray($))return"array";if($===null)return"nulo";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},iS={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"},tS=($)=>{switch($.code){case"invalid_type":return`Tipo inv\xE1lido: esperado ${$.expected}, recebido ${nS($.input)}`;case"invalid_value":if($.values.length===1)return`Entrada inv\xE1lida: esperado ${r($.values[0])}`;return`Op\xE7\xE3o inv\xE1lida: esperada uma das ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=UK($.origin);if(W)return`Muito grande: esperado que ${$.origin??"valor"} tivesse ${T}${$.maximum.toString()} ${W.unit??"elementos"}`;return`Muito grande: esperado que ${$.origin??"valor"} fosse ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=UK($.origin);if(W)return`Muito pequeno: esperado que ${$.origin} tivesse ${T}${$.minimum.toString()} ${W.unit}`;return`Muito pequeno: esperado que ${$.origin} fosse ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Texto inv\xE1lido: deve come\xE7ar com "${T.prefix}"`;if(T.format==="ends_with")return`Texto inv\xE1lido: deve terminar com "${T.suffix}"`;if(T.format==="includes")return`Texto inv\xE1lido: deve incluir "${T.includes}"`;if(T.format==="regex")return`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${T.pattern}`;return`${iS[T.format]??$.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${$.divisor}`;case"unrecognized_keys":return`Chave${$.keys.length>1?"s":""} desconhecida${$.keys.length>1?"s":""}: ${I($.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${$.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${$.origin}`;default:return"Campo inv\xE1lido"}};function d3(){return{localeError:tS}}function XK($,T,W,U){let X=Math.abs($),Y=X%10,w=X%100;if(w>=11&&w<=19)return U;if(Y===1)return T;if(Y>=2&&Y<=4)return W;return U}var aS={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 YK($){return aS[$]??null}var sS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0447\u0438\u0441\u043B\u043E";case"object":{if(Array.isArray($))return"\u043C\u0430\u0441\u0441\u0438\u0432";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},eS={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"},$j=($)=>{switch($.code){case"invalid_type":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${$.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${sS($.input)}`;case"invalid_value":if($.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 ${r($.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 ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=YK($.origin);if(W){let U=Number($.maximum),X=XK(U,W.unit.one,W.unit.few,W.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 ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${T}${$.maximum.toString()} ${X}`}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 ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=YK($.origin);if(W){let U=Number($.minimum),X=XK(U,W.unit.one,W.unit.few,W.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 ${$.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${T}${$.minimum.toString()} ${X}`}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 ${$.origin} \u0431\u0443\u0434\u0435\u0442 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${eS[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${$.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${$.keys.length>1?"\u0438":""}: ${I($.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${$.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 ${$.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}};function o3(){return{localeError:$j}}var Tj={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function wK($){return Tj[$]??null}var Wj=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0161tevilo";case"object":{if(Array.isArray($))return"tabela";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},Uj={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"},Xj=($)=>{switch($.code){case"invalid_type":return`Neveljaven vnos: pri\u010Dakovano ${$.expected}, prejeto ${Wj($.input)}`;case"invalid_value":if($.values.length===1)return`Neveljaven vnos: pri\u010Dakovano ${r($.values[0])}`;return`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=wK($.origin);if(W)return`Preveliko: pri\u010Dakovano, da bo ${$.origin??"vrednost"} imelo ${T}${$.maximum.toString()} ${W.unit??"elementov"}`;return`Preveliko: pri\u010Dakovano, da bo ${$.origin??"vrednost"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=wK($.origin);if(W)return`Premajhno: pri\u010Dakovano, da bo ${$.origin} imelo ${T}${$.minimum.toString()} ${W.unit}`;return`Premajhno: pri\u010Dakovano, da bo ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Neveljaven niz: mora se za\u010Deti z "${T.prefix}"`;if(T.format==="ends_with")return`Neveljaven niz: mora se kon\u010Dati z "${T.suffix}"`;if(T.format==="includes")return`Neveljaven niz: mora vsebovati "${T.includes}"`;if(T.format==="regex")return`Neveljaven niz: mora ustrezati vzorcu ${T.pattern}`;return`Neveljaven ${Uj[T.format]??$.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${$.divisor}`;case"unrecognized_keys":return`Neprepoznan${$.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${I($.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${$.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${$.origin}`;default:return"Neveljaven vnos"}};function l3(){return{localeError:Xj}}var Yj={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 GK($){return Yj[$]??null}var wj=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"antal";case"object":{if(Array.isArray($))return"lista";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},Gj={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"},zj=($)=>{switch($.code){case"invalid_type":return`Ogiltig inmatning: f\xF6rv\xE4ntat ${$.expected}, fick ${wj($.input)}`;case"invalid_value":if($.values.length===1)return`Ogiltig inmatning: f\xF6rv\xE4ntat ${r($.values[0])}`;return`Ogiltigt val: f\xF6rv\xE4ntade en av ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=GK($.origin);if(W)return`F\xF6r stor(t): f\xF6rv\xE4ntade ${$.origin??"v\xE4rdet"} att ha ${T}${$.maximum.toString()} ${W.unit??"element"}`;return`F\xF6r stor(t): f\xF6rv\xE4ntat ${$.origin??"v\xE4rdet"} att ha ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=GK($.origin);if(W)return`F\xF6r lite(t): f\xF6rv\xE4ntade ${$.origin??"v\xE4rdet"} att ha ${T}${$.minimum.toString()} ${W.unit}`;return`F\xF6r lite(t): f\xF6rv\xE4ntade ${$.origin??"v\xE4rdet"} att ha ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${T.prefix}"`;if(T.format==="ends_with")return`Ogiltig str\xE4ng: m\xE5ste sluta med "${T.suffix}"`;if(T.format==="includes")return`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${T.includes}"`;if(T.format==="regex")return`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${T.pattern}"`;return`Ogiltig(t) ${Gj[T.format]??$.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${$.divisor}`;case"unrecognized_keys":return`${$.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${I($.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${$.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${$.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}};function r3(){return{localeError:zj}}var Hj={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 zK($){return Hj[$]??null}var Fj=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u0B8E\u0BA3\u0BCD \u0B85\u0BB2\u0BCD\u0BB2\u0BBE\u0BA4\u0BA4\u0BC1":"\u0B8E\u0BA3\u0BCD";case"object":{if(Array.isArray($))return"\u0B85\u0BA3\u0BBF";if($===null)return"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},Oj={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"},Qj=($)=>{switch($.code){case"invalid_type":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 ${$.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${Fj($.input)}`;case"invalid_value":if($.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 ${r($.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 ${I($.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let T=$.inclusive?"<=":"<",W=zK($.origin);if(W)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 ${$.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${T}${$.maximum.toString()} ${W.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 ${$.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${T}${$.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let T=$.inclusive?">=":">",W=zK($.origin);if(W)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 ${$.origin} ${T}${$.minimum.toString()} ${W.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 ${$.origin} ${T}${$.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${T.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(T.format==="ends_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${T.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(T.format==="includes")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${T.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(T.format==="regex")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${T.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 ${Oj[T.format]??$.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${$.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${$.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${I($.keys,", ")}`;case"invalid_key":return`${$.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`${$.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"}};function n3(){return{localeError:Qj}}var Zj={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 HK($){return Zj[$]??null}var Dj=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u0E44\u0E21\u0E48\u0E43\u0E0A\u0E48\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02 (NaN)":"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02";case"object":{if(Array.isArray($))return"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)";if($===null)return"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},Vj={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"},Kj=($)=>{switch($.code){case"invalid_type":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 ${$.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${Dj($.input)}`;case"invalid_value":if($.values.length===1)return`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${r($.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 ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",W=HK($.origin);if(W)return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.maximum.toString()} ${W.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`;return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",W=HK($.origin);if(W)return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.minimum.toString()} ${W.unit}`;return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`;if(T.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 ${T.pattern}`;return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${Vj[T.format]??$.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 ${$.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: ${I($.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${$.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 ${$.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}};function i3(){return{localeError:Kj}}var Ej={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 FK($){return Ej[$]??null}var Aj=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},Mj={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"},Nj=($)=>{switch($.code){case"invalid_type":return`Ge\xE7ersiz de\u011Fer: beklenen ${$.expected}, al\u0131nan ${Aj($.input)}`;case"invalid_value":if($.values.length===1)return`Ge\xE7ersiz de\u011Fer: beklenen ${r($.values[0])}`;return`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=FK($.origin);if(W)return`\xC7ok b\xFCy\xFCk: beklenen ${$.origin??"de\u011Fer"} ${T}${$.maximum.toString()} ${W.unit??"\xF6\u011Fe"}`;return`\xC7ok b\xFCy\xFCk: beklenen ${$.origin??"de\u011Fer"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=FK($.origin);if(W)return`\xC7ok k\xFC\xE7\xFCk: beklenen ${$.origin} ${T}${$.minimum.toString()} ${W.unit}`;return`\xC7ok k\xFC\xE7\xFCk: beklenen ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ge\xE7ersiz metin: "${T.prefix}" ile ba\u015Flamal\u0131`;if(T.format==="ends_with")return`Ge\xE7ersiz metin: "${T.suffix}" ile bitmeli`;if(T.format==="includes")return`Ge\xE7ersiz metin: "${T.includes}" i\xE7ermeli`;if(T.format==="regex")return`Ge\xE7ersiz metin: ${T.pattern} desenine uymal\u0131`;return`Ge\xE7ersiz ${Mj[T.format]??$.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${$.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${$.keys.length>1?"lar":""}: ${I($.keys,", ")}`;case"invalid_key":return`${$.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${$.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}};function t3(){return{localeError:Nj}}var Lj={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 OK($){return Lj[$]??null}var Jj=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0447\u0438\u0441\u043B\u043E";case"object":{if(Array.isArray($))return"\u043C\u0430\u0441\u0438\u0432";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},_j={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"},Rj=($)=>{switch($.code){case"invalid_type":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 ${$.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${Jj($.input)}`;case"invalid_value":if($.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 ${r($.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 ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=OK($.origin);if(W)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 ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${W.verb} ${T}${$.maximum.toString()} ${W.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 ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=OK($.origin);if(W)return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${$.origin} ${W.verb} ${T}${$.minimum.toString()} ${W.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 ${$.origin} \u0431\u0443\u0434\u0435 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.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 "${T.prefix}"`;if(T.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 "${T.suffix}"`;if(T.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 "${T.includes}"`;if(T.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 ${T.pattern}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${_j[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${$.keys.length>1?"\u0456":""}: ${I($.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${$.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 ${$.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}};function a3(){return{localeError:Rj}}var kj={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 QK($){return kj[$]??null}var vj=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0646\u0645\u0628\u0631";case"object":{if(Array.isArray($))return"\u0622\u0631\u06D2";if($===null)return"\u0646\u0644";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},qj={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"},Pj=($)=>{switch($.code){case"invalid_type":return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${$.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${vj($.input)} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`;case"invalid_value":if($.values.length===1)return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${r($.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;return`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${I($.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let T=$.inclusive?"<=":"<",W=QK($.origin);if(W)return`\u0628\u06C1\u062A \u0628\u0691\u0627: ${$.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${T}${$.maximum.toString()} ${W.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: ${$.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${T}${$.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let T=$.inclusive?">=":">",W=QK($.origin);if(W)return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${$.origin} \u06A9\u06D2 ${T}${$.minimum.toString()} ${W.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`;return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${$.origin} \u06A9\u0627 ${T}${$.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${T.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(T.format==="ends_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${T.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(T.format==="includes")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${T.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(T.format==="regex")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${T.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;return`\u063A\u0644\u0637 ${qj[T.format]??$.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${$.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${$.keys.length>1?"\u0632":""}: ${I($.keys,"\u060C ")}`;case"invalid_key":return`${$.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${$.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}};function s3(){return{localeError:Pj}}var Cj={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 ZK($){return Cj[$]??null}var Sj=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"s\u1ED1";case"object":{if(Array.isArray($))return"m\u1EA3ng";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},jj={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"},Bj=($)=>{switch($.code){case"invalid_type":return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${$.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${Sj($.input)}`;case"invalid_value":if($.values.length===1)return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${r($.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 ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=ZK($.origin);if(W)return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${$.origin??"gi\xE1 tr\u1ECB"} ${W.verb} ${T}${$.maximum.toString()} ${W.unit??"ph\u1EA7n t\u1EED"}`;return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${$.origin??"gi\xE1 tr\u1ECB"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=ZK($.origin);if(W)return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${$.origin} ${W.verb} ${T}${$.minimum.toString()} ${W.unit}`;return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${T.prefix}"`;if(T.format==="ends_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${T.suffix}"`;if(T.format==="includes")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${T.includes}"`;if(T.format==="regex")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${T.pattern}`;return`${jj[T.format]??$.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 ${$.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${I($.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${$.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 ${$.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}};function e3(){return{localeError:Bj}}var xj={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 DK($){return xj[$]??null}var Ij=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u975E\u6570\u5B57(NaN)":"\u6570\u5B57";case"object":{if(Array.isArray($))return"\u6570\u7EC4";if($===null)return"\u7A7A\u503C(null)";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},bj={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"},fj=($)=>{switch($.code){case"invalid_type":return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${$.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${Ij($.input)}`;case"invalid_value":if($.values.length===1)return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${r($.values[0])}`;return`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=DK($.origin);if(W)return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${$.origin??"\u503C"} ${T}${$.maximum.toString()} ${W.unit??"\u4E2A\u5143\u7D20"}`;return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${$.origin??"\u503C"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=DK($.origin);if(W)return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${$.origin} ${T}${$.minimum.toString()} ${W.unit}`;return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${T.prefix}" \u5F00\u5934`;if(T.format==="ends_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${T.suffix}" \u7ED3\u5C3E`;if(T.format==="includes")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${T.includes}"`;if(T.format==="regex")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${T.pattern}`;return`\u65E0\u6548${bj[T.format]??$.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${$.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${I($.keys,", ")}`;case"invalid_key":return`${$.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${$.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}};function $H(){return{localeError:fj}}var yj={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 VK($){return yj[$]??null}var hj=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},gj={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"},mj=($)=>{switch($.code){case"invalid_type":return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${$.expected}\uFF0C\u4F46\u6536\u5230 ${hj($.input)}`;case"invalid_value":if($.values.length===1)return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${r($.values[0])}`;return`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${I($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=VK($.origin);if(W)return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${$.origin??"\u503C"} \u61C9\u70BA ${T}${$.maximum.toString()} ${W.unit??"\u500B\u5143\u7D20"}`;return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${$.origin??"\u503C"} \u61C9\u70BA ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=VK($.origin);if(W)return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${$.origin} \u61C9\u70BA ${T}${$.minimum.toString()} ${W.unit}`;return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${$.origin} \u61C9\u70BA ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${T.prefix}" \u958B\u982D`;if(T.format==="ends_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${T.suffix}" \u7D50\u5C3E`;if(T.format==="includes")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${T.includes}"`;if(T.format==="regex")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${T.pattern}`;return`\u7121\u6548\u7684 ${gj[T.format]??$.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${$.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${$.keys.length>1?"\u5011":""}\uFF1A${I($.keys,"\u3001")}`;case"invalid_key":return`${$.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${$.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}};function TH(){return{localeError:mj}}var WH=Symbol("ZodOutput"),UH=Symbol("ZodInput");class wX{constructor(){this._map=new WeakMap,this._idmap=new Map}add($,...T){let W=T[0];if(this._map.set($,W),W&&typeof W==="object"&&"id"in W){if(this._idmap.has(W.id))throw new Error(`ID ${W.id} already exists in the registry`);this._idmap.set(W.id,$)}return this}remove($){return this._map.delete($),this}get($){let T=$._zod.parent;if(T){let W={...this.get(T)??{}};return delete W.id,{...W,...this._map.get($)}}return this._map.get($)}has($){return this._map.has($)}}function Cw(){return new wX}var n1=Cw();function XH($,T){return new $({type:"string",...c(T)})}function YH($,T){return new $({type:"string",coerce:!0,...c(T)})}function Sw($,T){return new $({type:"string",format:"email",check:"string_format",abort:!1,...c(T)})}function GX($,T){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...c(T)})}function jw($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...c(T)})}function Bw($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...c(T)})}function xw($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...c(T)})}function Iw($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...c(T)})}function bw($,T){return new $({type:"string",format:"url",check:"string_format",abort:!1,...c(T)})}function fw($,T){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...c(T)})}function yw($,T){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...c(T)})}function hw($,T){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...c(T)})}function gw($,T){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...c(T)})}function mw($,T){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...c(T)})}function cw($,T){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...c(T)})}function uw($,T){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...c(T)})}function pw($,T){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...c(T)})}function dw($,T){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...c(T)})}function ow($,T){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...c(T)})}function lw($,T){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...c(T)})}function rw($,T){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...c(T)})}function nw($,T){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...c(T)})}function iw($,T){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...c(T)})}function tw($,T){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...c(T)})}function wH($,T){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...c(T)})}function GH($,T){return new $({type:"string",format:"date",check:"string_format",...c(T)})}function zH($,T){return new $({type:"string",format:"time",check:"string_format",precision:null,...c(T)})}function HH($,T){return new $({type:"string",format:"duration",check:"string_format",...c(T)})}function FH($,T){return new $({type:"number",checks:[],...c(T)})}function OH($,T){return new $({type:"number",coerce:!0,checks:[],...c(T)})}function QH($,T){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...c(T)})}function ZH($,T){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...c(T)})}function DH($,T){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...c(T)})}function VH($,T){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...c(T)})}function KH($,T){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...c(T)})}function EH($,T){return new $({type:"boolean",...c(T)})}function AH($,T){return new $({type:"boolean",coerce:!0,...c(T)})}function MH($,T){return new $({type:"bigint",...c(T)})}function NH($,T){return new $({type:"bigint",coerce:!0,...c(T)})}function LH($,T){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...c(T)})}function JH($,T){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...c(T)})}function _H($,T){return new $({type:"symbol",...c(T)})}function RH($,T){return new $({type:"undefined",...c(T)})}function kH($,T){return new $({type:"null",...c(T)})}function vH($){return new $({type:"any"})}function qH($){return new $({type:"unknown"})}function PH($,T){return new $({type:"never",...c(T)})}function CH($,T){return new $({type:"void",...c(T)})}function SH($,T){return new $({type:"date",...c(T)})}function jH($,T){return new $({type:"date",coerce:!0,...c(T)})}function BH($,T){return new $({type:"nan",...c(T)})}function V0($,T){return new Lw({check:"less_than",...c(T),value:$,inclusive:!1})}function D1($,T){return new Lw({check:"less_than",...c(T),value:$,inclusive:!0})}function K0($,T){return new Jw({check:"greater_than",...c(T),value:$,inclusive:!1})}function j6($,T){return new Jw({check:"greater_than",...c(T),value:$,inclusive:!0})}function xH($){return K0(0,$)}function IH($){return V0(0,$)}function bH($){return D1(0,$)}function fH($){return j6(0,$)}function sT($,T){return new a5({check:"multiple_of",...c(T),value:$})}function X2($,T){return new $7({check:"max_size",...c(T),maximum:$})}function eT($,T){return new T7({check:"min_size",...c(T),minimum:$})}function zX($,T){return new W7({check:"size_equals",...c(T),size:$})}function Y2($,T){return new U7({check:"max_length",...c(T),maximum:$})}function ZT($,T){return new X7({check:"min_length",...c(T),minimum:$})}function w2($,T){return new Y7({check:"length_equals",...c(T),length:$})}function HX($,T){return new w7({check:"string_format",format:"regex",...c(T),pattern:$})}function FX($){return new G7({check:"string_format",format:"lowercase",...c($)})}function OX($){return new z7({check:"string_format",format:"uppercase",...c($)})}function QX($,T){return new H7({check:"string_format",format:"includes",...c(T),includes:$})}function ZX($,T){return new F7({check:"string_format",format:"starts_with",...c(T),prefix:$})}function DX($,T){return new O7({check:"string_format",format:"ends_with",...c(T),suffix:$})}function yH($,T,W){return new Q7({check:"property",property:$,schema:T,...c(W)})}function VX($,T){return new Z7({check:"mime_type",mime:$,...c(T)})}function E0($){return new D7({check:"overwrite",tx:$})}function KX($){return E0((T)=>T.normalize($))}function EX(){return E0(($)=>$.trim())}function AX(){return E0(($)=>$.toLowerCase())}function MX(){return E0(($)=>$.toUpperCase())}function hH($,T,W){return new $({type:"array",element:T,...c(W)})}function cj($,T,W){return new $({type:"union",options:T,...c(W)})}function uj($,T,W,U){return new $({type:"union",options:W,discriminator:T,...c(U)})}function pj($,T,W){return new $({type:"intersection",left:T,right:W})}function gH($,T,W,U){let X=W instanceof Q$;return new $({type:"tuple",items:T,rest:X?W:null,...c(X?U:W)})}function dj($,T,W,U){return new $({type:"record",keyType:T,valueType:W,...c(U)})}function oj($,T,W,U){return new $({type:"map",keyType:T,valueType:W,...c(U)})}function lj($,T,W){return new $({type:"set",valueType:T,...c(W)})}function rj($,T,W){let U=Array.isArray(T)?Object.fromEntries(T.map((X)=>[X,X])):T;return new $({type:"enum",entries:U,...c(W)})}function nj($,T,W){return new $({type:"enum",entries:T,...c(W)})}function ij($,T,W){return new $({type:"literal",values:Array.isArray(T)?T:[T],...c(W)})}function mH($,T){return new $({type:"file",...c(T)})}function tj($,T){return new $({type:"transform",transform:T})}function aj($,T){return new $({type:"optional",innerType:T})}function sj($,T){return new $({type:"nullable",innerType:T})}function ej($,T,W){return new $({type:"default",innerType:T,get defaultValue(){return typeof W==="function"?W():W}})}function $B($,T,W){return new $({type:"nonoptional",innerType:T,...c(W)})}function TB($,T){return new $({type:"success",innerType:T})}function WB($,T,W){return new $({type:"catch",innerType:T,catchValue:typeof W==="function"?W:()=>W})}function UB($,T,W){return new $({type:"pipe",in:T,out:W})}function XB($,T){return new $({type:"readonly",innerType:T})}function YB($,T,W){return new $({type:"template_literal",parts:T,...c(W)})}function wB($,T){return new $({type:"lazy",getter:T})}function GB($,T){return new $({type:"promise",innerType:T})}function NX($,T,W){return new $({type:"custom",check:"custom",fn:T,...c(W)})}function zB($,T,W={}){return NX($,T,W)}function cH($,T){let{case:W,error:U,truthy:X,falsy:Y}=c(T),w=new Set(X??["true","1","yes","on","y","enabled"]),G=new Set(Y??["false","0","no","off","n","disabled"]),H=$.Pipe??UX,z=$.Boolean??TX,O=new($.Unknown??WX)({type:"unknown",checks:[{_zod:{check:(Q)=>{if(typeof Q.value==="string"){let Z=Q.value;if(W!=="sensitive")Z=Z.toLowerCase();if(w.has(Z))Q.value=!0;else if(G.has(Z))Q.value=!1;else Q.issues.push({code:"invalid_value",expected:"stringbool",values:[...w,...G],input:Q.value,inst:O})}else Q.issues.push({code:"invalid_type",expected:"string",input:Q.value})},def:{check:"custom"},onattach:[]}}],error:U});return new H({type:"pipe",in:O,out:new z({type:"boolean",error:U}),error:U})}class G2{constructor($){this._def=$,this.def=$}implement($){if(typeof $!=="function")throw new Error("implement() must be called with a function");let T=(...W)=>{let U=this._def.input?Zw(this._def.input,W,void 0,{callee:T}):W;if(!Array.isArray(U))throw new Error("Invalid arguments schema: not an array or tuple schema.");let X=$(...U);return this._def.output?Zw(this._def.output,X,void 0,{callee:T}):X};return T}implementAsync($){if(typeof $!=="function")throw new Error("implement() must be called with a function");let T=async(...W)=>{let U=this._def.input?await Vw(this._def.input,W,void 0,{callee:T}):W;if(!Array.isArray(U))throw new Error("Invalid arguments schema: not an array or tuple schema.");let X=await $(...U);return this._def.output?Vw(this._def.output,X,void 0,{callee:T}):X};return T}input(...$){if(Array.isArray($[0]))return new G2({type:"function",input:new aT({type:"tuple",items:$[0],rest:$[1]}),output:this._def.output});return new G2({type:"function",input:$[0],output:this._def.output})}output($){return new G2({type:"function",input:this._def.input,output:$})}}function uH($){return new G2({type:"function",input:Array.isArray($?.input)?gH(aT,$?.input):$?.input??null,output:$?.output??null})}var HB={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};class aw{constructor($){this.counter=0,this.metadataRegistry=$?.metadata??n1,this.target=$?.target??"draft-2020-12",this.unrepresentable=$?.unrepresentable??"throw",this.override=$?.override??(()=>{}),this.io=$?.io??"output",this.seen=new Map}process($,T={path:[],schemaPath:[]}){var W;let U=$._zod.def,X=this.seen.get($);if(X){if(X.count++,T.schemaPath.includes($))X.cycle=T.path;return X.count++,X.schema}let Y={schema:{},count:1,cycle:void 0};if(this.seen.set($,Y),$._zod.toJSONSchema)Y.schema=$._zod.toJSONSchema();let w={...T,schemaPath:[...T.schemaPath,$],path:T.path},G=$._zod.parent;if(G)Y.ref=G,this.process(G,w),this.seen.get(G).isParent=!0;else{let F=Y.schema;switch(U.type){case"string":{let O=F;O.type="string";let{minimum:Q,maximum:Z,format:V,patterns:E,contentEncoding:N}=$._zod.bag;if(typeof Q==="number")O.minLength=Q;if(typeof Z==="number")O.maxLength=Z;if(V){if(O.format=HB[V]??V,O.format==="")delete O.format}if(N)O.contentEncoding=N;if(E&&E.size>0){let J=[...E];if(J.length===1)O.pattern=J[0].source;else if(J.length>1)Y.schema.allOf=[...J.map((_)=>({...this.target==="draft-7"?{type:"string"}:{},pattern:_.source}))]}break}case"number":{let O=F,{minimum:Q,maximum:Z,format:V,multipleOf:E,exclusiveMaximum:N,exclusiveMinimum:J}=$._zod.bag;if(typeof V==="string"&&V.includes("int"))O.type="integer";else O.type="number";if(typeof J==="number")O.exclusiveMinimum=J;if(typeof Q==="number"){if(O.minimum=Q,typeof J==="number")if(J>=Q)delete O.minimum;else delete O.exclusiveMinimum}if(typeof N==="number")O.exclusiveMaximum=N;if(typeof Z==="number"){if(O.maximum=Z,typeof N==="number")if(N<=Z)delete O.maximum;else delete O.exclusiveMaximum}if(typeof E==="number")O.multipleOf=E;break}case"boolean":{let O=F;O.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"undefined":{let O=F;O.type="null";break}case"null":{F.type="null";break}case"any":break;case"unknown":break;case"never":{F.not={};break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let O=F,{minimum:Q,maximum:Z}=$._zod.bag;if(typeof Q==="number")O.minItems=Q;if(typeof Z==="number")O.maxItems=Z;O.type="array",O.items=this.process(U.element,{...w,path:[...w.path,"items"]});break}case"object":{let O=F;O.type="object",O.properties={};let Q=U.shape;for(let E in Q)O.properties[E]=this.process(Q[E],{...w,path:[...w.path,"properties",E]});let Z=new Set(Object.keys(Q)),V=new Set([...Z].filter((E)=>{let N=U.shape[E]._zod;if(this.io==="input")return N.optin===void 0;else return N.optout===void 0}));if(V.size>0)O.required=Array.from(V);if(U.catchall?._zod.def.type==="never")O.additionalProperties=!1;else if(!U.catchall){if(this.io==="output")O.additionalProperties=!1}else if(U.catchall)O.additionalProperties=this.process(U.catchall,{...w,path:[...w.path,"additionalProperties"]});break}case"union":{let O=F;O.anyOf=U.options.map((Q,Z)=>this.process(Q,{...w,path:[...w.path,"anyOf",Z]}));break}case"intersection":{let O=F;O.allOf=[this.process(U.left,{...w,path:[...w.path,"allOf",0]}),this.process(U.right,{...w,path:[...w.path,"allOf",1]})];break}case"tuple":{let O=F;O.type="array";let Q=U.items.map((E,N)=>this.process(E,{...w,path:[...w.path,"prefixItems",N]}));if(this.target==="draft-2020-12")O.prefixItems=Q;else O.items=Q;if(U.rest){let E=this.process(U.rest,{...w,path:[...w.path,"items"]});if(this.target==="draft-2020-12")O.items=E;else O.additionalItems=E}if(U.rest)O.items=this.process(U.rest,{...w,path:[...w.path,"items"]});let{minimum:Z,maximum:V}=$._zod.bag;if(typeof Z==="number")O.minItems=Z;if(typeof V==="number")O.maxItems=V;break}case"record":{let O=F;O.type="object",O.propertyNames=this.process(U.keyType,{...w,path:[...w.path,"propertyNames"]}),O.additionalProperties=this.process(U.valueType,{...w,path:[...w.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let O=F;O.enum=Object.values(U.entries);break}case"literal":{let O=F,Q=[];for(let Z of U.values)if(Z===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof Z==="bigint")if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");else Q.push(Number(Z));else Q.push(Z);if(Q.length===0);else if(Q.length===1){let Z=Q[0];O.const=Z}else O.enum=Q;break}case"file":{if(this.unrepresentable==="throw")throw new Error("File cannot be represented in JSON Schema");break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let O=this.process(U.innerType,w);F.anyOf=[O,{type:"null"}];break}case"nonoptional":{this.process(U.innerType,w),Y.ref=U.innerType;break}case"success":{let O=F;O.type="boolean";break}case"default":{this.process(U.innerType,w),Y.ref=U.innerType,F.default=U.defaultValue;break}case"prefault":{if(this.process(U.innerType,w),Y.ref=U.innerType,this.io==="input")F._prefault=U.defaultValue;break}case"catch":{this.process(U.innerType,w),Y.ref=U.innerType;let O;try{O=U.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}F.default=O;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let O=F,Q=$._zod.pattern;if(!Q)throw new Error("Pattern not found in template literal");O.type="string",O.pattern=Q.source;break}case"pipe":{let O=this.io==="input"?U.in._zod.def.type==="transform"?U.out:U.in:U.out;this.process(O,w),Y.ref=O;break}case"readonly":{this.process(U.innerType,w),Y.ref=U.innerType,F.readOnly=!0;break}case"promise":{this.process(U.innerType,w),Y.ref=U.innerType;break}case"optional":{this.process(U.innerType,w),Y.ref=U.innerType;break}case"lazy":{let O=$._zod.innerType;this.process(O,w),Y.ref=O;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}let H=this.metadataRegistry.get($);if(H)Object.assign(Y.schema,H);if(this.io==="input"&&U.type==="pipe"){if(delete Y.schema.examples,delete Y.schema.default,Y.schema._prefault)Y.schema.default=Y.schema._prefault}if(this.io==="input"&&Y.schema._prefault)(W=Y.schema).default??(W.default=Y.schema._prefault);return delete Y.schema._prefault,this.seen.get($).schema}emit($,T){let W={cycles:T?.cycles??"ref",reused:T?.reused??"inline",external:T?.external??void 0},U=this.seen.get($);if(!U)throw new Error("Unprocessed schema. This is a bug in Zod.");let X=(z)=>{let F=this.target==="draft-2020-12"?"$defs":"definitions";if(W.external){let V=W.external.registry.get(z[0])?.id;if(V)return{ref:W.external.uri(V)};let E=z[1].defId??z[1].schema.id??`schema${this.counter++}`;return z[1].defId=E,{defId:E,ref:`${W.external.uri("__shared")}#/${F}/${E}`}}if(z[1]===U)return{ref:"#"};let Q=`${"#"}/${F}/`,Z=z[1].schema.id??`__schema${this.counter++}`;return{defId:Z,ref:Q+Z}},Y=(z)=>{if(z[1].schema.$ref)return;let F=z[1],{ref:O,defId:Q}=X(z);if(F.def={...F.schema},Q)F.defId=Q;let Z=F.schema;for(let V in Z)delete Z[V];Z.$ref=O};for(let z of this.seen.entries()){let F=z[1];if($===z[0]){Y(z);continue}if(W.external){let Q=W.external.registry.get(z[0])?.id;if($!==z[0]&&Q){Y(z);continue}}if(this.metadataRegistry.get(z[0])?.id){Y(z);continue}if(F.cycle){if(W.cycles==="throw")throw new Error(`Cycle detected: #/${F.cycle?.join("/")}/<root>
|
|
32
32
|
|
|
33
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);else if(W.cycles==="ref")U(w);continue}if(H.count>1){if(W.reused==="ref"){U(w);continue}}}let G=(w,H)=>{let _=this.seen.get(w),F=_.def??_.schema,D={...F};if(_.ref===null)return;let V=_.ref;if(_.ref=null,V){G(V,H);let E=this.seen.get(V).schema;if(E.$ref&&H.target==="draft-7")F.allOf=F.allOf??[],F.allOf.push(E);else Object.assign(F,E),Object.assign(F,D)}if(!_.isParent)this.override({zodSchema:w,jsonSchema:F})};for(let w of[...this.seen.entries()].reverse())G(w[0],{target:this.target});let J={...X.def},z=W.external?.defs??{};for(let w of this.seen.entries()){let H=w[1];if(H.def&&H.defId)z[H.defId]=H.def}if(!W.external&&Object.keys(z).length>0)if(this.target==="draft-2020-12")J.$defs=z;else J.definitions=z;if(this.target==="draft-2020-12")J.$schema="https://json-schema.org/draft/2020-12/schema";else if(this.target==="draft-7")J.$schema="http://json-schema.org/draft-07/schema#";else console.warn(`Invalid target: ${this.target}`);try{return JSON.parse(JSON.stringify(J))}catch(w){throw new Error("Error converting schema to JSON.")}}}function bw($,T){if($ instanceof RW){let X=new kY(T),Y={};for(let J of $._idmap.entries()){let[z,w]=J;X.process(w)}let U={},G={registry:$,uri:T?.uri||((J)=>J),defs:Y};for(let J of $._idmap.entries()){let[z,w]=J;U[z]=X.emit(w,{...T,external:G})}if(Object.keys(Y).length>0){let J=X.target==="draft-2020-12"?"$defs":"definitions";U.__shared={[J]:Y}}return{schemas:U}}let W=new kY(T);return W.process($),W.emit($,T)}var OH={};var qY={};M1(qY,{time:()=>hw,duration:()=>gw,datetime:()=>fw,date:()=>yw,ZodISOTime:()=>EH,ZodISODuration:()=>MH,ZodISODateTime:()=>VH,ZodISODate:()=>KH});var VH=K("ZodISODateTime",($,T)=>{LJ.init($,T),f$.init($,T)});function fw($){return s9(VH,$)}var KH=K("ZodISODate",($,T)=>{SJ.init($,T),f$.init($,T)});function yw($){return e9(KH,$)}var EH=K("ZodISOTime",($,T)=>{BJ.init($,T),f$.init($,T)});function hw($){return $w(EH,$)}var MH=K("ZodISODuration",($,T)=>{RJ.init($,T),f$.init($,T)});function gw($){return Tw(MH,$)}var NH=($,T)=>{VW.init($,T),$.name="ZodError",Object.defineProperties($,{format:{value:(W)=>EW($,W)},flatten:{value:(W)=>KW($,W)},addIssue:{value:(W)=>$.issues.push(W)},addIssues:{value:(W)=>$.issues.push(...W)},isEmpty:{get(){return $.issues.length===0}}})},tS=K("ZodError",NH),a0=K("ZodError",NH,{Parent:Error});var mw=pX(a0),cw=oX(a0),uw=rX(a0),pw=iX(a0);var dw={};M1(dw,{string:()=>sS,number:()=>eS,date:()=>WB,boolean:()=>$B,bigint:()=>TB});function sS($){return a9(PY,$)}function eS($){return Xw(cW,$)}function $B($){return _w(uW,$)}function TB($){return Fw(pW,$)}function WB($){return Lw(CY,$)}var z$=K("ZodType",($,T)=>{return W$.init($,T),$.def=T,Object.defineProperty($,"_def",{value:T}),$.check=(...W)=>{return $.clone({...T,checks:[...T.checks??[],...W.map((X)=>typeof X==="function"?{_zod:{check:X,def:{check:"custom"},onattach:[]}}:X)]})},$.clone=(W,X)=>i4($,W,X),$.brand=()=>$,$.register=(W,X)=>{return W.add($,X),$},$.parse=(W,X)=>mw($,W,X,{callee:$.parse}),$.safeParse=(W,X)=>uw($,W,X),$.parseAsync=async(W,X)=>cw($,W,X,{callee:$.parseAsync}),$.safeParseAsync=async(W,X)=>pw($,W,X),$.spa=$.safeParseAsync,$.refine=(W,X)=>$.check(wF(W,X)),$.superRefine=(W)=>$.check(zF(W)),$.overwrite=(W)=>$.check(o6(W)),$.optional=()=>xY($),$.nullable=()=>bY($),$.nullish=()=>xY(bY($)),$.nonoptional=(W)=>tH($,W),$.array=()=>Qz($),$.or=(W)=>gY([$,W]),$.and=(W)=>bH($,W),$.transform=(W)=>fY($,Oz(W)),$.default=(W)=>rH($,W),$.prefault=(W)=>nH($,W),$.catch=(W)=>eH($,W),$.pipe=(W)=>fY($,W),$.readonly=()=>WF($),$.describe=(W)=>{let X=$.clone();return v6.add(X,{description:W}),X},Object.defineProperty($,"description",{get(){return v6.get($)?.description},configurable:!0}),$.meta=(...W)=>{if(W.length===0)return v6.get($);let X=$.clone();return v6.add(X,W[0]),X},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$}),rw=K("_ZodString",($,T)=>{MW.init($,T),z$.init($,T);let W=$._zod.bag;$.format=W.format??null,$.minLength=W.minimum??null,$.maxLength=W.maximum??null,$.regex=(...X)=>$.check(qW(...X)),$.includes=(...X)=>$.check(vW(...X)),$.startsWith=(...X)=>$.check(jW(...X)),$.endsWith=(...X)=>$.check(xW(...X)),$.min=(...X)=>$.check(I1(...X)),$.max=(...X)=>$.check(i0(...X)),$.length=(...X)=>$.check(n0(...X)),$.nonempty=(...X)=>$.check(I1(1,...X)),$.lowercase=(X)=>$.check(PW(X)),$.uppercase=(X)=>$.check(CW(X)),$.trim=()=>$.check(yW()),$.normalize=(...X)=>$.check(fW(...X)),$.toLowerCase=()=>$.check(hW()),$.toUpperCase=()=>$.check(gW())}),PY=K("ZodString",($,T)=>{MW.init($,T),rw.init($,T),$.email=(W)=>$.check(JY(iw,W)),$.url=(W)=>$.check(FY(nw,W)),$.jwt=(W)=>$.check(IY(_z,W)),$.emoji=(W)=>$.check(QY(tw,W)),$.guid=(W)=>$.check(IW(vY,W)),$.uuid=(W)=>$.check(wY(r6,W)),$.uuidv4=(W)=>$.check(zY(r6,W)),$.uuidv6=(W)=>$.check(_Y(r6,W)),$.uuidv7=(W)=>$.check(HY(r6,W)),$.nanoid=(W)=>$.check(ZY(aw,W)),$.guid=(W)=>$.check(IW(vY,W)),$.cuid=(W)=>$.check(DY(sw,W)),$.cuid2=(W)=>$.check(OY(ew,W)),$.ulid=(W)=>$.check(VY($z,W)),$.base64=(W)=>$.check(SY(Jz,W)),$.base64url=(W)=>$.check(BY(wz,W)),$.xid=(W)=>$.check(KY(Tz,W)),$.ksuid=(W)=>$.check(EY(Wz,W)),$.ipv4=(W)=>$.check(MY(Xz,W)),$.ipv6=(W)=>$.check(AY(Yz,W)),$.cidrv4=(W)=>$.check(NY(Uz,W)),$.cidrv6=(W)=>$.check(LY(Gz,W)),$.e164=(W)=>$.check(RY(zz,W)),$.datetime=(W)=>$.check(fw(W)),$.date=(W)=>$.check(yw(W)),$.time=(W)=>$.check(hw(W)),$.duration=(W)=>$.check(gw(W))});function ow($){return t9(PY,$)}var f$=K("ZodStringFormat",($,T)=>{q$.init($,T),rw.init($,T)}),iw=K("ZodEmail",($,T)=>{ZJ.init($,T),f$.init($,T)});function XB($){return JY(iw,$)}var vY=K("ZodGUID",($,T)=>{FJ.init($,T),f$.init($,T)});function YB($){return IW(vY,$)}var r6=K("ZodUUID",($,T)=>{QJ.init($,T),f$.init($,T)});function UB($){return wY(r6,$)}function GB($){return zY(r6,$)}function JB($){return _Y(r6,$)}function wB($){return HY(r6,$)}var nw=K("ZodURL",($,T)=>{DJ.init($,T),f$.init($,T)});function zB($){return FY(nw,$)}var tw=K("ZodEmoji",($,T)=>{OJ.init($,T),f$.init($,T)});function _B($){return QY(tw,$)}var aw=K("ZodNanoID",($,T)=>{VJ.init($,T),f$.init($,T)});function HB($){return ZY(aw,$)}var sw=K("ZodCUID",($,T)=>{KJ.init($,T),f$.init($,T)});function FB($){return DY(sw,$)}var ew=K("ZodCUID2",($,T)=>{EJ.init($,T),f$.init($,T)});function QB($){return OY(ew,$)}var $z=K("ZodULID",($,T)=>{MJ.init($,T),f$.init($,T)});function ZB($){return VY($z,$)}var Tz=K("ZodXID",($,T)=>{AJ.init($,T),f$.init($,T)});function DB($){return KY(Tz,$)}var Wz=K("ZodKSUID",($,T)=>{NJ.init($,T),f$.init($,T)});function OB($){return EY(Wz,$)}var Xz=K("ZodIPv4",($,T)=>{IJ.init($,T),f$.init($,T)});function VB($){return MY(Xz,$)}var Yz=K("ZodIPv6",($,T)=>{kJ.init($,T),f$.init($,T)});function KB($){return AY(Yz,$)}var Uz=K("ZodCIDRv4",($,T)=>{qJ.init($,T),f$.init($,T)});function EB($){return NY(Uz,$)}var Gz=K("ZodCIDRv6",($,T)=>{PJ.init($,T),f$.init($,T)});function MB($){return LY(Gz,$)}var Jz=K("ZodBase64",($,T)=>{vJ.init($,T),f$.init($,T)});function AB($){return SY(Jz,$)}var wz=K("ZodBase64URL",($,T)=>{jJ.init($,T),f$.init($,T)});function NB($){return BY(wz,$)}var zz=K("ZodE164",($,T)=>{xJ.init($,T),f$.init($,T)});function LB($){return RY(zz,$)}var _z=K("ZodJWT",($,T)=>{bJ.init($,T),f$.init($,T)});function SB($){return IY(_z,$)}var cW=K("ZodNumber",($,T)=>{XY.init($,T),z$.init($,T),$.gt=(X,Y)=>$.check(d6(X,Y)),$.gte=(X,Y)=>$.check(b4(X,Y)),$.min=(X,Y)=>$.check(b4(X,Y)),$.lt=(X,Y)=>$.check(p6(X,Y)),$.lte=(X,Y)=>$.check(U6(X,Y)),$.max=(X,Y)=>$.check(U6(X,Y)),$.int=(X)=>$.check(lw(X)),$.safe=(X)=>$.check(lw(X)),$.positive=(X)=>$.check(d6(0,X)),$.nonnegative=(X)=>$.check(b4(0,X)),$.negative=(X)=>$.check(p6(0,X)),$.nonpositive=(X)=>$.check(U6(0,X)),$.multipleOf=(X,Y)=>$.check($0(X,Y)),$.step=(X,Y)=>$.check($0(X,Y)),$.finite=()=>$;let W=$._zod.bag;$.minValue=Math.max(W.minimum??Number.NEGATIVE_INFINITY,W.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,$.maxValue=Math.min(W.maximum??Number.POSITIVE_INFINITY,W.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,$.isInt=(W.format??"").includes("int")||Number.isSafeInteger(W.multipleOf??0.5),$.isFinite=!0,$.format=W.format??null});function LH($){return Ww(cW,$)}var s0=K("ZodNumberFormat",($,T)=>{fJ.init($,T),cW.init($,T)});function lw($){return Yw(s0,$)}function BB($){return Uw(s0,$)}function RB($){return Gw(s0,$)}function IB($){return Jw(s0,$)}function kB($){return ww(s0,$)}var uW=K("ZodBoolean",($,T)=>{AW.init($,T),z$.init($,T)});function SH($){return zw(uW,$)}var pW=K("ZodBigInt",($,T)=>{YY.init($,T),z$.init($,T),$.gte=(X,Y)=>$.check(b4(X,Y)),$.min=(X,Y)=>$.check(b4(X,Y)),$.gt=(X,Y)=>$.check(d6(X,Y)),$.gte=(X,Y)=>$.check(b4(X,Y)),$.min=(X,Y)=>$.check(b4(X,Y)),$.lt=(X,Y)=>$.check(p6(X,Y)),$.lte=(X,Y)=>$.check(U6(X,Y)),$.max=(X,Y)=>$.check(U6(X,Y)),$.positive=(X)=>$.check(d6(BigInt(0),X)),$.negative=(X)=>$.check(p6(BigInt(0),X)),$.nonpositive=(X)=>$.check(U6(BigInt(0),X)),$.nonnegative=(X)=>$.check(b4(BigInt(0),X)),$.multipleOf=(X,Y)=>$.check($0(X,Y));let W=$._zod.bag;$.minValue=W.minimum??null,$.maxValue=W.maximum??null,$.format=W.format??null});function qB($){return Hw(pW,$)}var Hz=K("ZodBigIntFormat",($,T)=>{yJ.init($,T),pW.init($,T)});function PB($){return Qw(Hz,$)}function CB($){return Zw(Hz,$)}var BH=K("ZodSymbol",($,T)=>{hJ.init($,T),z$.init($,T)});function vB($){return Dw(BH,$)}var RH=K("ZodUndefined",($,T)=>{gJ.init($,T),z$.init($,T)});function jB($){return Ow(RH,$)}var IH=K("ZodNull",($,T)=>{mJ.init($,T),z$.init($,T)});function kH($){return Vw(IH,$)}var qH=K("ZodAny",($,T)=>{cJ.init($,T),z$.init($,T)});function xB(){return Kw(qH)}var Fz=K("ZodUnknown",($,T)=>{NW.init($,T),z$.init($,T)});function jY(){return Ew(Fz)}var PH=K("ZodNever",($,T)=>{uJ.init($,T),z$.init($,T)});function yY($){return Mw(PH,$)}var CH=K("ZodVoid",($,T)=>{pJ.init($,T),z$.init($,T)});function bB($){return Aw(CH,$)}var CY=K("ZodDate",($,T)=>{dJ.init($,T),z$.init($,T),$.min=(X,Y)=>$.check(b4(X,Y)),$.max=(X,Y)=>$.check(U6(X,Y));let W=$._zod.bag;$.minDate=W.minimum?new Date(W.minimum):null,$.maxDate=W.maximum?new Date(W.maximum):null});function fB($){return Nw(CY,$)}var vH=K("ZodArray",($,T)=>{oJ.init($,T),z$.init($,T),$.element=T.element,$.min=(W,X)=>$.check(I1(W,X)),$.nonempty=(W)=>$.check(I1(1,W)),$.max=(W,X)=>$.check(i0(W,X)),$.length=(W,X)=>$.check(n0(W,X)),$.unwrap=()=>$.element});function Qz($,T){return Pw(vH,$,T)}function yB($){let T=$._zod.def.shape;return uH(Object.keys(T))}var hY=K("ZodObject",($,T)=>{lJ.init($,T),z$.init($,T),g.defineLazy($,"shape",()=>{return Object.fromEntries(Object.entries($._zod.def.shape))}),$.keyof=()=>mH(Object.keys($._zod.def.shape)),$.catchall=(W)=>$.clone({...$._zod.def,catchall:W}),$.passthrough=()=>$.clone({...$._zod.def,catchall:jY()}),$.loose=()=>$.clone({...$._zod.def,catchall:jY()}),$.strict=()=>$.clone({...$._zod.def,catchall:yY()}),$.strip=()=>$.clone({...$._zod.def,catchall:void 0}),$.extend=(W)=>{return g.extend($,W)},$.merge=(W)=>g.merge($,W),$.pick=(W)=>g.pick($,W),$.omit=(W)=>g.omit($,W),$.partial=(...W)=>g.partial(Vz,$,W[0]),$.required=(...W)=>g.required(Kz,$,W[0])});function hB($,T){let W={type:"object",get shape(){return g.assignProp(this,"shape",{...$}),this.shape},...g.normalizeParams(T)};return new hY(W)}function gB($,T){return new hY({type:"object",get shape(){return g.assignProp(this,"shape",{...$}),this.shape},catchall:yY(),...g.normalizeParams(T)})}function mB($,T){return new hY({type:"object",get shape(){return g.assignProp(this,"shape",{...$}),this.shape},catchall:jY(),...g.normalizeParams(T)})}var Zz=K("ZodUnion",($,T)=>{UY.init($,T),z$.init($,T),$.options=T.options});function gY($,T){return new Zz({type:"union",options:$,...g.normalizeParams(T)})}var jH=K("ZodDiscriminatedUnion",($,T)=>{Zz.init($,T),rJ.init($,T)});function cB($,T,W){return new jH({type:"union",options:T,discriminator:$,...g.normalizeParams(W)})}var xH=K("ZodIntersection",($,T)=>{iJ.init($,T),z$.init($,T)});function bH($,T){return new xH({type:"intersection",left:$,right:T})}var fH=K("ZodTuple",($,T)=>{e1.init($,T),z$.init($,T),$.rest=(W)=>$.clone({...$._zod.def,rest:W})});function uB($,T,W){let X=T instanceof W$,Y=X?W:T;return new fH({type:"tuple",items:$,rest:X?T:null,...g.normalizeParams(Y)})}var Dz=K("ZodRecord",($,T)=>{nJ.init($,T),z$.init($,T),$.keyType=T.keyType,$.valueType=T.valueType});function yH($,T,W){return new Dz({type:"record",keyType:$,valueType:T,...g.normalizeParams(W)})}function pB($,T,W){return new Dz({type:"record",keyType:gY([$,yY()]),valueType:T,...g.normalizeParams(W)})}var hH=K("ZodMap",($,T)=>{tJ.init($,T),z$.init($,T),$.keyType=T.keyType,$.valueType=T.valueType});function dB($,T,W){return new hH({type:"map",keyType:$,valueType:T,...g.normalizeParams(W)})}var gH=K("ZodSet",($,T)=>{aJ.init($,T),z$.init($,T),$.min=(...W)=>$.check(T0(...W)),$.nonempty=(W)=>$.check(T0(1,W)),$.max=(...W)=>$.check(r0(...W)),$.size=(...W)=>$.check(kW(...W))});function oB($,T){return new gH({type:"set",valueType:$,...g.normalizeParams(T)})}var dW=K("ZodEnum",($,T)=>{sJ.init($,T),z$.init($,T),$.enum=T.entries,$.options=Object.values(T.entries);let W=new Set(Object.keys(T.entries));$.extract=(X,Y)=>{let U={};for(let G of X)if(W.has(G))U[G]=T.entries[G];else throw new Error(`Key ${G} not found in enum`);return new dW({...T,checks:[],...g.normalizeParams(Y),entries:U})},$.exclude=(X,Y)=>{let U={...T.entries};for(let G of X)if(W.has(G))delete U[G];else throw new Error(`Key ${G} not found in enum`);return new dW({...T,checks:[],...g.normalizeParams(Y),entries:U})}});function mH($,T){let W=Array.isArray($)?Object.fromEntries($.map((X)=>[X,X])):$;return new dW({type:"enum",entries:W,...g.normalizeParams(T)})}function lB($,T){return new dW({type:"enum",entries:$,...g.normalizeParams(T)})}var cH=K("ZodLiteral",($,T)=>{eJ.init($,T),z$.init($,T),$.values=new Set(T.values),Object.defineProperty($,"value",{get(){if(T.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return T.values[0]}})});function uH($,T){return new cH({type:"literal",values:Array.isArray($)?$:[$],...g.normalizeParams(T)})}var pH=K("ZodFile",($,T)=>{$9.init($,T),z$.init($,T),$.min=(W,X)=>$.check(T0(W,X)),$.max=(W,X)=>$.check(r0(W,X)),$.mime=(W,X)=>$.check(bW(W,X))});function rB($){return vw(pH,$)}var dH=K("ZodTransform",($,T)=>{T9.init($,T),z$.init($,T),$._zod.parse=(W,X)=>{W.addIssue=(U)=>{if(typeof U==="string")W.issues.push(g.issue(U,W.value,T));else{let G=U;if(G.fatal)G.continue=!1;G.code??(G.code="custom"),G.input??(G.input=W.value),G.inst??(G.inst=$),G.continue??(G.continue=!0),W.issues.push(g.issue(G))}};let Y=T.transform(W.value,W);if(Y instanceof Promise)return Y.then((U)=>{return W.value=U,W});return W.value=Y,W}});function Oz($){return new dH({type:"transform",transform:$})}var Vz=K("ZodOptional",($,T)=>{W9.init($,T),z$.init($,T),$.unwrap=()=>$._zod.def.innerType});function xY($){return new Vz({type:"optional",innerType:$})}var oH=K("ZodNullable",($,T)=>{X9.init($,T),z$.init($,T),$.unwrap=()=>$._zod.def.innerType});function bY($){return new oH({type:"nullable",innerType:$})}function iB($){return xY(bY($))}var lH=K("ZodDefault",($,T)=>{Y9.init($,T),z$.init($,T),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function rH($,T){return new lH({type:"default",innerType:$,get defaultValue(){return typeof T==="function"?T():T}})}var iH=K("ZodPrefault",($,T)=>{U9.init($,T),z$.init($,T),$.unwrap=()=>$._zod.def.innerType});function nH($,T){return new iH({type:"prefault",innerType:$,get defaultValue(){return typeof T==="function"?T():T}})}var Kz=K("ZodNonOptional",($,T)=>{G9.init($,T),z$.init($,T),$.unwrap=()=>$._zod.def.innerType});function tH($,T){return new Kz({type:"nonoptional",innerType:$,...g.normalizeParams(T)})}var aH=K("ZodSuccess",($,T)=>{J9.init($,T),z$.init($,T),$.unwrap=()=>$._zod.def.innerType});function nB($){return new aH({type:"success",innerType:$})}var sH=K("ZodCatch",($,T)=>{w9.init($,T),z$.init($,T),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function eH($,T){return new sH({type:"catch",innerType:$,catchValue:typeof T==="function"?T:()=>T})}var $F=K("ZodNaN",($,T)=>{z9.init($,T),z$.init($,T)});function tB($){return Sw($F,$)}var Ez=K("ZodPipe",($,T)=>{LW.init($,T),z$.init($,T),$.in=T.in,$.out=T.out});function fY($,T){return new Ez({type:"pipe",in:$,out:T})}var TF=K("ZodReadonly",($,T)=>{_9.init($,T),z$.init($,T)});function WF($){return new TF({type:"readonly",innerType:$})}var XF=K("ZodTemplateLiteral",($,T)=>{H9.init($,T),z$.init($,T)});function aB($,T){return new XF({type:"template_literal",parts:$,...g.normalizeParams(T)})}var YF=K("ZodLazy",($,T)=>{Q9.init($,T),z$.init($,T),$.unwrap=()=>$._zod.def.getter()});function UF($){return new YF({type:"lazy",getter:$})}var GF=K("ZodPromise",($,T)=>{F9.init($,T),z$.init($,T),$.unwrap=()=>$._zod.def.innerType});function sB($){return new GF({type:"promise",innerType:$})}var mY=K("ZodCustom",($,T)=>{Z9.init($,T),z$.init($,T)});function JF($,T){let W=new u$({check:"custom",...g.normalizeParams(T)});return W._zod.check=$,W}function eB($,T){return mW(mY,$??(()=>!0),T)}function wF($,T={}){return mW(mY,$,T)}function zF($,T){let W=JF((X)=>{return X.addIssue=(Y)=>{if(typeof Y==="string")X.issues.push(g.issue(Y,X.value,W._zod.def));else{let U=Y;if(U.fatal)U.continue=!1;U.code??(U.code="custom"),U.input??(U.input=X.value),U.inst??(U.inst=W),U.continue??(U.continue=!W._zod.def.abort),X.issues.push(g.issue(U))}},$(X.value,X)},T);return W}function $R($,T={error:`Input not instance of ${$.name}`}){let W=new mY({type:"custom",check:"custom",fn:(X)=>X instanceof $,abort:!0,...g.normalizeParams(T)});return W._zod.bag.Class=$,W}var TR=jw.bind(null,{Pipe:Ez,Boolean:uW,Unknown:Fz});function WR($){let T=UF(()=>{return gY([ow($),LH(),SH(),kH(),Qz(T),yH(ow(),T)])});return T}function XR($,T){return fY(Oz($),T)}var YR={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"},UR=Object.freeze({status:"aborted"}),GR=UR;function JR($){n$({customError:$})}function wR(){return n$().customError}n$(SW());function _F($,T){return function W({schema:X,fallback:Y,toJsonSchema:U=cY.toJSONSchema}){let G=U(X);return async function J(z,w=3){let H,_=[];while(_.length<w){H=await $(z,G,Y,_);let F=await X["~standard"].validate(H);if("value"in F)return F.value;T?.warn(`safegen failed to generate well-formed data.
|
|
33
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);else if(W.cycles==="ref")Y(z);continue}if(F.count>1){if(W.reused==="ref"){Y(z);continue}}}let w=(z,F)=>{let O=this.seen.get(z),Q=O.def??O.schema,Z={...Q};if(O.ref===null)return;let V=O.ref;if(O.ref=null,V){w(V,F);let E=this.seen.get(V).schema;if(E.$ref&&F.target==="draft-7")Q.allOf=Q.allOf??[],Q.allOf.push(E);else Object.assign(Q,E),Object.assign(Q,Z)}if(!O.isParent)this.override({zodSchema:z,jsonSchema:Q})};for(let z of[...this.seen.entries()].reverse())w(z[0],{target:this.target});let G={};if(this.target==="draft-2020-12")G.$schema="https://json-schema.org/draft/2020-12/schema";else if(this.target==="draft-7")G.$schema="http://json-schema.org/draft-07/schema#";else console.warn(`Invalid target: ${this.target}`);Object.assign(G,U.def);let H=W.external?.defs??{};for(let z of this.seen.entries()){let F=z[1];if(F.def&&F.defId)H[F.defId]=F.def}if(!W.external&&Object.keys(H).length>0)if(this.target==="draft-2020-12")G.$defs=H;else G.definitions=H;try{return JSON.parse(JSON.stringify(G))}catch(z){throw new Error("Error converting schema to JSON.")}}}function pH($,T){if($ instanceof wX){let U=new aw(T),X={};for(let G of $._idmap.entries()){let[H,z]=G;U.process(z)}let Y={},w={registry:$,uri:T?.uri||((G)=>G),defs:X};for(let G of $._idmap.entries()){let[H,z]=G;Y[H]=U.emit(z,{...T,external:w})}if(Object.keys(X).length>0){let G=U.target==="draft-2020-12"?"$defs":"definitions";Y.__shared={[G]:X}}return{schemas:Y}}let W=new aw(T);return W.process($),W.emit($,T)}var KK={};var sw={};wT(sw,{time:()=>lH,duration:()=>rH,datetime:()=>dH,date:()=>oH,ZodISOTime:()=>MK,ZodISODuration:()=>NK,ZodISODateTime:()=>EK,ZodISODate:()=>AK});var EK=k("ZodISODateTime",($,T)=>{P7.init($,T),T4.init($,T)});function dH($){return wH(EK,$)}var AK=k("ZodISODate",($,T)=>{C7.init($,T),T4.init($,T)});function oH($){return GH(AK,$)}var MK=k("ZodISOTime",($,T)=>{S7.init($,T),T4.init($,T)});function lH($){return zH(MK,$)}var NK=k("ZodISODuration",($,T)=>{j7.init($,T),T4.init($,T)});function rH($){return HH(NK,$)}var JK=($,T)=>{aU.init($,T),$.name="ZodError",Object.defineProperties($,{format:{value:(W)=>eU($,W)},flatten:{value:(W)=>sU($,W)},addIssue:{value:(W)=>$.issues.push(W)},addIssues:{value:(W)=>$.issues.push(...W)},isEmpty:{get(){return $.issues.length===0}}})},OB=k("ZodError",JK),z2=k("ZodError",JK,{Parent:Error});var nH=Qw(z2),iH=Dw(z2),tH=Kw(z2),aH=Ew(z2);var sH={};wT(sH,{string:()=>ZB,number:()=>DB,date:()=>EB,boolean:()=>VB,bigint:()=>KB});function ZB($){return YH(ew,$)}function DB($){return OH(LX,$)}function VB($){return AH(JX,$)}function KB($){return NH(_X,$)}function EB($){return jH($G,$)}var J$=k("ZodType",($,T)=>{return Q$.init($,T),$.def=T,Object.defineProperty($,"_def",{value:T}),$.check=(...W)=>{return $.clone({...T,checks:[...T.checks??[],...W.map((U)=>typeof U==="function"?{_zod:{check:U,def:{check:"custom"},onattach:[]}}:U)]})},$.clone=(W,U)=>a6($,W,U),$.brand=()=>$,$.register=(W,U)=>{return W.add($,U),$},$.parse=(W,U)=>nH($,W,U,{callee:$.parse}),$.safeParse=(W,U)=>tH($,W,U),$.parseAsync=async(W,U)=>iH($,W,U,{callee:$.parseAsync}),$.safeParseAsync=async(W,U)=>aH($,W,U),$.spa=$.safeParseAsync,$.refine=(W,U)=>$.check(zE(W,U)),$.superRefine=(W)=>$.check(HE(W)),$.overwrite=(W)=>$.check(E0(W)),$.optional=()=>UG($),$.nullable=()=>XG($),$.nullish=()=>UG(XG($)),$.nonoptional=(W)=>tK($,W),$.array=()=>LF($),$.or=(W)=>zG([$,W]),$.and=(W)=>bK($,W),$.transform=(W)=>YG($,RF(W)),$.default=(W)=>rK($,W),$.prefault=(W)=>iK($,W),$.catch=(W)=>eK($,W),$.pipe=(W)=>YG($,W),$.readonly=()=>WE($),$.describe=(W)=>{let U=$.clone();return n1.add(U,{description:W}),U},Object.defineProperty($,"description",{get(){return n1.get($)?.description},configurable:!0}),$.meta=(...W)=>{if(W.length===0)return n1.get($);let U=$.clone();return n1.add(U,W[0]),U},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$}),TF=k("_ZodString",($,T)=>{$X.init($,T),J$.init($,T);let W=$._zod.bag;$.format=W.format??null,$.minLength=W.minimum??null,$.maxLength=W.maximum??null,$.regex=(...U)=>$.check(HX(...U)),$.includes=(...U)=>$.check(QX(...U)),$.startsWith=(...U)=>$.check(ZX(...U)),$.endsWith=(...U)=>$.check(DX(...U)),$.min=(...U)=>$.check(ZT(...U)),$.max=(...U)=>$.check(Y2(...U)),$.length=(...U)=>$.check(w2(...U)),$.nonempty=(...U)=>$.check(ZT(1,...U)),$.lowercase=(U)=>$.check(FX(U)),$.uppercase=(U)=>$.check(OX(U)),$.trim=()=>$.check(EX()),$.normalize=(...U)=>$.check(KX(...U)),$.toLowerCase=()=>$.check(AX()),$.toUpperCase=()=>$.check(MX())}),ew=k("ZodString",($,T)=>{$X.init($,T),TF.init($,T),$.email=(W)=>$.check(Sw(WF,W)),$.url=(W)=>$.check(bw(UF,W)),$.jwt=(W)=>$.check(tw(AF,W)),$.emoji=(W)=>$.check(fw(XF,W)),$.guid=(W)=>$.check(GX(TG,W)),$.uuid=(W)=>$.check(jw(M0,W)),$.uuidv4=(W)=>$.check(Bw(M0,W)),$.uuidv6=(W)=>$.check(xw(M0,W)),$.uuidv7=(W)=>$.check(Iw(M0,W)),$.nanoid=(W)=>$.check(yw(YF,W)),$.guid=(W)=>$.check(GX(TG,W)),$.cuid=(W)=>$.check(hw(wF,W)),$.cuid2=(W)=>$.check(gw(GF,W)),$.ulid=(W)=>$.check(mw(zF,W)),$.base64=(W)=>$.check(rw(VF,W)),$.base64url=(W)=>$.check(nw(KF,W)),$.xid=(W)=>$.check(cw(HF,W)),$.ksuid=(W)=>$.check(uw(FF,W)),$.ipv4=(W)=>$.check(pw(OF,W)),$.ipv6=(W)=>$.check(dw(QF,W)),$.cidrv4=(W)=>$.check(ow(ZF,W)),$.cidrv6=(W)=>$.check(lw(DF,W)),$.e164=(W)=>$.check(iw(EF,W)),$.datetime=(W)=>$.check(dH(W)),$.date=(W)=>$.check(oH(W)),$.time=(W)=>$.check(lH(W)),$.duration=(W)=>$.check(rH(W))});function eH($){return XH(ew,$)}var T4=k("ZodStringFormat",($,T)=>{l$.init($,T),TF.init($,T)}),WF=k("ZodEmail",($,T)=>{M7.init($,T),T4.init($,T)});function AB($){return Sw(WF,$)}var TG=k("ZodGUID",($,T)=>{E7.init($,T),T4.init($,T)});function MB($){return GX(TG,$)}var M0=k("ZodUUID",($,T)=>{A7.init($,T),T4.init($,T)});function NB($){return jw(M0,$)}function LB($){return Bw(M0,$)}function JB($){return xw(M0,$)}function _B($){return Iw(M0,$)}var UF=k("ZodURL",($,T)=>{N7.init($,T),T4.init($,T)});function RB($){return bw(UF,$)}var XF=k("ZodEmoji",($,T)=>{L7.init($,T),T4.init($,T)});function kB($){return fw(XF,$)}var YF=k("ZodNanoID",($,T)=>{J7.init($,T),T4.init($,T)});function vB($){return yw(YF,$)}var wF=k("ZodCUID",($,T)=>{_7.init($,T),T4.init($,T)});function qB($){return hw(wF,$)}var GF=k("ZodCUID2",($,T)=>{R7.init($,T),T4.init($,T)});function PB($){return gw(GF,$)}var zF=k("ZodULID",($,T)=>{k7.init($,T),T4.init($,T)});function CB($){return mw(zF,$)}var HF=k("ZodXID",($,T)=>{v7.init($,T),T4.init($,T)});function SB($){return cw(HF,$)}var FF=k("ZodKSUID",($,T)=>{q7.init($,T),T4.init($,T)});function jB($){return uw(FF,$)}var OF=k("ZodIPv4",($,T)=>{B7.init($,T),T4.init($,T)});function BB($){return pw(OF,$)}var QF=k("ZodIPv6",($,T)=>{x7.init($,T),T4.init($,T)});function xB($){return dw(QF,$)}var ZF=k("ZodCIDRv4",($,T)=>{I7.init($,T),T4.init($,T)});function IB($){return ow(ZF,$)}var DF=k("ZodCIDRv6",($,T)=>{b7.init($,T),T4.init($,T)});function bB($){return lw(DF,$)}var VF=k("ZodBase64",($,T)=>{y7.init($,T),T4.init($,T)});function fB($){return rw(VF,$)}var KF=k("ZodBase64URL",($,T)=>{h7.init($,T),T4.init($,T)});function yB($){return nw(KF,$)}var EF=k("ZodE164",($,T)=>{g7.init($,T),T4.init($,T)});function hB($){return iw(EF,$)}var AF=k("ZodJWT",($,T)=>{m7.init($,T),T4.init($,T)});function gB($){return tw(AF,$)}var LX=k("ZodNumber",($,T)=>{vw.init($,T),J$.init($,T),$.gt=(U,X)=>$.check(K0(U,X)),$.gte=(U,X)=>$.check(j6(U,X)),$.min=(U,X)=>$.check(j6(U,X)),$.lt=(U,X)=>$.check(V0(U,X)),$.lte=(U,X)=>$.check(D1(U,X)),$.max=(U,X)=>$.check(D1(U,X)),$.int=(U)=>$.check($F(U)),$.safe=(U)=>$.check($F(U)),$.positive=(U)=>$.check(K0(0,U)),$.nonnegative=(U)=>$.check(j6(0,U)),$.negative=(U)=>$.check(V0(0,U)),$.nonpositive=(U)=>$.check(D1(0,U)),$.multipleOf=(U,X)=>$.check(sT(U,X)),$.step=(U,X)=>$.check(sT(U,X)),$.finite=()=>$;let W=$._zod.bag;$.minValue=Math.max(W.minimum??Number.NEGATIVE_INFINITY,W.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,$.maxValue=Math.min(W.maximum??Number.POSITIVE_INFINITY,W.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,$.isInt=(W.format??"").includes("int")||Number.isSafeInteger(W.multipleOf??0.5),$.isFinite=!0,$.format=W.format??null});function _K($){return FH(LX,$)}var H2=k("ZodNumberFormat",($,T)=>{c7.init($,T),LX.init($,T)});function $F($){return QH(H2,$)}function mB($){return ZH(H2,$)}function cB($){return DH(H2,$)}function uB($){return VH(H2,$)}function pB($){return KH(H2,$)}var JX=k("ZodBoolean",($,T)=>{TX.init($,T),J$.init($,T)});function RK($){return EH(JX,$)}var _X=k("ZodBigInt",($,T)=>{qw.init($,T),J$.init($,T),$.gte=(U,X)=>$.check(j6(U,X)),$.min=(U,X)=>$.check(j6(U,X)),$.gt=(U,X)=>$.check(K0(U,X)),$.gte=(U,X)=>$.check(j6(U,X)),$.min=(U,X)=>$.check(j6(U,X)),$.lt=(U,X)=>$.check(V0(U,X)),$.lte=(U,X)=>$.check(D1(U,X)),$.max=(U,X)=>$.check(D1(U,X)),$.positive=(U)=>$.check(K0(BigInt(0),U)),$.negative=(U)=>$.check(V0(BigInt(0),U)),$.nonpositive=(U)=>$.check(D1(BigInt(0),U)),$.nonnegative=(U)=>$.check(j6(BigInt(0),U)),$.multipleOf=(U,X)=>$.check(sT(U,X));let W=$._zod.bag;$.minValue=W.minimum??null,$.maxValue=W.maximum??null,$.format=W.format??null});function dB($){return MH(_X,$)}var MF=k("ZodBigIntFormat",($,T)=>{u7.init($,T),_X.init($,T)});function oB($){return LH(MF,$)}function lB($){return JH(MF,$)}var kK=k("ZodSymbol",($,T)=>{p7.init($,T),J$.init($,T)});function rB($){return _H(kK,$)}var vK=k("ZodUndefined",($,T)=>{d7.init($,T),J$.init($,T)});function nB($){return RH(vK,$)}var qK=k("ZodNull",($,T)=>{o7.init($,T),J$.init($,T)});function PK($){return kH(qK,$)}var CK=k("ZodAny",($,T)=>{l7.init($,T),J$.init($,T)});function iB(){return vH(CK)}var NF=k("ZodUnknown",($,T)=>{WX.init($,T),J$.init($,T)});function WG(){return qH(NF)}var SK=k("ZodNever",($,T)=>{r7.init($,T),J$.init($,T)});function wG($){return PH(SK,$)}var jK=k("ZodVoid",($,T)=>{n7.init($,T),J$.init($,T)});function tB($){return CH(jK,$)}var $G=k("ZodDate",($,T)=>{i7.init($,T),J$.init($,T),$.min=(U,X)=>$.check(j6(U,X)),$.max=(U,X)=>$.check(D1(U,X));let W=$._zod.bag;$.minDate=W.minimum?new Date(W.minimum):null,$.maxDate=W.maximum?new Date(W.maximum):null});function aB($){return SH($G,$)}var BK=k("ZodArray",($,T)=>{t7.init($,T),J$.init($,T),$.element=T.element,$.min=(W,U)=>$.check(ZT(W,U)),$.nonempty=(W)=>$.check(ZT(1,W)),$.max=(W,U)=>$.check(Y2(W,U)),$.length=(W,U)=>$.check(w2(W,U)),$.unwrap=()=>$.element});function LF($,T){return hH(BK,$,T)}function sB($){let T=$._zod.def.shape;return uK(Object.keys(T))}var GG=k("ZodObject",($,T)=>{a7.init($,T),J$.init($,T),d.defineLazy($,"shape",()=>{return Object.fromEntries(Object.entries($._zod.def.shape))}),$.keyof=()=>mK(Object.keys($._zod.def.shape)),$.catchall=(W)=>$.clone({...$._zod.def,catchall:W}),$.passthrough=()=>$.clone({...$._zod.def,catchall:WG()}),$.loose=()=>$.clone({...$._zod.def,catchall:WG()}),$.strict=()=>$.clone({...$._zod.def,catchall:wG()}),$.strip=()=>$.clone({...$._zod.def,catchall:void 0}),$.extend=(W)=>{return d.extend($,W)},$.merge=(W)=>d.merge($,W),$.pick=(W)=>d.pick($,W),$.omit=(W)=>d.omit($,W),$.partial=(...W)=>d.partial(kF,$,W[0]),$.required=(...W)=>d.required(vF,$,W[0])});function eB($,T){let W={type:"object",get shape(){return d.assignProp(this,"shape",{...$}),this.shape},...d.normalizeParams(T)};return new GG(W)}function $x($,T){return new GG({type:"object",get shape(){return d.assignProp(this,"shape",{...$}),this.shape},catchall:wG(),...d.normalizeParams(T)})}function Tx($,T){return new GG({type:"object",get shape(){return d.assignProp(this,"shape",{...$}),this.shape},catchall:WG(),...d.normalizeParams(T)})}var JF=k("ZodUnion",($,T)=>{Pw.init($,T),J$.init($,T),$.options=T.options});function zG($,T){return new JF({type:"union",options:$,...d.normalizeParams(T)})}var xK=k("ZodDiscriminatedUnion",($,T)=>{JF.init($,T),s7.init($,T)});function Wx($,T,W){return new xK({type:"union",options:T,discriminator:$,...d.normalizeParams(W)})}var IK=k("ZodIntersection",($,T)=>{e7.init($,T),J$.init($,T)});function bK($,T){return new IK({type:"intersection",left:$,right:T})}var fK=k("ZodTuple",($,T)=>{aT.init($,T),J$.init($,T),$.rest=(W)=>$.clone({...$._zod.def,rest:W})});function Ux($,T,W){let U=T instanceof Q$,X=U?W:T;return new fK({type:"tuple",items:$,rest:U?T:null,...d.normalizeParams(X)})}var _F=k("ZodRecord",($,T)=>{$3.init($,T),J$.init($,T),$.keyType=T.keyType,$.valueType=T.valueType});function yK($,T,W){return new _F({type:"record",keyType:$,valueType:T,...d.normalizeParams(W)})}function Xx($,T,W){return new _F({type:"record",keyType:zG([$,wG()]),valueType:T,...d.normalizeParams(W)})}var hK=k("ZodMap",($,T)=>{T3.init($,T),J$.init($,T),$.keyType=T.keyType,$.valueType=T.valueType});function Yx($,T,W){return new hK({type:"map",keyType:$,valueType:T,...d.normalizeParams(W)})}var gK=k("ZodSet",($,T)=>{W3.init($,T),J$.init($,T),$.min=(...W)=>$.check(eT(...W)),$.nonempty=(W)=>$.check(eT(1,W)),$.max=(...W)=>$.check(X2(...W)),$.size=(...W)=>$.check(zX(...W))});function wx($,T){return new gK({type:"set",valueType:$,...d.normalizeParams(T)})}var RX=k("ZodEnum",($,T)=>{U3.init($,T),J$.init($,T),$.enum=T.entries,$.options=Object.values(T.entries);let W=new Set(Object.keys(T.entries));$.extract=(U,X)=>{let Y={};for(let w of U)if(W.has(w))Y[w]=T.entries[w];else throw new Error(`Key ${w} not found in enum`);return new RX({...T,checks:[],...d.normalizeParams(X),entries:Y})},$.exclude=(U,X)=>{let Y={...T.entries};for(let w of U)if(W.has(w))delete Y[w];else throw new Error(`Key ${w} not found in enum`);return new RX({...T,checks:[],...d.normalizeParams(X),entries:Y})}});function mK($,T){let W=Array.isArray($)?Object.fromEntries($.map((U)=>[U,U])):$;return new RX({type:"enum",entries:W,...d.normalizeParams(T)})}function Gx($,T){return new RX({type:"enum",entries:$,...d.normalizeParams(T)})}var cK=k("ZodLiteral",($,T)=>{X3.init($,T),J$.init($,T),$.values=new Set(T.values),Object.defineProperty($,"value",{get(){if(T.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return T.values[0]}})});function uK($,T){return new cK({type:"literal",values:Array.isArray($)?$:[$],...d.normalizeParams(T)})}var pK=k("ZodFile",($,T)=>{Y3.init($,T),J$.init($,T),$.min=(W,U)=>$.check(eT(W,U)),$.max=(W,U)=>$.check(X2(W,U)),$.mime=(W,U)=>$.check(VX(W,U))});function zx($){return mH(pK,$)}var dK=k("ZodTransform",($,T)=>{w3.init($,T),J$.init($,T),$._zod.parse=(W,U)=>{W.addIssue=(Y)=>{if(typeof Y==="string")W.issues.push(d.issue(Y,W.value,T));else{let w=Y;if(w.fatal)w.continue=!1;w.code??(w.code="custom"),w.input??(w.input=W.value),w.inst??(w.inst=$),w.continue??(w.continue=!0),W.issues.push(d.issue(w))}};let X=T.transform(W.value,W);if(X instanceof Promise)return X.then((Y)=>{return W.value=Y,W});return W.value=X,W}});function RF($){return new dK({type:"transform",transform:$})}var kF=k("ZodOptional",($,T)=>{G3.init($,T),J$.init($,T),$.unwrap=()=>$._zod.def.innerType});function UG($){return new kF({type:"optional",innerType:$})}var oK=k("ZodNullable",($,T)=>{z3.init($,T),J$.init($,T),$.unwrap=()=>$._zod.def.innerType});function XG($){return new oK({type:"nullable",innerType:$})}function Hx($){return UG(XG($))}var lK=k("ZodDefault",($,T)=>{H3.init($,T),J$.init($,T),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function rK($,T){return new lK({type:"default",innerType:$,get defaultValue(){return typeof T==="function"?T():T}})}var nK=k("ZodPrefault",($,T)=>{F3.init($,T),J$.init($,T),$.unwrap=()=>$._zod.def.innerType});function iK($,T){return new nK({type:"prefault",innerType:$,get defaultValue(){return typeof T==="function"?T():T}})}var vF=k("ZodNonOptional",($,T)=>{O3.init($,T),J$.init($,T),$.unwrap=()=>$._zod.def.innerType});function tK($,T){return new vF({type:"nonoptional",innerType:$,...d.normalizeParams(T)})}var aK=k("ZodSuccess",($,T)=>{Q3.init($,T),J$.init($,T),$.unwrap=()=>$._zod.def.innerType});function Fx($){return new aK({type:"success",innerType:$})}var sK=k("ZodCatch",($,T)=>{Z3.init($,T),J$.init($,T),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function eK($,T){return new sK({type:"catch",innerType:$,catchValue:typeof T==="function"?T:()=>T})}var $E=k("ZodNaN",($,T)=>{D3.init($,T),J$.init($,T)});function Ox($){return BH($E,$)}var qF=k("ZodPipe",($,T)=>{UX.init($,T),J$.init($,T),$.in=T.in,$.out=T.out});function YG($,T){return new qF({type:"pipe",in:$,out:T})}var TE=k("ZodReadonly",($,T)=>{V3.init($,T),J$.init($,T)});function WE($){return new TE({type:"readonly",innerType:$})}var UE=k("ZodTemplateLiteral",($,T)=>{K3.init($,T),J$.init($,T)});function Qx($,T){return new UE({type:"template_literal",parts:$,...d.normalizeParams(T)})}var XE=k("ZodLazy",($,T)=>{A3.init($,T),J$.init($,T),$.unwrap=()=>$._zod.def.getter()});function YE($){return new XE({type:"lazy",getter:$})}var wE=k("ZodPromise",($,T)=>{E3.init($,T),J$.init($,T),$.unwrap=()=>$._zod.def.innerType});function Zx($){return new wE({type:"promise",innerType:$})}var HG=k("ZodCustom",($,T)=>{M3.init($,T),J$.init($,T)});function GE($,T){let W=new G4({check:"custom",...d.normalizeParams(T)});return W._zod.check=$,W}function Dx($,T){return NX(HG,$??(()=>!0),T)}function zE($,T={}){return NX(HG,$,T)}function HE($,T){let W=GE((U)=>{return U.addIssue=(X)=>{if(typeof X==="string")U.issues.push(d.issue(X,U.value,W._zod.def));else{let Y=X;if(Y.fatal)Y.continue=!1;Y.code??(Y.code="custom"),Y.input??(Y.input=U.value),Y.inst??(Y.inst=W),Y.continue??(Y.continue=!W._zod.def.abort),U.issues.push(d.issue(Y))}},$(U.value,U)},T);return W}function Vx($,T={error:`Input not instance of ${$.name}`}){let W=new HG({type:"custom",check:"custom",fn:(U)=>U instanceof $,abort:!0,...d.normalizeParams(T)});return W._zod.bag.Class=$,W}var Kx=cH.bind(null,{Pipe:qF,Boolean:JX,Unknown:NF});function Ex($){let T=YE(()=>{return zG([eH($),_K(),RK(),PK(),LF(T),yK(eH(),T)])});return T}function Ax($,T){return YG(RF($),T)}var Mx={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"},Nx=Object.freeze({status:"aborted"}),Lx=Nx;function Jx($){N4({customError:$})}function _x(){return N4().customError}N4(XX());function FE($,T){return function W({schema:U,fallback:X,toJsonSchema:Y=FG.toJSONSchema}){let w=Y(U);return async function G(H,z=3){let F,O=[];while(O.length<z){F=await $(H,w,X,O);let Q=await U["~standard"].validate(F);if("value"in Q)return Q.value;T?.warn(`safegen failed to generate well-formed data.
|
|
34
34
|
`,`Here's what was returned last time:
|
|
35
|
-
`,JSON.stringify(
|
|
35
|
+
`,JSON.stringify(F,null,"\t"),`
|
|
36
36
|
`,`Here are the issues returned from our validation:
|
|
37
|
-
`,JSON.stringify(
|
|
38
|
-
`)}var
|
|
37
|
+
`,JSON.stringify(Q.issues,null,"\t")),O.push({response:F,error:Q})}return T?.error(`safegen was unable to generate well-formed data after ${z} failed attempts.`),X}}}function OE($){return["Please generate a response in JSON that conforms to the following JSON Schema:",JSON.stringify($,null,2)].join(`
|
|
38
|
+
`)}var NE=AP(DE(),1);import*as B6 from"fs";import*as F2 from"path";import{resolve as Cx}from"path";import{createHash as Sx}from"crypto";import{copyFile as jx}from"fs/promises";import{existsSync as PF,mkdirSync as VE,readFileSync as qx,readdirSync as KE,rmSync as EE,statSync as AE,writeFileSync as Px}from"fs";import{resolve as CF}from"path";var ME=class{rootDir;get initialized(){return PF(this.rootDir)}initialize(){if(!this.initialized)VE(this.rootDir,{recursive:!0})}constructor($){if(this.rootDir=$.path,$.eagerInit)this.initialize()}getItem($){let T=CF(this.rootDir,$);if(PF(T))return qx(T,"utf-8");return null}setItem($,T){this.initialize();let W=CF(this.rootDir,$);Px(W,T)}removeItem($){let T=CF(this.rootDir,$);if(PF(T))this.initialize(),EE(T)}key($){return KE(this.rootDir).sort((U,X)=>{let Y=AE(U);return AE(X).ctimeMs-Y.ctimeMs})[$]??null}clear(){EE(this.rootDir,{recursive:!0}),VE(this.rootDir,{recursive:!0})}get length(){return KE(this.rootDir).length}};var LE=/[^a-zA-Z0-9\-._]/g;function PX($,T=64){if(T%2===1)T+=1;let W=$.replace(LE,"-");if(W.length<=T)return W;let U=Sx("sha256").update($).digest("base64").slice(0,8).replaceAll("/","_"),X=W;if(X.length>T){let Y=X.slice(0,T/2),w=X.slice(-T/2);X=Y+"_"+w}return X+"+"+U}var Bx=NE.default("varmint"),qX=PX(process.cwd(),150),SF=Cx(Bx,qX),v4="_-$-_-$-_",JE=`file${v4}`,_E=`list${v4}`,RE=`root${v4}`,xx=`unmatched${v4}`,r$={storage:new ME({path:SF,eagerInit:!1}),startGlobalTracking(){if(console.log(`\uD83D\uDC3F\uFE0F Starting global tracking of varmint files using project identifier "${qX}"`),r$.storage.initialized)console.error(`\uD83D\uDCA5 The global cache for the project "${qX}" was found already initialized. Clearing it and starting fresh.`),r$.storage.clear();r$.storage.initialize()},async prepareUploads($){console.log(`\uD83D\uDC3F\uFE0F Moving unmatched inputs to /tmp/varmint-uploads using project identifier "${qX}"`);let T=[];for(let W of B6.readdirSync(r$.storage.rootDir))if(OG(`unmatched${v4}`,W))T.push(W);if(T.length===0){console.log("\uD83D\uDC3F\uFE0F ","No unmatched input files found.");return}if(console.log("\uD83D\uDC3F\uFE0F ","Found the following unmatched files:",`
|
|
39
39
|
- ${T.join(`
|
|
40
40
|
`)}
|
|
41
41
|
`,`in root folder:
|
|
42
|
-
`,
|
|
42
|
+
`,SF),process.env[$])B6.mkdirSync("/tmp/varmint-uploads",{recursive:!0}),await Promise.all(T.map(async(W)=>{let U=F2.join(SF,W),X=F2.join("/tmp/varmint-uploads",W);await jx(U,X)}));else console.warn("\uD83D\uDCA5 Skipping artifact upload because process.env.CI is not set.")},endGlobalTrackingAndFlushUnusedFiles(){if(console.log(`\uD83D\uDC3F\uFE0F Ending global tracking of varmint files using project identifier "${qX}" and starting cleanup of untouched files.`),!r$.storage.initialized){console.error("\uD83D\uDCA5 called flushGlobal, but the global cache wasn't initialized with startGlobalTracking");return}let $=B6.readdirSync(r$.storage.rootDir),T=new Map,W=[],U=[],X=[];for(let w of $)if(OG(`root${v4}`,w))W.push(w);else if(OG(`list${v4}`,w))U.push(w);else if(OG(`file${v4}`,w))X.push(w);if(r$.storage.getItem("DID_CACHE_MISS"))console.log("\uD83D\uDC3F\uFE0F ","Cache miss detected. Since this likely prevented the cache from being fully utilized, we will not attempt to flush unused files.");else{let w=new Map;for(let G of W){let H=G.replace(RE,"");w.set(H,new Map);let z=r$.storage.getItem(G);if(z)T.set(H,z);else console.error(`\uD83D\uDCA5 Could not find folder ${z} referenced in the global cache`)}for(let G of U){let H=G.replace(_E,""),[z,F]=H.split(v4),O=w.get(z);if(O)O.set(F,new Set);else console.error(`\uD83D\uDCA5 Could not find root ${z} for list ${F}`)}for(let G of X){let H=G.replace(JE,""),[z,F,O]=H.split(v4),Q=w.get(z);if(Q){let Z=Q.get(F);if(Z)Z.add(O);else console.error(`\uD83D\uDCA5 Could not find list ${F} for file ${H}`)}else console.error(`\uD83D\uDCA5 Could not find root ${z} for file ${H}`)}console.log("\uD83D\uDC3F\uFE0F ",w);for(let[G,H]of w.entries()){let z=T.get(G);if(!z){console.error(`\uD83D\uDCA5 Could not find root ${G}`);continue}if(!B6.existsSync(z)){console.warn(`\uD83D\uDCA5 Root folder ${z}, identified as being used during tracking, no longer exists during cleanup.`);continue}let O=B6.readdirSync(z);for(let Q of O)if(Q!==".ferret"&&!H.has(Q)){let Z=F2.join(z,Q);console.log(`\uD83E\uDDF9 globalFlush: removing directory ${Z}`),B6.rmSync(Z,{recursive:!0})}for(let[Q,Z]of H.entries()){let V=F2.join(z,Q);if(!B6.existsSync(V)){console.warn(`\uD83D\uDCA5 List folder ${V}, identified as being used during tracking, no longer exists.`);continue}let N=B6.readdirSync(V);for(let J of N){let _=J.replace(".input.json","").replace(".output.json","").replace(".stream.txt","");if(!Z.has(_)){let R=F2.join(V,J);console.log(`\uD83E\uDDF9 globalFlush: removing file ${R}`),B6.rmSync(R)}}}}}B6.rmSync(r$.storage.rootDir,{recursive:!0})}};function OG($,T){return T.startsWith($)}import*as V4 from"fs";import*as j1 from"path";import{inspect as kE}from"util";var vE=class{filenameCache=new Map;filesTouched=new Map;mode;baseDir;rootName;constructor($="off",T=j1.join(process.cwd(),".varmint")){if(this.mode=$,this.baseDir=T,this.rootName=PX(this.baseDir),r$.storage.initialized&&!r$.storage.getItem(`root${v4}${this.rootName}`))r$.storage.setItem(`root${v4}${this.rootName}`,this.baseDir)}read($,T,W){let U=j1.join(this.baseDir,$),X=`${T}.input.json`,Y=j1.join(U,X);if(!V4.existsSync(Y)){if(!V4.existsSync(U)){if(r$.storage.initialized&&this.mode==="read")r$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: input file for key "${$}" with "${T}" was not found. Directory "${U}" does not exist.`)}let O=V4.readdirSync(U).map((V)=>[V,V4.readFileSync(j1.join(U,V),"utf-8")]).filter(([V])=>V.endsWith(".input.json")),Q=[];for(let[V,E]of O){let N=` ${V}`,J=` ${kE(JSON.parse(E),{depth:Number.POSITIVE_INFINITY,colors:!0}).split(`
|
|
43
43
|
`).join(`
|
|
44
|
-
`)}`;
|
|
45
|
-
${
|
|
44
|
+
`)}`;Q.push(N,J)}let Z=` ${X}
|
|
45
|
+
${kE(W,{depth:Number.POSITIVE_INFINITY,colors:!0}).split(`
|
|
46
46
|
`).join(`
|
|
47
|
-
`)}`;if(
|
|
47
|
+
`)}`;if(r$.storage.initialized&&this.mode==="read")r$.storage.setItem(`unmatched${v4}${X}`,JSON.stringify(W,null,"\t")),r$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: input file for key "${$}" with subKey "${T}" (${Y}) was not found. Directory "${U}" exists, but the file does not. Below is a list of CACHED INPUT FILES from that directory and their contents, followed by YOUR INPUT DATA.
|
|
48
48
|
|
|
49
49
|
CACHED INPUT FILES:
|
|
50
|
-
${
|
|
50
|
+
${Q.join(`
|
|
51
51
|
`)}
|
|
52
52
|
|
|
53
53
|
YOUR INPUT DATA:
|
|
54
|
-
${
|
|
55
|
-
`)}let
|
|
54
|
+
${Z}
|
|
55
|
+
`)}let w=V4.readFileSync(Y,"utf-8"),G=JSON.stringify(W,null,"\t");if(G!==w){if(r$.storage.initialized&&this.mode==="read")r$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: the content of the cached input file ${Y} does not match the input provided.
|
|
56
56
|
|
|
57
57
|
Provided:
|
|
58
|
-
${
|
|
58
|
+
${G}
|
|
59
59
|
|
|
60
60
|
Cached:
|
|
61
|
-
${G}`)}let z=K6.join(this.baseDir,`${$}/${T}.output.json`);return JSON.parse(l$.readFileSync(z,"utf-8"))}async write($,T,W,X){let Y=K6.join(this.baseDir,$),U=K6.join(Y,`${T}.input.json`),G=K6.join(Y,`${T}.output.json`),J=JSON.stringify(W,null,"\t");if(!l$.existsSync(this.baseDir))l$.mkdirSync(this.baseDir,{recursive:!0});if(!l$.existsSync(Y))l$.mkdirSync(Y);if(l$.writeFileSync(U,J),l$.existsSync(G))l$.unlinkSync(G);let z=await X(...W),w=JSON.stringify(z,null,"\t");return l$.writeFileSync(G,w),z}add($,T){let W=`${this.rootName}${W4}${iW($)}`;return{flush:()=>{this.flush($)},for:(X)=>{if(this.mode!=="off"){if(this.filesTouched.set($,new Set),P$.storage.initialized&&!P$.storage.getItem(`list${W4}${W}`))P$.storage.setItem(`list${W4}${W}`,"true")}return{get:async(...Y)=>{let U=X;if(this.mode!=="off"){let G=this.filenameCache.get(X);if(!G)G=iW(X),this.filenameCache.set(X,G);U=G,this.filesTouched.get($)?.add(U);let J=`${W}${W4}${U}`,z=`file${W4}${J}`;if(P$.storage.initialized&&!P$.storage.getItem(z))P$.storage.setItem(z,"true")}switch(this.mode){case"off":return T(...Y);case"read":return this.read($,U,Y);case"write":return this.write($,U,Y,T);case"read-write":try{return this.read($,U,Y)}catch(G){if(G instanceof Error)return this.write($,U,Y,T);throw G}}}}}}}flush(...$){console.log(this.filesTouched);for(let[T,W]of this.filesTouched.entries())if($.length===0||$.includes(T)){let X=K6.join(this.baseDir,T),Y=l$.readdirSync(X);for(let U of Y){let G=U.replace(".input.json","").replace(".output.json","");if(!W.has(G))console.info(`\uD83E\uDDF9 Flushing ${G}`),l$.unlinkSync(K6.join(X,U))}}}};var pY="RFC3986",dY={RFC1738:($)=>String($).replace(/%20/g,"+"),RFC3986:($)=>String($)},IF="RFC1738";var ER=Array.isArray,j6=(()=>{let $=[];for(let T=0;T<256;++T)$.push("%"+((T<16?"0":"")+T.toString(16)).toUpperCase());return $})();var Lz=1024,kF=($,T,W,X,Y)=>{if($.length===0)return $;let U=$;if(typeof $==="symbol")U=Symbol.prototype.toString.call($);else if(typeof $!=="string")U=String($);if(W==="iso-8859-1")return escape(U).replace(/%u[0-9a-f]{4}/gi,function(J){return"%26%23"+parseInt(J.slice(2),16)+"%3B"});let G="";for(let J=0;J<U.length;J+=Lz){let z=U.length>=Lz?U.slice(J,J+Lz):U,w=[];for(let H=0;H<z.length;++H){let _=z.charCodeAt(H);if(_===45||_===46||_===95||_===126||_>=48&&_<=57||_>=65&&_<=90||_>=97&&_<=122||Y===IF&&(_===40||_===41)){w[w.length]=z.charAt(H);continue}if(_<128){w[w.length]=j6[_];continue}if(_<2048){w[w.length]=j6[192|_>>6]+j6[128|_&63];continue}if(_<55296||_>=57344){w[w.length]=j6[224|_>>12]+j6[128|_>>6&63]+j6[128|_&63];continue}H+=1,_=65536+((_&1023)<<10|z.charCodeAt(H)&1023),w[w.length]=j6[240|_>>18]+j6[128|_>>12&63]+j6[128|_>>6&63]+j6[128|_&63]}G+=w.join("")}return G};function qF($){if(!$||typeof $!=="object")return!1;return!!($.constructor&&$.constructor.isBuffer&&$.constructor.isBuffer($))}function Sz($,T){if(ER($)){let W=[];for(let X=0;X<$.length;X+=1)W.push(T($[X]));return W}return T($)}var MR=Object.prototype.hasOwnProperty,PF={brackets($){return String($)+"[]"},comma:"comma",indices($,T){return String($)+"["+T+"]"},repeat($){return String($)}},x6=Array.isArray,AR=Array.prototype.push,CF=function($,T){AR.apply($,x6(T)?T:[T])},NR=Date.prototype.toISOString,X4={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:kF,encodeValuesOnly:!1,format:pY,formatter:dY[pY],indices:!1,serializeDate($){return NR.call($)},skipNulls:!1,strictNullHandling:!1};function LR($){return typeof $==="string"||typeof $==="number"||typeof $==="boolean"||typeof $==="symbol"||typeof $==="bigint"}var Bz={};function vF($,T,W,X,Y,U,G,J,z,w,H,_,F,D,V,E,R,P){let A=$,N=P,k=0,y=!1;while((N=N.get(Bz))!==void 0&&!y){let B=N.get($);if(k+=1,typeof B!=="undefined")if(B===k)throw new RangeError("Cyclic object value");else y=!0;if(typeof N.get(Bz)==="undefined")k=0}if(typeof w==="function")A=w(T,A);else if(A instanceof Date)A=F?.(A);else if(W==="comma"&&x6(A))A=Sz(A,function(B){if(B instanceof Date)return F?.(B);return B});if(A===null){if(U)return z&&!E?z(T,X4.encoder,R,"key",D):T;A=""}if(LR(A)||qF(A)){if(z){let B=E?T:z(T,X4.encoder,R,"key",D);return[V?.(B)+"="+V?.(z(A,X4.encoder,R,"value",D))]}return[V?.(T)+"="+V?.(String(A))]}let x=[];if(typeof A==="undefined")return x;let m;if(W==="comma"&&x6(A)){if(E&&z)A=Sz(A,z);m=[{value:A.length>0?A.join(",")||null:void 0}]}else if(x6(w))m=w;else{let B=Object.keys(A);m=H?B.sort(H):B}let J$=J?String(T).replace(/\./g,"%2E"):String(T),m$=X&&x6(A)&&A.length===1?J$+"[]":J$;if(Y&&x6(A)&&A.length===0)return m$+"[]";for(let B=0;B<m.length;++B){let Z$=m[B],$$=typeof Z$==="object"&&typeof Z$.value!=="undefined"?Z$.value:A[Z$];if(G&&$$===null)continue;let H$=_&&J?Z$.replace(/\./g,"%2E"):Z$,e$=x6(A)?typeof W==="function"?W(m$,H$):m$:m$+(_?"."+H$:"["+H$+"]");P.set($,k);let V4=new WeakMap;V4.set(Bz,P),CF(x,vF($$,e$,W,X,Y,U,G,J,W==="comma"&&E&&x6(A)?null:z,w,H,_,F,D,V,E,R,V4))}return x}function SR($=X4){if(typeof $.allowEmptyArrays!=="undefined"&&typeof $.allowEmptyArrays!=="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof $.encodeDotInKeys!=="undefined"&&typeof $.encodeDotInKeys!=="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if($.encoder!==null&&typeof $.encoder!=="undefined"&&typeof $.encoder!=="function")throw new TypeError("Encoder has to be a function.");let T=$.charset||X4.charset;if(typeof $.charset!=="undefined"&&$.charset!=="utf-8"&&$.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let W=pY;if(typeof $.format!=="undefined"){if(!MR.call(dY,$.format))throw new TypeError("Unknown format option provided.");W=$.format}let X=dY[W],Y=X4.filter;if(typeof $.filter==="function"||x6($.filter))Y=$.filter;let U;if($.arrayFormat&&$.arrayFormat in PF)U=$.arrayFormat;else if("indices"in $)U=$.indices?"indices":"repeat";else U=X4.arrayFormat;if("commaRoundTrip"in $&&typeof $.commaRoundTrip!=="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let G=typeof $.allowDots==="undefined"?!!$.encodeDotInKeys===!0?!0:X4.allowDots:!!$.allowDots;return{addQueryPrefix:typeof $.addQueryPrefix==="boolean"?$.addQueryPrefix:X4.addQueryPrefix,allowDots:G,allowEmptyArrays:typeof $.allowEmptyArrays==="boolean"?!!$.allowEmptyArrays:X4.allowEmptyArrays,arrayFormat:U,charset:T,charsetSentinel:typeof $.charsetSentinel==="boolean"?$.charsetSentinel:X4.charsetSentinel,commaRoundTrip:!!$.commaRoundTrip,delimiter:typeof $.delimiter==="undefined"?X4.delimiter:$.delimiter,encode:typeof $.encode==="boolean"?$.encode:X4.encode,encodeDotInKeys:typeof $.encodeDotInKeys==="boolean"?$.encodeDotInKeys:X4.encodeDotInKeys,encoder:typeof $.encoder==="function"?$.encoder:X4.encoder,encodeValuesOnly:typeof $.encodeValuesOnly==="boolean"?$.encodeValuesOnly:X4.encodeValuesOnly,filter:Y,format:W,formatter:X,serializeDate:typeof $.serializeDate==="function"?$.serializeDate:X4.serializeDate,skipNulls:typeof $.skipNulls==="boolean"?$.skipNulls:X4.skipNulls,sort:typeof $.sort==="function"?$.sort:null,strictNullHandling:typeof $.strictNullHandling==="boolean"?$.strictNullHandling:X4.strictNullHandling}}function Rz($,T={}){let W=$,X=SR(T),Y,U;if(typeof X.filter==="function")U=X.filter,W=U("",W);else if(x6(X.filter))U=X.filter,Y=U;let G=[];if(typeof W!=="object"||W===null)return"";let J=PF[X.arrayFormat],z=J==="comma"&&X.commaRoundTrip;if(!Y)Y=Object.keys(W);if(X.sort)Y.sort(X.sort);let w=new WeakMap;for(let F=0;F<Y.length;++F){let D=Y[F];if(X.skipNulls&&W[D]===null)continue;CF(G,vF(W[D],D,J,z,X.allowEmptyArrays,X.strictNullHandling,X.skipNulls,X.encodeDotInKeys,X.encode?X.encoder:null,X.filter,X.sort,X.allowDots,X.serializeDate,X.format,X.formatter,X.encodeValuesOnly,X.charset,w))}let H=G.join(X.delimiter),_=X.addQueryPrefix===!0?"?":"";if(X.charsetSentinel)if(X.charset==="iso-8859-1")_+="utf8=%26%2310003%3B&";else _+="utf8=%E2%9C%93&";return H.length>0?_+H:""}var W0="4.103.0";var jF=!1,X0=void 0,Iz=void 0,RR=void 0,IR=void 0,kR=void 0,kz=void 0,qR=void 0,oY=void 0,qz=void 0,Pz=void 0,Cz=void 0,lY=void 0,vz=void 0;function xF($,T={auto:!1}){if(jF)throw new Error(`you must \`import 'openai/shims/${$.kind}'\` before importing anything else from openai`);if(X0)throw new Error(`can't \`import 'openai/shims/${$.kind}'\` after \`import 'openai/shims/${X0}'\``);jF=T.auto,X0=$.kind,Iz=$.fetch,RR=$.Request,IR=$.Response,kR=$.Headers,kz=$.FormData,qR=$.Blob,oY=$.File,qz=$.ReadableStream,Pz=$.getMultipartRequestOptions,Cz=$.getDefaultAgent,lY=$.fileFromPath,vz=$.isFsReadStream}class jz{constructor($){this.body=$}get[Symbol.toStringTag](){return"MultipartBody"}}function bF({manuallyImported:$}={}){let T=$?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from 'openai'`:\n- `import 'openai/shims/node'` (if you're running on Node)\n- `import 'openai/shims/web'` (otherwise)\n",W,X,Y,U;try{W=fetch,X=Request,Y=Response,U=Headers}catch(G){throw new Error(`this environment is missing the following Web Fetch API type: ${G.message}. ${T}`)}return{kind:"web",fetch:W,Request:X,Response:Y,Headers:U,FormData:typeof FormData!=="undefined"?FormData:class G{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${T}`)}},Blob:typeof Blob!=="undefined"?Blob:class G{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${T}`)}},File:typeof File!=="undefined"?File:class G{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${T}`)}},ReadableStream:typeof ReadableStream!=="undefined"?ReadableStream:class G{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${T}`)}},getMultipartRequestOptions:async(G,J)=>({...J,body:new jz(G)}),getDefaultAgent:(G)=>{return},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")},isFsReadStream:(G)=>!1}}import{ReadStream as CR}from"fs";function fF(){let $=bF();function T(W){return W instanceof CR}return{...$,isFsReadStream:T}}var xz=()=>{if(!X0)xF(fF(),{auto:!0})};xz();class l extends Error{}class t$ extends l{constructor($,T,W,X){super(`${t$.makeMessage($,T,W)}`);this.status=$,this.headers=X,this.request_id=X?.["x-request-id"],this.error=T;let Y=T;this.code=Y?.code,this.param=Y?.param,this.type=Y?.type}static makeMessage($,T,W){let X=T?.message?typeof T.message==="string"?T.message:JSON.stringify(T.message):T?JSON.stringify(T):W;if($&&X)return`${$} ${X}`;if($)return`${$} status code (no body)`;if(X)return X;return"(no status code or body)"}static generate($,T,W,X){if(!$||!X)return new Y0({message:W,cause:T8(T)});let Y=T?.error;if($===400)return new rY($,Y,W,X);if($===401)return new iY($,Y,W,X);if($===403)return new nY($,Y,W,X);if($===404)return new tY($,Y,W,X);if($===409)return new aY($,Y,W,X);if($===422)return new sY($,Y,W,X);if($===429)return new eY($,Y,W,X);if($>=500)return new $8($,Y,W,X);return new t$($,Y,W,X)}}class Y4 extends t${constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class Y0 extends t${constructor({message:$,cause:T}){super(void 0,void 0,$||"Connection error.",void 0);if(T)this.cause=T}}class U0 extends Y0{constructor({message:$}={}){super({message:$??"Request timed out."})}}class rY extends t${}class iY extends t${}class nY extends t${}class tY extends t${}class aY extends t${}class sY extends t${}class eY extends t${}class $8 extends t${}class nW extends l{constructor(){super("Could not parse response content as the length limit was reached")}}class tW extends l{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var W8=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},G0=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},t4;class $T{constructor(){t4.set(this,void 0),this.buffer=new Uint8Array,W8(this,t4,null,"f")}decode($){if($==null)return[];let T=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?new TextEncoder().encode($):$,W=new Uint8Array(this.buffer.length+T.length);W.set(this.buffer),W.set(T,this.buffer.length),this.buffer=W;let X=[],Y;while((Y=jR(this.buffer,G0(this,t4,"f")))!=null){if(Y.carriage&&G0(this,t4,"f")==null){W8(this,t4,Y.index,"f");continue}if(G0(this,t4,"f")!=null&&(Y.index!==G0(this,t4,"f")+1||Y.carriage)){X.push(this.decodeText(this.buffer.slice(0,G0(this,t4,"f")-1))),this.buffer=this.buffer.slice(G0(this,t4,"f")),W8(this,t4,null,"f");continue}let U=G0(this,t4,"f")!==null?Y.preceding-1:Y.preceding,G=this.decodeText(this.buffer.slice(0,U));X.push(G),this.buffer=this.buffer.slice(Y.index),W8(this,t4,null,"f")}return X}decodeText($){if($==null)return"";if(typeof $==="string")return $;if(typeof Buffer!=="undefined"){if($ instanceof Buffer)return $.toString();if($ instanceof Uint8Array)return Buffer.from($).toString();throw new l(`Unexpected: received non-Uint8Array (${$.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder!=="undefined"){if($ instanceof Uint8Array||$ instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode($);throw new l(`Unexpected: received non-Uint8Array/ArrayBuffer (${$.constructor.name}) in a web platform. Please report this error.`)}throw new l("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length)return[];return this.decode(`
|
|
62
|
-
`)}}
|
|
63
|
-
`,"\r"])
|
|
64
|
-
`);
|
|
65
|
-
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],Y}if(this.chunks.push($),$.startsWith(":"))return null;let[T,W,X]=fR($,":");if(X.startsWith(" "))X=X.substring(1);if(T==="event")this.event=X;else if(T==="data")this.data.push(X);return null}}function fR($,T){let W=$.indexOf(T);if(W!==-1)return[$.substring(0,W),T,$.substring(W+T.length)];return[$,"",""]}var gF=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function",mF=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&aW($),aW=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function",yR=($)=>{return mF($)||gF($)||vz($)};async function gz($,T,W){if($=await $,mF($))return $;if(gF($)){let Y=await $.blob();T||(T=new URL($.url).pathname.split(/[\\/]/).pop()??"unknown_file");let U=aW(Y)?[await Y.arrayBuffer()]:[Y];return new oY(U,T,W)}let X=await hR($);if(T||(T=mR($)??"unknown_file"),!W?.type){let Y=X[0]?.type;if(typeof Y==="string")W={...W,type:Y}}return new oY(X,T,W)}async function hR($){let T=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)T.push($);else if(aW($))T.push(await $.arrayBuffer());else if(cR($))for await(let W of $)T.push(W);else throw new Error(`Unexpected data type: ${typeof $}; constructor: ${$?.constructor?.name}; props: ${gR($)}`);return T}function gR($){return`[${Object.getOwnPropertyNames($).map((W)=>`"${W}"`).join(", ")}]`}function mR($){return yz($.name)||yz($.filename)||yz($.path)?.split(/[\\/]/).pop()}var yz=($)=>{if(typeof $==="string")return $;if(typeof Buffer!=="undefined"&&$ instanceof Buffer)return String($);return},cR=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",mz=($)=>$&&typeof $==="object"&&$.body&&$[Symbol.toStringTag]==="MultipartBody";var y4=async($)=>{let T=await cF($.body);return Pz(T,$)},cF=async($)=>{let T=new kz;return await Promise.all(Object.entries($||{}).map(([W,X])=>hz(T,W,X))),T};var hz=async($,T,W)=>{if(W===void 0)return;if(W==null)throw new TypeError(`Received null for "${T}"; to pass null in FormData, you must use the string 'null'`);if(typeof W==="string"||typeof W==="number"||typeof W==="boolean")$.append(T,String(W));else if(yR(W)){let X=await gz(W);$.append(T,X)}else if(Array.isArray(W))await Promise.all(W.map((X)=>hz($,T+"[]",X)));else if(typeof W==="object")await Promise.all(Object.entries(W).map(([X,Y])=>hz($,`${T}[${X}]`,Y)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${W} instead`)};var pR=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},dR=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},X8;xz();async function rF($){let{response:T}=$;if($.options.stream){if(i6("response",T.status,T.url,T.headers,T.body),$.options.__streamClass)return $.options.__streamClass.fromSSEResponse(T,$.controller);return a4.fromSSEResponse(T,$.controller)}if(T.status===204)return null;if($.options.__binaryResponse)return T;let X=T.headers.get("content-type")?.split(";")[0]?.trim();if(X?.includes("application/json")||X?.endsWith("+json")){let G=await T.json();return i6("response",T.status,T.url,T.headers,G),iF(G,T)}let U=await T.text();return i6("response",T.status,T.url,T.headers,U),U}function iF($,T){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:T.headers.get("x-request-id"),enumerable:!1})}class U8 extends Promise{constructor($,T=rF){super((W)=>{W(null)});this.responsePromise=$,this.parseResponse=T}_thenUnwrap($){return new U8(this.responsePromise,async(T)=>iF($(await this.parseResponse(T),T),T.response))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,T]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:T,request_id:T.headers.get("x-request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(this.parseResponse);return this.parsedPromise}then($,T){return this.parse().then($,T)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}class uz{constructor({baseURL:$,maxRetries:T=2,timeout:W=600000,httpAgent:X,fetch:Y}){this.baseURL=$,this.maxRetries=cz("maxRetries",T),this.timeout=cz("timeout",W),this.httpAgent=X,this.fetch=Y??Iz}authHeaders($){return{}}defaultHeaders($){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...iR(),...this.authHeaders($)}}validateHeaders($,T){}defaultIdempotencyKey(){return`stainless-node-retry-${sR()}`}get($,T){return this.methodRequest("get",$,T)}post($,T){return this.methodRequest("post",$,T)}patch($,T){return this.methodRequest("patch",$,T)}put($,T){return this.methodRequest("put",$,T)}delete($,T){return this.methodRequest("delete",$,T)}methodRequest($,T,W){return this.request(Promise.resolve(W).then(async(X)=>{let Y=X&&aW(X?.body)?new DataView(await X.body.arrayBuffer()):X?.body instanceof DataView?X.body:X?.body instanceof ArrayBuffer?new DataView(X.body):X&&ArrayBuffer.isView(X?.body)?new DataView(X.body.buffer):X?.body;return{method:$,path:T,...X,body:Y}}))}getAPIList($,T,W){return this.requestAPIList(T,{method:"get",path:$,...W})}calculateContentLength($){if(typeof $==="string"){if(typeof Buffer!=="undefined")return Buffer.byteLength($,"utf8").toString();if(typeof TextEncoder!=="undefined")return new TextEncoder().encode($).length.toString()}else if(ArrayBuffer.isView($))return $.byteLength.toString();return null}buildRequest($,{retryCount:T=0}={}){let W={...$},{method:X,path:Y,query:U,headers:G={}}=W,J=ArrayBuffer.isView(W.body)||W.__binaryRequest&&typeof W.body==="string"?W.body:mz(W.body)?W.body.body:W.body?JSON.stringify(W.body,null,2):null,z=this.calculateContentLength(J),w=this.buildURL(Y,U);if("timeout"in W)cz("timeout",W.timeout);W.timeout=W.timeout??this.timeout;let H=W.httpAgent??this.httpAgent??Cz(w),_=W.timeout+1000;if(typeof H?.options?.timeout==="number"&&_>(H.options.timeout??0))H.options.timeout=_;if(this.idempotencyHeader&&X!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=$.idempotencyKey}let F=this.buildHeaders({options:W,headers:G,contentLength:z,retryCount:T});return{req:{method:X,...J&&{body:J},headers:F,...H&&{agent:H},signal:W.signal??null},url:w,timeout:W.timeout}}buildHeaders({options:$,headers:T,contentLength:W,retryCount:X}){let Y={};if(W)Y["content-length"]=W;let U=this.defaultHeaders($);if(oF(Y,U),oF(Y,T),mz($.body)&&X0!=="node")delete Y["content-type"];if(Y8(U,"x-stainless-retry-count")===void 0&&Y8(T,"x-stainless-retry-count")===void 0)Y["x-stainless-retry-count"]=String(X);if(Y8(U,"x-stainless-timeout")===void 0&&Y8(T,"x-stainless-timeout")===void 0&&$.timeout)Y["x-stainless-timeout"]=String(Math.trunc($.timeout/1000));return this.validateHeaders(Y,T),Y}async prepareOptions($){}async prepareRequest($,{url:T,options:W}){}parseHeaders($){return!$?{}:(Symbol.iterator in $)?Object.fromEntries(Array.from($).map((T)=>[...T])):{...$}}makeStatusError($,T,W,X){return t$.generate($,T,W,X)}request($,T=null){return new U8(this.makeRequest($,T))}async makeRequest($,T){let W=await $,X=W.maxRetries??this.maxRetries;if(T==null)T=X;await this.prepareOptions(W);let{req:Y,url:U,timeout:G}=this.buildRequest(W,{retryCount:X-T});if(await this.prepareRequest(Y,{url:U,options:W}),i6("request",U,W,Y.headers),W.signal?.aborted)throw new Y4;let J=new AbortController,z=await this.fetchWithTimeout(U,Y,G,J).catch(T8);if(z instanceof Error){if(W.signal?.aborted)throw new Y4;if(T)return this.retryRequest(W,T);if(z.name==="AbortError")throw new U0;throw new Y0({cause:z})}let w=fz(z.headers);if(!z.ok){if(T&&this.shouldRetry(z)){let E=`retrying, ${T} attempts remaining`;return i6(`response (error; ${E})`,z.status,U,w),this.retryRequest(W,T,w)}let H=await z.text().catch((E)=>T8(E).message),_=nR(H),F=_?void 0:H;throw i6(`response (error; ${T?"(error; no more retries left)":"(error; not retryable)"})`,z.status,U,w,F),this.makeStatusError(z.status,_,F,w)}return{response:z,options:W,controller:J}}requestAPIList($,T){let W=this.makeRequest(T,null);return new nF(this,W,$)}buildURL($,T){let W=aR($)?new URL($):new URL(this.baseURL+(this.baseURL.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),X=this.defaultQuery();if(!tF(X))T={...X,...T};if(typeof T==="object"&&T&&!Array.isArray(T))W.search=this.stringifyQuery(T);return W.toString()}stringifyQuery($){return Object.entries($).filter(([T,W])=>typeof W!=="undefined").map(([T,W])=>{if(typeof W==="string"||typeof W==="number"||typeof W==="boolean")return`${encodeURIComponent(T)}=${encodeURIComponent(W)}`;if(W===null)return`${encodeURIComponent(T)}=`;throw new l(`Cannot stringify type ${typeof W}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}async fetchWithTimeout($,T,W,X){let{signal:Y,...U}=T||{};if(Y)Y.addEventListener("abort",()=>X.abort());let G=setTimeout(()=>X.abort(),W),J={signal:X.signal,...U};if(J.method)J.method=J.method.toUpperCase();return this.fetch.call(void 0,$,J).finally(()=>{clearTimeout(G)})}shouldRetry($){let T=$.headers.get("x-should-retry");if(T==="true")return!0;if(T==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,T,W){let X,Y=W?.["retry-after-ms"];if(Y){let G=parseFloat(Y);if(!Number.isNaN(G))X=G}let U=W?.["retry-after"];if(U&&!X){let G=parseFloat(U);if(!Number.isNaN(G))X=G*1000;else X=Date.parse(U)-Date.now()}if(!(X&&0<=X&&X<60000)){let G=$.maxRetries??this.maxRetries;X=this.calculateDefaultRetryTimeoutMillis(T,G)}return await n6(X),this.makeRequest($,T-1)}calculateDefaultRetryTimeoutMillis($,T){let Y=T-$,U=Math.min(0.5*Math.pow(2,Y),8),G=1-Math.random()*0.25;return U*G*1000}getUserAgent(){return`${this.constructor.name}/JS ${W0}`}}class G8{constructor($,T,W,X){X8.set(this,void 0),pR(this,X8,$,"f"),this.options=X,this.response=T,this.body=W}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageInfo()!=null}async getNextPage(){let $=this.nextPageInfo();if(!$)throw new l("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let T={...this.options};if("params"in $&&typeof T.query==="object")T.query={...T.query,...$.params};else if("url"in $){let W=[...Object.entries(T.query||{}),...$.url.searchParams.entries()];for(let[X,Y]of W)$.url.searchParams.set(X,Y);T.query=void 0,T.path=$.url.toString()}return await dR(this,X8,"f").requestAPIList(this.constructor,T)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(X8=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let T of $.getPaginatedItems())yield T}}class nF extends U8{constructor($,T,W){super(T,async(X)=>new W($,X.response,await rF(X),X.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let T of $)yield T}}var fz=($)=>{return new Proxy(Object.fromEntries($.entries()),{get(T,W){let X=W.toString();return T[X.toLowerCase()]||T[X]}})},oR={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__metadata:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},T$=($)=>{return typeof $==="object"&&$!==null&&!tF($)&&Object.keys($).every((T)=>aF(oR,T))},lR=()=>{if(typeof Deno!=="undefined"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":W0,"X-Stainless-OS":pF(Deno.build.os),"X-Stainless-Arch":uF(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime!=="undefined")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":W0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process!=="undefined"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":W0,"X-Stainless-OS":pF(process.platform),"X-Stainless-Arch":uF(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let $=rR();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":W0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${$.browser}`,"X-Stainless-Runtime-Version":$.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":W0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function rR(){if(typeof navigator==="undefined"||!navigator)return null;let $=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:T,pattern:W}of $){let X=W.exec(navigator.userAgent);if(X){let Y=X[1]||0,U=X[2]||0,G=X[3]||0;return{browser:T,version:`${Y}.${U}.${G}`}}}return null}var uF=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},pF=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},dF,iR=()=>{return dF??(dF=lR())},nR=($)=>{try{return JSON.parse($)}catch(T){return}},tR=/^[a-z][a-z0-9+.-]*:/i,aR=($)=>{return tR.test($)},n6=($)=>new Promise((T)=>setTimeout(T,$)),cz=($,T)=>{if(typeof T!=="number"||!Number.isInteger(T))throw new l(`${$} must be an integer`);if(T<0)throw new l(`${$} must be a positive integer`);return T},T8=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null)try{return new Error(JSON.stringify($))}catch{}return new Error($)};var sW=($)=>{if(typeof process!=="undefined")return process.env?.[$]?.trim()??void 0;if(typeof Deno!=="undefined")return Deno.env?.get?.($)?.trim();return};function tF($){if(!$)return!0;for(let T in $)return!1;return!0}function aF($,T){return Object.prototype.hasOwnProperty.call($,T)}function oF($,T){for(let W in T){if(!aF(T,W))continue;let X=W.toLowerCase();if(!X)continue;let Y=T[W];if(Y===null)delete $[X];else if(Y!==void 0)$[X]=Y}}var lF=new Set(["authorization","api-key"]);function i6($,...T){if(typeof process!=="undefined"&&process?.env?.DEBUG==="true"){let W=T.map((X)=>{if(!X)return X;if(X.headers){let U={...X,headers:{...X.headers}};for(let G in X.headers)if(lF.has(G.toLowerCase()))U.headers[G]="REDACTED";return U}let Y=null;for(let U in X)if(lF.has(U.toLowerCase()))Y??(Y={...X}),Y[U]="REDACTED";return Y??X});console.log(`OpenAI:DEBUG:${$}`,...W)}}var sR=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,($)=>{let T=Math.random()*16|0;return($==="x"?T:T&3|8).toString(16)})},sF=()=>{return typeof window!=="undefined"&&typeof window.document!=="undefined"&&typeof navigator!=="undefined"},eR=($)=>{return typeof $?.get==="function"};var Y8=($,T)=>{let W=T.toLowerCase();if(eR($)){let X=T[0]?.toUpperCase()+T.substring(1).replace(/([^\w])(\w)/g,(Y,U,G)=>U+G.toUpperCase());for(let Y of[T,W,T.toUpperCase(),X]){let U=$.get(Y);if(U)return U}}for(let[X,Y]of Object.entries($))if(X.toLowerCase()===W){if(Array.isArray(Y)){if(Y.length<=1)return Y[0];return console.warn(`Received ${Y.length} entries for the ${T} header, using the first entry.`),Y[0]}return Y}return};var eF=($)=>{if(typeof Buffer!=="undefined"){let T=Buffer.from($,"base64");return Array.from(new Float32Array(T.buffer,T.byteOffset,T.length/Float32Array.BYTES_PER_ELEMENT))}else{let T=atob($),W=T.length,X=new Uint8Array(W);for(let Y=0;Y<W;Y++)X[Y]=T.charCodeAt(Y);return Array.from(new Float32Array(X.buffer))}};function eW($){return $!=null&&typeof $==="object"&&!Array.isArray($)}class a6 extends G8{constructor($,T,W,X){super($,T,W,X);this.data=W.data||[],this.object=W.object}getPaginatedItems(){return this.data??[]}nextPageParams(){return null}nextPageInfo(){return null}}class F$ extends G8{constructor($,T,W,X){super($,T,W,X);this.data=W.data||[],this.has_more=W.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageParams(){let $=this.nextPageInfo();if(!$)return null;if("params"in $)return $.params;let T=Object.fromEntries($.url.searchParams);if(!Object.keys(T).length)return null;return T}nextPageInfo(){let $=this.getPaginatedItems();if(!$.length)return null;let T=$[$.length-1]?.id;if(!T)return null;return{params:{after:T}}}}class C{constructor($){this._client=$}}class $2 extends C{list($,T={},W){if(T$(T))return this.list($,{},T);return this._client.getAPIList(`/chat/completions/${$}/messages`,pz,{query:T,...W})}}class J0 extends C{constructor(){super(...arguments);this.messages=new $2(this._client)}create($,T){return this._client.post("/chat/completions",{body:$,...T,stream:$.stream??!1})}retrieve($,T){return this._client.get(`/chat/completions/${$}`,T)}update($,T,W){return this._client.post(`/chat/completions/${$}`,{body:T,...W})}list($={},T){if(T$($))return this.list({},$);return this._client.getAPIList("/chat/completions",w0,{query:$,...T})}del($,T){return this._client.delete(`/chat/completions/${$}`,T)}}class w0 extends F${}class pz extends F${}J0.ChatCompletionsPage=w0;J0.Messages=$2;class k1 extends C{constructor(){super(...arguments);this.completions=new J0(this._client)}}k1.Completions=J0;k1.ChatCompletionsPage=w0;class T2 extends C{create($,T){return this._client.post("/audio/speech",{body:$,...T,headers:{Accept:"application/octet-stream",...T?.headers},__binaryResponse:!0})}}class W2 extends C{create($,T){return this._client.post("/audio/transcriptions",y4({body:$,...T,stream:$.stream??!1,__metadata:{model:$.model}}))}}class X2 extends C{create($,T){return this._client.post("/audio/translations",y4({body:$,...T,__metadata:{model:$.model}}))}}class s6 extends C{constructor(){super(...arguments);this.transcriptions=new W2(this._client),this.translations=new X2(this._client),this.speech=new T2(this._client)}}s6.Transcriptions=W2;s6.Translations=X2;s6.Speech=T2;class z0 extends C{create($,T){return this._client.post("/batches",{body:$,...T})}retrieve($,T){return this._client.get(`/batches/${$}`,T)}list($={},T){if(T$($))return this.list({},$);return this._client.getAPIList("/batches",TT,{query:$,...T})}cancel($,T){return this._client.post(`/batches/${$}/cancel`,T)}}class TT extends F${}z0.BatchesPage=TT;var E6=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},p$=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},dz,J8,w8,Y2,U2,z8,G2,e6,J2,_8,H8,WT,$Q;class _0{constructor(){dz.add(this),this.controller=new AbortController,J8.set(this,void 0),w8.set(this,()=>{}),Y2.set(this,()=>{}),U2.set(this,void 0),z8.set(this,()=>{}),G2.set(this,()=>{}),e6.set(this,{}),J2.set(this,!1),_8.set(this,!1),H8.set(this,!1),WT.set(this,!1),E6(this,J8,new Promise(($,T)=>{E6(this,w8,$,"f"),E6(this,Y2,T,"f")}),"f"),E6(this,U2,new Promise(($,T)=>{E6(this,z8,$,"f"),E6(this,G2,T,"f")}),"f"),p$(this,J8,"f").catch(()=>{}),p$(this,U2,"f").catch(()=>{})}_run($){setTimeout(()=>{$().then(()=>{this._emitFinal(),this._emit("end")},p$(this,dz,"m",$Q).bind(this))},0)}_connected(){if(this.ended)return;p$(this,w8,"f").call(this),this._emit("connect")}get ended(){return p$(this,J2,"f")}get errored(){return p$(this,_8,"f")}get aborted(){return p$(this,H8,"f")}abort(){this.controller.abort()}on($,T){return(p$(this,e6,"f")[$]||(p$(this,e6,"f")[$]=[])).push({listener:T}),this}off($,T){let W=p$(this,e6,"f")[$];if(!W)return this;let X=W.findIndex((Y)=>Y.listener===T);if(X>=0)W.splice(X,1);return this}once($,T){return(p$(this,e6,"f")[$]||(p$(this,e6,"f")[$]=[])).push({listener:T,once:!0}),this}emitted($){return new Promise((T,W)=>{if(E6(this,WT,!0,"f"),$!=="error")this.once("error",W);this.once($,T)})}async done(){E6(this,WT,!0,"f"),await p$(this,U2,"f")}_emit($,...T){if(p$(this,J2,"f"))return;if($==="end")E6(this,J2,!0,"f"),p$(this,z8,"f").call(this);let W=p$(this,e6,"f")[$];if(W)p$(this,e6,"f")[$]=W.filter((X)=>!X.once),W.forEach(({listener:X})=>X(...T));if($==="abort"){let X=T[0];if(!p$(this,WT,"f")&&!W?.length)Promise.reject(X);p$(this,Y2,"f").call(this,X),p$(this,G2,"f").call(this,X),this._emit("end");return}if($==="error"){let X=T[0];if(!p$(this,WT,"f")&&!W?.length)Promise.reject(X);p$(this,Y2,"f").call(this,X),p$(this,G2,"f").call(this,X),this._emit("end")}}_emitFinal(){}}J8=new WeakMap,w8=new WeakMap,Y2=new WeakMap,U2=new WeakMap,z8=new WeakMap,G2=new WeakMap,e6=new WeakMap,J2=new WeakMap,_8=new WeakMap,H8=new WeakMap,WT=new WeakMap,dz=new WeakSet,$Q=function $(T){if(E6(this,_8,!0,"f"),T instanceof Error&&T.name==="AbortError")T=new Y4;if(T instanceof Y4)return E6(this,H8,!0,"f"),this._emit("abort",T);if(T instanceof l)return this._emit("error",T);if(T instanceof Error){let W=new l(T.message);return W.cause=T,this._emit("error",W)}return this._emit("error",new l(String(T)))};var r=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},s4=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},D4,oz,b6,F8,M6,F0,XT,H0,D8,e4,Q8,Z8,_2,w2,z2,TQ,WQ,XQ,YQ,UQ,GQ,JQ;class $6 extends _0{constructor(){super(...arguments);D4.add(this),oz.set(this,[]),b6.set(this,{}),F8.set(this,{}),M6.set(this,void 0),F0.set(this,void 0),XT.set(this,void 0),H0.set(this,void 0),D8.set(this,void 0),e4.set(this,void 0),Q8.set(this,void 0),Z8.set(this,void 0),_2.set(this,void 0)}[(oz=new WeakMap,b6=new WeakMap,F8=new WeakMap,M6=new WeakMap,F0=new WeakMap,XT=new WeakMap,H0=new WeakMap,D8=new WeakMap,e4=new WeakMap,Q8=new WeakMap,Z8=new WeakMap,_2=new WeakMap,D4=new WeakSet,Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("event",(X)=>{let Y=T.shift();if(Y)Y.resolve(X);else $.push(X)}),this.on("end",()=>{W=!0;for(let X of T)X.resolve(void 0);T.length=0}),this.on("abort",(X)=>{W=!0;for(let Y of T)Y.reject(X);T.length=0}),this.on("error",(X)=>{W=!0;for(let Y of T)Y.reject(X);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((Y,U)=>T.push({resolve:Y,reject:U})).then((Y)=>Y?{value:Y,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}static fromReadableStream($){let T=new $6;return T._run(()=>T._fromReadableStream($)),T}async _fromReadableStream($,T){let W=T?.signal;if(W){if(W.aborted)this.controller.abort();W.addEventListener("abort",()=>this.controller.abort())}this._connected();let X=a4.fromReadableStream($,this.controller);for await(let Y of X)r(this,D4,"m",w2).call(this,Y);if(X.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,D4,"m",z2).call(this))}toReadableStream(){return new a4(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream($,T,W,X,Y){let U=new $6;return U._run(()=>U._runToolAssistantStream($,T,W,X,{...Y,headers:{...Y?.headers,"X-Stainless-Helper-Method":"stream"}})),U}async _createToolAssistantStream($,T,W,X,Y){let U=Y?.signal;if(U){if(U.aborted)this.controller.abort();U.addEventListener("abort",()=>this.controller.abort())}let G={...X,stream:!0},J=await $.submitToolOutputs(T,W,G,{...Y,signal:this.controller.signal});this._connected();for await(let z of J)r(this,D4,"m",w2).call(this,z);if(J.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,D4,"m",z2).call(this))}static createThreadAssistantStream($,T,W){let X=new $6;return X._run(()=>X._threadAssistantStream($,T,{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),X}static createAssistantStream($,T,W,X){let Y=new $6;return Y._run(()=>Y._runAssistantStream($,T,W,{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),Y}currentEvent(){return r(this,Q8,"f")}currentRun(){return r(this,Z8,"f")}currentMessageSnapshot(){return r(this,M6,"f")}currentRunStepSnapshot(){return r(this,_2,"f")}async finalRunSteps(){return await this.done(),Object.values(r(this,b6,"f"))}async finalMessages(){return await this.done(),Object.values(r(this,F8,"f"))}async finalRun(){if(await this.done(),!r(this,F0,"f"))throw Error("Final run was not received.");return r(this,F0,"f")}async _createThreadAssistantStream($,T,W){let X=W?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}let Y={...T,stream:!0},U=await $.createAndRun(Y,{...W,signal:this.controller.signal});this._connected();for await(let G of U)r(this,D4,"m",w2).call(this,G);if(U.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,D4,"m",z2).call(this))}async _createAssistantStream($,T,W,X){let Y=X?.signal;if(Y){if(Y.aborted)this.controller.abort();Y.addEventListener("abort",()=>this.controller.abort())}let U={...W,stream:!0},G=await $.create(T,U,{...X,signal:this.controller.signal});this._connected();for await(let J of G)r(this,D4,"m",w2).call(this,J);if(G.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,D4,"m",z2).call(this))}static accumulateDelta($,T){for(let[W,X]of Object.entries(T)){if(!$.hasOwnProperty(W)){$[W]=X;continue}let Y=$[W];if(Y===null||Y===void 0){$[W]=X;continue}if(W==="index"||W==="type"){$[W]=X;continue}if(typeof Y==="string"&&typeof X==="string")Y+=X;else if(typeof Y==="number"&&typeof X==="number")Y+=X;else if(eW(Y)&&eW(X))Y=this.accumulateDelta(Y,X);else if(Array.isArray(Y)&&Array.isArray(X)){if(Y.every((U)=>typeof U==="string"||typeof U==="number")){Y.push(...X);continue}for(let U of X){if(!eW(U))throw new Error(`Expected array delta entry to be an object but got: ${U}`);let G=U.index;if(G==null)throw console.error(U),new Error("Expected array delta entry to have an `index` property");if(typeof G!=="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${G}`);let J=Y[G];if(J==null)Y.push(U);else Y[G]=this.accumulateDelta(J,U)}continue}else throw Error(`Unhandled record type: ${W}, deltaValue: ${X}, accValue: ${Y}`);$[W]=Y}return $}_addRun($){return $}async _threadAssistantStream($,T,W){return await this._createThreadAssistantStream(T,$,W)}async _runAssistantStream($,T,W,X){return await this._createAssistantStream(T,$,W,X)}async _runToolAssistantStream($,T,W,X,Y){return await this._createToolAssistantStream(W,$,T,X,Y)}}w2=function $(T){if(this.ended)return;switch(s4(this,Q8,T,"f"),r(this,D4,"m",XQ).call(this,T),T.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":r(this,D4,"m",JQ).call(this,T);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":r(this,D4,"m",WQ).call(this,T);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":r(this,D4,"m",TQ).call(this,T);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier");default:UI(T)}},z2=function $(){if(this.ended)throw new l("stream has ended, this shouldn't happen");if(!r(this,F0,"f"))throw Error("Final run has not been received");return r(this,F0,"f")},TQ=function $(T){let[W,X]=r(this,D4,"m",UQ).call(this,T,r(this,M6,"f"));s4(this,M6,W,"f"),r(this,F8,"f")[W.id]=W;for(let Y of X){let U=W.content[Y.index];if(U?.type=="text")this._emit("textCreated",U.text)}switch(T.event){case"thread.message.created":this._emit("messageCreated",T.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",T.data.delta,W),T.data.delta.content)for(let Y of T.data.delta.content){if(Y.type=="text"&&Y.text){let U=Y.text,G=W.content[Y.index];if(G&&G.type=="text")this._emit("textDelta",U,G.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(Y.index!=r(this,XT,"f")){if(r(this,H0,"f"))switch(r(this,H0,"f").type){case"text":this._emit("textDone",r(this,H0,"f").text,r(this,M6,"f"));break;case"image_file":this._emit("imageFileDone",r(this,H0,"f").image_file,r(this,M6,"f"));break}s4(this,XT,Y.index,"f")}s4(this,H0,W.content[Y.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(r(this,XT,"f")!==void 0){let Y=T.data.content[r(this,XT,"f")];if(Y)switch(Y.type){case"image_file":this._emit("imageFileDone",Y.image_file,r(this,M6,"f"));break;case"text":this._emit("textDone",Y.text,r(this,M6,"f"));break}}if(r(this,M6,"f"))this._emit("messageDone",T.data);s4(this,M6,void 0,"f")}},WQ=function $(T){let W=r(this,D4,"m",YQ).call(this,T);switch(s4(this,_2,W,"f"),T.event){case"thread.run.step.created":this._emit("runStepCreated",T.data);break;case"thread.run.step.delta":let X=T.data.delta;if(X.step_details&&X.step_details.type=="tool_calls"&&X.step_details.tool_calls&&W.step_details.type=="tool_calls")for(let U of X.step_details.tool_calls)if(U.index==r(this,D8,"f"))this._emit("toolCallDelta",U,W.step_details.tool_calls[U.index]);else{if(r(this,e4,"f"))this._emit("toolCallDone",r(this,e4,"f"));if(s4(this,D8,U.index,"f"),s4(this,e4,W.step_details.tool_calls[U.index],"f"),r(this,e4,"f"))this._emit("toolCallCreated",r(this,e4,"f"))}this._emit("runStepDelta",T.data.delta,W);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":if(s4(this,_2,void 0,"f"),T.data.step_details.type=="tool_calls"){if(r(this,e4,"f"))this._emit("toolCallDone",r(this,e4,"f")),s4(this,e4,void 0,"f")}this._emit("runStepDone",T.data,W);break;case"thread.run.step.in_progress":break}},XQ=function $(T){r(this,oz,"f").push(T),this._emit("event",T)},YQ=function $(T){switch(T.event){case"thread.run.step.created":return r(this,b6,"f")[T.data.id]=T.data,T.data;case"thread.run.step.delta":let W=r(this,b6,"f")[T.data.id];if(!W)throw Error("Received a RunStepDelta before creation of a snapshot");let X=T.data;if(X.delta){let Y=$6.accumulateDelta(W,X.delta);r(this,b6,"f")[T.data.id]=Y}return r(this,b6,"f")[T.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":r(this,b6,"f")[T.data.id]=T.data;break}if(r(this,b6,"f")[T.data.id])return r(this,b6,"f")[T.data.id];throw new Error("No snapshot available")},UQ=function $(T,W){let X=[];switch(T.event){case"thread.message.created":return[T.data,X];case"thread.message.delta":if(!W)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let Y=T.data;if(Y.delta.content)for(let U of Y.delta.content)if(U.index in W.content){let G=W.content[U.index];W.content[U.index]=r(this,D4,"m",GQ).call(this,U,G)}else W.content[U.index]=U,X.push(U);return[W,X];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(W)return[W,X];else throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},GQ=function $(T,W){return $6.accumulateDelta(W,T)},JQ=function $(T){switch(s4(this,Z8,T.data,"f"),T.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":if(s4(this,F0,T.data,"f"),r(this,e4,"f"))this._emit("toolCallDone",r(this,e4,"f")),s4(this,e4,void 0,"f");break;case"thread.run.cancelling":break}};function UI($){}class YT extends C{create($,T){return this._client.post("/assistants",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}retrieve($,T){return this._client.get(`/assistants/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}update($,T,W){return this._client.post(`/assistants/${$}`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}list($={},T){if(T$($))return this.list({},$);return this._client.getAPIList("/assistants",H2,{query:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}del($,T){return this._client.delete(`/assistants/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class H2 extends F${}YT.AssistantsPage=H2;function lz($){return typeof $.parse==="function"}var q1=($)=>{return $?.role==="assistant"},rz=($)=>{return $?.role==="function"},iz=($)=>{return $?.role==="tool"};function F2($){return $?.$brand==="auto-parseable-response-format"}function Q0($){return $?.$brand==="auto-parseable-tool"}function wQ($,T){if(!T||!nz(T))return{...$,choices:$.choices.map((W)=>({...W,message:{...W.message,parsed:null,...W.message.tool_calls?{tool_calls:W.message.tool_calls}:void 0}}))};return Q2($,T)}function Q2($,T){let W=$.choices.map((X)=>{if(X.finish_reason==="length")throw new nW;if(X.finish_reason==="content_filter")throw new tW;return{...X,message:{...X.message,...X.message.tool_calls?{tool_calls:X.message.tool_calls?.map((Y)=>wI(T,Y))??void 0}:void 0,parsed:X.message.content&&!X.message.refusal?JI(T,X.message.content):null}}});return{...$,choices:W}}function JI($,T){if($.response_format?.type!=="json_schema")return null;if($.response_format?.type==="json_schema"){if("$parseRaw"in $.response_format)return $.response_format.$parseRaw(T);return JSON.parse(T)}return null}function wI($,T){let W=$.tools?.find((X)=>X.function?.name===T.function.name);return{...T,function:{...T.function,parsed_arguments:Q0(W)?W.$parseRaw(T.function.arguments):W?.function.strict?JSON.parse(T.function.arguments):null}}}function zQ($,T){if(!$)return!1;let W=$.tools?.find((X)=>X.function?.name===T.function.name);return Q0(W)||W?.function.strict||!1}function nz($){if(F2($.response_format))return!0;return $.tools?.some((T)=>Q0(T)||T.type==="function"&&T.function.strict===!0)??!1}function _Q($){for(let T of $??[]){if(T.type!=="function")throw new l(`Currently only \`function\` tool types support auto-parsing; Received \`${T.type}\``);if(T.function.strict!==!0)throw new l(`The \`${T.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var h4=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},A4,tz,O8,az,sz,ez,FQ,$7,HQ=10;class Z2 extends _0{constructor(){super(...arguments);A4.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion($){this._chatCompletions.push($),this._emit("chatCompletion",$);let T=$.choices[0]?.message;if(T)this._addMessage(T);return $}_addMessage($,T=!0){if(!("content"in $))$.content=null;if(this.messages.push($),T){if(this._emit("message",$),(rz($)||iz($))&&$.content)this._emit("functionCallResult",$.content);else if(q1($)&&$.function_call)this._emit("functionCall",$.function_call);else if(q1($)&&$.tool_calls){for(let W of $.tool_calls)if(W.type==="function")this._emit("functionCall",W.function)}}}async finalChatCompletion(){await this.done();let $=this._chatCompletions[this._chatCompletions.length-1];if(!$)throw new l("stream ended without producing a ChatCompletion");return $}async finalContent(){return await this.done(),h4(this,A4,"m",tz).call(this)}async finalMessage(){return await this.done(),h4(this,A4,"m",O8).call(this)}async finalFunctionCall(){return await this.done(),h4(this,A4,"m",az).call(this)}async finalFunctionCallResult(){return await this.done(),h4(this,A4,"m",sz).call(this)}async totalUsage(){return await this.done(),h4(this,A4,"m",ez).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let $=this._chatCompletions[this._chatCompletions.length-1];if($)this._emit("finalChatCompletion",$);let T=h4(this,A4,"m",O8).call(this);if(T)this._emit("finalMessage",T);let W=h4(this,A4,"m",tz).call(this);if(W)this._emit("finalContent",W);let X=h4(this,A4,"m",az).call(this);if(X)this._emit("finalFunctionCall",X);let Y=h4(this,A4,"m",sz).call(this);if(Y!=null)this._emit("finalFunctionCallResult",Y);if(this._chatCompletions.some((U)=>U.usage))this._emit("totalUsage",h4(this,A4,"m",ez).call(this))}async _createChatCompletion($,T,W){let X=W?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}h4(this,A4,"m",FQ).call(this,T);let Y=await $.chat.completions.create({...T,stream:!1},{...W,signal:this.controller.signal});return this._connected(),this._addChatCompletion(Q2(Y,T))}async _runChatCompletion($,T,W){for(let X of T.messages)this._addMessage(X,!1);return await this._createChatCompletion($,T,W)}async _runFunctions($,T,W){let{function_call:Y="auto",stream:U,...G}=T,J=typeof Y!=="string"&&Y?.name,{maxChatCompletions:z=HQ}=W||{},w={};for(let _ of T.functions)w[_.name||_.function.name]=_;let H=T.functions.map((_)=>({name:_.name||_.function.name,parameters:_.parameters,description:_.description}));for(let _ of T.messages)this._addMessage(_,!1);for(let _=0;_<z;++_){let D=(await this._createChatCompletion($,{...G,function_call:Y,functions:H,messages:[...this.messages]},W)).choices[0]?.message;if(!D)throw new l("missing message in ChatCompletion response");if(!D.function_call)return;let{name:V,arguments:E}=D.function_call,R=w[V];if(!R){let k=`Invalid function_call: ${JSON.stringify(V)}. Available options are: ${H.map((y)=>JSON.stringify(y.name)).join(", ")}. Please try again`;this._addMessage({role:"function",name:V,content:k});continue}else if(J&&J!==V){let k=`Invalid function_call: ${JSON.stringify(V)}. ${JSON.stringify(J)} requested. Please try again`;this._addMessage({role:"function",name:V,content:k});continue}let P;try{P=lz(R)?await R.parse(E):E}catch(k){this._addMessage({role:"function",name:V,content:k instanceof Error?k.message:String(k)});continue}let A=await R.function(P,this),N=h4(this,A4,"m",$7).call(this,A);if(this._addMessage({role:"function",name:V,content:N}),J)return}}async _runTools($,T,W){let{tool_choice:Y="auto",stream:U,...G}=T,J=typeof Y!=="string"&&Y?.function?.name,{maxChatCompletions:z=HQ}=W||{},w=T.tools.map((F)=>{if(Q0(F)){if(!F.$callback)throw new l("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:F.$callback,name:F.function.name,description:F.function.description||"",parameters:F.function.parameters,parse:F.$parseRaw,strict:!0}}}return F}),H={};for(let F of w)if(F.type==="function")H[F.function.name||F.function.function.name]=F.function;let _="tools"in T?w.map((F)=>F.type==="function"?{type:"function",function:{name:F.function.name||F.function.function.name,parameters:F.function.parameters,description:F.function.description,strict:F.function.strict}}:F):void 0;for(let F of T.messages)this._addMessage(F,!1);for(let F=0;F<z;++F){let V=(await this._createChatCompletion($,{...G,tool_choice:Y,tools:_,messages:[...this.messages]},W)).choices[0]?.message;if(!V)throw new l("missing message in ChatCompletion response");if(!V.tool_calls?.length)return;for(let E of V.tool_calls){if(E.type!=="function")continue;let R=E.id,{name:P,arguments:A}=E.function,N=H[P];if(!N){let m=`Invalid tool_call: ${JSON.stringify(P)}. Available options are: ${Object.keys(H).map((J$)=>JSON.stringify(J$)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:R,content:m});continue}else if(J&&J!==P){let m=`Invalid tool_call: ${JSON.stringify(P)}. ${JSON.stringify(J)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:R,content:m});continue}let k;try{k=lz(N)?await N.parse(A):A}catch(m){let J$=m instanceof Error?m.message:String(m);this._addMessage({role:"tool",tool_call_id:R,content:J$});continue}let y=await N.function(k,this),x=h4(this,A4,"m",$7).call(this,y);if(this._addMessage({role:"tool",tool_call_id:R,content:x}),J)return}}return}}A4=new WeakSet,tz=function $(){return h4(this,A4,"m",O8).call(this).content??null},O8=function $(){let T=this.messages.length;while(T-- >0){let W=this.messages[T];if(q1(W)){let{function_call:X,...Y}=W,U={...Y,content:W.content??null,refusal:W.refusal??null};if(X)U.function_call=X;return U}}throw new l("stream ended without producing a ChatCompletionMessage with role=assistant")},az=function $(){for(let T=this.messages.length-1;T>=0;T--){let W=this.messages[T];if(q1(W)&&W?.function_call)return W.function_call;if(q1(W)&&W?.tool_calls?.length)return W.tool_calls.at(-1)?.function}return},sz=function $(){for(let T=this.messages.length-1;T>=0;T--){let W=this.messages[T];if(rz(W)&&W.content!=null)return W.content;if(iz(W)&&W.content!=null&&typeof W.content==="string"&&this.messages.some((X)=>X.role==="assistant"&&X.tool_calls?.some((Y)=>Y.type==="function"&&Y.id===W.tool_call_id)))return W.content}return},ez=function $(){let T={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:W}of this._chatCompletions)if(W)T.completion_tokens+=W.completion_tokens,T.prompt_tokens+=W.prompt_tokens,T.total_tokens+=W.total_tokens;return T},FQ=function $(T){if(T.n!=null&&T.n>1)throw new l("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},$7=function $(T){return typeof T==="string"?T:T===void 0?"undefined":JSON.stringify(T)};class UT extends Z2{static runFunctions($,T,W){let X=new UT,Y={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return X._run(()=>X._runFunctions($,T,Y)),X}static runTools($,T,W){let X=new UT,Y={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runTools"}};return X._run(()=>X._runTools($,T,Y)),X}_addMessage($,T=!0){if(super._addMessage($,T),q1($)&&$.content)this._emit("content",$.content)}}var H4={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511};class QQ extends Error{}class ZQ extends Error{}function zI($,T=H4.ALL){if(typeof $!=="string")throw new TypeError(`expecting str, got ${typeof $}`);if(!$.trim())throw new Error(`${$} is empty`);return _I($.trim(),T)}var _I=($,T)=>{let W=$.length,X=0,Y=(F)=>{throw new QQ(`${F} at position ${X}`)},U=(F)=>{throw new ZQ(`${F} at position ${X}`)},G=()=>{if(_(),X>=W)Y("Unexpected end of input");if($[X]==='"')return J();if($[X]==="{")return z();if($[X]==="[")return w();if($.substring(X,X+4)==="null"||H4.NULL&T&&W-X<4&&"null".startsWith($.substring(X)))return X+=4,null;if($.substring(X,X+4)==="true"||H4.BOOL&T&&W-X<4&&"true".startsWith($.substring(X)))return X+=4,!0;if($.substring(X,X+5)==="false"||H4.BOOL&T&&W-X<5&&"false".startsWith($.substring(X)))return X+=5,!1;if($.substring(X,X+8)==="Infinity"||H4.INFINITY&T&&W-X<8&&"Infinity".startsWith($.substring(X)))return X+=8,1/0;if($.substring(X,X+9)==="-Infinity"||H4.MINUS_INFINITY&T&&1<W-X&&W-X<9&&"-Infinity".startsWith($.substring(X)))return X+=9,-1/0;if($.substring(X,X+3)==="NaN"||H4.NAN&T&&W-X<3&&"NaN".startsWith($.substring(X)))return X+=3,NaN;return H()},J=()=>{let F=X,D=!1;X++;while(X<W&&($[X]!=='"'||D&&$[X-1]==="\\"))D=$[X]==="\\"?!D:!1,X++;if($.charAt(X)=='"')try{return JSON.parse($.substring(F,++X-Number(D)))}catch(V){U(String(V))}else if(H4.STR&T)try{return JSON.parse($.substring(F,X-Number(D))+'"')}catch(V){return JSON.parse($.substring(F,$.lastIndexOf("\\"))+'"')}Y("Unterminated string literal")},z=()=>{X++,_();let F={};try{while($[X]!=="}"){if(_(),X>=W&&H4.OBJ&T)return F;let D=J();_(),X++;try{let V=G();Object.defineProperty(F,D,{value:V,writable:!0,enumerable:!0,configurable:!0})}catch(V){if(H4.OBJ&T)return F;else throw V}if(_(),$[X]===",")X++}}catch(D){if(H4.OBJ&T)return F;else Y("Expected '}' at end of object")}return X++,F},w=()=>{X++;let F=[];try{while($[X]!=="]")if(F.push(G()),_(),$[X]===",")X++}catch(D){if(H4.ARR&T)return F;Y("Expected ']' at end of array")}return X++,F},H=()=>{if(X===0){if($==="-"&&H4.NUM&T)Y("Not sure what '-' is");try{return JSON.parse($)}catch(D){if(H4.NUM&T)try{if($[$.length-1]===".")return JSON.parse($.substring(0,$.lastIndexOf(".")));return JSON.parse($.substring(0,$.lastIndexOf("e")))}catch(V){}U(String(D))}}let F=X;if($[X]==="-")X++;while($[X]&&!",]}".includes($[X]))X++;if(X==W&&!(H4.NUM&T))Y("Unterminated number literal");try{return JSON.parse($.substring(F,X))}catch(D){if($.substring(F,X)==="-"&&H4.NUM&T)Y("Not sure what '-' is");try{return JSON.parse($.substring(F,$.lastIndexOf("e")))}catch(V){U(String(V))}}},_=()=>{while(X<W&&`
|
|
66
|
-
\r `.includes($[
|
|
67
|
-
${
|
|
68
|
-
${
|
|
69
|
-
${
|
|
70
|
-
${E8($)}`);return{...J$,id:m,type:x,function:{...Z$,name:B,arguments:m$}}})}};return{...D,message:{...P,content:V,role:A,refusal:w.refusal??null},finish_reason:H,index:_,logprobs:F}}),created:Y,model:U,object:"chat.completion",...G?{system_fingerprint:G}:{}};return wQ(z,T)}function E8($){return JSON.stringify($)}function OQ($){return}function VQ($){}class D0 extends Z0{static fromReadableStream($){let T=new D0(null);return T._run(()=>T._fromReadableStream($)),T}static runFunctions($,T,W){let X=new D0(null),Y={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return X._run(()=>X._runFunctions($,T,Y)),X}static runTools($,T,W){let X=new D0(T),Y={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runTools"}};return X._run(()=>X._runTools($,T,Y)),X}}class M8 extends C{parse($,T){return _Q($.tools),this._client.chat.completions.create($,{...T,headers:{...T?.headers,"X-Stainless-Helper-Method":"beta.chat.completions.parse"}})._thenUnwrap((W)=>Q2(W,$))}runFunctions($,T){if($.stream)return D0.runFunctions(this._client,$,T);return UT.runFunctions(this._client,$,T)}runTools($,T){if($.stream)return D0.runTools(this._client,$,T);return UT.runTools(this._client,$,T)}stream($,T){return Z0.createChatCompletion(this._client,$,T)}}class D2 extends C{constructor(){super(...arguments);this.completions=new M8(this._client)}}(function($){$.Completions=M8})(D2||(D2={}));class O2 extends C{create($,T){return this._client.post("/realtime/sessions",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class V2 extends C{create($,T){return this._client.post("/realtime/transcription_sessions",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class O0 extends C{constructor(){super(...arguments);this.sessions=new O2(this._client),this.transcriptionSessions=new V2(this._client)}}O0.Sessions=O2;O0.TranscriptionSessions=V2;class wT extends C{create($,T,W){return this._client.post(`/threads/${$}/messages`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}retrieve($,T,W){return this._client.get(`/threads/${$}/messages/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}update($,T,W,X){return this._client.post(`/threads/${$}/messages/${T}`,{body:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}list($,T={},W){if(T$(T))return this.list($,{},T);return this._client.getAPIList(`/threads/${$}/messages`,K2,{query:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}del($,T,W){return this._client.delete(`/threads/${$}/messages/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class K2 extends F${}wT.MessagesPage=K2;class zT extends C{retrieve($,T,W,X={},Y){if(T$(X))return this.retrieve($,T,W,{},X);return this._client.get(`/threads/${$}/runs/${T}/steps/${W}`,{query:X,...Y,headers:{"OpenAI-Beta":"assistants=v2",...Y?.headers}})}list($,T,W={},X){if(T$(W))return this.list($,T,{},W);return this._client.getAPIList(`/threads/${$}/runs/${T}/steps`,E2,{query:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}}class E2 extends F${}zT.RunStepsPage=E2;class C1 extends C{constructor(){super(...arguments);this.steps=new zT(this._client)}create($,T,W){let{include:X,...Y}=T;return this._client.post(`/threads/${$}/runs`,{query:{include:X},body:Y,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers},stream:T.stream??!1})}retrieve($,T,W){return this._client.get(`/threads/${$}/runs/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}update($,T,W,X){return this._client.post(`/threads/${$}/runs/${T}`,{body:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}list($,T={},W){if(T$(T))return this.list($,{},T);return this._client.getAPIList(`/threads/${$}/runs`,M2,{query:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}cancel($,T,W){return this._client.post(`/threads/${$}/runs/${T}/cancel`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}async createAndPoll($,T,W){let X=await this.create($,T,W);return await this.poll($,X.id,W)}createAndStream($,T,W){return $6.createAssistantStream($,this._client.beta.threads.runs,T,W)}async poll($,T,W){let X={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)X["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let{data:Y,response:U}=await this.retrieve($,T,{...W,headers:{...W?.headers,...X}}).withResponse();switch(Y.status){case"queued":case"in_progress":case"cancelling":let G=5000;if(W?.pollIntervalMs)G=W.pollIntervalMs;else{let J=U.headers.get("openai-poll-after-ms");if(J){let z=parseInt(J);if(!isNaN(z))G=z}}await n6(G);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return Y}}}stream($,T,W){return $6.createAssistantStream($,this._client.beta.threads.runs,T,W)}submitToolOutputs($,T,W,X){return this._client.post(`/threads/${$}/runs/${T}/submit_tool_outputs`,{body:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers},stream:W.stream??!1})}async submitToolOutputsAndPoll($,T,W,X){let Y=await this.submitToolOutputs($,T,W,X);return await this.poll($,Y.id,X)}submitToolOutputsStream($,T,W,X){return $6.createToolAssistantStream($,T,this._client.beta.threads.runs,W,X)}}class M2 extends F${}C1.RunsPage=M2;C1.Steps=zT;C1.RunStepsPage=E2;class T1 extends C{constructor(){super(...arguments);this.runs=new C1(this._client),this.messages=new wT(this._client)}create($={},T){if(T$($))return this.create({},$);return this._client.post("/threads",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}retrieve($,T){return this._client.get(`/threads/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}update($,T,W){return this._client.post(`/threads/${$}`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}del($,T){return this._client.delete(`/threads/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}createAndRun($,T){return this._client.post("/threads/runs",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers},stream:$.stream??!1})}async createAndRunPoll($,T){let W=await this.createAndRun($,T);return await this.runs.poll(W.thread_id,W.id,T)}createAndRunStream($,T){return $6.createThreadAssistantStream($,this._client.beta.threads,T)}}T1.Runs=C1;T1.RunsPage=M2;T1.Messages=wT;T1.MessagesPage=K2;class f6 extends C{constructor(){super(...arguments);this.realtime=new O0(this._client),this.chat=new D2(this._client),this.assistants=new YT(this._client),this.threads=new T1(this._client)}}f6.Realtime=O0;f6.Assistants=YT;f6.AssistantsPage=H2;f6.Threads=T1;class _T extends C{create($,T){return this._client.post("/completions",{body:$,...T,stream:$.stream??!1})}}class A2 extends C{retrieve($,T,W){return this._client.get(`/containers/${$}/files/${T}/content`,{...W,headers:{Accept:"*/*",...W?.headers}})}}class V0 extends C{constructor(){super(...arguments);this.content=new A2(this._client)}create($,T,W){return this._client.post(`/containers/${$}/files`,y4({body:T,...W}))}retrieve($,T,W){return this._client.get(`/containers/${$}/files/${T}`,W)}list($,T={},W){if(T$(T))return this.list($,{},T);return this._client.getAPIList(`/containers/${$}/files`,N2,{query:T,...W})}del($,T,W){return this._client.delete(`/containers/${$}/files/${T}`,{...W,headers:{Accept:"*/*",...W?.headers}})}}class N2 extends F${}V0.FileListResponsesPage=N2;V0.Content=A2;class W1 extends C{constructor(){super(...arguments);this.files=new V0(this._client)}create($,T){return this._client.post("/containers",{body:$,...T})}retrieve($,T){return this._client.get(`/containers/${$}`,T)}list($={},T){if(T$($))return this.list({},$);return this._client.getAPIList("/containers",HT,{query:$,...T})}del($,T){return this._client.delete(`/containers/${$}`,{...T,headers:{Accept:"*/*",...T?.headers}})}}class HT extends F${}W1.ContainerListResponsesPage=HT;W1.Files=V0;W1.FileListResponsesPage=N2;class FT extends C{create($,T){let W=!!$.encoding_format,X=W?$.encoding_format:"base64";if(W)i6("Request","User defined encoding_format:",$.encoding_format);let Y=this._client.post("/embeddings",{body:{...$,encoding_format:X},...T});if(W)return Y;return i6("response","Decoding base64 embeddings to float32 array"),Y._thenUnwrap((U)=>{if(U&&U.data)U.data.forEach((G)=>{let J=G.embedding;G.embedding=eF(J)});return U})}}class QT extends C{retrieve($,T,W,X){return this._client.get(`/evals/${$}/runs/${T}/output_items/${W}`,X)}list($,T,W={},X){if(T$(W))return this.list($,T,{},W);return this._client.getAPIList(`/evals/${$}/runs/${T}/output_items`,L2,{query:W,...X})}}class L2 extends F${}QT.OutputItemListResponsesPage=L2;class v1 extends C{constructor(){super(...arguments);this.outputItems=new QT(this._client)}create($,T,W){return this._client.post(`/evals/${$}/runs`,{body:T,...W})}retrieve($,T,W){return this._client.get(`/evals/${$}/runs/${T}`,W)}list($,T={},W){if(T$(T))return this.list($,{},T);return this._client.getAPIList(`/evals/${$}/runs`,S2,{query:T,...W})}del($,T,W){return this._client.delete(`/evals/${$}/runs/${T}`,W)}cancel($,T,W){return this._client.post(`/evals/${$}/runs/${T}`,W)}}class S2 extends F${}v1.RunListResponsesPage=S2;v1.OutputItems=QT;v1.OutputItemListResponsesPage=L2;class X1 extends C{constructor(){super(...arguments);this.runs=new v1(this._client)}create($,T){return this._client.post("/evals",{body:$,...T})}retrieve($,T){return this._client.get(`/evals/${$}`,T)}update($,T,W){return this._client.post(`/evals/${$}`,{body:T,...W})}list($={},T){if(T$($))return this.list({},$);return this._client.getAPIList("/evals",ZT,{query:$,...T})}del($,T){return this._client.delete(`/evals/${$}`,T)}}class ZT extends F${}X1.EvalListResponsesPage=ZT;X1.Runs=v1;X1.RunListResponsesPage=S2;class K0 extends C{create($,T){return this._client.post("/files",y4({body:$,...T}))}retrieve($,T){return this._client.get(`/files/${$}`,T)}list($={},T){if(T$($))return this.list({},$);return this._client.getAPIList("/files",DT,{query:$,...T})}del($,T){return this._client.delete(`/files/${$}`,T)}content($,T){return this._client.get(`/files/${$}/content`,{...T,headers:{Accept:"application/binary",...T?.headers},__binaryResponse:!0})}retrieveContent($,T){return this._client.get(`/files/${$}/content`,T)}async waitForProcessing($,{pollInterval:T=5000,maxWait:W=1800000}={}){let X=new Set(["processed","error","deleted"]),Y=Date.now(),U=await this.retrieve($);while(!U.status||!X.has(U.status))if(await n6(T),U=await this.retrieve($),Date.now()-Y>W)throw new U0({message:`Giving up on waiting for file ${$} to finish processing after ${W} milliseconds.`});return U}}class DT extends F${}K0.FileObjectsPage=DT;class B2 extends C{}class R2 extends C{run($,T){return this._client.post("/fine_tuning/alpha/graders/run",{body:$,...T})}validate($,T){return this._client.post("/fine_tuning/alpha/graders/validate",{body:$,...T})}}class OT extends C{constructor(){super(...arguments);this.graders=new R2(this._client)}}OT.Graders=R2;class VT extends C{create($,T,W){return this._client.getAPIList(`/fine_tuning/checkpoints/${$}/permissions`,I2,{body:T,method:"post",...W})}retrieve($,T={},W){if(T$(T))return this.retrieve($,{},T);return this._client.get(`/fine_tuning/checkpoints/${$}/permissions`,{query:T,...W})}del($,T,W){return this._client.delete(`/fine_tuning/checkpoints/${$}/permissions/${T}`,W)}}class I2 extends a6{}VT.PermissionCreateResponsesPage=I2;class E0 extends C{constructor(){super(...arguments);this.permissions=new VT(this._client)}}E0.Permissions=VT;E0.PermissionCreateResponsesPage=I2;class KT extends C{list($,T={},W){if(T$(T))return this.list($,{},T);return this._client.getAPIList(`/fine_tuning/jobs/${$}/checkpoints`,k2,{query:T,...W})}}class k2 extends F${}KT.FineTuningJobCheckpointsPage=k2;class Y1 extends C{constructor(){super(...arguments);this.checkpoints=new KT(this._client)}create($,T){return this._client.post("/fine_tuning/jobs",{body:$,...T})}retrieve($,T){return this._client.get(`/fine_tuning/jobs/${$}`,T)}list($={},T){if(T$($))return this.list({},$);return this._client.getAPIList("/fine_tuning/jobs",q2,{query:$,...T})}cancel($,T){return this._client.post(`/fine_tuning/jobs/${$}/cancel`,T)}listEvents($,T={},W){if(T$(T))return this.listEvents($,{},T);return this._client.getAPIList(`/fine_tuning/jobs/${$}/events`,P2,{query:T,...W})}pause($,T){return this._client.post(`/fine_tuning/jobs/${$}/pause`,T)}resume($,T){return this._client.post(`/fine_tuning/jobs/${$}/resume`,T)}}class q2 extends F${}class P2 extends F${}Y1.FineTuningJobsPage=q2;Y1.FineTuningJobEventsPage=P2;Y1.Checkpoints=KT;Y1.FineTuningJobCheckpointsPage=k2;class G6 extends C{constructor(){super(...arguments);this.methods=new B2(this._client),this.jobs=new Y1(this._client),this.checkpoints=new E0(this._client),this.alpha=new OT(this._client)}}G6.Methods=B2;G6.Jobs=Y1;G6.FineTuningJobsPage=q2;G6.FineTuningJobEventsPage=P2;G6.Checkpoints=E0;G6.Alpha=OT;class C2 extends C{}class M0 extends C{constructor(){super(...arguments);this.graderModels=new C2(this._client)}}M0.GraderModels=C2;class ET extends C{createVariation($,T){return this._client.post("/images/variations",y4({body:$,...T}))}edit($,T){return this._client.post("/images/edits",y4({body:$,...T}))}generate($,T){return this._client.post("/images/generations",{body:$,...T})}}class A0 extends C{retrieve($,T){return this._client.get(`/models/${$}`,T)}list($){return this._client.getAPIList("/models",MT,$)}del($,T){return this._client.delete(`/models/${$}`,T)}}class MT extends a6{}A0.ModelsPage=MT;class AT extends C{create($,T){return this._client.post("/moderations",{body:$,...T})}}function KQ($,T){if(!T||!xI(T))return{...$,output_parsed:null,output:$.output.map((W)=>{if(W.type==="function_call")return{...W,parsed_arguments:null};if(W.type==="message")return{...W,content:W.content.map((X)=>({...X,parsed:null}))};else return W})};return J7($,T)}function J7($,T){let W=$.output.map((Y)=>{if(Y.type==="function_call")return{...Y,parsed_arguments:yI(T,Y)};if(Y.type==="message"){let U=Y.content.map((G)=>{if(G.type==="output_text")return{...G,parsed:jI(T,G.text)};return G});return{...Y,content:U}}return Y}),X=Object.assign({},$,{output:W});if(!Object.getOwnPropertyDescriptor($,"output_text"))A8(X);return Object.defineProperty(X,"output_parsed",{enumerable:!0,get(){for(let Y of X.output){if(Y.type!=="message")continue;for(let U of Y.content)if(U.type==="output_text"&&U.parsed!==null)return U.parsed}return null}}),X}function jI($,T){if($.text?.format?.type!=="json_schema")return null;if("$parseRaw"in $.text?.format)return($.text?.format).$parseRaw(T);return JSON.parse(T)}function xI($){if(F2($.text?.format))return!0;return!1}function bI($){return $?.$brand==="auto-parseable-tool"}function fI($,T){return $.find((W)=>W.type==="function"&&W.name===T)}function yI($,T){let W=fI($.tools??[],T.name);return{...T,...T,parsed_arguments:bI(W)?W.$parseRaw(T.arguments):W?.strict?JSON.parse(T.arguments):null}}function A8($){let T=[];for(let W of $.output){if(W.type!=="message")continue;for(let X of W.content)if(X.type==="output_text")T.push(X.text)}$.output_text=T.join("")}class v2 extends C{list($,T={},W){if(T$(T))return this.list($,{},T);return this._client.getAPIList(`/responses/${$}/input_items`,w7,{query:T,...W})}}var NT=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},j1=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},LT,N8,x1,L8,EQ,MQ,AQ,NQ;class S8 extends _0{constructor($){super();LT.add(this),N8.set(this,void 0),x1.set(this,void 0),L8.set(this,void 0),NT(this,N8,$,"f")}static createResponse($,T,W){let X=new S8(T);return X._run(()=>X._createOrRetrieveResponse($,T,{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),X}async _createOrRetrieveResponse($,T,W){let X=W?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}j1(this,LT,"m",EQ).call(this);let Y,U=null;if("response_id"in T)Y=await $.responses.retrieve(T.response_id,{stream:!0},{...W,signal:this.controller.signal,stream:!0}),U=T.starting_after??null;else Y=await $.responses.create({...T,stream:!0},{...W,signal:this.controller.signal});this._connected();for await(let G of Y)j1(this,LT,"m",MQ).call(this,G,U);if(Y.controller.signal?.aborted)throw new Y4;return j1(this,LT,"m",AQ).call(this)}[(N8=new WeakMap,x1=new WeakMap,L8=new WeakMap,LT=new WeakSet,EQ=function $(){if(this.ended)return;NT(this,x1,void 0,"f")},MQ=function $(T,W){if(this.ended)return;let X=(U,G)=>{if(W==null||G.sequence_number>W)this._emit(U,G)},Y=j1(this,LT,"m",NQ).call(this,T);switch(X("event",T),T.type){case"response.output_text.delta":{let U=Y.output[T.output_index];if(!U)throw new l(`missing output at index ${T.output_index}`);if(U.type==="message"){let G=U.content[T.content_index];if(!G)throw new l(`missing content at index ${T.content_index}`);if(G.type!=="output_text")throw new l(`expected content to be 'output_text', got ${G.type}`);X("response.output_text.delta",{...T,snapshot:G.text})}break}case"response.function_call_arguments.delta":{let U=Y.output[T.output_index];if(!U)throw new l(`missing output at index ${T.output_index}`);if(U.type==="function_call")X("response.function_call_arguments.delta",{...T,snapshot:U.arguments});break}default:X(T.type,T);break}},AQ=function $(){if(this.ended)throw new l("stream has ended, this shouldn't happen");let T=j1(this,x1,"f");if(!T)throw new l("request ended without sending any events");NT(this,x1,void 0,"f");let W=gI(T,j1(this,N8,"f"));return NT(this,L8,W,"f"),W},NQ=function $(T){let W=j1(this,x1,"f");if(!W){if(T.type!=="response.created")throw new l(`When snapshot hasn't been set yet, expected 'response.created' event, got ${T.type}`);return W=NT(this,x1,T.response,"f"),W}switch(T.type){case"response.output_item.added":{W.output.push(T.item);break}case"response.content_part.added":{let X=W.output[T.output_index];if(!X)throw new l(`missing output at index ${T.output_index}`);if(X.type==="message")X.content.push(T.part);break}case"response.output_text.delta":{let X=W.output[T.output_index];if(!X)throw new l(`missing output at index ${T.output_index}`);if(X.type==="message"){let Y=X.content[T.content_index];if(!Y)throw new l(`missing content at index ${T.content_index}`);if(Y.type!=="output_text")throw new l(`expected content to be 'output_text', got ${Y.type}`);Y.text+=T.delta}break}case"response.function_call_arguments.delta":{let X=W.output[T.output_index];if(!X)throw new l(`missing output at index ${T.output_index}`);if(X.type==="function_call")X.arguments+=T.delta;break}case"response.completed":{NT(this,x1,T.response,"f");break}}return W},Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("event",(X)=>{let Y=T.shift();if(Y)Y.resolve(X);else $.push(X)}),this.on("end",()=>{W=!0;for(let X of T)X.resolve(void 0);T.length=0}),this.on("abort",(X)=>{W=!0;for(let Y of T)Y.reject(X);T.length=0}),this.on("error",(X)=>{W=!0;for(let Y of T)Y.reject(X);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((Y,U)=>T.push({resolve:Y,reject:U})).then((Y)=>Y?{value:Y,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}async finalResponse(){await this.done();let $=j1(this,L8,"f");if(!$)throw new l("stream ended without producing a ChatCompletion");return $}}function gI($,T){return KQ($,T)}class N0 extends C{constructor(){super(...arguments);this.inputItems=new v2(this._client)}create($,T){return this._client.post("/responses",{body:$,...T,stream:$.stream??!1})._thenUnwrap((W)=>{if("object"in W&&W.object==="response")A8(W);return W})}retrieve($,T={},W){if(T$(T)&&W===void 0)return this.retrieve($,{},T);return this._client.get(`/responses/${$}`,{query:T,...W,stream:T.stream??!1})._thenUnwrap((X)=>{if("object"in X&&X.object==="response")A8(X);return X})}del($,T){return this._client.delete(`/responses/${$}`,{...T,headers:{Accept:"*/*",...T?.headers}})}parse($,T){return this._client.responses.create($,T)._thenUnwrap((W)=>J7(W,$))}stream($,T){return S8.createResponse(this._client,$,T)}cancel($,T){return this._client.post(`/responses/${$}/cancel`,{...T,headers:{Accept:"*/*",...T?.headers}})}}class w7 extends F${}N0.InputItems=v2;class j2 extends C{create($,T,W){return this._client.post(`/uploads/${$}/parts`,y4({body:T,...W}))}}class L0 extends C{constructor(){super(...arguments);this.parts=new j2(this._client)}create($,T){return this._client.post("/uploads",{body:$,...T})}cancel($,T){return this._client.post(`/uploads/${$}/cancel`,T)}complete($,T,W){return this._client.post(`/uploads/${$}/complete`,{body:T,...W})}}L0.Parts=j2;var LQ=async($)=>{let T=await Promise.allSettled($),W=T.filter((Y)=>Y.status==="rejected");if(W.length){for(let Y of W)console.error(Y.reason);throw new Error(`${W.length} promise(s) failed - see the above errors`)}let X=[];for(let Y of T)if(Y.status==="fulfilled")X.push(Y.value);return X};class S0 extends C{create($,T,W){return this._client.post(`/vector_stores/${$}/files`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}retrieve($,T,W){return this._client.get(`/vector_stores/${$}/files/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}update($,T,W,X){return this._client.post(`/vector_stores/${$}/files/${T}`,{body:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}list($,T={},W){if(T$(T))return this.list($,{},T);return this._client.getAPIList(`/vector_stores/${$}/files`,B0,{query:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}del($,T,W){return this._client.delete(`/vector_stores/${$}/files/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}async createAndPoll($,T,W){let X=await this.create($,T,W);return await this.poll($,X.id,W)}async poll($,T,W){let X={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)X["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let Y=await this.retrieve($,T,{...W,headers:X}).withResponse(),U=Y.data;switch(U.status){case"in_progress":let G=5000;if(W?.pollIntervalMs)G=W.pollIntervalMs;else{let J=Y.response.headers.get("openai-poll-after-ms");if(J){let z=parseInt(J);if(!isNaN(z))G=z}}await n6(G);break;case"failed":case"completed":return U}}}async upload($,T,W){let X=await this._client.files.create({file:T,purpose:"assistants"},W);return this.create($,{file_id:X.id},W)}async uploadAndPoll($,T,W){let X=await this.upload($,T,W);return await this.poll($,X.id,W)}content($,T,W){return this._client.getAPIList(`/vector_stores/${$}/files/${T}/content`,x2,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class B0 extends F${}class x2 extends a6{}S0.VectorStoreFilesPage=B0;S0.FileContentResponsesPage=x2;class b2 extends C{create($,T,W){return this._client.post(`/vector_stores/${$}/file_batches`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}retrieve($,T,W){return this._client.get(`/vector_stores/${$}/file_batches/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}cancel($,T,W){return this._client.post(`/vector_stores/${$}/file_batches/${T}/cancel`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}async createAndPoll($,T,W){let X=await this.create($,T);return await this.poll($,X.id,W)}listFiles($,T,W={},X){if(T$(W))return this.listFiles($,T,{},W);return this._client.getAPIList(`/vector_stores/${$}/file_batches/${T}/files`,B0,{query:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}async poll($,T,W){let X={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)X["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let{data:Y,response:U}=await this.retrieve($,T,{...W,headers:X}).withResponse();switch(Y.status){case"in_progress":let G=5000;if(W?.pollIntervalMs)G=W.pollIntervalMs;else{let J=U.headers.get("openai-poll-after-ms");if(J){let z=parseInt(J);if(!isNaN(z))G=z}}await n6(G);break;case"failed":case"cancelled":case"completed":return Y}}}async uploadAndPoll($,{files:T,fileIds:W=[]},X){if(T==null||T.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let Y=X?.maxConcurrency??5,U=Math.min(Y,T.length),G=this._client,J=T.values(),z=[...W];async function w(_){for(let F of _){let D=await G.files.create({file:F,purpose:"assistants"},X);z.push(D.id)}}let H=Array(U).fill(J).map(w);return await LQ(H),await this.createAndPoll($,{file_ids:z})}}class J6 extends C{constructor(){super(...arguments);this.files=new S0(this._client),this.fileBatches=new b2(this._client)}create($,T){return this._client.post("/vector_stores",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}retrieve($,T){return this._client.get(`/vector_stores/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}update($,T,W){return this._client.post(`/vector_stores/${$}`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}list($={},T){if(T$($))return this.list({},$);return this._client.getAPIList("/vector_stores",ST,{query:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}del($,T){return this._client.delete(`/vector_stores/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}search($,T,W){return this._client.getAPIList(`/vector_stores/${$}/search`,BT,{body:T,method:"post",...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class ST extends F${}class BT extends a6{}J6.VectorStoresPage=ST;J6.VectorStoreSearchResponsesPage=BT;J6.Files=S0;J6.VectorStoreFilesPage=B0;J6.FileContentResponsesPage=x2;J6.FileBatches=b2;var SQ;class X$ extends uz{constructor({baseURL:$=sW("OPENAI_BASE_URL"),apiKey:T=sW("OPENAI_API_KEY"),organization:W=sW("OPENAI_ORG_ID")??null,project:X=sW("OPENAI_PROJECT_ID")??null,...Y}={}){if(T===void 0)throw new l("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");let U={apiKey:T,organization:W,project:X,...Y,baseURL:$||"https://api.openai.com/v1"};if(!U.dangerouslyAllowBrowser&&sF())throw new l(`It looks like you're running in a browser-like environment.
|
|
61
|
+
${w}`)}let H=j1.join(this.baseDir,`${$}/${T}.output.json`);return JSON.parse(V4.readFileSync(H,"utf-8"))}async write($,T,W,U){let X=j1.join(this.baseDir,$),Y=j1.join(X,`${T}.input.json`),w=j1.join(X,`${T}.output.json`),G=JSON.stringify(W,null,"\t");if(!V4.existsSync(this.baseDir))V4.mkdirSync(this.baseDir,{recursive:!0});if(!V4.existsSync(X))V4.mkdirSync(X);if(V4.writeFileSync(Y,G),V4.existsSync(w))V4.unlinkSync(w);let H=await U(...W),z=JSON.stringify(H,null,"\t");return V4.writeFileSync(w,z),H}add($,T){let W=`${this.rootName}${v4}${PX($)}`;return{flush:()=>{this.flush($)},for:(U)=>{if(this.mode!=="off"){if(this.filesTouched.set($,new Set),r$.storage.initialized&&!r$.storage.getItem(`list${v4}${W}`))r$.storage.setItem(`list${v4}${W}`,"true")}return{get:async(...X)=>{let Y=U;if(this.mode!=="off"){let w=this.filenameCache.get(U);if(!w)w=PX(U),this.filenameCache.set(U,w);Y=w,this.filesTouched.get($)?.add(Y);let G=`${W}${v4}${Y}`,H=`file${v4}${G}`;if(r$.storage.initialized&&!r$.storage.getItem(H))r$.storage.setItem(H,"true")}switch(this.mode){case"off":return T(...X);case"read":return this.read($,Y,X);case"write":return this.write($,Y,X,T);case"read-write":try{return this.read($,Y,X)}catch(w){if(w instanceof Error)return this.write($,Y,X,T);throw w}}}}}}}flush(...$){console.log(this.filesTouched);for(let[T,W]of this.filesTouched.entries())if($.length===0||$.includes(T)){let U=j1.join(this.baseDir,T),X=V4.readdirSync(U);for(let Y of X){let w=Y.replace(".input.json","").replace(".output.json","");if(!W.has(w))console.info(`\uD83E\uDDF9 Flushing ${w}`),V4.unlinkSync(j1.join(U,Y))}}}};var QG="RFC3986",ZG={RFC1738:($)=>String($).replace(/%20/g,"+"),RFC3986:($)=>String($)},qE="RFC1738";var Ix=Array.isArray,i1=(()=>{let $=[];for(let T=0;T<256;++T)$.push("%"+((T<16?"0":"")+T.toString(16)).toUpperCase());return $})();var jF=1024,PE=($,T,W,U,X)=>{if($.length===0)return $;let Y=$;if(typeof $==="symbol")Y=Symbol.prototype.toString.call($);else if(typeof $!=="string")Y=String($);if(W==="iso-8859-1")return escape(Y).replace(/%u[0-9a-f]{4}/gi,function(G){return"%26%23"+parseInt(G.slice(2),16)+"%3B"});let w="";for(let G=0;G<Y.length;G+=jF){let H=Y.length>=jF?Y.slice(G,G+jF):Y,z=[];for(let F=0;F<H.length;++F){let O=H.charCodeAt(F);if(O===45||O===46||O===95||O===126||O>=48&&O<=57||O>=65&&O<=90||O>=97&&O<=122||X===qE&&(O===40||O===41)){z[z.length]=H.charAt(F);continue}if(O<128){z[z.length]=i1[O];continue}if(O<2048){z[z.length]=i1[192|O>>6]+i1[128|O&63];continue}if(O<55296||O>=57344){z[z.length]=i1[224|O>>12]+i1[128|O>>6&63]+i1[128|O&63];continue}F+=1,O=65536+((O&1023)<<10|H.charCodeAt(F)&1023),z[z.length]=i1[240|O>>18]+i1[128|O>>12&63]+i1[128|O>>6&63]+i1[128|O&63]}w+=z.join("")}return w};function CE($){if(!$||typeof $!=="object")return!1;return!!($.constructor&&$.constructor.isBuffer&&$.constructor.isBuffer($))}function BF($,T){if(Ix($)){let W=[];for(let U=0;U<$.length;U+=1)W.push(T($[U]));return W}return T($)}var bx=Object.prototype.hasOwnProperty,SE={brackets($){return String($)+"[]"},comma:"comma",indices($,T){return String($)+"["+T+"]"},repeat($){return String($)}},t1=Array.isArray,fx=Array.prototype.push,jE=function($,T){fx.apply($,t1(T)?T:[T])},yx=Date.prototype.toISOString,q4={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:PE,encodeValuesOnly:!1,format:QG,formatter:ZG[QG],indices:!1,serializeDate($){return yx.call($)},skipNulls:!1,strictNullHandling:!1};function hx($){return typeof $==="string"||typeof $==="number"||typeof $==="boolean"||typeof $==="symbol"||typeof $==="bigint"}var xF={};function BE($,T,W,U,X,Y,w,G,H,z,F,O,Q,Z,V,E,N,J){let _=$,R=J,P=0,x=!1;while((R=R.get(xF))!==void 0&&!x){let S=R.get($);if(P+=1,typeof S!=="undefined")if(S===P)throw new RangeError("Cyclic object value");else x=!0;if(typeof R.get(xF)==="undefined")P=0}if(typeof z==="function")_=z(T,_);else if(_ instanceof Date)_=Q?.(_);else if(W==="comma"&&t1(_))_=BF(_,function(S){if(S instanceof Date)return Q?.(S);return S});if(_===null){if(Y)return H&&!E?H(T,q4.encoder,N,"key",Z):T;_=""}if(hx(_)||CE(_)){if(H){let S=E?T:H(T,q4.encoder,N,"key",Z);return[V?.(S)+"="+V?.(H(_,q4.encoder,N,"value",Z))]}return[V?.(T)+"="+V?.(String(_))]}let f=[];if(typeof _==="undefined")return f;let h;if(W==="comma"&&t1(_)){if(E&&H)_=BF(_,H);h=[{value:_.length>0?_.join(",")||null:void 0}]}else if(t1(z))h=z;else{let S=Object.keys(_);h=F?S.sort(F):S}let a=G?String(T).replace(/\./g,"%2E"):String(T),M$=U&&t1(_)&&_.length===1?a+"[]":a;if(X&&t1(_)&&_.length===0)return M$+"[]";for(let S=0;S<h.length;++S){let W$=h[S],n=typeof W$==="object"&&typeof W$.value!=="undefined"?W$.value:_[W$];if(w&&n===null)continue;let Y$=O&&G?W$.replace(/\./g,"%2E"):W$,j$=t1(_)?typeof W==="function"?W(M$,Y$):M$:M$+(O?"."+Y$:"["+Y$+"]");J.set($,P);let s$=new WeakMap;s$.set(xF,J),jE(f,BE(n,j$,W,U,X,Y,w,G,W==="comma"&&E&&t1(_)?null:H,z,F,O,Q,Z,V,E,N,s$))}return f}function gx($=q4){if(typeof $.allowEmptyArrays!=="undefined"&&typeof $.allowEmptyArrays!=="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof $.encodeDotInKeys!=="undefined"&&typeof $.encodeDotInKeys!=="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if($.encoder!==null&&typeof $.encoder!=="undefined"&&typeof $.encoder!=="function")throw new TypeError("Encoder has to be a function.");let T=$.charset||q4.charset;if(typeof $.charset!=="undefined"&&$.charset!=="utf-8"&&$.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let W=QG;if(typeof $.format!=="undefined"){if(!bx.call(ZG,$.format))throw new TypeError("Unknown format option provided.");W=$.format}let U=ZG[W],X=q4.filter;if(typeof $.filter==="function"||t1($.filter))X=$.filter;let Y;if($.arrayFormat&&$.arrayFormat in SE)Y=$.arrayFormat;else if("indices"in $)Y=$.indices?"indices":"repeat";else Y=q4.arrayFormat;if("commaRoundTrip"in $&&typeof $.commaRoundTrip!=="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let w=typeof $.allowDots==="undefined"?!!$.encodeDotInKeys===!0?!0:q4.allowDots:!!$.allowDots;return{addQueryPrefix:typeof $.addQueryPrefix==="boolean"?$.addQueryPrefix:q4.addQueryPrefix,allowDots:w,allowEmptyArrays:typeof $.allowEmptyArrays==="boolean"?!!$.allowEmptyArrays:q4.allowEmptyArrays,arrayFormat:Y,charset:T,charsetSentinel:typeof $.charsetSentinel==="boolean"?$.charsetSentinel:q4.charsetSentinel,commaRoundTrip:!!$.commaRoundTrip,delimiter:typeof $.delimiter==="undefined"?q4.delimiter:$.delimiter,encode:typeof $.encode==="boolean"?$.encode:q4.encode,encodeDotInKeys:typeof $.encodeDotInKeys==="boolean"?$.encodeDotInKeys:q4.encodeDotInKeys,encoder:typeof $.encoder==="function"?$.encoder:q4.encoder,encodeValuesOnly:typeof $.encodeValuesOnly==="boolean"?$.encodeValuesOnly:q4.encodeValuesOnly,filter:X,format:W,formatter:U,serializeDate:typeof $.serializeDate==="function"?$.serializeDate:q4.serializeDate,skipNulls:typeof $.skipNulls==="boolean"?$.skipNulls:q4.skipNulls,sort:typeof $.sort==="function"?$.sort:null,strictNullHandling:typeof $.strictNullHandling==="boolean"?$.strictNullHandling:q4.strictNullHandling}}function IF($,T={}){let W=$,U=gx(T),X,Y;if(typeof U.filter==="function")Y=U.filter,W=Y("",W);else if(t1(U.filter))Y=U.filter,X=Y;let w=[];if(typeof W!=="object"||W===null)return"";let G=SE[U.arrayFormat],H=G==="comma"&&U.commaRoundTrip;if(!X)X=Object.keys(W);if(U.sort)X.sort(U.sort);let z=new WeakMap;for(let Q=0;Q<X.length;++Q){let Z=X[Q];if(U.skipNulls&&W[Z]===null)continue;jE(w,BE(W[Z],Z,G,H,U.allowEmptyArrays,U.strictNullHandling,U.skipNulls,U.encodeDotInKeys,U.encode?U.encoder:null,U.filter,U.sort,U.allowDots,U.serializeDate,U.format,U.formatter,U.encodeValuesOnly,U.charset,z))}let F=w.join(U.delimiter),O=U.addQueryPrefix===!0?"?":"";if(U.charsetSentinel)if(U.charset==="iso-8859-1")O+="utf8=%26%2310003%3B&";else O+="utf8=%E2%9C%93&";return F.length>0?O+F:""}var $W="4.103.0";var xE=!1,TW=void 0,bF=void 0,cx=void 0,ux=void 0,px=void 0,fF=void 0,dx=void 0,DG=void 0,yF=void 0,hF=void 0,gF=void 0,VG=void 0,mF=void 0;function IE($,T={auto:!1}){if(xE)throw new Error(`you must \`import 'openai/shims/${$.kind}'\` before importing anything else from openai`);if(TW)throw new Error(`can't \`import 'openai/shims/${$.kind}'\` after \`import 'openai/shims/${TW}'\``);xE=T.auto,TW=$.kind,bF=$.fetch,cx=$.Request,ux=$.Response,px=$.Headers,fF=$.FormData,dx=$.Blob,DG=$.File,yF=$.ReadableStream,hF=$.getMultipartRequestOptions,gF=$.getDefaultAgent,VG=$.fileFromPath,mF=$.isFsReadStream}class cF{constructor($){this.body=$}get[Symbol.toStringTag](){return"MultipartBody"}}function bE({manuallyImported:$}={}){let T=$?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from 'openai'`:\n- `import 'openai/shims/node'` (if you're running on Node)\n- `import 'openai/shims/web'` (otherwise)\n",W,U,X,Y;try{W=fetch,U=Request,X=Response,Y=Headers}catch(w){throw new Error(`this environment is missing the following Web Fetch API type: ${w.message}. ${T}`)}return{kind:"web",fetch:W,Request:U,Response:X,Headers:Y,FormData:typeof FormData!=="undefined"?FormData:class w{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${T}`)}},Blob:typeof Blob!=="undefined"?Blob:class w{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${T}`)}},File:typeof File!=="undefined"?File:class w{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${T}`)}},ReadableStream:typeof ReadableStream!=="undefined"?ReadableStream:class w{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${T}`)}},getMultipartRequestOptions:async(w,G)=>({...G,body:new cF(w)}),getDefaultAgent:(w)=>{return},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")},isFsReadStream:(w)=>!1}}import{ReadStream as lx}from"fs";function fE(){let $=bE();function T(W){return W instanceof lx}return{...$,isFsReadStream:T}}var uF=()=>{if(!TW)IE(fE(),{auto:!0})};uF();class e extends Error{}class L4 extends e{constructor($,T,W,U){super(`${L4.makeMessage($,T,W)}`);this.status=$,this.headers=U,this.request_id=U?.["x-request-id"],this.error=T;let X=T;this.code=X?.code,this.param=X?.param,this.type=X?.type}static makeMessage($,T,W){let U=T?.message?typeof T.message==="string"?T.message:JSON.stringify(T.message):T?JSON.stringify(T):W;if($&&U)return`${$} ${U}`;if($)return`${$} status code (no body)`;if(U)return U;return"(no status code or body)"}static generate($,T,W,U){if(!$||!U)return new WW({message:W,cause:RG(T)});let X=T?.error;if($===400)return new KG($,X,W,U);if($===401)return new EG($,X,W,U);if($===403)return new AG($,X,W,U);if($===404)return new MG($,X,W,U);if($===409)return new NG($,X,W,U);if($===422)return new LG($,X,W,U);if($===429)return new JG($,X,W,U);if($>=500)return new _G($,X,W,U);return new L4($,X,W,U)}}class P4 extends L4{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class WW extends L4{constructor({message:$,cause:T}){super(void 0,void 0,$||"Connection error.",void 0);if(T)this.cause=T}}class UW extends WW{constructor({message:$}={}){super({message:$??"Request timed out."})}}class KG extends L4{}class EG extends L4{}class AG extends L4{}class MG extends L4{}class NG extends L4{}class LG extends L4{}class JG extends L4{}class _G extends L4{}class CX extends e{constructor(){super("Could not parse response content as the length limit was reached")}}class SX extends e{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var kG=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},XW=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},e6;class O2{constructor(){e6.set(this,void 0),this.buffer=new Uint8Array,kG(this,e6,null,"f")}decode($){if($==null)return[];let T=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?new TextEncoder().encode($):$,W=new Uint8Array(this.buffer.length+T.length);W.set(this.buffer),W.set(T,this.buffer.length),this.buffer=W;let U=[],X;while((X=nx(this.buffer,XW(this,e6,"f")))!=null){if(X.carriage&&XW(this,e6,"f")==null){kG(this,e6,X.index,"f");continue}if(XW(this,e6,"f")!=null&&(X.index!==XW(this,e6,"f")+1||X.carriage)){U.push(this.decodeText(this.buffer.slice(0,XW(this,e6,"f")-1))),this.buffer=this.buffer.slice(XW(this,e6,"f")),kG(this,e6,null,"f");continue}let Y=XW(this,e6,"f")!==null?X.preceding-1:X.preceding,w=this.decodeText(this.buffer.slice(0,Y));U.push(w),this.buffer=this.buffer.slice(X.index),kG(this,e6,null,"f")}return U}decodeText($){if($==null)return"";if(typeof $==="string")return $;if(typeof Buffer!=="undefined"){if($ instanceof Buffer)return $.toString();if($ instanceof Uint8Array)return Buffer.from($).toString();throw new e(`Unexpected: received non-Uint8Array (${$.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder!=="undefined"){if($ instanceof Uint8Array||$ instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode($);throw new e(`Unexpected: received non-Uint8Array/ArrayBuffer (${$.constructor.name}) in a web platform. Please report this error.`)}throw new e("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length)return[];return this.decode(`
|
|
62
|
+
`)}}e6=new WeakMap;O2.NEWLINE_CHARS=new Set([`
|
|
63
|
+
`,"\r"]);O2.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function nx($,T){for(let X=T??0;X<$.length;X++){if($[X]===10)return{preceding:X,index:X+1,carriage:!1};if($[X]===13)return{preceding:X,index:X+1,carriage:!0}}return null}function yE($){for(let U=0;U<$.length-1;U++){if($[U]===10&&$[U+1]===10)return U+2;if($[U]===13&&$[U+1]===13)return U+2;if($[U]===13&&$[U+1]===10&&U+3<$.length&&$[U+2]===13&&$[U+3]===10)return U+4}return-1}function pF($){if($[Symbol.asyncIterator])return $;let T=$.getReader();return{async next(){try{let W=await T.read();if(W?.done)T.releaseLock();return W}catch(W){throw T.releaseLock(),W}},async return(){let W=T.cancel();return T.releaseLock(),await W,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}class $1{constructor($,T){this.iterator=$,this.controller=T}static fromSSEResponse($,T){let W=!1;async function*U(){if(W)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");W=!0;let X=!1;try{for await(let Y of ix($,T)){if(X)continue;if(Y.data.startsWith("[DONE]")){X=!0;continue}if(Y.event===null||Y.event.startsWith("response.")||Y.event.startsWith("transcript.")){let w;try{w=JSON.parse(Y.data)}catch(G){throw console.error("Could not parse message into JSON:",Y.data),console.error("From chunk:",Y.raw),G}if(w&&w.error)throw new L4(void 0,w.error,void 0,dF($.headers));yield w}else{let w;try{w=JSON.parse(Y.data)}catch(G){throw console.error("Could not parse message into JSON:",Y.data),console.error("From chunk:",Y.raw),G}if(Y.event=="error")throw new L4(void 0,w.error,w.message,void 0);yield{event:Y.event,data:w}}}X=!0}catch(Y){if(Y instanceof Error&&Y.name==="AbortError")return;throw Y}finally{if(!X)T.abort()}}return new $1(U,T)}static fromReadableStream($,T){let W=!1;async function*U(){let Y=new O2,w=pF($);for await(let G of w)for(let H of Y.decode(G))yield H;for(let G of Y.flush())yield G}async function*X(){if(W)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");W=!0;let Y=!1;try{for await(let w of U()){if(Y)continue;if(w)yield JSON.parse(w)}Y=!0}catch(w){if(w instanceof Error&&w.name==="AbortError")return;throw w}finally{if(!Y)T.abort()}}return new $1(X,T)}[Symbol.asyncIterator](){return this.iterator()}tee(){let $=[],T=[],W=this.iterator(),U=(X)=>{return{next:()=>{if(X.length===0){let Y=W.next();$.push(Y),T.push(Y)}return X.shift()}}};return[new $1(()=>U($),this.controller),new $1(()=>U(T),this.controller)]}toReadableStream(){let $=this,T,W=new TextEncoder;return new yF({async start(){T=$[Symbol.asyncIterator]()},async pull(U){try{let{value:X,done:Y}=await T.next();if(Y)return U.close();let w=W.encode(JSON.stringify(X)+`
|
|
64
|
+
`);U.enqueue(w)}catch(X){U.error(X)}},async cancel(){await T.return?.()}})}}async function*ix($,T){if(!$.body)throw T.abort(),new e("Attempted to iterate over a response with no body");let W=new hE,U=new O2,X=pF($.body);for await(let Y of tx(X))for(let w of U.decode(Y)){let G=W.decode(w);if(G)yield G}for(let Y of U.flush()){let w=W.decode(Y);if(w)yield w}}async function*tx($){let T=new Uint8Array;for await(let W of $){if(W==null)continue;let U=W instanceof ArrayBuffer?new Uint8Array(W):typeof W==="string"?new TextEncoder().encode(W):W,X=new Uint8Array(T.length+U.length);X.set(T),X.set(U,T.length),T=X;let Y;while((Y=yE(T))!==-1)yield T.slice(0,Y),T=T.slice(Y)}if(T.length>0)yield T}class hE{constructor(){this.event=null,this.data=[],this.chunks=[]}decode($){if($.endsWith("\r"))$=$.substring(0,$.length-1);if(!$){if(!this.event&&!this.data.length)return null;let X={event:this.event,data:this.data.join(`
|
|
65
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],X}if(this.chunks.push($),$.startsWith(":"))return null;let[T,W,U]=ax($,":");if(U.startsWith(" "))U=U.substring(1);if(T==="event")this.event=U;else if(T==="data")this.data.push(U);return null}}function ax($,T){let W=$.indexOf(T);if(W!==-1)return[$.substring(0,W),T,$.substring(W+T.length)];return[$,"",""]}var gE=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function",mE=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&jX($),jX=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function",sx=($)=>{return mE($)||gE($)||mF($)};async function rF($,T,W){if($=await $,mE($))return $;if(gE($)){let X=await $.blob();T||(T=new URL($.url).pathname.split(/[\\/]/).pop()??"unknown_file");let Y=jX(X)?[await X.arrayBuffer()]:[X];return new DG(Y,T,W)}let U=await ex($);if(T||(T=TI($)??"unknown_file"),!W?.type){let X=U[0]?.type;if(typeof X==="string")W={...W,type:X}}return new DG(U,T,W)}async function ex($){let T=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)T.push($);else if(jX($))T.push(await $.arrayBuffer());else if(WI($))for await(let W of $)T.push(W);else throw new Error(`Unexpected data type: ${typeof $}; constructor: ${$?.constructor?.name}; props: ${$I($)}`);return T}function $I($){return`[${Object.getOwnPropertyNames($).map((W)=>`"${W}"`).join(", ")}]`}function TI($){return oF($.name)||oF($.filename)||oF($.path)?.split(/[\\/]/).pop()}var oF=($)=>{if(typeof $==="string")return $;if(typeof Buffer!=="undefined"&&$ instanceof Buffer)return String($);return},WI=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",nF=($)=>$&&typeof $==="object"&&$.body&&$[Symbol.toStringTag]==="MultipartBody";var x6=async($)=>{let T=await cE($.body);return hF(T,$)},cE=async($)=>{let T=new fF;return await Promise.all(Object.entries($||{}).map(([W,U])=>lF(T,W,U))),T};var lF=async($,T,W)=>{if(W===void 0)return;if(W==null)throw new TypeError(`Received null for "${T}"; to pass null in FormData, you must use the string 'null'`);if(typeof W==="string"||typeof W==="number"||typeof W==="boolean")$.append(T,String(W));else if(sx(W)){let U=await rF(W);$.append(T,U)}else if(Array.isArray(W))await Promise.all(W.map((U)=>lF($,T+"[]",U)));else if(typeof W==="object")await Promise.all(Object.entries(W).map(([U,X])=>lF($,`${T}[${U}]`,X)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${W} instead`)};var XI=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},YI=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},vG;uF();async function rE($){let{response:T}=$;if($.options.stream){if(N0("response",T.status,T.url,T.headers,T.body),$.options.__streamClass)return $.options.__streamClass.fromSSEResponse(T,$.controller);return $1.fromSSEResponse(T,$.controller)}if(T.status===204)return null;if($.options.__binaryResponse)return T;let U=T.headers.get("content-type")?.split(";")[0]?.trim();if(U?.includes("application/json")||U?.endsWith("+json")){let w=await T.json();return N0("response",T.status,T.url,T.headers,w),nE(w,T)}let Y=await T.text();return N0("response",T.status,T.url,T.headers,Y),Y}function nE($,T){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:T.headers.get("x-request-id"),enumerable:!1})}class PG extends Promise{constructor($,T=rE){super((W)=>{W(null)});this.responsePromise=$,this.parseResponse=T}_thenUnwrap($){return new PG(this.responsePromise,async(T)=>nE($(await this.parseResponse(T),T),T.response))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,T]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:T,request_id:T.headers.get("x-request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(this.parseResponse);return this.parsedPromise}then($,T){return this.parse().then($,T)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}class tF{constructor({baseURL:$,maxRetries:T=2,timeout:W=600000,httpAgent:U,fetch:X}){this.baseURL=$,this.maxRetries=iF("maxRetries",T),this.timeout=iF("timeout",W),this.httpAgent=U,this.fetch=X??bF}authHeaders($){return{}}defaultHeaders($){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...HI(),...this.authHeaders($)}}validateHeaders($,T){}defaultIdempotencyKey(){return`stainless-node-retry-${ZI()}`}get($,T){return this.methodRequest("get",$,T)}post($,T){return this.methodRequest("post",$,T)}patch($,T){return this.methodRequest("patch",$,T)}put($,T){return this.methodRequest("put",$,T)}delete($,T){return this.methodRequest("delete",$,T)}methodRequest($,T,W){return this.request(Promise.resolve(W).then(async(U)=>{let X=U&&jX(U?.body)?new DataView(await U.body.arrayBuffer()):U?.body instanceof DataView?U.body:U?.body instanceof ArrayBuffer?new DataView(U.body):U&&ArrayBuffer.isView(U?.body)?new DataView(U.body.buffer):U?.body;return{method:$,path:T,...U,body:X}}))}getAPIList($,T,W){return this.requestAPIList(T,{method:"get",path:$,...W})}calculateContentLength($){if(typeof $==="string"){if(typeof Buffer!=="undefined")return Buffer.byteLength($,"utf8").toString();if(typeof TextEncoder!=="undefined")return new TextEncoder().encode($).length.toString()}else if(ArrayBuffer.isView($))return $.byteLength.toString();return null}buildRequest($,{retryCount:T=0}={}){let W={...$},{method:U,path:X,query:Y,headers:w={}}=W,G=ArrayBuffer.isView(W.body)||W.__binaryRequest&&typeof W.body==="string"?W.body:nF(W.body)?W.body.body:W.body?JSON.stringify(W.body,null,2):null,H=this.calculateContentLength(G),z=this.buildURL(X,Y);if("timeout"in W)iF("timeout",W.timeout);W.timeout=W.timeout??this.timeout;let F=W.httpAgent??this.httpAgent??gF(z),O=W.timeout+1000;if(typeof F?.options?.timeout==="number"&&O>(F.options.timeout??0))F.options.timeout=O;if(this.idempotencyHeader&&U!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();w[this.idempotencyHeader]=$.idempotencyKey}let Q=this.buildHeaders({options:W,headers:w,contentLength:H,retryCount:T});return{req:{method:U,...G&&{body:G},headers:Q,...F&&{agent:F},signal:W.signal??null},url:z,timeout:W.timeout}}buildHeaders({options:$,headers:T,contentLength:W,retryCount:U}){let X={};if(W)X["content-length"]=W;let Y=this.defaultHeaders($);if(oE(X,Y),oE(X,T),nF($.body)&&TW!=="node")delete X["content-type"];if(qG(Y,"x-stainless-retry-count")===void 0&&qG(T,"x-stainless-retry-count")===void 0)X["x-stainless-retry-count"]=String(U);if(qG(Y,"x-stainless-timeout")===void 0&&qG(T,"x-stainless-timeout")===void 0&&$.timeout)X["x-stainless-timeout"]=String(Math.trunc($.timeout/1000));return this.validateHeaders(X,T),X}async prepareOptions($){}async prepareRequest($,{url:T,options:W}){}parseHeaders($){return!$?{}:(Symbol.iterator in $)?Object.fromEntries(Array.from($).map((T)=>[...T])):{...$}}makeStatusError($,T,W,U){return L4.generate($,T,W,U)}request($,T=null){return new PG(this.makeRequest($,T))}async makeRequest($,T){let W=await $,U=W.maxRetries??this.maxRetries;if(T==null)T=U;await this.prepareOptions(W);let{req:X,url:Y,timeout:w}=this.buildRequest(W,{retryCount:U-T});if(await this.prepareRequest(X,{url:Y,options:W}),N0("request",Y,W,X.headers),W.signal?.aborted)throw new P4;let G=new AbortController,H=await this.fetchWithTimeout(Y,X,w,G).catch(RG);if(H instanceof Error){if(W.signal?.aborted)throw new P4;if(T)return this.retryRequest(W,T);if(H.name==="AbortError")throw new UW;throw new WW({cause:H})}let z=dF(H.headers);if(!H.ok){if(T&&this.shouldRetry(H)){let E=`retrying, ${T} attempts remaining`;return N0(`response (error; ${E})`,H.status,Y,z),this.retryRequest(W,T,z)}let F=await H.text().catch((E)=>RG(E).message),O=FI(F),Q=O?void 0:F;throw N0(`response (error; ${T?"(error; no more retries left)":"(error; not retryable)"})`,H.status,Y,z,Q),this.makeStatusError(H.status,O,Q,z)}return{response:H,options:W,controller:G}}requestAPIList($,T){let W=this.makeRequest(T,null);return new iE(this,W,$)}buildURL($,T){let W=QI($)?new URL($):new URL(this.baseURL+(this.baseURL.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),U=this.defaultQuery();if(!tE(U))T={...U,...T};if(typeof T==="object"&&T&&!Array.isArray(T))W.search=this.stringifyQuery(T);return W.toString()}stringifyQuery($){return Object.entries($).filter(([T,W])=>typeof W!=="undefined").map(([T,W])=>{if(typeof W==="string"||typeof W==="number"||typeof W==="boolean")return`${encodeURIComponent(T)}=${encodeURIComponent(W)}`;if(W===null)return`${encodeURIComponent(T)}=`;throw new e(`Cannot stringify type ${typeof W}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}async fetchWithTimeout($,T,W,U){let{signal:X,...Y}=T||{};if(X)X.addEventListener("abort",()=>U.abort());let w=setTimeout(()=>U.abort(),W),G={signal:U.signal,...Y};if(G.method)G.method=G.method.toUpperCase();return this.fetch.call(void 0,$,G).finally(()=>{clearTimeout(w)})}shouldRetry($){let T=$.headers.get("x-should-retry");if(T==="true")return!0;if(T==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,T,W){let U,X=W?.["retry-after-ms"];if(X){let w=parseFloat(X);if(!Number.isNaN(w))U=w}let Y=W?.["retry-after"];if(Y&&!U){let w=parseFloat(Y);if(!Number.isNaN(w))U=w*1000;else U=Date.parse(Y)-Date.now()}if(!(U&&0<=U&&U<60000)){let w=$.maxRetries??this.maxRetries;U=this.calculateDefaultRetryTimeoutMillis(T,w)}return await L0(U),this.makeRequest($,T-1)}calculateDefaultRetryTimeoutMillis($,T){let X=T-$,Y=Math.min(0.5*Math.pow(2,X),8),w=1-Math.random()*0.25;return Y*w*1000}getUserAgent(){return`${this.constructor.name}/JS ${$W}`}}class CG{constructor($,T,W,U){vG.set(this,void 0),XI(this,vG,$,"f"),this.options=U,this.response=T,this.body=W}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageInfo()!=null}async getNextPage(){let $=this.nextPageInfo();if(!$)throw new e("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let T={...this.options};if("params"in $&&typeof T.query==="object")T.query={...T.query,...$.params};else if("url"in $){let W=[...Object.entries(T.query||{}),...$.url.searchParams.entries()];for(let[U,X]of W)$.url.searchParams.set(U,X);T.query=void 0,T.path=$.url.toString()}return await YI(this,vG,"f").requestAPIList(this.constructor,T)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(vG=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let T of $.getPaginatedItems())yield T}}class iE extends PG{constructor($,T,W){super(T,async(U)=>new W($,U.response,await rE(U),U.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let T of $)yield T}}var dF=($)=>{return new Proxy(Object.fromEntries($.entries()),{get(T,W){let U=W.toString();return T[U.toLowerCase()]||T[U]}})},wI={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__metadata:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},Z$=($)=>{return typeof $==="object"&&$!==null&&!tE($)&&Object.keys($).every((T)=>aE(wI,T))},GI=()=>{if(typeof Deno!=="undefined"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$W,"X-Stainless-OS":pE(Deno.build.os),"X-Stainless-Arch":uE(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime!=="undefined")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$W,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process!=="undefined"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$W,"X-Stainless-OS":pE(process.platform),"X-Stainless-Arch":uE(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let $=zI();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$W,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${$.browser}`,"X-Stainless-Runtime-Version":$.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$W,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function zI(){if(typeof navigator==="undefined"||!navigator)return null;let $=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:T,pattern:W}of $){let U=W.exec(navigator.userAgent);if(U){let X=U[1]||0,Y=U[2]||0,w=U[3]||0;return{browser:T,version:`${X}.${Y}.${w}`}}}return null}var uE=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},pE=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},dE,HI=()=>{return dE??(dE=GI())},FI=($)=>{try{return JSON.parse($)}catch(T){return}},OI=/^[a-z][a-z0-9+.-]*:/i,QI=($)=>{return OI.test($)},L0=($)=>new Promise((T)=>setTimeout(T,$)),iF=($,T)=>{if(typeof T!=="number"||!Number.isInteger(T))throw new e(`${$} must be an integer`);if(T<0)throw new e(`${$} must be a positive integer`);return T},RG=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null)try{return new Error(JSON.stringify($))}catch{}return new Error($)};var BX=($)=>{if(typeof process!=="undefined")return process.env?.[$]?.trim()??void 0;if(typeof Deno!=="undefined")return Deno.env?.get?.($)?.trim();return};function tE($){if(!$)return!0;for(let T in $)return!1;return!0}function aE($,T){return Object.prototype.hasOwnProperty.call($,T)}function oE($,T){for(let W in T){if(!aE(T,W))continue;let U=W.toLowerCase();if(!U)continue;let X=T[W];if(X===null)delete $[U];else if(X!==void 0)$[U]=X}}var lE=new Set(["authorization","api-key"]);function N0($,...T){if(typeof process!=="undefined"&&process?.env?.DEBUG==="true"){let W=T.map((U)=>{if(!U)return U;if(U.headers){let Y={...U,headers:{...U.headers}};for(let w in U.headers)if(lE.has(w.toLowerCase()))Y.headers[w]="REDACTED";return Y}let X=null;for(let Y in U)if(lE.has(Y.toLowerCase()))X??(X={...U}),X[Y]="REDACTED";return X??U});console.log(`OpenAI:DEBUG:${$}`,...W)}}var ZI=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,($)=>{let T=Math.random()*16|0;return($==="x"?T:T&3|8).toString(16)})},sE=()=>{return typeof window!=="undefined"&&typeof window.document!=="undefined"&&typeof navigator!=="undefined"},DI=($)=>{return typeof $?.get==="function"};var qG=($,T)=>{let W=T.toLowerCase();if(DI($)){let U=T[0]?.toUpperCase()+T.substring(1).replace(/([^\w])(\w)/g,(X,Y,w)=>Y+w.toUpperCase());for(let X of[T,W,T.toUpperCase(),U]){let Y=$.get(X);if(Y)return Y}}for(let[U,X]of Object.entries($))if(U.toLowerCase()===W){if(Array.isArray(X)){if(X.length<=1)return X[0];return console.warn(`Received ${X.length} entries for the ${T} header, using the first entry.`),X[0]}return X}return};var eE=($)=>{if(typeof Buffer!=="undefined"){let T=Buffer.from($,"base64");return Array.from(new Float32Array(T.buffer,T.byteOffset,T.length/Float32Array.BYTES_PER_ELEMENT))}else{let T=atob($),W=T.length,U=new Uint8Array(W);for(let X=0;X<W;X++)U[X]=T.charCodeAt(X);return Array.from(new Float32Array(U.buffer))}};function xX($){return $!=null&&typeof $==="object"&&!Array.isArray($)}class _0 extends CG{constructor($,T,W,U){super($,T,W,U);this.data=W.data||[],this.object=W.object}getPaginatedItems(){return this.data??[]}nextPageParams(){return null}nextPageInfo(){return null}}class v$ extends CG{constructor($,T,W,U){super($,T,W,U);this.data=W.data||[],this.has_more=W.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageParams(){let $=this.nextPageInfo();if(!$)return null;if("params"in $)return $.params;let T=Object.fromEntries($.url.searchParams);if(!Object.keys(T).length)return null;return T}nextPageInfo(){let $=this.getPaginatedItems();if(!$.length)return null;let T=$[$.length-1]?.id;if(!T)return null;return{params:{after:T}}}}class y{constructor($){this._client=$}}class IX extends y{list($,T={},W){if(Z$(T))return this.list($,{},T);return this._client.getAPIList(`/chat/completions/${$}/messages`,aF,{query:T,...W})}}class YW extends y{constructor(){super(...arguments);this.messages=new IX(this._client)}create($,T){return this._client.post("/chat/completions",{body:$,...T,stream:$.stream??!1})}retrieve($,T){return this._client.get(`/chat/completions/${$}`,T)}update($,T,W){return this._client.post(`/chat/completions/${$}`,{body:T,...W})}list($={},T){if(Z$($))return this.list({},$);return this._client.getAPIList("/chat/completions",wW,{query:$,...T})}del($,T){return this._client.delete(`/chat/completions/${$}`,T)}}class wW extends v${}class aF extends v${}YW.ChatCompletionsPage=wW;YW.Messages=IX;class DT extends y{constructor(){super(...arguments);this.completions=new YW(this._client)}}DT.Completions=YW;DT.ChatCompletionsPage=wW;class bX extends y{create($,T){return this._client.post("/audio/speech",{body:$,...T,headers:{Accept:"application/octet-stream",...T?.headers},__binaryResponse:!0})}}class fX extends y{create($,T){return this._client.post("/audio/transcriptions",x6({body:$,...T,stream:$.stream??!1,__metadata:{model:$.model}}))}}class yX extends y{create($,T){return this._client.post("/audio/translations",x6({body:$,...T,__metadata:{model:$.model}}))}}class R0 extends y{constructor(){super(...arguments);this.transcriptions=new fX(this._client),this.translations=new yX(this._client),this.speech=new bX(this._client)}}R0.Transcriptions=fX;R0.Translations=yX;R0.Speech=bX;class GW extends y{create($,T){return this._client.post("/batches",{body:$,...T})}retrieve($,T){return this._client.get(`/batches/${$}`,T)}list($={},T){if(Z$($))return this.list({},$);return this._client.getAPIList("/batches",Q2,{query:$,...T})}cancel($,T){return this._client.post(`/batches/${$}/cancel`,T)}}class Q2 extends v${}GW.BatchesPage=Q2;var B1=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},z4=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},sF,SG,jG,hX,gX,BG,mX,k0,cX,xG,IG,Z2,$A;class zW{constructor(){sF.add(this),this.controller=new AbortController,SG.set(this,void 0),jG.set(this,()=>{}),hX.set(this,()=>{}),gX.set(this,void 0),BG.set(this,()=>{}),mX.set(this,()=>{}),k0.set(this,{}),cX.set(this,!1),xG.set(this,!1),IG.set(this,!1),Z2.set(this,!1),B1(this,SG,new Promise(($,T)=>{B1(this,jG,$,"f"),B1(this,hX,T,"f")}),"f"),B1(this,gX,new Promise(($,T)=>{B1(this,BG,$,"f"),B1(this,mX,T,"f")}),"f"),z4(this,SG,"f").catch(()=>{}),z4(this,gX,"f").catch(()=>{})}_run($){setTimeout(()=>{$().then(()=>{this._emitFinal(),this._emit("end")},z4(this,sF,"m",$A).bind(this))},0)}_connected(){if(this.ended)return;z4(this,jG,"f").call(this),this._emit("connect")}get ended(){return z4(this,cX,"f")}get errored(){return z4(this,xG,"f")}get aborted(){return z4(this,IG,"f")}abort(){this.controller.abort()}on($,T){return(z4(this,k0,"f")[$]||(z4(this,k0,"f")[$]=[])).push({listener:T}),this}off($,T){let W=z4(this,k0,"f")[$];if(!W)return this;let U=W.findIndex((X)=>X.listener===T);if(U>=0)W.splice(U,1);return this}once($,T){return(z4(this,k0,"f")[$]||(z4(this,k0,"f")[$]=[])).push({listener:T,once:!0}),this}emitted($){return new Promise((T,W)=>{if(B1(this,Z2,!0,"f"),$!=="error")this.once("error",W);this.once($,T)})}async done(){B1(this,Z2,!0,"f"),await z4(this,gX,"f")}_emit($,...T){if(z4(this,cX,"f"))return;if($==="end")B1(this,cX,!0,"f"),z4(this,BG,"f").call(this);let W=z4(this,k0,"f")[$];if(W)z4(this,k0,"f")[$]=W.filter((U)=>!U.once),W.forEach(({listener:U})=>U(...T));if($==="abort"){let U=T[0];if(!z4(this,Z2,"f")&&!W?.length)Promise.reject(U);z4(this,hX,"f").call(this,U),z4(this,mX,"f").call(this,U),this._emit("end");return}if($==="error"){let U=T[0];if(!z4(this,Z2,"f")&&!W?.length)Promise.reject(U);z4(this,hX,"f").call(this,U),z4(this,mX,"f").call(this,U),this._emit("end")}}_emitFinal(){}}SG=new WeakMap,jG=new WeakMap,hX=new WeakMap,gX=new WeakMap,BG=new WeakMap,mX=new WeakMap,k0=new WeakMap,cX=new WeakMap,xG=new WeakMap,IG=new WeakMap,Z2=new WeakMap,sF=new WeakSet,$A=function $(T){if(B1(this,xG,!0,"f"),T instanceof Error&&T.name==="AbortError")T=new P4;if(T instanceof P4)return B1(this,IG,!0,"f"),this._emit("abort",T);if(T instanceof e)return this._emit("error",T);if(T instanceof Error){let W=new e(T.message);return W.cause=T,this._emit("error",W)}return this._emit("error",new e(String(T)))};var T$=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},T1=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},p4,eF,a1,bG,x1,FW,D2,HW,hG,W1,fG,yG,dX,uX,pX,TA,WA,UA,XA,YA,wA,GA;class U1 extends zW{constructor(){super(...arguments);p4.add(this),eF.set(this,[]),a1.set(this,{}),bG.set(this,{}),x1.set(this,void 0),FW.set(this,void 0),D2.set(this,void 0),HW.set(this,void 0),hG.set(this,void 0),W1.set(this,void 0),fG.set(this,void 0),yG.set(this,void 0),dX.set(this,void 0)}[(eF=new WeakMap,a1=new WeakMap,bG=new WeakMap,x1=new WeakMap,FW=new WeakMap,D2=new WeakMap,HW=new WeakMap,hG=new WeakMap,W1=new WeakMap,fG=new WeakMap,yG=new WeakMap,dX=new WeakMap,p4=new WeakSet,Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("event",(U)=>{let X=T.shift();if(X)X.resolve(U);else $.push(U)}),this.on("end",()=>{W=!0;for(let U of T)U.resolve(void 0);T.length=0}),this.on("abort",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),this.on("error",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((X,Y)=>T.push({resolve:X,reject:Y})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}static fromReadableStream($){let T=new U1;return T._run(()=>T._fromReadableStream($)),T}async _fromReadableStream($,T){let W=T?.signal;if(W){if(W.aborted)this.controller.abort();W.addEventListener("abort",()=>this.controller.abort())}this._connected();let U=$1.fromReadableStream($,this.controller);for await(let X of U)T$(this,p4,"m",uX).call(this,X);if(U.controller.signal?.aborted)throw new P4;return this._addRun(T$(this,p4,"m",pX).call(this))}toReadableStream(){return new $1(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream($,T,W,U,X){let Y=new U1;return Y._run(()=>Y._runToolAssistantStream($,T,W,U,{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),Y}async _createToolAssistantStream($,T,W,U,X){let Y=X?.signal;if(Y){if(Y.aborted)this.controller.abort();Y.addEventListener("abort",()=>this.controller.abort())}let w={...U,stream:!0},G=await $.submitToolOutputs(T,W,w,{...X,signal:this.controller.signal});this._connected();for await(let H of G)T$(this,p4,"m",uX).call(this,H);if(G.controller.signal?.aborted)throw new P4;return this._addRun(T$(this,p4,"m",pX).call(this))}static createThreadAssistantStream($,T,W){let U=new U1;return U._run(()=>U._threadAssistantStream($,T,{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),U}static createAssistantStream($,T,W,U){let X=new U1;return X._run(()=>X._runAssistantStream($,T,W,{...U,headers:{...U?.headers,"X-Stainless-Helper-Method":"stream"}})),X}currentEvent(){return T$(this,fG,"f")}currentRun(){return T$(this,yG,"f")}currentMessageSnapshot(){return T$(this,x1,"f")}currentRunStepSnapshot(){return T$(this,dX,"f")}async finalRunSteps(){return await this.done(),Object.values(T$(this,a1,"f"))}async finalMessages(){return await this.done(),Object.values(T$(this,bG,"f"))}async finalRun(){if(await this.done(),!T$(this,FW,"f"))throw Error("Final run was not received.");return T$(this,FW,"f")}async _createThreadAssistantStream($,T,W){let U=W?.signal;if(U){if(U.aborted)this.controller.abort();U.addEventListener("abort",()=>this.controller.abort())}let X={...T,stream:!0},Y=await $.createAndRun(X,{...W,signal:this.controller.signal});this._connected();for await(let w of Y)T$(this,p4,"m",uX).call(this,w);if(Y.controller.signal?.aborted)throw new P4;return this._addRun(T$(this,p4,"m",pX).call(this))}async _createAssistantStream($,T,W,U){let X=U?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}let Y={...W,stream:!0},w=await $.create(T,Y,{...U,signal:this.controller.signal});this._connected();for await(let G of w)T$(this,p4,"m",uX).call(this,G);if(w.controller.signal?.aborted)throw new P4;return this._addRun(T$(this,p4,"m",pX).call(this))}static accumulateDelta($,T){for(let[W,U]of Object.entries(T)){if(!$.hasOwnProperty(W)){$[W]=U;continue}let X=$[W];if(X===null||X===void 0){$[W]=U;continue}if(W==="index"||W==="type"){$[W]=U;continue}if(typeof X==="string"&&typeof U==="string")X+=U;else if(typeof X==="number"&&typeof U==="number")X+=U;else if(xX(X)&&xX(U))X=this.accumulateDelta(X,U);else if(Array.isArray(X)&&Array.isArray(U)){if(X.every((Y)=>typeof Y==="string"||typeof Y==="number")){X.push(...U);continue}for(let Y of U){if(!xX(Y))throw new Error(`Expected array delta entry to be an object but got: ${Y}`);let w=Y.index;if(w==null)throw console.error(Y),new Error("Expected array delta entry to have an `index` property");if(typeof w!=="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${w}`);let G=X[w];if(G==null)X.push(Y);else X[w]=this.accumulateDelta(G,Y)}continue}else throw Error(`Unhandled record type: ${W}, deltaValue: ${U}, accValue: ${X}`);$[W]=X}return $}_addRun($){return $}async _threadAssistantStream($,T,W){return await this._createThreadAssistantStream(T,$,W)}async _runAssistantStream($,T,W,U){return await this._createAssistantStream(T,$,W,U)}async _runToolAssistantStream($,T,W,U,X){return await this._createToolAssistantStream(W,$,T,U,X)}}uX=function $(T){if(this.ended)return;switch(T1(this,fG,T,"f"),T$(this,p4,"m",UA).call(this,T),T.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":T$(this,p4,"m",GA).call(this,T);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":T$(this,p4,"m",WA).call(this,T);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":T$(this,p4,"m",TA).call(this,T);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier");default:NI(T)}},pX=function $(){if(this.ended)throw new e("stream has ended, this shouldn't happen");if(!T$(this,FW,"f"))throw Error("Final run has not been received");return T$(this,FW,"f")},TA=function $(T){let[W,U]=T$(this,p4,"m",YA).call(this,T,T$(this,x1,"f"));T1(this,x1,W,"f"),T$(this,bG,"f")[W.id]=W;for(let X of U){let Y=W.content[X.index];if(Y?.type=="text")this._emit("textCreated",Y.text)}switch(T.event){case"thread.message.created":this._emit("messageCreated",T.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",T.data.delta,W),T.data.delta.content)for(let X of T.data.delta.content){if(X.type=="text"&&X.text){let Y=X.text,w=W.content[X.index];if(w&&w.type=="text")this._emit("textDelta",Y,w.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(X.index!=T$(this,D2,"f")){if(T$(this,HW,"f"))switch(T$(this,HW,"f").type){case"text":this._emit("textDone",T$(this,HW,"f").text,T$(this,x1,"f"));break;case"image_file":this._emit("imageFileDone",T$(this,HW,"f").image_file,T$(this,x1,"f"));break}T1(this,D2,X.index,"f")}T1(this,HW,W.content[X.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(T$(this,D2,"f")!==void 0){let X=T.data.content[T$(this,D2,"f")];if(X)switch(X.type){case"image_file":this._emit("imageFileDone",X.image_file,T$(this,x1,"f"));break;case"text":this._emit("textDone",X.text,T$(this,x1,"f"));break}}if(T$(this,x1,"f"))this._emit("messageDone",T.data);T1(this,x1,void 0,"f")}},WA=function $(T){let W=T$(this,p4,"m",XA).call(this,T);switch(T1(this,dX,W,"f"),T.event){case"thread.run.step.created":this._emit("runStepCreated",T.data);break;case"thread.run.step.delta":let U=T.data.delta;if(U.step_details&&U.step_details.type=="tool_calls"&&U.step_details.tool_calls&&W.step_details.type=="tool_calls")for(let Y of U.step_details.tool_calls)if(Y.index==T$(this,hG,"f"))this._emit("toolCallDelta",Y,W.step_details.tool_calls[Y.index]);else{if(T$(this,W1,"f"))this._emit("toolCallDone",T$(this,W1,"f"));if(T1(this,hG,Y.index,"f"),T1(this,W1,W.step_details.tool_calls[Y.index],"f"),T$(this,W1,"f"))this._emit("toolCallCreated",T$(this,W1,"f"))}this._emit("runStepDelta",T.data.delta,W);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":if(T1(this,dX,void 0,"f"),T.data.step_details.type=="tool_calls"){if(T$(this,W1,"f"))this._emit("toolCallDone",T$(this,W1,"f")),T1(this,W1,void 0,"f")}this._emit("runStepDone",T.data,W);break;case"thread.run.step.in_progress":break}},UA=function $(T){T$(this,eF,"f").push(T),this._emit("event",T)},XA=function $(T){switch(T.event){case"thread.run.step.created":return T$(this,a1,"f")[T.data.id]=T.data,T.data;case"thread.run.step.delta":let W=T$(this,a1,"f")[T.data.id];if(!W)throw Error("Received a RunStepDelta before creation of a snapshot");let U=T.data;if(U.delta){let X=U1.accumulateDelta(W,U.delta);T$(this,a1,"f")[T.data.id]=X}return T$(this,a1,"f")[T.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":T$(this,a1,"f")[T.data.id]=T.data;break}if(T$(this,a1,"f")[T.data.id])return T$(this,a1,"f")[T.data.id];throw new Error("No snapshot available")},YA=function $(T,W){let U=[];switch(T.event){case"thread.message.created":return[T.data,U];case"thread.message.delta":if(!W)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let X=T.data;if(X.delta.content)for(let Y of X.delta.content)if(Y.index in W.content){let w=W.content[Y.index];W.content[Y.index]=T$(this,p4,"m",wA).call(this,Y,w)}else W.content[Y.index]=Y,U.push(Y);return[W,U];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(W)return[W,U];else throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},wA=function $(T,W){return U1.accumulateDelta(W,T)},GA=function $(T){switch(T1(this,yG,T.data,"f"),T.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":if(T1(this,FW,T.data,"f"),T$(this,W1,"f"))this._emit("toolCallDone",T$(this,W1,"f")),T1(this,W1,void 0,"f");break;case"thread.run.cancelling":break}};function NI($){}class V2 extends y{create($,T){return this._client.post("/assistants",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}retrieve($,T){return this._client.get(`/assistants/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}update($,T,W){return this._client.post(`/assistants/${$}`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}list($={},T){if(Z$($))return this.list({},$);return this._client.getAPIList("/assistants",oX,{query:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}del($,T){return this._client.delete(`/assistants/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class oX extends v${}V2.AssistantsPage=oX;function $O($){return typeof $.parse==="function"}var VT=($)=>{return $?.role==="assistant"},TO=($)=>{return $?.role==="function"},WO=($)=>{return $?.role==="tool"};function lX($){return $?.$brand==="auto-parseable-response-format"}function OW($){return $?.$brand==="auto-parseable-tool"}function zA($,T){if(!T||!UO(T))return{...$,choices:$.choices.map((W)=>({...W,message:{...W.message,parsed:null,...W.message.tool_calls?{tool_calls:W.message.tool_calls}:void 0}}))};return rX($,T)}function rX($,T){let W=$.choices.map((U)=>{if(U.finish_reason==="length")throw new CX;if(U.finish_reason==="content_filter")throw new SX;return{...U,message:{...U.message,...U.message.tool_calls?{tool_calls:U.message.tool_calls?.map((X)=>_I(T,X))??void 0}:void 0,parsed:U.message.content&&!U.message.refusal?JI(T,U.message.content):null}}});return{...$,choices:W}}function JI($,T){if($.response_format?.type!=="json_schema")return null;if($.response_format?.type==="json_schema"){if("$parseRaw"in $.response_format)return $.response_format.$parseRaw(T);return JSON.parse(T)}return null}function _I($,T){let W=$.tools?.find((U)=>U.function?.name===T.function.name);return{...T,function:{...T.function,parsed_arguments:OW(W)?W.$parseRaw(T.function.arguments):W?.function.strict?JSON.parse(T.function.arguments):null}}}function HA($,T){if(!$)return!1;let W=$.tools?.find((U)=>U.function?.name===T.function.name);return OW(W)||W?.function.strict||!1}function UO($){if(lX($.response_format))return!0;return $.tools?.some((T)=>OW(T)||T.type==="function"&&T.function.strict===!0)??!1}function FA($){for(let T of $??[]){if(T.type!=="function")throw new e(`Currently only \`function\` tool types support auto-parsing; Received \`${T.type}\``);if(T.function.strict!==!0)throw new e(`The \`${T.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var I6=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},a4,XO,gG,YO,wO,GO,QA,zO,OA=10;class nX extends zW{constructor(){super(...arguments);a4.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion($){this._chatCompletions.push($),this._emit("chatCompletion",$);let T=$.choices[0]?.message;if(T)this._addMessage(T);return $}_addMessage($,T=!0){if(!("content"in $))$.content=null;if(this.messages.push($),T){if(this._emit("message",$),(TO($)||WO($))&&$.content)this._emit("functionCallResult",$.content);else if(VT($)&&$.function_call)this._emit("functionCall",$.function_call);else if(VT($)&&$.tool_calls){for(let W of $.tool_calls)if(W.type==="function")this._emit("functionCall",W.function)}}}async finalChatCompletion(){await this.done();let $=this._chatCompletions[this._chatCompletions.length-1];if(!$)throw new e("stream ended without producing a ChatCompletion");return $}async finalContent(){return await this.done(),I6(this,a4,"m",XO).call(this)}async finalMessage(){return await this.done(),I6(this,a4,"m",gG).call(this)}async finalFunctionCall(){return await this.done(),I6(this,a4,"m",YO).call(this)}async finalFunctionCallResult(){return await this.done(),I6(this,a4,"m",wO).call(this)}async totalUsage(){return await this.done(),I6(this,a4,"m",GO).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let $=this._chatCompletions[this._chatCompletions.length-1];if($)this._emit("finalChatCompletion",$);let T=I6(this,a4,"m",gG).call(this);if(T)this._emit("finalMessage",T);let W=I6(this,a4,"m",XO).call(this);if(W)this._emit("finalContent",W);let U=I6(this,a4,"m",YO).call(this);if(U)this._emit("finalFunctionCall",U);let X=I6(this,a4,"m",wO).call(this);if(X!=null)this._emit("finalFunctionCallResult",X);if(this._chatCompletions.some((Y)=>Y.usage))this._emit("totalUsage",I6(this,a4,"m",GO).call(this))}async _createChatCompletion($,T,W){let U=W?.signal;if(U){if(U.aborted)this.controller.abort();U.addEventListener("abort",()=>this.controller.abort())}I6(this,a4,"m",QA).call(this,T);let X=await $.chat.completions.create({...T,stream:!1},{...W,signal:this.controller.signal});return this._connected(),this._addChatCompletion(rX(X,T))}async _runChatCompletion($,T,W){for(let U of T.messages)this._addMessage(U,!1);return await this._createChatCompletion($,T,W)}async _runFunctions($,T,W){let{function_call:X="auto",stream:Y,...w}=T,G=typeof X!=="string"&&X?.name,{maxChatCompletions:H=OA}=W||{},z={};for(let O of T.functions)z[O.name||O.function.name]=O;let F=T.functions.map((O)=>({name:O.name||O.function.name,parameters:O.parameters,description:O.description}));for(let O of T.messages)this._addMessage(O,!1);for(let O=0;O<H;++O){let Z=(await this._createChatCompletion($,{...w,function_call:X,functions:F,messages:[...this.messages]},W)).choices[0]?.message;if(!Z)throw new e("missing message in ChatCompletion response");if(!Z.function_call)return;let{name:V,arguments:E}=Z.function_call,N=z[V];if(!N){let P=`Invalid function_call: ${JSON.stringify(V)}. Available options are: ${F.map((x)=>JSON.stringify(x.name)).join(", ")}. Please try again`;this._addMessage({role:"function",name:V,content:P});continue}else if(G&&G!==V){let P=`Invalid function_call: ${JSON.stringify(V)}. ${JSON.stringify(G)} requested. Please try again`;this._addMessage({role:"function",name:V,content:P});continue}let J;try{J=$O(N)?await N.parse(E):E}catch(P){this._addMessage({role:"function",name:V,content:P instanceof Error?P.message:String(P)});continue}let _=await N.function(J,this),R=I6(this,a4,"m",zO).call(this,_);if(this._addMessage({role:"function",name:V,content:R}),G)return}}async _runTools($,T,W){let{tool_choice:X="auto",stream:Y,...w}=T,G=typeof X!=="string"&&X?.function?.name,{maxChatCompletions:H=OA}=W||{},z=T.tools.map((Q)=>{if(OW(Q)){if(!Q.$callback)throw new e("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:Q.$callback,name:Q.function.name,description:Q.function.description||"",parameters:Q.function.parameters,parse:Q.$parseRaw,strict:!0}}}return Q}),F={};for(let Q of z)if(Q.type==="function")F[Q.function.name||Q.function.function.name]=Q.function;let O="tools"in T?z.map((Q)=>Q.type==="function"?{type:"function",function:{name:Q.function.name||Q.function.function.name,parameters:Q.function.parameters,description:Q.function.description,strict:Q.function.strict}}:Q):void 0;for(let Q of T.messages)this._addMessage(Q,!1);for(let Q=0;Q<H;++Q){let V=(await this._createChatCompletion($,{...w,tool_choice:X,tools:O,messages:[...this.messages]},W)).choices[0]?.message;if(!V)throw new e("missing message in ChatCompletion response");if(!V.tool_calls?.length)return;for(let E of V.tool_calls){if(E.type!=="function")continue;let N=E.id,{name:J,arguments:_}=E.function,R=F[J];if(!R){let h=`Invalid tool_call: ${JSON.stringify(J)}. Available options are: ${Object.keys(F).map((a)=>JSON.stringify(a)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:N,content:h});continue}else if(G&&G!==J){let h=`Invalid tool_call: ${JSON.stringify(J)}. ${JSON.stringify(G)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:N,content:h});continue}let P;try{P=$O(R)?await R.parse(_):_}catch(h){let a=h instanceof Error?h.message:String(h);this._addMessage({role:"tool",tool_call_id:N,content:a});continue}let x=await R.function(P,this),f=I6(this,a4,"m",zO).call(this,x);if(this._addMessage({role:"tool",tool_call_id:N,content:f}),G)return}}return}}a4=new WeakSet,XO=function $(){return I6(this,a4,"m",gG).call(this).content??null},gG=function $(){let T=this.messages.length;while(T-- >0){let W=this.messages[T];if(VT(W)){let{function_call:U,...X}=W,Y={...X,content:W.content??null,refusal:W.refusal??null};if(U)Y.function_call=U;return Y}}throw new e("stream ended without producing a ChatCompletionMessage with role=assistant")},YO=function $(){for(let T=this.messages.length-1;T>=0;T--){let W=this.messages[T];if(VT(W)&&W?.function_call)return W.function_call;if(VT(W)&&W?.tool_calls?.length)return W.tool_calls.at(-1)?.function}return},wO=function $(){for(let T=this.messages.length-1;T>=0;T--){let W=this.messages[T];if(TO(W)&&W.content!=null)return W.content;if(WO(W)&&W.content!=null&&typeof W.content==="string"&&this.messages.some((U)=>U.role==="assistant"&&U.tool_calls?.some((X)=>X.type==="function"&&X.id===W.tool_call_id)))return W.content}return},GO=function $(){let T={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:W}of this._chatCompletions)if(W)T.completion_tokens+=W.completion_tokens,T.prompt_tokens+=W.prompt_tokens,T.total_tokens+=W.total_tokens;return T},QA=function $(T){if(T.n!=null&&T.n>1)throw new e("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},zO=function $(T){return typeof T==="string"?T:T===void 0?"undefined":JSON.stringify(T)};class K2 extends nX{static runFunctions($,T,W){let U=new K2,X={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return U._run(()=>U._runFunctions($,T,X)),U}static runTools($,T,W){let U=new K2,X={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runTools"}};return U._run(()=>U._runTools($,T,X)),U}_addMessage($,T=!0){if(super._addMessage($,T),VT($)&&$.content)this._emit("content",$.content)}}var y4={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511};class ZA extends Error{}class DA extends Error{}function RI($,T=y4.ALL){if(typeof $!=="string")throw new TypeError(`expecting str, got ${typeof $}`);if(!$.trim())throw new Error(`${$} is empty`);return kI($.trim(),T)}var kI=($,T)=>{let W=$.length,U=0,X=(Q)=>{throw new ZA(`${Q} at position ${U}`)},Y=(Q)=>{throw new DA(`${Q} at position ${U}`)},w=()=>{if(O(),U>=W)X("Unexpected end of input");if($[U]==='"')return G();if($[U]==="{")return H();if($[U]==="[")return z();if($.substring(U,U+4)==="null"||y4.NULL&T&&W-U<4&&"null".startsWith($.substring(U)))return U+=4,null;if($.substring(U,U+4)==="true"||y4.BOOL&T&&W-U<4&&"true".startsWith($.substring(U)))return U+=4,!0;if($.substring(U,U+5)==="false"||y4.BOOL&T&&W-U<5&&"false".startsWith($.substring(U)))return U+=5,!1;if($.substring(U,U+8)==="Infinity"||y4.INFINITY&T&&W-U<8&&"Infinity".startsWith($.substring(U)))return U+=8,1/0;if($.substring(U,U+9)==="-Infinity"||y4.MINUS_INFINITY&T&&1<W-U&&W-U<9&&"-Infinity".startsWith($.substring(U)))return U+=9,-1/0;if($.substring(U,U+3)==="NaN"||y4.NAN&T&&W-U<3&&"NaN".startsWith($.substring(U)))return U+=3,NaN;return F()},G=()=>{let Q=U,Z=!1;U++;while(U<W&&($[U]!=='"'||Z&&$[U-1]==="\\"))Z=$[U]==="\\"?!Z:!1,U++;if($.charAt(U)=='"')try{return JSON.parse($.substring(Q,++U-Number(Z)))}catch(V){Y(String(V))}else if(y4.STR&T)try{return JSON.parse($.substring(Q,U-Number(Z))+'"')}catch(V){return JSON.parse($.substring(Q,$.lastIndexOf("\\"))+'"')}X("Unterminated string literal")},H=()=>{U++,O();let Q={};try{while($[U]!=="}"){if(O(),U>=W&&y4.OBJ&T)return Q;let Z=G();O(),U++;try{let V=w();Object.defineProperty(Q,Z,{value:V,writable:!0,enumerable:!0,configurable:!0})}catch(V){if(y4.OBJ&T)return Q;else throw V}if(O(),$[U]===",")U++}}catch(Z){if(y4.OBJ&T)return Q;else X("Expected '}' at end of object")}return U++,Q},z=()=>{U++;let Q=[];try{while($[U]!=="]")if(Q.push(w()),O(),$[U]===",")U++}catch(Z){if(y4.ARR&T)return Q;X("Expected ']' at end of array")}return U++,Q},F=()=>{if(U===0){if($==="-"&&y4.NUM&T)X("Not sure what '-' is");try{return JSON.parse($)}catch(Z){if(y4.NUM&T)try{if($[$.length-1]===".")return JSON.parse($.substring(0,$.lastIndexOf(".")));return JSON.parse($.substring(0,$.lastIndexOf("e")))}catch(V){}Y(String(Z))}}let Q=U;if($[U]==="-")U++;while($[U]&&!",]}".includes($[U]))U++;if(U==W&&!(y4.NUM&T))X("Unterminated number literal");try{return JSON.parse($.substring(Q,U))}catch(Z){if($.substring(Q,U)==="-"&&y4.NUM&T)X("Not sure what '-' is");try{return JSON.parse($.substring(Q,$.lastIndexOf("e")))}catch(V){Y(String(V))}}},O=()=>{while(U<W&&`
|
|
66
|
+
\r `.includes($[U]))U++};return w()},HO=($)=>RI($,y4.ALL^y4.NUM);var E2=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},m$=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},C4,v0,A2,KT,FO,mG,OO,QO,ZO,cG,DO,VA;class QW extends nX{constructor($){super();C4.add(this),v0.set(this,void 0),A2.set(this,void 0),KT.set(this,void 0),E2(this,v0,$,"f"),E2(this,A2,[],"f")}get currentChatCompletionSnapshot(){return m$(this,KT,"f")}static fromReadableStream($){let T=new QW(null);return T._run(()=>T._fromReadableStream($)),T}static createChatCompletion($,T,W){let U=new QW(T);return U._run(()=>U._runChatCompletion($,{...T,stream:!0},{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),U}async _createChatCompletion($,T,W){super._createChatCompletion;let U=W?.signal;if(U){if(U.aborted)this.controller.abort();U.addEventListener("abort",()=>this.controller.abort())}m$(this,C4,"m",FO).call(this);let X=await $.chat.completions.create({...T,stream:!0},{...W,signal:this.controller.signal});this._connected();for await(let Y of X)m$(this,C4,"m",OO).call(this,Y);if(X.controller.signal?.aborted)throw new P4;return this._addChatCompletion(m$(this,C4,"m",cG).call(this))}async _fromReadableStream($,T){let W=T?.signal;if(W){if(W.aborted)this.controller.abort();W.addEventListener("abort",()=>this.controller.abort())}m$(this,C4,"m",FO).call(this),this._connected();let U=$1.fromReadableStream($,this.controller),X;for await(let Y of U){if(X&&X!==Y.id)this._addChatCompletion(m$(this,C4,"m",cG).call(this));m$(this,C4,"m",OO).call(this,Y),X=Y.id}if(U.controller.signal?.aborted)throw new P4;return this._addChatCompletion(m$(this,C4,"m",cG).call(this))}[(v0=new WeakMap,A2=new WeakMap,KT=new WeakMap,C4=new WeakSet,FO=function $(){if(this.ended)return;E2(this,KT,void 0,"f")},mG=function $(T){let W=m$(this,A2,"f")[T.index];if(W)return W;return W={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},m$(this,A2,"f")[T.index]=W,W},OO=function $(T){if(this.ended)return;let W=m$(this,C4,"m",VA).call(this,T);this._emit("chunk",T,W);for(let U of T.choices){let X=W.choices[U.index];if(U.delta.content!=null&&X.message?.role==="assistant"&&X.message?.content)this._emit("content",U.delta.content,X.message.content),this._emit("content.delta",{delta:U.delta.content,snapshot:X.message.content,parsed:X.message.parsed});if(U.delta.refusal!=null&&X.message?.role==="assistant"&&X.message?.refusal)this._emit("refusal.delta",{delta:U.delta.refusal,snapshot:X.message.refusal});if(U.logprobs?.content!=null&&X.message?.role==="assistant")this._emit("logprobs.content.delta",{content:U.logprobs?.content,snapshot:X.logprobs?.content??[]});if(U.logprobs?.refusal!=null&&X.message?.role==="assistant")this._emit("logprobs.refusal.delta",{refusal:U.logprobs?.refusal,snapshot:X.logprobs?.refusal??[]});let Y=m$(this,C4,"m",mG).call(this,X);if(X.finish_reason){if(m$(this,C4,"m",ZO).call(this,X),Y.current_tool_call_index!=null)m$(this,C4,"m",QO).call(this,X,Y.current_tool_call_index)}for(let w of U.delta.tool_calls??[]){if(Y.current_tool_call_index!==w.index){if(m$(this,C4,"m",ZO).call(this,X),Y.current_tool_call_index!=null)m$(this,C4,"m",QO).call(this,X,Y.current_tool_call_index)}Y.current_tool_call_index=w.index}for(let w of U.delta.tool_calls??[]){let G=X.message.tool_calls?.[w.index];if(!G?.type)continue;if(G?.type==="function")this._emit("tool_calls.function.arguments.delta",{name:G.function?.name,index:w.index,arguments:G.function.arguments,parsed_arguments:G.function.parsed_arguments,arguments_delta:w.function?.arguments??""});else EA(G?.type)}}},QO=function $(T,W){if(m$(this,C4,"m",mG).call(this,T).done_tool_calls.has(W))return;let X=T.message.tool_calls?.[W];if(!X)throw new Error("no tool call snapshot");if(!X.type)throw new Error("tool call snapshot missing `type`");if(X.type==="function"){let Y=m$(this,v0,"f")?.tools?.find((w)=>w.type==="function"&&w.function.name===X.function.name);this._emit("tool_calls.function.arguments.done",{name:X.function.name,index:W,arguments:X.function.arguments,parsed_arguments:OW(Y)?Y.$parseRaw(X.function.arguments):Y?.function.strict?JSON.parse(X.function.arguments):null})}else EA(X.type)},ZO=function $(T){let W=m$(this,C4,"m",mG).call(this,T);if(T.message.content&&!W.content_done){W.content_done=!0;let U=m$(this,C4,"m",DO).call(this);this._emit("content.done",{content:T.message.content,parsed:U?U.$parseRaw(T.message.content):null})}if(T.message.refusal&&!W.refusal_done)W.refusal_done=!0,this._emit("refusal.done",{refusal:T.message.refusal});if(T.logprobs?.content&&!W.logprobs_content_done)W.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:T.logprobs.content});if(T.logprobs?.refusal&&!W.logprobs_refusal_done)W.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:T.logprobs.refusal})},cG=function $(){if(this.ended)throw new e("stream has ended, this shouldn't happen");let T=m$(this,KT,"f");if(!T)throw new e("request ended without sending any chunks");return E2(this,KT,void 0,"f"),E2(this,A2,[],"f"),vI(T,m$(this,v0,"f"))},DO=function $(){let T=m$(this,v0,"f")?.response_format;if(lX(T))return T;return null},VA=function $(T){var W,U,X,Y;let w=m$(this,KT,"f"),{choices:G,...H}=T;if(!w)w=E2(this,KT,{...H,choices:[]},"f");else Object.assign(w,H);for(let{delta:z,finish_reason:F,index:O,logprobs:Q=null,...Z}of T.choices){let V=w.choices[O];if(!V)V=w.choices[O]={finish_reason:F,index:O,message:{},logprobs:Q,...Z};if(Q)if(!V.logprobs)V.logprobs=Object.assign({},Q);else{let{content:x,refusal:f,...h}=Q;if(KA(h),Object.assign(V.logprobs,h),x)(W=V.logprobs).content??(W.content=[]),V.logprobs.content.push(...x);if(f)(U=V.logprobs).refusal??(U.refusal=[]),V.logprobs.refusal.push(...f)}if(F){if(V.finish_reason=F,m$(this,v0,"f")&&UO(m$(this,v0,"f"))){if(F==="length")throw new CX;if(F==="content_filter")throw new SX}}if(Object.assign(V,Z),!z)continue;let{content:E,refusal:N,function_call:J,role:_,tool_calls:R,...P}=z;if(KA(P),Object.assign(V.message,P),N)V.message.refusal=(V.message.refusal||"")+N;if(_)V.message.role=_;if(J)if(!V.message.function_call)V.message.function_call=J;else{if(J.name)V.message.function_call.name=J.name;if(J.arguments)(X=V.message.function_call).arguments??(X.arguments=""),V.message.function_call.arguments+=J.arguments}if(E){if(V.message.content=(V.message.content||"")+E,!V.message.refusal&&m$(this,C4,"m",DO).call(this))V.message.parsed=HO(V.message.content)}if(R){if(!V.message.tool_calls)V.message.tool_calls=[];for(let{index:x,id:f,type:h,function:a,...M$}of R){let S=(Y=V.message.tool_calls)[x]??(Y[x]={});if(Object.assign(S,M$),f)S.id=f;if(h)S.type=h;if(a)S.function??(S.function={name:a.name??"",arguments:""});if(a?.name)S.function.name=a.name;if(a?.arguments){if(S.function.arguments+=a.arguments,HA(m$(this,v0,"f"),S))S.function.parsed_arguments=HO(S.function.arguments)}}}}return w},Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("chunk",(U)=>{let X=T.shift();if(X)X.resolve(U);else $.push(U)}),this.on("end",()=>{W=!0;for(let U of T)U.resolve(void 0);T.length=0}),this.on("abort",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),this.on("error",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((X,Y)=>T.push({resolve:X,reject:Y})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new $1(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function vI($,T){let{id:W,choices:U,created:X,model:Y,system_fingerprint:w,...G}=$,H={...G,id:W,choices:U.map(({message:z,finish_reason:F,index:O,logprobs:Q,...Z})=>{if(!F)throw new e(`missing finish_reason for choice ${O}`);let{content:V=null,function_call:E,tool_calls:N,...J}=z,_=z.role;if(!_)throw new e(`missing role for choice ${O}`);if(E){let{arguments:R,name:P}=E;if(R==null)throw new e(`missing function_call.arguments for choice ${O}`);if(!P)throw new e(`missing function_call.name for choice ${O}`);return{...Z,message:{content:V,function_call:{arguments:R,name:P},role:_,refusal:z.refusal??null},finish_reason:F,index:O,logprobs:Q}}if(N)return{...Z,index:O,finish_reason:F,logprobs:Q,message:{...J,role:_,content:V,refusal:z.refusal??null,tool_calls:N.map((R,P)=>{let{function:x,type:f,id:h,...a}=R,{arguments:M$,name:S,...W$}=x||{};if(h==null)throw new e(`missing choices[${O}].tool_calls[${P}].id
|
|
67
|
+
${uG($)}`);if(f==null)throw new e(`missing choices[${O}].tool_calls[${P}].type
|
|
68
|
+
${uG($)}`);if(S==null)throw new e(`missing choices[${O}].tool_calls[${P}].function.name
|
|
69
|
+
${uG($)}`);if(M$==null)throw new e(`missing choices[${O}].tool_calls[${P}].function.arguments
|
|
70
|
+
${uG($)}`);return{...a,id:h,type:f,function:{...W$,name:S,arguments:M$}}})}};return{...Z,message:{...J,content:V,role:_,refusal:z.refusal??null},finish_reason:F,index:O,logprobs:Q}}),created:X,model:Y,object:"chat.completion",...w?{system_fingerprint:w}:{}};return zA(H,T)}function uG($){return JSON.stringify($)}function KA($){return}function EA($){}class ZW extends QW{static fromReadableStream($){let T=new ZW(null);return T._run(()=>T._fromReadableStream($)),T}static runFunctions($,T,W){let U=new ZW(null),X={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return U._run(()=>U._runFunctions($,T,X)),U}static runTools($,T,W){let U=new ZW(T),X={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runTools"}};return U._run(()=>U._runTools($,T,X)),U}}class pG extends y{parse($,T){return FA($.tools),this._client.chat.completions.create($,{...T,headers:{...T?.headers,"X-Stainless-Helper-Method":"beta.chat.completions.parse"}})._thenUnwrap((W)=>rX(W,$))}runFunctions($,T){if($.stream)return ZW.runFunctions(this._client,$,T);return K2.runFunctions(this._client,$,T)}runTools($,T){if($.stream)return ZW.runTools(this._client,$,T);return K2.runTools(this._client,$,T)}stream($,T){return QW.createChatCompletion(this._client,$,T)}}class iX extends y{constructor(){super(...arguments);this.completions=new pG(this._client)}}(function($){$.Completions=pG})(iX||(iX={}));class tX extends y{create($,T){return this._client.post("/realtime/sessions",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class aX extends y{create($,T){return this._client.post("/realtime/transcription_sessions",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class DW extends y{constructor(){super(...arguments);this.sessions=new tX(this._client),this.transcriptionSessions=new aX(this._client)}}DW.Sessions=tX;DW.TranscriptionSessions=aX;class M2 extends y{create($,T,W){return this._client.post(`/threads/${$}/messages`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}retrieve($,T,W){return this._client.get(`/threads/${$}/messages/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}update($,T,W,U){return this._client.post(`/threads/${$}/messages/${T}`,{body:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers}})}list($,T={},W){if(Z$(T))return this.list($,{},T);return this._client.getAPIList(`/threads/${$}/messages`,sX,{query:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}del($,T,W){return this._client.delete(`/threads/${$}/messages/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class sX extends v${}M2.MessagesPage=sX;class N2 extends y{retrieve($,T,W,U={},X){if(Z$(U))return this.retrieve($,T,W,{},U);return this._client.get(`/threads/${$}/runs/${T}/steps/${W}`,{query:U,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}list($,T,W={},U){if(Z$(W))return this.list($,T,{},W);return this._client.getAPIList(`/threads/${$}/runs/${T}/steps`,eX,{query:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers}})}}class eX extends v${}N2.RunStepsPage=eX;class ET extends y{constructor(){super(...arguments);this.steps=new N2(this._client)}create($,T,W){let{include:U,...X}=T;return this._client.post(`/threads/${$}/runs`,{query:{include:U},body:X,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers},stream:T.stream??!1})}retrieve($,T,W){return this._client.get(`/threads/${$}/runs/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}update($,T,W,U){return this._client.post(`/threads/${$}/runs/${T}`,{body:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers}})}list($,T={},W){if(Z$(T))return this.list($,{},T);return this._client.getAPIList(`/threads/${$}/runs`,$8,{query:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}cancel($,T,W){return this._client.post(`/threads/${$}/runs/${T}/cancel`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}async createAndPoll($,T,W){let U=await this.create($,T,W);return await this.poll($,U.id,W)}createAndStream($,T,W){return U1.createAssistantStream($,this._client.beta.threads.runs,T,W)}async poll($,T,W){let U={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)U["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let{data:X,response:Y}=await this.retrieve($,T,{...W,headers:{...W?.headers,...U}}).withResponse();switch(X.status){case"queued":case"in_progress":case"cancelling":let w=5000;if(W?.pollIntervalMs)w=W.pollIntervalMs;else{let G=Y.headers.get("openai-poll-after-ms");if(G){let H=parseInt(G);if(!isNaN(H))w=H}}await L0(w);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return X}}}stream($,T,W){return U1.createAssistantStream($,this._client.beta.threads.runs,T,W)}submitToolOutputs($,T,W,U){return this._client.post(`/threads/${$}/runs/${T}/submit_tool_outputs`,{body:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers},stream:W.stream??!1})}async submitToolOutputsAndPoll($,T,W,U){let X=await this.submitToolOutputs($,T,W,U);return await this.poll($,X.id,U)}submitToolOutputsStream($,T,W,U){return U1.createToolAssistantStream($,T,this._client.beta.threads.runs,W,U)}}class $8 extends v${}ET.RunsPage=$8;ET.Steps=N2;ET.RunStepsPage=eX;class q0 extends y{constructor(){super(...arguments);this.runs=new ET(this._client),this.messages=new M2(this._client)}create($={},T){if(Z$($))return this.create({},$);return this._client.post("/threads",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}retrieve($,T){return this._client.get(`/threads/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}update($,T,W){return this._client.post(`/threads/${$}`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}del($,T){return this._client.delete(`/threads/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}createAndRun($,T){return this._client.post("/threads/runs",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers},stream:$.stream??!1})}async createAndRunPoll($,T){let W=await this.createAndRun($,T);return await this.runs.poll(W.thread_id,W.id,T)}createAndRunStream($,T){return U1.createThreadAssistantStream($,this._client.beta.threads,T)}}q0.Runs=ET;q0.RunsPage=$8;q0.Messages=M2;q0.MessagesPage=sX;class s1 extends y{constructor(){super(...arguments);this.realtime=new DW(this._client),this.chat=new iX(this._client),this.assistants=new V2(this._client),this.threads=new q0(this._client)}}s1.Realtime=DW;s1.Assistants=V2;s1.AssistantsPage=oX;s1.Threads=q0;class L2 extends y{create($,T){return this._client.post("/completions",{body:$,...T,stream:$.stream??!1})}}class T8 extends y{retrieve($,T,W){return this._client.get(`/containers/${$}/files/${T}/content`,{...W,headers:{Accept:"*/*",...W?.headers}})}}class VW extends y{constructor(){super(...arguments);this.content=new T8(this._client)}create($,T,W){return this._client.post(`/containers/${$}/files`,x6({body:T,...W}))}retrieve($,T,W){return this._client.get(`/containers/${$}/files/${T}`,W)}list($,T={},W){if(Z$(T))return this.list($,{},T);return this._client.getAPIList(`/containers/${$}/files`,W8,{query:T,...W})}del($,T,W){return this._client.delete(`/containers/${$}/files/${T}`,{...W,headers:{Accept:"*/*",...W?.headers}})}}class W8 extends v${}VW.FileListResponsesPage=W8;VW.Content=T8;class P0 extends y{constructor(){super(...arguments);this.files=new VW(this._client)}create($,T){return this._client.post("/containers",{body:$,...T})}retrieve($,T){return this._client.get(`/containers/${$}`,T)}list($={},T){if(Z$($))return this.list({},$);return this._client.getAPIList("/containers",J2,{query:$,...T})}del($,T){return this._client.delete(`/containers/${$}`,{...T,headers:{Accept:"*/*",...T?.headers}})}}class J2 extends v${}P0.ContainerListResponsesPage=J2;P0.Files=VW;P0.FileListResponsesPage=W8;class _2 extends y{create($,T){let W=!!$.encoding_format,U=W?$.encoding_format:"base64";if(W)N0("Request","User defined encoding_format:",$.encoding_format);let X=this._client.post("/embeddings",{body:{...$,encoding_format:U},...T});if(W)return X;return N0("response","Decoding base64 embeddings to float32 array"),X._thenUnwrap((Y)=>{if(Y&&Y.data)Y.data.forEach((w)=>{let G=w.embedding;w.embedding=eE(G)});return Y})}}class R2 extends y{retrieve($,T,W,U){return this._client.get(`/evals/${$}/runs/${T}/output_items/${W}`,U)}list($,T,W={},U){if(Z$(W))return this.list($,T,{},W);return this._client.getAPIList(`/evals/${$}/runs/${T}/output_items`,U8,{query:W,...U})}}class U8 extends v${}R2.OutputItemListResponsesPage=U8;class AT extends y{constructor(){super(...arguments);this.outputItems=new R2(this._client)}create($,T,W){return this._client.post(`/evals/${$}/runs`,{body:T,...W})}retrieve($,T,W){return this._client.get(`/evals/${$}/runs/${T}`,W)}list($,T={},W){if(Z$(T))return this.list($,{},T);return this._client.getAPIList(`/evals/${$}/runs`,X8,{query:T,...W})}del($,T,W){return this._client.delete(`/evals/${$}/runs/${T}`,W)}cancel($,T,W){return this._client.post(`/evals/${$}/runs/${T}`,W)}}class X8 extends v${}AT.RunListResponsesPage=X8;AT.OutputItems=R2;AT.OutputItemListResponsesPage=U8;class C0 extends y{constructor(){super(...arguments);this.runs=new AT(this._client)}create($,T){return this._client.post("/evals",{body:$,...T})}retrieve($,T){return this._client.get(`/evals/${$}`,T)}update($,T,W){return this._client.post(`/evals/${$}`,{body:T,...W})}list($={},T){if(Z$($))return this.list({},$);return this._client.getAPIList("/evals",k2,{query:$,...T})}del($,T){return this._client.delete(`/evals/${$}`,T)}}class k2 extends v${}C0.EvalListResponsesPage=k2;C0.Runs=AT;C0.RunListResponsesPage=X8;class KW extends y{create($,T){return this._client.post("/files",x6({body:$,...T}))}retrieve($,T){return this._client.get(`/files/${$}`,T)}list($={},T){if(Z$($))return this.list({},$);return this._client.getAPIList("/files",v2,{query:$,...T})}del($,T){return this._client.delete(`/files/${$}`,T)}content($,T){return this._client.get(`/files/${$}/content`,{...T,headers:{Accept:"application/binary",...T?.headers},__binaryResponse:!0})}retrieveContent($,T){return this._client.get(`/files/${$}/content`,T)}async waitForProcessing($,{pollInterval:T=5000,maxWait:W=1800000}={}){let U=new Set(["processed","error","deleted"]),X=Date.now(),Y=await this.retrieve($);while(!Y.status||!U.has(Y.status))if(await L0(T),Y=await this.retrieve($),Date.now()-X>W)throw new UW({message:`Giving up on waiting for file ${$} to finish processing after ${W} milliseconds.`});return Y}}class v2 extends v${}KW.FileObjectsPage=v2;class Y8 extends y{}class w8 extends y{run($,T){return this._client.post("/fine_tuning/alpha/graders/run",{body:$,...T})}validate($,T){return this._client.post("/fine_tuning/alpha/graders/validate",{body:$,...T})}}class q2 extends y{constructor(){super(...arguments);this.graders=new w8(this._client)}}q2.Graders=w8;class P2 extends y{create($,T,W){return this._client.getAPIList(`/fine_tuning/checkpoints/${$}/permissions`,G8,{body:T,method:"post",...W})}retrieve($,T={},W){if(Z$(T))return this.retrieve($,{},T);return this._client.get(`/fine_tuning/checkpoints/${$}/permissions`,{query:T,...W})}del($,T,W){return this._client.delete(`/fine_tuning/checkpoints/${$}/permissions/${T}`,W)}}class G8 extends _0{}P2.PermissionCreateResponsesPage=G8;class EW extends y{constructor(){super(...arguments);this.permissions=new P2(this._client)}}EW.Permissions=P2;EW.PermissionCreateResponsesPage=G8;class C2 extends y{list($,T={},W){if(Z$(T))return this.list($,{},T);return this._client.getAPIList(`/fine_tuning/jobs/${$}/checkpoints`,z8,{query:T,...W})}}class z8 extends v${}C2.FineTuningJobCheckpointsPage=z8;class S0 extends y{constructor(){super(...arguments);this.checkpoints=new C2(this._client)}create($,T){return this._client.post("/fine_tuning/jobs",{body:$,...T})}retrieve($,T){return this._client.get(`/fine_tuning/jobs/${$}`,T)}list($={},T){if(Z$($))return this.list({},$);return this._client.getAPIList("/fine_tuning/jobs",H8,{query:$,...T})}cancel($,T){return this._client.post(`/fine_tuning/jobs/${$}/cancel`,T)}listEvents($,T={},W){if(Z$(T))return this.listEvents($,{},T);return this._client.getAPIList(`/fine_tuning/jobs/${$}/events`,F8,{query:T,...W})}pause($,T){return this._client.post(`/fine_tuning/jobs/${$}/pause`,T)}resume($,T){return this._client.post(`/fine_tuning/jobs/${$}/resume`,T)}}class H8 extends v${}class F8 extends v${}S0.FineTuningJobsPage=H8;S0.FineTuningJobEventsPage=F8;S0.Checkpoints=C2;S0.FineTuningJobCheckpointsPage=z8;class V1 extends y{constructor(){super(...arguments);this.methods=new Y8(this._client),this.jobs=new S0(this._client),this.checkpoints=new EW(this._client),this.alpha=new q2(this._client)}}V1.Methods=Y8;V1.Jobs=S0;V1.FineTuningJobsPage=H8;V1.FineTuningJobEventsPage=F8;V1.Checkpoints=EW;V1.Alpha=q2;class O8 extends y{}class AW extends y{constructor(){super(...arguments);this.graderModels=new O8(this._client)}}AW.GraderModels=O8;class S2 extends y{createVariation($,T){return this._client.post("/images/variations",x6({body:$,...T}))}edit($,T){return this._client.post("/images/edits",x6({body:$,...T}))}generate($,T){return this._client.post("/images/generations",{body:$,...T})}}class MW extends y{retrieve($,T){return this._client.get(`/models/${$}`,T)}list($){return this._client.getAPIList("/models",j2,$)}del($,T){return this._client.delete(`/models/${$}`,T)}}class j2 extends _0{}MW.ModelsPage=j2;class B2 extends y{create($,T){return this._client.post("/moderations",{body:$,...T})}}function AA($,T){if(!T||!iI(T))return{...$,output_parsed:null,output:$.output.map((W)=>{if(W.type==="function_call")return{...W,parsed_arguments:null};if(W.type==="message")return{...W,content:W.content.map((U)=>({...U,parsed:null}))};else return W})};return VO($,T)}function VO($,T){let W=$.output.map((X)=>{if(X.type==="function_call")return{...X,parsed_arguments:sI(T,X)};if(X.type==="message"){let Y=X.content.map((w)=>{if(w.type==="output_text")return{...w,parsed:nI(T,w.text)};return w});return{...X,content:Y}}return X}),U=Object.assign({},$,{output:W});if(!Object.getOwnPropertyDescriptor($,"output_text"))dG(U);return Object.defineProperty(U,"output_parsed",{enumerable:!0,get(){for(let X of U.output){if(X.type!=="message")continue;for(let Y of X.content)if(Y.type==="output_text"&&Y.parsed!==null)return Y.parsed}return null}}),U}function nI($,T){if($.text?.format?.type!=="json_schema")return null;if("$parseRaw"in $.text?.format)return($.text?.format).$parseRaw(T);return JSON.parse(T)}function iI($){if(lX($.text?.format))return!0;return!1}function tI($){return $?.$brand==="auto-parseable-tool"}function aI($,T){return $.find((W)=>W.type==="function"&&W.name===T)}function sI($,T){let W=aI($.tools??[],T.name);return{...T,...T,parsed_arguments:tI(W)?W.$parseRaw(T.arguments):W?.strict?JSON.parse(T.arguments):null}}function dG($){let T=[];for(let W of $.output){if(W.type!=="message")continue;for(let U of W.content)if(U.type==="output_text")T.push(U.text)}$.output_text=T.join("")}class Q8 extends y{list($,T={},W){if(Z$(T))return this.list($,{},T);return this._client.getAPIList(`/responses/${$}/input_items`,KO,{query:T,...W})}}var x2=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},MT=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},I2,oG,NT,lG,MA,NA,LA,JA;class rG extends zW{constructor($){super();I2.add(this),oG.set(this,void 0),NT.set(this,void 0),lG.set(this,void 0),x2(this,oG,$,"f")}static createResponse($,T,W){let U=new rG(T);return U._run(()=>U._createOrRetrieveResponse($,T,{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),U}async _createOrRetrieveResponse($,T,W){let U=W?.signal;if(U){if(U.aborted)this.controller.abort();U.addEventListener("abort",()=>this.controller.abort())}MT(this,I2,"m",MA).call(this);let X,Y=null;if("response_id"in T)X=await $.responses.retrieve(T.response_id,{stream:!0},{...W,signal:this.controller.signal,stream:!0}),Y=T.starting_after??null;else X=await $.responses.create({...T,stream:!0},{...W,signal:this.controller.signal});this._connected();for await(let w of X)MT(this,I2,"m",NA).call(this,w,Y);if(X.controller.signal?.aborted)throw new P4;return MT(this,I2,"m",LA).call(this)}[(oG=new WeakMap,NT=new WeakMap,lG=new WeakMap,I2=new WeakSet,MA=function $(){if(this.ended)return;x2(this,NT,void 0,"f")},NA=function $(T,W){if(this.ended)return;let U=(Y,w)=>{if(W==null||w.sequence_number>W)this._emit(Y,w)},X=MT(this,I2,"m",JA).call(this,T);switch(U("event",T),T.type){case"response.output_text.delta":{let Y=X.output[T.output_index];if(!Y)throw new e(`missing output at index ${T.output_index}`);if(Y.type==="message"){let w=Y.content[T.content_index];if(!w)throw new e(`missing content at index ${T.content_index}`);if(w.type!=="output_text")throw new e(`expected content to be 'output_text', got ${w.type}`);U("response.output_text.delta",{...T,snapshot:w.text})}break}case"response.function_call_arguments.delta":{let Y=X.output[T.output_index];if(!Y)throw new e(`missing output at index ${T.output_index}`);if(Y.type==="function_call")U("response.function_call_arguments.delta",{...T,snapshot:Y.arguments});break}default:U(T.type,T);break}},LA=function $(){if(this.ended)throw new e("stream has ended, this shouldn't happen");let T=MT(this,NT,"f");if(!T)throw new e("request ended without sending any events");x2(this,NT,void 0,"f");let W=$b(T,MT(this,oG,"f"));return x2(this,lG,W,"f"),W},JA=function $(T){let W=MT(this,NT,"f");if(!W){if(T.type!=="response.created")throw new e(`When snapshot hasn't been set yet, expected 'response.created' event, got ${T.type}`);return W=x2(this,NT,T.response,"f"),W}switch(T.type){case"response.output_item.added":{W.output.push(T.item);break}case"response.content_part.added":{let U=W.output[T.output_index];if(!U)throw new e(`missing output at index ${T.output_index}`);if(U.type==="message")U.content.push(T.part);break}case"response.output_text.delta":{let U=W.output[T.output_index];if(!U)throw new e(`missing output at index ${T.output_index}`);if(U.type==="message"){let X=U.content[T.content_index];if(!X)throw new e(`missing content at index ${T.content_index}`);if(X.type!=="output_text")throw new e(`expected content to be 'output_text', got ${X.type}`);X.text+=T.delta}break}case"response.function_call_arguments.delta":{let U=W.output[T.output_index];if(!U)throw new e(`missing output at index ${T.output_index}`);if(U.type==="function_call")U.arguments+=T.delta;break}case"response.completed":{x2(this,NT,T.response,"f");break}}return W},Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("event",(U)=>{let X=T.shift();if(X)X.resolve(U);else $.push(U)}),this.on("end",()=>{W=!0;for(let U of T)U.resolve(void 0);T.length=0}),this.on("abort",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),this.on("error",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((X,Y)=>T.push({resolve:X,reject:Y})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}async finalResponse(){await this.done();let $=MT(this,lG,"f");if(!$)throw new e("stream ended without producing a ChatCompletion");return $}}function $b($,T){return AA($,T)}class NW extends y{constructor(){super(...arguments);this.inputItems=new Q8(this._client)}create($,T){return this._client.post("/responses",{body:$,...T,stream:$.stream??!1})._thenUnwrap((W)=>{if("object"in W&&W.object==="response")dG(W);return W})}retrieve($,T={},W){if(Z$(T)&&W===void 0)return this.retrieve($,{},T);return this._client.get(`/responses/${$}`,{query:T,...W,stream:T.stream??!1})._thenUnwrap((U)=>{if("object"in U&&U.object==="response")dG(U);return U})}del($,T){return this._client.delete(`/responses/${$}`,{...T,headers:{Accept:"*/*",...T?.headers}})}parse($,T){return this._client.responses.create($,T)._thenUnwrap((W)=>VO(W,$))}stream($,T){return rG.createResponse(this._client,$,T)}cancel($,T){return this._client.post(`/responses/${$}/cancel`,{...T,headers:{Accept:"*/*",...T?.headers}})}}class KO extends v${}NW.InputItems=Q8;class Z8 extends y{create($,T,W){return this._client.post(`/uploads/${$}/parts`,x6({body:T,...W}))}}class LW extends y{constructor(){super(...arguments);this.parts=new Z8(this._client)}create($,T){return this._client.post("/uploads",{body:$,...T})}cancel($,T){return this._client.post(`/uploads/${$}/cancel`,T)}complete($,T,W){return this._client.post(`/uploads/${$}/complete`,{body:T,...W})}}LW.Parts=Z8;var _A=async($)=>{let T=await Promise.allSettled($),W=T.filter((X)=>X.status==="rejected");if(W.length){for(let X of W)console.error(X.reason);throw new Error(`${W.length} promise(s) failed - see the above errors`)}let U=[];for(let X of T)if(X.status==="fulfilled")U.push(X.value);return U};class JW extends y{create($,T,W){return this._client.post(`/vector_stores/${$}/files`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}retrieve($,T,W){return this._client.get(`/vector_stores/${$}/files/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}update($,T,W,U){return this._client.post(`/vector_stores/${$}/files/${T}`,{body:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers}})}list($,T={},W){if(Z$(T))return this.list($,{},T);return this._client.getAPIList(`/vector_stores/${$}/files`,_W,{query:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}del($,T,W){return this._client.delete(`/vector_stores/${$}/files/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}async createAndPoll($,T,W){let U=await this.create($,T,W);return await this.poll($,U.id,W)}async poll($,T,W){let U={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)U["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let X=await this.retrieve($,T,{...W,headers:U}).withResponse(),Y=X.data;switch(Y.status){case"in_progress":let w=5000;if(W?.pollIntervalMs)w=W.pollIntervalMs;else{let G=X.response.headers.get("openai-poll-after-ms");if(G){let H=parseInt(G);if(!isNaN(H))w=H}}await L0(w);break;case"failed":case"completed":return Y}}}async upload($,T,W){let U=await this._client.files.create({file:T,purpose:"assistants"},W);return this.create($,{file_id:U.id},W)}async uploadAndPoll($,T,W){let U=await this.upload($,T,W);return await this.poll($,U.id,W)}content($,T,W){return this._client.getAPIList(`/vector_stores/${$}/files/${T}/content`,D8,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class _W extends v${}class D8 extends _0{}JW.VectorStoreFilesPage=_W;JW.FileContentResponsesPage=D8;class V8 extends y{create($,T,W){return this._client.post(`/vector_stores/${$}/file_batches`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}retrieve($,T,W){return this._client.get(`/vector_stores/${$}/file_batches/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}cancel($,T,W){return this._client.post(`/vector_stores/${$}/file_batches/${T}/cancel`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}async createAndPoll($,T,W){let U=await this.create($,T);return await this.poll($,U.id,W)}listFiles($,T,W={},U){if(Z$(W))return this.listFiles($,T,{},W);return this._client.getAPIList(`/vector_stores/${$}/file_batches/${T}/files`,_W,{query:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers}})}async poll($,T,W){let U={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)U["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let{data:X,response:Y}=await this.retrieve($,T,{...W,headers:U}).withResponse();switch(X.status){case"in_progress":let w=5000;if(W?.pollIntervalMs)w=W.pollIntervalMs;else{let G=Y.headers.get("openai-poll-after-ms");if(G){let H=parseInt(G);if(!isNaN(H))w=H}}await L0(w);break;case"failed":case"cancelled":case"completed":return X}}}async uploadAndPoll($,{files:T,fileIds:W=[]},U){if(T==null||T.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let X=U?.maxConcurrency??5,Y=Math.min(X,T.length),w=this._client,G=T.values(),H=[...W];async function z(O){for(let Q of O){let Z=await w.files.create({file:Q,purpose:"assistants"},U);H.push(Z.id)}}let F=Array(Y).fill(G).map(z);return await _A(F),await this.createAndPoll($,{file_ids:H})}}class K1 extends y{constructor(){super(...arguments);this.files=new JW(this._client),this.fileBatches=new V8(this._client)}create($,T){return this._client.post("/vector_stores",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}retrieve($,T){return this._client.get(`/vector_stores/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}update($,T,W){return this._client.post(`/vector_stores/${$}`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}list($={},T){if(Z$($))return this.list({},$);return this._client.getAPIList("/vector_stores",b2,{query:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}del($,T){return this._client.delete(`/vector_stores/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}search($,T,W){return this._client.getAPIList(`/vector_stores/${$}/search`,f2,{body:T,method:"post",...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class b2 extends v${}class f2 extends _0{}K1.VectorStoresPage=b2;K1.VectorStoreSearchResponsesPage=f2;K1.Files=JW;K1.VectorStoreFilesPage=_W;K1.FileContentResponsesPage=D8;K1.FileBatches=V8;var RA;class D$ extends tF{constructor({baseURL:$=BX("OPENAI_BASE_URL"),apiKey:T=BX("OPENAI_API_KEY"),organization:W=BX("OPENAI_ORG_ID")??null,project:U=BX("OPENAI_PROJECT_ID")??null,...X}={}){if(T===void 0)throw new e("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");let Y={apiKey:T,organization:W,project:U,...X,baseURL:$||"https://api.openai.com/v1"};if(!Y.dangerouslyAllowBrowser&&sE())throw new e(`It looks like you're running in a browser-like environment.
|
|
71
71
|
|
|
72
72
|
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
73
73
|
If you understand the risks and have appropriate mitigations in place,
|
|
@@ -76,21 +76,21 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
76
76
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
77
77
|
|
|
78
78
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
79
|
-
`);super({baseURL:
|
|
80
|
-
`)});return{model:$,messages:G}}var a=1e6,RQ={"gpt-4.1":{promptPricePerToken:2/a,promptPricePerTokenCached:0.5/a,completionPricePerToken:8/a},"gpt-4.1-mini":{promptPricePerToken:0.4/a,promptPricePerTokenCached:0.1/a,completionPricePerToken:1.6/a},"gpt-4.1-nano":{promptPricePerToken:0.1/a,promptPricePerTokenCached:0.025/a,completionPricePerToken:0.4/a},"gpt-4o":{promptPricePerToken:2.5/a,promptPricePerTokenCached:1.25/a,completionPricePerToken:10/a},"gpt-4o-mini":{promptPricePerToken:0.15/a,promptPricePerTokenCached:0.075/a,completionPricePerToken:0.6/a},o1:{promptPricePerToken:15/a,promptPricePerTokenCached:7.5/a,completionPricePerToken:60/a},"o1-mini":{promptPricePerToken:1.1/a,promptPricePerTokenCached:0.55/a,completionPricePerToken:4.4/a},o3:{promptPricePerToken:10/a,promptPricePerTokenCached:2.5/a,completionPricePerToken:40/a},"o3-mini":{promptPricePerToken:1.1/a,promptPricePerTokenCached:0.55/a,completionPricePerToken:4.4/a},"o4-mini":{promptPricePerToken:1.1/a,promptPricePerTokenCached:0.275/a,completionPricePerToken:4.4/a},"codex-mini-latest":{promptPricePerToken:1.5/a,promptPricePerTokenCached:0.375/a,completionPricePerToken:6/a},"chatgpt-4o-latest":{promptPricePerToken:5/a,promptPricePerTokenCached:5/a,completionPricePerToken:15/a},"gpt-4":{promptPricePerToken:30/a,promptPricePerTokenCached:30/a,completionPricePerToken:60/a},"gpt-4-turbo":{promptPricePerToken:10/a,promptPricePerTokenCached:10/a,completionPricePerToken:30/a},"gpt-3.5-turbo":{promptPricePerToken:0.5/a,promptPricePerTokenCached:0.5/a,completionPricePerToken:1.5/a},"gpt-4-32k":{promptPricePerToken:60/a,promptPricePerTokenCached:60/a,completionPricePerToken:120/a},"gpt-3.5-turbo-16k":{promptPricePerToken:3/a,promptPricePerTokenCached:3/a,completionPricePerToken:4/a}};function oI($){let W=Object.keys(RQ).filter((X)=>$.startsWith(X)).sort((X,Y)=>Y.length-X.length)[0];if(!W)return;return RQ[W]}function lI($){return async function T(W,X){if(!$)throw new Error("This is a bug in safegen. OpenAI client not available to the json generator.");let Y=await $.chat.completions.create({...W,stream:!1,response_format:{type:"json_object"}},X),U=Y.choices[0].message?.content,{usage:G}=Y;if(U&&G){let J=G.prompt_tokens,z=G.prompt_tokens_details?.cached_tokens??0,w=J-z,H=G.completion_tokens,_=oI(W.model),F=0;if(_)F=J*_.promptPricePerToken+w*(_.promptPricePerTokenCached??0)+H*_.completionPricePerToken;else console.warn(`No pricing facts found for model ${W.model}. Giving a price of 0.`);return{data:JSON.parse(U),usage:G,usdPrice:F}}if(!U&&!G)throw new Error("No content or usage found in completion");if(!U)throw new Error("No content found in completion");throw new Error("No usage found in completion")}}var IQ=new Map,kQ=class{usdBudget;usdMinimum;getUnknownJsonFromOpenAi;getUnknownJsonFromOpenAiSquirreled;squirrel;client;lastUsage;constructor({model:$,usdBudget:T,usdMinimum:W,apiKey:X,cachingMode:Y,cacheKey:U="openai-safegen",logger:G}){this.usdBudget=T,this.usdMinimum=W,this.squirrel=new RF(Y);let J=IQ.get(X);if(Y!=="read"){if(!J)J=new BQ({apiKey:X,dangerouslyAllowBrowser:!1}),IQ.set(X,J);this.client=J}this.getUnknownJsonFromOpenAi=lI(this.client),this.getUnknownJsonFromOpenAiSquirreled=this.squirrel.add(U,this.getUnknownJsonFromOpenAi),this.from=_F(async(...z)=>{if(this.usdBudget<this.usdMinimum)return G?.warn("SafeGen budget exhausted"),z[2];let w=dI($,...z),H=z[0],_=z[3],{data:F,usage:D,usdPrice:V}=await this.getUnknownJsonFromOpenAiSquirreled.for(`${H.replace(/[^a-zA-Z0-9-_. ]/g,"_")}-${_.length}`).get(w);return this.lastUsage=D,this.usdBudget-=V,F},G)}from};import{exec as $j}from"child_process";class B8{supported;constructor($){this.supported=$}refine($){for(let[T,W]of Object.entries(this.supported))try{if(W($)===!0&&W!==Boolean)return{type:T,data:$}}catch(X){try{if($ instanceof W)return{type:T,data:$}}catch(Y){}}return null}}var rI=new B8({number:($)=>typeof $==="number",string:($)=>typeof $==="string",boolean:($)=>typeof $==="boolean",null:($)=>$===null});function iI($){if(!$)return!1;return Object.getPrototypeOf($)===Object.prototype}var nI=new B8({object:iI,array:($)=>Array.isArray($)}),tI=new B8({...rI.supported,...nI.supported}),qQ=($)=>{if($===void 0)return"undefined";let T=tI.refine($);if(T)return T.type;return Object.getPrototypeOf($).constructor.name};var Z=Symbol.for("drizzle:entityKind"),Wd=Symbol.for("drizzle:hasOwnEntityKind");function S($,T){if(!$||typeof $!=="object")return!1;if($ instanceof T)return!0;if(!Object.prototype.hasOwnProperty.call(T,Z))throw new Error(`Class "${T.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let W=Object.getPrototypeOf($).constructor;if(W)while(W){if(Z in W&&W[Z]===T[Z])return!0;W=Object.getPrototypeOf(W)}return!1}class B${constructor($,T){this.table=$,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[Z]="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($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class z7{static[Z]="ColumnBuilder";config;constructor($,T,W){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:T,columnType:W,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}var A6=Symbol.for("drizzle:Name");class _7{static[Z]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor($,T){if(this.reference=()=>{let{name:W,columns:X,foreignColumns:Y}=$();return{name:W,columns:X,foreignTable:Y[0].table,foreignColumns:Y}},T)this._onUpdate=T.onUpdate,this._onDelete=T.onDelete}onUpdate($){return this._onUpdate=$===void 0?"no action":$,this}onDelete($){return this._onDelete=$===void 0?"no action":$,this}build($){return new PQ($,this)}}class PQ{constructor($,T){this.table=$,this.reference=T.reference,this.onUpdate=T._onUpdate,this.onDelete=T._onDelete}static[Z]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:T,foreignColumns:W}=this.reference(),X=T.map((G)=>G.name),Y=W.map((G)=>G.name),U=[this.table[A6],...X,W[0].table[A6],...Y];return $??`${U.join("_")}_fk`}}function R8($,...T){return $(...T)}function CQ($,T){return`${$[A6]}_${T.join("_")}_unique`}function vQ($,T,W){for(let X=T;X<$.length;X++){let Y=$[X];if(Y==="\\"){X++;continue}if(Y==='"')return[$.slice(T,X).replace(/\\/g,""),X+1];if(W)continue;if(Y===","||Y==="}")return[$.slice(T,X).replace(/\\/g,""),X]}return[$.slice(T).replace(/\\/g,""),$.length]}function jQ($,T=0){let W=[],X=T,Y=!1;while(X<$.length){let U=$[X];if(U===","){if(Y||X===T)W.push("");Y=!0,X++;continue}if(Y=!1,U==="\\"){X+=2;continue}if(U==='"'){let[z,w]=vQ($,X+1,!0);W.push(z),X=w;continue}if(U==="}")return[W,X+1];if(U==="{"){let[z,w]=jQ($,X+1);W.push(z),X=w;continue}let[G,J]=vQ($,X,!1);W.push(G),X=J}return[W,X]}function xQ($){let[T]=jQ($,1);return T}function H7($){return`{${$.map((T)=>{if(Array.isArray(T))return H7(T);if(typeof T==="string")return`"${T.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${T}`}).join(",")}}`}class d extends z7{foreignKeyConfigs=[];static[Z]="PgColumnBuilder";array($){return new fQ(this.config.name,this,$)}references($,T={}){return this.foreignKeyConfigs.push({ref:$,actions:T}),this}unique($,T){return this.config.isUnique=!0,this.config.uniqueName=$,this.config.uniqueType=T?.nulls,this}generatedAlwaysAs($){return this.config.generated={as:$,type:"always",mode:"stored"},this}buildForeignKeys($,T){return this.foreignKeyConfigs.map(({ref:W,actions:X})=>{return R8((Y,U)=>{let G=new _7(()=>{let J=Y();return{columns:[$],foreignColumns:[J]}});if(U.onUpdate)G.onUpdate(U.onUpdate);if(U.onDelete)G.onDelete(U.onDelete);return G.build(T)},W,X)})}buildExtraConfigColumn($){return new bQ($,this.config)}}class b extends B${constructor($,T){if(!T.uniqueName)T.uniqueName=CQ($,[T.name]);super($,T);this.table=$}static[Z]="PgColumn"}class bQ extends b{static[Z]="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($){return this.indexConfig.opClass=$,this}}class f2{static[Z]="IndexedColumn";constructor($,T,W,X){this.name=$,this.keyAsName=T,this.type=W,this.indexConfig=X}name;keyAsName;type;indexConfig}class fQ extends d{static[Z]="PgArrayBuilder";constructor($,T,W){super($,"array","PgArray");this.config.baseBuilder=T,this.config.size=W}build($){let T=this.config.baseBuilder.build($);return new F7($,this.config,T)}}class F7 extends b{constructor($,T,W,X){super($,T);this.baseColumn=W,this.range=X,this.size=T.size}size;static[Z]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue($){if(typeof $==="string")$=xQ($);return $.map((T)=>this.baseColumn.mapFromDriverValue(T))}mapToDriverValue($,T=!1){let W=$.map((X)=>X===null?null:S(this.baseColumn,F7)?this.baseColumn.mapToDriverValue(X,!0):this.baseColumn.mapToDriverValue(X));if(T)return W;return H7(W)}}class yQ extends d{static[Z]="PgEnumObjectColumnBuilder";constructor($,T){super($,"string","PgEnumObjectColumn");this.config.enum=T}build($){return new hQ($,this.config)}}class hQ extends b{static[Z]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,T){super($,T);this.enum=T.enum}getSQLType(){return this.enum.enumName}}var I8=Symbol.for("drizzle:isPgEnum");function gQ($){return!!$&&typeof $==="function"&&I8 in $&&$[I8]===!0}class mQ extends d{static[Z]="PgEnumColumnBuilder";constructor($,T){super($,"string","PgEnumColumn");this.config.enum=T}build($){return new cQ($,this.config)}}class cQ extends b{static[Z]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,T){super($,T);this.enum=T.enum}getSQLType(){return this.enum.enumName}}function y2($,T){return Array.isArray(T)?aI($,[...T],void 0):sI($,T,void 0)}function aI($,T,W){let X=Object.assign((Y)=>new mQ(Y??"",X),{enumName:$,enumValues:T,schema:W,[I8]:!0});return X}function sI($,T,W){let X=Object.assign((Y)=>new yQ(Y??"",X),{enumName:$,enumValues:Object.values(T),schema:W,[I8]:!0});return X}class G4{static[Z]="Subquery";constructor($,T,W,X=!1){this._={brand:"Subquery",sql:$,selectedFields:T,alias:W,isWith:X}}}class h2 extends G4{static[Z]="WithSubquery"}var uQ="0.43.1";var Q7,Z7,R$={startActiveSpan($,T){if(!Q7)return T();if(!Z7)Z7=Q7.trace.getTracer("drizzle-orm",uQ);return R8((W,X)=>X.startActiveSpan($,(Y)=>{try{return T(Y)}catch(U){throw Y.setStatus({code:W.SpanStatusCode.ERROR,message:U instanceof Error?U.message:"Unknown error"}),U}finally{Y.end()}}),Q7,Z7)}};var C$=Symbol.for("drizzle:ViewBaseConfig");var k8=Symbol.for("drizzle:Schema"),q8=Symbol.for("drizzle:Columns"),pQ=Symbol.for("drizzle:ExtraConfigColumns"),D7=Symbol.for("drizzle:OriginalName"),O7=Symbol.for("drizzle:BaseName"),g2=Symbol.for("drizzle:IsAlias"),dQ=Symbol.for("drizzle:ExtraConfigBuilder"),eI=Symbol.for("drizzle:IsDrizzleTable");class c{static[Z]="Table";static Symbol={Name:A6,Schema:k8,OriginalName:D7,Columns:q8,ExtraConfigColumns:pQ,BaseName:O7,IsAlias:g2,ExtraConfigBuilder:dQ};[A6];[D7];[k8];[q8];[pQ];[O7];[g2]=!1;[eI]=!0;[dQ]=void 0;constructor($,T,W){this[A6]=this[D7]=$,this[k8]=T,this[O7]=W}}function F4($){return $[A6]}function R0($){return`${$[k8]??"public"}.${$[A6]}`}function V7($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function $k($){let T={sql:"",params:[]};for(let W of $)if(T.sql+=W.sql,T.params.push(...W.params),W.typings?.length){if(!T.typings)T.typings=[];T.typings.push(...W.typings)}return T}class J4{static[Z]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new p([this])}}class p{constructor($){this.queryChunks=$}static[Z]="SQL";decoder=lQ;shouldInlineParams=!1;append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return R$.startActiveSpan("drizzle.buildSQL",(T)=>{let W=this.buildQueryFromSourceParams(this.queryChunks,$);return T?.setAttributes({"drizzle.query.text":W.sql,"drizzle.query.params":JSON.stringify(W.params)}),W})}buildQueryFromSourceParams($,T){let W=Object.assign({},T,{inlineParams:T.inlineParams||this.shouldInlineParams,paramStartIndex:T.paramStartIndex||{value:0}}),{casing:X,escapeName:Y,escapeParam:U,prepareTyping:G,inlineParams:J,paramStartIndex:z}=W;return $k($.map((w)=>{if(S(w,J4))return{sql:w.value.join(""),params:[]};if(S(w,P8))return{sql:Y(w.value),params:[]};if(w===void 0)return{sql:"",params:[]};if(Array.isArray(w)){let H=[new J4("(")];for(let[_,F]of w.entries())if(H.push(F),_<w.length-1)H.push(new J4(", "));return H.push(new J4(")")),this.buildQueryFromSourceParams(H,W)}if(S(w,p))return this.buildQueryFromSourceParams(w.queryChunks,{...W,inlineParams:J||w.shouldInlineParams});if(S(w,c)){let H=w[c.Symbol.Schema],_=w[c.Symbol.Name];return{sql:H===void 0||w[g2]?Y(_):Y(H)+"."+Y(_),params:[]}}if(S(w,B$)){let H=X.getColumnCasing(w);if(T.invokeSource==="indexes")return{sql:Y(H),params:[]};let _=w.table[c.Symbol.Schema];return{sql:w.table[g2]||_===void 0?Y(w.table[c.Symbol.Name])+"."+Y(H):Y(_)+"."+Y(w.table[c.Symbol.Name])+"."+Y(H),params:[]}}if(S(w,g4)){let H=w[C$].schema,_=w[C$].name;return{sql:H===void 0||w[C$].isAlias?Y(_):Y(H)+"."+Y(_),params:[]}}if(S(w,T6)){if(S(w.value,b1))return{sql:U(z.value++,w),params:[w],typings:["none"]};let H=w.value===null?null:w.encoder.mapToDriverValue(w.value);if(S(H,p))return this.buildQueryFromSourceParams([H],W);if(J)return{sql:this.mapInlineParam(H,W),params:[]};let _=["none"];if(G)_=[G(w.encoder)];return{sql:U(z.value++,H),params:[H],typings:_}}if(S(w,b1))return{sql:U(z.value++,w),params:[w],typings:["none"]};if(S(w,p.Aliased)&&w.fieldAlias!==void 0)return{sql:Y(w.fieldAlias),params:[]};if(S(w,G4)){if(w._.isWith)return{sql:Y(w._.alias),params:[]};return this.buildQueryFromSourceParams([new J4("("),w._.sql,new J4(") "),new P8(w._.alias)],W)}if(gQ(w)){if(w.schema)return{sql:Y(w.schema)+"."+Y(w.enumName),params:[]};return{sql:Y(w.enumName),params:[]}}if(V7(w)){if(w.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([w.getSQL()],W);return this.buildQueryFromSourceParams([new J4("("),w.getSQL(),new J4(")")],W)}if(J)return{sql:this.mapInlineParam(w,W),params:[]};return{sql:U(z.value++,w),params:[w],typings:["none"]}}))}mapInlineParam($,{escapeString:T}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return T($);if(typeof $==="object"){let W=$.toString();if(W==="[object Object]")return T(JSON.stringify($));return T(W)}throw new Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new p.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}}class P8{constructor($){this.value=$}static[Z]="Name";brand;getSQL(){return new p([this])}}function oQ($){return typeof $==="object"&&$!==null&&"mapToDriverValue"in $&&typeof $.mapToDriverValue==="function"}var lQ={mapFromDriverValue:($)=>$},rQ={mapToDriverValue:($)=>$},dd={...lQ,...rQ};class T6{constructor($,T=rQ){this.value=$,this.encoder=T}static[Z]="Param";brand;getSQL(){return new p([this])}}function O($,...T){let W=[];if(T.length>0||$.length>0&&$[0]!=="")W.push(new J4($[0]));for(let[X,Y]of T.entries())W.push(Y,new J4($[X+1]));return new p(W)}(($)=>{function T(){return new p([])}$.empty=T;function W(z){return new p(z)}$.fromList=W;function X(z){return new p([new J4(z)])}$.raw=X;function Y(z,w){let H=[];for(let[_,F]of z.entries()){if(_>0&&w!==void 0)H.push(w);H.push(F)}return new p(H)}$.join=Y;function U(z){return new P8(z)}$.identifier=U;function G(z){return new b1(z)}$.placeholder=G;function J(z,w){return new T6(z,w)}$.param=J})(O||(O={}));(($)=>{class T{constructor(W,X){this.sql=W,this.fieldAlias=X}static[Z]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new T(this.sql,this.fieldAlias)}}$.Aliased=T})(p||(p={}));class b1{constructor($){this.name=$}static[Z]="Placeholder";getSQL(){return new p([this])}}function K7($,T){return $.map((W)=>{if(S(W,b1)){if(!(W.name in T))throw new Error(`No value for placeholder "${W.name}" was provided`);return T[W.name]}if(S(W,T6)&&S(W.value,b1)){if(!(W.value.name in T))throw new Error(`No value for placeholder "${W.value.name}" was provided`);return W.encoder.mapToDriverValue(T[W.value.name])}return W})}var Tk=Symbol.for("drizzle:IsDrizzleView");class g4{static[Z]="View";[C$];[Tk]=!0;constructor({name:$,schema:T,selectedFields:W,query:X}){this[C$]={name:$,originalName:$,schema:T,selectedFields:W,query:X,isExisting:!X,isAlias:!1}}getSQL(){return new p([this])}}B$.prototype.getSQL=function(){return new p([this])};c.prototype.getSQL=function(){return new p([this])};G4.prototype.getSQL=function(){return new p([this])};class RT{constructor($){this.table=$}static[Z]="ColumnAliasProxyHandler";get($,T){if(T==="table")return this.table;return $[T]}}class m2{constructor($,T){this.alias=$,this.replaceOriginalName=T}static[Z]="TableAliasProxyHandler";get($,T){if(T===c.Symbol.IsAlias)return!0;if(T===c.Symbol.Name)return this.alias;if(this.replaceOriginalName&&T===c.Symbol.OriginalName)return this.alias;if(T===C$)return{...$[C$],name:this.alias,isAlias:!0};if(T===c.Symbol.Columns){let X=$[c.Symbol.Columns];if(!X)return X;let Y={};return Object.keys(X).map((U)=>{Y[U]=new Proxy(X[U],new RT(new Proxy($,this)))}),Y}let W=$[T];if(S(W,B$))return new Proxy(W,new RT(new Proxy($,this)));return W}}function C8($,T){return new Proxy($,new m2(T,!1))}function y6($,T){return new Proxy($,new RT(new Proxy($.table,new m2(T,!1))))}function E7($,T){return new p.Aliased(c2($.sql,T),$.fieldAlias)}function c2($,T){return O.join($.queryChunks.map((W)=>{if(S(W,B$))return y6(W,T);if(S(W,p))return c2(W,T);if(S(W,p.Aliased))return E7(W,T);return W}))}class v8 extends Error{static[Z]="DrizzleError";constructor({message:$,cause:T}){super($);this.name="DrizzleError",this.cause=T}}class M7 extends v8{static[Z]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class iQ{static[Z]="ConsoleLogWriter";write($){console.log($)}}class A7{static[Z]="DefaultLogger";writer;constructor($){this.writer=$?.writer??new iQ}logQuery($,T){let W=T.map((Y)=>{try{return JSON.stringify(Y)}catch{return String(Y)}}),X=W.length?` -- params: [${W.join(", ")}]`:"";this.writer.write(`Query: ${$}${X}`)}}class N7{static[Z]="NoopLogger";logQuery(){}}class k4{static[Z]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch($){return this.then(void 0,$)}finally($){return this.then((T)=>{return $?.(),T},(T)=>{throw $?.(),T})}then($,T){return this.execute().then($,T)}}function nQ($,T,W){let X={},Y=$.reduce((U,{path:G,field:J},z)=>{let w;if(S(J,B$))w=J;else if(S(J,p))w=J.decoder;else w=J.sql.decoder;let H=U;for(let[_,F]of G.entries())if(_<G.length-1){if(!(F in H))H[F]={};H=H[F]}else{let D=T[z],V=H[F]=D===null?null:w.mapFromDriverValue(D);if(W&&S(J,B$)&&G.length===2){let E=G[0];if(!(E in X))X[E]=V===null?F4(J.table):!1;else if(typeof X[E]==="string"&&X[E]!==F4(J.table))X[E]=!1}}return U},{});if(W&&Object.keys(X).length>0){for(let[U,G]of Object.entries(X))if(typeof G==="string"&&!W[G])Y[U]=null}return Y}function w6($,T){return Object.entries($).reduce((W,[X,Y])=>{if(typeof X!=="string")return W;let U=T?[...T,X]:[X];if(S(Y,B$)||S(Y,p)||S(Y,p.Aliased))W.push({path:U,field:Y});else if(S(Y,c))W.push(...w6(Y[c.Symbol.Columns],U));else W.push(...w6(Y,U));return W},[])}function u2($,T){let W=Object.keys($),X=Object.keys(T);if(W.length!==X.length)return!1;for(let[Y,U]of W.entries())if(U!==X[Y])return!1;return!0}function j8($,T){let W=Object.entries(T).filter(([,X])=>X!==void 0).map(([X,Y])=>{if(S(Y,p)||S(Y,B$))return[X,Y];else return[X,new T6(Y,$[c.Symbol.Columns][X])]});if(W.length===0)throw new Error("No values to set");return Object.fromEntries(W)}function tQ($,T){for(let W of T)for(let X of Object.getOwnPropertyNames(W.prototype)){if(X==="constructor")continue;Object.defineProperty($.prototype,X,Object.getOwnPropertyDescriptor(W.prototype,X)||Object.create(null))}}function aQ($){return $[c.Symbol.Columns]}function U1($){return S($,G4)?$._.alias:S($,g4)?$[C$].name:S($,p)?void 0:$[c.Symbol.IsAlias]?$[c.Symbol.Name]:$[c.Symbol.BaseName]}function D$($,T){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:T}}function sQ($){if(typeof $!=="object"||$===null)return!1;if($.constructor.name!=="Object")return!1;if("logger"in $){let T=typeof $.logger;if(T!=="boolean"&&(T!=="object"||typeof $.logger.logQuery!=="function")&&T!=="undefined")return!1;return!0}if("schema"in $){let T=typeof $.schema;if(T!=="object"&&T!=="undefined")return!1;return!0}if("casing"in $){let T=typeof $.casing;if(T!=="string"&&T!=="undefined")return!1;return!0}if("mode"in $){if($.mode!=="default"||$.mode!=="planetscale"||$.mode!==void 0)return!1;return!0}if("connection"in $){let T=typeof $.connection;if(T!=="string"&&T!=="object"&&T!=="undefined")return!1;return!0}if("client"in $){let T=typeof $.client;if(T!=="object"&&T!=="function"&&T!=="undefined")return!1;return!0}if(Object.keys($).length===0)return!0;return!1}class f1 extends d{static[Z]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity($){if($){let{name:T,...W}=$;this.config.generatedIdentity={type:"always",sequenceName:T,sequenceOptions:W}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity($){if($){let{name:T,...W}=$;this.config.generatedIdentity={type:"byDefault",sequenceName:T,sequenceOptions:W}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class eQ extends f1{static[Z]="PgBigInt53Builder";constructor($){super($,"number","PgBigInt53")}build($){return new $Z($,this.config)}}class $Z extends b{static[Z]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class TZ extends f1{static[Z]="PgBigInt64Builder";constructor($){super($,"bigint","PgBigInt64")}build($){return new WZ($,this.config)}}class WZ extends b{static[Z]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue($){return BigInt($)}}function XZ($,T){let{name:W,config:X}=D$($,T);if(X.mode==="number")return new eQ(W);return new TZ(W)}class YZ extends d{static[Z]="PgBigSerial53Builder";constructor($){super($,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new UZ($,this.config)}}class UZ extends b{static[Z]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class GZ extends d{static[Z]="PgBigSerial64Builder";constructor($){super($,"bigint","PgBigSerial64");this.config.hasDefault=!0}build($){return new JZ($,this.config)}}class JZ extends b{static[Z]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue($){return BigInt($)}}function wZ($,T){let{name:W,config:X}=D$($,T);if(X.mode==="number")return new YZ(W);return new GZ(W)}class zZ extends d{static[Z]="PgBooleanBuilder";constructor($){super($,"boolean","PgBoolean")}build($){return new _Z($,this.config)}}class _Z extends b{static[Z]="PgBoolean";getSQLType(){return"boolean"}}function p2($){return new zZ($??"")}class HZ extends d{static[Z]="PgCharBuilder";constructor($,T){super($,"string","PgChar");this.config.length=T.length,this.config.enumValues=T.enum}build($){return new FZ($,this.config)}}class FZ extends b{static[Z]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function QZ($,T={}){let{name:W,config:X}=D$($,T);return new HZ(W,X)}class ZZ extends d{static[Z]="PgCidrBuilder";constructor($){super($,"string","PgCidr")}build($){return new DZ($,this.config)}}class DZ extends b{static[Z]="PgCidr";getSQLType(){return"cidr"}}function OZ($){return new ZZ($??"")}class VZ extends d{static[Z]="PgCustomColumnBuilder";constructor($,T,W){super($,"custom","PgCustomColumn");this.config.fieldConfig=T,this.config.customTypeParams=W}build($){return new KZ($,this.config)}}class KZ extends b{static[Z]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor($,T){super($,T);this.sqlName=T.customTypeParams.dataType(T.fieldConfig),this.mapTo=T.customTypeParams.toDriver,this.mapFrom=T.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}function EZ($){return(T,W)=>{let{name:X,config:Y}=D$(T,W);return new VZ(X,Y,$)}}class G1 extends d{static[Z]="PgDateColumnBaseBuilder";defaultNow(){return this.default(O`now()`)}}class MZ extends G1{static[Z]="PgDateBuilder";constructor($){super($,"date","PgDate")}build($){return new x8($,this.config)}}class x8 extends b{static[Z]="PgDate";getSQLType(){return"date"}mapFromDriverValue($){return new Date($)}mapToDriverValue($){return $.toISOString()}}class AZ extends G1{static[Z]="PgDateStringBuilder";constructor($){super($,"string","PgDateString")}build($){return new b8($,this.config)}}class b8 extends b{static[Z]="PgDateString";getSQLType(){return"date"}}function NZ($,T){let{name:W,config:X}=D$($,T);if(X?.mode==="date")return new MZ(W);return new AZ(W)}class LZ extends d{static[Z]="PgDoublePrecisionBuilder";constructor($){super($,"number","PgDoublePrecision")}build($){return new SZ($,this.config)}}class SZ extends b{static[Z]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue($){if(typeof $==="string")return Number.parseFloat($);return $}}function BZ($){return new LZ($??"")}class RZ extends d{static[Z]="PgInetBuilder";constructor($){super($,"string","PgInet")}build($){return new IZ($,this.config)}}class IZ extends b{static[Z]="PgInet";getSQLType(){return"inet"}}function kZ($){return new RZ($??"")}class qZ extends f1{static[Z]="PgIntegerBuilder";constructor($){super($,"number","PgInteger")}build($){return new PZ($,this.config)}}class PZ extends b{static[Z]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue($){if(typeof $==="string")return Number.parseInt($);return $}}function d2($){return new qZ($??"")}class CZ extends d{static[Z]="PgIntervalBuilder";constructor($,T){super($,"string","PgInterval");this.config.intervalConfig=T}build($){return new vZ($,this.config)}}class vZ extends b{static[Z]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let $=this.fields?` ${this.fields}`:"",T=this.precision?`(${this.precision})`:"";return`interval${$}${T}`}}function jZ($,T={}){let{name:W,config:X}=D$($,T);return new CZ(W,X)}class xZ extends d{static[Z]="PgJsonBuilder";constructor($){super($,"json","PgJson")}build($){return new f8($,this.config)}}class f8 extends b{static[Z]="PgJson";constructor($,T){super($,T)}getSQLType(){return"json"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function bZ($){return new xZ($??"")}class fZ extends d{static[Z]="PgJsonbBuilder";constructor($){super($,"json","PgJsonb")}build($){return new y8($,this.config)}}class y8 extends b{static[Z]="PgJsonb";constructor($,T){super($,T)}getSQLType(){return"jsonb"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function yZ($){return new fZ($??"")}class hZ extends d{static[Z]="PgLineBuilder";constructor($){super($,"array","PgLine")}build($){return new gZ($,this.config)}}class gZ extends b{static[Z]="PgLine";getSQLType(){return"line"}mapFromDriverValue($){let[T,W,X]=$.slice(1,-1).split(",");return[Number.parseFloat(T),Number.parseFloat(W),Number.parseFloat(X)]}mapToDriverValue($){return`{${$[0]},${$[1]},${$[2]}}`}}class mZ extends d{static[Z]="PgLineABCBuilder";constructor($){super($,"json","PgLineABC")}build($){return new cZ($,this.config)}}class cZ extends b{static[Z]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue($){let[T,W,X]=$.slice(1,-1).split(",");return{a:Number.parseFloat(T),b:Number.parseFloat(W),c:Number.parseFloat(X)}}mapToDriverValue($){return`{${$.a},${$.b},${$.c}}`}}function uZ($,T){let{name:W,config:X}=D$($,T);if(!X?.mode||X.mode==="tuple")return new hZ(W);return new mZ(W)}class pZ extends d{static[Z]="PgMacaddrBuilder";constructor($){super($,"string","PgMacaddr")}build($){return new dZ($,this.config)}}class dZ extends b{static[Z]="PgMacaddr";getSQLType(){return"macaddr"}}function oZ($){return new pZ($??"")}class lZ extends d{static[Z]="PgMacaddr8Builder";constructor($){super($,"string","PgMacaddr8")}build($){return new rZ($,this.config)}}class rZ extends b{static[Z]="PgMacaddr8";getSQLType(){return"macaddr8"}}function iZ($){return new lZ($??"")}class nZ extends d{static[Z]="PgNumericBuilder";constructor($,T,W){super($,"string","PgNumeric");this.config.precision=T,this.config.scale=W}build($){return new h8($,this.config)}}class h8 extends b{static[Z]="PgNumeric";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class tZ extends d{static[Z]="PgNumericNumberBuilder";constructor($,T,W){super($,"number","PgNumericNumber");this.config.precision=T,this.config.scale=W}build($){return new aZ($,this.config)}}class aZ extends b{static[Z]="PgNumericNumber";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class sZ extends d{static[Z]="PgNumericBigIntBuilder";constructor($,T,W){super($,"bigint","PgNumericBigInt");this.config.precision=T,this.config.scale=W}build($){return new eZ($,this.config)}}class eZ extends b{static[Z]="PgNumericBigInt";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}function $D($,T){let{name:W,config:X}=D$($,T),Y=X?.mode;return Y==="number"?new tZ(W,X?.precision,X?.scale):Y==="bigint"?new sZ(W,X?.precision,X?.scale):new nZ(W,X?.precision,X?.scale)}class TD extends d{static[Z]="PgPointTupleBuilder";constructor($){super($,"array","PgPointTuple")}build($){return new WD($,this.config)}}class WD extends b{static[Z]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[T,W]=$.slice(1,-1).split(",");return[Number.parseFloat(T),Number.parseFloat(W)]}return[$.x,$.y]}mapToDriverValue($){return`(${$[0]},${$[1]})`}}class XD extends d{static[Z]="PgPointObjectBuilder";constructor($){super($,"json","PgPointObject")}build($){return new YD($,this.config)}}class YD extends b{static[Z]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[T,W]=$.slice(1,-1).split(",");return{x:Number.parseFloat(T),y:Number.parseFloat(W)}}return $}mapToDriverValue($){return`(${$.x},${$.y})`}}function UD($,T){let{name:W,config:X}=D$($,T);if(!X?.mode||X.mode==="tuple")return new TD(W);return new XD(W)}function Wk($){let T=[];for(let W=0;W<$.length;W+=2)T.push(Number.parseInt($.slice(W,W+2),16));return new Uint8Array(T)}function GD($,T){let W=new ArrayBuffer(8),X=new DataView(W);for(let Y=0;Y<8;Y++)X.setUint8(Y,$[T+Y]);return X.getFloat64(0,!0)}function L7($){let T=Wk($),W=0,X=T[W];W+=1;let Y=new DataView(T.buffer),U=Y.getUint32(W,X===1);W+=4;let G;if(U&536870912)G=Y.getUint32(W,X===1),W+=4;if((U&65535)===1){let J=GD(T,W);W+=8;let z=GD(T,W);return W+=8,[J,z]}throw new Error("Unsupported geometry type")}class JD extends d{static[Z]="PgGeometryBuilder";constructor($){super($,"array","PgGeometry")}build($){return new wD($,this.config)}}class wD extends b{static[Z]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue($){return L7($)}mapToDriverValue($){return`point(${$[0]} ${$[1]})`}}class zD extends d{static[Z]="PgGeometryObjectBuilder";constructor($){super($,"json","PgGeometryObject")}build($){return new _D($,this.config)}}class _D extends b{static[Z]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue($){let T=L7($);return{x:T[0],y:T[1]}}mapToDriverValue($){return`point(${$.x} ${$.y})`}}function HD($,T){let{name:W,config:X}=D$($,T);if(!X?.mode||X.mode==="tuple")return new JD(W);return new zD(W)}class FD extends d{static[Z]="PgRealBuilder";constructor($,T){super($,"number","PgReal");this.config.length=T}build($){return new QD($,this.config)}}class QD extends b{static[Z]="PgReal";constructor($,T){super($,T)}getSQLType(){return"real"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number.parseFloat($);return $}}function ZD($){return new FD($??"")}class DD extends d{static[Z]="PgSerialBuilder";constructor($){super($,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new OD($,this.config)}}class OD extends b{static[Z]="PgSerial";getSQLType(){return"serial"}}function VD($){return new DD($??"")}class KD extends f1{static[Z]="PgSmallIntBuilder";constructor($){super($,"number","PgSmallInt")}build($){return new ED($,this.config)}}class ED extends b{static[Z]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number($);return $}}function MD($){return new KD($??"")}class AD extends d{static[Z]="PgSmallSerialBuilder";constructor($){super($,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new ND($,this.config)}}class ND extends b{static[Z]="PgSmallSerial";getSQLType(){return"smallserial"}}function LD($){return new AD($??"")}class SD extends d{static[Z]="PgTextBuilder";constructor($,T){super($,"string","PgText");this.config.enumValues=T.enum}build($){return new BD($,this.config)}}class BD extends b{static[Z]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function RD($,T={}){let{name:W,config:X}=D$($,T);return new SD(W,X)}class ID extends G1{constructor($,T,W){super($,"string","PgTime");this.withTimezone=T,this.precision=W,this.config.withTimezone=T,this.config.precision=W}static[Z]="PgTimeBuilder";build($){return new g8($,this.config)}}class g8 extends b{static[Z]="PgTime";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function kD($,T={}){let{name:W,config:X}=D$($,T);return new ID(W,X.withTimezone??!1,X.precision)}class qD extends G1{static[Z]="PgTimestampBuilder";constructor($,T,W){super($,"date","PgTimestamp");this.config.withTimezone=T,this.config.precision=W}build($){return new m8($,this.config)}}class m8 extends b{static[Z]="PgTimestamp";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=($)=>{return new Date(this.withTimezone?$:$+"+0000")};mapToDriverValue=($)=>{return $.toISOString()}}class PD extends G1{static[Z]="PgTimestampStringBuilder";constructor($,T,W){super($,"string","PgTimestampString");this.config.withTimezone=T,this.config.precision=W}build($){return new c8($,this.config)}}class c8 extends b{static[Z]="PgTimestampString";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function N6($,T={}){let{name:W,config:X}=D$($,T);if(X?.mode==="string")return new PD(W,X.withTimezone??!1,X.precision);return new qD(W,X?.withTimezone??!1,X?.precision)}class CD extends d{static[Z]="PgUUIDBuilder";constructor($){super($,"string","PgUUID")}defaultRandom(){return this.default(O`gen_random_uuid()`)}build($){return new u8($,this.config)}}class u8 extends b{static[Z]="PgUUID";getSQLType(){return"uuid"}}function z6($){return new CD($??"")}class vD extends d{static[Z]="PgVarcharBuilder";constructor($,T){super($,"string","PgVarchar");this.config.length=T.length,this.config.enumValues=T.enum}build($){return new jD($,this.config)}}class jD extends b{static[Z]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function q4($,T={}){let{name:W,config:X}=D$($,T);return new vD(W,X)}class xD extends d{static[Z]="PgBinaryVectorBuilder";constructor($,T){super($,"string","PgBinaryVector");this.config.dimensions=T.dimensions}build($){return new bD($,this.config)}}class bD extends b{static[Z]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function fD($,T){let{name:W,config:X}=D$($,T);return new xD(W,X)}class yD extends d{static[Z]="PgHalfVectorBuilder";constructor($,T){super($,"array","PgHalfVector");this.config.dimensions=T.dimensions}build($){return new hD($,this.config)}}class hD extends b{static[Z]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((T)=>Number.parseFloat(T))}}function gD($,T){let{name:W,config:X}=D$($,T);return new yD(W,X)}class mD extends d{static[Z]="PgSparseVectorBuilder";constructor($,T){super($,"string","PgSparseVector");this.config.dimensions=T.dimensions}build($){return new cD($,this.config)}}class cD extends b{static[Z]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function uD($,T){let{name:W,config:X}=D$($,T);return new mD(W,X)}class pD extends d{static[Z]="PgVectorBuilder";constructor($,T){super($,"array","PgVector");this.config.dimensions=T.dimensions}build($){return new dD($,this.config)}}class dD extends b{static[Z]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((T)=>Number.parseFloat(T))}}function oD($,T){let{name:W,config:X}=D$($,T);return new pD(W,X)}function lD(){return{bigint:XZ,bigserial:wZ,boolean:p2,char:QZ,cidr:OZ,customType:EZ,date:NZ,doublePrecision:BZ,inet:kZ,integer:d2,interval:jZ,json:bZ,jsonb:yZ,line:uZ,macaddr:oZ,macaddr8:iZ,numeric:$D,point:UD,geometry:HD,real:ZD,serial:VD,smallint:MD,smallserial:LD,text:RD,time:kD,timestamp:N6,uuid:z6,varchar:q4,bit:fD,halfvec:gD,sparsevec:uD,vector:oD}}var S7=Symbol.for("drizzle:PgInlineForeignKeys"),rD=Symbol.for("drizzle:EnableRLS");class O4 extends c{static[Z]="PgTable";static Symbol=Object.assign({},c.Symbol,{InlineForeignKeys:S7,EnableRLS:rD});[S7]=[];[rD]=!1;[c.Symbol.ExtraConfigBuilder]=void 0;[c.Symbol.ExtraConfigColumns]={}}function Xk($,T,W,X,Y=$){let U=new O4($,X,Y),G=typeof T==="function"?T(lD()):T,J=Object.fromEntries(Object.entries(G).map(([H,_])=>{let F=_;F.setName(H);let D=F.build(U);return U[S7].push(...F.buildForeignKeys(D,U)),[H,D]})),z=Object.fromEntries(Object.entries(G).map(([H,_])=>{let F=_;F.setName(H);let D=F.buildExtraConfigColumn(U);return[H,D]})),w=Object.assign(U,J);if(w[c.Symbol.Columns]=J,w[c.Symbol.ExtraConfigColumns]=z,W)w[O4.Symbol.ExtraConfigBuilder]=W;return Object.assign(w,{enableRLS:()=>{return w[O4.Symbol.EnableRLS]=!0,w}})}var y1=($,T,W)=>{return Xk($,T,W,void 0)};function iD(...$){if($[0].columns)return new o2($[0].columns,$[0].name);return new o2($)}class o2{static[Z]="PgPrimaryKeyBuilder";columns;name;constructor($,T){this.columns=$,this.name=T}build($){return new nD($,this.columns,this.name)}}class nD{constructor($,T,W){this.table=$,this.columns=T,this.name=W}static[Z]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[O4.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}function m4($,T){if(oQ(T)&&!V7($)&&!S($,T6)&&!S($,b1)&&!S($,B$)&&!S($,c)&&!S($,g4))return new T6($,T);return $}var p8=($,T)=>{return O`${$} = ${m4(T,$)}`},tD=($,T)=>{return O`${$} <> ${m4(T,$)}`};function l2(...$){let T=$.filter((W)=>W!==void 0);if(T.length===0)return;if(T.length===1)return new p(T);return new p([new J4("("),O.join(T,new J4(" and ")),new J4(")")])}function aD(...$){let T=$.filter((W)=>W!==void 0);if(T.length===0)return;if(T.length===1)return new p(T);return new p([new J4("("),O.join(T,new J4(" or ")),new J4(")")])}function sD($){return O`not ${$}`}var d8=($,T)=>{return O`${$} > ${m4(T,$)}`},eD=($,T)=>{return O`${$} >= ${m4(T,$)}`},$O=($,T)=>{return O`${$} < ${m4(T,$)}`},TO=($,T)=>{return O`${$} <= ${m4(T,$)}`};function WO($,T){if(Array.isArray(T)){if(T.length===0)return O`false`;return O`${$} in ${T.map((W)=>m4(W,$))}`}return O`${$} in ${m4(T,$)}`}function XO($,T){if(Array.isArray(T)){if(T.length===0)return O`true`;return O`${$} not in ${T.map((W)=>m4(W,$))}`}return O`${$} not in ${m4(T,$)}`}function YO($){return O`${$} is null`}function UO($){return O`${$} is not null`}function GO($){return O`exists ${$}`}function JO($){return O`not exists ${$}`}function wO($,T,W){return O`${$} between ${m4(T,$)} and ${m4(W,$)}`}function zO($,T,W){return O`${$} not between ${m4(T,$)} and ${m4(W,$)}`}function _O($,T){return O`${$} like ${T}`}function HO($,T){return O`${$} not like ${T}`}function FO($,T){return O`${$} ilike ${T}`}function QO($,T){return O`${$} not ilike ${T}`}function ZO($){return O`${$} asc`}function DO($){return O`${$} desc`}class B7{constructor($,T,W){this.sourceTable=$,this.referencedTable=T,this.relationName=W,this.referencedTableName=T[c.Symbol.Name]}static[Z]="Relation";referencedTableName;fieldName}class OO{constructor($,T){this.table=$,this.config=T}static[Z]="Relations"}class h1 extends B7{constructor($,T,W,X){super($,T,W?.relationName);this.config=W,this.isNullable=X}static[Z]="One";withFieldName($){let T=new h1(this.sourceTable,this.referencedTable,this.config,this.isNullable);return T.fieldName=$,T}}class r2 extends B7{constructor($,T,W){super($,T,W?.relationName);this.config=W}static[Z]="Many";withFieldName($){let T=new r2(this.sourceTable,this.referencedTable,this.config);return T.fieldName=$,T}}function VO(){return{and:l2,between:wO,eq:p8,exists:GO,gt:d8,gte:eD,ilike:FO,inArray:WO,isNull:YO,isNotNull:UO,like:_O,lt:$O,lte:TO,ne:tD,not:sD,notBetween:zO,notExists:JO,notLike:HO,notIlike:QO,notInArray:XO,or:aD,sql:O}}function KO(){return{sql:O,asc:ZO,desc:DO}}function EO($,T){if(Object.keys($).length===1&&"default"in $&&!S($.default,c))$=$.default;let W={},X={},Y={};for(let[U,G]of Object.entries($))if(S(G,c)){let J=R0(G),z=X[J];W[J]=U,Y[U]={tsName:U,dbName:G[c.Symbol.Name],schema:G[c.Symbol.Schema],columns:G[c.Symbol.Columns],relations:z?.relations??{},primaryKey:z?.primaryKey??[]};for(let H of Object.values(G[c.Symbol.Columns]))if(H.primary)Y[U].primaryKey.push(H);let w=G[c.Symbol.ExtraConfigBuilder]?.(G[c.Symbol.ExtraConfigColumns]);if(w){for(let H of Object.values(w))if(S(H,o2))Y[U].primaryKey.push(...H.columns)}}else if(S(G,OO)){let J=R0(G.table),z=W[J],w=G.config(T(G.table)),H;for(let[_,F]of Object.entries(w))if(z){let D=Y[z];if(D.relations[_]=F,H)D.primaryKey.push(...H)}else{if(!(J in X))X[J]={relations:{},primaryKey:H};X[J].relations[_]=F}}return{tables:Y,tableNamesMap:W}}function Yk($){return function T(W,X){return new h1($,W,X,X?.fields.reduce((Y,U)=>Y&&U.notNull,!0)??!1)}}function Uk($){return function T(W,X){return new r2($,W,X)}}function MO($,T,W){if(S(W,h1)&&W.config)return{fields:W.config.fields,references:W.config.references};let X=T[R0(W.referencedTable)];if(!X)throw new Error(`Table "${W.referencedTable[c.Symbol.Name]}" not found in schema`);let Y=$[X];if(!Y)throw new Error(`Table "${X}" not found in schema`);let U=W.sourceTable,G=T[R0(U)];if(!G)throw new Error(`Table "${U[c.Symbol.Name]}" not found in schema`);let J=[];for(let z of Object.values(Y.relations))if(W.relationName&&W!==z&&z.relationName===W.relationName||!W.relationName&&z.referencedTable===W.sourceTable)J.push(z);if(J.length>1)throw W.relationName?new Error(`There are multiple relations with name "${W.relationName}" in table "${X}"`):new Error(`There are multiple relations between "${X}" and "${W.sourceTable[c.Symbol.Name]}". Please specify relation name`);if(J[0]&&S(J[0],h1)&&J[0].config)return{fields:J[0].config.references,references:J[0].config.fields};throw new Error(`There is not enough information to infer relation "${G}.${W.fieldName}"`)}function AO($){return{one:Yk($),many:Uk($)}}function o8($,T,W,X,Y=(U)=>U){let U={};for(let[G,J]of X.entries())if(J.isJson){let z=T.relations[J.tsKey],w=W[G],H=typeof w==="string"?JSON.parse(w):w;U[J.tsKey]=S(z,h1)?H&&o8($,$[J.relationTableTsKey],H,J.selection,Y):H.map((_)=>o8($,$[J.relationTableTsKey],_,J.selection,Y))}else{let z=Y(W[G]),w=J.field,H;if(S(w,B$))H=w;else if(S(w,p))H=w.decoder;else H=w.sql.decoder;U[J.tsKey]=z===null?null:H.mapFromDriverValue(z)}return U}import iv from"path";import qk from"os";import Pk from"fs";var l8=new Map,R7=new Map,I7=Symbol("OriginError"),IT={};class _6 extends Promise{constructor($,T,W,X,Y={}){let U,G;super((J,z)=>{U=J,G=z});this.tagged=Array.isArray($.raw),this.strings=$,this.args=T,this.handler=W,this.canceller=X,this.options=Y,this.state=null,this.statement=null,this.resolve=(J)=>(this.active=!1,U(J)),this.reject=(J)=>(this.active=!1,G(J)),this.active=!1,this.cancelled=null,this.executed=!1,this.signature="",this[I7]=this.handler.debug?new Error:this.tagged&&Gk(this.strings)}get origin(){return(this.handler.debug?this[I7].stack:this.tagged&&R7.has(this.strings)?R7.get(this.strings):R7.set(this.strings,this[I7].stack).get(this.strings))||""}static get[Symbol.species](){return Promise}cancel(){return this.canceller&&(this.canceller(this),this.canceller=null)}simple(){return this.options.simple=!0,this.options.prepare=!1,this}async readable(){return this.simple(),this.streaming=!0,this}async writable(){return this.simple(),this.streaming=!0,this}cursor($=1,T){if(this.options.simple=!1,typeof $==="function")T=$,$=1;if(this.cursorRows=$,typeof T==="function")return this.cursorFn=T,this;let W;return{[Symbol.asyncIterator]:()=>({next:()=>{if(this.executed&&!this.active)return{done:!0};W&&W();let X=new Promise((Y,U)=>{this.cursorFn=(G)=>{return Y({value:G,done:!1}),new Promise((J)=>W=J)},this.resolve=()=>(this.active=!1,Y({done:!0})),this.reject=(G)=>(this.active=!1,U(G))});return this.execute(),X},return(){return W&&W(IT),{done:!0}}})}}describe(){return this.options.simple=!1,this.onlyDescribe=this.options.prepare=!0,this}stream(){throw new Error(".stream has been renamed to .forEach")}forEach($){return this.forEachFn=$,this.handle(),this}raw(){return this.isRaw=!0,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=!0)&&await 1&&this.handler(this)}execute(){return this.handle(),this}then(){return this.handle(),super.then.apply(this,arguments)}catch(){return this.handle(),super.catch.apply(this,arguments)}finally(){return this.handle(),super.finally.apply(this,arguments)}}function Gk($){if(l8.has($))return l8.get($);let T=Error.stackTraceLimit;return Error.stackTraceLimit=4,l8.set($,new Error),Error.stackTraceLimit=T,l8.get($)}class kT extends Error{constructor($){super($.message);this.name=this.constructor.name,Object.assign(this,$)}}var a$={connection:NO,postgres:LO,generic:SO,notSupported:BO};function NO($,T,W){let{host:X,port:Y}=W||T,U=Object.assign(new Error("write "+$+" "+(T.path||X+":"+Y)),{code:$,errno:$,address:T.path||X},T.path?{}:{port:Y});return Error.captureStackTrace(U,NO),U}function LO($){let T=new kT($);return Error.captureStackTrace(T,LO),T}function SO($,T){let W=Object.assign(new Error($+": "+T),{code:$});return Error.captureStackTrace(W,SO),W}function BO($){let T=Object.assign(new Error($+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:$});return Error.captureStackTrace(T,BO),T}var Jk={string:{to:25,from:null,serialize:($)=>""+$},number:{to:0,from:[21,23,26,700,701],serialize:($)=>""+$,parse:($)=>+$},json:{to:114,from:[114,3802],serialize:($)=>JSON.stringify($),parse:($)=>JSON.parse($)},boolean:{to:16,from:16,serialize:($)=>$===!0?"t":"f",parse:($)=>$==="t"},date:{to:1184,from:[1082,1114,1184],serialize:($)=>($ instanceof Date?$:new Date($)).toISOString(),parse:($)=>new Date($)},bytea:{to:17,from:17,serialize:($)=>"\\x"+Buffer.from($).toString("hex"),parse:($)=>Buffer.from($.slice(2),"hex")}};class n8{then(){k7()}catch(){k7()}finally(){k7()}}class a2 extends n8{constructor($){super();this.value=s8($)}}class h6 extends n8{constructor($,T,W){super();this.value=$,this.type=T,this.array=W}}class t8 extends n8{constructor($,T){super();this.first=$,this.rest=T}build($,T,W,X){let Y=wk.map(([U,G])=>({fn:G,i:$.search(U)})).sort((U,G)=>U.i-G.i).pop();return Y.i===-1?j7(this.first,X):Y.fn(this.first,this.rest,T,W,X)}}function a8($,T,W,X){let Y=$ instanceof h6?$.value:$;if(Y===void 0){if($ instanceof h6?$.value=X.transform.undefined:Y=$=X.transform.undefined,Y===void 0)throw a$.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return"$"+W.push($ instanceof h6?(T.push($.value),$.array?$.array[$.type||i8($.value)]||$.type||qO($.value):$.type):(T.push($),i8($)))}var IO=CO(Jk);function C7($,T,W,X,Y,U){for(let G=1;G<$.strings.length;G++)T+=v7(T,W,X,Y,U)+$.strings[G],W=$.args[G];return T}function v7($,T,W,X,Y){return T instanceof t8?T.build($,W,X,Y):T instanceof _6?P7(T,W,X,Y):T instanceof a2?T.value:T&&T[0]instanceof _6?T.reduce((U,G)=>U+" "+P7(G,W,X,Y),""):a8(T,W,X,Y)}function P7($,T,W,X){return $.fragment=!0,C7($,$.strings[0],$.args[0],T,W,X)}function kO($,T,W,X,Y){return $.map((U)=>"("+X.map((G)=>v7("values",U[G],T,W,Y)).join(",")+")").join(",")}function RO($,T,W,X,Y){let U=Array.isArray($[0]),G=T.length?T.flat():Object.keys(U?$[0]:$);return kO(U?$:[$],W,X,G,Y)}function r8($,T,W,X,Y){if(typeof $==="string"&&($=[$].concat(T)),Array.isArray($))return j7($,Y);let U;return(T.length?T.flat():Object.keys($)).map((J)=>{return U=$[J],(U instanceof _6?P7(U,W,X,Y):U instanceof a2?U.value:a8(U,W,X,Y))+" as "+s8(Y.transform.column.to?Y.transform.column.to(J):J)}).join(",")}var wk=Object.entries({values:RO,in:(...$)=>{let T=RO(...$);return T==="()"?"(null)":T},select:r8,as:r8,returning:r8,"\\(":r8,update($,T,W,X,Y){return(T.length?T.flat():Object.keys($)).map((U)=>s8(Y.transform.column.to?Y.transform.column.to(U):U)+"="+v7("values",$[U],W,X,Y))},insert($,T,W,X,Y){let U=T.length?T.flat():Object.keys(Array.isArray($)?$[0]:$);return"("+j7(U,Y)+")values"+kO(Array.isArray($)?$:[$],W,X,U,Y)}}).map(([$,T])=>[new RegExp("((?:^|[\\s(])"+$+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),T]);function k7(){throw a$.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var{serializers:zk,parsers:_k}=IO;function qO($){if(Array.isArray($))return qO($[0]);return typeof $==="string"?1009:0}var PO=function($){let T=CO($||{});return{serializers:Object.assign({},zk,T.serializers),parsers:Object.assign({},_k,T.parsers)}};function CO($){return Object.keys($).reduce((T,W)=>{if($[W].from&&[].concat($[W].from).forEach((X)=>T.parsers[X]=$[W].parse),$[W].serialize)T.serializers[$[W].to]=$[W].serialize,$[W].from&&[].concat($[W].from).forEach((X)=>T.serializers[X]=$[W].serialize);return T},{parsers:{},serializers:{}})}function j7($,{transform:{column:T}}){return $.map((W)=>s8(T.to?T.to(W):W)).join(",")}var s8=function $(T){return'"'+T.replace(/"/g,'""').replace(/\./g,'"."')+'"'},i8=function $(T){return T instanceof h6?T.type:T instanceof Date?1184:T instanceof Uint8Array?17:T===!0||T===!1?16:typeof T==="bigint"?20:Array.isArray(T)?$(T[0]):0},Hk=/\\/g,Fk=/"/g;function Qk($){return $.replace(Hk,"\\\\").replace(Fk,"\\\"")}var vO=function $(T,W,X,Y){if(Array.isArray(T)===!1)return T;if(!T.length)return"{}";let U=T[0],G=Y===1020?";":",";if(Array.isArray(U)&&!U.type)return"{"+T.map((J)=>$(J,W,X,Y)).join(G)+"}";return"{"+T.map((J)=>{if(J===void 0){if(J=X.transform.undefined,J===void 0)throw a$.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return J===null?"null":'"'+Qk(W?W(J.type?J.value:J):""+J)+'"'}).join(G)+"}"},q7={i:0,char:null,str:"",quoted:!1,last:0},jO=function $(T,W,X){return q7.i=q7.last=0,xO(q7,T,W,X)};function xO($,T,W,X){let Y=[],U=X===1020?";":",";for(;$.i<T.length;$.i++){if($.char=T[$.i],$.quoted)if($.char==="\\")$.str+=T[++$.i];else if($.char==='"')Y.push(W?W($.str):$.str),$.str="",$.quoted=T[$.i+1]==='"',$.last=$.i+2;else $.str+=$.char;else if($.char==='"')$.quoted=!0;else if($.char==="{")$.last=++$.i,Y.push(xO($,T,W,X));else if($.char==="}"){$.quoted=!1,$.last<$.i&&Y.push(W?W(T.slice($.last,$.i)):T.slice($.last,$.i)),$.last=$.i+1;break}else if($.char===U&&$.p!=="}"&&$.p!=='"')Y.push(W?W(T.slice($.last,$.i)):T.slice($.last,$.i)),$.last=$.i+1;$.p=$.char}return $.last<$.i&&Y.push(W?W(T.slice($.last,$.i+1)):T.slice($.last,$.i+1)),Y}var I0=($)=>{let T=$[0];for(let W=1;W<$.length;W++)T+=$[W]==="_"?$[++W].toUpperCase():$[W];return T},k0=($)=>{let T=$[0].toUpperCase();for(let W=1;W<$.length;W++)T+=$[W]==="_"?$[++W].toUpperCase():$[W];return T},q0=($)=>$.replace(/_/g,"-"),i2=($)=>$.replace(/([A-Z])/g,"_$1").toLowerCase(),n2=($)=>($.slice(0,1)+$.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),t2=($)=>$.replace(/-/g,"_");function x7($){return function T(W,X){return typeof W==="object"&&W!==null&&(X.type===114||X.type===3802)?Array.isArray(W)?W.map((Y)=>T(Y,X)):Object.entries(W).reduce((Y,[U,G])=>Object.assign(Y,{[$(U)]:T(G,X)}),{}):W}}I0.column={from:I0};I0.value={from:x7(I0)};i2.column={to:i2};var b7={...I0};b7.column.to=i2;k0.column={from:k0};k0.value={from:x7(k0)};n2.column={to:n2};var f7={...k0};f7.column.to=n2;q0.column={from:q0};q0.value={from:x7(q0)};t2.column={to:t2};var y7={...q0};y7.column.to=t2;import bO from"net";import Vk from"tls";import s2 from"crypto";import h7 from"stream";import{performance as fO}from"perf_hooks";class P0 extends Array{constructor(){super();Object.defineProperties(this,{count:{value:null,writable:!0},state:{value:null,writable:!0},command:{value:null,writable:!0},columns:{value:null,writable:!0},statement:{value:null,writable:!0}})}static get[Symbol.species](){return Array}}var W6=Zk;function Zk($=[]){let T=$.slice(),W=0;return{get length(){return T.length-W},remove:(X)=>{let Y=T.indexOf(X);return Y===-1?null:(T.splice(Y,1),X)},push:(X)=>(T.push(X),X),shift:()=>{let X=T[W++];if(W===T.length)W=0,T=[];else T[W-1]=void 0;return X}}}var N4=Buffer.allocUnsafe(256),Dk="BCcDdEFfHPpQSX".split("").reduce(($,T)=>{let W=T.charCodeAt(0);return $[T]=()=>{return N4[0]=W,S$.i=5,S$},$},{}),S$=Object.assign(Ok,Dk,{N:String.fromCharCode(0),i:0,inc($){return S$.i+=$,S$},str($){let T=Buffer.byteLength($);return e8(T),S$.i+=N4.write($,S$.i,T,"utf8"),S$},i16($){return e8(2),N4.writeUInt16BE($,S$.i),S$.i+=2,S$},i32($,T){if(T||T===0)return N4.writeUInt32BE($,T),S$;return e8(4),N4.writeUInt32BE($,S$.i),S$.i+=4,S$},z($){return e8($),N4.fill(0,S$.i,S$.i+$),S$.i+=$,S$},raw($){return N4=Buffer.concat([N4.subarray(0,S$.i),$]),S$.i=N4.length,S$},end($=1){N4.writeUInt32BE(S$.i-$,$);let T=N4.subarray(0,S$.i);return S$.i=0,N4=Buffer.allocUnsafe(256),T}}),i=S$;function e8($){if(N4.length-S$.i<$){let T=N4,W=T.length;N4=Buffer.allocUnsafe(W+(W>>1)+$),T.copy(N4)}}function Ok(){return S$.i=0,S$}var c7=gO,Kk=1,g1=i().S().end(),yO=i().H().end(),Ek=i().i32(8).i32(80877103).end(8),Mk=Buffer.concat([i().E().str(i.N).i32(0).end(),g1]),Ak=i().D().str("S").str(i.N).end(),qT=()=>{},Nk=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),Lk={83:"severity_local",86:"severity",67:"code",77:"message",68:"detail",72:"hint",80:"position",112:"internal_position",113:"internal_query",87:"where",115:"schema_name",116:"table_name",99:"column_name",100:"data type_name",110:"constraint_name",70:"file",76:"line",82:"routine"};function gO($,T={},{onopen:W=qT,onend:X=qT,onclose:Y=qT}={}){let{ssl:U,max:G,user:J,host:z,port:w,database:H,parsers:_,transform:F,onnotice:D,onnotify:V,onparameter:E,max_pipeline:R,keep_alive:P,backoff:A,target_session_attrs:N}=$,k=W6(),y=Kk++,x={pid:null,secret:null},m=m7(uU,$.idle_timeout),J$=m7(uU,$.max_lifetime),m$=m7(SM,$.connect_timeout),B=null,Z$,$$=new P0,H$=Buffer.alloc(0),e$=$.fetch_types,V4={},D6={},g0=Math.random().toString(36).slice(2),v=1,e=0,M$=0,g$=0,$4=0,w$=0,A$=0,i$=0,c$=null,x$=null,K4=!1,k$=null,O6=null,Q4=null,K1=null,T4=null,b$=null,V6=null,k6=null,h=null,sT=null,E4={queue:T.closed,idleTimer:m,connect(Q){Q4=Q,v5()},terminate:$W,execute:eT,cancel:MM,end:uU,count:0,id:y};return T.closed&&T.closed.push(E4),E4;async function EM(){let Q;try{Q=$.socket?await Promise.resolve($.socket($)):new bO.Socket}catch(M){c0(M);return}return Q.on("error",c0),Q.on("close",j5),Q.on("drain",P5),Q}async function MM({pid:Q,secret:M},t,V$){try{Z$=i().i32(16).i32(80877102).i32(Q).i32(M).end(16),await C5(),B.once("error",V$),B.once("close",t)}catch(o$){V$(o$)}}function eT(Q){if(K4)return xX(Q,a$.connection("CONNECTION_DESTROYED",$));if(Q.cancelled)return;try{return Q.state=x,h?k.push(Q):(h=Q,h.active=!0),LM(Q),Z4(AM(Q))&&!Q.describeFirst&&!Q.cursorFn&&k.length<R&&(!Q.options.onexecute||Q.options.onexecute(E4))}catch(M){return k.length===0&&Z4(g1),q6(M),!0}}function AM(Q){if(Q.parameters.length>=65534)throw a$.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return Q.options.simple?i().Q().str(Q.statement.string+i.N).end():Q.describeFirst?Buffer.concat([I5(Q),yO]):Q.prepare?Q.prepared?jX(Q):Buffer.concat([I5(Q),jX(Q)]):NM(Q)}function I5(Q){return Buffer.concat([b5(Q.statement.string,Q.parameters,Q.statement.types,Q.statement.name),wA("S",Q.statement.name)])}function jX(Q){return Buffer.concat([JA(Q.parameters,Q.statement.types,Q.statement.name,Q.cursorName),Q.cursorFn?f5("",Q.cursorRows):Mk])}function NM(Q){return Buffer.concat([b5(Q.statement.string,Q.parameters,Q.statement.types),Ak,jX(Q)])}function LM(Q){let M=[],t=[],V$=C7(Q,Q.strings[0],Q.args[0],M,t,$);!Q.tagged&&Q.args.forEach((o$)=>a8(o$,M,t,$)),Q.prepare=$.prepare&&("prepare"in Q.options?Q.options.prepare:!0),Q.string=V$,Q.signature=Q.prepare&&t+V$,Q.onlyDescribe&&delete D6[Q.signature],Q.parameters=Q.parameters||M,Q.prepared=Q.prepare&&Q.signature in D6,Q.describeFirst=Q.onlyDescribe||M.length&&!Q.prepared,Q.statement=Q.prepared?D6[Q.signature]:{string:V$,types:t,name:Q.prepare?g0+v++:""},typeof $.debug==="function"&&$.debug(y,V$,M,t)}function Z4(Q,M){if(b$=b$?Buffer.concat([b$,Q]):Buffer.from(Q),M||b$.length>=1024)return k5(M);return x$===null&&(x$=setImmediate(k5)),!0}function k5(Q){let M=B.write(b$,Q);return x$!==null&&clearImmediate(x$),b$=x$=null,M}function SM(){q6(a$.connection("CONNECT_TIMEOUT",$,B)),B.destroy()}async function q5(){if(Z4(Ek),!await new Promise((M)=>B.once("data",(t)=>M(t[0]===83)))&&U==="prefer")return m0();B.removeAllListeners(),B=Vk.connect({socket:B,servername:bO.isIP(B.host)?void 0:B.host,...U==="require"||U==="allow"||U==="prefer"?{rejectUnauthorized:!1}:U==="verify-full"?{}:typeof U==="object"?U:{}}),B.on("secureConnect",m0),B.on("error",c0),B.on("close",j5),B.on("drain",P5)}function P5(){!h&&W(E4)}function cU(Q){if(k$){if(k$.push(Q),M$-=Q.length,M$>0)return}H$=k$?Buffer.concat(k$,w$-M$):H$.length===0?Q:Buffer.concat([H$,Q],H$.length+Q.length);while(H$.length>4){if(w$=H$.readUInt32BE(1),w$>=H$.length){M$=w$-H$.length,k$=[H$];break}try{BM(H$.subarray(0,w$+1))}catch(M){h&&(h.cursorFn||h.describeFirst)&&Z4(g1),q6(M)}H$=H$.subarray(w$+1),M$=0,k$=null}}async function C5(){if(K4=!1,V4={},B||(B=await EM()),!B)return;if(m$.start(),$.socket)return U?q5():m0();if(B.on("connect",U?q5:m0),$.path)return B.connect($.path);B.ssl=U,B.connect(w[g$],z[g$]),B.host=z[g$],B.port=w[g$],g$=(g$+1)%w.length}function v5(){setTimeout(C5,e?e+A$-fO.now():0)}function m0(){try{D6={},e$=$.fetch_types,g0=Math.random().toString(36).slice(2),v=1,J$.start(),B.on("data",cU),P&&B.setKeepAlive&&B.setKeepAlive(!0,1000*P);let Q=_A();Z4(Q)}catch(Q){c0(Q)}}function c0(Q){if(E4.queue===T.connecting&&$.host[$4+1])return;q6(Q);while(k.length)xX(k.shift(),Q)}function q6(Q){T4&&(T4.destroy(Q),T4=null),h&&xX(h,Q),Q4&&(xX(Q4,Q),Q4=null)}function xX(Q,M){if(Q.reserve)return Q.reject(M);if(!M||typeof M!=="object")M=new Error(M);"query"in M||"parameters"in M||Object.defineProperties(M,{stack:{value:M.stack+Q.origin.replace(/.*\n/,`
|
|
81
|
-
`),enumerable:$.debug},query:{value:
|
|
79
|
+
`);super({baseURL:Y.baseURL,timeout:Y.timeout??600000,httpAgent:Y.httpAgent,maxRetries:Y.maxRetries,fetch:Y.fetch});this.completions=new L2(this),this.chat=new DT(this),this.embeddings=new _2(this),this.files=new KW(this),this.images=new S2(this),this.audio=new R0(this),this.moderations=new B2(this),this.models=new MW(this),this.fineTuning=new V1(this),this.graders=new AW(this),this.vectorStores=new K1(this),this.beta=new s1(this),this.batches=new GW(this),this.uploads=new LW(this),this.responses=new NW(this),this.evals=new C0(this),this.containers=new P0(this),this._options=Y,this.apiKey=T,this.organization=W,this.project=U}defaultQuery(){return this._options.defaultQuery}defaultHeaders($){return{...super.defaultHeaders($),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project,...this._options.defaultHeaders}}authHeaders($){return{Authorization:`Bearer ${this.apiKey}`}}stringifyQuery($){return IF($,{arrayFormat:"brackets"})}}RA=D$;D$.OpenAI=RA;D$.DEFAULT_TIMEOUT=600000;D$.OpenAIError=e;D$.APIError=L4;D$.APIConnectionError=WW;D$.APIConnectionTimeoutError=UW;D$.APIUserAbortError=P4;D$.NotFoundError=MG;D$.ConflictError=NG;D$.RateLimitError=JG;D$.BadRequestError=KG;D$.AuthenticationError=EG;D$.InternalServerError=_G;D$.PermissionDeniedError=AG;D$.UnprocessableEntityError=LG;D$.toFile=rF;D$.fileFromPath=VG;D$.Completions=L2;D$.Chat=DT;D$.ChatCompletionsPage=wW;D$.Embeddings=_2;D$.Files=KW;D$.FileObjectsPage=v2;D$.Images=S2;D$.Audio=R0;D$.Moderations=B2;D$.Models=MW;D$.ModelsPage=j2;D$.FineTuning=V1;D$.Graders=AW;D$.VectorStores=K1;D$.VectorStoresPage=b2;D$.VectorStoreSearchResponsesPage=f2;D$.Beta=s1;D$.Batches=GW;D$.BatchesPage=Q2;D$.Uploads=LW;D$.Responses=NW;D$.Evals=C0;D$.EvalListResponsesPage=k2;D$.Containers=P0;D$.ContainerListResponsesPage=J2;var kA=D$;function Yb($,...T){let[W,U,X,Y]=T,w=[{role:"user",content:OE(U)},{role:"user",content:W}],G=Y.at(-1);if(G)w.push({role:"user",content:["Oops! That didn't work. Here's what was returned last time:",JSON.stringify(G.response,null,2),"Here's the error message:",JSON.stringify(G.error.issues,null,2)].join(`
|
|
80
|
+
`)});return{model:$,messages:w}}var z$=1e6,vA={"gpt-4.1":{promptPricePerToken:2/z$,promptPricePerTokenCached:0.5/z$,completionPricePerToken:8/z$},"gpt-4.1-mini":{promptPricePerToken:0.4/z$,promptPricePerTokenCached:0.1/z$,completionPricePerToken:1.6/z$},"gpt-4.1-nano":{promptPricePerToken:0.1/z$,promptPricePerTokenCached:0.025/z$,completionPricePerToken:0.4/z$},"gpt-4o":{promptPricePerToken:2.5/z$,promptPricePerTokenCached:1.25/z$,completionPricePerToken:10/z$},"gpt-4o-mini":{promptPricePerToken:0.15/z$,promptPricePerTokenCached:0.075/z$,completionPricePerToken:0.6/z$},o1:{promptPricePerToken:15/z$,promptPricePerTokenCached:7.5/z$,completionPricePerToken:60/z$},"o1-mini":{promptPricePerToken:1.1/z$,promptPricePerTokenCached:0.55/z$,completionPricePerToken:4.4/z$},o3:{promptPricePerToken:10/z$,promptPricePerTokenCached:2.5/z$,completionPricePerToken:40/z$},"o3-mini":{promptPricePerToken:1.1/z$,promptPricePerTokenCached:0.55/z$,completionPricePerToken:4.4/z$},"o4-mini":{promptPricePerToken:1.1/z$,promptPricePerTokenCached:0.275/z$,completionPricePerToken:4.4/z$},"codex-mini-latest":{promptPricePerToken:1.5/z$,promptPricePerTokenCached:0.375/z$,completionPricePerToken:6/z$},"chatgpt-4o-latest":{promptPricePerToken:5/z$,promptPricePerTokenCached:5/z$,completionPricePerToken:15/z$},"gpt-4":{promptPricePerToken:30/z$,promptPricePerTokenCached:30/z$,completionPricePerToken:60/z$},"gpt-4-turbo":{promptPricePerToken:10/z$,promptPricePerTokenCached:10/z$,completionPricePerToken:30/z$},"gpt-3.5-turbo":{promptPricePerToken:0.5/z$,promptPricePerTokenCached:0.5/z$,completionPricePerToken:1.5/z$},"gpt-4-32k":{promptPricePerToken:60/z$,promptPricePerTokenCached:60/z$,completionPricePerToken:120/z$},"gpt-3.5-turbo-16k":{promptPricePerToken:3/z$,promptPricePerTokenCached:3/z$,completionPricePerToken:4/z$}};function wb($){let W=Object.keys(vA).filter((U)=>$.startsWith(U)).sort((U,X)=>X.length-U.length)[0];if(!W)return;return vA[W]}function Gb($){return async function T(W,U){if(!$)throw new Error("This is a bug in safegen. OpenAI client not available to the json generator.");let X=await $.chat.completions.create({...W,stream:!1,response_format:{type:"json_object"}},U),Y=X.choices[0].message?.content,{usage:w}=X;if(Y&&w){let G=w.prompt_tokens,H=w.prompt_tokens_details?.cached_tokens??0,z=G-H,F=w.completion_tokens,O=wb(W.model),Q=0;if(O)Q=G*O.promptPricePerToken+z*(O.promptPricePerTokenCached??0)+F*O.completionPricePerToken;else console.warn(`No pricing facts found for model ${W.model}. Giving a price of 0.`);return{data:JSON.parse(Y),usage:w,usdPrice:Q}}if(!Y&&!w)throw new Error("No content or usage found in completion");if(!Y)throw new Error("No content found in completion");throw new Error("No usage found in completion")}}var qA=new Map,PA=class{usdBudget;usdMinimum;getUnknownJsonFromOpenAi;getUnknownJsonFromOpenAiSquirreled;squirrel;client;lastUsage;constructor({model:$,usdBudget:T,usdMinimum:W,apiKey:U,cachingMode:X,cacheKey:Y="openai-safegen",logger:w}){this.usdBudget=T,this.usdMinimum=W,this.squirrel=new vE(X);let G=qA.get(U);if(X!=="read"){if(!G)G=new kA({apiKey:U,dangerouslyAllowBrowser:!1}),qA.set(U,G);this.client=G}this.getUnknownJsonFromOpenAi=Gb(this.client),this.getUnknownJsonFromOpenAiSquirreled=this.squirrel.add(Y,this.getUnknownJsonFromOpenAi),this.from=FE(async(...H)=>{if(this.usdBudget<this.usdMinimum)return w?.warn("SafeGen budget exhausted"),H[2];let z=Yb($,...H),F=H[0],O=H[3],{data:Q,usage:Z,usdPrice:V}=await this.getUnknownJsonFromOpenAiSquirreled.for(`${F.replace(/[^a-zA-Z0-9-_. ]/g,"_")}-${O.length}`).get(z);return this.lastUsage=Z,this.usdBudget-=V,Q},w)}from};import{exec as Wc}from"child_process";class K extends Array{constructor($,T){if(super($),this.sign=T,Object.setPrototypeOf(this,K.prototype),$>K.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded")}static BigInt($){var T=Math.floor,W=Number.isFinite;if(typeof $=="number"){if($===0)return K.__zero();if(K.__isOneDigitInt($))return 0>$?K.__oneDigit(-$,!0):K.__oneDigit($,!1);if(!W($)||T($)!==$)throw new RangeError("The number "+$+" cannot be converted to BigInt because it is not an integer");return K.__fromDouble($)}if(typeof $=="string"){let U=K.__fromString($);if(U===null)throw new SyntaxError("Cannot convert "+$+" to a BigInt");return U}if(typeof $=="boolean")return $===!0?K.__oneDigit(1,!1):K.__zero();if(typeof $=="object"){if($.constructor===K)return $;let U=K.__toPrimitive($);return K.BigInt(U)}throw new TypeError("Cannot convert "+$+" to a BigInt")}toDebugString(){let $=["BigInt["];for(let T of this)$.push((T?(T>>>0).toString(16):T)+", ");return $.push("]"),$.join("")}toString($=10){if(2>$||36<$)throw new RangeError("toString() radix argument must be between 2 and 36");return this.length===0?"0":($&$-1)==0?K.__toStringBasePowerOfTwo(this,$):K.__toStringGeneric(this,$,!1)}valueOf(){throw new Error("Convert JSBI instances to native numbers using `toNumber`.")}static toNumber($){let T=$.length;if(T===0)return 0;if(T===1){let E=$.__unsignedDigit(0);return $.sign?-E:E}let W=$.__digit(T-1),U=K.__clz30(W),X=30*T-U;if(1024<X)return $.sign?-1/0:1/0;let Y=X-1,w=W,G=T-1,H=U+3,z=H===32?0:w<<H;z>>>=12;let F=H-12,O=12<=H?0:w<<20+H,Q=20+H;for(0<F&&0<G&&(G--,w=$.__digit(G),z|=w>>>30-F,O=w<<F+2,Q=F+2);0<Q&&0<G;)G--,w=$.__digit(G),O|=30<=Q?w<<Q-30:w>>>30-Q,Q-=30;let Z=K.__decideRounding($,Q,G,w);if((Z===1||Z===0&&(1&O)==1)&&(O=O+1>>>0,O===0&&(z++,z>>>20!=0&&(z=0,Y++,1023<Y))))return $.sign?-1/0:1/0;let V=$.sign?-2147483648:0;return Y=Y+1023<<20,K.__kBitConversionInts[K.__kBitConversionIntHigh]=V|Y|z,K.__kBitConversionInts[K.__kBitConversionIntLow]=O,K.__kBitConversionDouble[0]}static unaryMinus($){if($.length===0)return $;let T=$.__copy();return T.sign=!$.sign,T}static bitwiseNot($){return $.sign?K.__absoluteSubOne($).__trim():K.__absoluteAddOne($,!0)}static exponentiate($,T){if(T.sign)throw new RangeError("Exponent must be positive");if(T.length===0)return K.__oneDigit(1,!1);if($.length===0)return $;if($.length===1&&$.__digit(0)===1)return $.sign&&(1&T.__digit(0))==0?K.unaryMinus($):$;if(1<T.length)throw new RangeError("BigInt too big");let W=T.__unsignedDigit(0);if(W===1)return $;if(W>=K.__kMaxLengthBits)throw new RangeError("BigInt too big");if($.length===1&&$.__digit(0)===2){let Y=1+(0|W/30),w=$.sign&&(1&W)!=0,G=new K(Y,w);G.__initializeDigits();let H=1<<W%30;return G.__setDigit(Y-1,H),G}let U=null,X=$;for((1&W)!=0&&(U=$),W>>=1;W!==0;W>>=1)X=K.multiply(X,X),(1&W)!=0&&(U===null?U=X:U=K.multiply(U,X));return U}static multiply($,T){if($.length===0)return $;if(T.length===0)return T;let W=$.length+T.length;30<=$.__clzmsd()+T.__clzmsd()&&W--;let U=new K(W,$.sign!==T.sign);U.__initializeDigits();for(let X=0;X<$.length;X++)K.__multiplyAccumulate(T,$.__digit(X),U,X);return U.__trim()}static divide($,T){if(T.length===0)throw new RangeError("Division by zero");if(0>K.__absoluteCompare($,T))return K.__zero();let W=$.sign!==T.sign,U=T.__unsignedDigit(0),X;if(T.length===1&&32767>=U){if(U===1)return W===$.sign?$:K.unaryMinus($);X=K.__absoluteDivSmall($,U,null)}else X=K.__absoluteDivLarge($,T,!0,!1);return X.sign=W,X.__trim()}static remainder($,T){if(T.length===0)throw new RangeError("Division by zero");if(0>K.__absoluteCompare($,T))return $;let W=T.__unsignedDigit(0);if(T.length===1&&32767>=W){if(W===1)return K.__zero();let X=K.__absoluteModSmall($,W);return X===0?K.__zero():K.__oneDigit(X,$.sign)}let U=K.__absoluteDivLarge($,T,!1,!0);return U.sign=$.sign,U.__trim()}static add($,T){let W=$.sign;return W===T.sign?K.__absoluteAdd($,T,W):0<=K.__absoluteCompare($,T)?K.__absoluteSub($,T,W):K.__absoluteSub(T,$,!W)}static subtract($,T){let W=$.sign;return W===T.sign?0<=K.__absoluteCompare($,T)?K.__absoluteSub($,T,W):K.__absoluteSub(T,$,!W):K.__absoluteAdd($,T,W)}static leftShift($,T){return T.length===0||$.length===0?$:T.sign?K.__rightShiftByAbsolute($,T):K.__leftShiftByAbsolute($,T)}static signedRightShift($,T){return T.length===0||$.length===0?$:T.sign?K.__leftShiftByAbsolute($,T):K.__rightShiftByAbsolute($,T)}static unsignedRightShift(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}static lessThan($,T){return 0>K.__compareToBigInt($,T)}static lessThanOrEqual($,T){return 0>=K.__compareToBigInt($,T)}static greaterThan($,T){return 0<K.__compareToBigInt($,T)}static greaterThanOrEqual($,T){return 0<=K.__compareToBigInt($,T)}static equal($,T){if($.sign!==T.sign)return!1;if($.length!==T.length)return!1;for(let W=0;W<$.length;W++)if($.__digit(W)!==T.__digit(W))return!1;return!0}static notEqual($,T){return!K.equal($,T)}static bitwiseAnd($,T){var W=Math.max;if(!$.sign&&!T.sign)return K.__absoluteAnd($,T).__trim();if($.sign&&T.sign){let U=W($.length,T.length)+1,X=K.__absoluteSubOne($,U),Y=K.__absoluteSubOne(T);return X=K.__absoluteOr(X,Y,X),K.__absoluteAddOne(X,!0,X).__trim()}return $.sign&&([$,T]=[T,$]),K.__absoluteAndNot($,K.__absoluteSubOne(T)).__trim()}static bitwiseXor($,T){var W=Math.max;if(!$.sign&&!T.sign)return K.__absoluteXor($,T).__trim();if($.sign&&T.sign){let Y=W($.length,T.length),w=K.__absoluteSubOne($,Y),G=K.__absoluteSubOne(T);return K.__absoluteXor(w,G,w).__trim()}let U=W($.length,T.length)+1;$.sign&&([$,T]=[T,$]);let X=K.__absoluteSubOne(T,U);return X=K.__absoluteXor(X,$,X),K.__absoluteAddOne(X,!0,X).__trim()}static bitwiseOr($,T){var W=Math.max;let U=W($.length,T.length);if(!$.sign&&!T.sign)return K.__absoluteOr($,T).__trim();if($.sign&&T.sign){let Y=K.__absoluteSubOne($,U),w=K.__absoluteSubOne(T);return Y=K.__absoluteAnd(Y,w,Y),K.__absoluteAddOne(Y,!0,Y).__trim()}$.sign&&([$,T]=[T,$]);let X=K.__absoluteSubOne(T,U);return X=K.__absoluteAndNot(X,$,X),K.__absoluteAddOne(X,!0,X).__trim()}static asIntN($,T){var W=Math.floor;if(T.length===0)return T;if($=W($),0>$)throw new RangeError("Invalid value: not (convertible to) a safe integer");if($===0)return K.__zero();if($>=K.__kMaxLengthBits)return T;let U=0|($+29)/30;if(T.length<U)return T;let X=T.__unsignedDigit(U-1),Y=1<<($-1)%30;if(T.length===U&&X<Y)return T;if((X&Y)!==Y)return K.__truncateToNBits($,T);if(!T.sign)return K.__truncateAndSubFromPowerOfTwo($,T,!0);if((X&Y-1)==0){for(let w=U-2;0<=w;w--)if(T.__digit(w)!==0)return K.__truncateAndSubFromPowerOfTwo($,T,!1);return T.length===U&&X===Y?T:K.__truncateToNBits($,T)}return K.__truncateAndSubFromPowerOfTwo($,T,!1)}static asUintN($,T){var W=Math.floor;if(T.length===0)return T;if($=W($),0>$)throw new RangeError("Invalid value: not (convertible to) a safe integer");if($===0)return K.__zero();if(T.sign){if($>K.__kMaxLengthBits)throw new RangeError("BigInt too big");return K.__truncateAndSubFromPowerOfTwo($,T,!1)}if($>=K.__kMaxLengthBits)return T;let U=0|($+29)/30;if(T.length<U)return T;let X=$%30;if(T.length==U){if(X===0)return T;if(T.__digit(U-1)>>>X==0)return T}return K.__truncateToNBits($,T)}static ADD($,T){if($=K.__toPrimitive($),T=K.__toPrimitive(T),typeof $=="string")return typeof T!="string"&&(T=T.toString()),$+T;if(typeof T=="string")return $.toString()+T;if($=K.__toNumeric($),T=K.__toNumeric(T),K.__isBigInt($)&&K.__isBigInt(T))return K.add($,T);if(typeof $=="number"&&typeof T=="number")return $+T;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}static LT($,T){return K.__compare($,T,0)}static LE($,T){return K.__compare($,T,1)}static GT($,T){return K.__compare($,T,2)}static GE($,T){return K.__compare($,T,3)}static EQ($,T){for(;;){if(K.__isBigInt($))return K.__isBigInt(T)?K.equal($,T):K.EQ(T,$);if(typeof $=="number"){if(K.__isBigInt(T))return K.__equalToNumber(T,$);if(typeof T!="object")return $==T;T=K.__toPrimitive(T)}else if(typeof $=="string"){if(K.__isBigInt(T))return $=K.__fromString($),$!==null&&K.equal($,T);if(typeof T!="object")return $==T;T=K.__toPrimitive(T)}else if(typeof $=="boolean"){if(K.__isBigInt(T))return K.__equalToNumber(T,+$);if(typeof T!="object")return $==T;T=K.__toPrimitive(T)}else if(typeof $=="symbol"){if(K.__isBigInt(T))return!1;if(typeof T!="object")return $==T;T=K.__toPrimitive(T)}else if(typeof $=="object"){if(typeof T=="object"&&T.constructor!==K)return $==T;$=K.__toPrimitive($)}else return $==T}}static NE($,T){return!K.EQ($,T)}static DataViewGetBigInt64($,T,W=!1){return K.asIntN(64,K.DataViewGetBigUint64($,T,W))}static DataViewGetBigUint64($,T,W=!1){let[U,X]=W?[4,0]:[0,4],Y=$.getUint32(T+U,W),w=$.getUint32(T+X,W),G=new K(3,!1);return G.__setDigit(0,1073741823&w),G.__setDigit(1,(268435455&Y)<<2|w>>>30),G.__setDigit(2,Y>>>28),G.__trim()}static DataViewSetBigInt64($,T,W,U=!1){K.DataViewSetBigUint64($,T,W,U)}static DataViewSetBigUint64($,T,W,U=!1){W=K.asUintN(64,W);let X=0,Y=0;if(0<W.length&&(Y=W.__digit(0),1<W.length)){let H=W.__digit(1);Y|=H<<30,X=H>>>2,2<W.length&&(X|=W.__digit(2)<<28)}let[w,G]=U?[4,0]:[0,4];$.setUint32(T+w,X,U),$.setUint32(T+G,Y,U)}static __zero(){return new K(0,!1)}static __oneDigit($,T){let W=new K(1,T);return W.__setDigit(0,$),W}__copy(){let $=new K(this.length,this.sign);for(let T=0;T<this.length;T++)$[T]=this[T];return $}__trim(){let $=this.length,T=this[$-1];for(;T===0;)$--,T=this[$-1],this.pop();return $===0&&(this.sign=!1),this}__initializeDigits(){for(let $=0;$<this.length;$++)this[$]=0}static __decideRounding($,T,W,U){if(0<T)return-1;let X;if(0>T)X=-T-1;else{if(W===0)return-1;W--,U=$.__digit(W),X=29}let Y=1<<X;if((U&Y)==0)return-1;if(Y-=1,(U&Y)!=0)return 1;for(;0<W;)if(W--,$.__digit(W)!==0)return 1;return 0}static __fromDouble($){K.__kBitConversionDouble[0]=$;let T=2047&K.__kBitConversionInts[K.__kBitConversionIntHigh]>>>20,W=T-1023,U=(0|W/30)+1,X=new K(U,0>$),Y=1048575&K.__kBitConversionInts[K.__kBitConversionIntHigh]|1048576,w=K.__kBitConversionInts[K.__kBitConversionIntLow],G=20,H=W%30,z,F=0;if(H<20){let O=G-H;F=O+32,z=Y>>>O,Y=Y<<32-O|w>>>O,w<<=32-O}else if(H===20)F=32,z=Y,Y=w,w=0;else{let O=H-G;F=32-O,z=Y<<O|w>>>32-O,Y=w<<O,w=0}X.__setDigit(U-1,z);for(let O=U-2;0<=O;O--)0<F?(F-=30,z=Y>>>2,Y=Y<<30|w>>>2,w<<=30):z=0,X.__setDigit(O,z);return X.__trim()}static __isWhitespace($){return 13>=$&&9<=$||(159>=$?$==32:131071>=$?$==160||$==5760:196607>=$?($&=131071,10>=$||$==40||$==41||$==47||$==95||$==4096):$==65279)}static __fromString($,T=0){let W=0,U=$.length,X=0;if(X===U)return K.__zero();let Y=$.charCodeAt(X);for(;K.__isWhitespace(Y);){if(++X===U)return K.__zero();Y=$.charCodeAt(X)}if(Y===43){if(++X===U)return null;Y=$.charCodeAt(X),W=1}else if(Y===45){if(++X===U)return null;Y=$.charCodeAt(X),W=-1}if(T===0){if(T=10,Y===48){if(++X===U)return K.__zero();if(Y=$.charCodeAt(X),Y===88||Y===120){if(T=16,++X===U)return null;Y=$.charCodeAt(X)}else if(Y===79||Y===111){if(T=8,++X===U)return null;Y=$.charCodeAt(X)}else if(Y===66||Y===98){if(T=2,++X===U)return null;Y=$.charCodeAt(X)}}}else if(T===16&&Y===48){if(++X===U)return K.__zero();if(Y=$.charCodeAt(X),Y===88||Y===120){if(++X===U)return null;Y=$.charCodeAt(X)}}if(W!=0&&T!==10)return null;for(;Y===48;){if(++X===U)return K.__zero();Y=$.charCodeAt(X)}let w=U-X,G=K.__kMaxBitsPerChar[T],H=K.__kBitsPerCharTableMultiplier-1;if(w>1073741824/G)return null;let z=G*w+H>>>K.__kBitsPerCharTableShift,F=new K(0|(z+29)/30,!1),O=10>T?T:10,Q=10<T?T-10:0;if((T&T-1)==0){G>>=K.__kBitsPerCharTableShift;let Z=[],V=[],E=!1;do{let N=0,J=0;for(;;){let _;if(Y-48>>>0<O)_=Y-48;else if((32|Y)-97>>>0<Q)_=(32|Y)-87;else{E=!0;break}if(J+=G,N=N<<G|_,++X===U){E=!0;break}if(Y=$.charCodeAt(X),30<J+G)break}Z.push(N),V.push(J)}while(!E);K.__fillFromParts(F,Z,V)}else{F.__initializeDigits();let Z=!1,V=0;do{let E=0,N=1;for(;;){let _;if(Y-48>>>0<O)_=Y-48;else if((32|Y)-97>>>0<Q)_=(32|Y)-87;else{Z=!0;break}let R=N*T;if(1073741823<R)break;if(N=R,E=E*T+_,V++,++X===U){Z=!0;break}Y=$.charCodeAt(X)}H=30*K.__kBitsPerCharTableMultiplier-1;let J=0|(G*V+H>>>K.__kBitsPerCharTableShift)/30;F.__inplaceMultiplyAdd(N,E,J)}while(!Z)}if(X!==U){if(!K.__isWhitespace(Y))return null;for(X++;X<U;X++)if(Y=$.charCodeAt(X),!K.__isWhitespace(Y))return null}return F.sign=W==-1,F.__trim()}static __fillFromParts($,T,W){let U=0,X=0,Y=0;for(let w=T.length-1;0<=w;w--){let G=T[w],H=W[w];X|=G<<Y,Y+=H,Y===30?($.__setDigit(U++,X),Y=0,X=0):30<Y&&($.__setDigit(U++,1073741823&X),Y-=30,X=G>>>H-Y)}if(X!==0){if(U>=$.length)throw new Error("implementation bug");$.__setDigit(U++,X)}for(;U<$.length;U++)$.__setDigit(U,0)}static __toStringBasePowerOfTwo($,T){let W=$.length,U=T-1;U=(85&U>>>1)+(85&U),U=(51&U>>>2)+(51&U),U=(15&U>>>4)+(15&U);let X=U,Y=T-1,w=$.__digit(W-1),G=K.__clz30(w),H=0|(30*W-G+X-1)/X;if($.sign&&H++,268435456<H)throw new Error("string too long");let z=Array(H),F=H-1,O=0,Q=0;for(let V=0;V<W-1;V++){let E=$.__digit(V),N=(O|E<<Q)&Y;z[F--]=K.__kConversionChars[N];let J=X-Q;for(O=E>>>J,Q=30-J;Q>=X;)z[F--]=K.__kConversionChars[O&Y],O>>>=X,Q-=X}let Z=(O|w<<Q)&Y;for(z[F--]=K.__kConversionChars[Z],O=w>>>X-Q;O!==0;)z[F--]=K.__kConversionChars[O&Y],O>>>=X;if($.sign&&(z[F--]="-"),F!=-1)throw new Error("implementation bug");return z.join("")}static __toStringGeneric($,T,W){let U=$.length;if(U===0)return"";if(U===1){let V=$.__unsignedDigit(0).toString(T);return W===!1&&$.sign&&(V="-"+V),V}let X=30*U-K.__clz30($.__digit(U-1)),Y=K.__kMaxBitsPerChar[T],w=Y-1,G=X*K.__kBitsPerCharTableMultiplier;G+=w-1,G=0|G/w;let H=G+1>>1,z=K.exponentiate(K.__oneDigit(T,!1),K.__oneDigit(H,!1)),F,O,Q=z.__unsignedDigit(0);if(z.length===1&&32767>=Q){F=new K($.length,!1),F.__initializeDigits();let V=0;for(let E=2*$.length-1;0<=E;E--){let N=V<<15|$.__halfDigit(E);F.__setHalfDigit(E,0|N/Q),V=0|N%Q}O=V.toString(T)}else{let V=K.__absoluteDivLarge($,z,!0,!0);F=V.quotient;let E=V.remainder.__trim();O=K.__toStringGeneric(E,T,!0)}F.__trim();let Z=K.__toStringGeneric(F,T,!0);for(;O.length<H;)O="0"+O;return W===!1&&$.sign&&(Z="-"+Z),Z+O}static __unequalSign($){return $?-1:1}static __absoluteGreater($){return $?-1:1}static __absoluteLess($){return $?1:-1}static __compareToBigInt($,T){let W=$.sign;if(W!==T.sign)return K.__unequalSign(W);let U=K.__absoluteCompare($,T);return 0<U?K.__absoluteGreater(W):0>U?K.__absoluteLess(W):0}static __compareToNumber($,T){if(K.__isOneDigitInt(T)){let W=$.sign,U=0>T;if(W!==U)return K.__unequalSign(W);if($.length===0){if(U)throw new Error("implementation bug");return T===0?0:-1}if(1<$.length)return K.__absoluteGreater(W);let X=Math.abs(T),Y=$.__unsignedDigit(0);return Y>X?K.__absoluteGreater(W):Y<X?K.__absoluteLess(W):0}return K.__compareToDouble($,T)}static __compareToDouble($,T){if(T!==T)return T;if(T===1/0)return-1;if(T===-1/0)return 1;let W=$.sign;if(W!==0>T)return K.__unequalSign(W);if(T===0)throw new Error("implementation bug: should be handled elsewhere");if($.length===0)return-1;K.__kBitConversionDouble[0]=T;let U=2047&K.__kBitConversionInts[K.__kBitConversionIntHigh]>>>20;if(U==2047)throw new Error("implementation bug: handled elsewhere");let X=U-1023;if(0>X)return K.__absoluteGreater(W);let Y=$.length,w=$.__digit(Y-1),G=K.__clz30(w),H=30*Y-G,z=X+1;if(H<z)return K.__absoluteLess(W);if(H>z)return K.__absoluteGreater(W);let F=1048576|1048575&K.__kBitConversionInts[K.__kBitConversionIntHigh],O=K.__kBitConversionInts[K.__kBitConversionIntLow],Q=20,Z=29-G;if(Z!==(0|(H-1)%30))throw new Error("implementation bug");let V,E=0;if(20>Z){let N=Q-Z;E=N+32,V=F>>>N,F=F<<32-N|O>>>N,O<<=32-N}else if(Z===20)E=32,V=F,F=O,O=0;else{let N=Z-Q;E=32-N,V=F<<N|O>>>32-N,F=O<<N,O=0}if(w>>>=0,V>>>=0,w>V)return K.__absoluteGreater(W);if(w<V)return K.__absoluteLess(W);for(let N=Y-2;0<=N;N--){0<E?(E-=30,V=F>>>2,F=F<<30|O>>>2,O<<=30):V=0;let J=$.__unsignedDigit(N);if(J>V)return K.__absoluteGreater(W);if(J<V)return K.__absoluteLess(W)}if(F!==0||O!==0){if(E===0)throw new Error("implementation bug");return K.__absoluteLess(W)}return 0}static __equalToNumber($,T){var W=Math.abs;return K.__isOneDigitInt(T)?T===0?$.length===0:$.length===1&&$.sign===0>T&&$.__unsignedDigit(0)===W(T):K.__compareToDouble($,T)===0}static __comparisonResultToBool($,T){return T===0?0>$:T===1?0>=$:T===2?0<$:T===3?0<=$:void 0}static __compare($,T,W){if($=K.__toPrimitive($),T=K.__toPrimitive(T),typeof $=="string"&&typeof T=="string")switch(W){case 0:return $<T;case 1:return $<=T;case 2:return $>T;case 3:return $>=T}if(K.__isBigInt($)&&typeof T=="string")return T=K.__fromString(T),T!==null&&K.__comparisonResultToBool(K.__compareToBigInt($,T),W);if(typeof $=="string"&&K.__isBigInt(T))return $=K.__fromString($),$!==null&&K.__comparisonResultToBool(K.__compareToBigInt($,T),W);if($=K.__toNumeric($),T=K.__toNumeric(T),K.__isBigInt($)){if(K.__isBigInt(T))return K.__comparisonResultToBool(K.__compareToBigInt($,T),W);if(typeof T!="number")throw new Error("implementation bug");return K.__comparisonResultToBool(K.__compareToNumber($,T),W)}if(typeof $!="number")throw new Error("implementation bug");if(K.__isBigInt(T))return K.__comparisonResultToBool(K.__compareToNumber(T,$),2^W);if(typeof T!="number")throw new Error("implementation bug");return W===0?$<T:W===1?$<=T:W===2?$>T:W===3?$>=T:void 0}__clzmsd(){return K.__clz30(this.__digit(this.length-1))}static __absoluteAdd($,T,W){if($.length<T.length)return K.__absoluteAdd(T,$,W);if($.length===0)return $;if(T.length===0)return $.sign===W?$:K.unaryMinus($);let U=$.length;($.__clzmsd()===0||T.length===$.length&&T.__clzmsd()===0)&&U++;let X=new K(U,W),Y=0,w=0;for(;w<T.length;w++){let G=$.__digit(w)+T.__digit(w)+Y;Y=G>>>30,X.__setDigit(w,1073741823&G)}for(;w<$.length;w++){let G=$.__digit(w)+Y;Y=G>>>30,X.__setDigit(w,1073741823&G)}return w<X.length&&X.__setDigit(w,Y),X.__trim()}static __absoluteSub($,T,W){if($.length===0)return $;if(T.length===0)return $.sign===W?$:K.unaryMinus($);let U=new K($.length,W),X=0,Y=0;for(;Y<T.length;Y++){let w=$.__digit(Y)-T.__digit(Y)-X;X=1&w>>>30,U.__setDigit(Y,1073741823&w)}for(;Y<$.length;Y++){let w=$.__digit(Y)-X;X=1&w>>>30,U.__setDigit(Y,1073741823&w)}return U.__trim()}static __absoluteAddOne($,T,W=null){let U=$.length;W===null?W=new K(U,T):W.sign=T;let X=1;for(let Y=0;Y<U;Y++){let w=$.__digit(Y)+X;X=w>>>30,W.__setDigit(Y,1073741823&w)}return X!=0&&W.__setDigitGrow(U,1),W}static __absoluteSubOne($,T){let W=$.length;T=T||W;let U=new K(T,!1),X=1;for(let Y=0;Y<W;Y++){let w=$.__digit(Y)-X;X=1&w>>>30,U.__setDigit(Y,1073741823&w)}if(X!=0)throw new Error("implementation bug");for(let Y=W;Y<T;Y++)U.__setDigit(Y,0);return U}static __absoluteAnd($,T,W=null){let U=$.length,X=T.length,Y=X;if(U<X){Y=U;let H=$,z=U;$=T,U=X,T=H,X=z}let w=Y;W===null?W=new K(w,!1):w=W.length;let G=0;for(;G<Y;G++)W.__setDigit(G,$.__digit(G)&T.__digit(G));for(;G<w;G++)W.__setDigit(G,0);return W}static __absoluteAndNot($,T,W=null){let U=$.length,X=T.length,Y=X;U<X&&(Y=U);let w=U;W===null?W=new K(w,!1):w=W.length;let G=0;for(;G<Y;G++)W.__setDigit(G,$.__digit(G)&~T.__digit(G));for(;G<U;G++)W.__setDigit(G,$.__digit(G));for(;G<w;G++)W.__setDigit(G,0);return W}static __absoluteOr($,T,W=null){let U=$.length,X=T.length,Y=X;if(U<X){Y=U;let H=$,z=U;$=T,U=X,T=H,X=z}let w=U;W===null?W=new K(w,!1):w=W.length;let G=0;for(;G<Y;G++)W.__setDigit(G,$.__digit(G)|T.__digit(G));for(;G<U;G++)W.__setDigit(G,$.__digit(G));for(;G<w;G++)W.__setDigit(G,0);return W}static __absoluteXor($,T,W=null){let U=$.length,X=T.length,Y=X;if(U<X){Y=U;let H=$,z=U;$=T,U=X,T=H,X=z}let w=U;W===null?W=new K(w,!1):w=W.length;let G=0;for(;G<Y;G++)W.__setDigit(G,$.__digit(G)^T.__digit(G));for(;G<U;G++)W.__setDigit(G,$.__digit(G));for(;G<w;G++)W.__setDigit(G,0);return W}static __absoluteCompare($,T){let W=$.length-T.length;if(W!=0)return W;let U=$.length-1;for(;0<=U&&$.__digit(U)===T.__digit(U);)U--;return 0>U?0:$.__unsignedDigit(U)>T.__unsignedDigit(U)?1:-1}static __multiplyAccumulate($,T,W,U){if(T===0)return;let X=32767&T,Y=T>>>15,w=0,G=0;for(let H,z=0;z<$.length;z++,U++){H=W.__digit(U);let F=$.__digit(z),O=32767&F,Q=F>>>15,Z=K.__imul(O,X),V=K.__imul(O,Y),E=K.__imul(Q,X),N=K.__imul(Q,Y);H+=G+Z+w,w=H>>>30,H&=1073741823,H+=((32767&V)<<15)+((32767&E)<<15),w+=H>>>30,G=N+(V>>>15)+(E>>>15),W.__setDigit(U,1073741823&H)}for(;w!=0||G!==0;U++){let H=W.__digit(U);H+=w+G,G=0,w=H>>>30,W.__setDigit(U,1073741823&H)}}static __internalMultiplyAdd($,T,W,U,X){let Y=W,w=0;for(let G=0;G<U;G++){let H=$.__digit(G),z=K.__imul(32767&H,T),F=K.__imul(H>>>15,T),O=z+((32767&F)<<15)+w+Y;Y=O>>>30,w=F>>>15,X.__setDigit(G,1073741823&O)}if(X.length>U)for(X.__setDigit(U++,Y+w);U<X.length;)X.__setDigit(U++,0);else if(Y+w!==0)throw new Error("implementation bug")}__inplaceMultiplyAdd($,T,W){W>this.length&&(W=this.length);let U=32767&$,X=$>>>15,Y=0,w=T;for(let G=0;G<W;G++){let H=this.__digit(G),z=32767&H,F=H>>>15,O=K.__imul(z,U),Q=K.__imul(z,X),Z=K.__imul(F,U),V=K.__imul(F,X),E=w+O+Y;Y=E>>>30,E&=1073741823,E+=((32767&Q)<<15)+((32767&Z)<<15),Y+=E>>>30,w=V+(Q>>>15)+(Z>>>15),this.__setDigit(G,1073741823&E)}if(Y!=0||w!==0)throw new Error("implementation bug")}static __absoluteDivSmall($,T,W=null){W===null&&(W=new K($.length,!1));let U=0;for(let X,Y=2*$.length-1;0<=Y;Y-=2){X=(U<<15|$.__halfDigit(Y))>>>0;let w=0|X/T;U=0|X%T,X=(U<<15|$.__halfDigit(Y-1))>>>0;let G=0|X/T;U=0|X%T,W.__setDigit(Y>>>1,w<<15|G)}return W}static __absoluteModSmall($,T){let W=0;for(let U=2*$.length-1;0<=U;U--)W=0|((W<<15|$.__halfDigit(U))>>>0)%T;return W}static __absoluteDivLarge($,T,W,U){let X=T.__halfDigitLength(),Y=T.length,w=$.__halfDigitLength()-X,G=null;W&&(G=new K(w+2>>>1,!1),G.__initializeDigits());let H=new K(X+2>>>1,!1);H.__initializeDigits();let z=K.__clz15(T.__halfDigit(X-1));0<z&&(T=K.__specialLeftShift(T,z,0));let F=K.__specialLeftShift($,z,1),O=T.__halfDigit(X-1),Q=0;for(let Z,V=w;0<=V;V--){Z=32767;let E=F.__halfDigit(V+X);if(E!==O){let J=(E<<15|F.__halfDigit(V+X-1))>>>0;Z=0|J/O;let _=0|J%O,R=T.__halfDigit(X-2),P=F.__halfDigit(V+X-2);for(;K.__imul(Z,R)>>>0>(_<<16|P)>>>0&&(Z--,_+=O,!(32767<_)););}K.__internalMultiplyAdd(T,Z,0,Y,H);let N=F.__inplaceSub(H,V,X+1);N!==0&&(N=F.__inplaceAdd(T,V,X),F.__setHalfDigit(V+X,32767&F.__halfDigit(V+X)+N),Z--),W&&(1&V?Q=Z<<15:G.__setDigit(V>>>1,Q|Z))}if(U)return F.__inplaceRightShift(z),W?{quotient:G,remainder:F}:F;if(W)return G;throw new Error("unreachable")}static __clz15($){return K.__clz30($)-15}__inplaceAdd($,T,W){let U=0;for(let X=0;X<W;X++){let Y=this.__halfDigit(T+X)+$.__halfDigit(X)+U;U=Y>>>15,this.__setHalfDigit(T+X,32767&Y)}return U}__inplaceSub($,T,W){let U=0;if(1&T){T>>=1;let X=this.__digit(T),Y=32767&X,w=0;for(;w<W-1>>>1;w++){let z=$.__digit(w),F=(X>>>15)-(32767&z)-U;U=1&F>>>15,this.__setDigit(T+w,(32767&F)<<15|32767&Y),X=this.__digit(T+w+1),Y=(32767&X)-(z>>>15)-U,U=1&Y>>>15}let G=$.__digit(w),H=(X>>>15)-(32767&G)-U;if(U=1&H>>>15,this.__setDigit(T+w,(32767&H)<<15|32767&Y),T+w+1>=this.length)throw new RangeError("out of bounds");(1&W)==0&&(X=this.__digit(T+w+1),Y=(32767&X)-(G>>>15)-U,U=1&Y>>>15,this.__setDigit(T+$.length,1073709056&X|32767&Y))}else{T>>=1;let X=0;for(;X<$.length-1;X++){let z=this.__digit(T+X),F=$.__digit(X),O=(32767&z)-(32767&F)-U;U=1&O>>>15;let Q=(z>>>15)-(F>>>15)-U;U=1&Q>>>15,this.__setDigit(T+X,(32767&Q)<<15|32767&O)}let Y=this.__digit(T+X),w=$.__digit(X),G=(32767&Y)-(32767&w)-U;U=1&G>>>15;let H=0;(1&W)==0&&(H=(Y>>>15)-(w>>>15)-U,U=1&H>>>15),this.__setDigit(T+X,(32767&H)<<15|32767&G)}return U}__inplaceRightShift($){if($===0)return;let T=this.__digit(0)>>>$,W=this.length-1;for(let U=0;U<W;U++){let X=this.__digit(U+1);this.__setDigit(U,1073741823&X<<30-$|T),T=X>>>$}this.__setDigit(W,T)}static __specialLeftShift($,T,W){let U=$.length,X=new K(U+W,!1);if(T===0){for(let w=0;w<U;w++)X.__setDigit(w,$.__digit(w));return 0<W&&X.__setDigit(U,0),X}let Y=0;for(let w=0;w<U;w++){let G=$.__digit(w);X.__setDigit(w,1073741823&G<<T|Y),Y=G>>>30-T}return 0<W&&X.__setDigit(U,Y),X}static __leftShiftByAbsolute($,T){let W=K.__toShiftAmount(T);if(0>W)throw new RangeError("BigInt too big");let U=0|W/30,X=W%30,Y=$.length,w=X!==0&&$.__digit(Y-1)>>>30-X!=0,G=Y+U+(w?1:0),H=new K(G,$.sign);if(X===0){let z=0;for(;z<U;z++)H.__setDigit(z,0);for(;z<G;z++)H.__setDigit(z,$.__digit(z-U))}else{let z=0;for(let F=0;F<U;F++)H.__setDigit(F,0);for(let F=0;F<Y;F++){let O=$.__digit(F);H.__setDigit(F+U,1073741823&O<<X|z),z=O>>>30-X}if(w)H.__setDigit(Y+U,z);else if(z!==0)throw new Error("implementation bug")}return H.__trim()}static __rightShiftByAbsolute($,T){let{length:W,sign:U}=$,X=K.__toShiftAmount(T);if(0>X)return K.__rightShiftByMaximum(U);let Y=0|X/30,w=X%30,G=W-Y;if(0>=G)return K.__rightShiftByMaximum(U);let H=!1;if(U){if(($.__digit(Y)&(1<<w)-1)!=0)H=!0;else for(let F=0;F<Y;F++)if($.__digit(F)!==0){H=!0;break}}if(H&&w===0)~$.__digit(W-1)==0&&G++;let z=new K(G,U);if(w===0){z.__setDigit(G-1,0);for(let F=Y;F<W;F++)z.__setDigit(F-Y,$.__digit(F))}else{let F=$.__digit(Y)>>>w,O=W-Y-1;for(let Q=0;Q<O;Q++){let Z=$.__digit(Q+Y+1);z.__setDigit(Q,1073741823&Z<<30-w|F),F=Z>>>w}z.__setDigit(O,F)}return H&&(z=K.__absoluteAddOne(z,!0,z)),z.__trim()}static __rightShiftByMaximum($){return $?K.__oneDigit(1,!0):K.__zero()}static __toShiftAmount($){if(1<$.length)return-1;let T=$.__unsignedDigit(0);return T>K.__kMaxLengthBits?-1:T}static __toPrimitive($,T="default"){if(typeof $!="object")return $;if($.constructor===K)return $;if(typeof Symbol!="undefined"&&typeof Symbol.toPrimitive=="symbol"&&$[Symbol.toPrimitive]){let X=$[Symbol.toPrimitive](T);if(typeof X!="object")return X;throw new TypeError("Cannot convert object to primitive value")}let W=$.valueOf;if(W){let X=W.call($);if(typeof X!="object")return X}let U=$.toString;if(U){let X=U.call($);if(typeof X!="object")return X}throw new TypeError("Cannot convert object to primitive value")}static __toNumeric($){return K.__isBigInt($)?$:+$}static __isBigInt($){return typeof $=="object"&&$!==null&&$.constructor===K}static __truncateToNBits($,T){let W=0|($+29)/30,U=new K(W,T.sign),X=W-1;for(let w=0;w<X;w++)U.__setDigit(w,T.__digit(w));let Y=T.__digit(X);if($%30!=0){let w=32-$%30;Y=Y<<w>>>w}return U.__setDigit(X,Y),U.__trim()}static __truncateAndSubFromPowerOfTwo($,T,W){var U=Math.min;let X=0|($+29)/30,Y=new K(X,W),w=0,G=X-1,H=0;for(let Q=U(G,T.length);w<Q;w++){let Z=0-T.__digit(w)-H;H=1&Z>>>30,Y.__setDigit(w,1073741823&Z)}for(;w<G;w++)Y.__setDigit(w,0|1073741823&-H);let z=G<T.length?T.__digit(G):0,F=$%30,O;if(F==0)O=0-z-H,O&=1073741823;else{let Q=32-F;z=z<<Q>>>Q;let Z=1<<32-Q;O=Z-z-H,O&=Z-1}return Y.__setDigit(G,O),Y.__trim()}__digit($){return this[$]}__unsignedDigit($){return this[$]>>>0}__setDigit($,T){this[$]=0|T}__setDigitGrow($,T){this[$]=0|T}__halfDigitLength(){let $=this.length;return 32767>=this.__unsignedDigit($-1)?2*$-1:2*$}__halfDigit($){return 32767&this[$>>>1]>>>15*(1&$)}__setHalfDigit($,T){let W=$>>>1,U=this.__digit(W),X=1&$?32767&U|T<<15:1073709056&U|32767&T;this.__setDigit(W,X)}static __digitPow($,T){let W=1;for(;0<T;)1&T&&(W*=$),T>>>=1,$*=$;return W}static __detectBigEndian(){return K.__kBitConversionDouble[0]=-0,K.__kBitConversionInts[0]!==0}static __isOneDigitInt($){return(1073741823&$)===$}}K.__kMaxLength=33554432,K.__kMaxLengthBits=K.__kMaxLength<<5,K.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],K.__kBitsPerCharTableShift=5,K.__kBitsPerCharTableMultiplier=1<<K.__kBitsPerCharTableShift,K.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],K.__kBitConversionBuffer=new ArrayBuffer(8),K.__kBitConversionDouble=new Float64Array(K.__kBitConversionBuffer),K.__kBitConversionInts=new Int32Array(K.__kBitConversionBuffer),K.__kBitConversionIntHigh=K.__detectBigEndian()?0:1,K.__kBitConversionIntLow=K.__detectBigEndian()?1:0,K.__clz30=Math.clz32?function($){return Math.clz32($)-2}:function($){return $===0?30:0|29-(0|Math.log($>>>0)/Math.LN2)},K.__imul=Math.imul||function($,T){return 0|$*T};var q=K;var Y1=q.BigInt(0),x8=q.BigInt(1),uO=q.BigInt(2),zb=q.BigInt(10),Hb=q.BigInt(24),Fb=q.BigInt(60),Ob=q.BigInt(1000),u8=q.BigInt(1e6),q8=q.BigInt(1e9),HM=q.multiply(q.BigInt(3600),q8),Qb=q.multiply(Fb,q8),vT=q.multiply(HM,Hb);function B0($){return typeof $=="bigint"?q.BigInt($.toString(10)):$}function FM($){return q.equal(q.remainder($,uO),Y1)}function RW($){return q.lessThan($,Y1)?q.unaryMinus($):$}function tG($,T){return q.lessThan($,T)?-1:q.greaterThan($,T)?1:0}function M8($,T){return{quotient:q.divide($,T),remainder:q.remainder($,T)}}var CA,SA,F$="slot-epochNanoSeconds",O$="slot-iso-date",W4="slot-iso-date-time",O4="slot-time",m="slot-calendar",OM="slot-date-brand",QM="slot-year-month-brand",ZM="slot-month-day-brand",b$="slot-time-zone",O6="slot-years",Q6="slot-months",b6="slot-weeks",Z6="slot-days",D6="slot-hours",V6="slot-minutes",K6="slot-seconds",E6="slot-milliseconds",A6="slot-microseconds",f6="slot-nanoseconds",DM="date",VM="ym",KM="md",EM="time",AM="datetime",MM="instant",IW="original",m2="timezone-canonical",JO="timezone-original",N8="calendar-id",NM="locale",_O="options",LM=new WeakMap,RO=Symbol.for("@@Temporal__GetSlots");(CA=globalThis)[RO]||(CA[RO]=function($){return LM.get($)});var z9=globalThis[RO],kO=Symbol.for("@@Temporal__CreateSlots");(SA=globalThis)[kO]||(SA[kO]=function($){LM.set($,Object.create(null))});var u0=globalThis[kO];function _6($,...T){if(!$||typeof $!="object")return!1;let W=z9($);return!!W&&T.every((U)=>(U in W))}function D($,T){let W=z9($)?.[T];if(W===void 0)throw new TypeError(`Missing internal slot ${T}`);return W}function L$($,T,W){let U=z9($);if(U===void 0)throw new TypeError("Missing slots for the given container");if(U[T])throw new TypeError(`${T} already has set`);U[T]=W}var vO={};function p0($,T){Object.defineProperty($.prototype,Symbol.toStringTag,{value:T,writable:!1,enumerable:!1,configurable:!0});let W=Object.getOwnPropertyNames($);for(let X=0;X<W.length;X++){let Y=W[X],w=Object.getOwnPropertyDescriptor($,Y);w.configurable&&w.enumerable&&(w.enumerable=!1,Object.defineProperty($,Y,w))}let U=Object.getOwnPropertyNames($.prototype);for(let X=0;X<U.length;X++){let Y=U[X],w=Object.getOwnPropertyDescriptor($.prototype,Y);w.configurable&&w.enumerable&&(w.enumerable=!1,Object.defineProperty($.prototype,Y,w))}qO(T,$),qO(`${T}.prototype`,$.prototype)}function qO($,T){let W=`%${$}%`;if(vO[W]!==void 0)throw new Error(`intrinsic ${$} already exists`);vO[W]=T}function r4($){return vO[$]}function u2($,T){let W=$;if(W===0)return{div:W,mod:W};let U=Math.sign(W);W=Math.abs(W);let X=Math.trunc(1+Math.log10(W));if(T>=X)return{div:0*U,mod:U*W};if(T===0)return{div:U*W,mod:0*U};let Y=W.toPrecision(X);return{div:U*Number.parseInt(Y.slice(0,X-T),10),mod:U*Number.parseInt(Y.slice(X-T),10)}}function EO($,T,W){let U=$,X=W;if(U===0)return X;let Y=Math.sign(U)||Math.sign(X);U=Math.abs(U),X=Math.abs(X);let w=U.toPrecision(Math.trunc(1+Math.log10(U)));if(X===0)return Y*Number.parseInt(w+"0".repeat(T),10);let G=w+X.toPrecision(Math.trunc(1+Math.log10(X))).padStart(T,"0");return Y*Number.parseInt(G,10)}function H9($,T){let W=T==="negative";switch($){case"ceil":return W?"zero":"infinity";case"floor":return W?"infinity":"zero";case"expand":return"infinity";case"trunc":return"zero";case"halfCeil":return W?"half-zero":"half-infinity";case"halfFloor":return W?"half-infinity":"half-zero";case"halfExpand":return"half-infinity";case"halfTrunc":return"half-zero";case"halfEven":return"half-even"}}function F9($,T,W,U,X){return X==="zero"?$:X==="infinity"?T:W<0?$:W>0?T:X==="half-zero"?$:X==="half-infinity"?T:U?$:T}class R${constructor($){this.totalNs=B0($),this.sec=q.toNumber(q.divide(this.totalNs,q8)),this.subsec=q.toNumber(q.remainder(this.totalNs,q8))}static validateNew($,T){if(q.greaterThan(RW($),R$.MAX))throw new RangeError(`${T} of duration time units cannot exceed ${R$.MAX} s`);return new R$($)}static fromEpochNsDiff($,T){let W=q.subtract(B0($),B0(T));return new R$(W)}static fromComponents($,T,W,U,X,Y){let w=q.add(q.add(q.add(q.add(q.add(q.BigInt(Y),q.multiply(q.BigInt(X),Ob)),q.multiply(q.BigInt(U),u8)),q.multiply(q.BigInt(W),q8)),q.multiply(q.BigInt(T),Qb)),q.multiply(q.BigInt($),HM));return R$.validateNew(w,"total")}abs(){return new R$(RW(this.totalNs))}add($){return R$.validateNew(q.add(this.totalNs,$.totalNs),"sum")}add24HourDays($){return R$.validateNew(q.add(this.totalNs,q.multiply(q.BigInt($),vT)),"sum")}addToEpochNs($){return q.add(B0($),this.totalNs)}cmp($){return tG(this.totalNs,$.totalNs)}divmod($){let{quotient:T,remainder:W}=M8(this.totalNs,q.BigInt($));return{quotient:q.toNumber(T),remainder:new R$(W)}}fdiv($){let T=B0($),W=q.BigInt(T),{quotient:U,remainder:X}=M8(this.totalNs,W),Y=[],w,G=(q.lessThan(this.totalNs,Y1)?-1:1)*Math.sign(q.toNumber(T));for(;!q.equal(X,Y1)&&Y.length<50;)X=q.multiply(X,zb),{quotient:w,remainder:X}=M8(X,W),Y.push(Math.abs(q.toNumber(w)));return G*Number(RW(U).toString()+"."+Y.join(""))}isZero(){return q.equal(this.totalNs,Y1)}round($,T){let W=B0($);if(q.equal(W,x8))return this;let{quotient:U,remainder:X}=M8(this.totalNs,W),Y=q.lessThan(this.totalNs,Y1)?"negative":"positive",w=q.multiply(RW(U),W),G=q.add(w,W),H=tG(RW(q.multiply(X,uO)),W),z=H9(T,Y),F=q.equal(RW(this.totalNs),w)?w:F9(w,G,H,FM(U),z),O=Y==="positive"?F:q.unaryMinus(F);return R$.validateNew(O,"rounding")}sign(){return this.cmp(new R$(Y1))}subtract($){return R$.validateNew(q.subtract(this.totalNs,$.totalNs),"difference")}}R$.MAX=q.BigInt("9007199254740991999999999"),R$.ZERO=new R$(Y1);var jA=/[A-Za-z._][A-Za-z._0-9+-]*/,p8=new RegExp(`(?:${/(?:[+-](?:[01][0-9]|2[0-3])(?::?[0-5][0-9])?)/.source}|(?:${jA.source})(?:\\/(?:${jA.source}))*)`),JM=/(?:[+-]\d{6}|\d{4})/,aG=/(?:0[1-9]|1[0-2])/,PO=/(?:0[1-9]|[12]\d|3[01])/,Zb=new RegExp(`(${JM.source})(?:-(${aG.source})-(${PO.source})|(${aG.source})(${PO.source}))`),_M=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,RM=/((?:[+-])(?:[01][0-9]|2[0-3])(?::?(?:[0-5][0-9])(?::?(?:[0-5][0-9])(?:[.,](?:\d{1,9}))?)?)?)/,kM=new RegExp(`([zZ])|${RM.source}?`),l2=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,Db=new RegExp([`^${Zb.source}`,`(?:(?:[tT]|\\s+)${_M.source}(?:${kM.source})?)?`,`(?:\\[!?(${p8.source})\\])?`,`((?:${l2.source})*)$`].join("")),Vb=new RegExp([`^[tT]?${_M.source}`,`(?:${kM.source})?`,`(?:\\[!?${p8.source}\\])?`,`((?:${l2.source})*)$`].join("")),Kb=new RegExp(`^(${JM.source})-?(${aG.source})(?:\\[!?${p8.source}\\])?((?:${l2.source})*)$`),Eb=new RegExp(`^(?:--)?(${aG.source})-?(${PO.source})(?:\\[!?${p8.source}\\])?((?:${l2.source})*)$`),AO=/(\d+)(?:[.,](\d{1,9}))?/,Ab=new RegExp(`(?:${AO.source}H)?(?:${AO.source}M)?(?:${AO.source}S)?`),Mb=new RegExp(`^([+-])?P${/(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/.source}(?:T(?!$)${Ab.source})?$`,"i"),qT=86400000,sG=1e6*qT,Nb=60000000000,vM=1e8*qT,r2=f1(vM),I8=q.unaryMinus(r2),Lb=q.add(q.subtract(I8,vT),x8),Jb=q.subtract(q.add(r2,vT),x8),_b=146097*qT,BA=-271821,xA=275760,P8=Date.UTC(1847,0,1),Rb=["iso8601","hebrew","islamic","islamic-umalqura","islamic-tbla","islamic-civil","islamic-rgsa","islamicc","persian","ethiopic","ethioaa","ethiopic-amete-alem","coptic","chinese","dangi","roc","indian","buddhist","japanese","gregory"],kb=new Set(["ACT","AET","AGT","ART","AST","BET","BST","CAT","CNT","CST","CTT","EAT","ECT","IET","IST","JST","MIT","NET","NST","PLT","PNT","PRT","PST","SST","VST"]);function Q4($){return typeof $=="object"&&$!==null||typeof $=="function"}function O9($){if(typeof $=="bigint")throw new TypeError("Cannot convert BigInt to number");return Number($)}function Q9($){if(typeof $=="symbol")throw new TypeError("Cannot convert a Symbol value to a String");return String($)}function V$($){let T=O9($);if(T===0)return 0;if(Number.isNaN(T)||T===1/0||T===-1/0)throw new RangeError("invalid number value");let W=Math.trunc(T);return W===0?0:W}function IA($,T){let W=V$($);if(W<=0){if(T!==void 0)throw new RangeError(`property '${T}' cannot be a a number less than one`);throw new RangeError("Cannot convert a number less than one to a positive integer")}return W}function I1($){let T=O9($);if(Number.isNaN(T))throw new RangeError("not a number");if(T===1/0||T===-1/0)throw new RangeError("infinity is out of range");if(!function(W){if(typeof W!="number"||Number.isNaN(W)||W===1/0||W===-1/0)return!1;let U=Math.abs(W);return Math.floor(U)===U}(T))throw new RangeError(`unsupported fractional value ${$}`);return T===0?0:T}function b8($,T){return String($).padStart(T,"0")}function S4($){if(typeof $!="string")throw new TypeError(`expected a string, not ${String($)}`);return $}function CO($,T){if(Q4($)){let W=$?.toString();if(typeof W=="string"||typeof W=="number")return W;throw new TypeError("Cannot convert object to primitive value")}return $}var SO=["era","eraYear","year","month","monthCode","day","hour","minute","second","millisecond","microsecond","nanosecond","offset","timeZone"],vb={era:Q9,eraYear:V$,year:V$,month:IA,monthCode:function($){let T=S4(CO($));if(T.length<3||T.length>4||T[0]!=="M"||"0123456789".indexOf(T[1])===-1||"0123456789".indexOf(T[2])===-1||T[1]+T[2]==="00"&&T[3]!=="L"||T[3]!=="L"&&T[3]!==void 0)throw new RangeError(`bad month code ${T}; must match M01-M99 or M00L-M99L`);return T},day:IA,hour:V$,minute:V$,second:V$,millisecond:V$,microsecond:V$,nanosecond:V$,offset:function($){let T=S4(CO($));return XU(T),T},timeZone:L6},qb={hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},n2=[["years","year","date"],["months","month","date"],["weeks","week","date"],["days","day","date"],["hours","hour","time"],["minutes","minute","time"],["seconds","second","time"],["milliseconds","millisecond","time"],["microseconds","microsecond","time"],["nanoseconds","nanosecond","time"]],bA=Object.fromEntries(n2.map(($)=>[$[0],$[1]])),Pb=Object.fromEntries(n2.map(([$,T])=>[T,$])),C8=n2.map(([,$])=>$),i2={day:sG,hour:3600000000000,minute:60000000000,second:1e9,millisecond:1e6,microsecond:1000,nanosecond:1},eG=["days","hours","microseconds","milliseconds","minutes","months","nanoseconds","seconds","weeks","years"],Cb=Intl.DateTimeFormat,fA=new Map;function qM($){let T=m8($),W=fA.get(T);return W===void 0&&(W=new Cb("en-us",{timeZone:T,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),fA.set(T,W)),W}function d4($){return _6($,F$)&&!_6($,b$,m)}function H4($){return _6($,O6,Q6,Z6,D6,V6,K6,E6,A6,f6)}function F4($){return _6($,OM)}function K4($){return _6($,O4)}function n$($){return _6($,W4)}function o4($){return _6($,QM)}function X1($){return _6($,ZM)}function _$($){return _6($,F$,b$,m)}function C($,T){if(!T($))throw new TypeError("invalid receiver: method called with the wrong type of this-object")}function TU($){if(_6($,m)||_6($,b$))throw new TypeError("with() does not support a calendar or timeZone property");if(K4($))throw new TypeError("with() does not accept Temporal.PlainTime, use withPlainTime() instead");if($.calendar!==void 0)throw new TypeError("with() does not support a calendar property");if($.timeZone!==void 0)throw new TypeError("with() does not support a timeZone property")}function d8($,T){return T==="never"||T==="auto"&&$==="iso8601"?"":`[${T==="critical"?"!":""}u-ca=${$}]`}function Z9($){let T,W,U=!1;for(l2.lastIndex=0;W=l2.exec($);){let{1:X,2:Y,3:w}=W;if(Y==="u-ca"){if(T===void 0)T=w,U=X==="!";else if(X==="!"||U)throw new RangeError(`Invalid annotations in ${$}: more than one u-ca present with critical flag`)}else if(X==="!")throw new RangeError(`Unrecognized annotation: !${Y}=${w}`)}return T}function G0($){let T=Db.exec($);if(!T)throw new RangeError(`invalid RFC 9557 string: ${$}`);let W=Z9(T[16]),U=T[1];if(U==="-000000")throw new RangeError(`invalid RFC 9557 string: ${$}`);let X=+U,Y=+(T[2]??T[4]??1),w=+(T[3]??T[5]??1),G=T[6]!==void 0,H=+(T[6]??0),z=+(T[7]??T[10]??0),F=+(T[8]??T[11]??0);F===60&&(F=59);let O=(T[9]??T[12]??"")+"000000000",Q=+O.slice(0,3),Z=+O.slice(3,6),V=+O.slice(6,9),E,N=!1;T[13]?(E=void 0,N=!0):T[14]&&(E=T[14]);let J=T[15];return nO(X,Y,w,H,z,F,Q,Z,V),{year:X,month:Y,day:w,time:G?{hour:H,minute:z,second:F,millisecond:Q,microsecond:Z,nanosecond:V}:"start-of-day",tzAnnotation:J,offset:E,z:N,calendar:W}}function PM($){let T=Vb.exec($),W,U,X,Y,w,G,H;if(T){H=Z9(T[10]),W=+(T[1]??0),U=+(T[2]??T[5]??0),X=+(T[3]??T[6]??0),X===60&&(X=59);let z=(T[4]??T[7]??"")+"000000000";if(Y=+z.slice(0,3),w=+z.slice(3,6),G=+z.slice(6,9),T[8])throw new RangeError("Z designator not supported for PlainTime")}else{let z,F;if({time:z,z:F,calendar:H}=G0($),z==="start-of-day")throw new RangeError(`time is missing in string: ${$}`);if(F)throw new RangeError("Z designator not supported for PlainTime");({hour:W,minute:U,second:X,millisecond:Y,microsecond:w,nanosecond:G}=z)}if(E9(W,U,X,Y,w,G),/[tT ][0-9][0-9]/.test($))return{hour:W,minute:U,second:X,millisecond:Y,microsecond:w,nanosecond:G,calendar:H};try{let{month:z,day:F}=dO($);CW(1972,z,F)}catch{try{let{year:z,month:F}=pO($);CW(z,F,1)}catch{return{hour:W,minute:U,second:X,millisecond:Y,microsecond:w,nanosecond:G,calendar:H}}}throw new RangeError(`invalid RFC 9557 time-only string ${$}; may need a T prefix`)}function pO($){let T=Kb.exec($),W,U,X,Y;if(T){X=Z9(T[3]);let w=T[1];if(w==="-000000")throw new RangeError(`invalid RFC 9557 string: ${$}`);if(W=+w,U=+T[2],Y=1,X!==void 0&&X!=="iso8601")throw new RangeError("YYYY-MM format is only valid with iso8601 calendar")}else{let w;if({year:W,month:U,calendar:X,day:Y,z:w}=G0($),w)throw new RangeError("Z designator not supported for PlainYearMonth")}return{year:W,month:U,calendar:X,referenceISODay:Y}}function dO($){let T=Eb.exec($),W,U,X,Y;if(T){if(X=Z9(T[3]),W=+T[1],U=+T[2],X!==void 0&&X!=="iso8601")throw new RangeError("MM-DD format is only valid with iso8601 calendar")}else{let w;if({month:W,day:U,calendar:X,year:Y,z:w}=G0($),w)throw new RangeError("Z designator not supported for PlainMonthDay")}return{month:W,day:U,calendar:X,referenceISOYear:Y}}var CM=new RegExp(`^${p8.source}$`,"i"),SM=new RegExp(`^${/([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])?)?/.source}$`);function jM($){let T=jb.test($)?"Seconds not allowed in offset time zone":"Invalid time zone";throw new RangeError(`${T}: ${$}`)}function kT($){return CM.test($)||jM($),SM.test($)?{offsetMinutes:XU($)/60000000000}:{tzName:$}}function S8($,T,W,U){let X=$,Y=T,w=W;switch(U){case"reject":CW(X,Y,w);break;case"constrain":({year:X,month:Y,day:w}=nM(X,Y,w))}return{year:X,month:Y,day:w}}function D9($,T,W,U,X,Y,w){let G=$,H=T,z=W,F=U,O=X,Q=Y;switch(w){case"reject":E9(G,H,z,F,O,Q);break;case"constrain":G=M6(G,0,23),H=M6(H,0,59),z=M6(z,0,59),F=M6(F,0,999),O=M6(O,0,999),Q=M6(Q,0,999)}return{hour:G,minute:H,second:z,millisecond:F,microsecond:O,nanosecond:Q}}function BM($){if(!Q4($))throw new TypeError("invalid duration-like");let T={years:void 0,months:void 0,weeks:void 0,days:void 0,hours:void 0,minutes:void 0,seconds:void 0,milliseconds:void 0,microseconds:void 0,nanoseconds:void 0},W=!1;for(let U=0;U<eG.length;U++){let X=eG[U],Y=$[X];Y!==void 0&&(W=!0,T[X]=I1(Y))}if(!W)throw new TypeError("invalid duration-like");return T}function e4({years:$,months:T,weeks:W,days:U},X,Y,w){return{years:$,months:w??T,weeks:Y??W,days:X??U}}function B$($,T){return{isoDate:$,time:T}}function C$($){return g0($,"overflow",["constrain","reject"],"constrain")}function j8($){return g0($,"disambiguation",["compatible","earlier","later","reject"],"compatible")}function y1($,T){return g0($,"roundingMode",["ceil","floor","expand","trunc","halfCeil","halfFloor","halfExpand","halfTrunc","halfEven"],T)}function iG($,T){return g0($,"offset",["prefer","use","ignore","reject"],T)}function o8($){return g0($,"calendarName",["auto","always","never","critical"],"auto")}function WU($){let T=$.roundingIncrement;if(T===void 0)return 1;let W=V$(T);if(W<1||W>1e9)throw new RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${T}`);return W}function UU($,T,W){let U=W?T:T-1;if($>U)throw new RangeError(`roundingIncrement must be at least 1 and less than ${U}, not ${$}`);if(T%$!=0)throw new RangeError(`Rounding increment must divide evenly into ${T}`)}function l8($){let T=$.fractionalSecondDigits;if(T===void 0)return"auto";if(typeof T!="number"){if(Q9(T)!=="auto")throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${T}`);return"auto"}let W=Math.floor(T);if(!Number.isFinite(W)||W<0||W>9)throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${T}`);return W}function r8($,T){switch($){case"minute":return{precision:"minute",unit:"minute",increment:1};case"second":return{precision:0,unit:"second",increment:1};case"millisecond":return{precision:3,unit:"millisecond",increment:1};case"microsecond":return{precision:6,unit:"microsecond",increment:1};case"nanosecond":return{precision:9,unit:"nanosecond",increment:1}}switch(T){case"auto":return{precision:T,unit:"nanosecond",increment:1};case 0:return{precision:T,unit:"second",increment:1};case 1:case 2:case 3:return{precision:T,unit:"millisecond",increment:10**(3-T)};case 4:case 5:case 6:return{precision:T,unit:"microsecond",increment:10**(6-T)};case 7:case 8:case 9:return{precision:T,unit:"nanosecond",increment:10**(9-T)};default:throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${T}`)}}var c0=Symbol("~required~");function h6($,T,W,U,X=[]){let Y=[];for(let z=0;z<n2.length;z++){let F=n2[z],O=F[1],Q=F[2];W!=="datetime"&&W!==Q||Y.push(O)}Y=Y.concat(X);let w=U;w===c0?w=void 0:w!==void 0&&Y.push(w);let G=[];G=G.concat(Y);for(let z=0;z<Y.length;z++){let F=Y[z],O=Pb[F];O!==void 0&&G.push(O)}let H=g0($,T,G,w);if(H===void 0&&U===c0)throw new RangeError(`${T} is required`);return H&&H in bA?bA[H]:H}function MO($){let T=$.relativeTo;if(T===void 0)return{};let W,U,X,Y,w,G="option",H=!1;if(Q4(T)){if(_$(T))return{zonedRelativeTo:T};if(F4(T))return{plainRelativeTo:T};if(n$(T))return{plainRelativeTo:N6(D(T,W4).isoDate,D(T,m))};X=s8(T);let z=H1(X,T,["year","month","monthCode","day"],["hour","minute","second","millisecond","microsecond","nanosecond","offset","timeZone"],[]);({isoDate:W,time:U}=i8(X,z,"constrain")),{offset:w,timeZone:Y}=z,w===void 0&&(G="wall")}else{let z,F,O,Q,Z;if({year:O,month:Q,day:Z,time:U,calendar:X,tzAnnotation:z,offset:w,z:F}=G0(S4(T)),z)Y=L6(z),F?G="exact":w||(G="wall"),H=!0;else if(F)throw new RangeError("Z designator not supported for PlainDate relativeTo; either remove the Z or add a bracketed time zone");X||(X="iso8601"),X=R6(X),W={year:O,month:Q,day:Z}}return Y===void 0?{plainRelativeTo:N6(W,X)}:{zonedRelativeTo:s4($9(W,U,G,G==="option"?XU(w):0,Y,"compatible","reject",H),Y,X)}}function x0($){return D($,O6)!==0?"year":D($,Q6)!==0?"month":D($,b6)!==0?"week":D($,Z6)!==0?"day":D($,D6)!==0?"hour":D($,V6)!==0?"minute":D($,K6)!==0?"second":D($,E6)!==0?"millisecond":D($,A6)!==0?"microsecond":"nanosecond"}function y0($,T){return C8.indexOf($)>C8.indexOf(T)?T:$}function $0($){return $==="year"||$==="month"||$==="week"}function I0($){return $0($)||$==="day"?"date":"time"}function CT($){return r4("%calendarImpl%")($)}function n8($){return r4("%calendarImpl%")(D($,m))}function J6($,T,W="date"){let U=Object.create(null),X=CT($).isoToDate(T,{year:!0,monthCode:!0,day:!0});return U.monthCode=X.monthCode,W!=="month-day"&&W!=="date"||(U.day=X.day),W!=="year-month"&&W!=="date"||(U.year=X.year),U}function H1($,T,W,U,X){let Y=CT($).extraFields(W),w=W.concat(U,Y),G=Object.create(null),H=!1;w.sort();for(let z=0;z<w.length;z++){let F=w[z],O=T[F];if(O!==void 0)H=!0,G[F]=vb[F](O);else if(X!=="partial"){if(X.includes(F))throw new TypeError(`required property '${F}' missing or undefined`);G[F]=qb[F]}}if(X==="partial"&&!H)throw new TypeError("no supported properties found");return G}function jO($,T="complete"){let W=["hour","microsecond","millisecond","minute","nanosecond","second"],U=!1,X=Object.create(null);for(let Y=0;Y<W.length;Y++){let w=W[Y],G=$[w];G!==void 0?(X[w]=V$(G),U=!0):T==="complete"&&(X[w]=0)}if(!U)throw new TypeError("invalid time-like");return X}function L8($,T){if(Q4($)){if(F4($))return C$($$(T)),N6(D($,O$),D($,m));if(_$($)){let H=N1(D($,b$),D($,F$));return C$($$(T)),N6(H.isoDate,D($,m))}if(n$($))return C$($$(T)),N6(D($,W4).isoDate,D($,m));let G=s8($);return N6(PT(G,H1(G,$,["year","month","monthCode","day"],[],[]),C$($$(T))),G)}let{year:W,month:U,day:X,calendar:Y,z:w}=G0(S4($));if(w)throw new RangeError("Z designator not supported for PlainDate");return Y||(Y="iso8601"),Y=R6(Y),C$($$(T)),N6({year:W,month:U,day:X},Y)}function i8($,T,W){return B$(PT($,T,W),D9(T.hour,T.minute,T.second,T.millisecond,T.microsecond,T.nanosecond,W))}function J8($,T){let W,U,X;if(Q4($)){if(n$($))return C$($$(T)),E1(D($,W4),D($,m));if(_$($)){let G=N1(D($,b$),D($,F$));return C$($$(T)),E1(G,D($,m))}if(F4($))return C$($$(T)),E1(B$(D($,O$),{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),D($,m));X=s8($);let Y=H1(X,$,["year","month","monthCode","day"],["hour","minute","second","millisecond","microsecond","nanosecond"],[]),w=C$($$(T));({isoDate:W,time:U}=i8(X,Y,w))}else{let Y,w,G,H;if({year:w,month:G,day:H,time:U,calendar:X,z:Y}=G0(S4($)),Y)throw new RangeError("Z designator not supported for PlainDateTime");U==="start-of-day"&&(U={deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),nO(w,G,H,U.hour,U.minute,U.second,U.millisecond,U.microsecond,U.nanosecond),X||(X="iso8601"),X=R6(X),C$($$(T)),W={year:w,month:G,day:H}}return E1(B$(W,U),X)}function M1($){let T=r4("%Temporal.Duration%");if(H4($))return new T(D($,O6),D($,Q6),D($,b6),D($,Z6),D($,D6),D($,V6),D($,K6),D($,E6),D($,A6),D($,f6));if(!Q4($))return function(X){let{years:Y,months:w,weeks:G,days:H,hours:z,minutes:F,seconds:O,milliseconds:Q,microseconds:Z,nanoseconds:V}=function(E){let N=Mb.exec(E);if(!N)throw new RangeError(`invalid duration: ${E}`);if(N.every((g,G$)=>G$<2||g===void 0))throw new RangeError(`invalid duration: ${E}`);let J=N[1]==="-"?-1:1,_=N[2]===void 0?0:V$(N[2])*J,R=N[3]===void 0?0:V$(N[3])*J,P=N[4]===void 0?0:V$(N[4])*J,x=N[5]===void 0?0:V$(N[5])*J,f=N[6]===void 0?0:V$(N[6])*J,h=N[7],a=N[8],M$=N[9],S=N[10],W$=N[11],n=0,Y$=0,j$=0;if(h!==void 0){if(a??M$??S??W$)throw new RangeError("only the smallest unit can be fractional");j$=3600*V$((h+"000000000").slice(0,9))*J}else if(n=a===void 0?0:V$(a)*J,M$!==void 0){if(S??W$)throw new RangeError("only the smallest unit can be fractional");j$=60*V$((M$+"000000000").slice(0,9))*J}else Y$=S===void 0?0:V$(S)*J,W$!==void 0&&(j$=V$((W$+"000000000").slice(0,9))*J);let s$=j$%1000,f4=Math.trunc(j$/1000)%1000,n6=Math.trunc(j$/1e6)%1000;return Y$+=Math.trunc(j$/1e9)%60,n+=Math.trunc(j$/60000000000),A9(_,R,P,x,f,n,Y$,n6,f4,s$),{years:_,months:R,weeks:P,days:x,hours:f,minutes:n,seconds:Y$,milliseconds:n6,microseconds:f4,nanoseconds:s$}}(X);return new(r4("%Temporal.Duration%"))(Y,w,G,H,z,F,O,Q,Z,V)}(S4($));let W={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0},U=BM($);for(let X=0;X<eG.length;X++){let Y=eG[X],w=U[Y];w!==void 0&&(W[Y]=w)}return new T(W.years,W.months,W.weeks,W.days,W.hours,W.minutes,W.seconds,W.milliseconds,W.microseconds,W.nanoseconds)}function _8($){let T;if(Q4($)){if(d4($)||_$($))return b1(D($,F$));T=CO($)}else T=$;let{year:W,month:U,day:X,time:Y,offset:w,z:G}=function(E){let N=G0(E);if(!N.z&&!N.offset)throw new RangeError("Temporal.Instant requires a time zone offset");return N}(S4(T)),{hour:H=0,minute:z=0,second:F=0,millisecond:O=0,microsecond:Q=0,nanosecond:Z=0}=Y==="start-of-day"?{}:Y,V=g8(W,U,X,H,z,F,O,Q,Z-(G?0:XU(w)));return o2(V.isoDate),b1(l4(V))}function yA($,T){if(Q4($)){if(X1($))return C$($$(T)),p2(D($,O$),D($,m));let G;return _6($,m)?G=D($,m):(G=$.calendar,G===void 0&&(G="iso8601"),G=a8(G)),p2(T9(G,H1(G,$,["year","month","monthCode","day"],[],[]),C$($$(T))),G)}let{month:W,day:U,referenceISOYear:X,calendar:Y}=dO(S4($));if(Y===void 0&&(Y="iso8601"),Y=R6(Y),C$($$(T)),Y==="iso8601")return p2({year:1972,month:W,day:U},Y);let w={year:X,month:W,day:U};return bW(w),w=T9(Y,J6(Y,w,"month-day"),"constrain"),p2(w,Y)}function _T($,T){let W;if(Q4($)){if(K4($))return C$($$(T)),b0(D($,O4));if(n$($))return C$($$(T)),b0(D($,W4).time);if(_$($)){let z=N1(D($,b$),D($,F$));return C$($$(T)),b0(z.time)}let{hour:U,minute:X,second:Y,millisecond:w,microsecond:G,nanosecond:H}=jO($);W=D9(U,X,Y,w,G,H,C$($$(T)))}else W=PM(S4($)),C$($$(T));return b0(W)}function xM($){return $===void 0?{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}:D(_T($),O4)}function R8($,T){if(Q4($)){if(o4($))return C$($$(T)),d2(D($,O$),D($,m));let G=s8($);return d2(f8(G,H1(G,$,["year","month","monthCode"],[],[]),C$($$(T))),G)}let{year:W,month:U,referenceISODay:X,calendar:Y}=pO(S4($));Y===void 0&&(Y="iso8601"),Y=R6(Y),C$($$(T));let w={year:W,month:U,day:X};return iO(w),w=f8(Y,J6(Y,w,"year-month"),"constrain"),d2(w,Y)}function $9($,T,W,U,X,Y,w,G){if(T==="start-of-day")return LT(X,$);let H=B$($,T);if(W==="wall"||w==="ignore")return $6(X,H,Y);if(W==="exact"||w==="use"){let O=g8($.year,$.month,$.day,T.hour,T.minute,T.second,T.millisecond,T.microsecond,T.nanosecond-U);o2(O.isoDate);let Q=l4(O);return Y0(Q),Q}o2($);let z=l4(H),F=y8(X,H);for(let O=0;O<F.length;O++){let Q=F[O],Z=q.toNumber(q.subtract(z,Q)),V=RT(Z,60000000000,"halfExpand");if(Z===U||G&&V===U)return Q}if(w==="reject"){let O=BO(U),Q=h8(H,"iso8601","auto");throw new RangeError(`Offset ${O} is invalid for ${Q} in ${X}`)}return uM(F,X,H,Y)}function k8($,T){let W,U,X,Y,w,G,H,z=!1,F="option";if(Q4($)){if(_$($)){let E=$$(T);return j8(E),iG(E,"reject"),C$(E),s4(D($,F$),D($,b$),D($,m))}w=s8($);let Q=H1(w,$,["year","month","monthCode","day"],["hour","minute","second","millisecond","microsecond","nanosecond","offset","timeZone"],["timeZone"]);({offset:Y,timeZone:X}=Q),Y===void 0&&(F="wall");let Z=$$(T);G=j8(Z),H=iG(Z,"reject");let V=C$(Z);({isoDate:W,time:U}=i8(w,Q,V))}else{let Q,Z,V,E,N;({year:V,month:E,day:N,time:U,tzAnnotation:Q,offset:Y,z:Z,calendar:w}=function(_){let R=G0(_);if(!R.tzAnnotation)throw new RangeError("Temporal.ZonedDateTime requires a time zone ID in brackets");return R}(S4($))),X=L6(Q),Z?F="exact":Y||(F="wall"),w||(w="iso8601"),w=R6(w),z=!0;let J=$$(T);G=j8(J),H=iG(J,"reject"),C$(J),W={year:V,month:E,day:N}}let O=0;return F==="option"&&(O=XU(Y)),s4($9(W,U,F,O,X,G,H,z),X,w)}function IM($,T,W){bW(T),u0($),L$($,O$,T),L$($,m,W),L$($,OM,!0)}function N6($,T){let W=r4("%Temporal.PlainDate%"),U=Object.create(W.prototype);return IM(U,$,T),U}function bM($,T,W){SW(T),u0($),L$($,W4,T),L$($,m,W)}function E1($,T){let W=r4("%Temporal.PlainDateTime%"),U=Object.create(W.prototype);return bM(U,$,T),U}function fM($,T,W){bW(T),u0($),L$($,O$,T),L$($,m,W),L$($,ZM,!0)}function p2($,T){let W=r4("%Temporal.PlainMonthDay%"),U=Object.create(W.prototype);return fM(U,$,T),U}function yM($,T){u0($),L$($,O4,T)}function b0($){let T=r4("%Temporal.PlainTime%"),W=Object.create(T.prototype);return yM(W,$),W}function hM($,T,W){iO(T),u0($),L$($,O$,T),L$($,m,W),L$($,QM,!0)}function d2($,T){let W=r4("%Temporal.PlainYearMonth%"),U=Object.create(W.prototype);return hM(U,$,T),U}function gM($,T){Y0(T),u0($),L$($,F$,T)}function b1($){let T=r4("%Temporal.Instant%"),W=Object.create(T.prototype);return gM(W,$),W}function mM($,T,W,U){Y0(T),u0($),L$($,F$,T),L$($,b$,W),L$($,m,U)}function s4($,T,W="iso8601"){let U=r4("%Temporal.ZonedDateTime%"),X=Object.create(U.prototype);return mM(X,$,T,W),X}function hA($){return SO.filter((T)=>$[T]!==void 0)}function PW($,T,W){let U=hA(W),X=CT($).fieldKeysToIgnore(U),Y=Object.create(null),w=hA(T);for(let G=0;G<SO.length;G++){let H,z=SO[G];w.includes(z)&&!X.includes(z)&&(H=T[z]),U.includes(z)&&(H=W[z]),H!==void 0&&(Y[z]=H)}return Y}function G1($,T,W,U){let X=CT($).dateAdd(T,W,U);return bW(X),X}function t8($,T,W,U){return CT($).dateUntil(T,W,U)}function a8($){if(Q4($)&&_6($,m))return D($,m);let T=S4($);try{return R6(T)}catch{}let W;try{({calendar:W}=G0(T))}catch{try{({calendar:W}=PM(T))}catch{try{({calendar:W}=pO(T))}catch{({calendar:W}=dO(T))}}}return W||(W="iso8601"),R6(W)}function s8($){if(_6($,m))return D($,m);let{calendar:T}=$;return T===void 0?"iso8601":a8(T)}function X0($,T){return R6($)===R6(T)}function PT($,T,W){let U=CT($);U.resolveFields(T,"date");let X=U.dateToISO(T,W);return bW(X),X}function f8($,T,W){let U=CT($);U.resolveFields(T,"year-month"),T.day=1;let X=U.dateToISO(T,W);return iO(X),X}function T9($,T,W){let U=CT($);U.resolveFields(T,"month-day");let X=U.monthDayToISOReferenceDate(T,W);return bW(X),X}function L6($){if(Q4($)&&_$($))return D($,b$);let T=S4($);if(T==="UTC")return"UTC";let{tzName:W,offsetMinutes:U}=function(Y){let{tzAnnotation:w,offset:G,z:H}=function(z){if(CM.test(z))return{tzAnnotation:z,offset:void 0,z:!1};try{let{tzAnnotation:F,offset:O,z:Q}=G0(z);if(Q||F||O)return{tzAnnotation:F,offset:O,z:Q}}catch{}jM(z)}(Y);return w?kT(w):H?kT("UTC"):G?kT(G):void 0}(T);if(U!==void 0)return oO(U);let X=W9(W);if(!X)throw new RangeError(`Unrecognized time zone ${W}`);return X.identifier}function cM($,T){if($===T)return!0;let W=kT($).offsetMinutes,U=kT(T).offsetMinutes;if(W===void 0&&U===void 0){let X=W9(T);if(!X)return!1;let Y=W9($);return!!Y&&Y.primaryIdentifier===X.primaryIdentifier}return W===U}function f0($,T){let W=kT($).offsetMinutes;return W!==void 0?60000000000*W:xO($,T)}function BO($){let T=$<0?"-":"+",W=Math.abs($),U=Math.floor(W/3600000000000),X=Math.floor(W/60000000000)%60,Y=Math.floor(W/1e9)%60,w=W%1e9;return`${T}${V9(U,X,Y,w,Y===0&&w===0?"minute":"auto")}`}function N1($,T){let W=f0($,T),{isoDate:{year:U,month:X,day:Y},time:{hour:w,minute:G,second:H,millisecond:z,microsecond:F,nanosecond:O}}=oM(T);return g8(U,X,Y,w,G,H,z,F,O+W)}function $6($,T,W){return uM(y8($,T),$,T,W)}function uM($,T,W,U){let X=$.length;if(X===1)return $[0];if(X)switch(U){case"compatible":case"earlier":return $[0];case"later":return $[X-1];case"reject":throw new RangeError("multiple instants found")}if(U==="reject")throw new RangeError("multiple instants found");let Y=l4(W),w=q.subtract(Y,vT);Y0(w);let G=f0(T,w),H=q.add(Y,vT);Y0(H);let z=f0(T,H)-G;switch(U){case"earlier":{let F=R$.fromComponents(0,0,0,0,0,-z),O=t2(W.time,F);return y8(T,B$(g6(W.isoDate.year,W.isoDate.month,W.isoDate.day+O.deltaDays),O))[0]}case"compatible":case"later":{let F=R$.fromComponents(0,0,0,0,0,z),O=t2(W.time,F),Q=y8(T,B$(g6(W.isoDate.year,W.isoDate.month,W.isoDate.day+O.deltaDays),O));return Q[Q.length-1]}}}function y8($,T){if($==="UTC")return o2(T.isoDate),[l4(T)];let W=kT($).offsetMinutes;if(W!==void 0){let U=g8(T.isoDate.year,T.isoDate.month,T.isoDate.day,T.time.hour,T.time.minute-W,T.time.second,T.time.millisecond,T.time.microsecond,T.time.nanosecond);o2(U.isoDate);let X=l4(U);return Y0(X),[X]}return o2(T.isoDate),function(U,X){let Y=l4(X),w=q.subtract(Y,vT);q.lessThan(w,I8)&&(w=Y);let G=q.add(Y,vT);q.greaterThan(G,r2)&&(G=Y);let H=xO(U,w),z=xO(U,G);return(H===z?[H]:[H,z]).map((O)=>{let Q=q.subtract(Y,q.BigInt(O)),Z=function(V,E){let{epochMilliseconds:N,time:{millisecond:J,microsecond:_,nanosecond:R}}=oM(E),{year:P,month:x,day:f,hour:h,minute:a,second:M$}=lM(V,N);return g8(P,x,f,h,a,M$,J,_,R)}(U,Q);if(a2(X,Z)===0)return Y0(Q),Q}).filter((O)=>O!==void 0)}($,T)}function LT($,T){let W=B$(T,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),U=y8($,W);if(U.length)return U[0];let X=l4(W),Y=q.subtract(X,vT);return Y0(Y),rO($,Y)}function e8($){let T;return T=$<0||$>9999?($<0?"-":"+")+b8(Math.abs($),6):b8($,4),T}function z1($){return b8($,2)}function pM($,T){let W;if(T==="auto"){if($===0)return"";W=b8($,9).replace(/0+$/,"")}else{if(T===0)return"";W=b8($,9).slice(0,T)}return`.${W}`}function V9($,T,W,U,X){let Y=`${z1($)}:${z1(T)}`;return X==="minute"||(Y+=`:${z1(W)}`,Y+=pM(U,X)),Y}function gA($,T,W){let U=T;U===void 0&&(U="UTC");let X=D($,F$),Y=h8(N1(U,X),"iso8601",W,"never"),w="Z";return T!==void 0&&(w=dM(f0(U,X))),`${Y}${w}`}function nG($,T){let W=D($,O6),U=D($,Q6),X=D($,b6),Y=D($,Z6),w=D($,D6),G=D($,V6),H=X9($),z="";W!==0&&(z+=`${Math.abs(W)}Y`),U!==0&&(z+=`${Math.abs(U)}M`),X!==0&&(z+=`${Math.abs(X)}W`),Y!==0&&(z+=`${Math.abs(Y)}D`);let F="";w!==0&&(F+=`${Math.abs(w)}H`),G!==0&&(F+=`${Math.abs(G)}M`);let O=R$.fromComponents(0,0,D($,K6),D($,E6),D($,A6),D($,f6));O.isZero()&&!["second","millisecond","microsecond","nanosecond"].includes(x0($))&&T==="auto"||(F+=`${Math.abs(O.sec)}${pM(Math.abs(O.subsec),T)}S`);let Q=`${H<0?"-":""}P${z}`;return F&&(Q=`${Q}T${F}`),Q}function mA($,T="auto"){let{year:W,month:U,day:X}=D($,O$);return`${e8(W)}-${z1(U)}-${z1(X)}${d8(D($,m),T)}`}function cA({hour:$,minute:T,second:W,millisecond:U,microsecond:X,nanosecond:Y},w){return V9($,T,W,1e6*U+1000*X+Y,w)}function h8($,T,W,U="auto"){let{isoDate:{year:X,month:Y,day:w},time:{hour:G,minute:H,second:z,millisecond:F,microsecond:O,nanosecond:Q}}=$;return`${e8(X)}-${z1(Y)}-${z1(w)}T${V9(G,H,z,1e6*F+1000*O+Q,W)}${d8(T,U)}`}function uA($,T="auto"){let{year:W,month:U,day:X}=D($,O$),Y=`${z1(U)}-${z1(X)}`,w=D($,m);T!=="always"&&T!=="critical"&&w==="iso8601"||(Y=`${e8(W)}-${Y}`);let G=d8(w,T);return G&&(Y+=G),Y}function pA($,T="auto"){let{year:W,month:U,day:X}=D($,O$),Y=`${e8(W)}-${z1(U)}`,w=D($,m);T!=="always"&&T!=="critical"&&w==="iso8601"||(Y+=`-${z1(X)}`);let G=d8(w,T);return G&&(Y+=G),Y}function dA($,T,W="auto",U="auto",X="auto",Y=void 0){let w=D($,F$);if(Y){let{unit:F,increment:O,roundingMode:Q}=Y;w=yO(w,O,F,Q)}let G=D($,b$),H=f0(G,w),z=h8(N1(G,w),"iso8601",T,"never");return X!=="never"&&(z+=dM(H)),U!=="never"&&(z+=`[${U==="critical"?"!":""}${G}]`),z+=d8(D($,m),W),z}function oA($){return SM.test($)}function XU($){let T=Bb.exec($);if(!T)throw new RangeError(`invalid time zone offset: ${$}; must match \xB1HH:MM[:SS.SSSSSSSSS]`);return(T[1]==="-"?-1:1)*(1e9*(60*(60*+T[2]+ +(T[3]||0))+ +(T[4]||0))+ +((T[5]||0)+"000000000").slice(0,9))}var K8,Sb=Object.assign(Object.create(null),{"/":!0,"-":!0,_:!0});function W9($){if(K8===void 0){let Y=Intl.supportedValuesOf?.("timeZone");if(Y){K8=new Map;for(let w=0;w<Y.length;w++){let G=Y[w];K8.set(m8(G),G)}}else K8=null}let T=m8($),W=K8?.get(T);if(W)return{identifier:W,primaryIdentifier:W};try{W=qM($).resolvedOptions().timeZone}catch{return}if(T==="antarctica/south_pole"&&(W="Antarctica/McMurdo"),kb.has($))throw new RangeError(`${$} is a legacy time zone identifier from ICU. Use ${W} instead`);let U=[...T].map((Y,w)=>w===0||Sb[T[w-1]]?Y.toUpperCase():Y).join("").split("/");if(U.length===1)return T==="gb-eire"?{identifier:"GB-Eire",primaryIdentifier:W}:{identifier:T.length<=3||/[-0-9]/.test(T)?T.toUpperCase():U[0],primaryIdentifier:W};if(U[0]==="Etc")return{identifier:`Etc/${["Zulu","Greenwich","Universal"].includes(U[1])?U[1]:U[1].toUpperCase()}`,primaryIdentifier:W};if(U[0]==="Us")return{identifier:`US/${U[1]}`,primaryIdentifier:W};let X=new Map([["Act","ACT"],["Lhi","LHI"],["Nsw","NSW"],["Dar_Es_Salaam","Dar_es_Salaam"],["Port_Of_Spain","Port_of_Spain"],["Port-Au-Prince","Port-au-Prince"],["Isle_Of_Man","Isle_of_Man"],["Comodrivadavia","ComodRivadavia"],["Knox_In","Knox_IN"],["Dumontdurville","DumontDUrville"],["Mcmurdo","McMurdo"],["Denoronha","DeNoronha"],["Easterisland","EasterIsland"],["Bajanorte","BajaNorte"],["Bajasur","BajaSur"]]);return U[1]=X.get(U[1])??U[1],U.length>2&&(U[2]=X.get(U[2])??U[2]),{identifier:U.join("/"),primaryIdentifier:W}}function vW($,T){let{year:W,month:U,day:X,hour:Y,minute:w,second:G}=lM($,T),H=T%1000;return H<0&&(H+=1000),1e6*(lO({isoDate:{year:W,month:U,day:X},time:{hour:Y,minute:w,second:G,millisecond:H}})-T)}function xO($,T){return vW($,L1(T,"floor"))}function oO($){let T=$<0?"-":"+",W=Math.abs($);return`${T}${V9(Math.floor(W/60),W%60,0,0,"minute")}`}function dM($){return oO(RT($,Nb,"halfExpand")/60000000000)}function lO({isoDate:{year:$,month:T,day:W},time:{hour:U,minute:X,second:Y,millisecond:w}}){let G=$%400,H=($-G)/400,z=new Date;return z.setUTCHours(U,X,Y,w),z.setUTCFullYear(G,T-1,W),z.getTime()+_b*H}function l4($){let T=lO($),W=1000*$.time.microsecond+$.time.nanosecond;return q.add(f1(T),q.BigInt(W))}function oM($){let T=L1($,"trunc"),W=q.toNumber(q.remainder($,u8));W<0&&(W+=1e6,T-=1);let U=Math.floor(W/1000)%1000,X=W%1000,Y=new Date(T);return{epochMilliseconds:T,isoDate:{year:Y.getUTCFullYear(),month:Y.getUTCMonth()+1,day:Y.getUTCDate()},time:{hour:Y.getUTCHours(),minute:Y.getUTCMinutes(),second:Y.getUTCSeconds(),millisecond:Y.getUTCMilliseconds(),microsecond:U,nanosecond:X}}}function rO($,T){if($==="UTC")return null;let W=L1(T,"floor");if(W<P8)return rO($,f1(P8));let U=Date.now(),X=Math.max(W,U)+366*qT*3,Y=W,w=vW($,Y),G=Y,H=w;for(;w===H&&Y<X;){if(G=Y+2*qT*7,G>vM)return null;H=vW($,G),w===H&&(Y=G)}return w===H?null:f1(WN((z)=>vW($,z),Y,G,w,H))}function IO($,T){if($==="UTC")return null;let W=L1(T,"ceil"),U=Date.now(),X=U+366*qT*3;if(W>X){let z=IO($,f1(X));if(z===null||q.lessThan(z,f1(U)))return z}if($==="Africa/Casablanca"||$==="Africa/El_Aaiun"){let z=Date.UTC(2088,0,1);if(z<W)return IO($,f1(z))}let Y=W-1;if(Y<P8)return null;let w=vW($,Y),G=Y,H=w;for(;w===H&&Y>P8;){if(G=Y-2*qT*7,G<P8)return null;H=vW($,G),w===H&&(Y=G)}return w===H?null:f1(WN((z)=>vW($,z),G,Y,H,w))}function lM($,T){return function(W){let U=W.split(/[^\w]+/);if(U.length!==7)throw new RangeError(`expected 7 parts in "${W}`);let X=+U[0],Y=+U[1],w=+U[2],G=U[3];if(G[0]==="b"||G[0]==="B")w=1-w;else if(G[0]!=="a"&&G[0]!=="A")throw new RangeError(`Unknown era ${G} in "${W}`);let H=U[4]==="24"?0:+U[4],z=+U[5],F=+U[6];if(!(Number.isFinite(w)&&Number.isFinite(X)&&Number.isFinite(Y)&&Number.isFinite(H)&&Number.isFinite(z)&&Number.isFinite(F)))throw new RangeError(`Invalid number in "${W}`);return{year:w,month:X,day:Y,hour:H,minute:z,second:F}}(qM($).format(T))}function U9($){return $!==void 0&&!($%4!=0||$%100==0&&$%400!=0)}function qW($,T){return{standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]}[U9($)?"leapyear":"standard"][T-1]}function X9($){let T=[D($,O6),D($,Q6),D($,b6),D($,Z6),D($,D6),D($,V6),D($,K6),D($,E6),D($,A6),D($,f6)];for(let W=0;W<T.length;W++){let U=T[W];if(U!==0)return U<0?-1:1}return 0}function K9($){let T=["years","months","weeks","days"];for(let W=0;W<T.length;W++){let U=$[T[W]];if(U!==0)return U<0?-1:1}return 0}function rM($){let T=K9($.date);return T!==0?T:$.time.sign()}function kW($,T){let W=$,U=T;if(!Number.isFinite(W)||!Number.isFinite(U))throw new RangeError("infinity is out of range");return U-=1,W+=Math.floor(U/12),U%=12,U<0&&(U+=12),U+=1,{year:W,month:U}}function g6($,T,W){let U=$,X=T,Y=W;if(!Number.isFinite(Y))throw new RangeError("infinity is out of range");({year:U,month:X}=kW(U,X));let w=146097;if(Math.abs(Y)>w){let z=Math.trunc(Y/w);U+=400*z,Y-=z*w}let G=0,H=X>2?U:U-1;for(;G=U9(H)?366:365,Y<-G;)U-=1,H-=1,Y+=G;for(H+=1;G=U9(H)?366:365,Y>G;)U+=1,H+=1,Y-=G;for(;Y<1;)({year:U,month:X}=kW(U,X-1)),Y+=qW(U,X);for(;Y>qW(U,X);)Y-=qW(U,X),{year:U,month:X}=kW(U,X+1);return{year:U,month:X,day:Y}}function g8($,T,W,U,X,Y,w,G,H){let z=JT(U,X,Y,w,G,H);return B$(g6($,T,W+z.deltaDays),z)}function JT($,T,W,U,X,Y){let w,G=$,H=T,z=W,F=U,O=X,Q=Y;({div:w,mod:Q}=u2(Q,3)),O+=w,Q<0&&(O-=1,Q+=1000),{div:w,mod:O}=u2(O,3),F+=w,O<0&&(F-=1,O+=1000),z+=Math.trunc(F/1000),F%=1000,F<0&&(z-=1,F+=1000),H+=Math.trunc(z/60),z%=60,z<0&&(H-=1,z+=60),G+=Math.trunc(H/60),H%=60,H<0&&(G-=1,H+=60);let Z=Math.trunc(G/24);return G%=24,G<0&&(Z-=1,G+=24),Z+=0,G+=0,H+=0,z+=0,F+=0,O+=0,Q+=0,{deltaDays:Z,hour:G,minute:H,second:z,millisecond:F,microsecond:O,nanosecond:Q}}function lA($,T){let W=e4($,0);if(K9(W)===0)return $.days;let U=D(T,O$),X=G1(D(T,m),U,W,"constrain"),Y=jW(U.year,U.month-1,U.day),w=jW(X.year,X.month-1,X.day)-Y;return $.days+w}function m6($){return new(r4("%Temporal.Duration%"))(-D($,O6),-D($,Q6),-D($,b6),-D($,Z6),-D($,D6),-D($,V6),-D($,K6),-D($,E6),-D($,A6),-D($,f6))}function M6($,T,W){return Math.min(W,Math.max(T,$))}function nM($,T,W){let U=M6(T,1,12);return{year:$,month:U,day:M6(W,1,qW($,U))}}function g4($,T,W){if($<T||$>W)throw new RangeError(`value out of range: ${T} <= ${$} <= ${W}`)}function CW($,T,W){g4(T,1,12),g4(W,1,qW($,T))}function bW($){SW(B$($,{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}))}function E9($,T,W,U,X,Y){g4($,0,23),g4(T,0,59),g4(W,0,59),g4(U,0,999),g4(X,0,999),g4(Y,0,999)}function nO($,T,W,U,X,Y,w,G,H){CW($,T,W),E9(U,X,Y,w,G,H)}function SW($){let T=l4($);(q.lessThan(T,Lb)||q.greaterThan(T,Jb))&&Y0(T)}function bO($){l4($)}function Y0($){if(q.lessThan($,I8)||q.greaterThan($,r2))throw new RangeError("date/time value is outside of supported range")}function iO({year:$,month:T}){g4($,BA,xA),$===BA?g4(T,4,12):$===xA&&g4(T,1,9)}function A9($,T,W,U,X,Y,w,G,H,z){let F=0,O=[$,T,W,U,X,Y,w,G,H,z];for(let J=0;J<O.length;J++){let _=O[J];if(_===1/0||_===-1/0)throw new RangeError("infinite values not allowed as duration fields");if(_!==0){let R=_<0?-1:1;if(F!==0&&R!==F)throw new RangeError("mixed-sign values not allowed as duration fields");F=R}}if(Math.abs($)>=4294967296||Math.abs(T)>=4294967296||Math.abs(W)>=4294967296)throw new RangeError("years, months, and weeks must be < 2\xB3\xB2");let Q=u2(G,3),Z=u2(H,6),V=u2(z,9),E=u2(1e6*Q.mod+1000*Z.mod+V.mod,9).div,N=86400*U+3600*X+60*Y+w+Q.div+Z.div+V.div+E;if(!Number.isSafeInteger(N))throw new RangeError("total of duration time units cannot exceed 9007199254740991.999999999 s")}function c2($){return{date:{years:D($,O6),months:D($,Q6),weeks:D($,b6),days:D($,Z6)},time:R$.fromComponents(D($,D6),D($,V6),D($,K6),D($,E6),D($,A6),D($,f6))}}function W0($){let T=R$.fromComponents(D($,D6),D($,V6),D($,K6),D($,E6),D($,A6),D($,f6)).add24HourDays(D($,Z6));return{date:{years:D($,O6),months:D($,Q6),weeks:D($,b6),days:0},time:T}}function iM($){let T=W0($),W=Math.trunc(T.time.sec/86400);return A9(T.date.years,T.date.months,T.date.weeks,W,0,0,0,0,0,0),{...T.date,days:W}}function A1($,T){let W=$.time.sign(),U=$.time.abs().subsec,X=0,Y=0,w=$.time.abs().sec,G=0,H=0,z=0;switch(T){case"year":case"month":case"week":case"day":X=Math.trunc(U/1000),U%=1000,Y=Math.trunc(X/1000),X%=1000,w+=Math.trunc(Y/1000),Y%=1000,G=Math.trunc(w/60),w%=60,H=Math.trunc(G/60),G%=60,z=Math.trunc(H/24),H%=24;break;case"hour":X=Math.trunc(U/1000),U%=1000,Y=Math.trunc(X/1000),X%=1000,w+=Math.trunc(Y/1000),Y%=1000,G=Math.trunc(w/60),w%=60,H=Math.trunc(G/60),G%=60;break;case"minute":X=Math.trunc(U/1000),U%=1000,Y=Math.trunc(X/1000),X%=1000,w+=Math.trunc(Y/1000),Y%=1000,G=Math.trunc(w/60),w%=60;break;case"second":X=Math.trunc(U/1000),U%=1000,Y=Math.trunc(X/1000),X%=1000,w+=Math.trunc(Y/1000),Y%=1000;break;case"millisecond":X=Math.trunc(U/1000),U%=1000,Y=EO(w,3,Math.trunc(X/1000)),X%=1000,w=0;break;case"microsecond":X=EO(w,6,Math.trunc(U/1000)),U%=1000,w=0;break;case"nanosecond":U=EO(w,9,U),w=0}return new(r4("%Temporal.Duration%"))($.date.years,$.date.months,$.date.weeks,$.date.days+W*z,W*H,W*G,W*w,W*Y,W*X,W*U)}function h0($,T){return K9($),T.sign(),{date:$,time:T}}function jW($,T,W){return lO({isoDate:{year:$,month:T+1,day:W},time:{hour:0,minute:0,second:0,millisecond:0}})/qT}function o2({year:$,month:T,day:W}){if(Math.abs(jW($,T-1,W))>1e8)throw new RangeError("date/time value is outside the supported range")}function tO($,T){let W=T.hour-$.hour,U=T.minute-$.minute,X=T.second-$.second,Y=T.millisecond-$.millisecond,w=T.microsecond-$.microsecond,G=T.nanosecond-$.nanosecond;return R$.fromComponents(W,U,X,Y,w,G)}function aO($,T,W,U,X){let Y=R$.fromEpochNsDiff(T,$);return Y=Y9(Y,W,U,X),h0({years:0,months:0,weeks:0,days:0},Y)}function tM($,T,W,U){bO($),bO(T);let X=tO($.time,T.time),Y=X.sign(),w=w0($.isoDate,T.isoDate),G=T.isoDate;w===Y&&(G=g6(G.year,G.month,G.day+Y),X=X.add24HourDays(-Y));let H=y0("day",U),z=t8(W,$.isoDate,G,H);return U!==H&&(X=X.add24HourDays(z.days),z.days=0),h0(z,X)}function aM($,T,W,U,X){let Y=q.subtract(T,$);if(q.equal(Y,Y1))return{date:{years:0,months:0,weeks:0,days:0},time:R$.ZERO};let w=q.lessThan(Y,Y1)?-1:1,G=N1(W,$),H=N1(W,T),z,F=0,O=w===1?2:1,Q=tO(G.time,H.time);for(Q.sign()===-w&&F++;F<=O;F++){z=B$(g6(H.isoDate.year,H.isoDate.month,H.isoDate.day-F*w),G.time);let V=$6(W,z,"compatible");if(Q=R$.fromEpochNsDiff(T,V),Q.sign()!==-w)break}let Z=y0("day",X);return h0(t8(U,G.isoDate,z.isoDate,Z),Q)}function sM($,T,W,U,X,Y,w,G,H){let z,F,O,Q,Z=T;switch(G){case"year":{let n=RT(Z.date.years,w,"trunc");z=n,F=n+w*$,O={years:z,months:0,weeks:0,days:0},Q={...O,years:F};break}case"month":{let n=RT(Z.date.months,w,"trunc");z=n,F=n+w*$,O=e4(Z.date,0,0,z),Q=e4(Z.date,0,0,F);break}case"week":{let n=e4(Z.date,0,0),Y$=G1(Y,U.isoDate,n,"constrain"),j$=t8(Y,Y$,g6(Y$.year,Y$.month,Y$.day+Z.date.days),"week"),s$=RT(Z.date.weeks+j$.weeks,w,"trunc");z=s$,F=s$+w*$,O=e4(Z.date,0,z),Q=e4(Z.date,0,F);break}case"day":{let n=RT(Z.date.days,w,"trunc");z=n,F=n+w*$,O=e4(Z.date,z),Q=e4(Z.date,F);break}}let V=G1(Y,U.isoDate,O,"constrain"),E=G1(Y,U.isoDate,Q,"constrain"),N,J,_=B$(V,U.time),R=B$(E,U.time);X?(N=$6(X,_,"compatible"),J=$6(X,R,"compatible")):(N=l4(_),J=l4(R));let P=R$.fromEpochNsDiff(W,N),x=R$.fromEpochNsDiff(J,N),f=H9(H,$<0?"negative":"positive"),h=P.add(P).abs().subtract(x.abs()).sign(),a=Math.abs(z)/w%2==0,M$=P.isZero()?Math.abs(z):P.cmp(x)?F9(Math.abs(z),Math.abs(F),h,a,f):Math.abs(F),S=new R$(q.add(q.multiply(x.totalNs,q.BigInt(z)),q.multiply(P.totalNs,q.BigInt(w*$)))).fdiv(x.totalNs),W$=M$===Math.abs(F);return Z={date:W$?Q:O,time:R$.ZERO},{nudgeResult:{duration:Z,nudgedEpochNs:W$?J:N,didExpandCalendarUnit:W$},total:S}}function M9($,T,W,U,X,Y,w,G,H){let z=$,F=$0(G)||U&&G==="day",O=rM(z)<0?-1:1,Q;return F?{nudgeResult:Q}=sM(O,z,T,W,U,X,w,G,H):Q=U?function(Z,V,E,N,J,_,R,P){let x=V,f=G1(J,E.isoDate,x.date,"constrain"),h=B$(f,E.time),a=B$(g6(f.year,f.month,f.day+Z),E.time),M$=$6(N,h,"compatible"),S=$6(N,a,"compatible"),W$=R$.fromEpochNsDiff(S,M$);if(W$.sign()!==Z)throw new RangeError("time zone returned inconsistent Instants");let n=q.BigInt(i2[R]*_),Y$=x.time.round(n,P),j$=Y$.subtract(W$),s$=j$.sign()!==-Z,f4,n6;return s$?(f4=Z,Y$=j$.round(n,P),n6=Y$.addToEpochNs(S)):(f4=0,n6=Y$.addToEpochNs(M$)),{duration:h0(e4(x.date,x.date.days+f4),Y$),nudgedEpochNs:n6,didExpandCalendarUnit:s$}}(O,z,W,U,X,w,G,H):function(Z,V,E,N,J,_){let R=Z,P=R.time.add24HourDays(R.date.days),x=P.round(q.BigInt(N*i2[J]),_),f=x.subtract(P),{quotient:h}=P.divmod(sG),{quotient:a}=x.divmod(sG),M$=Math.sign(a-h)===P.sign(),S=f.addToEpochNs(V),W$=0,n=x;return I0(E)==="date"&&(W$=a,n=x.add(R$.fromComponents(24*-a,0,0,0,0,0))),{duration:{date:e4(R.date,W$),time:n},nudgedEpochNs:S,didExpandCalendarUnit:M$}}(z,T,Y,w,G,H),z=Q.duration,Q.didExpandCalendarUnit&&G!=="week"&&(z=function(Z,V,E,N,J,_,R,P){let x=V;if(P===R)return x;let f=C8.indexOf(R);for(let h=C8.indexOf(P)-1;h>=f;h--){let a=C8[h];if(a==="week"&&R!=="week")continue;let M$;switch(a){case"year":M$={years:x.date.years+Z,months:0,weeks:0,days:0};break;case"month":{let n=x.date.months+Z;M$=e4(x.date,0,0,n);break}case"week":{let n=x.date.weeks+Z;M$=e4(x.date,0,n);break}}let S=B$(G1(_,N.isoDate,M$,"constrain"),N.time),W$;if(W$=J?$6(J,S,"compatible"):l4(S),tG(E,W$)===-Z)break;x={date:M$,time:R$.ZERO}}return x}(O,z,Q.nudgedEpochNs,W,U,X,Y,y0(G,"day"))),z}function rA($,T,W,U,X,Y){return $0(Y)||U&&Y==="day"?sM(rM($)<0?-1:1,$,T,W,U,X,1,Y,"trunc").total:B8($.time.add24HourDays($.date.days),Y)}function eM($,T,W,U,X,Y,w){if(a2($,T)==0)return{date:{years:0,months:0,weeks:0,days:0},time:R$.ZERO};SW($),SW(T);let G=tM($,T,W,U);return Y==="nanosecond"&&X===1?G:M9(G,l4(T),$,null,W,U,X,Y,w)}function $N($,T,W,U,X,Y,w,G){if(I0(X)==="time")return aO($,T,Y,w,G);let H=aM($,T,W,U,X);return w==="nanosecond"&&Y===1?H:M9(H,T,N1(W,$),W,U,X,Y,w,G)}function YU($,T,W,U,X,Y){let w=n2.reduce((Z,V)=>{let E=V[0],N=V[1],J=V[2];return W!=="datetime"&&J!==W||U.includes(N)||Z.push(N,E),Z},[]),G=h6(T,"largestUnit",W,"auto");if(U.includes(G))throw new RangeError(`largestUnit must be one of ${w.join(", ")}, not ${G}`);let H=WU(T),z=y1(T,"trunc");$==="since"&&(z=function(Z){switch(Z){case"ceil":return"floor";case"floor":return"ceil";case"halfCeil":return"halfFloor";case"halfFloor":return"halfCeil";default:return Z}}(z));let F=h6(T,"smallestUnit",W,X);if(U.includes(F))throw new RangeError(`smallestUnit must be one of ${w.join(", ")}, not ${F}`);let O=y0(Y,F);if(G==="auto"&&(G=O),y0(G,F)!==G)throw new RangeError(`largestUnit ${G} cannot be smaller than smallestUnit ${F}`);let Q={hour:24,minute:60,second:60,millisecond:1000,microsecond:1000,nanosecond:1000}[F];return Q!==void 0&&UU(H,Q,!1),{largestUnit:G,roundingIncrement:H,roundingMode:z,smallestUnit:F}}function nA($,T,W,U){let X=_8(W),Y=YU($,$$(U),"time",[],"nanosecond","second"),w=A1(aO(D(T,F$),D(X,F$),Y.roundingIncrement,Y.smallestUnit,Y.roundingMode),Y.largestUnit);return $==="since"&&(w=m6(w)),w}function iA($,T,W,U){let X=L8(W),Y=D(T,m),w=D(X,m);if(!X0(Y,w))throw new RangeError(`cannot compute difference between dates of ${Y} and ${w} calendars`);let G=YU($,$$(U),"date",[],"day","day"),H=r4("%Temporal.Duration%"),z=D(T,O$),F=D(X,O$);if(w0(z,F)===0)return new H;let O={date:t8(Y,z,F,G.largestUnit),time:R$.ZERO};if(G.smallestUnit!=="day"||G.roundingIncrement!==1){let Z=B$(z,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});O=M9(O,l4(B$(F,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0})),Z,null,Y,G.largestUnit,G.roundingIncrement,G.smallestUnit,G.roundingMode)}let Q=A1(O,"day");return $==="since"&&(Q=m6(Q)),Q}function tA($,T,W,U){let X=J8(W),Y=D(T,m),w=D(X,m);if(!X0(Y,w))throw new RangeError(`cannot compute difference between dates of ${Y} and ${w} calendars`);let G=YU($,$$(U),"datetime",[],"nanosecond","day"),H=r4("%Temporal.Duration%"),z=D(T,W4),F=D(X,W4);if(a2(z,F)===0)return new H;let O=A1(eM(z,F,Y,G.largestUnit,G.roundingIncrement,G.smallestUnit,G.roundingMode),G.largestUnit);return $==="since"&&(O=m6(O)),O}function aA($,T,W,U){let X=_T(W),Y=YU($,$$(U),"time",[],"nanosecond","hour"),w=tO(D(T,O4),D(X,O4));w=Y9(w,Y.roundingIncrement,Y.smallestUnit,Y.roundingMode);let G=A1(h0({years:0,months:0,weeks:0,days:0},w),Y.largestUnit);return $==="since"&&(G=m6(G)),G}function sA($,T,W,U){let X=R8(W),Y=D(T,m),w=D(X,m);if(!X0(Y,w))throw new RangeError(`cannot compute difference between months of ${Y} and ${w} calendars`);let G=YU($,$$(U),"date",["week","day"],"month","year"),H=r4("%Temporal.Duration%");if(w0(D(T,O$),D(X,O$))==0)return new H;let z=J6(Y,D(T,O$),"year-month");z.day=1;let F=PT(Y,z,"constrain"),O=J6(Y,D(X,O$),"year-month");O.day=1;let Q=PT(Y,O,"constrain"),Z={date:e4(t8(Y,F,Q,G.largestUnit),0,0),time:R$.ZERO};if(G.smallestUnit!=="month"||G.roundingIncrement!==1){let E=B$(F,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});Z=M9(Z,l4(B$(Q,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0})),E,null,Y,G.largestUnit,G.roundingIncrement,G.smallestUnit,G.roundingMode)}let V=A1(Z,"day");return $==="since"&&(V=m6(V)),V}function eA($,T,W,U){let X=k8(W),Y=D(T,m),w=D(X,m);if(!X0(Y,w))throw new RangeError(`cannot compute difference between dates of ${Y} and ${w} calendars`);let G=YU($,$$(U),"datetime",[],"nanosecond","hour"),H=D(T,F$),z=D(X,F$),F=r4("%Temporal.Duration%"),O;if(I0(G.largestUnit)!=="date")O=A1(aO(H,z,G.roundingIncrement,G.smallestUnit,G.roundingMode),G.largestUnit);else{let Q=D(T,b$);if(!cM(Q,D(X,b$)))throw new RangeError("When calculating difference between time zones, largestUnit must be 'hours' or smaller because day lengths can vary between time zones due to DST or time zone offset changes.");if(q.equal(H,z))return new F;O=A1($N(H,z,Q,Y,G.largestUnit,G.roundingIncrement,G.smallestUnit,G.roundingMode),"hour")}return $==="since"&&(O=m6(O)),O}function t2({hour:$,minute:T,second:W,millisecond:U,microsecond:X,nanosecond:Y},w){let G=W,H=Y;return G+=w.sec,H+=w.subsec,JT($,T,G,U,X,H)}function fO($,T){let W=T.addToEpochNs($);return Y0(W),W}function v8($,T,W,U,X="constrain"){if(K9(U.date)===0)return fO($,U.time);let Y=N1(T,$);return fO($6(T,B$(G1(W,Y.isoDate,U.date,X),Y.time),"compatible"),U.time)}function $M($,T,W){let U=M1(W);$==="subtract"&&(U=m6(U));let X=y0(x0(T),x0(U));if($0(X))throw new RangeError("For years, months, or weeks arithmetic, use date arithmetic relative to a starting point");let Y=W0(T),w=W0(U);return A1(h0({years:0,months:0,weeks:0,days:0},Y.time.add(w.time)),X)}function TM($,T,W){let U=M1(W);$==="subtract"&&(U=m6(U));let X=x0(U);if(I0(X)==="date")throw new RangeError(`Duration field ${X} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);let Y=W0(U);return b1(fO(D(T,F$),Y.time))}function WM($,T,W,U){let X=D(T,m),Y=M1(W);$==="subtract"&&(Y=m6(Y));let w=iM(Y),G=C$($$(U));return N6(G1(X,D(T,O$),w,G),X)}function UM($,T,W,U){let X=M1(W);$==="subtract"&&(X=m6(X));let Y=C$($$(U)),w=D(T,m),G=W0(X),H=D(T,W4),z=t2(H.time,G.time),F=e4(G.date,z.deltaDays);return A9(F.years,F.months,F.weeks,F.days,0,0,0,0,0,0),E1(B$(G1(w,H.isoDate,F,Y),z),w)}function XM($,T,W){let U=M1(W);$==="subtract"&&(U=m6(U));let X=W0(U),{hour:Y,minute:w,second:G,millisecond:H,microsecond:z,nanosecond:F}=t2(D(T,O4),X.time);return b0(D9(Y,w,G,H,z,F,"reject"))}function YM($,T,W,U){let X=M1(W);$==="subtract"&&(X=m6(X));let Y=C$($$(U)),w=X9(X),G=D(T,m),H=J6(G,D(T,O$),"year-month");H.day=1;let z=PT(G,H,"constrain");if(w<0){let O=G1(G,z,{months:1},"constrain");z=g6(O.year,O.month,O.day-1)}let F=iM(X);return bW(z),d2(f8(G,J6(G,G1(G,z,F,Y),"year-month"),Y),G)}function wM($,T,W,U){let X=M1(W);$==="subtract"&&(X=m6(X));let Y=C$($$(U)),w=D(T,b$),G=D(T,m),H=c2(X);return s4(v8(D(T,F$),w,G,H,Y),w,G)}function RT($,T,W){let U=Math.trunc($/T),X=$%T,Y=$<0?"negative":"positive",w=Math.abs(U),G=w+1,H=y6(Math.abs(2*X)-T),z=w%2==0,F=H9(W,Y),O=X===0?w:F9(w,G,H,z,F);return T*(Y==="positive"?O:-O)}function yO($,T,W,U){let X=i2[W]*T;return function(Y,w,G){let H=B0(Y),z=B0(w),F=q.divide(H,z),O=q.remainder(H,z),Q=H9(G,"positive"),Z,V;q.lessThan(H,Y1)?(Z=q.subtract(F,x8),V=F):(Z=F,V=q.add(F,x8));let E=tG(RW(q.multiply(O,uO)),z)*(q.lessThan(H,Y1)?-1:1)+0,N=q.equal(O,Y1)?F:F9(Z,V,E,FM(Z),Q);return q.multiply(N,z)}($,q.BigInt(X),U)}function hO($,T,W,U){bO($);let{year:X,month:Y,day:w}=$.isoDate,G=gO($.time,T,W,U);return B$(g6(X,Y,w+G.deltaDays),G)}function gO({hour:$,minute:T,second:W,millisecond:U,microsecond:X,nanosecond:Y},w,G,H){let z;switch(G){case"day":case"hour":z=1000*(1000*(1000*(60*(60*$+T)+W)+U)+X)+Y;break;case"minute":z=1000*(1000*(1000*(60*T+W)+U)+X)+Y;break;case"second":z=1000*(1000*(1000*W+U)+X)+Y;break;case"millisecond":z=1000*(1000*U+X)+Y;break;case"microsecond":z=1000*X+Y;break;case"nanosecond":z=Y}let F=i2[G],O=RT(z,F*w,H)/F;switch(G){case"day":return{deltaDays:O,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0};case"hour":return JT(O,0,0,0,0,0);case"minute":return JT($,O,0,0,0,0);case"second":return JT($,T,O,0,0,0);case"millisecond":return JT($,T,W,O,0,0);case"microsecond":return JT($,T,W,U,O,0);case"nanosecond":return JT($,T,W,U,X,O);default:throw new Error(`Invalid unit ${G}`)}}function Y9($,T,W,U){let X=i2[W];return $.round(q.BigInt(X*T),U)}function B8($,T){let W=i2[T];return $.fdiv(q.BigInt(W))}function w0($,T){return $.year!==T.year?y6($.year-T.year):$.month!==T.month?y6($.month-T.month):$.day!==T.day?y6($.day-T.day):0}function mO($,T){return $.hour!==T.hour?y6($.hour-T.hour):$.minute!==T.minute?y6($.minute-T.minute):$.second!==T.second?y6($.second-T.second):$.millisecond!==T.millisecond?y6($.millisecond-T.millisecond):$.microsecond!==T.microsecond?y6($.microsecond-T.microsecond):$.nanosecond!==T.nanosecond?y6($.nanosecond-T.nanosecond):0}function a2($,T){let W=w0($.isoDate,T.isoDate);return W!==0?W:mO($.time,T.time)}function TN($){let T=w9($);return globalThis.BigInt!==void 0?globalThis.BigInt(T.toString(10)):T}function L1($,T){let W=B0($),{quotient:U,remainder:X}=M8(W,u8),Y=q.toNumber(U);return T==="floor"&&q.toNumber(X)<0&&(Y-=1),T==="ceil"&&q.toNumber(X)>0&&(Y+=1),Y}function f1($){if(!Number.isInteger($))throw new RangeError("epoch milliseconds must be an integer");return q.multiply(q.BigInt($),u8)}function w9($){let T=$;if(typeof $=="object"){let W=$[Symbol.toPrimitive];W&&typeof W=="function"&&(T=W.call($,"number"))}if(typeof T=="number")throw new TypeError("cannot convert number to bigint");return typeof T=="bigint"?q.BigInt(T.toString(10)):q.BigInt(T)}var cO=(()=>{let $=q.BigInt(Date.now()%1e6);return()=>{let T=Date.now(),W=q.BigInt(T),U=q.add(f1(T),$);return $=q.remainder(W,u8),q.greaterThan(U,r2)?r2:q.lessThan(U,I8)?I8:U}})();function E8(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}function y6($){return $<0?-1:$>0?1:$}function $$($){if($===void 0)return Object.create(null);if(Q4($)&&$!==null)return $;throw new TypeError("Options parameter must be an object, not "+($===null?"null":typeof $))}function BW($,T){let W=Object.create(null);return W[$]=T,W}function g0($,T,W,U){let X=$[T];if(X!==void 0){if(X=Q9(X),!W.includes(X))throw new RangeError(`${T} must be one of ${W.join(", ")}, not ${X}`);return X}if(U===c0)throw new RangeError(`${T} option is required`);return U}function R6($){let T=m8($);if(!Rb.includes(m8(T)))throw new RangeError(`invalid calendar identifier ${T}`);switch(T){case"ethiopic-amete-alem":return"ethioaa";case"islamicc":return"islamic-civil"}return T}function m8($){let T="";for(let W=0;W<$.length;W++){let U=$.charCodeAt(W);T+=U>=65&&U<=90?String.fromCharCode(U+32):String.fromCharCode(U)}return T}function ST($){throw new TypeError(`Do not use built-in arithmetic operators with Temporal objects. When comparing, use ${$==="PlainMonthDay"?"Temporal.PlainDate.compare(obj1.toPlainDate(year), obj2.toPlainDate(year))":`Temporal.${$}.compare(obj1, obj2)`}, not obj1 > obj2. When coercing to strings, use \`\${obj}\` or String(obj), not '' + obj. When coercing to numbers, use properties or methods of the object, not \`+obj\`. When concatenating with strings, use \`\${str}\${obj}\` or str.concat(obj), not str + obj. In React, coerce to a string before rendering a Temporal object.`)}var jb=new RegExp(`^${RM.source}$`),Bb=new RegExp(`^${/([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\d{1,9}))?)?)?/.source}$`);function WN($,T,W,U=$(T),X=$(W)){let Y=T,w=W,G=U,H=X;for(;w-Y>1;){let z=Math.trunc((Y+w)/2),F=$(z);F===G?(Y=z,G=F):F===H&&(w=z,H=F)}return w}function UN($){return[...$]}function XN($,T){if($!=="gregory"&&$!=="iso8601")return;let W=$Y[$],U=T.year,{dayOfWeek:X,dayOfYear:Y,daysInYear:w}=W.isoToDate(T,{dayOfWeek:!0,dayOfYear:!0,daysInYear:!0}),G=W.getFirstDayOfWeek(),H=W.getMinimalDaysInFirstWeek(),z=(X+7-G)%7,F=(X-Y+7001-G)%7,O=Math.floor((Y-1+F)/7);if(7-F>=H&&++O,O==0)O=function(Q,Z,V,E){let N=(E-Q-V+1)%7;N<0&&(N+=7);let J=Math.floor((V+N-1)/7);return 7-N>=Z&&++J,J}(G,H,Y+W.isoToDate(W.dateAdd(T,{years:-1},"constrain"),{daysInYear:!0}).daysInYear,X),U--;else if(Y>=w-5){let Q=(z+w-Y)%7;Q<0&&(Q+=7),6-Q>=H&&Y+7-z>w&&(O=1,U++)}return{week:O,year:U}}function GM($,T,W,U,X){if(T!==X.year){if($*(T-X.year)>0)return!0}else if(W!==X.month){if($*(W-X.month)>0)return!0}else if(U!==X.day&&$*(U-X.day)>0)return!0;return!1}var $Y={};function xW($){if(!$.startsWith("M"))throw new RangeError(`Invalid month code: ${$}. Month codes must start with M.`);let T=+$.slice(1);if(Number.isNaN(T))throw new RangeError(`Invalid month code: ${$}`);return T}function U0($,T=!1){return`M${`${$}`.padStart(2,"0")}${T?"L":""}`}function sO($,T=void 0,W=12){let{month:U,monthCode:X}=$;if(X===void 0){if(U===void 0)throw new TypeError("Either month or monthCode are required");T==="reject"&&g4(U,1,W),T==="constrain"&&(U=M6(U,1,W)),X=U0(U)}else{let Y=xW(X);if(X!==U0(Y))throw new RangeError(`Invalid month code: ${X}`);if(U!==void 0&&U!==Y)throw new RangeError(`monthCode ${X} and month ${U} must match if both are present`);if(U=Y,U<1||U>W)throw new RangeError(`Invalid monthCode: ${X}`)}return{...$,month:U,monthCode:X}}$Y.iso8601={resolveFields($,T){if((T==="date"||T==="year-month")&&$.year===void 0)throw new TypeError("year is required");if((T==="date"||T==="month-day")&&$.day===void 0)throw new TypeError("day is required");Object.assign($,sO($))},dateToISO:($,T)=>S8($.year,$.month,$.day,T),monthDayToISOReferenceDate($,T){let{month:W,day:U}=S8($.year??1972,$.month,$.day,T);return{month:W,day:U,year:1972}},extraFields:()=>[],fieldKeysToIgnore($){let T=new Set;for(let W=0;W<$.length;W++){let U=$[W];T.add(U),U==="month"?T.add("monthCode"):U==="monthCode"&&T.add("month")}return UN(T)},dateAdd($,{years:T=0,months:W=0,weeks:U=0,days:X=0},Y){let{year:w,month:G,day:H}=$;return w+=T,G+=W,{year:w,month:G}=kW(w,G),{year:w,month:G,day:H}=S8(w,G,H,Y),H+=X+7*U,g6(w,G,H)},dateUntil($,T,W){let U=-w0($,T);if(U===0)return{years:0,months:0,weeks:0,days:0};let X,Y=0,w=0;if(W==="year"||W==="month"){let F=T.year-$.year;for(F!==0&&(F-=U);!GM(U,$.year+F,$.month,$.day,T);)Y=F,F+=U;let O=U;for(X=kW($.year+Y,$.month+O);!GM(U,X.year,X.month,$.day,T);)w=O,O+=U,X=kW(X.year,X.month+U);W==="month"&&(w+=12*Y,Y=0)}X=kW($.year+Y,$.month+w);let G=nM(X.year,X.month,$.day),H=0,z=jW(T.year,T.month-1,T.day)-jW(G.year,G.month-1,G.day);return W==="week"&&(H=Math.trunc(z/7),z%=7),{years:Y,months:w,weeks:H,days:z}},isoToDate({year:$,month:T,day:W},U){let X={era:void 0,eraYear:void 0,year:$,month:T,day:W,daysInWeek:7,monthsInYear:12};if(U.monthCode&&(X.monthCode=U0(T)),U.dayOfWeek){let Y=T+(T<3?10:-2),w=$-(T<3?1:0),G=Math.floor(w/100),H=w-100*G,z=(W+Math.floor(2.6*Y-0.2)+(H+Math.floor(H/4))+(Math.floor(G/4)-2*G))%7;X.dayOfWeek=z+(z<=0?7:0)}if(U.dayOfYear){let Y=W;for(let w=T-1;w>0;w--)Y+=qW($,w);X.dayOfYear=Y}return U.weekOfYear&&(X.weekOfYear=XN("iso8601",{year:$,month:T,day:W})),U.daysInMonth&&(X.daysInMonth=qW($,T)),(U.daysInYear||U.inLeapYear)&&(X.inLeapYear=U9($),X.daysInYear=X.inLeapYear?366:365),X},getFirstDayOfWeek:()=>1,getMinimalDaysInFirstWeek:()=>4};class h4{constructor($){if(this.map=new Map,this.calls=0,this.hits=0,this.misses=0,$!==void 0){let T=0;for(let W of $.map.entries()){if(++T>h4.MAX_CACHE_ENTRIES)break;this.map.set(...W)}}}get($){let T=this.map.get($);return T&&(this.hits++,this.report()),this.calls++,T}set($,T){this.map.set($,T),this.misses++,this.report()}report(){}setObject($){if(h4.objectMap.get($))throw new RangeError("object already cached");h4.objectMap.set($,this),this.report()}static getCacheForObject($){let T=h4.objectMap.get($);return T||(T=new h4,h4.objectMap.set($,T)),T}}function YN({isoYear:$,isoMonth:T,isoDay:W}){return`${e8($)}-${z1(T)}-${z1(W)}T00:00Z`}function NO($,T){return{years:$.year-T.year,months:$.month-T.month,days:$.day-T.day}}h4.objectMap=new WeakMap,h4.MAX_CACHE_ENTRIES=1000;class jT{constructor(){this.eras=[],this.hasEra=!1,this.erasBeginMidYear=!1}getFormatter(){return this.formatter===void 0&&(this.formatter=new Intl.DateTimeFormat(`en-US-u-ca-${this.id}`,{day:"numeric",month:"numeric",year:"numeric",era:"short",timeZone:"UTC"})),this.formatter}getCalendarParts($){let T=this.getFormatter(),W=new Date($);if($==="-271821-04-19T00:00Z"){let U=T.resolvedOptions();T=new Intl.DateTimeFormat(U.locale,{...U,timeZone:"Etc/GMT+1"}),W=new Date("-271821-04-20T00:00Z")}try{return T.formatToParts(W)}catch(U){throw new RangeError(`Invalid ISO date: ${$}`)}}isoToCalendarDate($,T){let{year:W,month:U,day:X}=$,Y=JSON.stringify({func:"isoToCalendarDate",isoYear:W,isoMonth:U,isoDay:X,id:this.id}),w=T.get(Y);if(w)return w;let G=YN({isoYear:W,isoMonth:U,isoDay:X}),H=this.getCalendarParts(G),z={};for(let O=0;O<H.length;O++){let{type:Q,value:Z}=H[O];if(Q!=="year"&&Q!=="relatedYear"||(this.hasEra?z.eraYear=+Z:z.year=+Z),Q==="month"){let V=/^([0-9]*)(.*?)$/.exec(Z);if(!V||V.length!=3||!V[1]&&!V[2])throw new RangeError(`Unexpected month: ${Z}`);if(z.month=V[1]?+V[1]:1,z.month<1)throw new RangeError(`Invalid month ${Z} from ${G}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10527)`);if(z.month>13)throw new RangeError(`Invalid month ${Z} from ${G}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10529)`);V[2]&&(z.monthExtra=V[2])}Q==="day"&&(z.day=+Z),this.hasEra&&Q==="era"&&Z!=null&&Z!==""&&(z.era=Z.split(" (")[0].normalize("NFD").replace(/[^-0-9 \p{L}]/gu,"").replace(/ /g,"-").toLowerCase())}if(this.hasEra&&z.eraYear===void 0)throw new RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);if(this.hasEra){let O=this.eras.find((Q)=>z.era===Q.genericName);O&&(z.era=O.code)}if(this.reviseIntlEra){let{era:O,eraYear:Q}=this.reviseIntlEra(z,$);z.era=O,z.eraYear=Q}this.checkIcuBugs&&this.checkIcuBugs($);let F=this.adjustCalendarDate(z,T,"constrain",!0);if(F.year===void 0)throw new RangeError(`Missing year converting ${JSON.stringify($)}`);if(F.month===void 0)throw new RangeError(`Missing month converting ${JSON.stringify($)}`);if(F.day===void 0)throw new RangeError(`Missing day converting ${JSON.stringify($)}`);return T.set(Y,F),["constrain","reject"].forEach((O)=>{let Q=JSON.stringify({func:"calendarToIsoDate",year:F.year,month:F.month,day:F.day,overflow:O,id:this.id});T.set(Q,$)}),F}validateCalendarDate($){let{month:T,year:W,day:U,eraYear:X,monthCode:Y,monthExtra:w}=$;if(w!==void 0)throw new RangeError("Unexpected `monthExtra` value");if(W===void 0&&X===void 0)throw new TypeError("year or eraYear is required");if(T===void 0&&Y===void 0)throw new TypeError("month or monthCode is required");if(U===void 0)throw new RangeError("Missing day");if(Y!==void 0){if(typeof Y!="string")throw new RangeError("monthCode must be a string, not "+typeof Y);if(!/^M([01]?\d)(L?)$/.test(Y))throw new RangeError(`Invalid monthCode: ${Y}`)}if(this.hasEra&&$.era===void 0!=($.eraYear===void 0))throw new TypeError("properties era and eraYear must be provided together")}adjustCalendarDate($,T=void 0,W="constrain",U=!1){if(this.calendarType==="lunisolar")throw new RangeError("Override required for lunisolar calendars");let X=$;this.validateCalendarDate(X);let Y=this.monthsInYear(X,T),{month:w,monthCode:G}=X;return{month:w,monthCode:G}=sO(X,W,Y),{...X,month:w,monthCode:G}}regulateMonthDayNaive($,T,W){let U=this.monthsInYear($,W),{month:X,day:Y}=$;return T==="reject"?(g4(X,1,U),g4(Y,1,this.maximumMonthLength($))):(X=M6(X,1,U),Y=M6(Y,1,this.maximumMonthLength({...$,month:X}))),{...$,month:X,day:Y}}calendarToIsoDate($,T="constrain",W){let U=$,X=this.adjustCalendarDate($,W,T,!1);X=this.regulateMonthDayNaive(X,T,W);let{year:Y,month:w,day:G}=X,H=JSON.stringify({func:"calendarToIsoDate",year:Y,month:w,day:G,overflow:T,id:this.id}),z,F=W.get(H);if(F)return F;if(U.year!==void 0&&U.month!==void 0&&U.day!==void 0&&(U.year!==X.year||U.month!==X.month||U.day!==X.day)&&(z=JSON.stringify({func:"calendarToIsoDate",year:U.year,month:U.month,day:U.day,overflow:T,id:this.id}),F=W.get(z),F))return F;let O=this.estimateIsoDate({year:Y,month:w,day:G}),Q=(J)=>{let _=this.addDaysIso(O,J);if(X.day>this.minimumMonthLength(X)){let R=this.isoToCalendarDate(_,W);for(;R.month!==w||R.year!==Y;){if(T==="reject")throw new RangeError(`day ${G} does not exist in month ${w} of year ${Y}`);_=this.addDaysIso(_,-1),R=this.isoToCalendarDate(_,W)}}return _},Z=0,V=this.isoToCalendarDate(O,W),E=NO(X,V);if(E.years!==0||E.months!==0||E.days!==0){let J=365*E.years+30*E.months+E.days;O=this.addDaysIso(O,J),V=this.isoToCalendarDate(O,W),E=NO(X,V),E.years===0&&E.months===0?O=Q(E.days):Z=this.compareCalendarDates(X,V)}let N=8;for(;Z;){O=this.addDaysIso(O,Z*N);let J=V;V=this.isoToCalendarDate(O,W);let _=Z;if(Z=this.compareCalendarDates(X,V),Z){if(E=NO(X,V),E.years===0&&E.months===0)O=Q(E.days),Z=0;else if(_&&Z!==_)if(N>1)N/=2;else{if(T==="reject")throw new RangeError(`Can't find ISO date from calendar date: ${JSON.stringify({...U})}`);this.compareCalendarDates(V,J)>0&&(O=this.addDaysIso(O,-1)),Z=0}}}if(W.set(H,O),z&&W.set(z,O),X.year===void 0||X.month===void 0||X.day===void 0||X.monthCode===void 0||this.hasEra&&(X.era===void 0||X.eraYear===void 0))throw new RangeError("Unexpected missing property");return O}compareCalendarDates($,T){return $.year!==T.year?y6($.year-T.year):$.month!==T.month?y6($.month-T.month):$.day!==T.day?y6($.day-T.day):0}regulateDate($,T="constrain",W){let U=this.calendarToIsoDate($,T,W);return this.isoToCalendarDate(U,W)}addDaysIso($,T){return g6($.year,$.month,$.day+T)}addDaysCalendar($,T,W){let U=this.calendarToIsoDate($,"constrain",W),X=this.addDaysIso(U,T);return this.isoToCalendarDate(X,W)}addMonthsCalendar($,T,W,U){let X=$,{day:Y}=X;for(let w=0,G=Math.abs(T);w<G;w++){let{month:H}=X,z=X,F=T<0?-Math.max(Y,this.daysInPreviousMonth(X,U)):this.daysInMonth(X,U),O=this.calendarToIsoDate(X,"constrain",U),Q=this.addDaysIso(O,F);if(X=this.isoToCalendarDate(Q,U),T>0){let Z=this.monthsInYear(z,U);for(;X.month-1!=H%Z;)Q=this.addDaysIso(Q,-1),X=this.isoToCalendarDate(Q,U)}X.day!==Y&&(X=this.regulateDate({...X,day:Y},"constrain",U))}if(W==="reject"&&X.day!==Y)throw new RangeError(`Day ${Y} does not exist in resulting calendar month`);return X}addCalendar($,{years:T=0,months:W=0,weeks:U=0,days:X=0},Y,w){let{year:G,day:H,monthCode:z}=$,F=this.adjustCalendarDate({year:G+T,monthCode:z,day:H},w),O=this.addMonthsCalendar(F,W,Y,w),Q=X+7*U;return this.addDaysCalendar(O,Q,w)}untilCalendar($,T,W,U){let X=0,Y=0,w=0,G=0;switch(W){case"day":X=this.calendarDaysUntil($,T,U);break;case"week":{let H=this.calendarDaysUntil($,T,U);X=H%7,Y=(H-X)/7;break}case"month":case"year":{let H=this.compareCalendarDates(T,$);if(!H)return{years:0,months:0,weeks:0,days:0};let z=T.year-$.year,F=T.day-$.day;if(W==="year"&&z){let Z=0;T.monthCode>$.monthCode&&(Z=1),T.monthCode<$.monthCode&&(Z=-1),Z||(Z=Math.sign(F)),G=Z*H<0?z-H:z}let O,Q=G?this.addCalendar($,{years:G},"constrain",U):$;do w+=H,O=Q,Q=this.addMonthsCalendar(O,H,"constrain",U),Q.day!==$.day&&(Q=this.regulateDate({...Q,day:$.day},"constrain",U));while(this.compareCalendarDates(T,Q)*H>=0);w-=H,X=this.calendarDaysUntil(O,T,U);break}}return{years:G,months:w,weeks:Y,days:X}}daysInMonth($,T){let{day:W}=$,U=this.maximumMonthLength($),X=this.minimumMonthLength($);if(X===U)return X;let Y=W<=U-X?U:X,w=this.calendarToIsoDate($,"constrain",T),G=this.addDaysIso(w,Y),H=this.isoToCalendarDate(G,T),z=this.addDaysIso(G,-H.day);return this.isoToCalendarDate(z,T).day}daysInPreviousMonth($,T){let{day:W,month:U,year:X}=$,Y={year:U>1?X:X-1,month:U,day:1},w=U>1?U-1:this.monthsInYear(Y,T);Y={...Y,month:w};let G=this.minimumMonthLength(Y),H=this.maximumMonthLength(Y);if(G===H)return H;let z=this.calendarToIsoDate($,"constrain",T),F=this.addDaysIso(z,-W);return this.isoToCalendarDate(F,T).day}startOfCalendarYear($){return{year:$.year,month:1,monthCode:"M01",day:1}}startOfCalendarMonth($){return{year:$.year,month:$.month,day:1}}calendarDaysUntil($,T,W){let U=this.calendarToIsoDate($,"constrain",W),X=this.calendarToIsoDate(T,"constrain",W);return jW(X.year,X.month-1,X.day)-jW(U.year,U.month-1,U.day)}monthDaySearchStartYear($,T){return 1972}monthDayFromFields($,T,W){let U,X,Y,w,G,{era:H,eraYear:z,year:F,month:O,monthCode:Q,day:Z}=$;if(O!==void 0&&F===void 0&&(!this.hasEra||H===void 0||z===void 0))throw new TypeError("when month is present, year (or era and eraYear) are required");(Q===void 0||F!==void 0||this.hasEra&&z!==void 0)&&({monthCode:Q,day:Z}=this.isoToCalendarDate(this.calendarToIsoDate($,T,W),W));let V={year:this.monthDaySearchStartYear(Q,Z),month:12,day:31},E=this.isoToCalendarDate(V,W),N=E.monthCode>Q||E.monthCode===Q&&E.day>=Z?E.year:E.year-1;for(let J=0;J<20;J++){let _=this.adjustCalendarDate({day:Z,monthCode:Q,year:N-J},W),R=this.calendarToIsoDate(_,"constrain",W),P=this.isoToCalendarDate(R,W);if({year:U,month:X,day:Y}=R,P.monthCode===Q&&P.day===Z)return{month:X,day:Y,year:U};if(T==="constrain"){let x=this.maxLengthOfMonthCodeInAnyYear(P.monthCode);if(P.monthCode===Q&&P.day===x&&Z>x)return{month:X,day:Y,year:U};(w===void 0||P.monthCode===w.monthCode&&P.day>w.day)&&(w=P,G=R)}}if(T==="constrain"&&G!==void 0)return G;throw new RangeError(`No recent ${this.id} year with monthCode ${Q} and day ${Z}`)}getFirstDayOfWeek(){}getMinimalDaysInFirstWeek(){}}class wN extends jT{constructor(){super(...arguments),this.id="hebrew",this.calendarType="lunisolar",this.months={Tishri:{leap:1,regular:1,monthCode:"M01",days:30},Heshvan:{leap:2,regular:2,monthCode:"M02",days:{min:29,max:30}},Kislev:{leap:3,regular:3,monthCode:"M03",days:{min:29,max:30}},Tevet:{leap:4,regular:4,monthCode:"M04",days:29},Shevat:{leap:5,regular:5,monthCode:"M05",days:30},Adar:{leap:void 0,regular:6,monthCode:"M06",days:29},"Adar I":{leap:6,regular:void 0,monthCode:"M05L",days:30},"Adar II":{leap:7,regular:void 0,monthCode:"M06",days:29},Nisan:{leap:8,regular:7,monthCode:"M07",days:30},Iyar:{leap:9,regular:8,monthCode:"M08",days:29},Sivan:{leap:10,regular:9,monthCode:"M09",days:30},Tamuz:{leap:11,regular:10,monthCode:"M10",days:29},Av:{leap:12,regular:11,monthCode:"M11",days:30},Elul:{leap:13,regular:12,monthCode:"M12",days:29}}}inLeapYear($){let{year:T}=$;return(7*T+1)%19<7}monthsInYear($){return this.inLeapYear($)?13:12}minimumMonthLength($){return this.minMaxMonthLength($,"min")}maximumMonthLength($){return this.minMaxMonthLength($,"max")}minMaxMonthLength($,T){let{month:W,year:U}=$,X=this.getMonthCode(U,W),Y=Object.entries(this.months).find((G)=>G[1].monthCode===X);if(Y===void 0)throw new RangeError(`unmatched Hebrew month: ${W}`);let w=Y[1].days;return typeof w=="number"?w:w[T]}maxLengthOfMonthCodeInAnyYear($){return["M04","M06","M08","M10","M12"].includes($)?29:30}estimateIsoDate($){let{year:T}=$;return{year:T-3760,month:1,day:1}}getMonthCode($,T){return this.inLeapYear({year:$})?T===6?U0(5,!0):U0(T<6?T:T-1):U0(T)}adjustCalendarDate($,T,W="constrain",U=!1){let{year:X,month:Y,monthCode:w,day:G,monthExtra:H}=$;if(X===void 0)throw new TypeError("Missing property: year");if(U){if(H){let z=this.months[H];if(!z)throw new RangeError(`Unrecognized month from formatToParts: ${H}`);Y=this.inLeapYear({year:X})?z.leap:z.regular}return w=this.getMonthCode(X,Y),{year:X,month:Y,day:G,monthCode:w}}if(this.validateCalendarDate($),Y===void 0)if(w.endsWith("L")){if(w!=="M05L")throw new RangeError(`Hebrew leap month must have monthCode M05L, not ${w}`);if(Y=6,!this.inLeapYear({year:X})){if(W==="reject")throw new RangeError(`Hebrew monthCode M05L is invalid in year ${X} which is not a leap year`);Y=6,w="M06"}}else{Y=xW(w),this.inLeapYear({year:X})&&Y>=6&&Y++;let z=this.monthsInYear({year:X});if(Y<1||Y>z)throw new RangeError(`Invalid monthCode: ${w}`)}else if(W==="reject"?(g4(Y,1,this.monthsInYear({year:X})),g4(G,1,this.maximumMonthLength({year:X,month:Y}))):(Y=M6(Y,1,this.monthsInYear({year:X})),G=M6(G,1,this.maximumMonthLength({year:X,month:Y}))),w===void 0)w=this.getMonthCode(X,Y);else if(this.getMonthCode(X,Y)!==w)throw new RangeError(`monthCode ${w} doesn't correspond to month ${Y} in Hebrew year ${X}`);return{...$,day:G,month:Y,monthCode:w,year:X}}}class fW extends jT{constructor(){super(...arguments),this.calendarType="lunar",this.DAYS_PER_ISLAMIC_YEAR=354.3666666666667,this.DAYS_PER_ISO_YEAR=365.2425}inLeapYear($,T){let W={year:$.year,month:1,monthCode:"M01",day:1},U={year:$.year+1,month:1,monthCode:"M01",day:1};return this.calendarDaysUntil(W,U,T)===355}monthsInYear(){return 12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}maxLengthOfMonthCodeInAnyYear(){return 30}estimateIsoDate($){let{year:T}=this.adjustCalendarDate($);return{year:Math.floor(T*this.DAYS_PER_ISLAMIC_YEAR/this.DAYS_PER_ISO_YEAR)+622,month:1,day:1}}}class GN extends fW{constructor(){super(...arguments),this.id="islamic"}}class zN extends fW{constructor(){super(...arguments),this.id="islamic-umalqura"}}class HN extends fW{constructor(){super(...arguments),this.id="islamic-tbla"}}class FN extends fW{constructor(){super(...arguments),this.id="islamic-civil"}}class ON extends fW{constructor(){super(...arguments),this.id="islamic-rgsa"}}class QN extends fW{constructor(){super(...arguments),this.id="islamicc"}}class ZN extends jT{constructor(){super(...arguments),this.id="persian",this.calendarType="solar"}inLeapYear($,T){return this.daysInMonth({year:$.year,month:12,day:1},T)===30}monthsInYear(){return 12}minimumMonthLength($){let{month:T}=$;return T===12?29:T<=6?31:30}maximumMonthLength($){let{month:T}=$;return T===12?30:T<=6?31:30}maxLengthOfMonthCodeInAnyYear($){return xW($)<=6?31:30}estimateIsoDate($){let{year:T}=this.adjustCalendarDate($);return{year:T+621,month:1,day:1}}}class DN extends jT{constructor(){super(...arguments),this.id="indian",this.calendarType="solar",this.months={1:{length:30,month:3,day:22,leap:{length:31,month:3,day:21}},2:{length:31,month:4,day:21},3:{length:31,month:5,day:22},4:{length:31,month:6,day:22},5:{length:31,month:7,day:23},6:{length:31,month:8,day:23},7:{length:30,month:9,day:23},8:{length:30,month:10,day:23},9:{length:30,month:11,day:22},10:{length:30,month:12,day:22},11:{length:30,month:1,nextYear:!0,day:21},12:{length:30,month:2,nextYear:!0,day:20}},this.vulnerableToBceBug=new Date("0000-01-01T00:00Z").toLocaleDateString("en-US-u-ca-indian",{timeZone:"UTC"})!=="10/11/-79 Saka"}inLeapYear($){return eO($.year+78)}monthsInYear(){return 12}minimumMonthLength($){return this.getMonthInfo($).length}maximumMonthLength($){return this.getMonthInfo($).length}maxLengthOfMonthCodeInAnyYear($){let T=xW($),W=this.months[T];return W=W.leap??W,W.length}getMonthInfo($){let{month:T}=$,W=this.months[T];if(W===void 0)throw new RangeError(`Invalid month: ${T}`);return this.inLeapYear($)&&W.leap&&(W=W.leap),W}estimateIsoDate($){let T=this.adjustCalendarDate($),W=this.getMonthInfo(T);return g6(T.year+78+(W.nextYear?1:0),W.month,W.day+T.day-1)}checkIcuBugs($){if(this.vulnerableToBceBug&&$.year<1)throw new RangeError(`calendar '${this.id}' is broken for ISO dates before 0001-01-01 (see https://bugs.chromium.org/p/v8/issues/detail?id=10529)`)}}function eO($){return $%4==0&&($%100!=0||$%400==0)}class $Q extends jT{constructor($,T){super(),this.calendarType="solar",this.id=$,this.isoEpoch=T}inLeapYear($){let{year:T}=this.estimateIsoDate({month:1,day:1,year:$.year});return eO(T)}monthsInYear(){return 12}minimumMonthLength($){let{month:T}=$;return T===2?this.inLeapYear($)?29:28:[4,6,9,11].indexOf(T)>=0?30:31}maximumMonthLength($){return this.minimumMonthLength($)}maxLengthOfMonthCodeInAnyYear($){return[31,29,31,30,31,30,31,31,30,31,30,31][xW($)-1]}estimateIsoDate($){let T=this.adjustCalendarDate($);return S8(T.year+this.isoEpoch.year,T.month+this.isoEpoch.month,T.day+this.isoEpoch.day,"constrain")}}class TQ extends jT{constructor($,T){super(),this.hasEra=!0,this.calendarType="solar",this.id=$;let{eras:W,anchorEra:U}=function(X){let Y,w=X;if(w.length===0)throw new RangeError("Invalid era data: eras are required");if(w.length===1&&w[0].reverseOf)throw new RangeError("Invalid era data: anchor era cannot count years backwards");if(w.length===1&&!w[0].code)throw new RangeError("Invalid era data: at least one named era is required");if(w.filter((H)=>H.reverseOf!=null).length>1)throw new RangeError("Invalid era data: only one era can count years backwards");w.forEach((H)=>{if(H.isAnchor||!H.anchorEpoch&&!H.reverseOf){if(Y)throw new RangeError("Invalid era data: cannot have multiple anchor eras");Y=H,H.anchorEpoch={year:H.hasYearZero?0:1}}else if(!H.code)throw new RangeError("If era name is blank, it must be the anchor era")}),w=w.filter((H)=>H.code),w.forEach((H)=>{let{reverseOf:z}=H;if(z){let F=w.find((O)=>O.code===z);if(F===void 0)throw new RangeError(`Invalid era data: unmatched reverseOf era: ${z}`);H.reverseOf=F,H.anchorEpoch=F.anchorEpoch,H.isoEpoch=F.isoEpoch}H.anchorEpoch.month===void 0&&(H.anchorEpoch.month=1),H.anchorEpoch.day===void 0&&(H.anchorEpoch.day=1)}),w.sort((H,z)=>{if(H.reverseOf)return 1;if(z.reverseOf)return-1;if(!H.isoEpoch||!z.isoEpoch)throw new RangeError("Invalid era data: missing ISO epoch");return z.isoEpoch.year-H.isoEpoch.year});let G=w[w.length-1].reverseOf;if(G&&G!==w[w.length-2])throw new RangeError("Invalid era data: invalid reverse-sign era");return w.forEach((H,z)=>{H.genericName="era"+(w.length-1-z)}),{eras:w,anchorEra:Y||w[0]}}(T);this.anchorEra=U,this.eras=W}inLeapYear($){let{year:T}=this.estimateIsoDate({month:1,day:1,year:$.year});return eO(T)}monthsInYear(){return 12}minimumMonthLength($){let{month:T}=$;return T===2?this.inLeapYear($)?29:28:[4,6,9,11].indexOf(T)>=0?30:31}maximumMonthLength($){return this.minimumMonthLength($)}maxLengthOfMonthCodeInAnyYear($){return[31,29,31,30,31,30,31,31,30,31,30,31][xW($)-1]}completeEraYear($){let T=(w,G,H)=>{let z=$[w];if(z!=null&&z!=G&&!(H||[]).includes(z)){let F=H?.[0];throw new RangeError(`Input ${w} ${z} doesn't match calculated value ${F?`${G} (also called ${F})`:G}`)}},W=(w)=>{let G,H={...$,year:w},z=this.eras.find((F,O)=>{if(O===this.eras.length-1){if(F.reverseOf){if(w>0)throw new RangeError(`Signed year ${w} is invalid for era ${F.code}`);return G=F.anchorEpoch.year-w,!0}return G=w-F.anchorEpoch.year+(F.hasYearZero?0:1),!0}return this.compareCalendarDates(H,F.anchorEpoch)>=0&&(G=w-F.anchorEpoch.year+(F.hasYearZero?0:1),!0)});if(!z)throw new RangeError(`Year ${w} was not matched by any era`);return{eraYear:G,era:z.code,eraNames:z.names}},{year:U,eraYear:X,era:Y}=$;if(U!=null){let w=W(U);({eraYear:X,era:Y}=w),T("era",Y,w?.eraNames),T("eraYear",X)}else{if(X==null)throw new RangeError("Either year or eraYear and era are required");{if(Y===void 0)throw new RangeError("era and eraYear must be provided together");let w=this.eras.find(({code:G,names:H=[]})=>G===Y||H.includes(Y));if(!w)throw new RangeError(`Era ${Y} (ISO year ${X}) was not matched by any era`);U=w.reverseOf?w.anchorEpoch.year-X:X+w.anchorEpoch.year-(w.hasYearZero?0:1),T("year",U),{eraYear:X,era:Y}=W(U)}}return{...$,year:U,eraYear:X,era:Y}}adjustCalendarDate($,T,W="constrain"){let U=$,{month:X,monthCode:Y}=U;return X===void 0&&(U={...U,month:xW(Y)}),this.validateCalendarDate(U),U=this.completeEraYear(U),super.adjustCalendarDate(U,T,W)}estimateIsoDate($){let T=this.adjustCalendarDate($),{year:W,month:U,day:X}=T,{anchorEra:Y}=this;return S8(W+Y.isoEpoch.year-(Y.hasYearZero?0:1),U,X,"constrain")}}class N9 extends TQ{constructor($,T){super($,T)}isoToCalendarDate($){let{year:T,month:W,day:U}=$,X=U0(W),Y=T-this.anchorEra.isoEpoch.year+1;return this.completeEraYear({year:Y,month:W,monthCode:X,day:U})}}var T0={inLeapYear($){let{year:T}=$;return(T+1)%4==0},monthsInYear:()=>13,minimumMonthLength($){let{month:T}=$;return T===13?this.inLeapYear($)?6:5:30},maximumMonthLength($){return this.minimumMonthLength($)},maxLengthOfMonthCodeInAnyYear:($)=>$==="M13"?6:30};class VN extends $Q{constructor($,T){super($,T),this.inLeapYear=T0.inLeapYear,this.monthsInYear=T0.monthsInYear,this.minimumMonthLength=T0.minimumMonthLength,this.maximumMonthLength=T0.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=T0.maxLengthOfMonthCodeInAnyYear}}class WQ extends TQ{constructor($,T){super($,T),this.inLeapYear=T0.inLeapYear,this.monthsInYear=T0.monthsInYear,this.minimumMonthLength=T0.minimumMonthLength,this.maximumMonthLength=T0.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=T0.maxLengthOfMonthCodeInAnyYear}}class KN extends VN{constructor(){super("ethioaa",{year:-5492,month:7,day:17})}}class EN extends WQ{constructor(){super("coptic",[{code:"coptic",isoEpoch:{year:284,month:8,day:29}},{code:"coptic-inverse",reverseOf:"coptic"}])}}class AN extends WQ{constructor(){super("ethiopic",[{code:"ethioaa",names:["ethiopic-amete-alem","mundi"],isoEpoch:{year:-5492,month:7,day:17}},{code:"ethiopic",names:["incar"],isoEpoch:{year:8,month:8,day:27},anchorEpoch:{year:5501}}])}}class MN extends N9{constructor(){super("roc",[{code:"roc",names:["minguo"],isoEpoch:{year:1912,month:1,day:1}},{code:"roc-inverse",names:["before-roc"],reverseOf:"roc"}])}}class NN extends $Q{constructor(){super("buddhist",{year:-543,month:1,day:1})}}class LN extends N9{constructor(){super("gregory",[{code:"gregory",names:["ad","ce"],isoEpoch:{year:1,month:1,day:1}},{code:"gregory-inverse",names:["be","bce"],reverseOf:"gregory"}])}reviseIntlEra($){let{era:T,eraYear:W}=$;return T==="b"&&(T="gregory-inverse"),T==="a"&&(T="gregory"),{era:T,eraYear:W}}getFirstDayOfWeek(){return 1}getMinimalDaysInFirstWeek(){return 1}}class JN extends N9{constructor(){super("japanese",[{code:"reiwa",isoEpoch:{year:2019,month:5,day:1},anchorEpoch:{year:2019,month:5,day:1}},{code:"heisei",isoEpoch:{year:1989,month:1,day:8},anchorEpoch:{year:1989,month:1,day:8}},{code:"showa",isoEpoch:{year:1926,month:12,day:25},anchorEpoch:{year:1926,month:12,day:25}},{code:"taisho",isoEpoch:{year:1912,month:7,day:30},anchorEpoch:{year:1912,month:7,day:30}},{code:"meiji",isoEpoch:{year:1868,month:9,day:8},anchorEpoch:{year:1868,month:9,day:8}},{code:"japanese",names:["japanese","gregory","ad","ce"],isoEpoch:{year:1,month:1,day:1}},{code:"japanese-inverse",names:["japanese-inverse","gregory-inverse","bc","bce"],reverseOf:"japanese"}]),this.erasBeginMidYear=!0}reviseIntlEra($,T){let{era:W,eraYear:U}=$,{year:X}=T;return this.eras.find((Y)=>Y.code===W)?{era:W,eraYear:U}:X<1?{era:"japanese-inverse",eraYear:1-X}:{era:"japanese",eraYear:X}}}class UQ extends jT{constructor(){super(...arguments),this.calendarType="lunisolar"}inLeapYear($,T){let W=this.getMonthList($.year,T);return Object.entries(W).length===13}monthsInYear($,T){return this.inLeapYear($,T)?13:12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}maxLengthOfMonthCodeInAnyYear($){return["M01L","M09L","M10L","M11L","M12L"].includes($)?29:30}monthDaySearchStartYear($,T){let W={M01L:[1651,1651],M02L:[1947,1765],M03L:[1966,1955],M04L:[1963,1944],M05L:[1971,1952],M06L:[1960,1941],M07L:[1968,1938],M08L:[1957,1718],M09L:[1832,1832],M10L:[1870,1870],M11L:[1814,1814],M12L:[1890,1890]}[$]??[1972,1972];return T<30?W[0]:W[1]}getMonthList($,T){if($===void 0)throw new TypeError("Missing year");let W=JSON.stringify({func:"getMonthList",calendarYear:$,id:this.id}),U=T.get(W);if(U)return U;let X=this.getFormatter(),Y=(E,N)=>{let J=YN({isoYear:E,isoMonth:2,isoDay:1}),_=new Date(J);_.setUTCDate(N+1);let R=X.formatToParts(_),P=R.find((a)=>a.type==="month").value,x=+R.find((a)=>a.type==="day").value,f=R.find((a)=>a.type==="relatedYear"),h;if(f===void 0)throw new RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);return h=+f.value,{calendarMonthString:P,calendarDay:x,calendarYearToVerify:h}},w=17,{calendarMonthString:G,calendarDay:H,calendarYearToVerify:z}=Y($,w);G!=="1"&&(w+=29,{calendarMonthString:G,calendarDay:H}=Y($,w)),w-=H-5;let F={},O,Q,Z=1,V=!1;do({calendarMonthString:G,calendarDay:H,calendarYearToVerify:z}=Y($,w)),O&&(F[Q].daysInMonth=O+30-H),z!==$?V=!0:(F[G]={monthIndex:Z++},w+=30),O=H,Q=G;while(!V);return F[Q].daysInMonth=O+30-H,T.set(W,F),F}estimateIsoDate($){let{year:T,month:W}=$;return{year:T,month:W>=12?12:W+1,day:1}}adjustCalendarDate($,T,W="constrain",U=!1){let{year:X,month:Y,monthExtra:w,day:G,monthCode:H}=$;if(X===void 0)throw new TypeError("Missing property: year");if(U){if(w&&w!=="bis")throw new RangeError(`Unexpected leap month suffix: ${w}`);let z=U0(Y,w!==void 0),F=`${Y}${w||""}`,O=this.getMonthList(X,T)[F];if(O===void 0)throw new RangeError(`Unmatched month ${F} in Chinese year ${X}`);return Y=O.monthIndex,{year:X,month:Y,day:G,monthCode:z}}if(this.validateCalendarDate($),Y===void 0){let z=this.getMonthList(X,T),F=H.replace(/^M|L$/g,(Q)=>Q==="L"?"bis":"");F[0]==="0"&&(F=F.slice(1));let O=z[F];if(Y=O&&O.monthIndex,Y===void 0&&H.endsWith("L")&&H!="M13L"&&W==="constrain"){let Q=+H.replace(/^M0?|L$/g,"");O=z[Q],O&&(Y=O.monthIndex,H=U0(Q))}if(Y===void 0)throw new RangeError(`Unmatched month ${H} in Chinese year ${X}`)}else if(H===void 0){let z=this.getMonthList(X,T),F=Object.entries(z),O=F.length;W==="reject"?(g4(Y,1,O),g4(G,1,this.maximumMonthLength())):(Y=M6(Y,1,O),G=M6(G,1,this.maximumMonthLength()));let Q=F.find((Z)=>Z[1].monthIndex===Y);if(Q===void 0)throw new RangeError(`Invalid month ${Y} in Chinese year ${X}`);H=U0(+Q[0].replace("bis",""),Q[0].indexOf("bis")!==-1)}else{let z=this.getMonthList(X,T),F=H.replace(/^M|L$/g,(Q)=>Q==="L"?"bis":"");F[0]==="0"&&(F=F.slice(1));let O=z[F];if(!O)throw new RangeError(`Unmatched monthCode ${H} in Chinese year ${X}`);if(Y!==O.monthIndex)throw new RangeError(`monthCode ${H} doesn't correspond to month ${Y} in Chinese year ${X}`)}return{...$,year:X,month:Y,monthCode:H,day:G}}}class _N extends UQ{constructor(){super(...arguments),this.id="chinese"}}class RN extends UQ{constructor(){super(...arguments),this.id="dangi"}}class kN{constructor($){this.helper=$}extraFields($){return this.helper.hasEra&&$.includes("year")?["era","eraYear"]:[]}resolveFields($){if(this.helper.calendarType!=="lunisolar"){let T=new h4;sO($,void 0,this.helper.monthsInYear({year:$.year??1972},T))}}dateToISO($,T){let W=new h4,U=this.helper.calendarToIsoDate($,T,W);return W.setObject(U),U}monthDayToISOReferenceDate($,T){let W=new h4,U=this.helper.monthDayFromFields($,T,W);return W.setObject(U),U}fieldKeysToIgnore($){let T=new Set;for(let W=0;W<$.length;W++){let U=$[W];switch(T.add(U),U){case"era":T.add("eraYear"),T.add("year");break;case"eraYear":T.add("era"),T.add("year");break;case"year":T.add("era"),T.add("eraYear");break;case"month":T.add("monthCode"),this.helper.erasBeginMidYear&&(T.add("era"),T.add("eraYear"));break;case"monthCode":T.add("month"),this.helper.erasBeginMidYear&&(T.add("era"),T.add("eraYear"));break;case"day":this.helper.erasBeginMidYear&&(T.add("era"),T.add("eraYear"))}}return UN(T)}dateAdd($,{years:T,months:W,weeks:U,days:X},Y){let w=h4.getCacheForObject($),G=this.helper.isoToCalendarDate($,w),H=this.helper.addCalendar(G,{years:T,months:W,weeks:U,days:X},Y,w),z=this.helper.calendarToIsoDate(H,"constrain",w);return h4.getCacheForObject(z)||new h4(w).setObject(z),z}dateUntil($,T,W){let U=h4.getCacheForObject($),X=h4.getCacheForObject(T),Y=this.helper.isoToCalendarDate($,U),w=this.helper.isoToCalendarDate(T,X);return this.helper.untilCalendar(Y,w,W,U)}isoToDate($,T){let W=h4.getCacheForObject($),U=this.helper.isoToCalendarDate($,W);if(T.dayOfWeek&&(U.dayOfWeek=$Y.iso8601.isoToDate($,{dayOfWeek:!0}).dayOfWeek),T.dayOfYear){let X=this.helper.startOfCalendarYear(U),Y=this.helper.calendarDaysUntil(X,U,W);U.dayOfYear=Y+1}if(T.weekOfYear&&(U.weekOfYear=XN(this.helper.id,$)),U.daysInWeek=7,T.daysInMonth&&(U.daysInMonth=this.helper.daysInMonth(U,W)),T.daysInYear){let X=this.helper.startOfCalendarYear(U),Y=this.helper.addCalendar(X,{years:1},"constrain",W);U.daysInYear=this.helper.calendarDaysUntil(X,Y,W)}return T.monthsInYear&&(U.monthsInYear=this.helper.monthsInYear(U,W)),T.inLeapYear&&(U.inLeapYear=this.helper.inLeapYear(U,W)),U}getFirstDayOfWeek(){return this.helper.getFirstDayOfWeek()}getMinimalDaysInFirstWeek(){return this.helper.getMinimalDaysInFirstWeek()}}for(let $ of[wN,ZN,AN,KN,EN,_N,RN,MN,DN,NN,LN,JN,GN,zN,HN,FN,ON,QN]){let T=new $;$Y[T.id]=new kN(T)}qO("calendarImpl",function($){return $Y[$]});var c8=Intl.DateTimeFormat;function y2($,T){let W=D($,T);return typeof W=="function"&&(W=new c8(D($,NM),W(D($,_O))),function(U,X,Y){let w=z9(U);if(w===void 0)throw new TypeError("Missing slots for the given container");if(w[X]===void 0)throw new TypeError(`tried to reset ${X} which was not set`);w[X]=Y}($,T,W)),W}function A8($){return _6($,IW)}class s2{constructor($=void 0,T=void 0){(function(W,U,X){let Y=X!==void 0,w;if(Y){let F=["localeMatcher","calendar","numberingSystem","hour12","hourCycle","timeZone","weekday","era","year","month","day","dayPeriod","hour","minute","second","fractionalSecondDigits","timeZoneName","formatMatcher","dateStyle","timeStyle"];w=function(Q){if(Q==null)throw new TypeError(`Expected object not ${Q}`);return Object(Q)}(X);let O=Object.create(null);for(let Q=0;Q<F.length;Q++){let Z=F[Q];Object.prototype.hasOwnProperty.call(w,Z)&&(O[Z]=w[Z])}w=O}else w=Object.create(null);let G=new c8(U,w),H=G.resolvedOptions();if(u0(W),Y){let F=Object.assign(Object.create(null),H);for(let O in F)Object.prototype.hasOwnProperty.call(w,O)||delete F[O];F.hour12=w.hour12,F.hourCycle=w.hourCycle,L$(W,_O,F)}else L$(W,_O,w);L$(W,NM,H.locale),L$(W,IW,G),L$(W,m2,H.timeZone),L$(W,N8,H.calendar),L$(W,DM,cb),L$(W,VM,gb),L$(W,KM,mb),L$(W,EM,hb),L$(W,AM,ub),L$(W,MM,pb);let z=Y?w.timeZone:void 0;if(z===void 0)L$(W,JO,H.timeZone);else{let F=Q9(z);if(F.startsWith("\u2212"))throw new RangeError("Unicode minus (U+2212) is not supported in time zone offsets");L$(W,JO,L6(F))}})(this,$,T)}get format(){C(this,A8);let $=Ib.bind(this);return Object.defineProperties($,{length:{value:1,enumerable:!1,writable:!1,configurable:!0},name:{value:"",enumerable:!1,writable:!1,configurable:!0}}),$}formatRange($,T){return C(this,A8),fb.call(this,$,T)}formatToParts($,...T){return C(this,A8),bb.call(this,$,...T)}formatRangeToParts($,T){return C(this,A8),yb.call(this,$,T)}resolvedOptions(){return C(this,A8),xb.call(this)}}"formatToParts"in c8.prototype||delete s2.prototype.formatToParts,"formatRangeToParts"in c8.prototype||delete s2.prototype.formatRangeToParts;var w1=function($=void 0,T=void 0){return new s2($,T)};function xb(){let $=D(this,IW).resolvedOptions();return $.timeZone=D(this,JO),$}function Ib($,...T){let W,U,X=e2($,this);return X.formatter?(W=X.formatter,U=[L1(X.epochNs,"floor")]):(W=D(this,IW),U=[$,...T]),W.format(...U)}function bb($,...T){let W,U,X=e2($,this);return X.formatter?(W=X.formatter,U=[L1(X.epochNs,"floor")]):(W=D(this,IW),U=[$,...T]),W.formatToParts(...U)}function fb($,T){if($===void 0||T===void 0)throw new TypeError("Intl.DateTimeFormat.formatRange requires two values");let W=G9($),U=G9(T),X,Y=[W,U];if(m0(W)!==m0(U))throw new TypeError("Intl.DateTimeFormat.formatRange accepts two values of the same type");if(m0(W)){if(!vN(W,U))throw new TypeError("Intl.DateTimeFormat.formatRange accepts two values of the same type");let{epochNs:w,formatter:G}=e2(W,this),{epochNs:H,formatter:z}=e2(U,this);G&&(X=G,Y=[L1(w,"floor"),L1(H,"floor")])}return X||(X=D(this,IW)),X.formatRange(...Y)}function yb($,T){if($===void 0||T===void 0)throw new TypeError("Intl.DateTimeFormat.formatRange requires two values");let W=G9($),U=G9(T),X,Y=[W,U];if(m0(W)!==m0(U))throw new TypeError("Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type");if(m0(W)){if(!vN(W,U))throw new TypeError("Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type");let{epochNs:w,formatter:G}=e2(W,this),{epochNs:H,formatter:z}=e2(U,this);G&&(X=G,Y=[L1(w,"floor"),L1(H,"floor")])}return X||(X=D(this,IW)),X.formatRangeToParts(...Y)}function TY($={},T={}){let W=Object.assign({},$),U=["year","month","day","hour","minute","second","weekday","dayPeriod","timeZoneName","dateStyle","timeStyle"];for(let X=0;X<U.length;X++){let Y=U[X];W[Y]=Y in T?T[Y]:W[Y],W[Y]!==!1&&W[Y]!==void 0||delete W[Y]}return W}function hb($){let T=TY($,{year:!1,month:!1,day:!1,weekday:!1,timeZoneName:!1,dateStyle:!1});if(T.timeStyle!=="long"&&T.timeStyle!=="full"||(delete T.timeStyle,Object.assign(T,{hour:"numeric",minute:"2-digit",second:"2-digit"})),!J9(T)){if(WY($))throw new TypeError(`cannot format Temporal.PlainTime with options [${Object.keys($)}]`);Object.assign(T,{hour:"numeric",minute:"numeric",second:"numeric"})}return T}function gb($){let T={short:{year:"2-digit",month:"numeric"},medium:{year:"numeric",month:"short"},long:{year:"numeric",month:"long"},full:{year:"numeric",month:"long"}},W=TY($,{day:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if("dateStyle"in W&&W.dateStyle){let U=W.dateStyle;delete W.dateStyle,Object.assign(W,T[U])}if(!(("year"in W)||("month"in W)||("era"in W))){if(WY($))throw new TypeError(`cannot format PlainYearMonth with options [${Object.keys($)}]`);Object.assign(W,{year:"numeric",month:"numeric"})}return W}function mb($){let T={short:{month:"numeric",day:"numeric"},medium:{month:"short",day:"numeric"},long:{month:"long",day:"numeric"},full:{month:"long",day:"numeric"}},W=TY($,{year:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if("dateStyle"in W&&W.dateStyle){let U=W.dateStyle;delete W.dateStyle,Object.assign(W,T[U])}if(!("month"in W)&&!("day"in W)){if(WY($))throw new TypeError(`cannot format PlainMonthDay with options [${Object.keys($)}]`);Object.assign(W,{month:"numeric",day:"numeric"})}return W}function cb($){let T=TY($,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if(!L9(T)){if(WY($))throw new TypeError(`cannot format PlainDate with options [${Object.keys($)}]`);Object.assign(T,{year:"numeric",month:"numeric",day:"numeric"})}return T}function ub($){let T=TY($,{timeZoneName:!1});if((T.timeStyle==="long"||T.timeStyle==="full")&&(delete T.timeStyle,Object.assign(T,{hour:"numeric",minute:"2-digit",second:"2-digit"}),T.dateStyle))Object.assign(T,{short:{year:"numeric",month:"numeric",day:"numeric"},medium:{year:"numeric",month:"short",day:"numeric"},long:{year:"numeric",month:"long",day:"numeric"},full:{year:"numeric",month:"long",day:"numeric",weekday:"long"}}[T.dateStyle]),delete T.dateStyle;if(!J9(T)&&!L9(T)){if(WY($))throw new TypeError(`cannot format PlainDateTime with options [${Object.keys($)}]`);Object.assign(T,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}return T}function pb($){let T=$;return J9(T)||L9(T)||(T=Object.assign({},T,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),T}function L9($){return"year"in $||"month"in $||"day"in $||"weekday"in $||"dateStyle"in $||"era"in $}function J9($){return"hour"in $||"minute"in $||"second"in $||"timeStyle"in $||"dayPeriod"in $||"fractionalSecondDigits"in $}function WY($){return L9($)||J9($)||"dateStyle"in $||"timeStyle"in $||"timeZoneName"in $}function m0($){return F4($)||K4($)||n$($)||_$($)||o4($)||X1($)||d4($)}function G9($){return m0($)?$:O9($)}function vN($,T){return!(!m0($)||!m0(T)||K4($)&&!K4(T)||F4($)&&!F4(T)||n$($)&&!n$(T)||_$($)&&!_$(T)||o4($)&&!o4(T)||X1($)&&!X1(T)||d4($)&&!d4(T))}function e2($,T){if(K4($)){let W={isoDate:{year:1970,month:1,day:1},time:D($,O4)};return{epochNs:$6(D(T,m2),W,"compatible"),formatter:y2(T,EM)}}if(o4($)){let W=D($,m),U=D(T,N8);if(W!==U)throw new RangeError(`cannot format PlainYearMonth with calendar ${W} in locale with calendar ${U}`);let X=B$(D($,O$),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:$6(D(T,m2),X,"compatible"),formatter:y2(T,VM)}}if(X1($)){let W=D($,m),U=D(T,N8);if(W!==U)throw new RangeError(`cannot format PlainMonthDay with calendar ${W} in locale with calendar ${U}`);let X=B$(D($,O$),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:$6(D(T,m2),X,"compatible"),formatter:y2(T,KM)}}if(F4($)){let W=D($,m),U=D(T,N8);if(W!=="iso8601"&&W!==U)throw new RangeError(`cannot format PlainDate with calendar ${W} in locale with calendar ${U}`);let X=B$(D($,O$),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:$6(D(T,m2),X,"compatible"),formatter:y2(T,DM)}}if(n$($)){let W=D($,m),U=D(T,N8);if(W!=="iso8601"&&W!==U)throw new RangeError(`cannot format PlainDateTime with calendar ${W} in locale with calendar ${U}`);let X=D($,W4);return{epochNs:$6(D(T,m2),X,"compatible"),formatter:y2(T,AM)}}if(_$($))throw new TypeError("Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.");return d4($)?{epochNs:D($,F$),formatter:y2(T,MM)}:{}}function qN($){let T=Object.create(null);return T.years=D($,O6),T.months=D($,Q6),T.weeks=D($,b6),T.days=D($,Z6),T.hours=D($,D6),T.minutes=D($,V6),T.seconds=D($,K6),T.milliseconds=D($,E6),T.microseconds=D($,A6),T.nanoseconds=D($,f6),T}s2.prototype.constructor=w1,Object.defineProperty(w1,"prototype",{value:s2.prototype,writable:!1,enumerable:!1,configurable:!1}),w1.supportedLocalesOf=c8.supportedLocalesOf,p0(w1,"Intl.DateTimeFormat");var{format:db,formatToParts:ob}=Intl.DurationFormat?.prototype??Object.create(null);function XQ($){Intl.DurationFormat.prototype.resolvedOptions.call(this);let T=qN(M1($));return db.call(this,T)}Intl.DurationFormat?.prototype&&(Intl.DurationFormat.prototype.format=XQ,Intl.DurationFormat.prototype.formatToParts=function($){Intl.DurationFormat.prototype.resolvedOptions.call(this);let T=qN(M1($));return ob.call(this,T)});var Qs=Object.freeze({__proto__:null,DateTimeFormat:w1,ModifiedIntlDurationFormatPrototypeFormat:XQ});class _9{constructor($){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");gM(this,w9($))}get epochMilliseconds(){return C(this,d4),L1(D(this,F$),"floor")}get epochNanoseconds(){return C(this,d4),TN(q.BigInt(D(this,F$)))}add($){return C(this,d4),TM("add",this,$)}subtract($){return C(this,d4),TM("subtract",this,$)}until($,T=void 0){return C(this,d4),nA("until",this,$,T)}since($,T=void 0){return C(this,d4),nA("since",this,$,T)}round($){if(C(this,d4),$===void 0)throw new TypeError("options parameter is required");let T=typeof $=="string"?BW("smallestUnit",$):$$($),W=WU(T),U=y1(T,"halfExpand"),X=h6(T,"smallestUnit","time",c0);return UU(W,{hour:24,minute:1440,second:86400,millisecond:86400000,microsecond:86400000000,nanosecond:86400000000000}[X],!0),b1(yO(D(this,F$),W,X,U))}equals($){C(this,d4);let T=_8($),W=D(this,F$),U=D(T,F$);return q.equal(q.BigInt(W),q.BigInt(U))}toString($=void 0){C(this,d4);let T=$$($),W=l8(T),U=y1(T,"trunc"),X=h6(T,"smallestUnit","time",void 0);if(X==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let Y=T.timeZone;Y!==void 0&&(Y=L6(Y));let{precision:w,unit:G,increment:H}=r8(X,W);return gA(b1(yO(D(this,F$),H,G,U)),Y,w)}toJSON(){return C(this,d4),gA(this,void 0,"auto")}toLocaleString($=void 0,T=void 0){return C(this,d4),new w1($,T).format(this)}valueOf(){ST("Instant")}toZonedDateTimeISO($){C(this,d4);let T=L6($);return s4(D(this,F$),T,"iso8601")}static fromEpochMilliseconds($){return b1(f1(O9($)))}static fromEpochNanoseconds($){return b1(w9($))}static from($){return _8($)}static compare($,T){let W=_8($),U=_8(T),X=D(W,F$),Y=D(U,F$);return q.lessThan(X,Y)?-1:q.greaterThan(X,Y)?1:0}}p0(_9,"Temporal.Instant");class R9{constructor($,T,W,U="iso8601"){let X=V$($),Y=V$(T),w=V$(W),G=R6(U===void 0?"iso8601":S4(U));CW(X,Y,w),IM(this,{year:X,month:Y,day:w},G)}get calendarId(){return C(this,F4),D(this,m)}get era(){return z6(this,"era")}get eraYear(){return z6(this,"eraYear")}get year(){return z6(this,"year")}get month(){return z6(this,"month")}get monthCode(){return z6(this,"monthCode")}get day(){return z6(this,"day")}get dayOfWeek(){return z6(this,"dayOfWeek")}get dayOfYear(){return z6(this,"dayOfYear")}get weekOfYear(){return z6(this,"weekOfYear")?.week}get yearOfWeek(){return z6(this,"weekOfYear")?.year}get daysInWeek(){return z6(this,"daysInWeek")}get daysInMonth(){return z6(this,"daysInMonth")}get daysInYear(){return z6(this,"daysInYear")}get monthsInYear(){return z6(this,"monthsInYear")}get inLeapYear(){return z6(this,"inLeapYear")}with($,T=void 0){if(C(this,F4),!Q4($))throw new TypeError("invalid argument");TU($);let W=D(this,m),U=J6(W,D(this,O$));return U=PW(W,U,H1(W,$,["year","month","monthCode","day"],[],"partial")),N6(PT(W,U,C$($$(T))),W)}withCalendar($){C(this,F4);let T=a8($);return N6(D(this,O$),T)}add($,T=void 0){return C(this,F4),WM("add",this,$,T)}subtract($,T=void 0){return C(this,F4),WM("subtract",this,$,T)}until($,T=void 0){return C(this,F4),iA("until",this,$,T)}since($,T=void 0){return C(this,F4),iA("since",this,$,T)}equals($){C(this,F4);let T=L8($);return w0(D(this,O$),D(T,O$))===0&&X0(D(this,m),D(T,m))}toString($=void 0){return C(this,F4),mA(this,o8($$($)))}toJSON(){return C(this,F4),mA(this)}toLocaleString($=void 0,T=void 0){return C(this,F4),new w1($,T).format(this)}valueOf(){ST("PlainDate")}toPlainDateTime($=void 0){C(this,F4);let T=xM($);return E1(B$(D(this,O$),T),D(this,m))}toZonedDateTime($){let T,W;if(C(this,F4),Q4($)){let Y=$.timeZone;Y===void 0?T=L6($):(T=L6(Y),W=$.plainTime)}else T=L6($);let U=D(this,O$),X;return W===void 0?X=LT(T,U):(W=_T(W),X=$6(T,B$(U,D(W,O4)),"compatible")),s4(X,T,D(this,m))}toPlainYearMonth(){C(this,F4);let $=D(this,m);return d2(f8($,J6($,D(this,O$)),"constrain"),$)}toPlainMonthDay(){C(this,F4);let $=D(this,m);return p2(T9($,J6($,D(this,O$)),"constrain"),$)}static from($,T=void 0){return L8($,T)}static compare($,T){let W=L8($),U=L8(T);return w0(D(W,O$),D(U,O$))}}function z6($,T){C($,F4);let W=D($,O$);return n8($).isoToDate(W,{[T]:!0})[T]}p0(R9,"Temporal.PlainDate");class k9{constructor($,T,W,U=0,X=0,Y=0,w=0,G=0,H=0,z="iso8601"){let F=V$($),O=V$(T),Q=V$(W),Z=U===void 0?0:V$(U),V=X===void 0?0:V$(X),E=Y===void 0?0:V$(Y),N=w===void 0?0:V$(w),J=G===void 0?0:V$(G),_=H===void 0?0:V$(H),R=R6(z===void 0?"iso8601":S4(z));nO(F,O,Q,Z,V,E,N,J,_),bM(this,{isoDate:{year:F,month:O,day:Q},time:{hour:Z,minute:V,second:E,millisecond:N,microsecond:J,nanosecond:_}},R)}get calendarId(){return C(this,n$),D(this,m)}get year(){return H6(this,"year")}get month(){return H6(this,"month")}get monthCode(){return H6(this,"monthCode")}get day(){return H6(this,"day")}get hour(){return h2(this,"hour")}get minute(){return h2(this,"minute")}get second(){return h2(this,"second")}get millisecond(){return h2(this,"millisecond")}get microsecond(){return h2(this,"microsecond")}get nanosecond(){return h2(this,"nanosecond")}get era(){return H6(this,"era")}get eraYear(){return H6(this,"eraYear")}get dayOfWeek(){return H6(this,"dayOfWeek")}get dayOfYear(){return H6(this,"dayOfYear")}get weekOfYear(){return H6(this,"weekOfYear")?.week}get yearOfWeek(){return H6(this,"weekOfYear")?.year}get daysInWeek(){return H6(this,"daysInWeek")}get daysInYear(){return H6(this,"daysInYear")}get daysInMonth(){return H6(this,"daysInMonth")}get monthsInYear(){return H6(this,"monthsInYear")}get inLeapYear(){return H6(this,"inLeapYear")}with($,T=void 0){if(C(this,n$),!Q4($))throw new TypeError("invalid argument");TU($);let W=D(this,m),U=D(this,W4),X={...J6(W,U.isoDate),...U.time};return X=PW(W,X,H1(W,$,["year","month","monthCode","day"],["hour","minute","second","millisecond","microsecond","nanosecond"],"partial")),E1(i8(W,X,C$($$(T))),W)}withPlainTime($=void 0){C(this,n$);let T=xM($);return E1(B$(D(this,W4).isoDate,T),D(this,m))}withCalendar($){C(this,n$);let T=a8($);return E1(D(this,W4),T)}add($,T=void 0){return C(this,n$),UM("add",this,$,T)}subtract($,T=void 0){return C(this,n$),UM("subtract",this,$,T)}until($,T=void 0){return C(this,n$),tA("until",this,$,T)}since($,T=void 0){return C(this,n$),tA("since",this,$,T)}round($){if(C(this,n$),$===void 0)throw new TypeError("options parameter is required");let T=typeof $=="string"?BW("smallestUnit",$):$$($),W=WU(T),U=y1(T,"halfExpand"),X=h6(T,"smallestUnit","time",c0,["day"]),Y={day:1,hour:24,minute:60,second:60,millisecond:1000,microsecond:1000,nanosecond:1000}[X];UU(W,Y,Y===1);let w=D(this,W4);return E1(W===1&&X==="nanosecond"?w:hO(w,W,X,U),D(this,m))}equals($){C(this,n$);let T=J8($);return a2(D(this,W4),D(T,W4))===0&&X0(D(this,m),D(T,m))}toString($=void 0){C(this,n$);let T=$$($),W=o8(T),U=l8(T),X=y1(T,"trunc"),Y=h6(T,"smallestUnit","time",void 0);if(Y==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let{precision:w,unit:G,increment:H}=r8(Y,U),z=hO(D(this,W4),H,G,X);return SW(z),h8(z,D(this,m),w,W)}toJSON(){return C(this,n$),h8(D(this,W4),D(this,m),"auto")}toLocaleString($=void 0,T=void 0){return C(this,n$),new w1($,T).format(this)}valueOf(){ST("PlainDateTime")}toZonedDateTime($,T=void 0){C(this,n$);let W=L6($),U=j8($$(T));return s4($6(W,D(this,W4),U),W,D(this,m))}toPlainDate(){return C(this,n$),N6(D(this,W4).isoDate,D(this,m))}toPlainTime(){return C(this,n$),b0(D(this,W4).time)}static from($,T=void 0){return J8($,T)}static compare($,T){let W=J8($),U=J8(T);return a2(D(W,W4),D(U,W4))}}function H6($,T){C($,n$);let W=D($,W4).isoDate;return n8($).isoToDate(W,{[T]:!0})[T]}function h2($,T){return C($,n$),D($,W4).time[T]}p0(k9,"Temporal.PlainDateTime");class $U{constructor($=0,T=0,W=0,U=0,X=0,Y=0,w=0,G=0,H=0,z=0){let F=$===void 0?0:I1($),O=T===void 0?0:I1(T),Q=W===void 0?0:I1(W),Z=U===void 0?0:I1(U),V=X===void 0?0:I1(X),E=Y===void 0?0:I1(Y),N=w===void 0?0:I1(w),J=G===void 0?0:I1(G),_=H===void 0?0:I1(H),R=z===void 0?0:I1(z);A9(F,O,Q,Z,V,E,N,J,_,R),u0(this),L$(this,O6,F),L$(this,Q6,O),L$(this,b6,Q),L$(this,Z6,Z),L$(this,D6,V),L$(this,V6,E),L$(this,K6,N),L$(this,E6,J),L$(this,A6,_),L$(this,f6,R)}get years(){return C(this,H4),D(this,O6)}get months(){return C(this,H4),D(this,Q6)}get weeks(){return C(this,H4),D(this,b6)}get days(){return C(this,H4),D(this,Z6)}get hours(){return C(this,H4),D(this,D6)}get minutes(){return C(this,H4),D(this,V6)}get seconds(){return C(this,H4),D(this,K6)}get milliseconds(){return C(this,H4),D(this,E6)}get microseconds(){return C(this,H4),D(this,A6)}get nanoseconds(){return C(this,H4),D(this,f6)}get sign(){return C(this,H4),X9(this)}get blank(){return C(this,H4),X9(this)===0}with($){C(this,H4);let T=BM($),{years:W=D(this,O6),months:U=D(this,Q6),weeks:X=D(this,b6),days:Y=D(this,Z6),hours:w=D(this,D6),minutes:G=D(this,V6),seconds:H=D(this,K6),milliseconds:z=D(this,E6),microseconds:F=D(this,A6),nanoseconds:O=D(this,f6)}=T;return new $U(W,U,X,Y,w,G,H,z,F,O)}negated(){return C(this,H4),m6(this)}abs(){return C(this,H4),new $U(Math.abs(D(this,O6)),Math.abs(D(this,Q6)),Math.abs(D(this,b6)),Math.abs(D(this,Z6)),Math.abs(D(this,D6)),Math.abs(D(this,V6)),Math.abs(D(this,K6)),Math.abs(D(this,E6)),Math.abs(D(this,A6)),Math.abs(D(this,f6)))}add($){return C(this,H4),$M("add",this,$)}subtract($){return C(this,H4),$M("subtract",this,$)}round($){if(C(this,H4),$===void 0)throw new TypeError("options parameter is required");let T=x0(this),W=typeof $=="string"?BW("smallestUnit",$):$$($),U=h6(W,"largestUnit","datetime",void 0,["auto"]),{plainRelativeTo:X,zonedRelativeTo:Y}=MO(W),w=WU(W),G=y1(W,"halfExpand"),H=h6(W,"smallestUnit","datetime",void 0),z=!0;H||(z=!1,H="nanosecond");let F=y0(T,H),O=!0;if(U||(O=!1,U=F),U==="auto"&&(U=F),!z&&!O)throw new RangeError("at least one of smallestUnit or largestUnit is required");if(y0(U,H)!==U)throw new RangeError(`largestUnit ${U} cannot be smaller than smallestUnit ${H}`);let Q={hour:24,minute:60,second:60,millisecond:1000,microsecond:1000,nanosecond:1000}[H];if(Q!==void 0&&UU(w,Q,!1),w>1&&I0(H)==="date"&&U!==H)throw new RangeError("For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit");if(Y){let V=c2(this),E=D(Y,b$),N=D(Y,m),J=D(Y,F$);return V=$N(J,v8(J,E,N,V),E,N,U,w,H,G),I0(U)==="date"&&(U="hour"),A1(V,U)}if(X){let V=W0(this),E=t2({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},V.time),N=D(X,O$),J=D(X,m),_=G1(J,N,e4(V.date,E.deltaDays),"constrain");return V=eM(B$(N,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),B$(_,E),J,U,w,H,G),A1(V,U)}if($0(T))throw new RangeError(`a starting point is required for ${T}s balancing`);if($0(U))throw new RangeError(`a starting point is required for ${U}s balancing`);let Z=W0(this);if(H==="day"){let{quotient:V,remainder:E}=Z.time.divmod(sG),N=Z.date.days+V+B8(E,"day");N=RT(N,w,G),Z=h0({years:0,months:0,weeks:0,days:N},R$.ZERO)}else Z=h0({years:0,months:0,weeks:0,days:0},Y9(Z.time,w,H,G));return A1(Z,U)}total($){if(C(this,H4),$===void 0)throw new TypeError("options argument is required");let T=typeof $=="string"?BW("unit",$):$$($),{plainRelativeTo:W,zonedRelativeTo:U}=MO(T),X=h6(T,"unit","datetime",c0);if(U){let w=c2(this),G=D(U,b$),H=D(U,m),z=D(U,F$);return function(F,O,Q,Z,V){return I0(V)==="time"?B8(R$.fromEpochNsDiff(O,F),V):rA(aM(F,O,Q,Z,V),O,N1(Q,F),Q,Z,V)}(z,v8(z,G,H,w),G,H,X)}if(W){let w=W0(this),G=t2({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},w.time),H=D(W,O$),z=D(W,m),F=G1(z,H,e4(w.date,G.deltaDays),"constrain");return function(O,Q,Z,V){if(a2(O,Q)==0)return 0;SW(O),SW(Q);let E=tM(O,Q,Z,V);return V==="nanosecond"?q.toNumber(E.time.totalNs):rA(E,l4(Q),O,null,Z,V)}(B$(H,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),B$(F,G),z,X)}let Y=x0(this);if($0(Y))throw new RangeError(`a starting point is required for ${Y}s total`);if($0(X))throw new RangeError(`a starting point is required for ${X}s total`);return B8(W0(this).time,X)}toString($=void 0){C(this,H4);let T=$$($),W=l8(T),U=y1(T,"trunc"),X=h6(T,"smallestUnit","time",void 0);if(X==="hour"||X==="minute")throw new RangeError('smallestUnit must be a time unit other than "hours" or "minutes"');let{precision:Y,unit:w,increment:G}=r8(X,W);if(w==="nanosecond"&&G===1)return nG(this,Y);let H=x0(this),z=c2(this),F=Y9(z.time,G,w,U);return z=h0(z.date,F),nG(A1(z,y0(H,"second")),Y)}toJSON(){return C(this,H4),nG(this,"auto")}toLocaleString($=void 0,T=void 0){if(C(this,H4),typeof Intl.DurationFormat=="function"){let W=new Intl.DurationFormat($,T);return XQ.call(W,this)}return console.warn("Temporal.Duration.prototype.toLocaleString() requires Intl.DurationFormat."),nG(this,"auto")}valueOf(){ST("Duration")}static from($){return M1($)}static compare($,T,W=void 0){let U=M1($),X=M1(T),Y=$$(W),{plainRelativeTo:w,zonedRelativeTo:G}=MO(Y);if(D(U,O6)===D(X,O6)&&D(U,Q6)===D(X,Q6)&&D(U,b6)===D(X,b6)&&D(U,Z6)===D(X,Z6)&&D(U,D6)===D(X,D6)&&D(U,V6)===D(X,V6)&&D(U,K6)===D(X,K6)&&D(U,E6)===D(X,E6)&&D(U,A6)===D(X,A6)&&D(U,f6)===D(X,f6))return 0;let H=x0(U),z=x0(X),F=c2(U),O=c2(X);if(G&&(I0(H)==="date"||I0(z)==="date")){let N=D(G,b$),J=D(G,m),_=D(G,F$),R=v8(_,N,J,F),P=v8(_,N,J,O);return y6(q.toNumber(q.subtract(R,P)))}let Q=F.date.days,Z=O.date.days;if($0(H)||$0(z)){if(!w)throw new RangeError("A starting point is required for years, months, or weeks comparison");Q=lA(F.date,w),Z=lA(O.date,w)}let V=F.time.add24HourDays(Q),E=O.time.add24HourDays(Z);return V.cmp(E)}}p0($U,"Temporal.Duration");class v9{constructor($,T,W="iso8601",U=1972){let X=V$($),Y=V$(T),w=R6(W===void 0?"iso8601":S4(W)),G=V$(U);CW(G,X,Y),fM(this,{year:G,month:X,day:Y},w)}get monthCode(){return zM(this,"monthCode")}get day(){return zM(this,"day")}get calendarId(){return C(this,X1),D(this,m)}with($,T=void 0){if(C(this,X1),!Q4($))throw new TypeError("invalid argument");TU($);let W=D(this,m),U=J6(W,D(this,O$),"month-day");return U=PW(W,U,H1(W,$,["year","month","monthCode","day"],[],"partial")),p2(T9(W,U,C$($$(T))),W)}equals($){C(this,X1);let T=yA($);return w0(D(this,O$),D(T,O$))===0&&X0(D(this,m),D(T,m))}toString($=void 0){return C(this,X1),uA(this,o8($$($)))}toJSON(){return C(this,X1),uA(this)}toLocaleString($=void 0,T=void 0){return C(this,X1),new w1($,T).format(this)}valueOf(){ST("PlainMonthDay")}toPlainDate($){if(C(this,X1),!Q4($))throw new TypeError("argument should be an object");let T=D(this,m);return N6(PT(T,PW(T,J6(T,D(this,O$),"month-day"),H1(T,$,["year"],[],[])),"constrain"),T)}static from($,T=void 0){return yA($,T)}}function zM($,T){C($,X1);let W=D($,O$);return n8($).isoToDate(W,{[T]:!0})[T]}function LO($){return N1($,cO())}p0(v9,"Temporal.PlainMonthDay");var PN={instant:()=>b1(cO()),plainDateTimeISO:($=E8())=>E1(LO(L6($)),"iso8601"),plainDateISO:($=E8())=>N6(LO(L6($)).isoDate,"iso8601"),plainTimeISO:($=E8())=>b0(LO(L6($)).time),timeZoneId:()=>E8(),zonedDateTimeISO:($=E8())=>{let T=L6($);return s4(cO(),T,"iso8601")},[Symbol.toStringTag]:"Temporal.Now"};Object.defineProperty(PN,Symbol.toStringTag,{value:"Temporal.Now",writable:!1,enumerable:!1,configurable:!0});class UY{constructor($=0,T=0,W=0,U=0,X=0,Y=0){let w=$===void 0?0:V$($),G=T===void 0?0:V$(T),H=W===void 0?0:V$(W),z=U===void 0?0:V$(U),F=X===void 0?0:V$(X),O=Y===void 0?0:V$(Y);E9(w,G,H,z,F,O),yM(this,{hour:w,minute:G,second:H,millisecond:z,microsecond:F,nanosecond:O})}get hour(){return C(this,K4),D(this,O4).hour}get minute(){return C(this,K4),D(this,O4).minute}get second(){return C(this,K4),D(this,O4).second}get millisecond(){return C(this,K4),D(this,O4).millisecond}get microsecond(){return C(this,K4),D(this,O4).microsecond}get nanosecond(){return C(this,K4),D(this,O4).nanosecond}with($,T=void 0){if(C(this,K4),!Q4($))throw new TypeError("invalid argument");TU($);let W=jO($,"partial"),U=jO(this),{hour:X,minute:Y,second:w,millisecond:G,microsecond:H,nanosecond:z}=Object.assign(U,W),F=C$($$(T));return{hour:X,minute:Y,second:w,millisecond:G,microsecond:H,nanosecond:z}=D9(X,Y,w,G,H,z,F),new UY(X,Y,w,G,H,z)}add($){return C(this,K4),XM("add",this,$)}subtract($){return C(this,K4),XM("subtract",this,$)}until($,T=void 0){return C(this,K4),aA("until",this,$,T)}since($,T=void 0){return C(this,K4),aA("since",this,$,T)}round($){if(C(this,K4),$===void 0)throw new TypeError("options parameter is required");let T=typeof $=="string"?BW("smallestUnit",$):$$($),W=WU(T),U=y1(T,"halfExpand"),X=h6(T,"smallestUnit","time",c0);return UU(W,{hour:24,minute:60,second:60,millisecond:1000,microsecond:1000,nanosecond:1000}[X],!1),b0(gO(D(this,O4),W,X,U))}equals($){C(this,K4);let T=_T($);return mO(D(this,O4),D(T,O4))===0}toString($=void 0){C(this,K4);let T=$$($),W=l8(T),U=y1(T,"trunc"),X=h6(T,"smallestUnit","time",void 0);if(X==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let{precision:Y,unit:w,increment:G}=r8(X,W);return cA(gO(D(this,O4),G,w,U),Y)}toJSON(){return C(this,K4),cA(D(this,O4),"auto")}toLocaleString($=void 0,T=void 0){return C(this,K4),new w1($,T).format(this)}valueOf(){ST("PlainTime")}static from($,T=void 0){return _T($,T)}static compare($,T){let W=_T($),U=_T(T);return mO(D(W,O4),D(U,O4))}}p0(UY,"Temporal.PlainTime");class q9{constructor($,T,W="iso8601",U=1){let X=V$($),Y=V$(T),w=R6(W===void 0?"iso8601":S4(W)),G=V$(U);CW(X,Y,G),hM(this,{year:X,month:Y,day:G},w)}get year(){return j0(this,"year")}get month(){return j0(this,"month")}get monthCode(){return j0(this,"monthCode")}get calendarId(){return C(this,o4),D(this,m)}get era(){return j0(this,"era")}get eraYear(){return j0(this,"eraYear")}get daysInMonth(){return j0(this,"daysInMonth")}get daysInYear(){return j0(this,"daysInYear")}get monthsInYear(){return j0(this,"monthsInYear")}get inLeapYear(){return j0(this,"inLeapYear")}with($,T=void 0){if(C(this,o4),!Q4($))throw new TypeError("invalid argument");TU($);let W=D(this,m),U=J6(W,D(this,O$),"year-month");return U=PW(W,U,H1(W,$,["year","month","monthCode"],[],"partial")),d2(f8(W,U,C$($$(T))),W)}add($,T=void 0){return C(this,o4),YM("add",this,$,T)}subtract($,T=void 0){return C(this,o4),YM("subtract",this,$,T)}until($,T=void 0){return C(this,o4),sA("until",this,$,T)}since($,T=void 0){return C(this,o4),sA("since",this,$,T)}equals($){C(this,o4);let T=R8($);return w0(D(this,O$),D(T,O$))===0&&X0(D(this,m),D(T,m))}toString($=void 0){return C(this,o4),pA(this,o8($$($)))}toJSON(){return C(this,o4),pA(this)}toLocaleString($=void 0,T=void 0){return C(this,o4),new w1($,T).format(this)}valueOf(){ST("PlainYearMonth")}toPlainDate($){if(C(this,o4),!Q4($))throw new TypeError("argument should be an object");let T=D(this,m);return N6(PT(T,PW(T,J6(T,D(this,O$),"year-month"),H1(T,$,["day"],[],[])),"constrain"),T)}static from($,T=void 0){return R8($,T)}static compare($,T){let W=R8($),U=R8(T);return w0(D(W,O$),D(U,O$))}}function j0($,T){C($,o4);let W=D($,O$);return n8($).isoToDate(W,{[T]:!0})[T]}p0(q9,"Temporal.PlainYearMonth");var lb=w1.prototype.resolvedOptions;class P9{constructor($,T,W="iso8601"){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");let U=w9($),X=S4(T),{tzName:Y,offsetMinutes:w}=kT(X);if(w===void 0){let G=W9(Y);if(!G)throw new RangeError(`unknown time zone ${Y}`);X=G.identifier}else X=oO(w);mM(this,U,X,R6(W===void 0?"iso8601":S4(W)))}get calendarId(){return C(this,_$),D(this,m)}get timeZoneId(){return C(this,_$),D(this,b$)}get year(){return F6(this,"year")}get month(){return F6(this,"month")}get monthCode(){return F6(this,"monthCode")}get day(){return F6(this,"day")}get hour(){return g2(this,"hour")}get minute(){return g2(this,"minute")}get second(){return g2(this,"second")}get millisecond(){return g2(this,"millisecond")}get microsecond(){return g2(this,"microsecond")}get nanosecond(){return g2(this,"nanosecond")}get era(){return F6(this,"era")}get eraYear(){return F6(this,"eraYear")}get epochMilliseconds(){return C(this,_$),L1(D(this,F$),"floor")}get epochNanoseconds(){return C(this,_$),TN(D(this,F$))}get dayOfWeek(){return F6(this,"dayOfWeek")}get dayOfYear(){return F6(this,"dayOfYear")}get weekOfYear(){return F6(this,"weekOfYear")?.week}get yearOfWeek(){return F6(this,"weekOfYear")?.year}get hoursInDay(){C(this,_$);let $=D(this,b$),T=e1(this).isoDate,W=g6(T.year,T.month,T.day+1),U=LT($,T),X=LT($,W);return B8(R$.fromEpochNsDiff(X,U),"hour")}get daysInWeek(){return F6(this,"daysInWeek")}get daysInMonth(){return F6(this,"daysInMonth")}get daysInYear(){return F6(this,"daysInYear")}get monthsInYear(){return F6(this,"monthsInYear")}get inLeapYear(){return F6(this,"inLeapYear")}get offset(){return C(this,_$),BO(f0(D(this,b$),D(this,F$)))}get offsetNanoseconds(){return C(this,_$),f0(D(this,b$),D(this,F$))}with($,T=void 0){if(C(this,_$),!Q4($))throw new TypeError("invalid zoned-date-time-like");TU($);let W=D(this,m),U=D(this,b$),X=f0(U,D(this,F$)),Y=e1(this),w={...J6(W,Y.isoDate),...Y.time,offset:BO(X)};w=PW(W,w,H1(W,$,["year","month","monthCode","day"],["hour","minute","second","millisecond","microsecond","nanosecond","offset"],"partial"));let G=$$(T),H=j8(G),z=iG(G,"prefer"),F=i8(W,w,C$(G)),O=XU(w.offset);return s4($9(F.isoDate,F.time,"option",O,U,H,z,!1),U,W)}withPlainTime($=void 0){C(this,_$);let T=D(this,b$),W=D(this,m),U=e1(this).isoDate,X;return X=$===void 0?LT(T,U):$6(T,B$(U,D(_T($),O4)),"compatible"),s4(X,T,W)}withTimeZone($){C(this,_$);let T=L6($);return s4(D(this,F$),T,D(this,m))}withCalendar($){C(this,_$);let T=a8($);return s4(D(this,F$),D(this,b$),T)}add($,T=void 0){return C(this,_$),wM("add",this,$,T)}subtract($,T=void 0){return C(this,_$),wM("subtract",this,$,T)}until($,T=void 0){return C(this,_$),eA("until",this,$,T)}since($,T=void 0){return C(this,_$),eA("since",this,$,T)}round($){if(C(this,_$),$===void 0)throw new TypeError("options parameter is required");let T=typeof $=="string"?BW("smallestUnit",$):$$($),W=WU(T),U=y1(T,"halfExpand"),X=h6(T,"smallestUnit","time",c0,["day"]),Y={day:1,hour:24,minute:60,second:60,millisecond:1000,microsecond:1000,nanosecond:1000}[X];if(UU(W,Y,Y===1),X==="nanosecond"&&W===1)return s4(D(this,F$),D(this,b$),D(this,m));let w=D(this,b$),G=D(this,F$),H=e1(this),z;if(X==="day"){let F=H.isoDate,O=g6(F.year,F.month,F.day+1),Q=LT(w,F),Z=LT(w,O),V=q.subtract(Z,Q);z=R$.fromEpochNsDiff(G,Q).round(V,U).addToEpochNs(Q)}else{let F=hO(H,W,X,U),O=f0(w,G);z=$9(F.isoDate,F.time,"option",O,w,"compatible","prefer",!1)}return s4(z,w,D(this,m))}equals($){C(this,_$);let T=k8($),W=D(this,F$),U=D(T,F$);return!!q.equal(q.BigInt(W),q.BigInt(U))&&!!cM(D(this,b$),D(T,b$))&&X0(D(this,m),D(T,m))}toString($=void 0){C(this,_$);let T=$$($),W=o8(T),U=l8(T),X=function(O){return g0(O,"offset",["auto","never"],"auto")}(T),Y=y1(T,"trunc"),w=h6(T,"smallestUnit","time",void 0);if(w==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let G=function(O){return g0(O,"timeZoneName",["auto","never","critical"],"auto")}(T),{precision:H,unit:z,increment:F}=r8(w,U);return dA(this,H,W,G,X,{unit:z,increment:F,roundingMode:Y})}toLocaleString($=void 0,T=void 0){C(this,_$);let W=$$(T),U=Object.create(null);if(function(G,H,z,F){if(H==null)return;let O=Reflect.ownKeys(H);for(let Q=0;Q<O.length;Q++){let Z=O[Q];if(!z.some((V)=>Object.is(V,Z))&&Object.prototype.propertyIsEnumerable.call(H,Z)){let V=H[Z];G[Z]=V}}}(U,W,["timeZone"]),W.timeZone!==void 0)throw new TypeError("ZonedDateTime toLocaleString does not accept a timeZone option");if(U.year===void 0&&U.month===void 0&&U.day===void 0&&U.era===void 0&&U.weekday===void 0&&U.dateStyle===void 0&&U.hour===void 0&&U.minute===void 0&&U.second===void 0&&U.fractionalSecondDigits===void 0&&U.timeStyle===void 0&&U.dayPeriod===void 0&&U.timeZoneName===void 0&&(U.timeZoneName="short"),U.timeZone=D(this,b$),oA(U.timeZone))throw new RangeError("toLocaleString does not currently support offset time zones");let X=new w1($,U),Y=lb.call(X).calendar,w=D(this,m);if(w!=="iso8601"&&Y!=="iso8601"&&!X0(Y,w))throw new RangeError(`cannot format ZonedDateTime with calendar ${w} in locale with calendar ${Y}`);return X.format(b1(D(this,F$)))}toJSON(){return C(this,_$),dA(this,"auto")}valueOf(){ST("ZonedDateTime")}startOfDay(){C(this,_$);let $=D(this,b$);return s4(LT($,e1(this).isoDate),$,D(this,m))}getTimeZoneTransition($){C(this,_$);let T=D(this,b$);if($===void 0)throw new TypeError("options parameter is required");let W=g0(typeof $=="string"?BW("direction",$):$$($),"direction",["next","previous"],c0);if(W===void 0)throw new TypeError("direction option is required");if(oA(T)||T==="UTC")return null;let U=D(this,F$),X=W==="next"?rO(T,U):IO(T,U);return X===null?null:s4(X,T,D(this,m))}toInstant(){return C(this,_$),b1(D(this,F$))}toPlainDate(){return C(this,_$),N6(e1(this).isoDate,D(this,m))}toPlainTime(){return C(this,_$),b0(e1(this).time)}toPlainDateTime(){return C(this,_$),E1(e1(this),D(this,m))}static from($,T=void 0){return k8($,T)}static compare($,T){let W=k8($),U=k8(T),X=D(W,F$),Y=D(U,F$);return q.lessThan(q.BigInt(X),q.BigInt(Y))?-1:q.greaterThan(q.BigInt(X),q.BigInt(Y))?1:0}}function e1($){return N1(D($,b$),D($,F$))}function F6($,T){C($,_$);let W=e1($).isoDate;return n8($).isoToDate(W,{[T]:!0})[T]}function g2($,T){return C($,_$),e1($).time[T]}p0(P9,"Temporal.ZonedDateTime");var C9=Object.freeze({__proto__:null,Duration:$U,Instant:_9,Now:PN,PlainDate:R9,PlainDateTime:k9,PlainMonthDay:v9,PlainTime:UY,PlainYearMonth:q9,ZonedDateTime:P9}),Zs=class ${toTemporalInstant(){return b1(f1(Date.prototype.valueOf.call(this)))}}.prototype.toTemporalInstant,rb=[_9,R9,k9,$U,v9,UY,q9,P9];for(let $ of rb){let T=Object.getOwnPropertyDescriptor($,"prototype");(T.configurable||T.enumerable||T.writable)&&(T.configurable=!1,T.enumerable=!1,T.writable=!1,Object.defineProperty($,"prototype",T))}class S9{supported;constructor($){this.supported=$}refine($){for(let[T,W]of Object.entries(this.supported))try{if(W($)===!0&&W!==Boolean)return{type:T,data:$}}catch(U){try{if($ instanceof W)return{type:T,data:$}}catch(X){}}return null}}var nb=new S9({number:($)=>typeof $==="number",string:($)=>typeof $==="string",boolean:($)=>typeof $==="boolean",null:($)=>$===null});function ib($){if(!$)return!1;return Object.getPrototypeOf($)===Object.prototype}var tb=new S9({object:ib,array:($)=>Array.isArray($)}),ab=new S9({...nb.supported,...tb.supported}),CN=($)=>{if($===void 0)return"undefined";let T=ab.refine($);if(T)return T.type;return Object.getPrototypeOf($).constructor.name};var M=Symbol.for("drizzle:entityKind"),Ks=Symbol.for("drizzle:hasOwnEntityKind");function j($,T){if(!$||typeof $!=="object")return!1;if($ instanceof T)return!0;if(!Object.prototype.hasOwnProperty.call(T,M))throw new Error(`Class "${T.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let W=Object.getPrototypeOf($).constructor;if(W)while(W){if(M in W&&W[M]===T[M])return!0;W=Object.getPrototypeOf(W)}return!1}class u${constructor($,T){this.table=$,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[M]="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($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class YQ{static[M]="ColumnBuilder";config;constructor($,T,W){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:T,columnType:W,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}var h1=Symbol.for("drizzle:Name");class wQ{static[M]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor($,T){if(this.reference=()=>{let{name:W,columns:U,foreignColumns:X}=$();return{name:W,columns:U,foreignTable:X[0].table,foreignColumns:X}},T)this._onUpdate=T.onUpdate,this._onDelete=T.onDelete}onUpdate($){return this._onUpdate=$===void 0?"no action":$,this}onDelete($){return this._onDelete=$===void 0?"no action":$,this}build($){return new SN($,this)}}class SN{constructor($,T){this.table=$,this.reference=T.reference,this.onUpdate=T._onUpdate,this.onDelete=T._onDelete}static[M]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:T,foreignColumns:W}=this.reference(),U=T.map((w)=>w.name),X=W.map((w)=>w.name),Y=[this.table[h1],...U,W[0].table[h1],...X];return $??`${Y.join("_")}_fk`}}function j9($,...T){return $(...T)}function jN($,T){return`${$[h1]}_${T.join("_")}_unique`}function BN($,T,W){for(let U=T;U<$.length;U++){let X=$[U];if(X==="\\"){U++;continue}if(X==='"')return[$.slice(T,U).replace(/\\/g,""),U+1];if(W)continue;if(X===","||X==="}")return[$.slice(T,U).replace(/\\/g,""),U]}return[$.slice(T).replace(/\\/g,""),$.length]}function xN($,T=0){let W=[],U=T,X=!1;while(U<$.length){let Y=$[U];if(Y===","){if(X||U===T)W.push("");X=!0,U++;continue}if(X=!1,Y==="\\"){U+=2;continue}if(Y==='"'){let[H,z]=BN($,U+1,!0);W.push(H),U=z;continue}if(Y==="}")return[W,U+1];if(Y==="{"){let[H,z]=xN($,U+1);W.push(H),U=z;continue}let[w,G]=BN($,U,!1);W.push(w),U=G}return[W,U]}function IN($){let[T]=xN($,1);return T}function GQ($){return`{${$.map((T)=>{if(Array.isArray(T))return GQ(T);if(typeof T==="string")return`"${T.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${T}`}).join(",")}}`}class t extends YQ{foreignKeyConfigs=[];static[M]="PgColumnBuilder";array($){return new fN(this.config.name,this,$)}references($,T={}){return this.foreignKeyConfigs.push({ref:$,actions:T}),this}unique($,T){return this.config.isUnique=!0,this.config.uniqueName=$,this.config.uniqueType=T?.nulls,this}generatedAlwaysAs($){return this.config.generated={as:$,type:"always",mode:"stored"},this}buildForeignKeys($,T){return this.foreignKeyConfigs.map(({ref:W,actions:U})=>{return j9((X,Y)=>{let w=new wQ(()=>{let G=X();return{columns:[$],foreignColumns:[G]}});if(Y.onUpdate)w.onUpdate(Y.onUpdate);if(Y.onDelete)w.onDelete(Y.onDelete);return w.build(T)},W,U)})}buildExtraConfigColumn($){return new bN($,this.config)}}class u extends u${constructor($,T){if(!T.uniqueName)T.uniqueName=jN($,[T.name]);super($,T);this.table=$}static[M]="PgColumn"}class bN extends u{static[M]="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($){return this.indexConfig.opClass=$,this}}class XY{static[M]="IndexedColumn";constructor($,T,W,U){this.name=$,this.keyAsName=T,this.type=W,this.indexConfig=U}name;keyAsName;type;indexConfig}class fN extends t{static[M]="PgArrayBuilder";constructor($,T,W){super($,"array","PgArray");this.config.baseBuilder=T,this.config.size=W}build($){let T=this.config.baseBuilder.build($);return new zQ($,this.config,T)}}class zQ extends u{constructor($,T,W,U){super($,T);this.baseColumn=W,this.range=U,this.size=T.size}size;static[M]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue($){if(typeof $==="string")$=IN($);return $.map((T)=>this.baseColumn.mapFromDriverValue(T))}mapToDriverValue($,T=!1){let W=$.map((U)=>U===null?null:j(this.baseColumn,zQ)?this.baseColumn.mapToDriverValue(U,!0):this.baseColumn.mapToDriverValue(U));if(T)return W;return GQ(W)}}class yN extends t{static[M]="PgEnumObjectColumnBuilder";constructor($,T){super($,"string","PgEnumObjectColumn");this.config.enum=T}build($){return new hN($,this.config)}}class hN extends u{static[M]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,T){super($,T);this.enum=T.enum}getSQLType(){return this.enum.enumName}}var B9=Symbol.for("drizzle:isPgEnum");function gN($){return!!$&&typeof $==="function"&&B9 in $&&$[B9]===!0}class mN extends t{static[M]="PgEnumColumnBuilder";constructor($,T){super($,"string","PgEnumColumn");this.config.enum=T}build($){return new cN($,this.config)}}class cN extends u{static[M]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,T){super($,T);this.enum=T.enum}getSQLType(){return this.enum.enumName}}function YY($,T){return Array.isArray(T)?sb($,[...T],void 0):eb($,T,void 0)}function sb($,T,W){let U=Object.assign((X)=>new mN(X??"",U),{enumName:$,enumValues:T,schema:W,[B9]:!0});return U}function eb($,T,W){let U=Object.assign((X)=>new yN(X??"",U),{enumName:$,enumValues:Object.values(T),schema:W,[B9]:!0});return U}class A4{static[M]="Subquery";constructor($,T,W,U=!1,X=[]){this._={brand:"Subquery",sql:$,selectedFields:T,alias:W,isWith:U,usedTables:X}}}class wY extends A4{static[M]="WithSubquery"}var uN="0.44.0";var HQ,FQ,p$={startActiveSpan($,T){if(!HQ)return T();if(!FQ)FQ=HQ.trace.getTracer("drizzle-orm",uN);return j9((W,U)=>U.startActiveSpan($,(X)=>{try{return T(X)}catch(Y){throw X.setStatus({code:W.SpanStatusCode.ERROR,message:Y instanceof Error?Y.message:"Unknown error"}),Y}finally{X.end()}}),HQ,FQ)}};var i$=Symbol.for("drizzle:ViewBaseConfig");var yW=Symbol.for("drizzle:Schema"),x9=Symbol.for("drizzle:Columns"),pN=Symbol.for("drizzle:ExtraConfigColumns"),OQ=Symbol.for("drizzle:OriginalName"),QQ=Symbol.for("drizzle:BaseName"),GY=Symbol.for("drizzle:IsAlias"),dN=Symbol.for("drizzle:ExtraConfigBuilder"),$f=Symbol.for("drizzle:IsDrizzleTable");class p{static[M]="Table";static Symbol={Name:h1,Schema:yW,OriginalName:OQ,Columns:x9,ExtraConfigColumns:pN,BaseName:QQ,IsAlias:GY,ExtraConfigBuilder:dN};[h1];[OQ];[yW];[x9];[pN];[QQ];[GY]=!1;[$f]=!0;[dN]=void 0;constructor($,T,W){this[h1]=this[OQ]=$,this[yW]=T,this[QQ]=W}}function m4($){return $[h1]}function hW($){return`${$[yW]??"public"}.${$[h1]}`}function ZQ($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function Tf($){let T={sql:"",params:[]};for(let W of $)if(T.sql+=W.sql,T.params.push(...W.params),W.typings?.length){if(!T.typings)T.typings=[];T.typings.push(...W.typings)}return T}class j4{static[M]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new i([this])}}class i{constructor($){this.queryChunks=$;for(let T of $)if(j(T,p)){let W=T[p.Symbol.Schema];this.usedTables.push(W===void 0?T[p.Symbol.Name]:W+"."+T[p.Symbol.Name])}}static[M]="SQL";decoder=lN;shouldInlineParams=!1;usedTables=[];append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return p$.startActiveSpan("drizzle.buildSQL",(T)=>{let W=this.buildQueryFromSourceParams(this.queryChunks,$);return T?.setAttributes({"drizzle.query.text":W.sql,"drizzle.query.params":JSON.stringify(W.params)}),W})}buildQueryFromSourceParams($,T){let W=Object.assign({},T,{inlineParams:T.inlineParams||this.shouldInlineParams,paramStartIndex:T.paramStartIndex||{value:0}}),{casing:U,escapeName:X,escapeParam:Y,prepareTyping:w,inlineParams:G,paramStartIndex:H}=W;return Tf($.map((z)=>{if(j(z,j4))return{sql:z.value.join(""),params:[]};if(j(z,I9))return{sql:X(z.value),params:[]};if(z===void 0)return{sql:"",params:[]};if(Array.isArray(z)){let F=[new j4("(")];for(let[O,Q]of z.entries())if(F.push(Q),O<z.length-1)F.push(new j4(", "));return F.push(new j4(")")),this.buildQueryFromSourceParams(F,W)}if(j(z,i))return this.buildQueryFromSourceParams(z.queryChunks,{...W,inlineParams:G||z.shouldInlineParams});if(j(z,p)){let F=z[p.Symbol.Schema],O=z[p.Symbol.Name];return{sql:F===void 0||z[GY]?X(O):X(F)+"."+X(O),params:[]}}if(j(z,u$)){let F=U.getColumnCasing(z);if(T.invokeSource==="indexes")return{sql:X(F),params:[]};let O=z.table[p.Symbol.Schema];return{sql:z.table[GY]||O===void 0?X(z.table[p.Symbol.Name])+"."+X(F):X(O)+"."+X(z.table[p.Symbol.Name])+"."+X(F),params:[]}}if(j(z,c6)){let F=z[i$].schema,O=z[i$].name;return{sql:F===void 0||z[i$].isAlias?X(O):X(F)+"."+X(O),params:[]}}if(j(z,F1)){if(j(z.value,BT))return{sql:Y(H.value++,z),params:[z],typings:["none"]};let F=z.value===null?null:z.encoder.mapToDriverValue(z.value);if(j(F,i))return this.buildQueryFromSourceParams([F],W);if(G)return{sql:this.mapInlineParam(F,W),params:[]};let O=["none"];if(w)O=[w(z.encoder)];return{sql:Y(H.value++,F),params:[F],typings:O}}if(j(z,BT))return{sql:Y(H.value++,z),params:[z],typings:["none"]};if(j(z,i.Aliased)&&z.fieldAlias!==void 0)return{sql:X(z.fieldAlias),params:[]};if(j(z,A4)){if(z._.isWith)return{sql:X(z._.alias),params:[]};return this.buildQueryFromSourceParams([new j4("("),z._.sql,new j4(") "),new I9(z._.alias)],W)}if(gN(z)){if(z.schema)return{sql:X(z.schema)+"."+X(z.enumName),params:[]};return{sql:X(z.enumName),params:[]}}if(ZQ(z)){if(z.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([z.getSQL()],W);return this.buildQueryFromSourceParams([new j4("("),z.getSQL(),new j4(")")],W)}if(G)return{sql:this.mapInlineParam(z,W),params:[]};return{sql:Y(H.value++,z),params:[z],typings:["none"]}}))}mapInlineParam($,{escapeString:T}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return T($);if(typeof $==="object"){let W=$.toString();if(W==="[object Object]")return T(JSON.stringify($));return T(W)}throw new Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new i.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}}class I9{constructor($){this.value=$}static[M]="Name";brand;getSQL(){return new i([this])}}function oN($){return typeof $==="object"&&$!==null&&"mapToDriverValue"in $&&typeof $.mapToDriverValue==="function"}var lN={mapFromDriverValue:($)=>$},rN={mapToDriverValue:($)=>$},Xe={...lN,...rN};class F1{constructor($,T=rN){this.value=$,this.encoder=T}static[M]="Param";brand;getSQL(){return new i([this])}}function L($,...T){let W=[];if(T.length>0||$.length>0&&$[0]!=="")W.push(new j4($[0]));for(let[U,X]of T.entries())W.push(X,new j4($[U+1]));return new i(W)}(($)=>{function T(){return new i([])}$.empty=T;function W(H){return new i(H)}$.fromList=W;function U(H){return new i([new j4(H)])}$.raw=U;function X(H,z){let F=[];for(let[O,Q]of H.entries()){if(O>0&&z!==void 0)F.push(z);F.push(Q)}return new i(F)}$.join=X;function Y(H){return new I9(H)}$.identifier=Y;function w(H){return new BT(H)}$.placeholder=w;function G(H,z){return new F1(H,z)}$.param=G})(L||(L={}));(($)=>{class T{constructor(W,U){this.sql=W,this.fieldAlias=U}static[M]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new T(this.sql,this.fieldAlias)}}$.Aliased=T})(i||(i={}));class BT{constructor($){this.name=$}static[M]="Placeholder";getSQL(){return new i([this])}}function DQ($,T){return $.map((W)=>{if(j(W,BT)){if(!(W.name in T))throw new Error(`No value for placeholder "${W.name}" was provided`);return T[W.name]}if(j(W,F1)&&j(W.value,BT)){if(!(W.value.name in T))throw new Error(`No value for placeholder "${W.value.name}" was provided`);return W.encoder.mapToDriverValue(T[W.value.name])}return W})}var Wf=Symbol.for("drizzle:IsDrizzleView");class c6{static[M]="View";[i$];[Wf]=!0;constructor({name:$,schema:T,selectedFields:W,query:U}){this[i$]={name:$,originalName:$,schema:T,selectedFields:W,query:U,isExisting:!U,isAlias:!1}}getSQL(){return new i([this])}}u$.prototype.getSQL=function(){return new i([this])};p.prototype.getSQL=function(){return new i([this])};A4.prototype.getSQL=function(){return new i([this])};class wU{constructor($){this.table=$}static[M]="ColumnAliasProxyHandler";get($,T){if(T==="table")return this.table;return $[T]}}class zY{constructor($,T){this.alias=$,this.replaceOriginalName=T}static[M]="TableAliasProxyHandler";get($,T){if(T===p.Symbol.IsAlias)return!0;if(T===p.Symbol.Name)return this.alias;if(this.replaceOriginalName&&T===p.Symbol.OriginalName)return this.alias;if(T===i$)return{...$[i$],name:this.alias,isAlias:!0};if(T===p.Symbol.Columns){let U=$[p.Symbol.Columns];if(!U)return U;let X={};return Object.keys(U).map((Y)=>{X[Y]=new Proxy(U[Y],new wU(new Proxy($,this)))}),X}let W=$[T];if(j(W,u$))return new Proxy(W,new wU(new Proxy($,this)));return W}}function b9($,T){return new Proxy($,new zY(T,!1))}function z0($,T){return new Proxy($,new wU(new Proxy($.table,new zY(T,!1))))}function VQ($,T){return new i.Aliased(HY($.sql,T),$.fieldAlias)}function HY($,T){return L.join($.queryChunks.map((W)=>{if(j(W,u$))return z0(W,T);if(j(W,i))return HY(W,T);if(j(W,i.Aliased))return VQ(W,T);return W}))}class f9 extends Error{static[M]="DrizzleError";constructor({message:$,cause:T}){super($);this.name="DrizzleError",this.cause=T}}class KQ extends f9{static[M]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class nN{static[M]="ConsoleLogWriter";write($){console.log($)}}class EQ{static[M]="DefaultLogger";writer;constructor($){this.writer=$?.writer??new nN}logQuery($,T){let W=T.map((X)=>{try{return JSON.stringify(X)}catch{return String(X)}}),U=W.length?` -- params: [${W.join(", ")}]`:"";this.writer.write(`Query: ${$}${U}`)}}class AQ{static[M]="NoopLogger";logQuery(){}}class k6{static[M]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch($){return this.then(void 0,$)}finally($){return this.then((T)=>{return $?.(),T},(T)=>{throw $?.(),T})}then($,T){return this.execute().then($,T)}}function iN($,T,W){let U={},X=$.reduce((Y,{path:w,field:G},H)=>{let z;if(j(G,u$))z=G;else if(j(G,i))z=G.decoder;else z=G.sql.decoder;let F=Y;for(let[O,Q]of w.entries())if(O<w.length-1){if(!(Q in F))F[Q]={};F=F[Q]}else{let Z=T[H],V=F[Q]=Z===null?null:z.mapFromDriverValue(Z);if(W&&j(G,u$)&&w.length===2){let E=w[0];if(!(E in U))U[E]=V===null?m4(G.table):!1;else if(typeof U[E]==="string"&&U[E]!==m4(G.table))U[E]=!1}}return Y},{});if(W&&Object.keys(U).length>0){for(let[Y,w]of Object.entries(U))if(typeof w==="string"&&!W[w])X[Y]=null}return X}function J1($,T){return Object.entries($).reduce((W,[U,X])=>{if(typeof U!=="string")return W;let Y=T?[...T,U]:[U];if(j(X,u$)||j(X,i)||j(X,i.Aliased))W.push({path:Y,field:X});else if(j(X,p))W.push(...J1(X[p.Symbol.Columns],Y));else W.push(...J1(X,Y));return W},[])}function FY($,T){let W=Object.keys($),U=Object.keys(T);if(W.length!==U.length)return!1;for(let[X,Y]of W.entries())if(Y!==U[X])return!1;return!0}function y9($,T){let W=Object.entries(T).filter(([,U])=>U!==void 0).map(([U,X])=>{if(j(X,i)||j(X,u$))return[U,X];else return[U,new F1(X,$[p.Symbol.Columns][U])]});if(W.length===0)throw new Error("No values to set");return Object.fromEntries(W)}function tN($,T){for(let W of T)for(let U of Object.getOwnPropertyNames(W.prototype)){if(U==="constructor")continue;Object.defineProperty($.prototype,U,Object.getOwnPropertyDescriptor(W.prototype,U)||Object.create(null))}}function aN($){return $[p.Symbol.Columns]}function d0($){return j($,A4)?$._.alias:j($,c6)?$[i$].name:j($,i)?void 0:$[p.Symbol.IsAlias]?$[p.Symbol.Name]:$[p.Symbol.BaseName]}function P$($,T){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:T}}function sN($){if(typeof $!=="object"||$===null)return!1;if($.constructor.name!=="Object")return!1;if("logger"in $){let T=typeof $.logger;if(T!=="boolean"&&(T!=="object"||typeof $.logger.logQuery!=="function")&&T!=="undefined")return!1;return!0}if("schema"in $){let T=typeof $.schema;if(T!=="object"&&T!=="undefined")return!1;return!0}if("casing"in $){let T=typeof $.casing;if(T!=="string"&&T!=="undefined")return!1;return!0}if("mode"in $){if($.mode!=="default"||$.mode!=="planetscale"||$.mode!==void 0)return!1;return!0}if("connection"in $){let T=typeof $.connection;if(T!=="string"&&T!=="object"&&T!=="undefined")return!1;return!0}if("client"in $){let T=typeof $.client;if(T!=="object"&&T!=="function"&&T!=="undefined")return!1;return!0}if(Object.keys($).length===0)return!0;return!1}class xT extends t{static[M]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity($){if($){let{name:T,...W}=$;this.config.generatedIdentity={type:"always",sequenceName:T,sequenceOptions:W}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity($){if($){let{name:T,...W}=$;this.config.generatedIdentity={type:"byDefault",sequenceName:T,sequenceOptions:W}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class eN extends xT{static[M]="PgBigInt53Builder";constructor($){super($,"number","PgBigInt53")}build($){return new $L($,this.config)}}class $L extends u{static[M]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class TL extends xT{static[M]="PgBigInt64Builder";constructor($){super($,"bigint","PgBigInt64")}build($){return new WL($,this.config)}}class WL extends u{static[M]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue($){return BigInt($)}}function UL($,T){let{name:W,config:U}=P$($,T);if(U.mode==="number")return new eN(W);return new TL(W)}class XL extends t{static[M]="PgBigSerial53Builder";constructor($){super($,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new YL($,this.config)}}class YL extends u{static[M]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class wL extends t{static[M]="PgBigSerial64Builder";constructor($){super($,"bigint","PgBigSerial64");this.config.hasDefault=!0}build($){return new GL($,this.config)}}class GL extends u{static[M]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue($){return BigInt($)}}function zL($,T){let{name:W,config:U}=P$($,T);if(U.mode==="number")return new XL(W);return new wL(W)}class HL extends t{static[M]="PgBooleanBuilder";constructor($){super($,"boolean","PgBoolean")}build($){return new FL($,this.config)}}class FL extends u{static[M]="PgBoolean";getSQLType(){return"boolean"}}function OY($){return new HL($??"")}class OL extends t{static[M]="PgCharBuilder";constructor($,T){super($,"string","PgChar");this.config.length=T.length,this.config.enumValues=T.enum}build($){return new QL($,this.config)}}class QL extends u{static[M]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function ZL($,T={}){let{name:W,config:U}=P$($,T);return new OL(W,U)}class DL extends t{static[M]="PgCidrBuilder";constructor($){super($,"string","PgCidr")}build($){return new VL($,this.config)}}class VL extends u{static[M]="PgCidr";getSQLType(){return"cidr"}}function KL($){return new DL($??"")}class EL extends t{static[M]="PgCustomColumnBuilder";constructor($,T,W){super($,"custom","PgCustomColumn");this.config.fieldConfig=T,this.config.customTypeParams=W}build($){return new AL($,this.config)}}class AL extends u{static[M]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor($,T){super($,T);this.sqlName=T.customTypeParams.dataType(T.fieldConfig),this.mapTo=T.customTypeParams.toDriver,this.mapFrom=T.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}function ML($){return(T,W)=>{let{name:U,config:X}=P$(T,W);return new EL(U,X,$)}}class o0 extends t{static[M]="PgDateColumnBaseBuilder";defaultNow(){return this.default(L`now()`)}}class NL extends o0{static[M]="PgDateBuilder";constructor($){super($,"date","PgDate")}build($){return new h9($,this.config)}}class h9 extends u{static[M]="PgDate";getSQLType(){return"date"}mapFromDriverValue($){return new Date($)}mapToDriverValue($){return $.toISOString()}}class LL extends o0{static[M]="PgDateStringBuilder";constructor($){super($,"string","PgDateString")}build($){return new g9($,this.config)}}class g9 extends u{static[M]="PgDateString";getSQLType(){return"date"}}function JL($,T){let{name:W,config:U}=P$($,T);if(U?.mode==="date")return new NL(W);return new LL(W)}class _L extends t{static[M]="PgDoublePrecisionBuilder";constructor($){super($,"number","PgDoublePrecision")}build($){return new RL($,this.config)}}class RL extends u{static[M]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue($){if(typeof $==="string")return Number.parseFloat($);return $}}function kL($){return new _L($??"")}class vL extends t{static[M]="PgInetBuilder";constructor($){super($,"string","PgInet")}build($){return new qL($,this.config)}}class qL extends u{static[M]="PgInet";getSQLType(){return"inet"}}function PL($){return new vL($??"")}class CL extends xT{static[M]="PgIntegerBuilder";constructor($){super($,"number","PgInteger")}build($){return new SL($,this.config)}}class SL extends u{static[M]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue($){if(typeof $==="string")return Number.parseInt($);return $}}function QY($){return new CL($??"")}class jL extends t{static[M]="PgIntervalBuilder";constructor($,T){super($,"string","PgInterval");this.config.intervalConfig=T}build($){return new BL($,this.config)}}class BL extends u{static[M]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let $=this.fields?` ${this.fields}`:"",T=this.precision?`(${this.precision})`:"";return`interval${$}${T}`}}function xL($,T={}){let{name:W,config:U}=P$($,T);return new jL(W,U)}class IL extends t{static[M]="PgJsonBuilder";constructor($){super($,"json","PgJson")}build($){return new m9($,this.config)}}class m9 extends u{static[M]="PgJson";constructor($,T){super($,T)}getSQLType(){return"json"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function bL($){return new IL($??"")}class fL extends t{static[M]="PgJsonbBuilder";constructor($){super($,"json","PgJsonb")}build($){return new c9($,this.config)}}class c9 extends u{static[M]="PgJsonb";constructor($,T){super($,T)}getSQLType(){return"jsonb"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function yL($){return new fL($??"")}class hL extends t{static[M]="PgLineBuilder";constructor($){super($,"array","PgLine")}build($){return new gL($,this.config)}}class gL extends u{static[M]="PgLine";getSQLType(){return"line"}mapFromDriverValue($){let[T,W,U]=$.slice(1,-1).split(",");return[Number.parseFloat(T),Number.parseFloat(W),Number.parseFloat(U)]}mapToDriverValue($){return`{${$[0]},${$[1]},${$[2]}}`}}class mL extends t{static[M]="PgLineABCBuilder";constructor($){super($,"json","PgLineABC")}build($){return new cL($,this.config)}}class cL extends u{static[M]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue($){let[T,W,U]=$.slice(1,-1).split(",");return{a:Number.parseFloat(T),b:Number.parseFloat(W),c:Number.parseFloat(U)}}mapToDriverValue($){return`{${$.a},${$.b},${$.c}}`}}function uL($,T){let{name:W,config:U}=P$($,T);if(!U?.mode||U.mode==="tuple")return new hL(W);return new mL(W)}class pL extends t{static[M]="PgMacaddrBuilder";constructor($){super($,"string","PgMacaddr")}build($){return new dL($,this.config)}}class dL extends u{static[M]="PgMacaddr";getSQLType(){return"macaddr"}}function oL($){return new pL($??"")}class lL extends t{static[M]="PgMacaddr8Builder";constructor($){super($,"string","PgMacaddr8")}build($){return new rL($,this.config)}}class rL extends u{static[M]="PgMacaddr8";getSQLType(){return"macaddr8"}}function nL($){return new lL($??"")}class iL extends t{static[M]="PgNumericBuilder";constructor($,T,W){super($,"string","PgNumeric");this.config.precision=T,this.config.scale=W}build($){return new u9($,this.config)}}class u9 extends u{static[M]="PgNumeric";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class tL extends t{static[M]="PgNumericNumberBuilder";constructor($,T,W){super($,"number","PgNumericNumber");this.config.precision=T,this.config.scale=W}build($){return new aL($,this.config)}}class aL extends u{static[M]="PgNumericNumber";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class sL extends t{static[M]="PgNumericBigIntBuilder";constructor($,T,W){super($,"bigint","PgNumericBigInt");this.config.precision=T,this.config.scale=W}build($){return new eL($,this.config)}}class eL extends u{static[M]="PgNumericBigInt";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}function $J($,T){let{name:W,config:U}=P$($,T),X=U?.mode;return X==="number"?new tL(W,U?.precision,U?.scale):X==="bigint"?new sL(W,U?.precision,U?.scale):new iL(W,U?.precision,U?.scale)}class TJ extends t{static[M]="PgPointTupleBuilder";constructor($){super($,"array","PgPointTuple")}build($){return new WJ($,this.config)}}class WJ extends u{static[M]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[T,W]=$.slice(1,-1).split(",");return[Number.parseFloat(T),Number.parseFloat(W)]}return[$.x,$.y]}mapToDriverValue($){return`(${$[0]},${$[1]})`}}class UJ extends t{static[M]="PgPointObjectBuilder";constructor($){super($,"json","PgPointObject")}build($){return new XJ($,this.config)}}class XJ extends u{static[M]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[T,W]=$.slice(1,-1).split(",");return{x:Number.parseFloat(T),y:Number.parseFloat(W)}}return $}mapToDriverValue($){return`(${$.x},${$.y})`}}function YJ($,T){let{name:W,config:U}=P$($,T);if(!U?.mode||U.mode==="tuple")return new TJ(W);return new UJ(W)}function Uf($){let T=[];for(let W=0;W<$.length;W+=2)T.push(Number.parseInt($.slice(W,W+2),16));return new Uint8Array(T)}function wJ($,T){let W=new ArrayBuffer(8),U=new DataView(W);for(let X=0;X<8;X++)U.setUint8(X,$[T+X]);return U.getFloat64(0,!0)}function MQ($){let T=Uf($),W=0,U=T[W];W+=1;let X=new DataView(T.buffer),Y=X.getUint32(W,U===1);W+=4;let w;if(Y&536870912)w=X.getUint32(W,U===1),W+=4;if((Y&65535)===1){let G=wJ(T,W);W+=8;let H=wJ(T,W);return W+=8,[G,H]}throw new Error("Unsupported geometry type")}class GJ extends t{static[M]="PgGeometryBuilder";constructor($){super($,"array","PgGeometry")}build($){return new zJ($,this.config)}}class zJ extends u{static[M]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue($){return MQ($)}mapToDriverValue($){return`point(${$[0]} ${$[1]})`}}class HJ extends t{static[M]="PgGeometryObjectBuilder";constructor($){super($,"json","PgGeometryObject")}build($){return new FJ($,this.config)}}class FJ extends u{static[M]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue($){let T=MQ($);return{x:T[0],y:T[1]}}mapToDriverValue($){return`point(${$.x} ${$.y})`}}function OJ($,T){let{name:W,config:U}=P$($,T);if(!U?.mode||U.mode==="tuple")return new GJ(W);return new HJ(W)}class QJ extends t{static[M]="PgRealBuilder";constructor($,T){super($,"number","PgReal");this.config.length=T}build($){return new ZJ($,this.config)}}class ZJ extends u{static[M]="PgReal";constructor($,T){super($,T)}getSQLType(){return"real"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number.parseFloat($);return $}}function DJ($){return new QJ($??"")}class VJ extends t{static[M]="PgSerialBuilder";constructor($){super($,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new KJ($,this.config)}}class KJ extends u{static[M]="PgSerial";getSQLType(){return"serial"}}function EJ($){return new VJ($??"")}class AJ extends xT{static[M]="PgSmallIntBuilder";constructor($){super($,"number","PgSmallInt")}build($){return new MJ($,this.config)}}class MJ extends u{static[M]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number($);return $}}function NJ($){return new AJ($??"")}class LJ extends t{static[M]="PgSmallSerialBuilder";constructor($){super($,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new JJ($,this.config)}}class JJ extends u{static[M]="PgSmallSerial";getSQLType(){return"smallserial"}}function _J($){return new LJ($??"")}class RJ extends t{static[M]="PgTextBuilder";constructor($,T){super($,"string","PgText");this.config.enumValues=T.enum}build($){return new kJ($,this.config)}}class kJ extends u{static[M]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function vJ($,T={}){let{name:W,config:U}=P$($,T);return new RJ(W,U)}class qJ extends o0{constructor($,T,W){super($,"string","PgTime");this.withTimezone=T,this.precision=W,this.config.withTimezone=T,this.config.precision=W}static[M]="PgTimeBuilder";build($){return new p9($,this.config)}}class p9 extends u{static[M]="PgTime";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function PJ($,T={}){let{name:W,config:U}=P$($,T);return new qJ(W,U.withTimezone??!1,U.precision)}class CJ extends o0{static[M]="PgTimestampBuilder";constructor($,T,W){super($,"date","PgTimestamp");this.config.withTimezone=T,this.config.precision=W}build($){return new d9($,this.config)}}class d9 extends u{static[M]="PgTimestamp";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=($)=>{return new Date(this.withTimezone?$:$+"+0000")};mapToDriverValue=($)=>{return $.toISOString()}}class SJ extends o0{static[M]="PgTimestampStringBuilder";constructor($,T,W){super($,"string","PgTimestampString");this.config.withTimezone=T,this.config.precision=W}build($){return new o9($,this.config)}}class o9 extends u{static[M]="PgTimestampString";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function jJ($,T={}){let{name:W,config:U}=P$($,T);if(U?.mode==="string")return new SJ(W,U.withTimezone??!1,U.precision);return new CJ(W,U?.withTimezone??!1,U?.precision)}class BJ extends t{static[M]="PgUUIDBuilder";constructor($){super($,"string","PgUUID")}defaultRandom(){return this.default(L`gen_random_uuid()`)}build($){return new l9($,this.config)}}class l9 extends u{static[M]="PgUUID";getSQLType(){return"uuid"}}function _1($){return new BJ($??"")}class xJ extends t{static[M]="PgVarcharBuilder";constructor($,T){super($,"string","PgVarchar");this.config.length=T.length,this.config.enumValues=T.enum}build($){return new IJ($,this.config)}}class IJ extends u{static[M]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function T6($,T={}){let{name:W,config:U}=P$($,T);return new xJ(W,U)}class bJ extends t{static[M]="PgBinaryVectorBuilder";constructor($,T){super($,"string","PgBinaryVector");this.config.dimensions=T.dimensions}build($){return new fJ($,this.config)}}class fJ extends u{static[M]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function yJ($,T){let{name:W,config:U}=P$($,T);return new bJ(W,U)}class hJ extends t{static[M]="PgHalfVectorBuilder";constructor($,T){super($,"array","PgHalfVector");this.config.dimensions=T.dimensions}build($){return new gJ($,this.config)}}class gJ extends u{static[M]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((T)=>Number.parseFloat(T))}}function mJ($,T){let{name:W,config:U}=P$($,T);return new hJ(W,U)}class cJ extends t{static[M]="PgSparseVectorBuilder";constructor($,T){super($,"string","PgSparseVector");this.config.dimensions=T.dimensions}build($){return new uJ($,this.config)}}class uJ extends u{static[M]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function pJ($,T){let{name:W,config:U}=P$($,T);return new cJ(W,U)}class dJ extends t{static[M]="PgVectorBuilder";constructor($,T){super($,"array","PgVector");this.config.dimensions=T.dimensions}build($){return new oJ($,this.config)}}class oJ extends u{static[M]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((T)=>Number.parseFloat(T))}}function lJ($,T){let{name:W,config:U}=P$($,T);return new dJ(W,U)}function rJ(){return{bigint:UL,bigserial:zL,boolean:OY,char:ZL,cidr:KL,customType:ML,date:JL,doublePrecision:kL,inet:PL,integer:QY,interval:xL,json:bL,jsonb:yL,line:uL,macaddr:oL,macaddr8:nL,numeric:$J,point:YJ,geometry:OJ,real:DJ,serial:EJ,smallint:NJ,smallserial:_J,text:vJ,time:PJ,timestamp:jJ,uuid:_1,varchar:T6,bit:yJ,halfvec:mJ,sparsevec:pJ,vector:lJ}}var NQ=Symbol.for("drizzle:PgInlineForeignKeys"),nJ=Symbol.for("drizzle:EnableRLS");class B4 extends p{static[M]="PgTable";static Symbol=Object.assign({},p.Symbol,{InlineForeignKeys:NQ,EnableRLS:nJ});[NQ]=[];[nJ]=!1;[p.Symbol.ExtraConfigBuilder]=void 0;[p.Symbol.ExtraConfigColumns]={}}function Xf($,T,W,U,X=$){let Y=new B4($,U,X),w=typeof T==="function"?T(rJ()):T,G=Object.fromEntries(Object.entries(w).map(([F,O])=>{let Q=O;Q.setName(F);let Z=Q.build(Y);return Y[NQ].push(...Q.buildForeignKeys(Z,Y)),[F,Z]})),H=Object.fromEntries(Object.entries(w).map(([F,O])=>{let Q=O;Q.setName(F);let Z=Q.buildExtraConfigColumn(Y);return[F,Z]})),z=Object.assign(Y,G);if(z[p.Symbol.Columns]=G,z[p.Symbol.ExtraConfigColumns]=H,W)z[B4.Symbol.ExtraConfigBuilder]=W;return Object.assign(z,{enableRLS:()=>{return z[B4.Symbol.EnableRLS]=!0,z}})}var IT=($,T,W)=>{return Xf($,T,W,void 0)};function iJ(...$){if($[0].columns)return new ZY($[0].columns,$[0].name);return new ZY($)}class ZY{static[M]="PgPrimaryKeyBuilder";columns;name;constructor($,T){this.columns=$,this.name=T}build($){return new tJ($,this.columns,this.name)}}class tJ{constructor($,T,W){this.table=$,this.columns=T,this.name=W}static[M]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[B4.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}function u6($,T){if(oN(T)&&!ZQ($)&&!j($,F1)&&!j($,BT)&&!j($,u$)&&!j($,p)&&!j($,c6))return new F1($,T);return $}var r9=($,T)=>{return L`${$} = ${u6(T,$)}`},aJ=($,T)=>{return L`${$} <> ${u6(T,$)}`};function DY(...$){let T=$.filter((W)=>W!==void 0);if(T.length===0)return;if(T.length===1)return new i(T);return new i([new j4("("),L.join(T,new j4(" and ")),new j4(")")])}function sJ(...$){let T=$.filter((W)=>W!==void 0);if(T.length===0)return;if(T.length===1)return new i(T);return new i([new j4("("),L.join(T,new j4(" or ")),new j4(")")])}function eJ($){return L`not ${$}`}var n9=($,T)=>{return L`${$} > ${u6(T,$)}`},$_=($,T)=>{return L`${$} >= ${u6(T,$)}`},T_=($,T)=>{return L`${$} < ${u6(T,$)}`},W_=($,T)=>{return L`${$} <= ${u6(T,$)}`};function U_($,T){if(Array.isArray(T)){if(T.length===0)return L`false`;return L`${$} in ${T.map((W)=>u6(W,$))}`}return L`${$} in ${u6(T,$)}`}function X_($,T){if(Array.isArray(T)){if(T.length===0)return L`true`;return L`${$} not in ${T.map((W)=>u6(W,$))}`}return L`${$} not in ${u6(T,$)}`}function Y_($){return L`${$} is null`}function w_($){return L`${$} is not null`}function G_($){return L`exists ${$}`}function z_($){return L`not exists ${$}`}function H_($,T,W){return L`${$} between ${u6(T,$)} and ${u6(W,$)}`}function F_($,T,W){return L`${$} not between ${u6(T,$)} and ${u6(W,$)}`}function O_($,T){return L`${$} like ${T}`}function Q_($,T){return L`${$} not like ${T}`}function Z_($,T){return L`${$} ilike ${T}`}function D_($,T){return L`${$} not ilike ${T}`}function V_($){return L`${$} asc`}function K_($){return L`${$} desc`}class LQ{constructor($,T,W){this.sourceTable=$,this.referencedTable=T,this.relationName=W,this.referencedTableName=T[p.Symbol.Name]}static[M]="Relation";referencedTableName;fieldName}class E_{constructor($,T){this.table=$,this.config=T}static[M]="Relations"}class bT extends LQ{constructor($,T,W,U){super($,T,W?.relationName);this.config=W,this.isNullable=U}static[M]="One";withFieldName($){let T=new bT(this.sourceTable,this.referencedTable,this.config,this.isNullable);return T.fieldName=$,T}}class VY extends LQ{constructor($,T,W){super($,T,W?.relationName);this.config=W}static[M]="Many";withFieldName($){let T=new VY(this.sourceTable,this.referencedTable,this.config);return T.fieldName=$,T}}function A_(){return{and:DY,between:H_,eq:r9,exists:G_,gt:n9,gte:$_,ilike:Z_,inArray:U_,isNull:Y_,isNotNull:w_,like:O_,lt:T_,lte:W_,ne:aJ,not:eJ,notBetween:F_,notExists:z_,notLike:Q_,notIlike:D_,notInArray:X_,or:sJ,sql:L}}function M_(){return{sql:L,asc:V_,desc:K_}}function N_($,T){if(Object.keys($).length===1&&"default"in $&&!j($.default,p))$=$.default;let W={},U={},X={};for(let[Y,w]of Object.entries($))if(j(w,p)){let G=hW(w),H=U[G];W[G]=Y,X[Y]={tsName:Y,dbName:w[p.Symbol.Name],schema:w[p.Symbol.Schema],columns:w[p.Symbol.Columns],relations:H?.relations??{},primaryKey:H?.primaryKey??[]};for(let F of Object.values(w[p.Symbol.Columns]))if(F.primary)X[Y].primaryKey.push(F);let z=w[p.Symbol.ExtraConfigBuilder]?.(w[p.Symbol.ExtraConfigColumns]);if(z){for(let F of Object.values(z))if(j(F,ZY))X[Y].primaryKey.push(...F.columns)}}else if(j(w,E_)){let G=hW(w.table),H=W[G],z=w.config(T(w.table)),F;for(let[O,Q]of Object.entries(z))if(H){let Z=X[H];if(Z.relations[O]=Q,F)Z.primaryKey.push(...F)}else{if(!(G in U))U[G]={relations:{},primaryKey:F};U[G].relations[O]=Q}}return{tables:X,tableNamesMap:W}}function Yf($){return function T(W,U){return new bT($,W,U,U?.fields.reduce((X,Y)=>X&&Y.notNull,!0)??!1)}}function wf($){return function T(W,U){return new VY($,W,U)}}function L_($,T,W){if(j(W,bT)&&W.config)return{fields:W.config.fields,references:W.config.references};let U=T[hW(W.referencedTable)];if(!U)throw new Error(`Table "${W.referencedTable[p.Symbol.Name]}" not found in schema`);let X=$[U];if(!X)throw new Error(`Table "${U}" not found in schema`);let Y=W.sourceTable,w=T[hW(Y)];if(!w)throw new Error(`Table "${Y[p.Symbol.Name]}" not found in schema`);let G=[];for(let H of Object.values(X.relations))if(W.relationName&&W!==H&&H.relationName===W.relationName||!W.relationName&&H.referencedTable===W.sourceTable)G.push(H);if(G.length>1)throw W.relationName?new Error(`There are multiple relations with name "${W.relationName}" in table "${U}"`):new Error(`There are multiple relations between "${U}" and "${W.sourceTable[p.Symbol.Name]}". Please specify relation name`);if(G[0]&&j(G[0],bT)&&G[0].config)return{fields:G[0].config.references,references:G[0].config.fields};throw new Error(`There is not enough information to infer relation "${w}.${W.fieldName}"`)}function J_($){return{one:Yf($),many:wf($)}}function i9($,T,W,U,X=(Y)=>Y){let Y={};for(let[w,G]of U.entries())if(G.isJson){let H=T.relations[G.tsKey],z=W[w],F=typeof z==="string"?JSON.parse(z):z;Y[G.tsKey]=j(H,bT)?F&&i9($,$[G.relationTableTsKey],F,G.selection,X):F.map((O)=>i9($,$[G.relationTableTsKey],O,G.selection,X))}else{let H=X(W[w]),z=G.field,F;if(j(z,u$))F=z;else if(j(z,i))F=z.decoder;else F=z.sql.decoder;Y[G.tsKey]=H===null?null:F.mapFromDriverValue(H)}return Y}import tm from"path";import Sf from"os";import jf from"fs";var t9=new Map,JQ=new Map,_Q=Symbol("OriginError"),GU={};class R1 extends Promise{constructor($,T,W,U,X={}){let Y,w;super((G,H)=>{Y=G,w=H});this.tagged=Array.isArray($.raw),this.strings=$,this.args=T,this.handler=W,this.canceller=U,this.options=X,this.state=null,this.statement=null,this.resolve=(G)=>(this.active=!1,Y(G)),this.reject=(G)=>(this.active=!1,w(G)),this.active=!1,this.cancelled=null,this.executed=!1,this.signature="",this[_Q]=this.handler.debug?new Error:this.tagged&&Gf(this.strings)}get origin(){return(this.handler.debug?this[_Q].stack:this.tagged&&JQ.has(this.strings)?JQ.get(this.strings):JQ.set(this.strings,this[_Q].stack).get(this.strings))||""}static get[Symbol.species](){return Promise}cancel(){return this.canceller&&(this.canceller(this),this.canceller=null)}simple(){return this.options.simple=!0,this.options.prepare=!1,this}async readable(){return this.simple(),this.streaming=!0,this}async writable(){return this.simple(),this.streaming=!0,this}cursor($=1,T){if(this.options.simple=!1,typeof $==="function")T=$,$=1;if(this.cursorRows=$,typeof T==="function")return this.cursorFn=T,this;let W;return{[Symbol.asyncIterator]:()=>({next:()=>{if(this.executed&&!this.active)return{done:!0};W&&W();let U=new Promise((X,Y)=>{this.cursorFn=(w)=>{return X({value:w,done:!1}),new Promise((G)=>W=G)},this.resolve=()=>(this.active=!1,X({done:!0})),this.reject=(w)=>(this.active=!1,Y(w))});return this.execute(),U},return(){return W&&W(GU),{done:!0}}})}}describe(){return this.options.simple=!1,this.onlyDescribe=this.options.prepare=!0,this}stream(){throw new Error(".stream has been renamed to .forEach")}forEach($){return this.forEachFn=$,this.handle(),this}raw(){return this.isRaw=!0,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=!0)&&await 1&&this.handler(this)}execute(){return this.handle(),this}then(){return this.handle(),super.then.apply(this,arguments)}catch(){return this.handle(),super.catch.apply(this,arguments)}finally(){return this.handle(),super.finally.apply(this,arguments)}}function Gf($){if(t9.has($))return t9.get($);let T=Error.stackTraceLimit;return Error.stackTraceLimit=4,t9.set($,new Error),Error.stackTraceLimit=T,t9.get($)}class zU extends Error{constructor($){super($.message);this.name=this.constructor.name,Object.assign(this,$)}}var J4={connection:__,postgres:R_,generic:k_,notSupported:v_};function __($,T,W){let{host:U,port:X}=W||T,Y=Object.assign(new Error("write "+$+" "+(T.path||U+":"+X)),{code:$,errno:$,address:T.path||U},T.path?{}:{port:X});return Error.captureStackTrace(Y,__),Y}function R_($){let T=new zU($);return Error.captureStackTrace(T,R_),T}function k_($,T){let W=Object.assign(new Error($+": "+T),{code:$});return Error.captureStackTrace(W,k_),W}function v_($){let T=Object.assign(new Error($+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:$});return Error.captureStackTrace(T,v_),T}var zf={string:{to:25,from:null,serialize:($)=>""+$},number:{to:0,from:[21,23,26,700,701],serialize:($)=>""+$,parse:($)=>+$},json:{to:114,from:[114,3802],serialize:($)=>JSON.stringify($),parse:($)=>JSON.parse($)},boolean:{to:16,from:16,serialize:($)=>$===!0?"t":"f",parse:($)=>$==="t"},date:{to:1184,from:[1082,1114,1184],serialize:($)=>($ instanceof Date?$:new Date($)).toISOString(),parse:($)=>new Date($)},bytea:{to:17,from:17,serialize:($)=>"\\x"+Buffer.from($).toString("hex"),parse:($)=>Buffer.from($.slice(2),"hex")}};class e9{then(){RQ()}catch(){RQ()}finally(){RQ()}}class MY extends e9{constructor($){super();this.value=Wz($)}}class H0 extends e9{constructor($,T,W){super();this.value=$,this.type=T,this.array=W}}class $z extends e9{constructor($,T){super();this.first=$,this.rest=T}build($,T,W,U){let X=Hf.map(([Y,w])=>({fn:w,i:$.search(Y)})).sort((Y,w)=>Y.i-w.i).pop();return X.i===-1?CQ(this.first,U):X.fn(this.first,this.rest,T,W,U)}}function Tz($,T,W,U){let X=$ instanceof H0?$.value:$;if(X===void 0){if($ instanceof H0?$.value=U.transform.undefined:X=$=U.transform.undefined,X===void 0)throw J4.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return"$"+W.push($ instanceof H0?(T.push($.value),$.array?$.array[$.type||s9($.value)]||$.type||S_($.value):$.type):(T.push($),s9($)))}var P_=B_(zf);function qQ($,T,W,U,X,Y){for(let w=1;w<$.strings.length;w++)T+=PQ(T,W,U,X,Y)+$.strings[w],W=$.args[w];return T}function PQ($,T,W,U,X){return T instanceof $z?T.build($,W,U,X):T instanceof R1?vQ(T,W,U,X):T instanceof MY?T.value:T&&T[0]instanceof R1?T.reduce((Y,w)=>Y+" "+vQ(w,W,U,X),""):Tz(T,W,U,X)}function vQ($,T,W,U){return $.fragment=!0,qQ($,$.strings[0],$.args[0],T,W,U)}function C_($,T,W,U,X){return $.map((Y)=>"("+U.map((w)=>PQ("values",Y[w],T,W,X)).join(",")+")").join(",")}function q_($,T,W,U,X){let Y=Array.isArray($[0]),w=T.length?T.flat():Object.keys(Y?$[0]:$);return C_(Y?$:[$],W,U,w,X)}function a9($,T,W,U,X){if(typeof $==="string"&&($=[$].concat(T)),Array.isArray($))return CQ($,X);let Y;return(T.length?T.flat():Object.keys($)).map((G)=>{return Y=$[G],(Y instanceof R1?vQ(Y,W,U,X):Y instanceof MY?Y.value:Tz(Y,W,U,X))+" as "+Wz(X.transform.column.to?X.transform.column.to(G):G)}).join(",")}var Hf=Object.entries({values:q_,in:(...$)=>{let T=q_(...$);return T==="()"?"(null)":T},select:a9,as:a9,returning:a9,"\\(":a9,update($,T,W,U,X){return(T.length?T.flat():Object.keys($)).map((Y)=>Wz(X.transform.column.to?X.transform.column.to(Y):Y)+"="+PQ("values",$[Y],W,U,X))},insert($,T,W,U,X){let Y=T.length?T.flat():Object.keys(Array.isArray($)?$[0]:$);return"("+CQ(Y,X)+")values"+C_(Array.isArray($)?$:[$],W,U,Y,X)}}).map(([$,T])=>[new RegExp("((?:^|[\\s(])"+$+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),T]);function RQ(){throw J4.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var{serializers:Ff,parsers:Of}=P_;function S_($){if(Array.isArray($))return S_($[0]);return typeof $==="string"?1009:0}var j_=function($){let T=B_($||{});return{serializers:Object.assign({},Ff,T.serializers),parsers:Object.assign({},Of,T.parsers)}};function B_($){return Object.keys($).reduce((T,W)=>{if($[W].from&&[].concat($[W].from).forEach((U)=>T.parsers[U]=$[W].parse),$[W].serialize)T.serializers[$[W].to]=$[W].serialize,$[W].from&&[].concat($[W].from).forEach((U)=>T.serializers[U]=$[W].serialize);return T},{parsers:{},serializers:{}})}function CQ($,{transform:{column:T}}){return $.map((W)=>Wz(T.to?T.to(W):W)).join(",")}var Wz=function $(T){return'"'+T.replace(/"/g,'""').replace(/\./g,'"."')+'"'},s9=function $(T){return T instanceof H0?T.type:T instanceof Date?1184:T instanceof Uint8Array?17:T===!0||T===!1?16:typeof T==="bigint"?20:Array.isArray(T)?$(T[0]):0},Qf=/\\/g,Zf=/"/g;function Df($){return $.replace(Qf,"\\\\").replace(Zf,"\\\"")}var x_=function $(T,W,U,X){if(Array.isArray(T)===!1)return T;if(!T.length)return"{}";let Y=T[0],w=X===1020?";":",";if(Array.isArray(Y)&&!Y.type)return"{"+T.map((G)=>$(G,W,U,X)).join(w)+"}";return"{"+T.map((G)=>{if(G===void 0){if(G=U.transform.undefined,G===void 0)throw J4.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return G===null?"null":'"'+Df(W?W(G.type?G.value:G):""+G)+'"'}).join(w)+"}"},kQ={i:0,char:null,str:"",quoted:!1,last:0},I_=function $(T,W,U){return kQ.i=kQ.last=0,b_(kQ,T,W,U)};function b_($,T,W,U){let X=[],Y=U===1020?";":",";for(;$.i<T.length;$.i++){if($.char=T[$.i],$.quoted)if($.char==="\\")$.str+=T[++$.i];else if($.char==='"')X.push(W?W($.str):$.str),$.str="",$.quoted=T[$.i+1]==='"',$.last=$.i+2;else $.str+=$.char;else if($.char==='"')$.quoted=!0;else if($.char==="{")$.last=++$.i,X.push(b_($,T,W,U));else if($.char==="}"){$.quoted=!1,$.last<$.i&&X.push(W?W(T.slice($.last,$.i)):T.slice($.last,$.i)),$.last=$.i+1;break}else if($.char===Y&&$.p!=="}"&&$.p!=='"')X.push(W?W(T.slice($.last,$.i)):T.slice($.last,$.i)),$.last=$.i+1;$.p=$.char}return $.last<$.i&&X.push(W?W(T.slice($.last,$.i+1)):T.slice($.last,$.i+1)),X}var gW=($)=>{let T=$[0];for(let W=1;W<$.length;W++)T+=$[W]==="_"?$[++W].toUpperCase():$[W];return T},mW=($)=>{let T=$[0].toUpperCase();for(let W=1;W<$.length;W++)T+=$[W]==="_"?$[++W].toUpperCase():$[W];return T},cW=($)=>$.replace(/_/g,"-"),KY=($)=>$.replace(/([A-Z])/g,"_$1").toLowerCase(),EY=($)=>($.slice(0,1)+$.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),AY=($)=>$.replace(/-/g,"_");function SQ($){return function T(W,U){return typeof W==="object"&&W!==null&&(U.type===114||U.type===3802)?Array.isArray(W)?W.map((X)=>T(X,U)):Object.entries(W).reduce((X,[Y,w])=>Object.assign(X,{[$(Y)]:T(w,U)}),{}):W}}gW.column={from:gW};gW.value={from:SQ(gW)};KY.column={to:KY};var jQ={...gW};jQ.column.to=KY;mW.column={from:mW};mW.value={from:SQ(mW)};EY.column={to:EY};var BQ={...mW};BQ.column.to=EY;cW.column={from:cW};cW.value={from:SQ(cW)};AY.column={to:AY};var xQ={...cW};xQ.column.to=AY;import f_ from"net";import Af from"tls";import NY from"crypto";import IQ from"stream";import{performance as y_}from"perf_hooks";class uW extends Array{constructor(){super();Object.defineProperties(this,{count:{value:null,writable:!0},state:{value:null,writable:!0},command:{value:null,writable:!0},columns:{value:null,writable:!0},statement:{value:null,writable:!0}})}static get[Symbol.species](){return Array}}var O1=Vf;function Vf($=[]){let T=$.slice(),W=0;return{get length(){return T.length-W},remove:(U)=>{let X=T.indexOf(U);return X===-1?null:(T.splice(X,1),U)},push:(U)=>(T.push(U),U),shift:()=>{let U=T[W++];if(W===T.length)W=0,T=[];else T[W-1]=void 0;return U}}}var W6=Buffer.allocUnsafe(256),Kf="BCcDdEFfHPpQSX".split("").reduce(($,T)=>{let W=T.charCodeAt(0);return $[T]=()=>{return W6[0]=W,c$.i=5,c$},$},{}),c$=Object.assign(Ef,Kf,{N:String.fromCharCode(0),i:0,inc($){return c$.i+=$,c$},str($){let T=Buffer.byteLength($);return Uz(T),c$.i+=W6.write($,c$.i,T,"utf8"),c$},i16($){return Uz(2),W6.writeUInt16BE($,c$.i),c$.i+=2,c$},i32($,T){if(T||T===0)return W6.writeUInt32BE($,T),c$;return Uz(4),W6.writeUInt32BE($,c$.i),c$.i+=4,c$},z($){return Uz($),W6.fill(0,c$.i,c$.i+$),c$.i+=$,c$},raw($){return W6=Buffer.concat([W6.subarray(0,c$.i),$]),c$.i=W6.length,c$},end($=1){W6.writeUInt32BE(c$.i-$,$);let T=W6.subarray(0,c$.i);return c$.i=0,W6=Buffer.allocUnsafe(256),T}}),U$=c$;function Uz($){if(W6.length-c$.i<$){let T=W6,W=T.length;W6=Buffer.allocUnsafe(W+(W>>1)+$),T.copy(W6)}}function Ef(){return c$.i=0,c$}var yQ=m_,Mf=1,fT=U$().S().end(),h_=U$().H().end(),Nf=U$().i32(8).i32(80877103).end(8),Lf=Buffer.concat([U$().E().str(U$.N).i32(0).end(),fT]),Jf=U$().D().str("S").str(U$.N).end(),HU=()=>{},_f=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),Rf={83:"severity_local",86:"severity",67:"code",77:"message",68:"detail",72:"hint",80:"position",112:"internal_position",113:"internal_query",87:"where",115:"schema_name",116:"table_name",99:"column_name",100:"data type_name",110:"constraint_name",70:"file",76:"line",82:"routine"};function m_($,T={},{onopen:W=HU,onend:U=HU,onclose:X=HU}={}){let{ssl:Y,max:w,user:G,host:H,port:z,database:F,parsers:O,transform:Q,onnotice:Z,onnotify:V,onparameter:E,max_pipeline:N,keep_alive:J,backoff:_,target_session_attrs:R}=$,P=O1(),x=Mf++,f={pid:null,secret:null},h=fQ(rz,$.idle_timeout),a=fQ(rz,$.max_lifetime),M$=fQ(qq,$.connect_timeout),S=null,W$,n=new uW,Y$=Buffer.alloc(0),j$=$.fetch_types,s$={},f4={},n6=Math.random().toString(36).slice(2),g=1,G$=0,y$=0,Y4=0,R4=0,N$=0,h$=0,M4=0,w4=null,e$=null,n4=!1,o$=null,C1=null,c4=null,XT=null,k4=null,$4=null,S1=null,o1=null,l=null,BU=null,i4={queue:T.closed,idleTimer:h,connect(A){c4=A,CD()},terminate:IU,execute:xU,cancel:_q,end:rz,count:0,id:x};return T.closed&&T.closed.push(i4),i4;async function Jq(){let A;try{A=$.socket?await Promise.resolve($.socket($)):new f_.Socket}catch(v){sW(v);return}return A.on("error",sW),A.on("close",SD),A.on("drain",qD),A}async function _q({pid:A,secret:v},w$,x$){try{W$=U$().i32(16).i32(80877102).i32(A).i32(v).end(16),await PD(),S.once("error",x$),S.once("close",w$)}catch(D4){x$(D4)}}function xU(A){if(n4)return Uw(A,J4.connection("CONNECTION_DESTROYED",$));if(A.cancelled)return;try{return A.state=f,l?P.push(A):(l=A,l.active=!0),vq(A),u4(Rq(A))&&!A.describeFirst&&!A.cursorFn&&P.length<N&&(!A.options.onexecute||A.options.onexecute(i4))}catch(v){return P.length===0&&u4(fT),l1(v),!0}}function Rq(A){if(A.parameters.length>=65534)throw J4.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return A.options.simple?U$().Q().str(A.statement.string+U$.N).end():A.describeFirst?Buffer.concat([RD(A),h_]):A.prepare?A.prepared?Ww(A):Buffer.concat([RD(A),Ww(A)]):kq(A)}function RD(A){return Buffer.concat([BD(A.statement.string,A.parameters,A.statement.types,A.statement.name),OP("S",A.statement.name)])}function Ww(A){return Buffer.concat([FP(A.parameters,A.statement.types,A.statement.name,A.cursorName),A.cursorFn?xD("",A.cursorRows):Lf])}function kq(A){return Buffer.concat([BD(A.statement.string,A.parameters,A.statement.types),Jf,Ww(A)])}function vq(A){let v=[],w$=[],x$=qQ(A,A.strings[0],A.args[0],v,w$,$);!A.tagged&&A.args.forEach((D4)=>Tz(D4,v,w$,$)),A.prepare=$.prepare&&("prepare"in A.options?A.options.prepare:!0),A.string=x$,A.signature=A.prepare&&w$+x$,A.onlyDescribe&&delete f4[A.signature],A.parameters=A.parameters||v,A.prepared=A.prepare&&A.signature in f4,A.describeFirst=A.onlyDescribe||v.length&&!A.prepared,A.statement=A.prepared?f4[A.signature]:{string:x$,types:w$,name:A.prepare?n6+g++:""},typeof $.debug==="function"&&$.debug(x,x$,v,w$)}function u4(A,v){if($4=$4?Buffer.concat([$4,A]):Buffer.from(A),v||$4.length>=1024)return kD(v);return e$===null&&(e$=setImmediate(kD)),!0}function kD(A){let v=S.write($4,A);return e$!==null&&clearImmediate(e$),$4=e$=null,v}function qq(){l1(J4.connection("CONNECT_TIMEOUT",$,S)),S.destroy()}async function vD(){if(u4(Nf),!await new Promise((v)=>S.once("data",(w$)=>v(w$[0]===83)))&&Y==="prefer")return aW();S.removeAllListeners(),S=Af.connect({socket:S,servername:f_.isIP(S.host)?void 0:S.host,...Y==="require"||Y==="allow"||Y==="prefer"?{rejectUnauthorized:!1}:Y==="verify-full"?{}:typeof Y==="object"?Y:{}}),S.on("secureConnect",aW),S.on("error",sW),S.on("close",SD),S.on("drain",qD)}function qD(){!l&&W(i4)}function lz(A){if(o$){if(o$.push(A),y$-=A.length,y$>0)return}Y$=o$?Buffer.concat(o$,N$-y$):Y$.length===0?A:Buffer.concat([Y$,A],Y$.length+A.length);while(Y$.length>4){if(N$=Y$.readUInt32BE(1),N$>=Y$.length){y$=N$-Y$.length,o$=[Y$];break}try{Pq(Y$.subarray(0,N$+1))}catch(v){l&&(l.cursorFn||l.describeFirst)&&u4(fT),l1(v)}Y$=Y$.subarray(N$+1),y$=0,o$=null}}async function PD(){if(n4=!1,s$={},S||(S=await Jq()),!S)return;if(M$.start(),$.socket)return Y?vD():aW();if(S.on("connect",Y?vD:aW),$.path)return S.connect($.path);S.ssl=Y,S.connect(z[Y4],H[Y4]),S.host=H[Y4],S.port=z[Y4],Y4=(Y4+1)%z.length}function CD(){setTimeout(PD,G$?G$+h$-y_.now():0)}function aW(){try{f4={},j$=$.fetch_types,n6=Math.random().toString(36).slice(2),g=1,a.start(),S.on("data",lz),J&&S.setKeepAlive&&S.setKeepAlive(!0,1000*J);let A=ZP();u4(A)}catch(A){sW(A)}}function sW(A){if(i4.queue===T.connecting&&$.host[R4+1])return;l1(A);while(P.length)Uw(P.shift(),A)}function l1(A){k4&&(k4.destroy(A),k4=null),l&&Uw(l,A),c4&&(Uw(c4,A),c4=null)}function Uw(A,v){if(A.reserve)return A.reject(v);if(!v||typeof v!=="object")v=new Error(v);"query"in v||"parameters"in v||Object.defineProperties(v,{stack:{value:v.stack+A.origin.replace(/.*\n/,`
|
|
81
|
+
`),enumerable:$.debug},query:{value:A.string,enumerable:$.debug},parameters:{value:A.parameters,enumerable:$.debug},args:{value:A.args,enumerable:$.debug},types:{value:A.statement&&A.statement.types,enumerable:$.debug}}),A.reject(v)}function rz(){return XT||(!i4.reserved&&U(i4),!i4.reserved&&!c4&&!l&&P.length===0?(IU(),new Promise((A)=>S&&S.readyState!=="closed"?S.once("close",A):A())):XT=new Promise((A)=>S1=A))}function IU(){if(n4=!0,k4||l||c4||P.length)sW(J4.connection("CONNECTION_DESTROYED",$));if(clearImmediate(e$),S)S.removeListener("data",lz),S.removeListener("connect",aW),S.readyState==="open"&&S.end(U$().X().end());S1&&(S1(),XT=S1=null)}async function SD(A){if(Y$=Buffer.alloc(0),y$=0,o$=null,clearImmediate(e$),S.removeListener("data",lz),S.removeListener("connect",aW),h.cancel(),a.cancel(),M$.cancel(),S.removeAllListeners(),S=null,c4)return CD();!A&&(l||P.length)&&sW(J4.connection("CONNECTION_CLOSED",$,S)),G$=y_.now(),A&&$.shared.retries++,h$=(typeof _==="function"?_($.shared.retries):_)*1000,X(i4,J4.connection("CONNECTION_CLOSED",$,S))}function Pq(A,v=A[0]){(v===68?Cq:v===100?WP:v===65?tq:v===83?Sq:v===90?jq:v===67?Bq:v===50?jD:v===49?xq:v===116?Iq:v===84?bq:v===82?fq:v===110?uq:v===75?pq:v===69?nq:v===115?aq:v===51?sq:v===71?eq:v===78?XP:v===72?$P:v===99?UP:v===73?YP:v===86?wP:v===118?GP:v===87?TP:zP)(A)}function Cq(A){let v=7,w$,x$,D4,t4=l.isRaw?new Array(l.statement.columns.length):{};for(let Y6=0;Y6<l.statement.columns.length;Y6++)x$=l.statement.columns[Y6],w$=A.readInt32BE(v),v+=4,D4=w$===-1?null:l.isRaw===!0?A.subarray(v,v+=w$):x$.parser===void 0?A.toString("utf8",v,v+=w$):x$.parser.array===!0?x$.parser(A.toString("utf8",v+1,v+=w$)):x$.parser(A.toString("utf8",v,v+=w$)),l.isRaw?t4[Y6]=l.isRaw===!0?D4:Q.value.from?Q.value.from(D4,x$):D4:t4[x$.name]=Q.value.from?Q.value.from(D4,x$):D4;l.forEachFn?l.forEachFn(Q.row.from?Q.row.from(t4):t4,n):n[M4++]=Q.row.from?Q.row.from(t4):t4}function Sq(A){let[v,w$]=A.toString("utf8",5,A.length-1).split(U$.N);if(s$[v]=w$,$.parameters[v]!==w$)$.parameters[v]=w$,E&&E(v,w$)}function jq(A){if(l&&l.options.simple&&l.resolve(C1||n),l=C1=null,n=new uW,M$.cancel(),c4){if(R){if(!s$.in_hot_standby||!s$.default_transaction_read_only)return rq();else if(lq(R,s$))return IU()}if(j$)return c4.reserve&&(c4=null),dq();c4&&!c4.reserve&&xU(c4),$.shared.retries=R4=0,c4=null;return}while(P.length&&(l=P.shift())&&(l.active=!0,l.cancelled))m_($).cancel(l.state,l.cancelled.resolve,l.cancelled.reject);if(l)return;i4.reserved?!i4.reserved.release&&A[5]===73?XT?IU():(i4.reserved=null,W(i4)):i4.reserved():XT?IU():W(i4)}function Bq(A){M4=0;for(let v=A.length-1;v>0;v--){if(A[v]===32&&A[v+1]<58&&n.count===null)n.count=+A.toString("utf8",v+1,A.length-1);if(A[v-1]>=65){n.command=A.toString("utf8",5,v),n.state=f;break}}if(BU&&(BU(),BU=null),n.command==="BEGIN"&&w!==1&&!i4.reserved)return l1(J4.generic("UNSAFE_TRANSACTION","Only use sql.begin, sql.reserved or max: 1"));if(l.options.simple)return jD();if(l.cursorFn)n.count&&l.cursorFn(n),u4(fT);l.resolve(n)}function xq(){l.parsing=!1}function jD(){!n.statement&&(n.statement=l.statement),n.columns=l.statement.columns}function Iq(A){let v=A.readUInt16BE(5);for(let w$=0;w$<v;++w$)!l.statement.types[w$]&&(l.statement.types[w$]=A.readUInt32BE(7+w$*4));l.prepare&&(f4[l.signature]=l.statement),l.describeFirst&&!l.onlyDescribe&&(u4(Ww(l)),l.describeFirst=!1)}function bq(A){if(n.command)C1=C1||[n],C1.push(n=new uW),n.count=null,l.statement.columns=null;let v=A.readUInt16BE(5),w$=7,x$;l.statement.columns=Array(v);for(let D4=0;D4<v;++D4){x$=w$;while(A[w$++]!==0);let t4=A.readUInt32BE(w$),Y6=A.readUInt16BE(w$+4),YT=A.readUInt32BE(w$+6);l.statement.columns[D4]={name:Q.column.from?Q.column.from(A.toString("utf8",x$,w$-1)):A.toString("utf8",x$,w$-1),parser:O[YT],table:t4,number:Y6,type:YT},w$+=18}if(n.statement=l.statement,l.onlyDescribe)return l.resolve(l.statement),u4(fT)}async function fq(A,v=A.readUInt32BE(5)){(v===3?yq:v===5?hq:v===10?gq:v===11?mq:v===12?cq:v!==0?HP:HU)(A,v)}async function yq(){let A=await nz();u4(U$().p().str(A).z(1).end())}async function hq(A){let v="md5"+await g_(Buffer.concat([Buffer.from(await g_(await nz()+G)),A.subarray(9)]));u4(U$().p().str(v).z(1).end())}async function gq(){o1=(await NY.randomBytes(18)).toString("base64"),U$().p().str("SCRAM-SHA-256"+U$.N);let A=U$.i;u4(U$.inc(4).str("n,,n=*,r="+o1).i32(U$.i-A-4,A).end())}async function mq(A){let v=A.toString("utf8",9).split(",").reduce((Y6,YT)=>(Y6[YT[0]]=YT.slice(2),Y6),{}),w$=await NY.pbkdf2Sync(await nz(),Buffer.from(v.s,"base64"),parseInt(v.i),32,"sha256"),x$=await Xz(w$,"Client Key"),D4="n=*,r="+o1+",r="+v.r+",s="+v.s+",i="+v.i+",c=biws,r="+v.r;w4=(await Xz(await Xz(w$,"Server Key"),D4)).toString("base64");let t4="c=biws,r="+v.r+",p="+vf(x$,Buffer.from(await Xz(await kf(x$),D4))).toString("base64");u4(U$().p().str(t4).end())}function cq(A){if(A.toString("utf8",9).split(U$.N,1)[0].slice(2)===w4)return;l1(J4.generic("SASL_SIGNATURE_MISMATCH","The server did not return the correct signature")),S.destroy()}function nz(){return Promise.resolve(typeof $.pass==="function"?$.pass():$.pass)}function uq(){if(n.statement=l.statement,n.statement.columns=[],l.onlyDescribe)return l.resolve(l.statement),u4(fT)}function pq(A){f.pid=A.readUInt32BE(5),f.secret=A.readUInt32BE(9)}async function dq(){j$=!1,(await new R1([`
|
|
82
82
|
select b.oid, b.typarray
|
|
83
83
|
from pg_catalog.pg_type a
|
|
84
84
|
left join pg_catalog.pg_type b on b.oid = a.typelem
|
|
85
85
|
where a.typcategory = 'A'
|
|
86
86
|
group by b.oid, b.typarray
|
|
87
87
|
order by b.oid
|
|
88
|
-
`],[],
|
|
88
|
+
`],[],xU)).forEach(({oid:v,typarray:w$})=>oq(v,w$))}function oq(A,v){if(!!$.parsers[v]&&!!$.serializers[v])return;let w$=$.parsers[A];$.shared.typeArrayMap[A]=v,$.parsers[v]=(x$)=>I_(x$,w$,v),$.parsers[v].array=!0,$.serializers[v]=(x$)=>x_(x$,$.serializers[A],$,v)}function lq(A,v){return A==="read-write"&&v.default_transaction_read_only==="on"||A==="read-only"&&v.default_transaction_read_only==="off"||A==="primary"&&v.in_hot_standby==="on"||A==="standby"&&v.in_hot_standby==="off"||A==="prefer-standby"&&v.in_hot_standby==="off"&&$.host[R4]}function rq(){let A=new R1([`
|
|
89
89
|
show transaction_read_only;
|
|
90
90
|
select pg_catalog.pg_is_in_recovery()
|
|
91
|
-
`],[],
|
|
91
|
+
`],[],xU,null,{simple:!0});A.resolve=([[v],[w$]])=>{s$.default_transaction_read_only=v.transaction_read_only,s$.in_hot_standby=w$.pg_is_in_recovery?"on":"off"},A.execute()}function nq(A){l&&(l.cursorFn||l.describeFirst)&&u4(fT);let v=J4.postgres(bQ(A));l&&l.retried?l1(l.retried):l&&l.prepared&&_f.has(v.routine)?iq(l,v):l1(v)}function iq(A,v){delete f4[A.signature],A.retried=v,xU(A)}function tq(A){if(!V)return;let v=9;while(A[v++]!==0);V(A.toString("utf8",9,v-1),A.toString("utf8",v,A.length-1))}async function aq(){try{let A=await Promise.resolve(l.cursorFn(n));M4=0,A===GU?u4(QP(l.portal)):(n=new uW,u4(xD("",l.cursorRows)))}catch(A){u4(fT),l.reject(A)}}function sq(){n.count&&l.cursorFn(n),l.resolve(n)}function eq(){k4=new IQ.Writable({autoDestroy:!0,write(A,v,w$){S.write(U$().d().raw(A).end(),w$)},destroy(A,v){v(A),S.write(U$().f().str(A+U$.N).end()),k4=null},final(A){S.write(U$().c().end()),BU=A}}),l.resolve(k4)}function $P(){k4=new IQ.Readable({read(){S.resume()}}),l.resolve(k4)}function TP(){k4=new IQ.Duplex({autoDestroy:!0,read(){S.resume()},write(A,v,w$){S.write(U$().d().raw(A).end(),w$)},destroy(A,v){v(A),S.write(U$().f().str(A+U$.N).end()),k4=null},final(A){S.write(U$().c().end()),BU=A}}),l.resolve(k4)}function WP(A){k4&&(k4.push(A.subarray(5))||S.pause())}function UP(){k4&&k4.push(null),k4=null}function XP(A){Z?Z(bQ(A)):console.log(bQ(A))}function YP(){}function wP(){l1(J4.notSupported("FunctionCallResponse"))}function GP(){l1(J4.notSupported("NegotiateProtocolVersion"))}function zP(A){console.error("Postgres.js : Unknown Message:",A[0])}function HP(A,v){console.error("Postgres.js : Unknown Auth:",v)}function FP(A,v,w$="",x$=""){let D4,t4;return U$().B().str(x$+U$.N).str(w$+U$.N).i16(0).i16(A.length),A.forEach((Y6,YT)=>{if(Y6===null)return U$.i32(4294967295);t4=v[YT],A[YT]=Y6=t4 in $.serializers?$.serializers[t4](Y6):""+Y6,D4=U$.i,U$.inc(4).str(Y6).i32(U$.i-D4-4,D4)}),U$.i16(0),U$.end()}function BD(A,v,w$,x$=""){return U$().P().str(x$+U$.N).str(A+U$.N).i16(v.length),v.forEach((D4,t4)=>U$.i32(w$[t4]||0)),U$.end()}function OP(A,v=""){return U$().D().str(A).str(v+U$.N).end()}function xD(A="",v=0){return Buffer.concat([U$().E().str(A+U$.N).i32(v).end(),h_])}function QP(A=""){return Buffer.concat([U$().C().str("P").str(A+U$.N).end(),U$().S().end()])}function ZP(){return W$||U$().inc(4).i16(3).z(2).str(Object.entries(Object.assign({user:G,database:F,client_encoding:"UTF8"},$.connection)).filter(([,A])=>A).map(([A,v])=>A+U$.N+v).join(U$.N)).z(2).end(0)}}function bQ($){let T={},W=5;for(let U=5;U<$.length-1;U++)if($[U]===0)T[Rf[$[W]]]=$.toString("utf8",W+1,U),W=U+1;return T}function g_($){return NY.createHash("md5").update($).digest("hex")}function Xz($,T){return NY.createHmac("sha256",$).update(T).digest()}function kf($){return NY.createHash("sha256").update($).digest()}function vf($,T){let W=Math.max($.length,T.length),U=Buffer.allocUnsafe(W);for(let X=0;X<W;X++)U[X]=$[X]^T[X];return U}function fQ($,T){if(T=typeof T==="function"?T():T,!T)return{cancel:HU,start:HU};let W;return{cancel(){W&&(clearTimeout(W),W=null)},start(){W&&clearTimeout(W),W=setTimeout(U,T*1000,arguments)}};function U(X){$.apply(null,X),W=null}}var c_=()=>{};function hQ($,T){let W=new Map,U="postgresjs_"+Math.random().toString(36).slice(2),X={},Y,w,G=!1,H=O.sql=$({...T,transform:{column:{},value:{},row:{}},max:1,fetch_types:!1,idle_timeout:null,max_lifetime:null,connection:{...T.connection,replication:"database"},onclose:async function(){if(G)return;w=null,X.pid=X.secret=void 0,Q(await Z(H,U,T.publications)),W.forEach((E)=>E.forEach(({onsubscribe:N})=>N()))},no_subscribe:!0}),z=H.end,F=H.close;return H.end=async()=>{return G=!0,w&&await new Promise((E)=>(w.once("close",E),w.end())),z()},H.close=async()=>{return w&&await new Promise((E)=>(w.once("close",E),w.end())),F()},O;async function O(E,N,J=c_,_=c_){if(E=Cf(E),!Y)Y=Z(H,U,T.publications);let R={fn:N,onsubscribe:J},P=W.has(E)?W.get(E).add(R):W.set(E,new Set([R])).get(E),x=()=>{P.delete(R),P.size===0&&W.delete(E)};return Y.then((f)=>{return Q(f),J(),w&&w.on("error",_),{unsubscribe:x,state:X,sql:H}})}function Q(E){w=E.stream,X.pid=E.state.pid,X.secret=E.state.secret}async function Z(E,N,J){if(!J)throw new Error("Missing publication names");let _=await E.unsafe(`CREATE_REPLICATION_SLOT ${N} TEMPORARY LOGICAL pgoutput NOEXPORT_SNAPSHOT`),[R]=_,P=await E.unsafe(`START_REPLICATION SLOT ${N} LOGICAL ${R.consistent_point} (proto_version '1', publication_names '${J}')`).writable(),x={lsn:Buffer.concat(R.consistent_point.split("/").map((S)=>Buffer.from(("00000000"+S).slice(-8),"hex")))};return P.on("data",h),P.on("error",f),P.on("close",E.close),{stream:P,state:_.state};function f(S){console.error("Unexpected error during logical streaming - reconnecting",S)}function h(S){if(S[0]===119)Pf(S.subarray(25),x,E.options.parsers,a,T.transform);else if(S[0]===107&&S[17])x.lsn=S.subarray(1,9),M$()}function a(S,W$){let n=W$.relation.schema+"."+W$.relation.table;V("*",S,W$),V("*:"+n,S,W$),W$.relation.keys.length&&V("*:"+n+"="+W$.relation.keys.map((Y$)=>S[Y$.name]),S,W$),V(W$.command,S,W$),V(W$.command+":"+n,S,W$),W$.relation.keys.length&&V(W$.command+":"+n+"="+W$.relation.keys.map((Y$)=>S[Y$.name]),S,W$)}function M$(){let S=Buffer.alloc(34);S[0]=114,S.fill(x.lsn,1),S.writeBigInt64BE(BigInt(Date.now()-Date.UTC(2000,0,1))*BigInt(1000),25),P.write(S)}}function V(E,N,J){W.has(E)&&W.get(E).forEach(({fn:_})=>_(N,J,E))}}function qf($){return new Date(Date.UTC(2000,0,1)+Number($/BigInt(1000)))}function Pf($,T,W,U,X){let Y=(w,[G,H])=>(w[G.charCodeAt(0)]=H,w);Object.entries({R:(w)=>{let G=1,H=T[w.readUInt32BE(G)]={schema:w.toString("utf8",G+=4,G=w.indexOf(0,G))||"pg_catalog",table:w.toString("utf8",G+1,G=w.indexOf(0,G+1)),columns:Array(w.readUInt16BE(G+=2)),keys:[]};G+=2;let z=0,F;while(G<w.length)F=H.columns[z++]={key:w[G++],name:X.column.from?X.column.from(w.toString("utf8",G,G=w.indexOf(0,G))):w.toString("utf8",G,G=w.indexOf(0,G)),type:w.readUInt32BE(G+=1),parser:W[w.readUInt32BE(G)],atttypmod:w.readUInt32BE(G+=4)},F.key&&H.keys.push(F),G+=4},Y:()=>{},O:()=>{},B:(w)=>{T.date=qf(w.readBigInt64BE(9)),T.lsn=w.subarray(1,9)},I:(w)=>{let G=1,H=T[w.readUInt32BE(G)],{row:z}=Yz(w,H.columns,G+=7,X);U(z,{command:"insert",relation:H})},D:(w)=>{let G=1,H=T[w.readUInt32BE(G)];G+=4;let z=w[G]===75;U(z||w[G]===79?Yz(w,H.columns,G+=3,X).row:null,{command:"delete",relation:H,key:z})},U:(w)=>{let G=1,H=T[w.readUInt32BE(G)];G+=4;let z=w[G]===75,F=z||w[G]===79?Yz(w,H.columns,G+=3,X):null;F&&(G=F.i);let{row:O}=Yz(w,H.columns,G+3,X);U(O,{command:"update",relation:H,key:z,old:F&&F.row})},T:()=>{},C:()=>{}}).reduce(Y,{})[$[0]]($)}function Yz($,T,W,U){let X,Y,w,G=U.raw?new Array(T.length):{};for(let H=0;H<T.length;H++)X=$[W++],Y=T[H],w=X===110?null:X===117?void 0:Y.parser===void 0?$.toString("utf8",W+4,W+=4+$.readUInt32BE(W)):Y.parser.array===!0?Y.parser($.toString("utf8",W+5,W+=4+$.readUInt32BE(W))):Y.parser($.toString("utf8",W+4,W+=4+$.readUInt32BE(W))),U.raw?G[H]=U.raw===!0?w:U.value.from?U.value.from(w,Y):w:G[Y.name]=U.value.from?U.value.from(w,Y):w;return{i:W,row:U.row.from?U.row.from(G):G}}function Cf($){let T=$.match(/^(\*|insert|update|delete)?:?([^.]+?\.?[^=]+)?=?(.+)?/i)||[];if(!T)throw new Error("Malformed subscribe pattern: "+$);let[,W,U,X]=T;return(W||"*")+(U?":"+(U.indexOf(".")===-1?"public."+U:U):"")+(X?"="+X:"")}import u_ from"stream";function gQ($,T,W=393216){return new Promise(async(U,X)=>{await $.begin(async(Y)=>{let w;!T&&([{oid:T}]=await Y`select lo_creat(-1) as oid`);let[{fd:G}]=await Y`select lo_open(${T}, ${W}) as fd`,H={writable:F,readable:z,close:()=>Y`select lo_close(${G})`.then(w),tell:()=>Y`select lo_tell64(${G})`,read:(O)=>Y`select loread(${G}, ${O}) as data`,write:(O)=>Y`select lowrite(${G}, ${O})`,truncate:(O)=>Y`select lo_truncate64(${G}, ${O})`,seek:(O,Q=0)=>Y`select lo_lseek64(${G}, ${O}, ${Q})`,size:()=>Y`
|
|
92
92
|
select
|
|
93
|
-
lo_lseek64(${
|
|
93
|
+
lo_lseek64(${G}, location, 0) as position,
|
|
94
94
|
seek.size
|
|
95
95
|
from (
|
|
96
96
|
select
|
|
@@ -98,62 +98,63 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
|
98
98
|
tell.location
|
|
99
99
|
from (select lo_tell64($1) as location) tell
|
|
100
100
|
) seek
|
|
101
|
-
`};return X(z),new Promise(async(_)=>G=_);async function w({highWaterMark:_=16384,start:F=0,end:D=1/0}={}){let V=D-F;return F&&await z.seek(F),new cO.Readable({highWaterMark:_,async read(E){let R=E>V?E-V:E;V-=E;let[{data:P}]=await z.read(R);if(this.push(P),P.length<E)this.push(null)}})}async function H({highWaterMark:_=16384,start:F=0}={}){return F&&await z.seek(F),new cO.Writable({highWaterMark:_,write(D,V,E){z.write(D).then(()=>E(),E)}})}}).catch(Y)})}Object.assign(WU,{PostgresError:kT,toPascal:k0,pascal:f7,toCamel:I0,camel:b7,toKebab:q0,kebab:y7,fromPascal:n2,fromCamel:i2,fromKebab:t2,BigInt:{to:20,from:[20],parse:($)=>BigInt($),serialize:($)=>$.toString()}});var PT=WU;function WU($,T){let W=Ck($,T),X=W.no_subscribe||u7(WU,{...W}),Y=!1,U=W6(),G=W6(),J=W6(),z=W6(),w=W6(),H=W6(),_=W6(),F=W6(),D={connecting:G,reserved:J,closed:z,ended:w,open:H,busy:_,full:F},V=[...Array(W.max)].map(()=>c7(W,D,{onopen:D6,onend:V4,onclose:g0})),E=R(J$);return Object.assign(E,{get parameters(){return W.parameters},largeObject:p7.bind(null,E),subscribe:X,CLOSE:IT,END:IT,PostgresError:kT,options:W,reserve:N,listen:P,begin:k,close:$$,end:Z$}),E;function R(v){return v.debug=W.debug,Object.entries(W.types).reduce((w$,[A$,i$])=>{return w$[A$]=(c$)=>new h6(c$,i$.to),w$},e),Object.assign(M$,{types:e,typed:e,unsafe:g$,notify:A,array:m,json:x,file:$4}),M$;function e(w$,A$){return new h6(w$,A$)}function M$(w$,...A$){return w$&&Array.isArray(w$.raw)?new _6(w$,A$,v,B):typeof w$==="string"&&!A$.length?new a2(W.transform.column.to?W.transform.column.to(w$):w$):new t8(w$,A$)}function g$(w$,A$=[],i$={}){return arguments.length===2&&!Array.isArray(A$)&&(i$=A$,A$=[]),new _6([w$],A$,v,B,{prepare:!1,...i$,simple:"simple"in i$?i$.simple:A$.length===0})}function $4(w$,A$=[],i$={}){return arguments.length===2&&!Array.isArray(A$)&&(i$=A$,A$=[]),new _6([],A$,(x$)=>{Pk.readFile(w$,"utf8",(K4,k$)=>{if(K4)return x$.reject(K4);x$.strings=[k$],v(x$)})},B,{...i$,simple:"simple"in i$?i$.simple:A$.length===0})}}async function P(v,e,M$){let g$={fn:e,onlisten:M$},$4=P.sql||(P.sql=WU({...W,max:1,idle_timeout:null,max_lifetime:null,fetch_types:!1,onclose(){Object.entries(P.channels).forEach(([x$,{listeners:K4}])=>{delete P.channels[x$],Promise.all(K4.map((k$)=>P(x$,k$.fn,k$.onlisten).catch(()=>{})))})},onnotify(x$,K4){x$ in P.channels&&P.channels[x$].listeners.forEach((k$)=>k$.fn(K4))}})),w$=P.channels||(P.channels={});if(v in w$){w$[v].listeners.push(g$);let x$=await w$[v].result;return g$.onlisten&&g$.onlisten(),{state:x$.state,unlisten:c$}}w$[v]={result:$4`listen ${$4.unsafe('"'+v.replace(/"/g,'""')+'"')}`,listeners:[g$]};let i$=await w$[v].result;return g$.onlisten&&g$.onlisten(),{state:i$.state,unlisten:c$};async function c$(){if(v in w$===!1)return;if(w$[v].listeners=w$[v].listeners.filter((x$)=>x$!==g$),w$[v].listeners.length)return;return delete w$[v],$4`unlisten ${$4.unsafe('"'+v.replace(/"/g,'""')+'"')}`}}async function A(v,e){return await E`select pg_notify(${v}, ${""+e})`}async function N(){let v=W6(),e=H.length?H.shift():await new Promise(($4,w$)=>{let A$={reserve:$4,reject:w$};U.push(A$),z.length&&e$(z.shift(),A$)});y(e,J),e.reserved=()=>v.length?e.execute(v.shift()):y(e,J),e.reserved.release=!0;let M$=R(g$);return M$.release=()=>{e.reserved=null,D6(e)},M$;function g$($4){e.queue===F?v.push($4):e.execute($4)||y(e,F)}}async function k(v,e){!e&&(e=v,v="");let M$=W6(),g$=0,$4,w$=null;try{return await E.unsafe("begin "+v.replace(/[^a-z ]/ig,""),[],{onexecute:i$}).execute(),await Promise.race([A$($4,e),new Promise((c$,x$)=>$4.onclose=x$)])}catch(c$){throw c$}async function A$(c$,x$,K4){let k$=R(T4);k$.savepoint=K1,k$.prepare=(b$)=>w$=b$.replace(/[^a-z0-9$-_. ]/gi);let O6,Q4;K4&&await k$`savepoint ${k$(K4)}`;try{if(Q4=await new Promise((b$,V6)=>{let k6=x$(k$);Promise.resolve(Array.isArray(k6)?Promise.all(k6):k6).then(b$,V6)}),O6)throw O6}catch(b$){throw await(K4?k$`rollback to ${k$(K4)}`:k$`rollback`),b$ instanceof kT&&b$.code==="25P02"&&O6||b$}if(!K4)w$?await k$`prepare transaction '${k$.unsafe(w$)}'`:await k$`commit`;return Q4;function K1(b$,V6){if(b$&&Array.isArray(b$.raw))return K1((k6)=>k6.apply(k6,arguments));return arguments.length===1&&(V6=b$,b$=null),A$(c$,V6,"s"+g$+++(b$?"_"+b$:""))}function T4(b$){b$.catch((V6)=>O6||(O6=V6)),c$.queue===F?M$.push(b$):c$.execute(b$)||y(c$,F)}}function i$(c$){$4=c$,y(c$,J),c$.reserved=()=>M$.length?c$.execute(M$.shift()):y(c$,J)}}function y(v,e){return v.queue.remove(v),e.push(v),v.queue=e,e===H?v.idleTimer.start():v.idleTimer.cancel(),v}function x(v){return new h6(v,3802)}function m(v,e){if(!Array.isArray(v))return m(Array.from(arguments));return new h6(v,e||(v.length?i8(v)||25:0),W.shared.typeArrayMap)}function J$(v){if(Y)return v.reject(a$.connection("CONNECTION_ENDED",W,W));if(H.length)return m$(H.shift(),v);if(z.length)return e$(z.shift(),v);_.length?m$(_.shift(),v):U.push(v)}function m$(v,e){return v.execute(e)?y(v,_):y(v,F)}function B(v){return new Promise((e,M$)=>{v.state?v.active?c7(W).cancel(v.state,e,M$):v.cancelled={resolve:e,reject:M$}:(U.remove(v),v.cancelled=!0,v.reject(a$.generic("57014","canceling statement due to user request")),e())})}async function Z$({timeout:v=null}={}){if(Y)return Y;await 1;let e;return Y=Promise.race([new Promise((M$)=>v!==null&&(e=setTimeout(H$,v*1000,M$))),Promise.all(V.map((M$)=>M$.end()).concat(P.sql?P.sql.end({timeout:0}):[],X.sql?X.sql.end({timeout:0}):[]))]).then(()=>clearTimeout(e))}async function $$(){await Promise.all(V.map((v)=>v.end()))}async function H$(v){await Promise.all(V.map((e)=>e.terminate()));while(U.length)U.shift().reject(a$.connection("CONNECTION_DESTROYED",W));v()}function e$(v,e){return y(v,G),v.connect(e),v}function V4(v){y(v,w)}function D6(v){if(U.length===0)return y(v,H);let e=Math.ceil(U.length/(G.length+1)),M$=!0;while(M$&&U.length&&e-- >0){let g$=U.shift();if(g$.reserve)return g$.reserve(v);M$=v.execute(g$)}M$?y(v,_):y(v,F)}function g0(v,e){y(v,z),v.reserved=null,v.onclose&&(v.onclose(e),v.onclose=null),W.onclose&&W.onclose(v.id),U.length&&e$(v,U.shift())}}function Ck($,T){if($&&$.shared)return $;let W=process.env,X=(!$||typeof $==="string"?T:$)||{},{url:Y,multihost:U}=fk($),G=[...Y.searchParams].reduce((F,[D,V])=>(F[D]=V,F),{}),J=X.hostname||X.host||U||Y.hostname||W.PGHOST||"localhost",z=X.port||Y.port||W.PGPORT||5432,w=X.user||X.username||Y.username||W.PGUSERNAME||W.PGUSER||yk();X.no_prepare&&(X.prepare=!1),G.sslmode&&(G.ssl=G.sslmode,delete G.sslmode),"timeout"in X&&(console.log("The timeout option is deprecated, use idle_timeout instead"),X.idle_timeout=X.timeout),G.sslrootcert==="system"&&(G.ssl="verify-full");let H=["idle_timeout","connect_timeout","max_lifetime","max_pipeline","backoff","keep_alive"],_={max:10,ssl:!1,idle_timeout:null,connect_timeout:30,max_lifetime:xk,max_pipeline:100,backoff:jk,keep_alive:60,prepare:!0,debug:!1,fetch_types:!0,publications:"alltables",target_session_attrs:null};return{host:Array.isArray(J)?J:J.split(",").map((F)=>F.split(":")[0]),port:Array.isArray(z)?z:J.split(",").map((F)=>parseInt(F.split(":")[1]||z)),path:X.path||J.indexOf("/")>-1&&J+"/.s.PGSQL."+z,database:X.database||X.db||(Y.pathname||"").slice(1)||W.PGDATABASE||w,user:w,pass:X.pass||X.password||Y.password||W.PGPASSWORD||"",...Object.entries(_).reduce((F,[D,V])=>{let E=D in X?X[D]:(D in G)?G[D]==="disable"||G[D]==="false"?!1:G[D]:W["PG"+D.toUpperCase()]||V;return F[D]=typeof E==="string"&&H.includes(D)?+E:E,F},{}),connection:{application_name:W.PGAPPNAME||"postgres.js",...X.connection,...Object.entries(G).reduce((F,[D,V])=>((D in _)||(F[D]=V),F),{})},types:X.types||{},target_session_attrs:vk(X,Y,W),onnotice:X.onnotice,onnotify:X.onnotify,onclose:X.onclose,onparameter:X.onparameter,socket:X.socket,transform:bk(X.transform||{undefined:void 0}),parameters:{},shared:{retries:0,typeArrayMap:{}},...PO(X.types)}}function vk($,T,W){let X=$.target_session_attrs||T.searchParams.get("target_session_attrs")||W.PGTARGETSESSIONATTRS;if(!X||["read-write","read-only","primary","standby","prefer-standby"].includes(X))return X;throw new Error("target_session_attrs "+X+" is not supported")}function jk($){return(0.5+Math.random()/2)*Math.min(3**$/100,20)}function xk(){return 60*(30+Math.random()*30)}function bk($){return{undefined:$.undefined,column:{from:typeof $.column==="function"?$.column:$.column&&$.column.from,to:$.column&&$.column.to},value:{from:typeof $.value==="function"?$.value:$.value&&$.value.from,to:$.value&&$.value.to},row:{from:typeof $.row==="function"?$.row:$.row&&$.row.from,to:$.row&&$.row.to}}}function fk($){if(!$||typeof $!=="string")return{url:{searchParams:new Map}};let T=$;T=T.slice(T.indexOf("://")+3).split(/[?/]/)[0],T=decodeURIComponent(T.slice(T.indexOf("@")+1));let W=new URL($.replace(T,T.split(",")[0]));return{url:{username:decodeURIComponent(W.username),password:decodeURIComponent(W.password),host:W.host,hostname:W.hostname,port:W.port,pathname:W.pathname,searchParams:W.searchParams},multihost:T.indexOf(",")>-1&&T}}function yk(){try{return qk.userInfo().username}catch($){return process.env.USERNAME||process.env.USER||process.env.LOGNAME}}class r${static[Z]="SelectionProxyHandler";config;constructor($){this.config={...$}}get($,T){if(T==="_")return{...$._,selectedFields:new Proxy($._.selectedFields,this)};if(T===C$)return{...$[C$],selectedFields:new Proxy($[C$].selectedFields,this)};if(typeof T==="symbol")return $[T];let X=(S($,G4)?$._.selectedFields:S($,g4)?$[C$].selectedFields:$)[T];if(S(X,p.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!X.isSelectionField)return X.sql;let Y=X.clone();return Y.isSelectionField=!0,Y}if(S(X,p)){if(this.config.sqlBehavior==="sql")return X;throw new 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(S(X,B$)){if(this.config.alias)return new Proxy(X,new RT(new Proxy(X.table,new m2(this.config.alias,this.config.replaceOriginalName??!1))));return X}if(typeof X!=="object"||X===null)return X;return new Proxy(X,new r$(this.config))}}class XU extends k4{constructor($,T,W,X){super();this.session=T,this.dialect=W,this.config={table:$,withList:X}}static[Z]="PgDelete";config;where($){return this.config.where=$,this}returning($=this.config.table[c.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=w6($),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return R$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return R$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new r$({alias:F4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}function hk($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((W)=>W.toLowerCase()).join("_")}function gk($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((W,X,Y)=>{let U=Y===0?X.toLowerCase():`${X[0].toUpperCase()}${X.slice(1)}`;return W+U},"")}function mk($){return $}class d7{static[Z]="CasingCache";cache={};cachedTables={};convert;constructor($){this.convert=$==="snake_case"?hk:$==="camelCase"?gk:mk}getColumnCasing($){if(!$.keyAsName)return $.name;let T=$.table[c.Symbol.Schema]??"public",W=$.table[c.Symbol.OriginalName],X=`${T}.${W}.${$.name}`;if(!this.cache[X])this.cacheTable($.table);return this.cache[X]}cacheTable($){let T=$[c.Symbol.Schema]??"public",W=$[c.Symbol.OriginalName],X=`${T}.${W}`;if(!this.cachedTables[X]){for(let Y of Object.values($[c.Symbol.Columns])){let U=`${X}.${Y.name}`;this.cache[U]=this.convert(Y.name)}this.cachedTables[X]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class e2 extends g4{static[Z]="PgViewBase"}class C0{static[Z]="PgDialect";casing;constructor($){this.casing=new d7($?.casing)}async migrate($,T,W){let X=typeof W==="string"?"__drizzle_migrations":W.migrationsTable??"__drizzle_migrations",Y=typeof W==="string"?"drizzle":W.migrationsSchema??"drizzle",U=O`
|
|
102
|
-
CREATE TABLE IF NOT EXISTS ${
|
|
101
|
+
`};return U(H),new Promise(async(O)=>w=O);async function z({highWaterMark:O=16384,start:Q=0,end:Z=1/0}={}){let V=Z-Q;return Q&&await H.seek(Q),new u_.Readable({highWaterMark:O,async read(E){let N=E>V?E-V:E;V-=E;let[{data:J}]=await H.read(N);if(this.push(J),J.length<E)this.push(null)}})}async function F({highWaterMark:O=16384,start:Q=0}={}){return Q&&await H.seek(Q),new u_.Writable({highWaterMark:O,write(Z,V,E){H.write(Z).then(()=>E(),E)}})}}).catch(X)})}Object.assign(wz,{PostgresError:zU,toPascal:mW,pascal:BQ,toCamel:gW,camel:jQ,toKebab:cW,kebab:xQ,fromPascal:EY,fromCamel:KY,fromKebab:AY,BigInt:{to:20,from:[20],parse:($)=>BigInt($),serialize:($)=>$.toString()}});var FU=wz;function wz($,T){let W=Bf($,T),U=W.no_subscribe||hQ(wz,{...W}),X=!1,Y=O1(),w=O1(),G=O1(),H=O1(),z=O1(),F=O1(),O=O1(),Q=O1(),Z={connecting:w,reserved:G,closed:H,ended:z,open:F,busy:O,full:Q},V=[...Array(W.max)].map(()=>yQ(W,Z,{onopen:f4,onend:s$,onclose:n6})),E=N(a);return Object.assign(E,{get parameters(){return W.parameters},largeObject:gQ.bind(null,E),subscribe:U,CLOSE:GU,END:GU,PostgresError:zU,options:W,reserve:R,listen:J,begin:P,close:n,end:W$}),E;function N(g){return g.debug=W.debug,Object.entries(W.types).reduce((N$,[h$,M4])=>{return N$[h$]=(w4)=>new H0(w4,M4.to),N$},G$),Object.assign(y$,{types:G$,typed:G$,unsafe:Y4,notify:_,array:h,json:f,file:R4}),y$;function G$(N$,h$){return new H0(N$,h$)}function y$(N$,...h$){return N$&&Array.isArray(N$.raw)?new R1(N$,h$,g,S):typeof N$==="string"&&!h$.length?new MY(W.transform.column.to?W.transform.column.to(N$):N$):new $z(N$,h$)}function Y4(N$,h$=[],M4={}){return arguments.length===2&&!Array.isArray(h$)&&(M4=h$,h$=[]),new R1([N$],h$,g,S,{prepare:!1,...M4,simple:"simple"in M4?M4.simple:h$.length===0})}function R4(N$,h$=[],M4={}){return arguments.length===2&&!Array.isArray(h$)&&(M4=h$,h$=[]),new R1([],h$,(e$)=>{jf.readFile(N$,"utf8",(n4,o$)=>{if(n4)return e$.reject(n4);e$.strings=[o$],g(e$)})},S,{...M4,simple:"simple"in M4?M4.simple:h$.length===0})}}async function J(g,G$,y$){let Y4={fn:G$,onlisten:y$},R4=J.sql||(J.sql=wz({...W,max:1,idle_timeout:null,max_lifetime:null,fetch_types:!1,onclose(){Object.entries(J.channels).forEach(([e$,{listeners:n4}])=>{delete J.channels[e$],Promise.all(n4.map((o$)=>J(e$,o$.fn,o$.onlisten).catch(()=>{})))})},onnotify(e$,n4){e$ in J.channels&&J.channels[e$].listeners.forEach((o$)=>o$.fn(n4))}})),N$=J.channels||(J.channels={});if(g in N$){N$[g].listeners.push(Y4);let e$=await N$[g].result;return Y4.onlisten&&Y4.onlisten(),{state:e$.state,unlisten:w4}}N$[g]={result:R4`listen ${R4.unsafe('"'+g.replace(/"/g,'""')+'"')}`,listeners:[Y4]};let M4=await N$[g].result;return Y4.onlisten&&Y4.onlisten(),{state:M4.state,unlisten:w4};async function w4(){if(g in N$===!1)return;if(N$[g].listeners=N$[g].listeners.filter((e$)=>e$!==Y4),N$[g].listeners.length)return;return delete N$[g],R4`unlisten ${R4.unsafe('"'+g.replace(/"/g,'""')+'"')}`}}async function _(g,G$){return await E`select pg_notify(${g}, ${""+G$})`}async function R(){let g=O1(),G$=F.length?F.shift():await new Promise((R4,N$)=>{let h$={reserve:R4,reject:N$};Y.push(h$),H.length&&j$(H.shift(),h$)});x(G$,G),G$.reserved=()=>g.length?G$.execute(g.shift()):x(G$,G),G$.reserved.release=!0;let y$=N(Y4);return y$.release=()=>{G$.reserved=null,f4(G$)},y$;function Y4(R4){G$.queue===Q?g.push(R4):G$.execute(R4)||x(G$,Q)}}async function P(g,G$){!G$&&(G$=g,g="");let y$=O1(),Y4=0,R4,N$=null;try{return await E.unsafe("begin "+g.replace(/[^a-z ]/ig,""),[],{onexecute:M4}).execute(),await Promise.race([h$(R4,G$),new Promise((w4,e$)=>R4.onclose=e$)])}catch(w4){throw w4}async function h$(w4,e$,n4){let o$=N(k4);o$.savepoint=XT,o$.prepare=($4)=>N$=$4.replace(/[^a-z0-9$-_. ]/gi);let C1,c4;n4&&await o$`savepoint ${o$(n4)}`;try{if(c4=await new Promise(($4,S1)=>{let o1=e$(o$);Promise.resolve(Array.isArray(o1)?Promise.all(o1):o1).then($4,S1)}),C1)throw C1}catch($4){throw await(n4?o$`rollback to ${o$(n4)}`:o$`rollback`),$4 instanceof zU&&$4.code==="25P02"&&C1||$4}if(!n4)N$?await o$`prepare transaction '${o$.unsafe(N$)}'`:await o$`commit`;return c4;function XT($4,S1){if($4&&Array.isArray($4.raw))return XT((o1)=>o1.apply(o1,arguments));return arguments.length===1&&(S1=$4,$4=null),h$(w4,S1,"s"+Y4+++($4?"_"+$4:""))}function k4($4){$4.catch((S1)=>C1||(C1=S1)),w4.queue===Q?y$.push($4):w4.execute($4)||x(w4,Q)}}function M4(w4){R4=w4,x(w4,G),w4.reserved=()=>y$.length?w4.execute(y$.shift()):x(w4,G)}}function x(g,G$){return g.queue.remove(g),G$.push(g),g.queue=G$,G$===F?g.idleTimer.start():g.idleTimer.cancel(),g}function f(g){return new H0(g,3802)}function h(g,G$){if(!Array.isArray(g))return h(Array.from(arguments));return new H0(g,G$||(g.length?s9(g)||25:0),W.shared.typeArrayMap)}function a(g){if(X)return g.reject(J4.connection("CONNECTION_ENDED",W,W));if(F.length)return M$(F.shift(),g);if(H.length)return j$(H.shift(),g);O.length?M$(O.shift(),g):Y.push(g)}function M$(g,G$){return g.execute(G$)?x(g,O):x(g,Q)}function S(g){return new Promise((G$,y$)=>{g.state?g.active?yQ(W).cancel(g.state,G$,y$):g.cancelled={resolve:G$,reject:y$}:(Y.remove(g),g.cancelled=!0,g.reject(J4.generic("57014","canceling statement due to user request")),G$())})}async function W$({timeout:g=null}={}){if(X)return X;await 1;let G$;return X=Promise.race([new Promise((y$)=>g!==null&&(G$=setTimeout(Y$,g*1000,y$))),Promise.all(V.map((y$)=>y$.end()).concat(J.sql?J.sql.end({timeout:0}):[],U.sql?U.sql.end({timeout:0}):[]))]).then(()=>clearTimeout(G$))}async function n(){await Promise.all(V.map((g)=>g.end()))}async function Y$(g){await Promise.all(V.map((G$)=>G$.terminate()));while(Y.length)Y.shift().reject(J4.connection("CONNECTION_DESTROYED",W));g()}function j$(g,G$){return x(g,w),g.connect(G$),g}function s$(g){x(g,z)}function f4(g){if(Y.length===0)return x(g,F);let G$=Math.ceil(Y.length/(w.length+1)),y$=!0;while(y$&&Y.length&&G$-- >0){let Y4=Y.shift();if(Y4.reserve)return Y4.reserve(g);y$=g.execute(Y4)}y$?x(g,O):x(g,Q)}function n6(g,G$){x(g,H),g.reserved=null,g.onclose&&(g.onclose(G$),g.onclose=null),W.onclose&&W.onclose(g.id),Y.length&&j$(g,Y.shift())}}function Bf($,T){if($&&$.shared)return $;let W=process.env,U=(!$||typeof $==="string"?T:$)||{},{url:X,multihost:Y}=yf($),w=[...X.searchParams].reduce((Q,[Z,V])=>(Q[Z]=V,Q),{}),G=U.hostname||U.host||Y||X.hostname||W.PGHOST||"localhost",H=U.port||X.port||W.PGPORT||5432,z=U.user||U.username||X.username||W.PGUSERNAME||W.PGUSER||hf();U.no_prepare&&(U.prepare=!1),w.sslmode&&(w.ssl=w.sslmode,delete w.sslmode),"timeout"in U&&(console.log("The timeout option is deprecated, use idle_timeout instead"),U.idle_timeout=U.timeout),w.sslrootcert==="system"&&(w.ssl="verify-full");let F=["idle_timeout","connect_timeout","max_lifetime","max_pipeline","backoff","keep_alive"],O={max:10,ssl:!1,idle_timeout:null,connect_timeout:30,max_lifetime:bf,max_pipeline:100,backoff:If,keep_alive:60,prepare:!0,debug:!1,fetch_types:!0,publications:"alltables",target_session_attrs:null};return{host:Array.isArray(G)?G:G.split(",").map((Q)=>Q.split(":")[0]),port:Array.isArray(H)?H:G.split(",").map((Q)=>parseInt(Q.split(":")[1]||H)),path:U.path||G.indexOf("/")>-1&&G+"/.s.PGSQL."+H,database:U.database||U.db||(X.pathname||"").slice(1)||W.PGDATABASE||z,user:z,pass:U.pass||U.password||X.password||W.PGPASSWORD||"",...Object.entries(O).reduce((Q,[Z,V])=>{let E=Z in U?U[Z]:(Z in w)?w[Z]==="disable"||w[Z]==="false"?!1:w[Z]:W["PG"+Z.toUpperCase()]||V;return Q[Z]=typeof E==="string"&&F.includes(Z)?+E:E,Q},{}),connection:{application_name:W.PGAPPNAME||"postgres.js",...U.connection,...Object.entries(w).reduce((Q,[Z,V])=>((Z in O)||(Q[Z]=V),Q),{})},types:U.types||{},target_session_attrs:xf(U,X,W),onnotice:U.onnotice,onnotify:U.onnotify,onclose:U.onclose,onparameter:U.onparameter,socket:U.socket,transform:ff(U.transform||{undefined:void 0}),parameters:{},shared:{retries:0,typeArrayMap:{}},...j_(U.types)}}function xf($,T,W){let U=$.target_session_attrs||T.searchParams.get("target_session_attrs")||W.PGTARGETSESSIONATTRS;if(!U||["read-write","read-only","primary","standby","prefer-standby"].includes(U))return U;throw new Error("target_session_attrs "+U+" is not supported")}function If($){return(0.5+Math.random()/2)*Math.min(3**$/100,20)}function bf(){return 60*(30+Math.random()*30)}function ff($){return{undefined:$.undefined,column:{from:typeof $.column==="function"?$.column:$.column&&$.column.from,to:$.column&&$.column.to},value:{from:typeof $.value==="function"?$.value:$.value&&$.value.from,to:$.value&&$.value.to},row:{from:typeof $.row==="function"?$.row:$.row&&$.row.from,to:$.row&&$.row.to}}}function yf($){if(!$||typeof $!=="string")return{url:{searchParams:new Map}};let T=$;T=T.slice(T.indexOf("://")+3).split(/[?/]/)[0],T=decodeURIComponent(T.slice(T.indexOf("@")+1));let W=new URL($.replace(T,T.split(",")[0]));return{url:{username:decodeURIComponent(W.username),password:decodeURIComponent(W.password),host:W.host,hostname:W.hostname,port:W.port,pathname:W.pathname,searchParams:W.searchParams},multihost:T.indexOf(",")>-1&&T}}function hf(){try{return Sf.userInfo().username}catch($){return process.env.USERNAME||process.env.USER||process.env.LOGNAME}}class E4{static[M]="SelectionProxyHandler";config;constructor($){this.config={...$}}get($,T){if(T==="_")return{...$._,selectedFields:new Proxy($._.selectedFields,this)};if(T===i$)return{...$[i$],selectedFields:new Proxy($[i$].selectedFields,this)};if(typeof T==="symbol")return $[T];let U=(j($,A4)?$._.selectedFields:j($,c6)?$[i$].selectedFields:$)[T];if(j(U,i.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!U.isSelectionField)return U.sql;let X=U.clone();return X.isSelectionField=!0,X}if(j(U,i)){if(this.config.sqlBehavior==="sql")return U;throw new 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(j(U,u$)){if(this.config.alias)return new Proxy(U,new wU(new Proxy(U.table,new zY(this.config.alias,this.config.replaceOriginalName??!1))));return U}if(typeof U!=="object"||U===null)return U;return new Proxy(U,new E4(this.config))}}class p_{constructor($,T){this.unique=$,this.name=T}static[M]="PgIndexBuilderOn";on(...$){return new Gz($.map((T)=>{if(j(T,i))return T;T=T;let W=new XY(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=JSON.parse(JSON.stringify(T.defaultConfig)),W}),this.unique,!1,this.name)}onOnly(...$){return new Gz($.map((T)=>{if(j(T,i))return T;T=T;let W=new XY(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=T.defaultConfig,W}),this.unique,!0,this.name)}using($,...T){return new Gz(T.map((W)=>{if(j(W,i))return W;W=W;let U=new XY(W.name,!!W.keyAsName,W.columnType,W.indexConfig);return W.indexConfig=JSON.parse(JSON.stringify(W.defaultConfig)),U}),this.unique,!0,this.name,$)}}class Gz{static[M]="PgIndexBuilder";config;constructor($,T,W,U,X="btree"){this.config={name:U,columns:$,unique:T,only:W,method:X}}concurrently(){return this.config.concurrently=!0,this}with($){return this.config.with=$,this}where($){return this.config.where=$,this}build($){return new d_(this.config,$)}}class d_{static[M]="PgIndex";config;constructor($,T){this.config={...$,table:T}}}function mQ($){return new p_(!0,$)}function gf($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((W)=>W.toLowerCase()).join("_")}function mf($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((W,U,X)=>{let Y=X===0?U.toLowerCase():`${U[0].toUpperCase()}${U.slice(1)}`;return W+Y},"")}function cf($){return $}class cQ{static[M]="CasingCache";cache={};cachedTables={};convert;constructor($){this.convert=$==="snake_case"?gf:$==="camelCase"?mf:cf}getColumnCasing($){if(!$.keyAsName)return $.name;let T=$.table[p.Symbol.Schema]??"public",W=$.table[p.Symbol.OriginalName],U=`${T}.${W}.${$.name}`;if(!this.cache[U])this.cacheTable($.table);return this.cache[U]}cacheTable($){let T=$[p.Symbol.Schema]??"public",W=$[p.Symbol.OriginalName],U=`${T}.${W}`;if(!this.cachedTables[U]){for(let X of Object.values($[p.Symbol.Columns])){let Y=`${U}.${X.name}`;this.cache[Y]=this.convert(X.name)}this.cachedTables[U]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class LY extends c6{static[M]="PgViewBase"}class pW{static[M]="PgDialect";casing;constructor($){this.casing=new cQ($?.casing)}async migrate($,T,W){let U=typeof W==="string"?"__drizzle_migrations":W.migrationsTable??"__drizzle_migrations",X=typeof W==="string"?"drizzle":W.migrationsSchema??"drizzle",Y=L`
|
|
102
|
+
CREATE TABLE IF NOT EXISTS ${L.identifier(X)}.${L.identifier(U)} (
|
|
103
103
|
id SERIAL PRIMARY KEY,
|
|
104
104
|
hash text NOT NULL,
|
|
105
105
|
created_at bigint
|
|
106
106
|
)
|
|
107
|
-
`;await T.execute(O`CREATE SCHEMA IF NOT EXISTS ${O.identifier(Y)}`),await T.execute(U);let J=(await T.all(O`select id, hash, created_at from ${O.identifier(Y)}.${O.identifier(X)} order by created_at desc limit 1`))[0];await T.transaction(async(z)=>{for await(let w of $)if(!J||Number(J.created_at)<w.folderMillis){for(let H of w.sql)await z.execute(O.raw(H));await z.execute(O`insert into ${O.identifier(Y)}.${O.identifier(X)} ("hash", "created_at") values(${w.hash}, ${w.folderMillis})`)}})}escapeName($){return`"${$}"`}escapeParam($){return`$${$+1}`}escapeString($){return`'${$.replace(/'/g,"''")}'`}buildWithCTE($){if(!$?.length)return;let T=[O`with `];for(let[W,X]of $.entries())if(T.push(O`${O.identifier(X._.alias)} as (${X._.sql})`),W<$.length-1)T.push(O`, `);return T.push(O` `),O.join(T)}buildDeleteQuery({table:$,where:T,returning:W,withList:X}){let Y=this.buildWithCTE(X),U=W?O` returning ${this.buildSelection(W,{isSingleTable:!0})}`:void 0,G=T?O` where ${T}`:void 0;return O`${Y}delete from ${$}${G}${U}`}buildUpdateSet($,T){let W=$[c.Symbol.Columns],X=Object.keys(W).filter((U)=>T[U]!==void 0||W[U]?.onUpdateFn!==void 0),Y=X.length;return O.join(X.flatMap((U,G)=>{let J=W[U],z=T[U]??O.param(J.onUpdateFn(),J),w=O`${O.identifier(this.casing.getColumnCasing(J))} = ${z}`;if(G<Y-1)return[w,O.raw(", ")];return[w]}))}buildUpdateQuery({table:$,set:T,where:W,returning:X,withList:Y,from:U,joins:G}){let J=this.buildWithCTE(Y),z=$[O4.Symbol.Name],w=$[O4.Symbol.Schema],H=$[O4.Symbol.OriginalName],_=z===H?void 0:z,F=O`${w?O`${O.identifier(w)}.`:void 0}${O.identifier(H)}${_&&O` ${O.identifier(_)}`}`,D=this.buildUpdateSet($,T),V=U&&O.join([O.raw(" from "),this.buildFromTable(U)]),E=this.buildJoins(G),R=X?O` returning ${this.buildSelection(X,{isSingleTable:!U})}`:void 0,P=W?O` where ${W}`:void 0;return O`${J}update ${F} set ${D}${V}${E}${P}${R}`}buildSelection($,{isSingleTable:T=!1}={}){let W=$.length,X=$.flatMap(({field:Y},U)=>{let G=[];if(S(Y,p.Aliased)&&Y.isSelectionField)G.push(O.identifier(Y.fieldAlias));else if(S(Y,p.Aliased)||S(Y,p)){let J=S(Y,p.Aliased)?Y.sql:Y;if(T)G.push(new p(J.queryChunks.map((z)=>{if(S(z,b))return O.identifier(this.casing.getColumnCasing(z));return z})));else G.push(J);if(S(Y,p.Aliased))G.push(O` as ${O.identifier(Y.fieldAlias)}`)}else if(S(Y,B$))if(T)G.push(O.identifier(this.casing.getColumnCasing(Y)));else G.push(Y);if(U<W-1)G.push(O`, `);return G});return O.join(X)}buildJoins($){if(!$||$.length===0)return;let T=[];for(let[W,X]of $.entries()){if(W===0)T.push(O` `);let Y=X.table,U=X.lateral?O` lateral`:void 0,G=X.on?O` on ${X.on}`:void 0;if(S(Y,O4)){let J=Y[O4.Symbol.Name],z=Y[O4.Symbol.Schema],w=Y[O4.Symbol.OriginalName],H=J===w?void 0:X.alias;T.push(O`${O.raw(X.joinType)} join${U} ${z?O`${O.identifier(z)}.`:void 0}${O.identifier(w)}${H&&O` ${O.identifier(H)}`}${G}`)}else if(S(Y,g4)){let J=Y[C$].name,z=Y[C$].schema,w=Y[C$].originalName,H=J===w?void 0:X.alias;T.push(O`${O.raw(X.joinType)} join${U} ${z?O`${O.identifier(z)}.`:void 0}${O.identifier(w)}${H&&O` ${O.identifier(H)}`}${G}`)}else T.push(O`${O.raw(X.joinType)} join${U} ${Y}${G}`);if(W<$.length-1)T.push(O` `)}return O.join(T)}buildFromTable($){if(S($,c)&&$[c.Symbol.IsAlias]){let T=O`${O.identifier($[c.Symbol.OriginalName])}`;if($[c.Symbol.Schema])T=O`${O.identifier($[c.Symbol.Schema])}.${T}`;return O`${T} ${O.identifier($[c.Symbol.Name])}`}return $}buildSelectQuery({withList:$,fields:T,fieldsFlat:W,where:X,having:Y,table:U,joins:G,orderBy:J,groupBy:z,limit:w,offset:H,lockingClause:_,distinct:F,setOperators:D}){let V=W??w6(T);for(let H$ of V)if(S(H$.field,B$)&&F4(H$.field.table)!==(S(U,G4)?U._.alias:S(U,e2)?U[C$].name:S(U,p)?void 0:F4(U))&&!((e$)=>G?.some(({alias:V4})=>V4===(e$[c.Symbol.IsAlias]?F4(e$):e$[c.Symbol.BaseName])))(H$.field.table)){let e$=F4(H$.field.table);throw new Error(`Your "${H$.path.join("->")}" field references a column "${e$}"."${H$.field.name}", but the table "${e$}" is not part of the query! Did you forget to join it?`)}let E=!G||G.length===0,R=this.buildWithCTE($),P;if(F)P=F===!0?O` distinct`:O` distinct on (${O.join(F.on,O`, `)})`;let A=this.buildSelection(V,{isSingleTable:E}),N=this.buildFromTable(U),k=this.buildJoins(G),y=X?O` where ${X}`:void 0,x=Y?O` having ${Y}`:void 0,m;if(J&&J.length>0)m=O` order by ${O.join(J,O`, `)}`;let J$;if(z&&z.length>0)J$=O` group by ${O.join(z,O`, `)}`;let m$=typeof w==="object"||typeof w==="number"&&w>=0?O` limit ${w}`:void 0,B=H?O` offset ${H}`:void 0,Z$=O.empty();if(_){let H$=O` for ${O.raw(_.strength)}`;if(_.config.of)H$.append(O` of ${O.join(Array.isArray(_.config.of)?_.config.of:[_.config.of],O`, `)}`);if(_.config.noWait)H$.append(O` nowait`);else if(_.config.skipLocked)H$.append(O` skip locked`);Z$.append(H$)}let $$=O`${R}select${P} ${A} from ${N}${k}${y}${J$}${x}${m}${m$}${B}${Z$}`;if(D.length>0)return this.buildSetOperations($$,D);return $$}buildSetOperations($,T){let[W,...X]=T;if(!W)throw new Error("Cannot pass undefined values to any set operator");if(X.length===0)return this.buildSetOperationQuery({leftSelect:$,setOperator:W});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:$,setOperator:W}),X)}buildSetOperationQuery({leftSelect:$,setOperator:{type:T,isAll:W,rightSelect:X,limit:Y,orderBy:U,offset:G}}){let J=O`(${$.getSQL()}) `,z=O`(${X.getSQL()})`,w;if(U&&U.length>0){let D=[];for(let V of U)if(S(V,b))D.push(O.identifier(V.name));else if(S(V,p)){for(let E=0;E<V.queryChunks.length;E++){let R=V.queryChunks[E];if(S(R,b))V.queryChunks[E]=O.identifier(R.name)}D.push(O`${V}`)}else D.push(O`${V}`);w=O` order by ${O.join(D,O`, `)} `}let H=typeof Y==="object"||typeof Y==="number"&&Y>=0?O` limit ${Y}`:void 0,_=O.raw(`${T} ${W?"all ":""}`),F=G?O` offset ${G}`:void 0;return O`${J}${_}${z}${w}${H}${F}`}buildInsertQuery({table:$,values:T,onConflict:W,returning:X,withList:Y,select:U,overridingSystemValue_:G}){let J=[],z=$[c.Symbol.Columns],w=Object.entries(z).filter(([R,P])=>!P.shouldDisableInsert()),H=w.map(([,R])=>O.identifier(this.casing.getColumnCasing(R)));if(U){let R=T;if(S(R,p))J.push(R);else J.push(R.getSQL())}else{let R=T;J.push(O.raw("values "));for(let[P,A]of R.entries()){let N=[];for(let[k,y]of w){let x=A[k];if(x===void 0||S(x,T6)&&x.value===void 0)if(y.defaultFn!==void 0){let m=y.defaultFn(),J$=S(m,p)?m:O.param(m,y);N.push(J$)}else if(!y.default&&y.onUpdateFn!==void 0){let m=y.onUpdateFn(),J$=S(m,p)?m:O.param(m,y);N.push(J$)}else N.push(O`default`);else N.push(x)}if(J.push(N),P<R.length-1)J.push(O`, `)}}let _=this.buildWithCTE(Y),F=O.join(J),D=X?O` returning ${this.buildSelection(X,{isSingleTable:!0})}`:void 0,V=W?O` on conflict ${W}`:void 0,E=G===!0?O`overriding system value `:void 0;return O`${_}insert into ${$} ${H} ${E}${F}${V}${D}`}buildRefreshMaterializedViewQuery({view:$,concurrently:T,withNoData:W}){let X=T?O` concurrently`:void 0,Y=W?O` with no data`:void 0;return O`refresh materialized view${X} ${$}${Y}`}prepareTyping($){if(S($,y8)||S($,f8))return"json";else if(S($,h8))return"decimal";else if(S($,g8))return"time";else if(S($,m8)||S($,c8))return"timestamp";else if(S($,x8)||S($,b8))return"date";else if(S($,u8))return"uuid";else return"none"}sqlToQuery($,T){return $.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,prepareTyping:this.prepareTyping,invokeSource:T})}buildRelationalQueryWithoutPK({fullSchema:$,schema:T,tableNamesMap:W,table:X,tableConfig:Y,queryConfig:U,tableAlias:G,nestedQueryRelation:J,joinOn:z}){let w=[],H,_,F=[],D,V=[];if(U===!0)w=Object.entries(Y.columns).map(([P,A])=>({dbKey:A.name,tsKey:P,field:y6(A,G),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let R=Object.fromEntries(Object.entries(Y.columns).map(([x,m])=>[x,y6(m,G)]));if(U.where){let x=typeof U.where==="function"?U.where(R,VO()):U.where;D=x&&c2(x,G)}let P=[],A=[];if(U.columns){let x=!1;for(let[m,J$]of Object.entries(U.columns)){if(J$===void 0)continue;if(m in Y.columns){if(!x&&J$===!0)x=!0;A.push(m)}}if(A.length>0)A=x?A.filter((m)=>U.columns?.[m]===!0):Object.keys(Y.columns).filter((m)=>!A.includes(m))}else A=Object.keys(Y.columns);for(let x of A){let m=Y.columns[x];P.push({tsKey:x,value:m})}let N=[];if(U.with)N=Object.entries(U.with).filter((x)=>!!x[1]).map(([x,m])=>({tsKey:x,queryConfig:m,relation:Y.relations[x]}));let k;if(U.extras){k=typeof U.extras==="function"?U.extras(R,{sql:O}):U.extras;for(let[x,m]of Object.entries(k))P.push({tsKey:x,value:E7(m,G)})}for(let{tsKey:x,value:m}of P)w.push({dbKey:S(m,p.Aliased)?m.fieldAlias:Y.columns[x].name,tsKey:x,field:S(m,B$)?y6(m,G):m,relationTableTsKey:void 0,isJson:!1,selection:[]});let y=typeof U.orderBy==="function"?U.orderBy(R,KO()):U.orderBy??[];if(!Array.isArray(y))y=[y];F=y.map((x)=>{if(S(x,B$))return y6(x,G);return c2(x,G)}),H=U.limit,_=U.offset;for(let{tsKey:x,queryConfig:m,relation:J$}of N){let m$=MO(T,W,J$),B=R0(J$.referencedTable),Z$=W[B],$$=`${G}_${x}`,H$=l2(...m$.fields.map((D6,g0)=>p8(y6(m$.references[g0],$$),y6(D6,G)))),e$=this.buildRelationalQueryWithoutPK({fullSchema:$,schema:T,tableNamesMap:W,table:$[Z$],tableConfig:T[Z$],queryConfig:S(J$,h1)?m===!0?{limit:1}:{...m,limit:1}:m,tableAlias:$$,joinOn:H$,nestedQueryRelation:J$}),V4=O`${O.identifier($$)}.${O.identifier("data")}`.as(x);V.push({on:O`true`,table:new G4(e$.sql,{},$$),alias:$$,joinType:"left",lateral:!0}),w.push({dbKey:x,tsKey:x,field:V4,relationTableTsKey:Z$,isJson:!0,selection:e$.selection})}}if(w.length===0)throw new v8({message:`No fields selected for table "${Y.tsName}" ("${G}")`});let E;if(D=l2(z,D),J){let R=O`json_build_array(${O.join(w.map(({field:N,tsKey:k,isJson:y})=>y?O`${O.identifier(`${G}_${k}`)}.${O.identifier("data")}`:S(N,p.Aliased)?N.sql:N),O`, `)})`;if(S(J,r2))R=O`coalesce(json_agg(${R}${F.length>0?O` order by ${O.join(F,O`, `)}`:void 0}), '[]'::json)`;let P=[{dbKey:"data",tsKey:"data",field:R.as("data"),isJson:!0,relationTableTsKey:Y.tsName,selection:w}];if(H!==void 0||_!==void 0||F.length>0)E=this.buildSelectQuery({table:C8(X,G),fields:{},fieldsFlat:[{path:[],field:O.raw("*")}],where:D,limit:H,offset:_,orderBy:F,setOperators:[]}),D=void 0,H=void 0,_=void 0,F=[];else E=C8(X,G);E=this.buildSelectQuery({table:S(E,O4)?E:new G4(E,{},G),fields:{},fieldsFlat:P.map(({field:N})=>({path:[],field:S(N,B$)?y6(N,G):N})),joins:V,where:D,limit:H,offset:_,orderBy:F,setOperators:[]})}else E=this.buildSelectQuery({table:C8(X,G),fields:{},fieldsFlat:w.map(({field:R})=>({path:[],field:S(R,B$)?y6(R,G):R})),joins:V,where:D,limit:H,offset:_,orderBy:F,setOperators:[]});return{tableTsKey:Y.tsName,sql:E,selection:w}}}class o7{static[Z]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class P4{static[Z]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor($){if(this.fields=$.fields,this.session=$.session,this.dialect=$.dialect,$.withList)this.withList=$.withList;this.distinct=$.distinct}authToken;setToken($){return this.authToken=$,this}from($){let T=!!this.fields,W=$,X;if(this.fields)X=this.fields;else if(S(W,G4))X=Object.fromEntries(Object.keys(W._.selectedFields).map((Y)=>[Y,W[Y]]));else if(S(W,e2))X=W[C$].selectedFields;else if(S(W,p))X={};else X=aQ(W);return new l7({table:W,fields:X,isPartialSelect:T,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class uO extends o7{static[Z]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:$,fields:T,isPartialSelect:W,session:X,dialect:Y,withList:U,distinct:G}){super();this.config={withList:U,table:$,fields:{...T},distinct:G,setOperators:[]},this.isPartialSelect=W,this.session=X,this.dialect=Y,this._={selectedFields:T},this.tableName=U1($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}createJoin($,T){return(W,X)=>{let Y=this.tableName,U=U1(W);if(typeof U==="string"&&this.config.joins?.some((G)=>G.alias===U))throw new Error(`Alias "${U}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof Y==="string")this.config.fields={[Y]:this.config.fields};if(typeof U==="string"&&!S(W,p)){let G=S(W,G4)?W._.selectedFields:S(W,g4)?W[C$].selectedFields:W[c.Symbol.Columns];this.config.fields[U]=G}}if(typeof X==="function")X=X(new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:X,table:W,joinType:$,alias:U,lateral:T}),typeof U==="string")switch($){case"left":{this.joinsNotNullableMap[U]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([G])=>[G,!1])),this.joinsNotNullableMap[U]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[U]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([G])=>[G,!1])),this.joinsNotNullableMap[U]=!1;break}}return this}}leftJoin=this.createJoin("left",!1);leftJoinLateral=this.createJoin("left",!0);rightJoin=this.createJoin("right",!1);innerJoin=this.createJoin("inner",!1);innerJoinLateral=this.createJoin("inner",!0);fullJoin=this.createJoin("full",!1);crossJoin=this.createJoin("cross",!1);crossJoinLateral=this.createJoin("cross",!0);createSetOperator($,T){return(W)=>{let X=typeof W==="function"?W(ck()):W;if(!u2(this.getSelectedFields(),X.getSelectedFields()))throw new 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:$,isAll:T,rightSelect:X}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators($){return this.config.setOperators.push(...$),this}where($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=$,this}having($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=$,this}groupBy(...$){if(typeof $[0]==="function"){let T=$[0](new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(T)?T:[T]}else this.config.groupBy=$;return this}orderBy(...$){if(typeof $[0]==="function"){let T=$[0](new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),W=Array.isArray(T)?T:[T];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=W;else this.config.orderBy=W}else{let T=$;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=T;else this.config.orderBy=T}return this}limit($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=$;else this.config.limit=$;return this}offset($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=$;else this.config.offset=$;return this}for($,T={}){return this.config.lockingClause={strength:$,config:T},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}as($){return new Proxy(new G4(this.getSQL(),this.config.fields,$),new r$({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new r$({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}class l7 extends uO{static[Z]="PgSelect";_prepare($){let{session:T,config:W,dialect:X,joinsNotNullableMap:Y,authToken:U}=this;if(!T)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return R$.startActiveSpan("drizzle.prepareQuery",()=>{let G=w6(W.fields),J=T.prepareQuery(X.sqlToQuery(this.getSQL()),G,$,!0);return J.joinsNotNullableMap=Y,J.setToken(U)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return R$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}tQ(l7,[k4]);function CT($,T){return(W,X,...Y)=>{let U=[X,...Y].map((G)=>({type:$,isAll:T,rightSelect:G}));for(let G of U)if(!u2(W.getSelectedFields(),G.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return W.addSetOperators(U)}}var ck=()=>({union:uk,unionAll:pk,intersect:dk,intersectAll:ok,except:lk,exceptAll:rk}),uk=CT("union",!1),pk=CT("union",!0),dk=CT("intersect",!1),ok=CT("intersect",!0),lk=CT("except",!1),rk=CT("except",!0);class $X{static[Z]="PgQueryBuilder";dialect;dialectConfig;constructor($){this.dialect=S($,C0)?$:void 0,this.dialectConfig=S($,C0)?void 0:$}$with=($,T)=>{let W=this;return{as:(Y)=>{if(typeof Y==="function")Y=Y(W);return new Proxy(new h2(Y.getSQL(),T??("getSelectedFields"in Y?Y.getSelectedFields()??{}:{}),$,!0),new r$({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...$){let T=this;function W(U){return new P4({fields:U??void 0,session:void 0,dialect:T.getDialect(),withList:$})}function X(U){return new P4({fields:U??void 0,session:void 0,dialect:T.getDialect(),distinct:!0})}function Y(U,G){return new P4({fields:G??void 0,session:void 0,dialect:T.getDialect(),distinct:{on:U}})}return{select:W,selectDistinct:X,selectDistinctOn:Y}}select($){return new P4({fields:$??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct($){return new P4({fields:$??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn($,T){return new P4({fields:T??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:$}})}getDialect(){if(!this.dialect)this.dialect=new C0(this.dialectConfig);return this.dialect}}class YU{constructor($,T,W,X,Y){this.table=$,this.session=T,this.dialect=W,this.withList=X,this.overridingSystemValue_=Y}static[Z]="PgInsertBuilder";authToken;setToken($){return this.authToken=$,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values($){if($=Array.isArray($)?$:[$],$.length===0)throw new Error("values() must be called with at least one value");let T=$.map((W)=>{let X={},Y=this.table[c.Symbol.Columns];for(let U of Object.keys(W)){let G=W[U];X[U]=S(G,p)?G:new T6(G,Y[U])}return X});return new r7(this.table,T,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select($){let T=typeof $==="function"?$(new $X):$;if(!S(T,p)&&!u2(this.table[q8],T._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new r7(this.table,T,this.session,this.dialect,this.withList,!0)}}class r7 extends k4{constructor($,T,W,X,Y,U,G){super();this.session=W,this.dialect=X,this.config={table:$,values:T,withList:Y,select:U,overridingSystemValue_:G}}static[Z]="PgInsert";config;returning($=this.config.table[c.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=w6($),this}onConflictDoNothing($={}){if($.target===void 0)this.config.onConflict=O`do nothing`;else{let T="";T=Array.isArray($.target)?$.target.map((X)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(X))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target));let W=$.where?O` where ${$.where}`:void 0;this.config.onConflict=O`(${O.raw(T)})${W} do nothing`}return this}onConflictDoUpdate($){if($.where&&($.targetWhere||$.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let T=$.where?O` where ${$.where}`:void 0,W=$.targetWhere?O` where ${$.targetWhere}`:void 0,X=$.setWhere?O` where ${$.setWhere}`:void 0,Y=this.dialect.buildUpdateSet(this.config.table,j8(this.config.table,$.set)),U="";return U=Array.isArray($.target)?$.target.map((G)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(G))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target)),this.config.onConflict=O`(${O.raw(U)})${W} do update set ${Y}${T}${X}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return R$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return R$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new r$({alias:F4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class i7 extends k4{constructor($,T,W){super();this.session=T,this.dialect=W,this.config={view:$}}static[Z]="PgRefreshMaterializedView";config;concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return R$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return R$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}class UU{constructor($,T,W,X){this.table=$,this.session=T,this.dialect=W,this.withList=X}static[Z]="PgUpdateBuilder";authToken;setToken($){return this.authToken=$,this}set($){return new pO(this.table,j8(this.table,$),this.session,this.dialect,this.withList).setToken(this.authToken)}}class pO extends k4{constructor($,T,W,X,Y){super();this.session=W,this.dialect=X,this.config={set:T,table:$,withList:Y,joins:[]},this.tableName=U1($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[Z]="PgUpdate";config;tableName;joinsNotNullableMap;from($){let T=$,W=U1(T);if(typeof W==="string")this.joinsNotNullableMap[W]=!0;return this.config.from=T,this}getTableLikeFields($){if(S($,O4))return $[c.Symbol.Columns];else if(S($,G4))return $._.selectedFields;return $[C$].selectedFields}createJoin($){return(T,W)=>{let X=U1(T);if(typeof X==="string"&&this.config.joins.some((Y)=>Y.alias===X))throw new Error(`Alias "${X}" is already used in this query`);if(typeof W==="function"){let Y=this.config.from&&!S(this.config.from,p)?this.getTableLikeFields(this.config.from):void 0;W=W(new Proxy(this.config.table[c.Symbol.Columns],new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),Y&&new Proxy(Y,new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:W,table:T,joinType:$,alias:X}),typeof X==="string")switch($){case"left":{this.joinsNotNullableMap[X]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([Y])=>[Y,!1])),this.joinsNotNullableMap[X]=!0;break}case"inner":{this.joinsNotNullableMap[X]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([Y])=>[Y,!1])),this.joinsNotNullableMap[X]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where($){return this.config.where=$,this}returning($){if(!$){if($=Object.assign({},this.config.table[c.Symbol.Columns]),this.config.from){let T=U1(this.config.from);if(typeof T==="string"&&this.config.from&&!S(this.config.from,p)){let W=this.getTableLikeFields(this.config.from);$[T]=W}for(let W of this.config.joins){let X=U1(W.table);if(typeof X==="string"&&!S(W.table,p)){let Y=this.getTableLikeFields(W.table);$[X]=Y}}}}return this.config.returningFields=$,this.config.returning=w6($),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){let T=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0);return T.joinsNotNullableMap=this.joinsNotNullableMap,T}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return this._prepare().execute($,this.authToken)};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new r$({alias:F4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class TX extends p{constructor($){super(TX.buildEmbeddedCount($.source,$.filters).queryChunks);this.params=$,this.mapWith(Number),this.session=$.session,this.sql=TX.buildCount($.source,$.filters)}sql;token;static[Z]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount($,T){return O`(select count(*) from ${$}${O.raw(" where ").if(T)}${T})`}static buildCount($,T){return O`select count(*) as count from ${$}${O.raw(" where ").if(T)}${T};`}setToken($){return this.token=$,this}then($,T){return Promise.resolve(this.session.count(this.sql,this.token)).then($,T)}catch($){return this.then(void 0,$)}finally($){return this.then((T)=>{return $?.(),T},(T)=>{throw $?.(),T})}}class t7{constructor($,T,W,X,Y,U,G){this.fullSchema=$,this.schema=T,this.tableNamesMap=W,this.table=X,this.tableConfig=Y,this.dialect=U,this.session=G}static[Z]="PgRelationalQueryBuilder";findMany($){return new n7(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?$:{},"many")}findFirst($){return new n7(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?{...$,limit:1}:{limit:1},"first")}}class n7 extends k4{constructor($,T,W,X,Y,U,G,J,z){super();this.fullSchema=$,this.schema=T,this.tableNamesMap=W,this.table=X,this.tableConfig=Y,this.dialect=U,this.session=G,this.config=J,this.mode=z}static[Z]="PgRelationalQuery";_prepare($){return R$.startActiveSpan("drizzle.prepareQuery",()=>{let{query:T,builtQuery:W}=this._toSQL();return this.session.prepareQuery(W,void 0,$,!0,(X,Y)=>{let U=X.map((G)=>o8(this.schema,this.tableConfig,G,T.selection,Y));if(this.mode==="first")return U[0];return U})})}prepare($){return this._prepare($)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let $=this._getQuery(),T=this.dialect.sqlToQuery($.sql);return{query:$,builtQuery:T}}toSQL(){return this._toSQL().builtQuery}authToken;setToken($){return this.authToken=$,this}execute(){return R$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class a7 extends k4{constructor($,T,W,X){super();this.execute=$,this.sql=T,this.query=W,this.mapBatchResult=X}static[Z]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult($,T){return T?this.mapBatchResult($):$}_prepare(){return this}isResponseInArrayMode(){return!1}}class WX{constructor($,T,W){if(this.dialect=$,this.session=T,this._=W?{schema:W.schema,fullSchema:W.fullSchema,tableNamesMap:W.tableNamesMap,session:T}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:T},this.query={},this._.schema)for(let[X,Y]of Object.entries(this._.schema))this.query[X]=new t7(W.fullSchema,this._.schema,this._.tableNamesMap,W.fullSchema[X],Y,$,T)}static[Z]="PgDatabase";query;$with=($,T)=>{let W=this;return{as:(Y)=>{if(typeof Y==="function")Y=Y(new $X(W.dialect));return new Proxy(new h2(Y.getSQL(),T??("getSelectedFields"in Y?Y.getSelectedFields()??{}:{}),$,!0),new r$({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count($,T){return new TX({source:$,filters:T,session:this.session})}with(...$){let T=this;function W(z){return new P4({fields:z??void 0,session:T.session,dialect:T.dialect,withList:$})}function X(z){return new P4({fields:z??void 0,session:T.session,dialect:T.dialect,withList:$,distinct:!0})}function Y(z,w){return new P4({fields:w??void 0,session:T.session,dialect:T.dialect,withList:$,distinct:{on:z}})}function U(z){return new UU(z,T.session,T.dialect,$)}function G(z){return new YU(z,T.session,T.dialect,$)}function J(z){return new XU(z,T.session,T.dialect,$)}return{select:W,selectDistinct:X,selectDistinctOn:Y,update:U,insert:G,delete:J}}select($){return new P4({fields:$??void 0,session:this.session,dialect:this.dialect})}selectDistinct($){return new P4({fields:$??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn($,T){return new P4({fields:T??void 0,session:this.session,dialect:this.dialect,distinct:{on:$}})}update($){return new UU($,this.session,this.dialect)}insert($){return new YU($,this.session,this.dialect)}delete($){return new XU($,this.session,this.dialect)}refreshMaterializedView($){return new i7($,this.session,this.dialect)}authToken;execute($){let T=typeof $==="string"?O.raw($):$.getSQL(),W=this.dialect.sqlToQuery(T),X=this.session.prepareQuery(W,void 0,void 0,!1);return new a7(()=>X.execute(void 0,this.authToken),T,W,(Y)=>X.mapResult(Y,!0))}transaction($,T){return this.session.transaction($,T)}}class dO{constructor($,T){this.unique=$,this.name=T}static[Z]="PgIndexBuilderOn";on(...$){return new GU($.map((T)=>{if(S(T,p))return T;T=T;let W=new f2(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=JSON.parse(JSON.stringify(T.defaultConfig)),W}),this.unique,!1,this.name)}onOnly(...$){return new GU($.map((T)=>{if(S(T,p))return T;T=T;let W=new f2(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=T.defaultConfig,W}),this.unique,!0,this.name)}using($,...T){return new GU(T.map((W)=>{if(S(W,p))return W;W=W;let X=new f2(W.name,!!W.keyAsName,W.columnType,W.indexConfig);return W.indexConfig=JSON.parse(JSON.stringify(W.defaultConfig)),X}),this.unique,!0,this.name,$)}}class GU{static[Z]="PgIndexBuilder";config;constructor($,T,W,X,Y="btree"){this.config={name:X,columns:$,unique:T,only:W,method:Y}}concurrently(){return this.config.concurrently=!0,this}with($){return this.config.with=$,this}where($){return this.config.where=$,this}build($){return new oO(this.config,$)}}class oO{static[Z]="PgIndex";config;constructor($,T){this.config={...$,table:T}}}function s7($){return new dO(!0,$)}class e7{constructor($){this.query=$}authToken;getQuery(){return this.query}mapResult($,T){return $}setToken($){return this.authToken=$,this}static[Z]="PgPreparedQuery";joinsNotNullableMap}class $_{constructor($){this.dialect=$}static[Z]="PgSession";execute($,T){return R$.startActiveSpan("drizzle.operation",()=>{return R$.startActiveSpan("drizzle.prepareQuery",()=>{return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1)}).setToken(T).execute(void 0,T)})}all($){return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1).all()}async count($,T){let W=await this.execute($,T);return Number(W[0].count)}}class T_ extends WX{constructor($,T,W,X=0){super($,T,W);this.schema=W,this.nestedIndex=X}static[Z]="PgTransaction";rollback(){throw new M7}getTransactionConfigSQL($){let T=[];if($.isolationLevel)T.push(`isolation level ${$.isolationLevel}`);if($.accessMode)T.push($.accessMode);if(typeof $.deferrable==="boolean")T.push($.deferrable?"deferrable":"not deferrable");return O.raw(T.join(" "))}setTransaction($){return this.session.execute(O`set transaction ${this.getTransactionConfigSQL($)}`)}}class lO extends e7{constructor($,T,W,X,Y,U,G){super({sql:T,params:W});this.client=$,this.queryString=T,this.params=W,this.logger=X,this.fields=Y,this._isResponseInArrayMode=U,this.customResultMapper=G}static[Z]="PostgresJsPreparedQuery";async execute($={}){return R$.startActiveSpan("drizzle.execute",async(T)=>{let W=K7(this.params,$);T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.logger.logQuery(this.queryString,W);let{fields:X,queryString:Y,client:U,joinsNotNullableMap:G,customResultMapper:J}=this;if(!X&&!J)return R$.startActiveSpan("drizzle.driver.execute",()=>{return U.unsafe(Y,W)});let z=await R$.startActiveSpan("drizzle.driver.execute",()=>{return T?.setAttributes({"drizzle.query.text":Y,"drizzle.query.params":JSON.stringify(W)}),U.unsafe(Y,W).values()});return R$.startActiveSpan("drizzle.mapResponse",()=>{return J?J(z):z.map((w)=>nQ(X,w,G))})})}all($={}){return R$.startActiveSpan("drizzle.execute",async(T)=>{let W=K7(this.params,$);return T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.logger.logQuery(this.queryString,W),R$.startActiveSpan("drizzle.driver.execute",()=>{return T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.client.unsafe(this.queryString,W)})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class XX extends $_{constructor($,T,W,X={}){super(T);this.client=$,this.schema=W,this.options=X,this.logger=X.logger??new N7}static[Z]="PostgresJsSession";logger;prepareQuery($,T,W,X,Y){return new lO(this.client,$.sql,$.params,this.logger,T,X,Y)}query($,T){return this.logger.logQuery($,T),this.client.unsafe($,T).values()}queryObjects($,T){return this.client.unsafe($,T)}transaction($,T){return this.client.begin(async(W)=>{let X=new XX(W,this.dialect,this.schema,this.options),Y=new W_(this.dialect,X,this.schema);if(T)await Y.setTransaction(T);return $(Y)})}}class W_ extends T_{constructor($,T,W,X=0){super($,T,W,X);this.session=T}static[Z]="PostgresJsTransaction";transaction($){return this.session.client.savepoint((T)=>{let W=new XX(T,this.dialect,this.schema,this.session.options),X=new W_(this.dialect,W,this.schema);return $(X)})}}class rO extends WX{static[Z]="PostgresJsDatabase"}function vT($,T={}){let W=(z)=>z;for(let z of["1184","1082","1083","1114","1182","1185","1115","1231"])$.options.parsers[z]=W,$.options.serializers[z]=W;$.options.serializers["114"]=W,$.options.serializers["3802"]=W;let X=new C0({casing:T.casing}),Y;if(T.logger===!0)Y=new A7;else if(T.logger!==!1)Y=T.logger;let U;if(T.schema){let z=EO(T.schema,AO);U={fullSchema:T.schema,schema:z.tables,tableNamesMap:z.tableNamesMap}}let G=new XX($,X,U,{logger:Y}),J=new rO(X,G,U);return J.$client=$,J}function JU(...$){if(typeof $[0]==="string"){let T=PT($[0]);return vT(T,$[1])}if(sQ($[0])){let{connection:T,client:W,...X}=$[0];if(W)return vT(W,X);if(typeof T==="object"&&T.url!==void 0){let{url:U,...G}=T,J=PT(U,G);return vT(J,X)}let Y=PT(T);return vT(Y,X)}return vT($[0],$[1])}(($)=>{function T(W){return vT({options:{parsers:{},serializers:{}}},W)}$.mock=T})(JU||(JU={}));function iO($,T){if($ instanceof Promise)throw new Error(T)}function ik($,T){let W={},X=[];for(let Y in $){let U=$[Y]["~standard"].validate(T[Y]);if(iO(U,`Validation must be synchronous, but ${Y} returned a Promise.`),U.issues){X.push(...U.issues.map((G)=>({...G,path:[Y,...G.path??[]]})));continue}W[Y]=U.value}if(X.length)return{issues:X};return{value:W}}function X_($){let T=$.runtimeEnvStrict??$.runtimeEnv??process.env;if($.emptyStringAsUndefined??!1){for(let[A,N]of Object.entries(T))if(N==="")delete T[A]}if(!!$.skipValidation)return T;let Y=typeof $.client==="object"?$.client:{},U=typeof $.server==="object"?$.server:{},G=typeof $.shared==="object"?$.shared:{},J=$.isServer??(typeof window==="undefined"||("Deno"in window)),z=J?{...U,...G,...Y}:{...Y,...G},w=$.createFinalSchema?.(z,J)["~standard"].validate(T)??ik(z,T);iO(w,"Validation must be synchronous");let H=$.onValidationError??((A)=>{throw console.error("\u274C Invalid environment variables:",A),new Error("Invalid environment variables")}),_=$.onInvalidAccess??(()=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")});if(w.issues)return H(w.issues);let F=(A)=>{if(!$.clientPrefix)return!0;return!A.startsWith($.clientPrefix)&&!(A in G)},D=(A)=>{return J||!F(A)},V=(A)=>{return A==="__esModule"||A==="$$typeof"},E=($.extends??[]).reduce((A,N)=>{return Object.assign(A,N)},{}),R=Object.assign(E,w.value);return new Proxy(R,{get(A,N){if(typeof N!=="string")return;if(V(N))return;if(!D(N))return _(N);return Reflect.get(A,N)}})}var m1=($)=>Array.isArray($)?$:[$],nO=($,T)=>{let W=[[],[]];for(let X of $)if(T(X))W[0].push(X);else W[1].push(X);return W},wU=Array,J1=($,T)=>$.includes(T),tO=($,T=0)=>[...new Array($)].map((W,X)=>X+T),Q$=($,T,W)=>{if($===void 0)return T===void 0?[]:Array.isArray(T)?T:[T];if(W?.prepend)if(Array.isArray(T))$.unshift(...T);else $.unshift(T);else if(Array.isArray(T))$.push(...T);else $.push(T);return $},w1=($,T)=>{if(T===void 0||T===null)return $??[];if($===void 0||$===null)return m1(T);return $.concat(T)},aO=(...$)=>$.reduce(w1,[]),g6=($,T,W)=>{if($===void 0)return Array.isArray(T)?T:[T];let X=W?.isEqual??((Y,U)=>Y===U);for(let Y of m1(T))if(!$.some((U)=>X(U,Y)))$.push(Y);return $},sO=($,T)=>$.reduce((W,X)=>{let Y=X[T];return W[Y]=Q$(W[Y],X),W},{}),z1=($,T,W)=>$.length===T.length&&$.every(W?.isEqual?(X,Y)=>W.isEqual(X,T[Y]):(X,Y)=>X===T[Y]);var c4=($,T)=>w4($)===T,w4=($)=>{let T=typeof $;return T==="object"?$===null?"null":"object":T==="function"?"object":T},u4={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},eO={...u4,function:"a function"};class $V extends Error{}var O$=($)=>v0($,$V),v0=($,T=Error)=>{throw new T($)};class YX extends Error{name="ParseError"}var L=($)=>v0($,YX),L6=($)=>` ${$}`;var Y$=($,T)=>{let W={},X=Array.isArray($),Y=!1;for(let[U,G]of Object.entries($).entries()){let J=X?T(U,G[1]):T(...G,U);Y||=typeof J[0]==="number";let z=Array.isArray(J[0])||J.length===0?J:[J];for(let[w,H]of z)if(typeof w==="object")W[w.group]=Q$(W[w.group],H);else W[w]=H}return Y?Object.values(W):W};var Y_=Object.entries;var z4=($,T)=>($ in T),jT=($,T)=>(T in $);class U_{constructor($){Object.assign(this,$)}}var TV=class{};class UX extends TV{}var nk=($,T)=>{let W={},X={},Y;for(Y in $)if(Y in T)W[Y]=$[Y];else X[Y]=$[Y];return[W,X]};var WV=($,T)=>nk($,T)[1],m6=($)=>Object.keys($).length===0,j0=($)=>[...Object.entries($),...Object.getOwnPropertySymbols($).map((T)=>[T,$[T]])],XV=($,T)=>Object.defineProperties($,Object.getOwnPropertyDescriptors(T)),YV=($)=>{let T=Object.keys($).sort(),W={};for(let X=0;X<T.length;X++)W[T[X]]=$[T[X]];return W};var X6=L6("represents an uninitialized value"),UV=($)=>Object.values($).filter((T)=>{if(typeof T==="number")return!0;return typeof $[T]!=="number"});var G_={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},J_=globalThis.File??Blob,w_={ArrayBuffer,Blob,File:J_,FormData,Headers,Request,Response,URL},tk={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},x0={...G_,...w_,...tk,String,Number,Boolean},GX=($)=>{let T=Object.getPrototypeOf($);while(T?.constructor&&(!z4(T.constructor.name,x0)||!($ instanceof x0[T.constructor.name])))T=Object.getPrototypeOf(T);let W=T?.constructor?.name;if(W===void 0||W==="Object")return;return W},JX=($)=>typeof $==="object"&&$!==null?GX($)??"object":w4($);var I$=Array.isArray,ak={Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},sk={ArrayBuffer:"an ArrayBuffer instance",Blob:"a Blob instance",File:"a File instance",FormData:"a FormData instance",Headers:"a Headers instance",Request:"a Request instance",Response:"a Response instance",URL:"a URL instance"},ek={Int8Array:"an Int8Array",Uint8Array:"a Uint8Array",Uint8ClampedArray:"a Uint8ClampedArray",Int16Array:"an Int16Array",Uint16Array:"a Uint16Array",Int32Array:"an Int32Array",Uint32Array:"a Uint32Array",Float32Array:"a Float32Array",Float64Array:"a Float64Array",BigInt64Array:"a BigInt64Array",BigUint64Array:"a BigUint64Array"},GV={...ak,...sk,...ek},wX=($)=>{let T=Object($).name??null;return T&&z4(T,x0)&&x0[T]===$?T:null};var z_=($,T)=>{let W=$.prototype;while(W!==null){if(W===T.prototype)return!0;W=Object.getPrototypeOf(W)}return!1};var JV=($)=>wV($,new Map),wV=($,T)=>{if(typeof $!=="object"||$===null)return $;if(T?.has($))return T.get($);let W=wX($.constructor);if(W==="Date")return new Date($.getTime());if(W&&W!=="Array")return $;let X=Array.isArray($)?$.slice():Object.create(Object.getPrototypeOf($)),Y=Object.getOwnPropertyDescriptors($);if(T){T.set($,X);for(let U in Y){let G=Y[U];if("get"in G||"set"in G)continue;G.value=wV(G.value,T)}}return Object.defineProperties(X,Y),X};var $q=($)=>{let T=X6;return()=>T===X6?T=$():T},c1=($)=>typeof $==="function"&&$.length===0;var zV=class extends Function{constructor(...$){let T=$.slice(0,-1),W=$.at(-1);try{super(...T,W)}catch(X){return O$(`Encountered an unexpected error while compiling your definition:
|
|
108
|
-
Message: ${X}
|
|
107
|
+
`;await T.execute(L`CREATE SCHEMA IF NOT EXISTS ${L.identifier(X)}`),await T.execute(Y);let G=(await T.all(L`select id, hash, created_at from ${L.identifier(X)}.${L.identifier(U)} order by created_at desc limit 1`))[0];await T.transaction(async(H)=>{for await(let z of $)if(!G||Number(G.created_at)<z.folderMillis){for(let F of z.sql)await H.execute(L.raw(F));await H.execute(L`insert into ${L.identifier(X)}.${L.identifier(U)} ("hash", "created_at") values(${z.hash}, ${z.folderMillis})`)}})}escapeName($){return`"${$}"`}escapeParam($){return`$${$+1}`}escapeString($){return`'${$.replace(/'/g,"''")}'`}buildWithCTE($){if(!$?.length)return;let T=[L`with `];for(let[W,U]of $.entries())if(T.push(L`${L.identifier(U._.alias)} as (${U._.sql})`),W<$.length-1)T.push(L`, `);return T.push(L` `),L.join(T)}buildDeleteQuery({table:$,where:T,returning:W,withList:U}){let X=this.buildWithCTE(U),Y=W?L` returning ${this.buildSelection(W,{isSingleTable:!0})}`:void 0,w=T?L` where ${T}`:void 0;return L`${X}delete from ${$}${w}${Y}`}buildUpdateSet($,T){let W=$[p.Symbol.Columns],U=Object.keys(W).filter((Y)=>T[Y]!==void 0||W[Y]?.onUpdateFn!==void 0),X=U.length;return L.join(U.flatMap((Y,w)=>{let G=W[Y],H=T[Y]??L.param(G.onUpdateFn(),G),z=L`${L.identifier(this.casing.getColumnCasing(G))} = ${H}`;if(w<X-1)return[z,L.raw(", ")];return[z]}))}buildUpdateQuery({table:$,set:T,where:W,returning:U,withList:X,from:Y,joins:w}){let G=this.buildWithCTE(X),H=$[B4.Symbol.Name],z=$[B4.Symbol.Schema],F=$[B4.Symbol.OriginalName],O=H===F?void 0:H,Q=L`${z?L`${L.identifier(z)}.`:void 0}${L.identifier(F)}${O&&L` ${L.identifier(O)}`}`,Z=this.buildUpdateSet($,T),V=Y&&L.join([L.raw(" from "),this.buildFromTable(Y)]),E=this.buildJoins(w),N=U?L` returning ${this.buildSelection(U,{isSingleTable:!Y})}`:void 0,J=W?L` where ${W}`:void 0;return L`${G}update ${Q} set ${Z}${V}${E}${J}${N}`}buildSelection($,{isSingleTable:T=!1}={}){let W=$.length,U=$.flatMap(({field:X},Y)=>{let w=[];if(j(X,i.Aliased)&&X.isSelectionField)w.push(L.identifier(X.fieldAlias));else if(j(X,i.Aliased)||j(X,i)){let G=j(X,i.Aliased)?X.sql:X;if(T)w.push(new i(G.queryChunks.map((H)=>{if(j(H,u))return L.identifier(this.casing.getColumnCasing(H));return H})));else w.push(G);if(j(X,i.Aliased))w.push(L` as ${L.identifier(X.fieldAlias)}`)}else if(j(X,u$))if(T)w.push(L.identifier(this.casing.getColumnCasing(X)));else w.push(X);if(Y<W-1)w.push(L`, `);return w});return L.join(U)}buildJoins($){if(!$||$.length===0)return;let T=[];for(let[W,U]of $.entries()){if(W===0)T.push(L` `);let X=U.table,Y=U.lateral?L` lateral`:void 0,w=U.on?L` on ${U.on}`:void 0;if(j(X,B4)){let G=X[B4.Symbol.Name],H=X[B4.Symbol.Schema],z=X[B4.Symbol.OriginalName],F=G===z?void 0:U.alias;T.push(L`${L.raw(U.joinType)} join${Y} ${H?L`${L.identifier(H)}.`:void 0}${L.identifier(z)}${F&&L` ${L.identifier(F)}`}${w}`)}else if(j(X,c6)){let G=X[i$].name,H=X[i$].schema,z=X[i$].originalName,F=G===z?void 0:U.alias;T.push(L`${L.raw(U.joinType)} join${Y} ${H?L`${L.identifier(H)}.`:void 0}${L.identifier(z)}${F&&L` ${L.identifier(F)}`}${w}`)}else T.push(L`${L.raw(U.joinType)} join${Y} ${X}${w}`);if(W<$.length-1)T.push(L` `)}return L.join(T)}buildFromTable($){if(j($,p)&&$[p.Symbol.IsAlias]){let T=L`${L.identifier($[p.Symbol.OriginalName])}`;if($[p.Symbol.Schema])T=L`${L.identifier($[p.Symbol.Schema])}.${T}`;return L`${T} ${L.identifier($[p.Symbol.Name])}`}return $}buildSelectQuery({withList:$,fields:T,fieldsFlat:W,where:U,having:X,table:Y,joins:w,orderBy:G,groupBy:H,limit:z,offset:F,lockingClause:O,distinct:Q,setOperators:Z}){let V=W??J1(T);for(let Y$ of V)if(j(Y$.field,u$)&&m4(Y$.field.table)!==(j(Y,A4)?Y._.alias:j(Y,LY)?Y[i$].name:j(Y,i)?void 0:m4(Y))&&!((j$)=>w?.some(({alias:s$})=>s$===(j$[p.Symbol.IsAlias]?m4(j$):j$[p.Symbol.BaseName])))(Y$.field.table)){let j$=m4(Y$.field.table);throw new Error(`Your "${Y$.path.join("->")}" field references a column "${j$}"."${Y$.field.name}", but the table "${j$}" is not part of the query! Did you forget to join it?`)}let E=!w||w.length===0,N=this.buildWithCTE($),J;if(Q)J=Q===!0?L` distinct`:L` distinct on (${L.join(Q.on,L`, `)})`;let _=this.buildSelection(V,{isSingleTable:E}),R=this.buildFromTable(Y),P=this.buildJoins(w),x=U?L` where ${U}`:void 0,f=X?L` having ${X}`:void 0,h;if(G&&G.length>0)h=L` order by ${L.join(G,L`, `)}`;let a;if(H&&H.length>0)a=L` group by ${L.join(H,L`, `)}`;let M$=typeof z==="object"||typeof z==="number"&&z>=0?L` limit ${z}`:void 0,S=F?L` offset ${F}`:void 0,W$=L.empty();if(O){let Y$=L` for ${L.raw(O.strength)}`;if(O.config.of)Y$.append(L` of ${L.join(Array.isArray(O.config.of)?O.config.of:[O.config.of],L`, `)}`);if(O.config.noWait)Y$.append(L` nowait`);else if(O.config.skipLocked)Y$.append(L` skip locked`);W$.append(Y$)}let n=L`${N}select${J} ${_} from ${R}${P}${x}${a}${f}${h}${M$}${S}${W$}`;if(Z.length>0)return this.buildSetOperations(n,Z);return n}buildSetOperations($,T){let[W,...U]=T;if(!W)throw new Error("Cannot pass undefined values to any set operator");if(U.length===0)return this.buildSetOperationQuery({leftSelect:$,setOperator:W});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:$,setOperator:W}),U)}buildSetOperationQuery({leftSelect:$,setOperator:{type:T,isAll:W,rightSelect:U,limit:X,orderBy:Y,offset:w}}){let G=L`(${$.getSQL()}) `,H=L`(${U.getSQL()})`,z;if(Y&&Y.length>0){let Z=[];for(let V of Y)if(j(V,u))Z.push(L.identifier(V.name));else if(j(V,i)){for(let E=0;E<V.queryChunks.length;E++){let N=V.queryChunks[E];if(j(N,u))V.queryChunks[E]=L.identifier(N.name)}Z.push(L`${V}`)}else Z.push(L`${V}`);z=L` order by ${L.join(Z,L`, `)} `}let F=typeof X==="object"||typeof X==="number"&&X>=0?L` limit ${X}`:void 0,O=L.raw(`${T} ${W?"all ":""}`),Q=w?L` offset ${w}`:void 0;return L`${G}${O}${H}${z}${F}${Q}`}buildInsertQuery({table:$,values:T,onConflict:W,returning:U,withList:X,select:Y,overridingSystemValue_:w}){let G=[],H=$[p.Symbol.Columns],z=Object.entries(H).filter(([N,J])=>!J.shouldDisableInsert()),F=z.map(([,N])=>L.identifier(this.casing.getColumnCasing(N)));if(Y){let N=T;if(j(N,i))G.push(N);else G.push(N.getSQL())}else{let N=T;G.push(L.raw("values "));for(let[J,_]of N.entries()){let R=[];for(let[P,x]of z){let f=_[P];if(f===void 0||j(f,F1)&&f.value===void 0)if(x.defaultFn!==void 0){let h=x.defaultFn(),a=j(h,i)?h:L.param(h,x);R.push(a)}else if(!x.default&&x.onUpdateFn!==void 0){let h=x.onUpdateFn(),a=j(h,i)?h:L.param(h,x);R.push(a)}else R.push(L`default`);else R.push(f)}if(G.push(R),J<N.length-1)G.push(L`, `)}}let O=this.buildWithCTE(X),Q=L.join(G),Z=U?L` returning ${this.buildSelection(U,{isSingleTable:!0})}`:void 0,V=W?L` on conflict ${W}`:void 0,E=w===!0?L`overriding system value `:void 0;return L`${O}insert into ${$} ${F} ${E}${Q}${V}${Z}`}buildRefreshMaterializedViewQuery({view:$,concurrently:T,withNoData:W}){let U=T?L` concurrently`:void 0,X=W?L` with no data`:void 0;return L`refresh materialized view${U} ${$}${X}`}prepareTyping($){if(j($,c9)||j($,m9))return"json";else if(j($,u9))return"decimal";else if(j($,p9))return"time";else if(j($,d9)||j($,o9))return"timestamp";else if(j($,h9)||j($,g9))return"date";else if(j($,l9))return"uuid";else return"none"}sqlToQuery($,T){return $.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,prepareTyping:this.prepareTyping,invokeSource:T})}buildRelationalQueryWithoutPK({fullSchema:$,schema:T,tableNamesMap:W,table:U,tableConfig:X,queryConfig:Y,tableAlias:w,nestedQueryRelation:G,joinOn:H}){let z=[],F,O,Q=[],Z,V=[];if(Y===!0)z=Object.entries(X.columns).map(([J,_])=>({dbKey:_.name,tsKey:J,field:z0(_,w),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let N=Object.fromEntries(Object.entries(X.columns).map(([f,h])=>[f,z0(h,w)]));if(Y.where){let f=typeof Y.where==="function"?Y.where(N,A_()):Y.where;Z=f&&HY(f,w)}let J=[],_=[];if(Y.columns){let f=!1;for(let[h,a]of Object.entries(Y.columns)){if(a===void 0)continue;if(h in X.columns){if(!f&&a===!0)f=!0;_.push(h)}}if(_.length>0)_=f?_.filter((h)=>Y.columns?.[h]===!0):Object.keys(X.columns).filter((h)=>!_.includes(h))}else _=Object.keys(X.columns);for(let f of _){let h=X.columns[f];J.push({tsKey:f,value:h})}let R=[];if(Y.with)R=Object.entries(Y.with).filter((f)=>!!f[1]).map(([f,h])=>({tsKey:f,queryConfig:h,relation:X.relations[f]}));let P;if(Y.extras){P=typeof Y.extras==="function"?Y.extras(N,{sql:L}):Y.extras;for(let[f,h]of Object.entries(P))J.push({tsKey:f,value:VQ(h,w)})}for(let{tsKey:f,value:h}of J)z.push({dbKey:j(h,i.Aliased)?h.fieldAlias:X.columns[f].name,tsKey:f,field:j(h,u$)?z0(h,w):h,relationTableTsKey:void 0,isJson:!1,selection:[]});let x=typeof Y.orderBy==="function"?Y.orderBy(N,M_()):Y.orderBy??[];if(!Array.isArray(x))x=[x];Q=x.map((f)=>{if(j(f,u$))return z0(f,w);return HY(f,w)}),F=Y.limit,O=Y.offset;for(let{tsKey:f,queryConfig:h,relation:a}of R){let M$=L_(T,W,a),S=hW(a.referencedTable),W$=W[S],n=`${w}_${f}`,Y$=DY(...M$.fields.map((f4,n6)=>r9(z0(M$.references[n6],n),z0(f4,w)))),j$=this.buildRelationalQueryWithoutPK({fullSchema:$,schema:T,tableNamesMap:W,table:$[W$],tableConfig:T[W$],queryConfig:j(a,bT)?h===!0?{limit:1}:{...h,limit:1}:h,tableAlias:n,joinOn:Y$,nestedQueryRelation:a}),s$=L`${L.identifier(n)}.${L.identifier("data")}`.as(f);V.push({on:L`true`,table:new A4(j$.sql,{},n),alias:n,joinType:"left",lateral:!0}),z.push({dbKey:f,tsKey:f,field:s$,relationTableTsKey:W$,isJson:!0,selection:j$.selection})}}if(z.length===0)throw new f9({message:`No fields selected for table "${X.tsName}" ("${w}")`});let E;if(Z=DY(H,Z),G){let N=L`json_build_array(${L.join(z.map(({field:R,tsKey:P,isJson:x})=>x?L`${L.identifier(`${w}_${P}`)}.${L.identifier("data")}`:j(R,i.Aliased)?R.sql:R),L`, `)})`;if(j(G,VY))N=L`coalesce(json_agg(${N}${Q.length>0?L` order by ${L.join(Q,L`, `)}`:void 0}), '[]'::json)`;let J=[{dbKey:"data",tsKey:"data",field:N.as("data"),isJson:!0,relationTableTsKey:X.tsName,selection:z}];if(F!==void 0||O!==void 0||Q.length>0)E=this.buildSelectQuery({table:b9(U,w),fields:{},fieldsFlat:[{path:[],field:L.raw("*")}],where:Z,limit:F,offset:O,orderBy:Q,setOperators:[]}),Z=void 0,F=void 0,O=void 0,Q=[];else E=b9(U,w);E=this.buildSelectQuery({table:j(E,B4)?E:new A4(E,{},w),fields:{},fieldsFlat:J.map(({field:R})=>({path:[],field:j(R,u$)?z0(R,w):R})),joins:V,where:Z,limit:F,offset:O,orderBy:Q,setOperators:[]})}else E=this.buildSelectQuery({table:b9(U,w),fields:{},fieldsFlat:z.map(({field:N})=>({path:[],field:j(N,u$)?z0(N,w):N})),joins:V,where:Z,limit:F,offset:O,orderBy:Q,setOperators:[]});return{tableTsKey:X.tsName,sql:E,selection:z}}}class uQ{static[M]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class v6{static[M]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor($){if(this.fields=$.fields,this.session=$.session,this.dialect=$.dialect,$.withList)this.withList=$.withList;this.distinct=$.distinct}authToken;setToken($){return this.authToken=$,this}from($){let T=!!this.fields,W=$,U;if(this.fields)U=this.fields;else if(j(W,A4))U=Object.fromEntries(Object.keys(W._.selectedFields).map((X)=>[X,W[X]]));else if(j(W,LY))U=W[i$].selectedFields;else if(j(W,i))U={};else U=aN(W);return new pQ({table:W,fields:U,isPartialSelect:T,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class o_ extends uQ{static[M]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:$,fields:T,isPartialSelect:W,session:U,dialect:X,withList:Y,distinct:w}){super();this.config={withList:Y,table:$,fields:{...T},distinct:w,setOperators:[]},this.isPartialSelect=W,this.session=U,this.dialect=X,this._={selectedFields:T,config:this.config},this.tableName=d0($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let G of g1($))this.usedTables.add(G)}getUsedTables(){return[...this.usedTables]}createJoin($,T){return(W,U)=>{let X=this.tableName,Y=d0(W);for(let w of g1(W))this.usedTables.add(w);if(typeof Y==="string"&&this.config.joins?.some((w)=>w.alias===Y))throw new Error(`Alias "${Y}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof X==="string")this.config.fields={[X]:this.config.fields};if(typeof Y==="string"&&!j(W,i)){let w=j(W,A4)?W._.selectedFields:j(W,c6)?W[i$].selectedFields:W[p.Symbol.Columns];this.config.fields[Y]=w}}if(typeof U==="function")U=U(new Proxy(this.config.fields,new E4({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:U,table:W,joinType:$,alias:Y,lateral:T}),typeof Y==="string")switch($){case"left":{this.joinsNotNullableMap[Y]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([w])=>[w,!1])),this.joinsNotNullableMap[Y]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[Y]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([w])=>[w,!1])),this.joinsNotNullableMap[Y]=!1;break}}return this}}leftJoin=this.createJoin("left",!1);leftJoinLateral=this.createJoin("left",!0);rightJoin=this.createJoin("right",!1);innerJoin=this.createJoin("inner",!1);innerJoinLateral=this.createJoin("inner",!0);fullJoin=this.createJoin("full",!1);crossJoin=this.createJoin("cross",!1);crossJoinLateral=this.createJoin("cross",!0);createSetOperator($,T){return(W)=>{let U=typeof W==="function"?W(uf()):W;if(!FY(this.getSelectedFields(),U.getSelectedFields()))throw new 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:$,isAll:T,rightSelect:U}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators($){return this.config.setOperators.push(...$),this}where($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new E4({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=$,this}having($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new E4({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=$,this}groupBy(...$){if(typeof $[0]==="function"){let T=$[0](new Proxy(this.config.fields,new E4({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(T)?T:[T]}else this.config.groupBy=$;return this}orderBy(...$){if(typeof $[0]==="function"){let T=$[0](new Proxy(this.config.fields,new E4({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),W=Array.isArray(T)?T:[T];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=W;else this.config.orderBy=W}else{let T=$;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=T;else this.config.orderBy=T}return this}limit($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=$;else this.config.limit=$;return this}offset($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=$;else this.config.offset=$;return this}for($,T={}){return this.config.lockingClause={strength:$,config:T},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}as($){let T=[];if(T.push(...g1(this.config.table)),this.config.joins)for(let W of this.config.joins)T.push(...g1(W.table));return new Proxy(new A4(this.getSQL(),this.config.fields,$,!1,[...new Set(T)]),new E4({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new E4({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}$withCache($){return this.cacheConfig=$===void 0?{config:{},enable:!0,autoInvalidate:!0}:$===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...$},this}}class pQ extends o_{static[M]="PgSelect";_prepare($){let{session:T,config:W,dialect:U,joinsNotNullableMap:X,authToken:Y,cacheConfig:w,usedTables:G}=this;if(!T)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");let{fields:H}=W;return p$.startActiveSpan("drizzle.prepareQuery",()=>{let z=J1(H),F=T.prepareQuery(U.sqlToQuery(this.getSQL()),z,$,!0,void 0,{type:"select",tables:[...G]},w);return F.joinsNotNullableMap=X,F.setToken(Y)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return p$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}tN(pQ,[k6]);function OU($,T){return(W,U,...X)=>{let Y=[U,...X].map((w)=>({type:$,isAll:T,rightSelect:w}));for(let w of Y)if(!FY(W.getSelectedFields(),w.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return W.addSetOperators(Y)}}var uf=()=>({union:pf,unionAll:df,intersect:of,intersectAll:lf,except:rf,exceptAll:nf}),pf=OU("union",!1),df=OU("union",!0),of=OU("intersect",!1),lf=OU("intersect",!0),rf=OU("except",!1),nf=OU("except",!0);class JY{static[M]="PgQueryBuilder";dialect;dialectConfig;constructor($){this.dialect=j($,pW)?$:void 0,this.dialectConfig=j($,pW)?void 0:$}$with=($,T)=>{let W=this;return{as:(X)=>{if(typeof X==="function")X=X(W);return new Proxy(new wY(X.getSQL(),T??("getSelectedFields"in X?X.getSelectedFields()??{}:{}),$,!0),new E4({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...$){let T=this;function W(Y){return new v6({fields:Y??void 0,session:void 0,dialect:T.getDialect(),withList:$})}function U(Y){return new v6({fields:Y??void 0,session:void 0,dialect:T.getDialect(),distinct:!0})}function X(Y,w){return new v6({fields:w??void 0,session:void 0,dialect:T.getDialect(),distinct:{on:Y}})}return{select:W,selectDistinct:U,selectDistinctOn:X}}select($){return new v6({fields:$??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct($){return new v6({fields:$??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn($,T){return new v6({fields:T??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:$}})}getDialect(){if(!this.dialect)this.dialect=new pW(this.dialectConfig);return this.dialect}}function g1($){if(j($,B4))return[$[yW]?`${$[yW]}.${$[p.Symbol.BaseName]}`:$[p.Symbol.BaseName]];if(j($,A4))return $._.usedTables??[];if(j($,i))return $.usedTables??[];return[]}class zz extends k6{constructor($,T,W,U){super();this.session=T,this.dialect=W,this.config={table:$,withList:U}}static[M]="PgDelete";config;cacheConfig;where($){return this.config.where=$,this}returning($=this.config.table[p.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=J1($),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return p$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0,void 0,{type:"delete",tables:g1(this.config.table)},this.cacheConfig)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return p$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new E4({alias:m4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class Hz{constructor($,T,W,U,X){this.table=$,this.session=T,this.dialect=W,this.withList=U,this.overridingSystemValue_=X}static[M]="PgInsertBuilder";authToken;setToken($){return this.authToken=$,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values($){if($=Array.isArray($)?$:[$],$.length===0)throw new Error("values() must be called with at least one value");let T=$.map((W)=>{let U={},X=this.table[p.Symbol.Columns];for(let Y of Object.keys(W)){let w=W[Y];U[Y]=j(w,i)?w:new F1(w,X[Y])}return U});return new dQ(this.table,T,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select($){let T=typeof $==="function"?$(new JY):$;if(!j(T,i)&&!FY(this.table[x9],T._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new dQ(this.table,T,this.session,this.dialect,this.withList,!0)}}class dQ extends k6{constructor($,T,W,U,X,Y,w){super();this.session=W,this.dialect=U,this.config={table:$,values:T,withList:X,select:Y,overridingSystemValue_:w}}static[M]="PgInsert";config;cacheConfig;returning($=this.config.table[p.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=J1($),this}onConflictDoNothing($={}){if($.target===void 0)this.config.onConflict=L`do nothing`;else{let T="";T=Array.isArray($.target)?$.target.map((U)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(U))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target));let W=$.where?L` where ${$.where}`:void 0;this.config.onConflict=L`(${L.raw(T)})${W} do nothing`}return this}onConflictDoUpdate($){if($.where&&($.targetWhere||$.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let T=$.where?L` where ${$.where}`:void 0,W=$.targetWhere?L` where ${$.targetWhere}`:void 0,U=$.setWhere?L` where ${$.setWhere}`:void 0,X=this.dialect.buildUpdateSet(this.config.table,y9(this.config.table,$.set)),Y="";return Y=Array.isArray($.target)?$.target.map((w)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(w))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target)),this.config.onConflict=L`(${L.raw(Y)})${W} do update set ${X}${T}${U}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return p$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0,void 0,{type:"insert",tables:g1(this.config.table)},this.cacheConfig)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return p$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new E4({alias:m4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class oQ extends k6{constructor($,T,W){super();this.session=T,this.dialect=W,this.config={view:$}}static[M]="PgRefreshMaterializedView";config;concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return p$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return p$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}class Fz{constructor($,T,W,U){this.table=$,this.session=T,this.dialect=W,this.withList=U}static[M]="PgUpdateBuilder";authToken;setToken($){return this.authToken=$,this}set($){return new l_(this.table,y9(this.table,$),this.session,this.dialect,this.withList).setToken(this.authToken)}}class l_ extends k6{constructor($,T,W,U,X){super();this.session=W,this.dialect=U,this.config={set:T,table:$,withList:X,joins:[]},this.tableName=d0($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[M]="PgUpdate";config;tableName;joinsNotNullableMap;cacheConfig;from($){let T=$,W=d0(T);if(typeof W==="string")this.joinsNotNullableMap[W]=!0;return this.config.from=T,this}getTableLikeFields($){if(j($,B4))return $[p.Symbol.Columns];else if(j($,A4))return $._.selectedFields;return $[i$].selectedFields}createJoin($){return(T,W)=>{let U=d0(T);if(typeof U==="string"&&this.config.joins.some((X)=>X.alias===U))throw new Error(`Alias "${U}" is already used in this query`);if(typeof W==="function"){let X=this.config.from&&!j(this.config.from,i)?this.getTableLikeFields(this.config.from):void 0;W=W(new Proxy(this.config.table[p.Symbol.Columns],new E4({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),X&&new Proxy(X,new E4({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:W,table:T,joinType:$,alias:U}),typeof U==="string")switch($){case"left":{this.joinsNotNullableMap[U]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([X])=>[X,!1])),this.joinsNotNullableMap[U]=!0;break}case"inner":{this.joinsNotNullableMap[U]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([X])=>[X,!1])),this.joinsNotNullableMap[U]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where($){return this.config.where=$,this}returning($){if(!$){if($=Object.assign({},this.config.table[p.Symbol.Columns]),this.config.from){let T=d0(this.config.from);if(typeof T==="string"&&this.config.from&&!j(this.config.from,i)){let W=this.getTableLikeFields(this.config.from);$[T]=W}for(let W of this.config.joins){let U=d0(W.table);if(typeof U==="string"&&!j(W.table,i)){let X=this.getTableLikeFields(W.table);$[U]=X}}}}return this.config.returningFields=$,this.config.returning=J1($),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){let T=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0,void 0,{type:"insert",tables:g1(this.config.table)},this.cacheConfig);return T.joinsNotNullableMap=this.joinsNotNullableMap,T}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return this._prepare().execute($,this.authToken)};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new E4({alias:m4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class _Y extends i{constructor($){super(_Y.buildEmbeddedCount($.source,$.filters).queryChunks);this.params=$,this.mapWith(Number),this.session=$.session,this.sql=_Y.buildCount($.source,$.filters)}sql;token;static[M]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount($,T){return L`(select count(*) from ${$}${L.raw(" where ").if(T)}${T})`}static buildCount($,T){return L`select count(*) as count from ${$}${L.raw(" where ").if(T)}${T};`}setToken($){return this.token=$,this}then($,T){return Promise.resolve(this.session.count(this.sql,this.token)).then($,T)}catch($){return this.then(void 0,$)}finally($){return this.then((T)=>{return $?.(),T},(T)=>{throw $?.(),T})}}class rQ{constructor($,T,W,U,X,Y,w){this.fullSchema=$,this.schema=T,this.tableNamesMap=W,this.table=U,this.tableConfig=X,this.dialect=Y,this.session=w}static[M]="PgRelationalQueryBuilder";findMany($){return new lQ(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?$:{},"many")}findFirst($){return new lQ(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?{...$,limit:1}:{limit:1},"first")}}class lQ extends k6{constructor($,T,W,U,X,Y,w,G,H){super();this.fullSchema=$,this.schema=T,this.tableNamesMap=W,this.table=U,this.tableConfig=X,this.dialect=Y,this.session=w,this.config=G,this.mode=H}static[M]="PgRelationalQuery";_prepare($){return p$.startActiveSpan("drizzle.prepareQuery",()=>{let{query:T,builtQuery:W}=this._toSQL();return this.session.prepareQuery(W,void 0,$,!0,(U,X)=>{let Y=U.map((w)=>i9(this.schema,this.tableConfig,w,T.selection,X));if(this.mode==="first")return Y[0];return Y})})}prepare($){return this._prepare($)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let $=this._getQuery(),T=this.dialect.sqlToQuery($.sql);return{query:$,builtQuery:T}}toSQL(){return this._toSQL().builtQuery}authToken;setToken($){return this.authToken=$,this}execute(){return p$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class nQ extends k6{constructor($,T,W,U){super();this.execute=$,this.sql=T,this.query=W,this.mapBatchResult=U}static[M]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult($,T){return T?this.mapBatchResult($):$}_prepare(){return this}isResponseInArrayMode(){return!1}}class RY{constructor($,T,W){if(this.dialect=$,this.session=T,this._=W?{schema:W.schema,fullSchema:W.fullSchema,tableNamesMap:W.tableNamesMap,session:T}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:T},this.query={},this._.schema)for(let[U,X]of Object.entries(this._.schema))this.query[U]=new rQ(W.fullSchema,this._.schema,this._.tableNamesMap,W.fullSchema[U],X,$,T);this.$cache={invalidate:async(U)=>{}}}static[M]="PgDatabase";query;$with=($,T)=>{let W=this;return{as:(X)=>{if(typeof X==="function")X=X(new JY(W.dialect));return new Proxy(new wY(X.getSQL(),T??("getSelectedFields"in X?X.getSelectedFields()??{}:{}),$,!0),new E4({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count($,T){return new _Y({source:$,filters:T,session:this.session})}$cache;with(...$){let T=this;function W(H){return new v6({fields:H??void 0,session:T.session,dialect:T.dialect,withList:$})}function U(H){return new v6({fields:H??void 0,session:T.session,dialect:T.dialect,withList:$,distinct:!0})}function X(H,z){return new v6({fields:z??void 0,session:T.session,dialect:T.dialect,withList:$,distinct:{on:H}})}function Y(H){return new Fz(H,T.session,T.dialect,$)}function w(H){return new Hz(H,T.session,T.dialect,$)}function G(H){return new zz(H,T.session,T.dialect,$)}return{select:W,selectDistinct:U,selectDistinctOn:X,update:Y,insert:w,delete:G}}select($){return new v6({fields:$??void 0,session:this.session,dialect:this.dialect})}selectDistinct($){return new v6({fields:$??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn($,T){return new v6({fields:T??void 0,session:this.session,dialect:this.dialect,distinct:{on:$}})}update($){return new Fz($,this.session,this.dialect)}insert($){return new Hz($,this.session,this.dialect)}delete($){return new zz($,this.session,this.dialect)}refreshMaterializedView($){return new oQ($,this.session,this.dialect)}authToken;execute($){let T=typeof $==="string"?L.raw($):$.getSQL(),W=this.dialect.sqlToQuery(T),U=this.session.prepareQuery(W,void 0,void 0,!1);return new nQ(()=>U.execute(void 0,this.authToken),T,W,(X)=>U.mapResult(X,!0))}transaction($,T){return this.session.transaction($,T)}}class r_{static[M]="Cache"}class kY extends r_{strategy(){return"all"}static[M]="NoopCache";async get($){return}async put($,T,W,U){}async onMutate($){}}async function iQ($,T){let W=`${$}-${JSON.stringify(T)}`,X=new TextEncoder().encode(W),Y=await crypto.subtle.digest("SHA-256",X);return[...new Uint8Array(Y)].map((H)=>H.toString(16).padStart(2,"0")).join("")}class l0 extends Error{constructor($,T,W){super(`Failed query: ${$}
|
|
108
|
+
params: ${T}`);if(this.query=$,this.params=T,this.cause=W,Error.captureStackTrace(this,l0),W)this.cause=W}}class tQ{constructor($,T,W,U){if(this.query=$,this.cache=T,this.queryMetadata=W,this.cacheConfig=U,T&&T.strategy()==="all"&&U===void 0)this.cacheConfig={enable:!0,autoInvalidate:!0};if(!this.cacheConfig?.enable)this.cacheConfig=void 0}authToken;getQuery(){return this.query}mapResult($,T){return $}setToken($){return this.authToken=$,this}static[M]="PgPreparedQuery";joinsNotNullableMap;async queryWithCache($,T,W){if(this.cache===void 0||j(this.cache,kY)||this.queryMetadata===void 0)try{return await W()}catch(U){throw new l0($,T,U)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await W()}catch(U){throw new l0($,T,U)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[U]=await Promise.all([W(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return U}catch(U){throw new l0($,T,U)}if(!this.cacheConfig)try{return await W()}catch(U){throw new l0($,T,U)}if(this.queryMetadata.type==="select"){let U=await this.cache.get(this.cacheConfig.tag??await iQ($,T),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(U===void 0){let X;try{X=await W()}catch(Y){throw new l0($,T,Y)}return await this.cache.put(this.cacheConfig.tag??await iQ($,T),X,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),X}return U}try{return await W()}catch(U){throw new l0($,T,U)}}}class aQ{constructor($){this.dialect=$}static[M]="PgSession";execute($,T){return p$.startActiveSpan("drizzle.operation",()=>{return p$.startActiveSpan("drizzle.prepareQuery",()=>{return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1)}).setToken(T).execute(void 0,T)})}all($){return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1).all()}async count($,T){let W=await this.execute($,T);return Number(W[0].count)}}class sQ extends RY{constructor($,T,W,U=0){super($,T,W);this.schema=W,this.nestedIndex=U}static[M]="PgTransaction";rollback(){throw new KQ}getTransactionConfigSQL($){let T=[];if($.isolationLevel)T.push(`isolation level ${$.isolationLevel}`);if($.accessMode)T.push($.accessMode);if(typeof $.deferrable==="boolean")T.push($.deferrable?"deferrable":"not deferrable");return L.raw(T.join(" "))}setTransaction($){return this.session.execute(L`set transaction ${this.getTransactionConfigSQL($)}`)}}class n_ extends tQ{constructor($,T,W,U,X,Y,w,G,H,z){super({sql:T,params:W},X,Y,w);this.client=$,this.queryString=T,this.params=W,this.logger=U,this.fields=G,this._isResponseInArrayMode=H,this.customResultMapper=z}static[M]="PostgresJsPreparedQuery";async execute($={}){return p$.startActiveSpan("drizzle.execute",async(T)=>{let W=DQ(this.params,$);T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.logger.logQuery(this.queryString,W);let{fields:U,queryString:X,client:Y,joinsNotNullableMap:w,customResultMapper:G}=this;if(!U&&!G)return p$.startActiveSpan("drizzle.driver.execute",()=>{return this.queryWithCache(X,W,async()=>{return await Y.unsafe(X,W)})});let H=await p$.startActiveSpan("drizzle.driver.execute",()=>{return T?.setAttributes({"drizzle.query.text":X,"drizzle.query.params":JSON.stringify(W)}),this.queryWithCache(X,W,async()=>{return await Y.unsafe(X,W).values()})});return p$.startActiveSpan("drizzle.mapResponse",()=>{return G?G(H):H.map((z)=>iN(U,z,w))})})}all($={}){return p$.startActiveSpan("drizzle.execute",async(T)=>{let W=DQ(this.params,$);return T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.logger.logQuery(this.queryString,W),p$.startActiveSpan("drizzle.driver.execute",()=>{return T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.queryWithCache(this.queryString,W,async()=>{return this.client.unsafe(this.queryString,W)})})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class vY extends aQ{constructor($,T,W,U={}){super(T);this.client=$,this.schema=W,this.options=U,this.logger=U.logger??new AQ,this.cache=U.cache??new kY}static[M]="PostgresJsSession";logger;cache;prepareQuery($,T,W,U,X,Y,w){return new n_(this.client,$.sql,$.params,this.logger,this.cache,Y,w,T,U,X)}query($,T){return this.logger.logQuery($,T),this.client.unsafe($,T).values()}queryObjects($,T){return this.client.unsafe($,T)}transaction($,T){return this.client.begin(async(W)=>{let U=new vY(W,this.dialect,this.schema,this.options),X=new eQ(this.dialect,U,this.schema);if(T)await X.setTransaction(T);return $(X)})}}class eQ extends sQ{constructor($,T,W,U=0){super($,T,W,U);this.session=T}static[M]="PostgresJsTransaction";transaction($){return this.session.client.savepoint((T)=>{let W=new vY(T,this.dialect,this.schema,this.session.options),U=new eQ(this.dialect,W,this.schema);return $(U)})}}class i_ extends RY{static[M]="PostgresJsDatabase"}function QU($,T={}){let W=(H)=>H;for(let H of["1184","1082","1083","1114","1182","1185","1115","1231"])$.options.parsers[H]=W,$.options.serializers[H]=W;$.options.serializers["114"]=W,$.options.serializers["3802"]=W;let U=new pW({casing:T.casing}),X;if(T.logger===!0)X=new EQ;else if(T.logger!==!1)X=T.logger;let Y;if(T.schema){let H=N_(T.schema,J_);Y={fullSchema:T.schema,schema:H.tables,tableNamesMap:H.tableNamesMap}}let w=new vY($,U,Y,{logger:X,cache:T.cache}),G=new i_(U,w,Y);if(G.$client=$,G.$cache=T.cache,G.$cache)G.$cache.invalidate=T.cache?.onMutate;return G}function Oz(...$){if(typeof $[0]==="string"){let T=FU($[0]);return QU(T,$[1])}if(sN($[0])){let{connection:T,client:W,...U}=$[0];if(W)return QU(W,U);if(typeof T==="object"&&T.url!==void 0){let{url:Y,...w}=T,G=FU(Y,w);return QU(G,U)}let X=FU(T);return QU(X,U)}return QU($[0],$[1])}(($)=>{function T(W){return QU({options:{parsers:{},serializers:{}}},W)}$.mock=T})(Oz||(Oz={}));function t_($,T){if($ instanceof Promise)throw new Error(T)}function tf($,T){let W={},U=[];for(let X in $){let Y=$[X]["~standard"].validate(T[X]);if(t_(Y,`Validation must be synchronous, but ${X} returned a Promise.`),Y.issues){U.push(...Y.issues.map((w)=>({...w,message:w.message,path:[X,...w.path??[]]})));continue}W[X]=Y.value}if(U.length)return{issues:U};return{value:W}}function $Z($){let T=$.runtimeEnvStrict??$.runtimeEnv??process.env;if($.emptyStringAsUndefined??!1){for(let[_,R]of Object.entries(T))if(R==="")delete T[_]}if(!!$.skipValidation)return T;let X=typeof $.client==="object"?$.client:{},Y=typeof $.server==="object"?$.server:{},w=typeof $.shared==="object"?$.shared:{},G=$.isServer??(typeof window==="undefined"||("Deno"in window)),H=G?{...Y,...w,...X}:{...X,...w},z=$.createFinalSchema?.(H,G)["~standard"].validate(T)??tf(H,T);t_(z,"Validation must be synchronous");let F=$.onValidationError??((_)=>{throw console.error("\u274C Invalid environment variables:",_),new Error("Invalid environment variables")}),O=$.onInvalidAccess??(()=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")});if(z.issues)return F(z.issues);let Q=(_)=>{if(!$.clientPrefix)return!0;return!_.startsWith($.clientPrefix)&&!(_ in w)},Z=(_)=>{return G||!Q(_)},V=(_)=>{return _==="__esModule"||_==="$$typeof"},E=($.extends??[]).reduce((_,R)=>{return Object.assign(_,R)},{}),N=Object.assign(E,z.value);return new Proxy(N,{get(_,R){if(typeof R!=="string")return;if(V(R))return;if(!Z(R))return O(R);return Reflect.get(_,R)}})}var yT=($)=>Array.isArray($)?$:[$],a_=($,T)=>{let W=[[],[]];for(let U of $)if(T(U))W[0].push(U);else W[1].push(U);return W},Qz=Array,r0=($,T)=>$.includes(T),s_=($,T=0)=>[...new Array($)].map((W,U)=>U+T),q$=($,T,W)=>{if($===void 0)return T===void 0?[]:Array.isArray(T)?T:[T];if(W?.prepend)if(Array.isArray(T))$.unshift(...T);else $.unshift(T);else if(Array.isArray(T))$.push(...T);else $.push(T);return $},n0=($,T)=>{if(T===void 0||T===null)return $??[];if($===void 0||$===null)return yT(T);return $.concat(T)},e_=(...$)=>$.reduce(n0,[]),F0=($,T,W)=>{if($===void 0)return Array.isArray(T)?T:[T];let U=W?.isEqual??((X,Y)=>X===Y);for(let X of yT(T))if(!$.some((Y)=>U(Y,X)))$.push(X);return $},$R=($,T)=>$.reduce((W,U)=>{let X=U[T];return W[X]=q$(W[X],U),W},{}),i0=($,T,W)=>$.length===T.length&&$.every(W?.isEqual?(U,X)=>W.isEqual(U,T[X]):(U,X)=>U===T[X]);var p6=($,T)=>x4($)===T,x4=($)=>{let T=typeof $;return T==="object"?$===null?"null":"object":T==="function"?"object":T},d6={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},TR={...d6,function:"a function"};class WR extends Error{}var S$=($)=>dW($,WR),dW=($,T=Error)=>{throw new T($)};class qY extends Error{name="ParseError"}var B=($)=>dW($,qY),m1=($)=>` ${$}`;var K$=($,T)=>{let W={},U=Array.isArray($),X=!1;for(let[Y,w]of Object.entries($).entries()){let G=U?T(Y,w[1]):T(...w,Y);X||=typeof G[0]==="number";let H=Array.isArray(G[0])||G.length===0?G:[G];for(let[z,F]of H)if(typeof z==="object")W[z.group]=q$(W[z.group],F);else W[z]=F}return X?Object.values(W):W};var TZ=Object.entries;var I4=($,T)=>($ in T),ZU=($,T)=>(T in $);class WZ{constructor($){Object.assign(this,$)}}var UR=class{};class PY extends UR{}var af=($,T)=>{let W={},U={},X;for(X in $)if(X in T)W[X]=$[X];else U[X]=$[X];return[W,U]};var XR=($,T)=>af($,T)[1],O0=($)=>Object.keys($).length===0,oW=($)=>[...Object.entries($),...Object.getOwnPropertySymbols($).map((T)=>[T,$[T]])],YR=($,T)=>Object.defineProperties($,Object.getOwnPropertyDescriptors(T)),wR=($)=>{let T=Object.keys($).sort(),W={};for(let U=0;U<T.length;U++)W[T[U]]=$[T[U]];return W};var Q1=m1("represents an uninitialized value"),GR=($)=>Object.values($).filter((T)=>{if(typeof T==="number")return!0;return typeof $[T]!=="number"});var UZ={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},XZ=globalThis.File??Blob,YZ={ArrayBuffer,Blob,File:XZ,FormData,Headers,Request,Response,URL},sf={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},lW={...UZ,...YZ,...sf,String,Number,Boolean},CY=($)=>{let T=Object.getPrototypeOf($);while(T?.constructor&&(!I4(T.constructor.name,lW)||!($ instanceof lW[T.constructor.name])))T=Object.getPrototypeOf(T);let W=T?.constructor?.name;if(W===void 0||W==="Object")return;return W},SY=($)=>typeof $==="object"&&$!==null?CY($)??"object":x4($);var d$=Array.isArray,ef={Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},$y={ArrayBuffer:"an ArrayBuffer instance",Blob:"a Blob instance",File:"a File instance",FormData:"a FormData instance",Headers:"a Headers instance",Request:"a Request instance",Response:"a Response instance",URL:"a URL instance"},Ty={Int8Array:"an Int8Array",Uint8Array:"a Uint8Array",Uint8ClampedArray:"a Uint8ClampedArray",Int16Array:"an Int16Array",Uint16Array:"a Uint16Array",Int32Array:"an Int32Array",Uint32Array:"a Uint32Array",Float32Array:"a Float32Array",Float64Array:"a Float64Array",BigInt64Array:"a BigInt64Array",BigUint64Array:"a BigUint64Array"},zR={...ef,...$y,...Ty},jY=($)=>{let T=Object($).name??null;return T&&I4(T,lW)&&lW[T]===$?T:null};var wZ=($,T)=>{let W=$.prototype;while(W!==null){if(W===T.prototype)return!0;W=Object.getPrototypeOf(W)}return!1};var HR=($)=>FR($,new Map),FR=($,T)=>{if(typeof $!=="object"||$===null)return $;if(T?.has($))return T.get($);let W=jY($.constructor);if(W==="Date")return new Date($.getTime());if(W&&W!=="Array")return $;let U=Array.isArray($)?$.slice():Object.create(Object.getPrototypeOf($)),X=Object.getOwnPropertyDescriptors($);if(T){T.set($,U);for(let Y in X){let w=X[Y];if("get"in w||"set"in w)continue;w.value=FR(w.value,T)}}return Object.defineProperties(U,X),U};var Wy=($)=>{let T=Q1;return()=>T===Q1?T=$():T},hT=($)=>typeof $==="function"&&$.length===0;var OR=class extends Function{constructor(...$){let T=$.slice(0,-1),W=$.at(-1);try{super(...T,W)}catch(U){return S$(`Encountered an unexpected error while compiling your definition:
|
|
109
|
+
Message: ${U}
|
|
109
110
|
Source: (${$.slice(0,-1)}) => {
|
|
110
111
|
${$.at(-1)}
|
|
111
|
-
}`)}}};class
|
|
112
|
-
`)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},
|
|
113
|
-
`+
|
|
114
|
-
${
|
|
115
|
-
${W}]`:`[${
|
|
116
|
-
${
|
|
112
|
+
}`)}}};class c1{constructor($,...[T]){return Object.assign(Object.setPrototypeOf($.bind(T?.bind??this),this.constructor.prototype),T?.attach)}}var QR=Wy(()=>{try{return new Function("return false")()}catch{return!0}});var SW$=m1("brand");var ZR=m1("arkInferred");var xW$=m1("args");class U6{constructor(){}}var Uy=()=>{try{return((new Error().stack?.split(`
|
|
113
|
+
`)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},Xy=globalThis.process?.env??{},DR={fileName:Uy,env:Xy};var VR=($)=>$[0].toUpperCase()+$.slice(1);var GZ=($)=>new RegExp(Yy($),typeof $==="string"?"":$.flags);var Yy=($)=>{return`^(?:${typeof $==="string"?$:$.source})$`};var t0={negativeLookahead:($)=>`(?!${$})`,nonCapturingGroup:($)=>`(?:${$})`},BY="\\",gT={" ":1,"\n":1,"\t":1};var wy=/^-0\.?0*$/.source,ER=/[1-9]\d*/.source,Gy=/\.\d+/.source,zy=/\.\d*[1-9]/.source,AR=($)=>GZ(t0.negativeLookahead(wy)+t0.nonCapturingGroup("-?"+t0.nonCapturingGroup(t0.nonCapturingGroup("0|"+ER)+t0.nonCapturingGroup($.decimalPattern)+"?")+($.allowDecimalOnly?"|"+$.decimalPattern:"")+"?")),KR=AR({decimalPattern:zy,allowDecimalOnly:!1}),Hy=KR.test.bind(KR),Zz=AR({decimalPattern:Gy,allowDecimalOnly:!0}),mW$=Zz.test.bind(Zz),Fy=/^-?\d*\.?\d*$/,Oy=($)=>$.length!==0&&Fy.test($),xY=GZ(t0.negativeLookahead("^-0$")+"-?"+t0.nonCapturingGroup(t0.nonCapturingGroup("0|"+ER))),Qy=xY.test.bind(xY),zZ=/^-?\d+$/,Zy=zZ.test.bind(zZ),MR={number:"a number",bigint:"a bigint",integer:"an integer"},NR=($,T)=>`'${$}' was parsed as ${MR[T]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,Dy=($,T)=>T==="number"?Hy($):Qy($),Vy=($,T)=>T==="number"?Number($):Number.parseInt($),Ky=($,T)=>T==="number"?Oy($):Zy($),LR=($,T)=>HZ($,"number",T),JR=($,T)=>HZ($,"number",{...T,strict:!0}),_R=($,T)=>HZ($,"integer",T),HZ=($,T,W)=>{let U=Vy($,T);if(!Number.isNaN(U)){if(Ky($,T)){if(W?.strict)return Dy($,T)?U:B(NR($,T));return U}}return W?.errorOnFail?B(W?.errorOnFail===!0?`Failed to parse ${MR[T]} from '${$}'`:W?.errorOnFail):void 0},RR=($)=>{if($[$.length-1]!=="n")return;let T=$.slice(0,-1),W;try{W=BigInt(T)}catch{return}if(xY.test(T))return W;if(zZ.test(T))return B(NR($,"bigint"))};var Ey="0.46.0",Ay={version:Ey,filename:DR.fileName(),FileConstructor:XZ},rW=Ay,kR=new Map,FZ=Object.create(null),IY=($)=>{let T=kR.get($);if(T)return T;let W=My($);if(FZ[W])W=`${W}${FZ[W]++}`;else FZ[W]=1;return rW[W]=$,kR.set($,W),W},mT=($)=>/^[$A-Z_a-z][\w$]*$/.test($),My=($)=>{switch(typeof $){case"object":{if($===null)break;let T=CY($)??"object";return T[0].toLowerCase()+T.slice(1)}case"function":return mT($.name)?$.name:"fn";case"symbol":return $.description&&mT($.description)?$.description:"symbol"}return S$(`Unexpected attempt to register serializable value of type ${x4($)}`)};var bY=($)=>typeof $==="string"?JSON.stringify($):typeof $==="bigint"?`${$}n`:`${$}`;var vR=($,T={})=>fY($,{onUndefined:"$ark.undefined",onBigInt:(W)=>`$ark.bigint-${W}`,...T},[]);var E$=($,T)=>{switch(x4($)){case"object":let W=$,U=W.constructor.name;return U==="Object"||U==="Array"?T?.quoteKeys===!1?Dz(W,T?.indent??0,""):JSON.stringify(fY(W,DU,[]),null,T?.indent):Dz(W,T?.indent??0,"");case"symbol":return DU.onSymbol($);default:return bY($)}},Dz=($,T,W)=>{if(typeof $==="function")return DU.onFunction($);if(typeof $!=="object"||$===null)return bY($);let U=W+" ".repeat(T);if(Array.isArray($)){if($.length===0)return"[]";let Y=$.map((w)=>Dz(w,T,U)).join(`,
|
|
114
|
+
`+U);return T?`[
|
|
115
|
+
${U}${Y}
|
|
116
|
+
${W}]`:`[${Y}]`}let X=$.constructor.name;if(X==="Object"){let Y=oW($).map(([w,G])=>{let H=typeof w==="symbol"?DU.onSymbol(w):mT(w)?w:JSON.stringify(w),z=Dz(G,T,U);return`${U}${H}: ${z}`});if(Y.length===0)return"{}";return T?`{
|
|
117
|
+
${Y.join(`,
|
|
117
118
|
`)}
|
|
118
|
-
${W}}`:`{${
|
|
119
|
+
${W}}`:`{${Y.join(", ")}}`}if($ instanceof Date)return nW($);if("expression"in $&&typeof $.expression==="string")return $.expression;return X},DU={onCycle:()=>"(cycle)",onSymbol:($)=>`Symbol(${IY($)})`,onFunction:($)=>`Function(${IY($)})`},fY=($,T,W)=>{switch(x4($)){case"object":{let U=$;if("toJSON"in U&&typeof U.toJSON==="function")return U.toJSON();if(typeof U==="function")return DU.onFunction(U);if(W.includes(U))return"(cycle)";let X=[...W,U];if(Array.isArray(U))return U.map((w)=>fY(w,T,X));if(U instanceof Date)return U.toDateString();let Y={};for(let w in U)Y[w]=fY(U[w],T,X);for(let w of Object.getOwnPropertySymbols(U))Y[T.onSymbol?.(w)??w.toString()]=fY(U[w],T,X);return Y}case"symbol":return DU.onSymbol($);case"bigint":return T.onBigInt?.($)??`${$}n`;case"undefined":return T.onUndefined??"undefined";case"string":return $.replaceAll("\\","\\\\");default:return $}},nW=($)=>{let T=$.getFullYear(),W=$.getMonth(),U=$.getDate(),X=$.getHours(),Y=$.getMinutes(),w=$.getSeconds(),G=$.getMilliseconds();if(W===0&&U===1&&X===0&&Y===0&&w===0&&G===0)return`${T}`;let H=`${Ny[W]} ${U}, ${T}`;if(X===0&&Y===0&&w===0&&G===0)return H;let z=$.toLocaleTimeString(),F=z.endsWith(" AM")||z.endsWith(" PM")?z.slice(-3):"";if(F)z=z.slice(0,-F.length);if(G)z+=`.${Jy(G,3)}`;else if(Ly.test(z))z=z.slice(0,-3);return`${z+F}, ${H}`},Ny=["January","February","March","April","May","June","July","August","September","October","November","December"],Ly=/:\d\d:00$/,Jy=($,T)=>String($).padStart(T,"0");var qR=($,T,...[W])=>{let U=W?.stringifySymbol??E$,X=$;switch(typeof T){case"string":X=mT(T)?$===""?T:`${$}.${T}`:`${$}[${JSON.stringify(T)}]`;break;case"number":X=`${$}[${T}]`;break;case"symbol":X=`${$}[${U(T)}]`;break;default:if(W?.stringifyNonKey)X=`${$}[${W.stringifyNonKey(T)}]`;else B(`${E$(T)} must be a PropertyKey or stringifyNonKey must be passed to options`)}return X},a0=($,...T)=>$.reduce((W,U)=>qR(W,U,...T),"");class yY extends Qz{cache={};constructor(...$){super();this.push(...$)}toJSON(){if(this.cache.json)return this.cache.json;this.cache.json=[];for(let $=0;$<this.length;$++)this.cache.json.push(typeof this[$]==="symbol"?E$(this[$]):this[$]);return this.cache.json}stringify(){if(this.cache.stringify)return this.cache.stringify;return this.cache.stringify=a0(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let $="",T=[$];for(let W of this)$=qR($,W),T.push($);return this.cache.stringifyAncestors=T}}class OZ{chars;i;def;constructor($){this.def=$,this.chars=[...$],this.i=0}shift(){return this.chars[this.i++]??""}get lookahead(){return this.chars[this.i]??""}get nextLookahead(){return this.chars[this.i+1]??""}get length(){return this.chars.length}shiftUntil($){let T="";while(this.lookahead){if($(this,T))if(T[T.length-1]===BY)T=T.slice(0,-1);else break;T+=this.shift()}return T}shiftUntilLookahead($){return typeof $==="string"?this.shiftUntil((T)=>T.lookahead===$):this.shiftUntil((T)=>(T.lookahead in $))}shiftUntilNonWhitespace(){return this.shiftUntil(()=>!(this.lookahead in gT))}jumpToIndex($){this.i=$<0?this.length+$:$}jumpForward($){this.i+=$}get location(){return this.i}get unscanned(){return this.chars.slice(this.i,this.length).join("")}get scanned(){return this.chars.slice(0,this.i).join("")}sliceChars($,T){return this.chars.slice($,T).join("")}lookaheadIs($){return this.lookahead===$}lookaheadIsIn($){return this.lookahead in $}}var O2$=m1("implementedTraits");var QZ="$ark",_y=2;while(QZ in globalThis)QZ=`$ark${_y++}`;var PR=QZ;globalThis[PR]=rW;var b=rW,Ry=($)=>`${PR}.${$}`,Z4=($)=>Ry(IY($));class Vz extends PY{argNames;body="";constructor(...$){super();this.argNames=$;for(let T of $){if(T in this)throw new Error(`Arg name '${T}' would overwrite an existing property on FunctionBody`);this[T]=T}}indentation=0;indent(){return this.indentation+=4,this}dedent(){return this.indentation-=4,this}prop($,T=!1){return ZZ($,T)}index($,T=!1){return CR(`${$}`,T)}line($){return this.body+=`${" ".repeat(this.indentation)}${$}
|
|
119
120
|
`,this}const($,T){return this.line(`const ${$} = ${T}`),this}let($,T){return this.line(`let ${$} = ${T}`)}set($,T){return this.line(`${$} = ${T}`)}if($,T){return this.block(`if (${$})`,T)}elseIf($,T){return this.block(`else if (${$})`,T)}else($){return this.block("else",$)}for($,T,W=0){return this.block(`for (let i = ${W}; ${$}; i++)`,T)}forIn($,T){return this.block(`for (const k in ${$})`,T)}block($,T,W=""){return this.line(`${$} {`),this.indent(),T(this),this.dedent(),this.line(`}${W}`)}return($=""){return this.line(`return ${$}`)}write($="anonymous",T=0){return`${$}(${this.argNames.join(", ")}) { ${T?this.body.split(`
|
|
120
121
|
`).map((W)=>" ".repeat(T)+`${W}`).join(`
|
|
121
|
-
`):this.body} }`}compile(){return new
|
|
122
|
-
`)}_add($){let T=this.byPath[$.propString];if(T){if(T.hasCode("union")&&T.errors.length===0)return;let W=$.hasCode("union")&&$.errors.length===0?$:new
|
|
123
|
-
`+$.map((T)=>` \u2022 ${
|
|
124
|
-
`));Object.defineProperty(this,"arkErrors",{value:$,enumerable:!1})}}var
|
|
122
|
+
`):this.body} }`}compile(){return new OR(...this.argNames,this.body)}}var s0=($)=>p6($,"object")||typeof $==="symbol"?Z4($):bY($),ZZ=($,T=!1)=>{if(typeof $==="string"&&mT($))return`${T?"?":""}.${$}`;return CR(ky($),T)},ky=($)=>typeof $==="symbol"?Z4($):JSON.stringify($),CR=($,T=!1)=>`${T?"?.":""}[${$}]`;class hY extends Vz{traversalKind;optimistic;constructor($){super("data","ctx");this.traversalKind=$.kind,this.optimistic=$.optimistic===!0}invoke($,T){let W=T?.arg??this.data,U=typeof $==="string"?!0:this.requiresContextFor($),X=typeof $==="string"?$:$.id;if(U)return`${this.referenceToId(X,T)}(${W}, ${this.ctx})`;return`${this.referenceToId(X,T)}(${W})`}referenceToId($,T){let W=T?.kind??this.traversalKind,U=`this.${$}${W}`;return T?.bind?`${U}.bind(${T?.bind})`:U}requiresContextFor($){return this.traversalKind==="Apply"||$.allowsRequiresContext}initializeErrorCount(){return this.const("errorCount","ctx.currentErrorCount")}returnIfFail(){return this.if("ctx.currentErrorCount > errorCount",()=>this.return())}returnIfFailFast(){return this.if("ctx.failFast && ctx.currentErrorCount > errorCount",()=>this.return())}traverseKey($,T,W){let U=this.requiresContextFor(W);if(U)this.line(`${this.ctx}.path.push(${$})`);if(this.check(W,{arg:T}),U)this.line(`${this.ctx}.path.pop()`);return this}check($,T){return this.traversalKind==="Allows"?this.if(`!${this.invoke($,T)}`,()=>this.return(!1)):this.line(this.invoke($,T))}}var Kz=($)=>K$($,(T,W)=>[T,d$(W)?[...W]:W]),q6=m1("arkKind"),s=($,T)=>$?.[q6]===T,t$=($)=>s($,"root")||s($,"constraint");var SR=["unit","proto","domain"],VU=["required","optional","index","sequence"],DZ=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],Ez=[...DZ,...VU,"structure","predicate"],KU=["alias","union","morph","unit","intersection","proto","domain"],vy=[...KU,...Ez],Az=K$(Ez,($,T)=>[T,1]),jR=K$([...VU,"undeclared"],($,T)=>[T,1]),BR=K$(vy,($,T)=>[T,$]),EU=($)=>typeof $==="string"&&($ in BR);var AU=($)=>BR[$],Mz=($)=>KU.slice(AU($)+1),n2$=[...Mz("union"),"alias"],i2$=[...Mz("morph"),"alias"],k1=($)=>{if(typeof $==="string"||typeof $==="boolean"||$===null)return $;if(typeof $==="number"){if(Number.isNaN($))return"NaN";if($===Number.POSITIVE_INFINITY)return"Infinity";if($===Number.NEGATIVE_INFINITY)return"-Infinity";return $}return s0($)},cT=($)=>{let T="{ ";for(let[W,U]of Object.entries($))T+=`${W}: ${s0(U)}, `;return T+" }"},A$=($)=>{let T=$;if(T.hasAssociatedError)T.defaults.expected??=(W)=>("description"in W)?W.description:T.defaults.description(W),T.defaults.actual??=(W)=>E$(W),T.defaults.problem??=(W)=>`must be ${W.expected}${W.actual?` (was ${W.actual})`:""}`,T.defaults.message??=(W)=>{if(W.path.length===0)return W.problem;let U=`${W.propString} ${W.problem}`;if(U[0]==="[")return`value at ${U}`;return U};return T};class xR extends Error{name="ToJsonSchemaError";code;context;constructor($,T){super(E$(T,{quoteKeys:!1,indent:4}));this.code=$,this.context=T}hasCode($){return this.code===$}}var qy={dialect:"https://json-schema.org/draft/2020-12/schema",useRefs:!1,fallback:{arrayObject:($)=>U4.throw("arrayObject",$),arrayPostfix:($)=>U4.throw("arrayPostfix",$),defaultValue:($)=>U4.throw("defaultValue",$),domain:($)=>U4.throw("domain",$),morph:($)=>U4.throw("morph",$),patternIntersection:($)=>U4.throw("patternIntersection",$),predicate:($)=>U4.throw("predicate",$),proto:($)=>U4.throw("proto",$),symbolKey:($)=>U4.throw("symbolKey",$),unit:($)=>U4.throw("unit",$),date:($)=>U4.throw("date",$)}},U4={Error:xR,throw:(...$)=>{throw new U4.Error(...$)},throwInternalOperandError:($,T)=>S$(`Unexpected JSON Schema input for ${$}: ${E$(T)}`),defaultConfig:qy};b.config??={};var gY=($,T)=>{if(!T)return $;let W={...$},U;for(U in T){let X={...$.keywords};if(U==="keywords"){for(let Y in T[U]){let w=T.keywords[Y];if(w===void 0)continue;X[Y]=typeof w==="string"?{description:w}:w}W.keywords=X}else if(U==="toJsonSchema")W[U]=VZ($.toJsonSchema,T.toJsonSchema);else if(EU(U))W[U]={...$[U],...T[U]};else W[U]=T[U]}return W},VZ=($,T)=>{if(!$)return T??{};if(!T)return $;let W={...$},U;for(U in T)if(U==="fallback")W.fallback=Py($.fallback,T.fallback);else W[U]=T[U];return W},Py=($,T)=>{$=IR($),T=IR(T);let W={},U;for(U in U4.defaultConfig.fallback)W[U]=T[U]??T.default??$[U]??$.default??U4.defaultConfig.fallback[U];return W},IR=($)=>typeof $==="function"?{default:$}:$??{};class uT extends PY{[q6]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:$,relativePath:T,...W},U){super();this.input=W,this.ctx=U,YR(this,W);let X=U.data;if(W.code==="union")W.errors=W.errors.flatMap((w)=>{let G=w.hasCode("union")?w.errors:[w];if(!$&&!T)return G;return G.map((H)=>H.transform((z)=>({...z,path:e_($,z.path,T)})))});this.nodeConfig=U.config[this.code];let Y=[...W.path??U.path];if(T)Y.push(...T);if($)Y.unshift(...$);this.path=new yY(...Y),this.data="data"in W?W.data:X}transform($){return new uT($({data:this.data,path:this.path,...this.input}),this.ctx)}hasCode($){return this.code===$}get propString(){return a0(this.path)}get expected(){if(this.input.expected)return this.input.expected;let $=this.meta?.expected??this.nodeConfig.expected;return typeof $==="function"?$(this.input):$}get actual(){if(this.input.actual)return this.input.actual;let $=this.meta?.actual??this.nodeConfig.actual;return typeof $==="function"?$(this.data):$}get problem(){if(this.input.problem)return this.input.problem;let $=this.meta?.problem??this.nodeConfig.problem;return typeof $==="function"?$(this):$}get message(){if(this.input.message)return this.input.message;let $=this.meta?.message??this.nodeConfig.message;return typeof $==="function"?$(this):$}get flat(){return this.hasCode("intersection")?[...this.errors]:[this]}toJSON(){return{data:this.data,path:this.path,...this.input,expected:this.expected,actual:this.actual,problem:this.problem,message:this.message}}toString(){return this.message}throw(){throw this}}class o6 extends Qz{[q6]="errors";ctx;constructor($){super();this.ctx=$}byPath=Object.create(null);get flatByPath(){return K$(this.byPath,($,T)=>[$,T.flat])}get flatProblemsByPath(){return K$(this.byPath,($,T)=>[$,T.flat.map((W)=>W.problem)])}byAncestorPath=Object.create(null);count=0;mutable=this;throw(){throw this.toTraversalError()}toTraversalError(){return new KZ(this)}add($){if(this.includes($))return;this._add($)}transform($){let T=new o6(this.ctx);for(let W of this)T.add($(W));return T}merge($){for(let T of $){if(this.includes(T))continue;this._add(new uT({...T,path:[...this.ctx.path,...T.path]},this.ctx))}}affectsPath($){if(this.length===0)return!1;return $.stringifyAncestors().some((T)=>(T in this.byPath))||$.stringify()in this.byAncestorPath}get summary(){return this.toString()}get issues(){return this}toJSON(){return[...this.map(($)=>$.toJSON())]}toString(){return this.join(`
|
|
123
|
+
`)}_add($){let T=this.byPath[$.propString];if(T){if(T.hasCode("union")&&T.errors.length===0)return;let W=$.hasCode("union")&&$.errors.length===0?$:new uT({code:"intersection",errors:T.hasCode("intersection")?[...T.errors,$]:[T,$]},this.ctx),U=this.indexOf(T);this.mutable[U===-1?this.length:U]=W,this.byPath[$.propString]=W,this.addAncestorPaths($)}else this.byPath[$.propString]=$,this.addAncestorPaths($),this.mutable.push($);this.count++}addAncestorPaths($){for(let T of $.path.stringifyAncestors())this.byAncestorPath[T]=q$(this.byAncestorPath[T],$)}}class KZ extends Error{name="TraversalError";constructor($){if($.length===1)super($.summary);else super(`
|
|
124
|
+
`+$.map((T)=>` \u2022 ${Cy(T)}`).join(`
|
|
125
|
+
`));Object.defineProperty(this,"arkErrors",{value:$,enumerable:!1})}}var Cy=($)=>$.toString().split(`
|
|
125
126
|
`).join(`
|
|
126
|
-
`);class B6{path=[];errors=new p4(this);root;config;queuedMorphs=[];branches=[];seen={};constructor($,T){this.root=$,this.config=T}get data(){let $=this.root;for(let T of this.path)$=$?.[T];return $}get propString(){return H1(this.path)}reject($){return this.error($),!1}mustBe($){return this.error($),!1}error($){let T=typeof $==="object"?$.code?$:{...$,code:"predicate"}:{code:"predicate",expected:$};return this.errorFromContext(T)}hasError(){return this.currentErrorCount!==0}get currentBranch(){return this.branches.at(-1)}queueMorphs($){let T={path:new ZX(...this.path),morphs:$};if(this.currentBranch)this.currentBranch.queuedMorphs.push(T);else this.queuedMorphs.push(T)}finalize($){if(this.queuedMorphs.length){if(typeof this.root==="object"&&this.root!==null&&this.config.clone)this.root=this.config.clone(this.root);this.applyQueuedMorphs()}if(this.hasError())return $?$(this.errors):this.errors;return this.root}get currentErrorCount(){return this.currentBranch?this.currentBranch.error?1:0:this.errors.count}get failFast(){return this.branches.length!==0}pushBranch(){this.branches.push({error:void 0,queuedMorphs:[]})}popBranch(){return this.branches.pop()}get external(){return this}errorFromNodeContext($){return this.errorFromContext($)}errorFromContext($){let T=new o1($,this);if(this.currentBranch)this.currentBranch.error=T;else this.errors.add(T);return T}applyQueuedMorphs(){while(this.queuedMorphs.length){let $=this.queuedMorphs;this.queuedMorphs=[];for(let{path:T,morphs:W}of $){if(this.errors.affectsPath(T))continue;this.applyMorphsAtPath(T,W)}}}applyMorphsAtPath($,T){let W=$.at(-1),X;if(W!==void 0){X=this.root;for(let Y=0;Y<$.length-1;Y++)X=X[$[Y]]}this.path=[...$];for(let Y of T){let U=v$(Y),G=Y(X===void 0?this.root:X[W],this);if(G instanceof o1){this.errors.add(G);break}if(G instanceof p4){if(!U)this.errors.merge(G);break}if(X===void 0)this.root=G;else X[W]=G;this.applyQueuedMorphs()}}}var d4=($,T,W)=>{if(!W)return T();W.path.push($);let X=T();return W.path.pop(),X};class KX extends S6{attachments;$;onFail;includesTransform;includesContextualPredicate;isCyclic;allowsRequiresContext;rootApplyStrategy;contextFreeMorph;rootApply;referencesById;shallowReferences;flatRefs;flatMorphs;allows;get shallowMorphs(){return[]}constructor($,T){super((X,Y,U=this.onFail)=>{if(Y)return this.traverseApply(X,Y),Y.hasError()?Y.errors:Y.data;return this.rootApply(X,U)},{attach:$});this.attachments=$,this.$=T,this.onFail=this.meta.onFail??this.$.resolvedConfig.onFail,this.includesTransform=this.hasKind("morph")||this.hasKind("structure")&&this.structuralMorph!==void 0,this.includesContextualPredicate=this.hasKind("predicate")&&this.inner.predicate.length!==1,this.isCyclic=this.kind==="alias",this.referencesById={[this.id]:this},this.shallowReferences=this.hasKind("structure")?[this,...this.children]:this.children.reduce((X,Y)=>Cq(X,Y.shallowReferences),[this]);let W=this.isStructural();this.flatRefs=[],this.flatMorphs=[];for(let X=0;X<this.children.length;X++){if(this.includesTransform||=this.children[X].includesTransform,this.includesContextualPredicate||=this.children[X].includesContextualPredicate,this.isCyclic||=this.children[X].isCyclic,!W){let Y=this.children[X].flatRefs;for(let U=0;U<Y.length;U++){let G=Y[U];if(!this.flatRefs.some((J)=>xV(J,G))){this.flatRefs.push(G);for(let J of G.node.branches)if(J.hasKind("morph")||J.hasKind("intersection")&&J.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:G.path,propString:G.propString,node:J})}}}Object.assign(this.referencesById,this.children[X].referencesById)}this.flatRefs.sort((X,Y)=>X.path.length>Y.path.length?1:X.path.length<Y.path.length?-1:X.propString>Y.propString?1:X.propString<Y.propString?-1:X.node.expression<Y.node.expression?-1:1),this.allowsRequiresContext=this.includesContextualPredicate||this.isCyclic,this.rootApplyStrategy=!this.allowsRequiresContext&&this.flatMorphs.length===0?this.shallowMorphs.length===0?"allows":this.shallowMorphs.every((X)=>X.length===1||X.name==="$arkStructuralMorph")?this.hasKind("union")?this.branches.some((X)=>X.shallowMorphs.length>1)?"contextual":"branchedOptimistic":this.shallowMorphs.length>1?"contextual":"optimistic":"contextual":"contextual",this.rootApply=this.createRootApply(),this.allows=this.allowsRequiresContext?(X)=>this.traverseAllows(X,new B6(X,this.$.resolvedConfig)):(X)=>this.traverseAllows(X)}createRootApply(){switch(this.rootApplyStrategy){case"allows":return(T,W)=>{if(this.allows(T))return T;let X=new B6(T,this.$.resolvedConfig);return this.traverseApply(T,X),X.finalize(W)};case"contextual":return(T,W)=>{let X=new B6(T,this.$.resolvedConfig);return this.traverseApply(T,X),X.finalize(W)};case"optimistic":this.contextFreeMorph=this.shallowMorphs[0];let $=this.$.resolvedConfig.clone;return(T,W)=>{if(this.allows(T))return this.contextFreeMorph($&&(typeof T==="object"&&T!==null||typeof T==="function")?$(T):T);let X=new B6(T,this.$.resolvedConfig);return this.traverseApply(T,X),X.finalize(W)};case"branchedOptimistic":return this.createBranchedOptimisticRootApply();default:return this.rootApplyStrategy,O$(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=Pq(this.metaJson);cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get description(){return this.cacheGetter("description",this.meta?.description??this.$.resolvedConfig[this.kind].description(this))}get references(){return Object.values(this.referencesById)}precedence=hT(this.kind);precompilation;assert=($,T)=>this($,T,(W)=>W.throw());traverse($,T){return this($,T,null)}get in(){return this.cacheGetter("in",this.getIo("in"))}get out(){return this.cacheGetter("out",this.getIo("out"))}getIo($){if(!this.includesTransform)return this;let T={};for(let[W,X]of this.innerEntries){let Y=this.impl.keys[W];if(Y.reduceIo)Y.reduceIo($,T,X);else if(Y.child){let U=X;T[W]=I$(U)?U.map((G)=>G[$]):U[$]}else T[W]=X}return this.$.node(this.kind,T)}toJSON(){return this.json}toString(){return`Type<${this.expression}>`}equals($){let T=v$($)?$:this.$.parseDefinition($);return this.innerHash===T.innerHash}ifEquals($){return this.equals($)?this:void 0}hasKind($){return this.kind===$}assertHasKind($){if(this.kind!==$)v0(`${this.kind} node was not of asserted kind ${$}`);return this}hasKindIn(...$){return $.includes(this.kind)}assertHasKindIn(...$){if(!J1($,this.kind))v0(`${this.kind} node was not one of asserted kinds ${$}`);return this}isBasis(){return J1(kV,this.kind)}isConstraint(){return J1(QU,this.kind)}isStructural(){return J1(bT,this.kind)}isRefinement(){return J1(V_,this.kind)}isRoot(){return J1(fT,this.kind)}isUnknown(){return this.hasKind("intersection")&&this.children.length===0}isNever(){return this.hasKind("union")&&this.children.length===0}hasUnit($){return this.hasKind("unit")&&this.allows($)}hasOpenIntersection(){return this.impl.intersectionIsOpen}get nestableExpression(){return this.expression}select($){let T=VX.normalize($);return this._select(T)}_select($){let T=VX.applyBoundary[$.boundary??"references"](this);if($.kind)T=T.filter((W)=>W.kind===$.kind);if($.where)T=T.filter($.where);return VX.applyMethod[$.method??"filter"](T,this,$)}transform($,T){return this._transform($,this._createTransformContext(T))}_createTransformContext($){return{root:this,selected:void 0,seen:{},path:[],parseOptions:{prereduced:$?.prereduced??!1},undeclaredKeyHandling:void 0,...$}}_transform($,T){let W=T.bindScope??this.$;if(T.seen[this.id])return this.$.lazilyResolve(T.seen[this.id]);if(T.shouldTransform?.(this,T)===!1)return this;let X;if(T.seen[this.id]=()=>X,this.hasKind("structure")&&this.undeclared!==T.undeclaredKeyHandling)T={...T,undeclaredKeyHandling:this.undeclared};let Y=Y$(this.inner,(w,H)=>{if(!this.impl.keys[w].child)return[w,H];let _=H;if(!I$(_)){let D=_._transform($,T);return D?[w,D]:[]}if(_.length===0)return[w,H];let F=_.flatMap((D)=>{return D._transform($,T)??[]});return F.length?[w,F]:[]});delete T.seen[this.id];let U=Object.assign(Y,{meta:this.meta}),G=T.selected&&!T.selected.includes(this)?U:$(this.kind,U,T);if(G===null)return null;if(v$(G))return X=G;let J=Object.keys(G);if((J.length===0||J.length===1&&J[0]==="meta")&&!m6(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in G))return T.undeclaredKeyHandling?{...G,value:I.intrinsic.unknown}:null;if(this.kind==="morph")G.in??=I.intrinsic.unknown;return X=W.node(this.kind,G,T.parseOptions)}configureReferences($,T="references"){let W=VX.normalize(T),X=typeof $==="string"?(J,z)=>({...z,meta:{...z.meta,description:$}}):typeof $==="function"?(J,z)=>({...z,meta:$(z.meta)}):(J,z)=>({...z,meta:{...z.meta,...$}});if(W.boundary==="self")return this.$.node(this.kind,X(this.kind,{...this.inner,meta:this.meta}));let Y=this._select(W),U=Y&&m1(Y),G=W.boundary==="child"?(J,z)=>z.root.children.includes(J):W.boundary==="shallow"?(J)=>J.kind!=="structure":()=>!0;return this.$.finalize(this.transform(X,{shouldTransform:G,selected:U}))}}var VX={applyBoundary:{self:($)=>[$],child:($)=>[...$.children],shallow:($)=>[...$.shallowReferences],references:($)=>[...$.references]},applyMethod:{filter:($)=>$,assertFilter:($,T,W)=>{if($.length===0)v0(jV(T,W));return $},find:($)=>$[0],assertFind:($,T,W)=>{if($.length===0)v0(jV(T,W));return $[0]}},normalize:($)=>typeof $==="function"?{boundary:"references",method:"filter",where:$}:typeof $==="string"?z4($,VX.applyBoundary)?{method:"filter",boundary:$}:{boundary:"references",method:"filter",kind:$}:{boundary:"references",method:"filter",...$}},jV=($,T)=>`${$} had no references matching ${U$(T)}.`,kq=($)=>H1($,{stringifyNonKey:(T)=>T.expression}),qq=/"(\$ark\.[^"]+)"/g,Pq=($)=>JSON.stringify($).replaceAll(qq,"$1"),R6=($,T)=>({path:$,node:T,propString:kq($)}),xV=($,T)=>$.propString===T.propString&&$.node.equals(T.node),M_=($,T)=>g6($,T,{isEqual:xV}),Cq=($,T)=>g6($,T,{isEqual:(W,X)=>W.equals(X)});class f extends Array{static init($,T,W,X){return new f({kind:$,l:T,r:W,path:X?.path??[],optional:X?.optional??!1})}add($,T,W,X){return this.push({kind:$,l:T,r:W,path:X?.path??[],optional:X?.optional??!1}),this}get summary(){return this.describeReasons()}describeReasons(){if(this.length===1){let{path:$,l:T,r:W}=this[0],X=H1($);return N_(`Intersection${X&&` at ${X}`} of ${bV(T,W)}`)}return`The following intersections result in unsatisfiable types:
|
|
127
|
-
\u2022 ${this.map(({path:$,l:T,r:W})=>`${$}: ${
|
|
128
|
-
\u2022 `)}`}throw(){return L(this.describeReasons())}invert(){let $=this.map((T)=>({...T,l:T.r,r:T.l}));if(!($ instanceof f))return new f(...$);return $}withPrefixKey($,T){return this.map((W)=>({...W,path:[$,...W.path],optional:W.optional||T==="optional"}))}toNeverIfDisjoint(){return I.intrinsic.never}}var bV=($,T)=>`${A_($)} and ${A_(T)}`,A_=($)=>v$($)?$.expression:I$($)?$.map(A_).join(" | ")||"never":String($),N_=($)=>`${$} results in an unsatisfiable type`;var gT={},o4=($,T,W)=>j$($,T,{$:W,invert:!1,pipe:!1}),EX=($,T,W)=>j$($,T,{$:W,invert:!1,pipe:!0}),j$=($,T,W)=>{let X=W.pipe?"|>":"&",Y=`${$.hash}${X}${T.hash}`;if(gT[Y]!==void 0)return gT[Y];if(!W.pipe){let J=`${T.hash}${X}${$.hash}`;if(gT[J]!==void 0){let z=gT[J],w=z instanceof f?z.invert():z;return gT[Y]=w,w}}let U=!W.pipe||!$.includesTransform&&!T.includesTransform;if(U&&$.equals(T))return $;let G=U?L_($,T,W):$.hasKindIn(...fT)?vq($,T,W):L_($,T,W);if(v$(G)){if($.equals(G))G=$;else if(T.equals(G))G=T}return gT[Y]=G,G},L_=($,T,W)=>{let X=$.precedence<T.precedence?$.kind:T.kind,Y=$.impl.intersections[T.kind]??T.impl.intersections[$.kind];if(Y===void 0)return null;else if(X===$.kind)return Y($,T,W);else{let U=Y(T,$,{...W,invert:!W.invert});if(U instanceof f)U=U.invert();return U}},vq=($,T,W)=>$.includesTransform||T.includesTransform?W.invert?fV(T,$,W):fV($,T,W):L_($,T,W),fV=($,T,W)=>$.distribute((X)=>jq(X,T,W),(X)=>{let Y=X.filter(v$);if(Y.length===0)return f.init("union",$.branches,T.branches);if(Y.length<$.branches.length||!$.branches.every((J,z)=>J.in.equals(Y[z].in)))return W.$.parseSchema(Y);let U;if(Y.length===1){let J=Y[0];if(!U)return J;return W.$.node("morph",{...J.inner,in:J.in.configure(U,"self")})}let G={branches:Y};if(U)G.meta=U;return W.$.parseSchema(G)}),jq=($,T,W)=>{if($.hasKind("morph")){let Y=[...$.morphs];if($.lastMorphIfNode){let U=j$($.lastMorphIfNode,T,W);if(U instanceof f)return U;Y[Y.length-1]=U}else Y.push(T);return W.$.node("morph",{morphs:Y,in:$.inner.in})}if(T.hasKind("morph")){let Y=j$($,T.in,W);if(Y instanceof f)return Y;return W.$.node("morph",{morphs:[T],in:Y})}return W.$.node("morph",{morphs:[T],in:$})};class F6 extends KX{constructor($,T){super($,T);Object.defineProperty(this,C4,{value:"constraint",enumerable:!1})}impliedSiblings;intersect($){return o4(this,$,this.$)}}class Q1 extends F6{traverseApply=($,T)=>{if(!this.traverseAllows($,T))T.errorFromNodeContext(this.errorContext)};compile($){if($.traversalKind==="Allows")$.return(this.compiledCondition);else $.if(this.compiledNegation,()=>$.line(`${$.ctx}.errorFromNodeContext(${this.compiledErrorContext})`))}get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return d1(this.errorContext)}}var S4=($)=>(T,W)=>{if(I$(T)){if(T.length===0)return;let Y=T.map((U)=>W.$.node($,U));if($==="predicate")return Y;return Y.sort((U,G)=>U.hash<G.hash?-1:1)}let X=W.$.node($,T);return X.hasOpenIntersection()?[X]:X},mT=($)=>{let T=$.r.shift();if(!T){let X=$.l.length===0&&$.kind==="structure"?I.intrinsic.unknown.internal:$.ctx.$.node($.kind,Object.assign($.baseInner,xq($.l)),{prereduced:!0});for(let Y of $.roots){if(X instanceof f)return X;X=j$(Y,X,$.ctx)}return X}let W=!1;for(let X=0;X<$.l.length;X++){let Y=j$($.l[X],T,$.ctx);if(Y===null)continue;if(Y instanceof f)return Y;if(!W){if(Y.isRoot())return $.roots.push(Y),$.l.splice(X),mT($);$.l[X]=Y,W=!0}else if(!$.l.includes(Y))return O$(`Unexpectedly encountered multiple distinct intersection results for refinement ${Y}`)}if(!W)$.l.push(T);if($.kind==="intersection"){if(T.impliedSiblings)for(let X of T.impliedSiblings)g6($.r,X)}return mT($)},cT=($)=>{return Object.entries($).flatMap(([W,X])=>(W in ZU)?X:[]).sort((W,X)=>W.precedence<X.precedence?-1:W.precedence>X.precedence?1:W.kind==="predicate"&&X.kind==="predicate"?0:W.hash<X.hash?-1:1)},xq=($)=>{let T={};for(let W of $)if(W.hasOpenIntersection())T[W.kind]=Q$(T[W.kind],W);else{if(T[W.kind])return O$(`Unexpected intersection of closed refinements of kind ${W.kind}`);T[W.kind]=W}return T},yV=(...$)=>L(hV(...$)),hV=($,T,W)=>{let X=W.hasKind("morph")?"a morph":W.isUnknown()?"unknown":W.exclude(T).defaultShortDescription;return`${QV($)} operand must be ${T.description} (was ${X})`};var gV=($,T,W)=>new l1($,T,W,W,null);class OU extends S6{}class l1 extends S6{[C4]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor($,T,W,X,Y){super((...U)=>{let G=Y$(this.names,(J,z)=>{let w=this.arg$.parse(U[J]);if(!w.extends(this.constraints[J]))L(bq(z,this.constraints[J].expression,w.expression));return[z,w]});if(this.defIsLazy()){let J=this.bodyDef(G);return this.$.parse(J)}return this.$.parse(T,{args:G})});this.paramDefs=$,this.bodyDef=T,this.$=W,this.arg$=X,this.hkt=Y,this.description=Y?new Y().description??`a generic type for ${Y.constructor.name}`:"a generic type",this.baseInstantiation=this(...this.constraints)}defIsLazy(){return this.bodyDef instanceof OU}cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get json(){return this.cacheGetter("json",{params:this.params.map(($)=>$[1].isUnknown()?$[0]:[$[0],$[1].json]),body:SV(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map(($)=>typeof $==="string"?[$,I.intrinsic.unknown]:[$[0],this.$.parse($[1])]))}get names(){return this.cacheGetter("names",this.params.map(($)=>$[0]))}get constraints(){return this.cacheGetter("constraints",this.params.map(($)=>$[1]))}get internal(){return this}get referencesById(){return this.baseInstantiation.internal.referencesById}get references(){return this.baseInstantiation.internal.references}}var bq=($,T,W)=>`${$} must be assignable to ${T} (was ${W})`;var fq=G$({kind:"predicate",hasAssociatedError:!0,collapsibleKey:"predicate",keys:{predicate:{}},normalize:($)=>typeof $==="function"?{predicate:$}:$,defaults:{description:($)=>`valid according to ${$.predicate.name||"an anonymous predicate"}`},intersectionIsOpen:!0,intersections:{predicate:()=>null}});class mV extends F6{serializedPredicate=d$(this.predicate);compiledCondition=`${this.serializedPredicate}(data, ctx)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=null;expression=this.serializedPredicate;traverseAllows=this.predicate;errorContext={code:"predicate",description:this.description,meta:this.meta};compiledErrorContext=d1(this.errorContext);traverseApply=($,T)=>{if(!this.predicate($,T.external)&&!T.hasError())T.errorFromNodeContext(this.errorContext)};compile($){if($.traversalKind==="Allows"){$.return(this.compiledCondition);return}$.if(`${this.compiledNegation} && !ctx.hasError()`,()=>$.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}reduceJsonSchema($,T){return T.fallback.predicate({code:"predicate",base:$,predicate:this.predicate})}}var S_={implementation:fq,Node:mV};var yq=G$({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:($)=>Number.isInteger($)?$:L(hq($))}},normalize:($)=>typeof $==="number"?{rule:$}:$,hasAssociatedError:!0,defaults:{description:($)=>$.rule===1?"an integer":$.rule===2?"even":`a multiple of ${$.rule}`},intersections:{divisor:($,T,W)=>W.$.node("divisor",{rule:Math.abs($.rule*T.rule/gq($.rule,T.rule))})},obviatesBasisDescription:!0});class cV extends Q1{traverseAllows=($)=>$%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=I.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema($){if($.type="integer",this.rule===1)return $;return $.multipleOf=this.rule,$}}var B_={implementation:yq,Node:cV};var hq=($)=>`divisor must be an integer (was ${$})`,gq=($,T)=>{let W,X=$,Y=T;while(Y!==0)W=Y,Y=X%Y,X=W;return X};class Y6 extends Q1{boundOperandKind=pq[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=dq(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${mq[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?oq(this.numericLimit):`${this.numericLimit}`;limitKind=this.comparator["0"]==="<"?"upper":"lower";isStricterThan($){return(this.limitKind==="upper"?this.numericLimit<$.numericLimit:this.numericLimit>$.numericLimit)||this.numericLimit===$.numericLimit&&this.exclusive===!0&&!$.exclusive}overlapsRange($){if(this.isStricterThan($))return!1;if(this.numericLimit===$.numericLimit&&(this.exclusive||$.exclusive))return!1;return!0}overlapIsUnit($){return this.numericLimit===$.numericLimit&&!this.exclusive&&!$.exclusive}}var mq={"<":">=","<=":">",">":"<=",">=":"<"},cq={min:"max",minLength:"maxLength",after:"before"},VU={parse:($)=>$||void 0},KU=($)=>(T)=>{if(typeof T==="number")return{rule:T};let{exclusive:W,...X}=T;return W?{...X,rule:$==="minLength"?X.rule+1:X.rule-1}:X},EU=($)=>(T)=>{if(typeof T==="number"||typeof T==="string"||T instanceof Date)return{rule:T};let{exclusive:W,...X}=T;if(!W)return X;let Y=typeof X.rule==="number"?X.rule:typeof X.rule==="string"?new Date(X.rule).valueOf():X.rule.valueOf();return W?{...X,rule:$==="after"?Y+1:Y-1}:X},MU=($)=>typeof $==="string"||typeof $==="number"?new Date($):$,uq=($,T)=>`${$} bound must be a positive integer (was ${T})`,uT=($)=>(T)=>{if(!Number.isInteger(T)||T<0)L(uq($,T));return T},pq={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},dq=($,T)=>`${z4($,cq)?">":"<"}${T?"":"="}`,oq=($)=>typeof $==="string"?$:new Date($).toLocaleString(),uV=($)=>`Bounded expression ${$} must be exactly one of number, string, Array, or Date`;var lq=G$({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:MU,serialize:($)=>$.toISOString()}},normalize:EU("after"),defaults:{description:($)=>`${$.collapsibleLimitString} or later`,actual:f0},intersections:{after:($,T)=>$.isStricterThan(T)?$:T}});class pV extends Y6{impliedBasis=I.intrinsic.Date.internal;collapsibleLimitString=f0(this.rule);traverseAllows=($)=>$>=this.rule;reduceJsonSchema($,T){return T.fallback.date({code:"date",base:$,after:this.rule})}}var R_={implementation:lq,Node:pV};var rq=G$({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:MU,serialize:($)=>$.toISOString()}},normalize:EU("before"),defaults:{description:($)=>`${$.collapsibleLimitString} or earlier`,actual:f0},intersections:{before:($,T)=>$.isStricterThan(T)?$:T,after:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("unit",{unit:$.rule}):null:f.init("range",$,T)}});class dV extends Y6{collapsibleLimitString=f0(this.rule);traverseAllows=($)=>$<=this.rule;impliedBasis=I.intrinsic.Date.internal;reduceJsonSchema($,T){return T.fallback.date({code:"date",base:$,before:this.rule})}}var I_={implementation:rq,Node:dV};var iq=G$({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:uT("exactLength")}},normalize:($)=>typeof $==="number"?{rule:$}:$,hasAssociatedError:!0,defaults:{description:($)=>`exactly length ${$.rule}`,actual:($)=>`${$.length}`},intersections:{exactLength:($,T,W)=>f.init("unit",W.$.node("unit",{unit:$.rule}),W.$.node("unit",{unit:T.rule}),{path:["length"]}),minLength:($,T)=>$.rule>=T.rule?$:f.init("range",$,T),maxLength:($,T)=>$.rule<=T.rule?$:f.init("range",$,T)}});class oV extends Q1{traverseAllows=($)=>$.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=I.intrinsic.lengthBoundable.internal;expression=`== ${this.rule}`;reduceJsonSchema($){switch($.type){case"string":return $.minLength=this.rule,$.maxLength=this.rule,$;case"array":return $.minItems=this.rule,$.maxItems=this.rule,$;default:return y$.throwInternalOperandError("exactLength",$)}}}var k_={implementation:iq,Node:oV};var nq=G$({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:VU},normalize:($)=>typeof $==="number"?{rule:$}:$,defaults:{description:($)=>{if($.rule===0)return $.exclusive?"negative":"non-positive";return`${$.exclusive?"less than":"at most"} ${$.rule}`}},intersections:{max:($,T)=>$.isStricterThan(T)?$:T,min:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("unit",{unit:$.rule}):null:f.init("range",$,T)},obviatesBasisDescription:!0});class lV extends Y6{impliedBasis=I.intrinsic.number.internal;traverseAllows=this.exclusive?($)=>$<this.rule:($)=>$<=this.rule;reduceJsonSchema($){if(this.exclusive)$.exclusiveMaximum=this.rule;else $.maximum=this.rule;return $}}var q_={implementation:nq,Node:lV};var tq=G$({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:uT("maxLength")}},reduce:($,T)=>$.rule===0?T.node("exactLength",$):void 0,normalize:KU("maxLength"),defaults:{description:($)=>`at most length ${$.rule}`,actual:($)=>`${$.length}`},intersections:{maxLength:($,T)=>$.isStricterThan(T)?$:T,minLength:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("exactLength",{rule:$.rule}):null:f.init("range",$,T)}});class rV extends Y6{impliedBasis=I.intrinsic.lengthBoundable.internal;traverseAllows=($)=>$.length<=this.rule;reduceJsonSchema($){switch($.type){case"string":return $.maxLength=this.rule,$;case"array":return $.maxItems=this.rule,$;default:return y$.throwInternalOperandError("maxLength",$)}}}var P_={implementation:tq,Node:rV};var aq=G$({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:VU},normalize:($)=>typeof $==="number"?{rule:$}:$,defaults:{description:($)=>{if($.rule===0)return $.exclusive?"positive":"non-negative";return`${$.exclusive?"more than":"at least"} ${$.rule}`}},intersections:{min:($,T)=>$.isStricterThan(T)?$:T},obviatesBasisDescription:!0});class iV extends Y6{impliedBasis=I.intrinsic.number.internal;traverseAllows=this.exclusive?($)=>$>this.rule:($)=>$>=this.rule;reduceJsonSchema($){if(this.exclusive)$.exclusiveMinimum=this.rule;else $.minimum=this.rule;return $}}var C_={implementation:aq,Node:iV};var sq=G$({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:uT("minLength")}},reduce:($)=>$.rule===0?I.intrinsic.unknown:void 0,normalize:KU("minLength"),defaults:{description:($)=>$.rule===1?"non-empty":`at least length ${$.rule}`,actual:($)=>$.length===0?"":`${$.length}`},intersections:{minLength:($,T)=>$.isStricterThan(T)?$:T}});class nV extends Y6{impliedBasis=I.intrinsic.lengthBoundable.internal;traverseAllows=($)=>$.length>=this.rule;reduceJsonSchema($){switch($.type){case"string":return $.minLength=this.rule,$;case"array":return $.minItems=this.rule,$;default:return y$.throwInternalOperandError("minLength",$)}}}var v_={implementation:sq,Node:nV};var tV={min:C_.implementation,max:q_.implementation,minLength:v_.implementation,maxLength:P_.implementation,exactLength:k_.implementation,after:R_.implementation,before:I_.implementation},aV={min:C_.Node,max:q_.Node,minLength:v_.Node,maxLength:P_.Node,exactLength:k_.Node,after:R_.Node,before:I_.Node};var eq=G$({kind:"pattern",collapsibleKey:"rule",keys:{rule:{},flags:{}},normalize:($)=>typeof $==="string"?{rule:$}:$ instanceof RegExp?$.flags?{rule:$.source,flags:$.flags}:{rule:$.source}:$,obviatesBasisDescription:!0,obviatesBasisExpression:!0,hasAssociatedError:!0,intersectionIsOpen:!0,defaults:{description:($)=>`matched by ${$.rule}`},intersections:{pattern:()=>null}});class sV extends Q1{instance=new RegExp(this.rule,this.flags);expression=`${this.instance}`;traverseAllows=this.instance.test.bind(this.instance);compiledCondition=`${this.expression}.test(data)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=I.intrinsic.string.internal;reduceJsonSchema($,T){if($.pattern)return T.fallback.patternIntersection({code:"patternIntersection",base:$,pattern:this.rule});return $.pattern=this.rule,$}}var j_={implementation:eq,Node:sV};var MX=($,T)=>{let W=$P($);if(T&&!T.includes(W))return L(`Root of kind ${W} should be one of ${T}`);return W},$P=($)=>{if(o($,"root"))return $.kind;if(typeof $==="string")return $[0]==="$"?"alias":($ in u4)?"domain":"proto";if(typeof $==="function")return"proto";if(typeof $!=="object"||$===null)return L(eV($));if("morphs"in $)return"morph";if("branches"in $||I$($))return"union";if("unit"in $)return"unit";if("reference"in $)return"alias";let T=Object.keys($);if(T.length===0||T.some((W)=>(W in ZU)))return"intersection";if("proto"in $)return"proto";if("domain"in $)return"domain";return L(eV($))},eV=($)=>`${U$($)} is not a valid type schema`,$K={},TP=($)=>I$($)?$.map((T)=>T.collapsibleJson):$.collapsibleJson,v4={};I.nodesByRegisteredId=v4;var x_=($)=>{return $K[$]??=0,`${$}${++$K[$]}`},b_=($)=>{let T=pT[$.kind],W=T.applyConfig?.($.def,$.$.resolvedConfig)??$.def,X={},{meta:Y,...U}=W,G=Y===void 0?{}:typeof Y==="string"?{description:Y}:Y,J=Y_(U).sort(([w],[H])=>yT(w)?yT(H)?hT(w)-hT(H):1:yT(H)?-1:w<H?-1:1).filter(([w,H])=>{if(w.startsWith("meta.")){let _=w.slice(5);return G[_]=H,!1}return!0});for(let w of J){let H=w[0],_=T.keys[H];if(!_)return L(`Key ${H} is not valid on ${$.kind} schema`);let F=_.parse?_.parse(w[1],$):w[1];if(F!==X6&&(F!==void 0||_.preserveUndefined))X[H]=F}if(T.reduce&&!$.prereduced){let w=T.reduce(X,$.$);if(w){if(w instanceof f)return w.throw();return WP(w,G)}}return f_({id:$.id,kind:$.kind,inner:X,meta:G,$:$.$})},f_=({id:$,kind:T,inner:W,meta:X,$:Y,ignoreCache:U})=>{let G=pT[T],J=Y_(W),z=[],w={};for(let[P,A]of J){let N=G.keys[P],k=N.serialize??(N.child?TP:H6);if(w[P]=k(A),N.child===!0){let y=A;if(I$(y))z.push(...y);else z.push(y)}else if(typeof N.child==="function")z.push(...N.child(A))}if(G.finalizeInnerJson)w=G.finalizeInnerJson(w);let H={...w},_={};if(!m6(X))_=Y$(X,(P,A)=>[P,P==="examples"?A:H6(A)]),H.meta=AU(_,"description",!0);w=AU(w,G.collapsibleKey,!1);let F=JSON.stringify({kind:T,...w});H=AU(H,G.collapsibleKey,!1);let D=AU(H,G.collapsibleKey,!0),V=JSON.stringify({kind:T,...H});if(Y.nodesByHash[V]&&!U)return Y.nodesByHash[V];let E={id:$,kind:T,impl:G,inner:W,innerEntries:J,innerJson:w,innerHash:F,meta:X,metaJson:_,json:H,hash:V,collapsibleJson:D,children:z};if(T!=="intersection"){for(let P in W)if(P!=="in"&&P!=="out")E[P]=W[P]}let R=new WK[T](E,Y);return Y.nodesByHash[V]=R},TK=($,T)=>{if($.id===T)return $;if(v$(v4[T]))O$(`Unexpected attempt to overwrite node id ${T}`);return f_({id:T,kind:$.kind,inner:$.inner,meta:$.meta,$:$.$,ignoreCache:!0})},WP=($,T,W)=>{if(W&&v$(v4[W]))O$(`Unexpected attempt to overwrite node id ${W}`);return f_({id:W??x_(T.alias??$.kind),kind:$.kind,inner:$.inner,meta:T,$:$.$})},AU=($,T,W)=>{let X=Object.keys($);if(X.length===1&&X[0]===T){let Y=$[T];if(W)return Y;if(c4(Y,"object")&&(Object.keys(Y).length===1||Array.isArray(Y)))return Y}return $};var AX=($,T,W)=>{if($.key!==T.key)return null;let X=$.key,Y=j$($.value,T.value,W),U=$.required||T.required?"required":"optional";if(Y instanceof f)if(U==="optional")Y=I.intrinsic.never.internal;else return Y.withPrefixKey($.key,$.required&&T.required?"required":"optional");if(U==="required")return W.$.node("required",{key:X,value:Y});let G=$.hasDefault()?T.hasDefault()?$.default===T.default?$.default:L(y_($.default,T.default)):$.default:T.hasDefault()?T.default:X6;return W.$.node("optional",{key:X,value:Y,default:G})};class NX extends F6{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=I.intrinsic.object.internal;serializedKey=F1(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=Q$(this.value.flatRefs.map(($)=>R6([this.key,...$.path],$.node)),R6([this.key],this.value));_transform($,T){T.path.push(this.key);let W=super._transform($,T);return T.path.pop(),W}hasDefault(){return"default"in this.inner}traverseAllows=($,T)=>{if(this.key in $)return d4(this.key,()=>this.value.traverseAllows($[this.key],T),T);return this.optional};traverseApply=($,T)=>{if(this.key in $)d4(this.key,()=>this.value.traverseApply($[this.key],T),T);else if(this.hasKind("required"))T.errorFromNodeContext(this.errorContext)};compile($){if($.if(`${this.serializedKey} in data`,()=>$.traverseKey(this.serializedKey,`data${$.prop(this.key)}`,this.value)),this.hasKind("required"))$.else(()=>$.traversalKind==="Apply"?$.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`):$.return(!1));if($.traversalKind==="Allows")$.return(!0)}}var y_=($,T)=>`Invalid intersection of default values ${U$($)} & ${U$(T)}`;var XP=G$({kind:"optional",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:($,T)=>T.$.parseSchema($)},default:{preserveUndefined:!0}},normalize:($)=>$,reduce:($,T)=>{if(T.resolvedConfig.exactOptionalPropertyTypes===!1){if(!$.value.allows(void 0))return T.node("optional",{...$,value:$.value.or(n.undefined)},{prereduced:!0})}},defaults:{description:($)=>`${$.compiledKey}?: ${$.value.description}`},intersections:{optional:AX}});class XK extends NX{constructor(...$){super(...$);if("default"in this.inner)SX(this.value,this.inner.default,this.key)}get outProp(){if(!this.hasDefault())return this;let{default:$,...T}=this.inner;return this.cacheGetter("outProp",this.$.node("required",T,{prereduced:!0}))}expression=this.hasDefault()?`${this.compiledKey}: ${this.value.expression} = ${U$(this.inner.default)}`:`${this.compiledKey}?: ${this.value.expression}`;defaultValueMorph=UP(this);defaultValueMorphRef=this.defaultValueMorph&&d$(this.defaultValueMorph)}var LX={implementation:XP,Node:XK},YP={},UP=($)=>{if(!$.hasDefault())return;let T=`{${$.compiledKey}: ${$.value.id} = ${H6($.default)}}`;return YP[T]??=h_($.key,$.value,$.default)},h_=($,T,W)=>{if(typeof W==="function")return T.includesTransform?(Y,U)=>{return d4($,()=>T(Y[$]=W(),U),U),Y}:(Y)=>{return Y[$]=W(),Y};let X=T.includesTransform?T.assert(W):W;return c4(X,"object")?(Y,U)=>{return d4($,()=>T(Y[$]=W,U),U),Y}:(Y)=>{return Y[$]=X,Y}},SX=($,T,W)=>{let X=c1(T);if(c4(T,"object")&&!X)L(GP(W));let Y=$.in(X?T():T);if(Y instanceof p4){if(W===null)L(`Default ${Y.summary}`);let U=Y.transform((G)=>G.transform((J)=>({...J,prefixPath:[W]})));L(`Default for ${U.summary}`)}return T},GP=($)=>{return`Non-primitive default ${$===null?"":typeof $==="number"?`for value at [${$}] `:`for ${F1($)} `}must be specified as a function like () => ({my: 'object'})`};class Q6 extends KX{constructor($,T){super($,T);Object.defineProperty(this,C4,{value:"root",enumerable:!1})}get internal(){return this}get "~standard"(){return{vendor:"arktype",version:1,validate:($)=>{let T=this($);if(T instanceof p4)return T;return{value:T}}}}as(){return this}brand($){if($==="")return L(JP);return this}readonly(){return this}branches=this.hasKind("union")?this.inner.branches:[this];distribute($,T){let W=this.branches.map($);return T?.(W)??W}get shortDescription(){return this.meta.description??this.defaultShortDescription}toJsonSchema($={}){let T=K_(this.$.resolvedConfig.toJsonSchema,$);T.useRefs||=this.isCyclic;let W=typeof T.dialect==="string"?{$schema:T.dialect}:{};if(Object.assign(W,this.toJsonSchemaRecurse(T)),T.useRefs)W.$defs=Y$(this.references,(X,Y)=>Y.isRoot()&&!Y.alwaysExpandJsonSchema?[Y.id,Y.toResolvedJsonSchema(T)]:[]);return W}toJsonSchemaRecurse($){if($.useRefs&&!this.alwaysExpandJsonSchema)return{$ref:`#/$defs/${this.id}`};return this.toResolvedJsonSchema($)}get alwaysExpandJsonSchema(){return this.isBasis()||this.kind==="alias"||this.hasKind("union")&&this.isBoolean}toResolvedJsonSchema($){let T=this.innerToJsonSchema($);return Object.assign(T,this.metaJson)}intersect($){let T=this.$.parseDefinition($),W=this.rawIntersect(T);if(W instanceof f)return W;return this.$.finalize(W)}rawIntersect($){return o4(this,$,this.$)}toNeverIfDisjoint(){return this}and($){let T=this.intersect($);return T instanceof f?T.throw():T}rawAnd($){let T=this.rawIntersect($);return T instanceof f?T.throw():T}or($){let T=this.$.parseDefinition($);return this.$.finalize(this.rawOr(T))}rawOr($){let T=[...this.branches,...$.branches];return this.$.node("union",T)}map($){return this.$.schema(this.applyStructuralOperation("map",[$]))}pick(...$){return this.$.schema(this.applyStructuralOperation("pick",$))}omit(...$){return this.$.schema(this.applyStructuralOperation("omit",$))}required(){return this.$.schema(this.applyStructuralOperation("required",[]))}partial(){return this.$.schema(this.applyStructuralOperation("partial",[]))}_keyof;keyof(){if(this._keyof)return this._keyof;let $=this.applyStructuralOperation("keyof",[]).reduce((T,W)=>T.intersect(W).toNeverIfDisjoint(),I.intrinsic.unknown.internal);if($.branches.length===0)L(N_(`keyof ${this.expression}`));return this._keyof=this.$.finalize($)}get props(){if(this.branches.length!==1)return L(wP(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge($){let T=this.$.parseDefinition($);return this.$.schema(T.distribute((W)=>this.applyStructuralOperation("merge",[YK(W)??L(UK("merge",W.expression))])))}applyStructuralOperation($,T){return this.distribute((W)=>{if(W.equals(I.intrinsic.object)&&$!=="merge")return W;let X=YK(W);if(!X)L(UK($,W.expression));if($==="keyof")return X.keyof();if($==="get")return X.get(...T);if($==="props")return X.props;let Y=$==="required"?"require":$==="partial"?"optionalize":$;return this.$.node("intersection",{...W.inner,structure:X[Y](...T)})})}get(...$){if($[0]===void 0)return this;return this.$.schema(this.applyStructuralOperation("get",$))}extract($){let T=this.$.parseDefinition($);return this.$.schema(this.branches.filter((W)=>W.extends(T)))}exclude($){let T=this.$.parseDefinition($);return this.$.schema(this.branches.filter((W)=>!W.extends(T)))}array(){return this.$.schema(this.isUnknown()?{proto:Array}:{proto:Array,sequence:this},{prereduced:!0})}overlaps($){return!(this.intersect($)instanceof f)}extends($){let T=this.intersect($);return!(T instanceof f)&&this.equals(T)}ifExtends($){return this.extends($)?this:void 0}subsumes($){return this.$.parseDefinition($).extends(this)}configure($,T="shallow"){return this.configureReferences($,T)}describe($,T="shallow"){return this.configure({description:$},T)}optional(){return[this,"?"]}default($){return SX(this,$,null),[this,"=",$]}from($){return this.assert($)}_pipe(...$){let T=$.reduce((W,X)=>W.rawPipeOnce(X),this);return this.$.finalize(T)}tryPipe(...$){let T=$.reduce((W,X)=>W.rawPipeOnce(o(X,"root")?X:(Y,U)=>{try{return X(Y,U)}catch(G){return U.error({code:"predicate",predicate:X,actual:`aborted due to error:
|
|
129
|
-
${
|
|
130
|
-
`})}}),this);return this.$.finalize(T)}pipe=Object.assign(this._pipe.bind(this),{try:this.tryPipe.bind(this)});to($){return this.$.finalize(this.toNode(this.$.parseDefinition($)))}toNode($){let T=
|
|
131
|
-
${$}`,
|
|
127
|
+
`);class u1{path=[];errors=new o6(this);root;config;queuedMorphs=[];branches=[];seen={};constructor($,T){this.root=$,this.config=T}get data(){let $=this.root;for(let T of this.path)$=$?.[T];return $}get propString(){return a0(this.path)}reject($){return this.error($),!1}mustBe($){return this.error($),!1}error($){let T=typeof $==="object"?$.code?$:{...$,code:"predicate"}:{code:"predicate",expected:$};return this.errorFromContext(T)}hasError(){return this.currentErrorCount!==0}get currentBranch(){return this.branches.at(-1)}queueMorphs($){let T={path:new yY(...this.path),morphs:$};if(this.currentBranch)this.currentBranch.queuedMorphs.push(T);else this.queuedMorphs.push(T)}finalize($){if(this.queuedMorphs.length){if(typeof this.root==="object"&&this.root!==null&&this.config.clone)this.root=this.config.clone(this.root);this.applyQueuedMorphs()}if(this.hasError())return $?$(this.errors):this.errors;return this.root}get currentErrorCount(){return this.currentBranch?this.currentBranch.error?1:0:this.errors.count}get failFast(){return this.branches.length!==0}pushBranch(){this.branches.push({error:void 0,queuedMorphs:[]})}popBranch(){return this.branches.pop()}get external(){return this}errorFromNodeContext($){return this.errorFromContext($)}errorFromContext($){let T=new uT($,this);if(this.currentBranch)this.currentBranch.error=T;else this.errors.add(T);return T}applyQueuedMorphs(){while(this.queuedMorphs.length){let $=this.queuedMorphs;this.queuedMorphs=[];for(let{path:T,morphs:W}of $){if(this.errors.affectsPath(T))continue;this.applyMorphsAtPath(T,W)}}}applyMorphsAtPath($,T){let W=$.at(-1),U;if(W!==void 0){U=this.root;for(let X=0;X<$.length-1;X++)U=U[$[X]]}this.path=[...$];for(let X of T){let Y=t$(X),w=X(U===void 0?this.root:U[W],this);if(w instanceof uT){this.errors.add(w);break}if(w instanceof o6){if(!Y)this.errors.merge(w);break}if(U===void 0)this.root=w;else U[W]=w;this.applyQueuedMorphs()}}}var l6=($,T,W)=>{if(!W)return T();W.path.push($);let U=T();return W.path.pop(),U};class cY extends c1{attachments;$;onFail;includesTransform;includesContextualPredicate;isCyclic;allowsRequiresContext;rootApplyStrategy;contextFreeMorph;rootApply;referencesById;shallowReferences;flatRefs;flatMorphs;allows;get shallowMorphs(){return[]}constructor($,T){super((U,X,Y=this.onFail)=>{if(X)return this.traverseApply(U,X),X.hasError()?X.errors:X.data;return this.rootApply(U,Y)},{attach:$});this.attachments=$,this.$=T,this.onFail=this.meta.onFail??this.$.resolvedConfig.onFail,this.includesTransform=this.hasKind("morph")||this.hasKind("structure")&&this.structuralMorph!==void 0,this.includesContextualPredicate=this.hasKind("predicate")&&this.inner.predicate.length!==1,this.isCyclic=this.kind==="alias",this.referencesById={[this.id]:this},this.shallowReferences=this.hasKind("structure")?[this,...this.children]:this.children.reduce((U,X)=>xy(U,X.shallowReferences),[this]);let W=this.isStructural();this.flatRefs=[],this.flatMorphs=[];for(let U=0;U<this.children.length;U++){if(this.includesTransform||=this.children[U].includesTransform,this.includesContextualPredicate||=this.children[U].includesContextualPredicate,this.isCyclic||=this.children[U].isCyclic,!W){let X=this.children[U].flatRefs;for(let Y=0;Y<X.length;Y++){let w=X[Y];if(!this.flatRefs.some((G)=>fR(G,w))){this.flatRefs.push(w);for(let G of w.node.branches)if(G.hasKind("morph")||G.hasKind("intersection")&&G.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:w.path,propString:w.propString,node:G})}}}Object.assign(this.referencesById,this.children[U].referencesById)}this.flatRefs.sort((U,X)=>U.path.length>X.path.length?1:U.path.length<X.path.length?-1:U.propString>X.propString?1:U.propString<X.propString?-1:U.node.expression<X.node.expression?-1:1),this.allowsRequiresContext=this.includesContextualPredicate||this.isCyclic,this.rootApplyStrategy=!this.allowsRequiresContext&&this.flatMorphs.length===0?this.shallowMorphs.length===0?"allows":this.shallowMorphs.every((U)=>U.length===1||U.name==="$arkStructuralMorph")?this.hasKind("union")?this.branches.some((U)=>U.shallowMorphs.length>1)?"contextual":"branchedOptimistic":this.shallowMorphs.length>1?"contextual":"optimistic":"contextual":"contextual",this.rootApply=this.createRootApply(),this.allows=this.allowsRequiresContext?(U)=>this.traverseAllows(U,new u1(U,this.$.resolvedConfig)):(U)=>this.traverseAllows(U)}createRootApply(){switch(this.rootApplyStrategy){case"allows":return(T,W)=>{if(this.allows(T))return T;let U=new u1(T,this.$.resolvedConfig);return this.traverseApply(T,U),U.finalize(W)};case"contextual":return(T,W)=>{let U=new u1(T,this.$.resolvedConfig);return this.traverseApply(T,U),U.finalize(W)};case"optimistic":this.contextFreeMorph=this.shallowMorphs[0];let $=this.$.resolvedConfig.clone;return(T,W)=>{if(this.allows(T))return this.contextFreeMorph($&&(typeof T==="object"&&T!==null||typeof T==="function")?$(T):T);let U=new u1(T,this.$.resolvedConfig);return this.traverseApply(T,U),U.finalize(W)};case"branchedOptimistic":return this.createBranchedOptimisticRootApply();default:return this.rootApplyStrategy,S$(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=By(this.metaJson);cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get description(){return this.cacheGetter("description",this.meta?.description??this.$.resolvedConfig[this.kind].description(this))}get references(){return Object.values(this.referencesById)}precedence=AU(this.kind);precompilation;assert=($,T)=>this($,T,(W)=>W.throw());traverse($,T){return this($,T,null)}get in(){return this.cacheGetter("in",this.getIo("in"))}get out(){return this.cacheGetter("out",this.getIo("out"))}getIo($){if(!this.includesTransform)return this;let T={};for(let[W,U]of this.innerEntries){let X=this.impl.keys[W];if(X.reduceIo)X.reduceIo($,T,U);else if(X.child){let Y=U;T[W]=d$(Y)?Y.map((w)=>w[$]):Y[$]}else T[W]=U}return this.$.node(this.kind,T)}toJSON(){return this.json}toString(){return`Type<${this.expression}>`}equals($){let T=t$($)?$:this.$.parseDefinition($);return this.innerHash===T.innerHash}ifEquals($){return this.equals($)?this:void 0}hasKind($){return this.kind===$}assertHasKind($){if(this.kind!==$)dW(`${this.kind} node was not of asserted kind ${$}`);return this}hasKindIn(...$){return $.includes(this.kind)}assertHasKindIn(...$){if(!r0($,this.kind))dW(`${this.kind} node was not one of asserted kinds ${$}`);return this}isBasis(){return r0(SR,this.kind)}isConstraint(){return r0(Ez,this.kind)}isStructural(){return r0(VU,this.kind)}isRefinement(){return r0(DZ,this.kind)}isRoot(){return r0(KU,this.kind)}isUnknown(){return this.hasKind("intersection")&&this.children.length===0}isNever(){return this.hasKind("union")&&this.children.length===0}hasUnit($){return this.hasKind("unit")&&this.allows($)}hasOpenIntersection(){return this.impl.intersectionIsOpen}get nestableExpression(){return this.expression}select($){let T=mY.normalize($);return this._select(T)}_select($){let T=mY.applyBoundary[$.boundary??"references"](this);if($.kind)T=T.filter((W)=>W.kind===$.kind);if($.where)T=T.filter($.where);return mY.applyMethod[$.method??"filter"](T,this,$)}transform($,T){return this._transform($,this._createTransformContext(T))}_createTransformContext($){return{root:this,selected:void 0,seen:{},path:[],parseOptions:{prereduced:$?.prereduced??!1},undeclaredKeyHandling:void 0,...$}}_transform($,T){let W=T.bindScope??this.$;if(T.seen[this.id])return this.$.lazilyResolve(T.seen[this.id]);if(T.shouldTransform?.(this,T)===!1)return this;let U;if(T.seen[this.id]=()=>U,this.hasKind("structure")&&this.undeclared!==T.undeclaredKeyHandling)T={...T,undeclaredKeyHandling:this.undeclared};let X=K$(this.inner,(z,F)=>{if(!this.impl.keys[z].child)return[z,F];let O=F;if(!d$(O)){let Z=O._transform($,T);return Z?[z,Z]:[]}if(O.length===0)return[z,F];let Q=O.flatMap((Z)=>{return Z._transform($,T)??[]});return Q.length?[z,Q]:[]});delete T.seen[this.id];let Y=Object.assign(X,{meta:this.meta}),w=T.selected&&!T.selected.includes(this)?Y:$(this.kind,Y,T);if(w===null)return null;if(t$(w))return U=w;let G=Object.keys(w);if((G.length===0||G.length===1&&G[0]==="meta")&&!O0(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in w))return T.undeclaredKeyHandling?{...w,value:b.intrinsic.unknown}:null;if(this.kind==="morph")w.in??=b.intrinsic.unknown;return U=W.node(this.kind,w,T.parseOptions)}configureReferences($,T="references"){let W=mY.normalize(T),U=typeof $==="string"?(G,H)=>({...H,meta:{...H.meta,description:$}}):typeof $==="function"?(G,H)=>({...H,meta:$(H.meta)}):(G,H)=>({...H,meta:{...H.meta,...$}});if(W.boundary==="self")return this.$.node(this.kind,U(this.kind,{...this.inner,meta:this.meta}));let X=this._select(W),Y=X&&yT(X),w=W.boundary==="child"?(G,H)=>H.root.children.includes(G):W.boundary==="shallow"?(G)=>G.kind!=="structure":()=>!0;return this.$.finalize(this.transform(U,{shouldTransform:w,selected:Y}))}}var mY={applyBoundary:{self:($)=>[$],child:($)=>[...$.children],shallow:($)=>[...$.shallowReferences],references:($)=>[...$.references]},applyMethod:{filter:($)=>$,assertFilter:($,T,W)=>{if($.length===0)dW(bR(T,W));return $},find:($)=>$[0],assertFind:($,T,W)=>{if($.length===0)dW(bR(T,W));return $[0]}},normalize:($)=>typeof $==="function"?{boundary:"references",method:"filter",where:$}:typeof $==="string"?I4($,mY.applyBoundary)?{method:"filter",boundary:$}:{boundary:"references",method:"filter",kind:$}:{boundary:"references",method:"filter",...$}},bR=($,T)=>`${$} had no references matching ${E$(T)}.`,Sy=($)=>a0($,{stringifyNonKey:(T)=>T.expression}),jy=/"(\$ark\.[^"]+)"/g,By=($)=>JSON.stringify($).replaceAll(jy,"$1"),p1=($,T)=>({path:$,node:T,propString:Sy($)}),fR=($,T)=>$.propString===T.propString&&$.node.equals(T.node),EZ=($,T)=>F0($,T,{isEqual:fR}),xy=($,T)=>F0($,T,{isEqual:(W,U)=>W.equals(U)});class o extends Array{static init($,T,W,U){return new o({kind:$,l:T,r:W,path:U?.path??[],optional:U?.optional??!1})}add($,T,W,U){return this.push({kind:$,l:T,r:W,path:U?.path??[],optional:U?.optional??!1}),this}get summary(){return this.describeReasons()}describeReasons(){if(this.length===1){let{path:$,l:T,r:W}=this[0],U=a0($);return MZ(`Intersection${U&&` at ${U}`} of ${yR(T,W)}`)}return`The following intersections result in unsatisfiable types:
|
|
128
|
+
\u2022 ${this.map(({path:$,l:T,r:W})=>`${$}: ${yR(T,W)}`).join(`
|
|
129
|
+
\u2022 `)}`}throw(){return B(this.describeReasons())}invert(){let $=this.map((T)=>({...T,l:T.r,r:T.l}));if(!($ instanceof o))return new o(...$);return $}withPrefixKey($,T){return this.map((W)=>({...W,path:[$,...W.path],optional:W.optional||T==="optional"}))}toNeverIfDisjoint(){return b.intrinsic.never}}var yR=($,T)=>`${AZ($)} and ${AZ(T)}`,AZ=($)=>t$($)?$.expression:d$($)?$.map(AZ).join(" | ")||"never":String($),MZ=($)=>`${$} results in an unsatisfiable type`;var MU={},r6=($,T,W)=>a$($,T,{$:W,invert:!1,pipe:!1}),uY=($,T,W)=>a$($,T,{$:W,invert:!1,pipe:!0}),a$=($,T,W)=>{let U=W.pipe?"|>":"&",X=`${$.hash}${U}${T.hash}`;if(MU[X]!==void 0)return MU[X];if(!W.pipe){let G=`${T.hash}${U}${$.hash}`;if(MU[G]!==void 0){let H=MU[G],z=H instanceof o?H.invert():H;return MU[X]=z,z}}let Y=!W.pipe||!$.includesTransform&&!T.includesTransform;if(Y&&$.equals(T))return $;let w=Y?NZ($,T,W):$.hasKindIn(...KU)?Iy($,T,W):NZ($,T,W);if(t$(w)){if($.equals(w))w=$;else if(T.equals(w))w=T}return MU[X]=w,w},NZ=($,T,W)=>{let U=$.precedence<T.precedence?$.kind:T.kind,X=$.impl.intersections[T.kind]??T.impl.intersections[$.kind];if(X===void 0)return null;else if(U===$.kind)return X($,T,W);else{let Y=X(T,$,{...W,invert:!W.invert});if(Y instanceof o)Y=Y.invert();return Y}},Iy=($,T,W)=>$.includesTransform||T.includesTransform?W.invert?hR(T,$,W):hR($,T,W):NZ($,T,W),hR=($,T,W)=>$.distribute((U)=>by(U,T,W),(U)=>{let X=U.filter(t$);if(X.length===0)return o.init("union",$.branches,T.branches);if(X.length<$.branches.length||!$.branches.every((G,H)=>G.in.equals(X[H].in)))return W.$.parseSchema(X);let Y;if(X.length===1){let G=X[0];if(!Y)return G;return W.$.node("morph",{...G.inner,in:G.in.configure(Y,"self")})}let w={branches:X};if(Y)w.meta=Y;return W.$.parseSchema(w)}),by=($,T,W)=>{if($.hasKind("morph")){let X=[...$.morphs];if($.lastMorphIfNode){let Y=a$($.lastMorphIfNode,T,W);if(Y instanceof o)return Y;X[X.length-1]=Y}else X.push(T);return W.$.node("morph",{morphs:X,in:$.inner.in})}if(T.hasKind("morph")){let X=a$($,T.in,W);if(X instanceof o)return X;return W.$.node("morph",{morphs:[T],in:X})}return W.$.node("morph",{morphs:[T],in:$})};class v1 extends cY{constructor($,T){super($,T);Object.defineProperty(this,q6,{value:"constraint",enumerable:!1})}impliedSiblings;intersect($){return r6(this,$,this.$)}}class e0 extends v1{traverseApply=($,T)=>{if(!this.traverseAllows($,T))T.errorFromNodeContext(this.errorContext)};compile($){if($.traversalKind==="Allows")$.return(this.compiledCondition);else $.if(this.compiledNegation,()=>$.line(`${$.ctx}.errorFromNodeContext(${this.compiledErrorContext})`))}get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return cT(this.errorContext)}}var X6=($)=>(T,W)=>{if(d$(T)){if(T.length===0)return;let X=T.map((Y)=>W.$.node($,Y));if($==="predicate")return X;return X.sort((Y,w)=>Y.hash<w.hash?-1:1)}let U=W.$.node($,T);return U.hasOpenIntersection()?[U]:U},NU=($)=>{let T=$.r.shift();if(!T){let U=$.l.length===0&&$.kind==="structure"?b.intrinsic.unknown.internal:$.ctx.$.node($.kind,Object.assign($.baseInner,fy($.l)),{prereduced:!0});for(let X of $.roots){if(U instanceof o)return U;U=a$(X,U,$.ctx)}return U}let W=!1;for(let U=0;U<$.l.length;U++){let X=a$($.l[U],T,$.ctx);if(X===null)continue;if(X instanceof o)return X;if(!W){if(X.isRoot())return $.roots.push(X),$.l.splice(U),NU($);$.l[U]=X,W=!0}else if(!$.l.includes(X))return S$(`Unexpectedly encountered multiple distinct intersection results for refinement ${X}`)}if(!W)$.l.push(T);if($.kind==="intersection"){if(T.impliedSiblings)for(let U of T.impliedSiblings)F0($.r,U)}return NU($)},LU=($)=>{return Object.entries($).flatMap(([W,U])=>(W in Az)?U:[]).sort((W,U)=>W.precedence<U.precedence?-1:W.precedence>U.precedence?1:W.kind==="predicate"&&U.kind==="predicate"?0:W.hash<U.hash?-1:1)},fy=($)=>{let T={};for(let W of $)if(W.hasOpenIntersection())T[W.kind]=q$(T[W.kind],W);else{if(T[W.kind])return S$(`Unexpected intersection of closed refinements of kind ${W.kind}`);T[W.kind]=W}return T},gR=(...$)=>B(mR(...$)),mR=($,T,W)=>{let U=W.hasKind("morph")?"a morph":W.isUnknown()?"unknown":W.exclude(T).defaultShortDescription;return`${VR($)} operand must be ${T.description} (was ${U})`};var cR=($,T,W)=>new pT($,T,W,W,null);class Nz extends c1{}class pT extends c1{[q6]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor($,T,W,U,X){super((...Y)=>{let w=K$(this.names,(G,H)=>{let z=this.arg$.parse(Y[G]);if(!z.extends(this.constraints[G]))B(yy(H,this.constraints[G].expression,z.expression));return[H,z]});if(this.defIsLazy()){let G=this.bodyDef(w);return this.$.parse(G)}return this.$.parse(T,{args:w})});this.paramDefs=$,this.bodyDef=T,this.$=W,this.arg$=U,this.hkt=X,this.description=X?new X().description??`a generic type for ${X.constructor.name}`:"a generic type",this.baseInstantiation=this(...this.constraints)}defIsLazy(){return this.bodyDef instanceof Nz}cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get json(){return this.cacheGetter("json",{params:this.params.map(($)=>$[1].isUnknown()?$[0]:[$[0],$[1].json]),body:vR(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map(($)=>typeof $==="string"?[$,b.intrinsic.unknown]:[$[0],this.$.parse($[1])]))}get names(){return this.cacheGetter("names",this.params.map(($)=>$[0]))}get constraints(){return this.cacheGetter("constraints",this.params.map(($)=>$[1]))}get internal(){return this}get referencesById(){return this.baseInstantiation.internal.referencesById}get references(){return this.baseInstantiation.internal.references}}var yy=($,T,W)=>`${$} must be assignable to ${T} (was ${W})`;var hy=A$({kind:"predicate",hasAssociatedError:!0,collapsibleKey:"predicate",keys:{predicate:{}},normalize:($)=>typeof $==="function"?{predicate:$}:$,defaults:{description:($)=>`valid according to ${$.predicate.name||"an anonymous predicate"}`},intersectionIsOpen:!0,intersections:{predicate:()=>null}});class uR extends v1{serializedPredicate=Z4(this.predicate);compiledCondition=`${this.serializedPredicate}(data, ctx)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=null;expression=this.serializedPredicate;traverseAllows=this.predicate;errorContext={code:"predicate",description:this.description,meta:this.meta};compiledErrorContext=cT(this.errorContext);traverseApply=($,T)=>{if(!this.predicate($,T.external)&&!T.hasError())T.errorFromNodeContext(this.errorContext)};compile($){if($.traversalKind==="Allows"){$.return(this.compiledCondition);return}$.if(`${this.compiledNegation} && !ctx.hasError()`,()=>$.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}reduceJsonSchema($,T){return T.fallback.predicate({code:"predicate",base:$,predicate:this.predicate})}}var LZ={implementation:hy,Node:uR};var gy=A$({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:($)=>Number.isInteger($)?$:B(my($))}},normalize:($)=>typeof $==="number"?{rule:$}:$,hasAssociatedError:!0,defaults:{description:($)=>$.rule===1?"an integer":$.rule===2?"even":`a multiple of ${$.rule}`},intersections:{divisor:($,T,W)=>W.$.node("divisor",{rule:Math.abs($.rule*T.rule/cy($.rule,T.rule))})},obviatesBasisDescription:!0});class pR extends e0{traverseAllows=($)=>$%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=b.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema($){if($.type="integer",this.rule===1)return $;return $.multipleOf=this.rule,$}}var JZ={implementation:gy,Node:pR};var my=($)=>`divisor must be an integer (was ${$})`,cy=($,T)=>{let W,U=$,X=T;while(X!==0)W=X,X=U%X,U=W;return U};class Z1 extends e0{boundOperandKind=oy[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=ly(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${uy[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?ry(this.numericLimit):`${this.numericLimit}`;limitKind=this.comparator["0"]==="<"?"upper":"lower";isStricterThan($){return(this.limitKind==="upper"?this.numericLimit<$.numericLimit:this.numericLimit>$.numericLimit)||this.numericLimit===$.numericLimit&&this.exclusive===!0&&!$.exclusive}overlapsRange($){if(this.isStricterThan($))return!1;if(this.numericLimit===$.numericLimit&&(this.exclusive||$.exclusive))return!1;return!0}overlapIsUnit($){return this.numericLimit===$.numericLimit&&!this.exclusive&&!$.exclusive}}var uy={"<":">=","<=":">",">":"<=",">=":"<"},py={min:"max",minLength:"maxLength",after:"before"},Lz={parse:($)=>$||void 0},Jz=($)=>(T)=>{if(typeof T==="number")return{rule:T};let{exclusive:W,...U}=T;return W?{...U,rule:$==="minLength"?U.rule+1:U.rule-1}:U},_z=($)=>(T)=>{if(typeof T==="number"||typeof T==="string"||T instanceof Date)return{rule:T};let{exclusive:W,...U}=T;if(!W)return U;let X=typeof U.rule==="number"?U.rule:typeof U.rule==="string"?new Date(U.rule).valueOf():U.rule.valueOf();return W?{...U,rule:$==="after"?X+1:X-1}:U},Rz=($)=>typeof $==="string"||typeof $==="number"?new Date($):$,dy=($,T)=>`${$} bound must be a positive integer (was ${T})`,JU=($)=>(T)=>{if(!Number.isInteger(T)||T<0)B(dy($,T));return T},oy={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},ly=($,T)=>`${I4($,py)?">":"<"}${T?"":"="}`,ry=($)=>typeof $==="string"?$:new Date($).toLocaleString(),dR=($)=>`Bounded expression ${$} must be exactly one of number, string, Array, or Date`;var ny=A$({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:Rz,serialize:($)=>$.toISOString()}},normalize:_z("after"),defaults:{description:($)=>`${$.collapsibleLimitString} or later`,actual:nW},intersections:{after:($,T)=>$.isStricterThan(T)?$:T}});class oR extends Z1{impliedBasis=b.intrinsic.Date.internal;collapsibleLimitString=nW(this.rule);traverseAllows=($)=>$>=this.rule;reduceJsonSchema($,T){return T.fallback.date({code:"date",base:$,after:this.rule})}}var _Z={implementation:ny,Node:oR};var iy=A$({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:Rz,serialize:($)=>$.toISOString()}},normalize:_z("before"),defaults:{description:($)=>`${$.collapsibleLimitString} or earlier`,actual:nW},intersections:{before:($,T)=>$.isStricterThan(T)?$:T,after:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("unit",{unit:$.rule}):null:o.init("range",$,T)}});class lR extends Z1{collapsibleLimitString=nW(this.rule);traverseAllows=($)=>$<=this.rule;impliedBasis=b.intrinsic.Date.internal;reduceJsonSchema($,T){return T.fallback.date({code:"date",base:$,before:this.rule})}}var RZ={implementation:iy,Node:lR};var ty=A$({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:JU("exactLength")}},normalize:($)=>typeof $==="number"?{rule:$}:$,hasAssociatedError:!0,defaults:{description:($)=>`exactly length ${$.rule}`,actual:($)=>`${$.length}`},intersections:{exactLength:($,T,W)=>o.init("unit",W.$.node("unit",{unit:$.rule}),W.$.node("unit",{unit:T.rule}),{path:["length"]}),minLength:($,T)=>$.rule>=T.rule?$:o.init("range",$,T),maxLength:($,T)=>$.rule<=T.rule?$:o.init("range",$,T)}});class rR extends e0{traverseAllows=($)=>$.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=b.intrinsic.lengthBoundable.internal;expression=`== ${this.rule}`;reduceJsonSchema($){switch($.type){case"string":return $.minLength=this.rule,$.maxLength=this.rule,$;case"array":return $.minItems=this.rule,$.maxItems=this.rule,$;default:return U4.throwInternalOperandError("exactLength",$)}}}var kZ={implementation:ty,Node:rR};var ay=A$({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:Lz},normalize:($)=>typeof $==="number"?{rule:$}:$,defaults:{description:($)=>{if($.rule===0)return $.exclusive?"negative":"non-positive";return`${$.exclusive?"less than":"at most"} ${$.rule}`}},intersections:{max:($,T)=>$.isStricterThan(T)?$:T,min:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("unit",{unit:$.rule}):null:o.init("range",$,T)},obviatesBasisDescription:!0});class nR extends Z1{impliedBasis=b.intrinsic.number.internal;traverseAllows=this.exclusive?($)=>$<this.rule:($)=>$<=this.rule;reduceJsonSchema($){if(this.exclusive)$.exclusiveMaximum=this.rule;else $.maximum=this.rule;return $}}var vZ={implementation:ay,Node:nR};var sy=A$({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:JU("maxLength")}},reduce:($,T)=>$.rule===0?T.node("exactLength",$):void 0,normalize:Jz("maxLength"),defaults:{description:($)=>`at most length ${$.rule}`,actual:($)=>`${$.length}`},intersections:{maxLength:($,T)=>$.isStricterThan(T)?$:T,minLength:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("exactLength",{rule:$.rule}):null:o.init("range",$,T)}});class iR extends Z1{impliedBasis=b.intrinsic.lengthBoundable.internal;traverseAllows=($)=>$.length<=this.rule;reduceJsonSchema($){switch($.type){case"string":return $.maxLength=this.rule,$;case"array":return $.maxItems=this.rule,$;default:return U4.throwInternalOperandError("maxLength",$)}}}var qZ={implementation:sy,Node:iR};var ey=A$({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:Lz},normalize:($)=>typeof $==="number"?{rule:$}:$,defaults:{description:($)=>{if($.rule===0)return $.exclusive?"positive":"non-negative";return`${$.exclusive?"more than":"at least"} ${$.rule}`}},intersections:{min:($,T)=>$.isStricterThan(T)?$:T},obviatesBasisDescription:!0});class tR extends Z1{impliedBasis=b.intrinsic.number.internal;traverseAllows=this.exclusive?($)=>$>this.rule:($)=>$>=this.rule;reduceJsonSchema($){if(this.exclusive)$.exclusiveMinimum=this.rule;else $.minimum=this.rule;return $}}var PZ={implementation:ey,Node:tR};var $h=A$({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:JU("minLength")}},reduce:($)=>$.rule===0?b.intrinsic.unknown:void 0,normalize:Jz("minLength"),defaults:{description:($)=>$.rule===1?"non-empty":`at least length ${$.rule}`,actual:($)=>$.length===0?"":`${$.length}`},intersections:{minLength:($,T)=>$.isStricterThan(T)?$:T}});class aR extends Z1{impliedBasis=b.intrinsic.lengthBoundable.internal;traverseAllows=($)=>$.length>=this.rule;reduceJsonSchema($){switch($.type){case"string":return $.minLength=this.rule,$;case"array":return $.minItems=this.rule,$;default:return U4.throwInternalOperandError("minLength",$)}}}var CZ={implementation:$h,Node:aR};var sR={min:PZ.implementation,max:vZ.implementation,minLength:CZ.implementation,maxLength:qZ.implementation,exactLength:kZ.implementation,after:_Z.implementation,before:RZ.implementation},eR={min:PZ.Node,max:vZ.Node,minLength:CZ.Node,maxLength:qZ.Node,exactLength:kZ.Node,after:_Z.Node,before:RZ.Node};var Th=A$({kind:"pattern",collapsibleKey:"rule",keys:{rule:{},flags:{}},normalize:($)=>typeof $==="string"?{rule:$}:$ instanceof RegExp?$.flags?{rule:$.source,flags:$.flags}:{rule:$.source}:$,obviatesBasisDescription:!0,obviatesBasisExpression:!0,hasAssociatedError:!0,intersectionIsOpen:!0,defaults:{description:($)=>`matched by ${$.rule}`},intersections:{pattern:()=>null}});class $k extends e0{instance=new RegExp(this.rule,this.flags);expression=`${this.instance}`;traverseAllows=this.instance.test.bind(this.instance);compiledCondition=`${this.expression}.test(data)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=b.intrinsic.string.internal;reduceJsonSchema($,T){if($.pattern)return T.fallback.patternIntersection({code:"patternIntersection",base:$,pattern:this.rule});return $.pattern=this.rule,$}}var SZ={implementation:Th,Node:$k};var pY=($,T)=>{let W=Wh($);if(T&&!T.includes(W))return B(`Root of kind ${W} should be one of ${T}`);return W},Wh=($)=>{if(s($,"root"))return $.kind;if(typeof $==="string")return $[0]==="$"?"alias":($ in d6)?"domain":"proto";if(typeof $==="function")return"proto";if(typeof $!=="object"||$===null)return B(Tk($));if("morphs"in $)return"morph";if("branches"in $||d$($))return"union";if("unit"in $)return"unit";if("reference"in $)return"alias";let T=Object.keys($);if(T.length===0||T.some((W)=>(W in Az)))return"intersection";if("proto"in $)return"proto";if("domain"in $)return"domain";return B(Tk($))},Tk=($)=>`${E$($)} is not a valid type schema`,Wk={},Uh=($)=>d$($)?$.map((T)=>T.collapsibleJson):$.collapsibleJson,P6={};b.nodesByRegisteredId=P6;var jZ=($)=>{return Wk[$]??=0,`${$}${++Wk[$]}`},BZ=($)=>{let T=_U[$.kind],W=T.applyConfig?.($.def,$.$.resolvedConfig)??$.def,U={},{meta:X,...Y}=W,w=X===void 0?{}:typeof X==="string"?{description:X}:X,G=TZ(Y).sort(([z],[F])=>EU(z)?EU(F)?AU(z)-AU(F):1:EU(F)?-1:z<F?-1:1).filter(([z,F])=>{if(z.startsWith("meta.")){let O=z.slice(5);return w[O]=F,!1}return!0});for(let z of G){let F=z[0],O=T.keys[F];if(!O)return B(`Key ${F} is not valid on ${$.kind} schema`);let Q=O.parse?O.parse(z[1],$):z[1];if(Q!==Q1&&(Q!==void 0||O.preserveUndefined))U[F]=Q}if(T.reduce&&!$.prereduced){let z=T.reduce(U,$.$);if(z){if(z instanceof o)return z.throw();return Xh(z,w)}}return xZ({id:$.id,kind:$.kind,inner:U,meta:w,$:$.$})},xZ=({id:$,kind:T,inner:W,meta:U,$:X,ignoreCache:Y})=>{let w=_U[T],G=TZ(W),H=[],z={};for(let[J,_]of G){let R=w.keys[J],P=R.serialize??(R.child?Uh:k1);if(z[J]=P(_),R.child===!0){let x=_;if(d$(x))H.push(...x);else H.push(x)}else if(typeof R.child==="function")H.push(...R.child(_))}if(w.finalizeInnerJson)z=w.finalizeInnerJson(z);let F={...z},O={};if(!O0(U))O=K$(U,(J,_)=>[J,J==="examples"?_:k1(_)]),F.meta=kz(O,"description",!0);z=kz(z,w.collapsibleKey,!1);let Q=JSON.stringify({kind:T,...z});F=kz(F,w.collapsibleKey,!1);let Z=kz(F,w.collapsibleKey,!0),V=JSON.stringify({kind:T,...F});if(X.nodesByHash[V]&&!Y)return X.nodesByHash[V];let E={id:$,kind:T,impl:w,inner:W,innerEntries:G,innerJson:z,innerHash:Q,meta:U,metaJson:O,json:F,hash:V,collapsibleJson:Z,children:H};if(T!=="intersection"){for(let J in W)if(J!=="in"&&J!=="out")E[J]=W[J]}let N=new Xk[T](E,X);return X.nodesByHash[V]=N},Uk=($,T)=>{if($.id===T)return $;if(t$(P6[T]))S$(`Unexpected attempt to overwrite node id ${T}`);return xZ({id:T,kind:$.kind,inner:$.inner,meta:$.meta,$:$.$,ignoreCache:!0})},Xh=($,T,W)=>{if(W&&t$(P6[W]))S$(`Unexpected attempt to overwrite node id ${W}`);return xZ({id:W??jZ(T.alias??$.kind),kind:$.kind,inner:$.inner,meta:T,$:$.$})},kz=($,T,W)=>{let U=Object.keys($);if(U.length===1&&U[0]===T){let X=$[T];if(W)return X;if(p6(X,"object")&&(Object.keys(X).length===1||Array.isArray(X)))return X}return $};var dY=($,T,W)=>{if($.key!==T.key)return null;let U=$.key,X=a$($.value,T.value,W),Y=$.required||T.required?"required":"optional";if(X instanceof o)if(Y==="optional")X=b.intrinsic.never.internal;else return X.withPrefixKey($.key,$.required&&T.required?"required":"optional");if(Y==="required")return W.$.node("required",{key:U,value:X});let w=$.hasDefault()?T.hasDefault()?$.default===T.default?$.default:B(IZ($.default,T.default)):$.default:T.hasDefault()?T.default:Q1;return W.$.node("optional",{key:U,value:X,default:w})};class oY extends v1{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=b.intrinsic.object.internal;serializedKey=s0(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=q$(this.value.flatRefs.map(($)=>p1([this.key,...$.path],$.node)),p1([this.key],this.value));_transform($,T){T.path.push(this.key);let W=super._transform($,T);return T.path.pop(),W}hasDefault(){return"default"in this.inner}traverseAllows=($,T)=>{if(this.key in $)return l6(this.key,()=>this.value.traverseAllows($[this.key],T),T);return this.optional};traverseApply=($,T)=>{if(this.key in $)l6(this.key,()=>this.value.traverseApply($[this.key],T),T);else if(this.hasKind("required"))T.errorFromNodeContext(this.errorContext)};compile($){if($.if(`${this.serializedKey} in data`,()=>$.traverseKey(this.serializedKey,`data${$.prop(this.key)}`,this.value)),this.hasKind("required"))$.else(()=>$.traversalKind==="Apply"?$.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`):$.return(!1));if($.traversalKind==="Allows")$.return(!0)}}var IZ=($,T)=>`Invalid intersection of default values ${E$($)} & ${E$(T)}`;var Yh=A$({kind:"optional",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:($,T)=>T.$.parseSchema($)},default:{preserveUndefined:!0}},normalize:($)=>$,reduce:($,T)=>{if(T.resolvedConfig.exactOptionalPropertyTypes===!1){if(!$.value.allows(void 0))return T.node("optional",{...$,value:$.value.or(X$.undefined)},{prereduced:!0})}},defaults:{description:($)=>`${$.compiledKey}?: ${$.value.description}`},intersections:{optional:dY}});class Yk extends oY{constructor(...$){super(...$);if("default"in this.inner)rY(this.value,this.inner.default,this.key)}get outProp(){if(!this.hasDefault())return this;let{default:$,...T}=this.inner;return this.cacheGetter("outProp",this.$.node("required",T,{prereduced:!0}))}expression=this.hasDefault()?`${this.compiledKey}: ${this.value.expression} = ${E$(this.inner.default)}`:`${this.compiledKey}?: ${this.value.expression}`;defaultValueMorph=Gh(this);defaultValueMorphRef=this.defaultValueMorph&&Z4(this.defaultValueMorph)}var lY={implementation:Yh,Node:Yk},wh={},Gh=($)=>{if(!$.hasDefault())return;let T=`{${$.compiledKey}: ${$.value.id} = ${k1($.default)}}`;return wh[T]??=bZ($.key,$.value,$.default)},bZ=($,T,W)=>{if(typeof W==="function")return T.includesTransform?(X,Y)=>{return l6($,()=>T(X[$]=W(),Y),Y),X}:(X)=>{return X[$]=W(),X};let U=T.includesTransform?T.assert(W):W;return p6(U,"object")?(X,Y)=>{return l6($,()=>T(X[$]=W,Y),Y),X}:(X)=>{return X[$]=U,X}},rY=($,T,W)=>{let U=hT(T);if(p6(T,"object")&&!U)B(zh(W));let X=$.in(U?T():T);if(X instanceof o6){if(W===null)B(`Default ${X.summary}`);let Y=X.transform((w)=>w.transform((G)=>({...G,prefixPath:[W]})));B(`Default for ${Y.summary}`)}return T},zh=($)=>{return`Non-primitive default ${$===null?"":typeof $==="number"?`for value at [${$}] `:`for ${s0($)} `}must be specified as a function like () => ({my: 'object'})`};class q1 extends cY{constructor($,T){super($,T);Object.defineProperty(this,q6,{value:"root",enumerable:!1})}get internal(){return this}get "~standard"(){return{vendor:"arktype",version:1,validate:($)=>{let T=this($);if(T instanceof o6)return T;return{value:T}}}}as(){return this}brand($){if($==="")return B(Hh);return this}readonly(){return this}branches=this.hasKind("union")?this.inner.branches:[this];distribute($,T){let W=this.branches.map($);return T?.(W)??W}get shortDescription(){return this.meta.description??this.defaultShortDescription}toJsonSchema($={}){let T=VZ(this.$.resolvedConfig.toJsonSchema,$);T.useRefs||=this.isCyclic;let W=typeof T.dialect==="string"?{$schema:T.dialect}:{};if(Object.assign(W,this.toJsonSchemaRecurse(T)),T.useRefs)W.$defs=K$(this.references,(U,X)=>X.isRoot()&&!X.alwaysExpandJsonSchema?[X.id,X.toResolvedJsonSchema(T)]:[]);return W}toJsonSchemaRecurse($){if($.useRefs&&!this.alwaysExpandJsonSchema)return{$ref:`#/$defs/${this.id}`};return this.toResolvedJsonSchema($)}get alwaysExpandJsonSchema(){return this.isBasis()||this.kind==="alias"||this.hasKind("union")&&this.isBoolean}toResolvedJsonSchema($){let T=this.innerToJsonSchema($);return Object.assign(T,this.metaJson)}intersect($){let T=this.$.parseDefinition($),W=this.rawIntersect(T);if(W instanceof o)return W;return this.$.finalize(W)}rawIntersect($){return r6(this,$,this.$)}toNeverIfDisjoint(){return this}and($){let T=this.intersect($);return T instanceof o?T.throw():T}rawAnd($){let T=this.rawIntersect($);return T instanceof o?T.throw():T}or($){let T=this.$.parseDefinition($);return this.$.finalize(this.rawOr(T))}rawOr($){let T=[...this.branches,...$.branches];return this.$.node("union",T)}map($){return this.$.schema(this.applyStructuralOperation("map",[$]))}pick(...$){return this.$.schema(this.applyStructuralOperation("pick",$))}omit(...$){return this.$.schema(this.applyStructuralOperation("omit",$))}required(){return this.$.schema(this.applyStructuralOperation("required",[]))}partial(){return this.$.schema(this.applyStructuralOperation("partial",[]))}_keyof;keyof(){if(this._keyof)return this._keyof;let $=this.applyStructuralOperation("keyof",[]).reduce((T,W)=>T.intersect(W).toNeverIfDisjoint(),b.intrinsic.unknown.internal);if($.branches.length===0)B(MZ(`keyof ${this.expression}`));return this._keyof=this.$.finalize($)}get props(){if(this.branches.length!==1)return B(Fh(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge($){let T=this.$.parseDefinition($);return this.$.schema(T.distribute((W)=>this.applyStructuralOperation("merge",[wk(W)??B(Gk("merge",W.expression))])))}applyStructuralOperation($,T){return this.distribute((W)=>{if(W.equals(b.intrinsic.object)&&$!=="merge")return W;let U=wk(W);if(!U)B(Gk($,W.expression));if($==="keyof")return U.keyof();if($==="get")return U.get(...T);if($==="props")return U.props;let X=$==="required"?"require":$==="partial"?"optionalize":$;return this.$.node("intersection",{...W.inner,structure:U[X](...T)})})}get(...$){if($[0]===void 0)return this;return this.$.schema(this.applyStructuralOperation("get",$))}extract($){let T=this.$.parseDefinition($);return this.$.schema(this.branches.filter((W)=>W.extends(T)))}exclude($){let T=this.$.parseDefinition($);return this.$.schema(this.branches.filter((W)=>!W.extends(T)))}array(){return this.$.schema(this.isUnknown()?{proto:Array}:{proto:Array,sequence:this},{prereduced:!0})}overlaps($){return!(this.intersect($)instanceof o)}extends($){let T=this.intersect($);return!(T instanceof o)&&this.equals(T)}ifExtends($){return this.extends($)?this:void 0}subsumes($){return this.$.parseDefinition($).extends(this)}configure($,T="shallow"){return this.configureReferences($,T)}describe($,T="shallow"){return this.configure({description:$},T)}optional(){return[this,"?"]}default($){return rY(this,$,null),[this,"=",$]}from($){return this.assert($)}_pipe(...$){let T=$.reduce((W,U)=>W.rawPipeOnce(U),this);return this.$.finalize(T)}tryPipe(...$){let T=$.reduce((W,U)=>W.rawPipeOnce(s(U,"root")?U:(X,Y)=>{try{return U(X,Y)}catch(w){return Y.error({code:"predicate",predicate:U,actual:`aborted due to error:
|
|
130
|
+
${w}
|
|
131
|
+
`})}}),this);return this.$.finalize(T)}pipe=Object.assign(this._pipe.bind(this),{try:this.tryPipe.bind(this)});to($){return this.$.finalize(this.toNode(this.$.parseDefinition($)))}toNode($){let T=uY(this,$,this.$);if(T instanceof o)return T.throw();return T}rawPipeOnce($){if(s($,"root"))return this.toNode($);return this.distribute((T)=>T.hasKind("morph")?this.$.node("morph",{in:T.inner.in,morphs:[...T.morphs,$]}):this.$.node("morph",{in:T,morphs:[$]}),this.$.parseSchema)}narrow($){return this.constrainOut("predicate",$)}constrain($,T){return this._constrain("root",$,T)}constrainIn($,T){return this._constrain("in",$,T)}constrainOut($,T){return this._constrain("out",$,T)}_constrain($,T,W){let U=this.$.node(T,W);if(U.isRoot())return U.isUnknown()?this:S$(`Unexpected constraint node ${U}`);let X=$==="root"?this:this[$];if(X.hasKind("morph")||U.impliedBasis&&!X.extends(U.impliedBasis))return gR(T,U.impliedBasis,this);let Y=this.$.node("intersection",{[U.kind]:U}),w=$==="out"?uY(this,Y,this.$):r6(this,Y,this.$);if(w instanceof o)w.throw();return this.$.finalize(w)}onUndeclaredKey($){let T=typeof $==="string"?$:$.rule,W=typeof $==="string"?!1:$.deep;return this.$.finalize(this.transform((U,X)=>U==="structure"?T==="ignore"?XR(X,{undeclared:1}):{...X,undeclared:T}:X,W?void 0:{shouldTransform:(U)=>!r0(VU,U.kind)}))}hasEqualMorphs($){if(!this.includesTransform&&!$.includesTransform)return!0;if(!i0(this.shallowMorphs,$.shallowMorphs))return!1;if(!i0(this.flatMorphs,$.flatMorphs,{isEqual:(T,W)=>T.propString===W.propString&&(T.node.hasKind("morph")&&W.node.hasKind("morph")?T.node.hasEqualMorphs(W.node):T.node.hasKind("intersection")&&W.node.hasKind("intersection")?T.node.structure?.structuralMorphRef===W.node.structure?.structuralMorphRef:!1)}))return!1;return!0}onDeepUndeclaredKey($){return this.onUndeclaredKey({rule:$,deep:!0})}filter($){return this.constrainIn("predicate",$)}divisibleBy($){return this.constrain("divisor",$)}matching($){return this.constrain("pattern",$)}atLeast($){return this.constrain("min",$)}atMost($){return this.constrain("max",$)}moreThan($){return this.constrain("min",RU($))}lessThan($){return this.constrain("max",RU($))}atLeastLength($){return this.constrain("minLength",$)}atMostLength($){return this.constrain("maxLength",$)}moreThanLength($){return this.constrain("minLength",RU($))}lessThanLength($){return this.constrain("maxLength",RU($))}exactlyLength($){return this.constrain("exactLength",$)}atOrAfter($){return this.constrain("after",$)}atOrBefore($){return this.constrain("before",$)}laterThan($){return this.constrain("after",RU($))}earlierThan($){return this.constrain("before",RU($))}}var Hh="Expected a non-empty brand name after #",RU=($)=>typeof $==="object"&&!($ instanceof Date)?{...$,exclusive:!0}:{rule:$,exclusive:!0},nY=($,T)=>s(T,"root")?s($,"root")?$.extends(T):T.allows($):s($,"root")?$.hasUnit(T):T===$,wk=($)=>{if($.hasKind("morph"))return null;if($.hasKind("intersection"))return $.inner.structure??($.basis?.domain==="object"?$.$.bindReference(b.intrinsic.emptyStructure):null);if($.isBasis()&&$.domain==="object")return $.$.bindReference(b.intrinsic.emptyStructure);return null},Fh=($)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
|
|
132
|
+
${$}`,Gk=($,T)=>`${$} operand must be an object (was ${T})`;var Q0=($,T)=>K$(Mz($),(W,U)=>[U,T]);var Oh=($)=>typeof $==="string"?{reference:$}:$,zk=($)=>$ instanceof o?b.intrinsic.never.internal:$,Qh=A$({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:($)=>$.startsWith("$")?$:`$ark.${$}`},resolve:{}},normalize:Oh,defaults:{description:($)=>$.reference},intersections:{alias:($,T,W)=>W.$.lazilyResolve(()=>zk(a$($.resolution,T.resolution,W)),`${$.reference}${W.pipe?"=>":"&"}${T.reference}`),...Q0("alias",($,T,W)=>{if(T.isUnknown())return $;if(T.isNever())return T;if(T.isBasis()&&!T.overlaps(b.intrinsic.object))return o.init("assignability",b.intrinsic.object,T);return W.$.lazilyResolve(()=>zk(a$($.resolution,T,W)),`${$.reference}${W.pipe?"=>":"&"}${T.id}`)})}});class Hk extends q1{expression=this.reference;structure=void 0;get resolution(){let $=this._resolve();return P6[this.id]=$}_resolve(){if(this.resolve)return this.resolve();if(this.reference[0]==="$")return this.$.resolveRoot(this.reference.slice(1));let $=this.reference,T=P6[$],W=[];while(s(T,"context")){if(W.includes(T.id))return B(Zh(T.id,W));W.push(T.id),T=P6[T.id]}if(!s(T,"root"))return S$(`Unexpected resolution for reference ${this.reference}
|
|
132
133
|
Seen: [${W.join("->")}]
|
|
133
|
-
Resolution: ${
|
|
134
|
+
Resolution: ${E$(T)}`);return T}get resolutionId(){if(this.reference.includes("&")||this.reference.includes("=>"))return this.resolution.id;if(this.reference[0]!=="$")return this.reference;let $=this.reference.slice(1),T=this.$.resolutions[$];if(typeof T==="string")return T;if(s(T,"root"))return T.id;return S$(`Unexpected resolution for reference ${this.reference}: ${E$(T)}`)}get defaultShortDescription(){return d6.object}innerToJsonSchema($){return this.resolution.toJsonSchemaRecurse($)}traverseAllows=($,T)=>{let W=T.seen[this.reference];if(W?.includes($))return!0;return T.seen[this.reference]=q$(W,$),this.resolution.traverseAllows($,T)};traverseApply=($,T)=>{let W=T.seen[this.reference];if(W?.includes($))return;T.seen[this.reference]=q$(W,$),this.resolution.traverseApply($,T)};compile($){let T=this.resolutionId;$.if(`ctx.seen.${T} && ctx.seen.${T}.includes(data)`,()=>$.return(!0)),$.if(`!ctx.seen.${T}`,()=>$.line(`ctx.seen.${T} = []`)),$.line(`ctx.seen.${T}.push(data)`),$.return($.invoke(T))}}var Zh=($,T)=>`Alias '${$}' has a shallow resolution cycle: ${[...T,$].join("->")}`,iY={implementation:Qh,Node:Hk};class iW extends q1{traverseApply=($,T)=>{if(!this.traverseAllows($,T))T.errorFromNodeContext(this.errorContext)};get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return cT(this.errorContext)}compile($){if($.traversalKind==="Allows")$.return(this.compiledCondition);else $.if(this.compiledNegation,()=>$.line(`${$.ctx}.errorFromNodeContext(${this.compiledErrorContext})`))}}var Dh=A$({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:($)=>typeof $==="string"?{domain:$}:ZU($,"numberAllowsNaN")&&$.domain!=="number"?B(vz.writeBadAllowNanMessage($.domain)):$,applyConfig:($,T)=>$.numberAllowsNaN===void 0&&$.domain==="number"&&T.numberAllowsNaN?{...$,numberAllowsNaN:!0}:$,defaults:{description:($)=>d6[$.domain],actual:($)=>Number.isNaN($)?"NaN":d6[x4($)]},intersections:{domain:($,T)=>$.domain==="number"&&T.domain==="number"?$.numberAllowsNaN?T:$:o.init("domain",$,T)}});class Fk extends iW{requiresNaNCheck=this.domain==="number"&&!this.numberAllowsNaN;traverseAllows=this.requiresNaNCheck?($)=>typeof $==="number"&&!Number.isNaN($):($)=>x4($)===this.domain;compiledCondition=this.domain==="object"?'((typeof data === "object" && data !== null) || typeof data === "function")':`typeof data === "${this.domain}"${this.requiresNaNCheck?" && !Number.isNaN(data)":""}`;compiledNegation=this.domain==="object"?'((typeof data !== "object" || data === null) && typeof data !== "function")':`typeof data !== "${this.domain}"${this.requiresNaNCheck?" || Number.isNaN(data)":""}`;expression=this.numberAllowsNaN?"number | NaN":this.domain;get nestableExpression(){return this.numberAllowsNaN?`(${this.expression})`:this.expression}get defaultShortDescription(){return d6[this.domain]}innerToJsonSchema($){if(this.domain==="bigint"||this.domain==="symbol")return $.fallback.domain({code:"domain",base:{},domain:this.domain});return{type:this.domain}}}var vz={implementation:Dh,Node:Fk,writeBadAllowNanMessage:($)=>`numberAllowsNaN may only be specified with domain "number" (was ${$})`};var Vh=A$({kind:"intersection",hasAssociatedError:!0,normalize:($)=>{if(t$($))return $;let{structure:T,...W}=$,U=!!T,X=T??{},Y=K$(W,(w,G)=>{if(I4(w,jR)){if(U)B(`Flattened structure key ${w} cannot be specified alongside a root 'structure' key.`);return X[w]=G,[]}return[w,G]});if(s(X,"constraint")||!O0(X))Y.structure=X;return Y},finalizeInnerJson:({structure:$,...T})=>p6($,"object")?{...$,...T}:T,keys:{domain:{child:!0,parse:($,T)=>T.$.node("domain",$)},proto:{child:!0,parse:($,T)=>T.$.node("proto",$)},structure:{child:!0,parse:($,T)=>T.$.node("structure",$),serialize:($)=>{if(!$.sequence?.minLength)return $.collapsibleJson;let{sequence:T,...W}=$.collapsibleJson,{minVariadicLength:U,...X}=T,Y=X.variadic&&Object.keys(X).length===1?X.variadic:X;return{...W,sequence:Y}}},divisor:{child:!0,parse:X6("divisor")},max:{child:!0,parse:X6("max")},min:{child:!0,parse:X6("min")},maxLength:{child:!0,parse:X6("maxLength")},minLength:{child:!0,parse:X6("minLength")},exactLength:{child:!0,parse:X6("exactLength")},before:{child:!0,parse:X6("before")},after:{child:!0,parse:X6("after")},pattern:{child:!0,parse:X6("pattern")},predicate:{child:!0,parse:X6("predicate")}},reduce:($,T)=>Ok({},$,{$:T,invert:!1,pipe:!1}),defaults:{description:($)=>{if($.children.length===0)return"unknown";if($.structure)return $.structure.description;let T=[];if($.basis&&!$.refinements.some((W)=>W.impl.obviatesBasisDescription))T.push($.basis.description);if($.refinements.length){let W=$.refinements.toSorted((U,X)=>U.kind==="min"&&X.kind==="max"?-1:0).map((U)=>U.description);T.push(...W)}if($.inner.predicate)T.push(...$.inner.predicate.map((W)=>W.description));return T.join(" and ")},expected:($)=>` \u25E6 ${$.errors.map((T)=>T.expected).join(`
|
|
134
135
|
\u25E6 `)}`,problem:($)=>`(${$.actual}) must be...
|
|
135
|
-
${$.expected}`},intersections:{intersection:($,T,W)=>
|
|
136
|
+
${$.expected}`},intersections:{intersection:($,T,W)=>Ok($.inner,T.inner,W),...Q0("intersection",($,T,W)=>{if($.children.length===0)return T;let{domain:U,proto:X,...Y}=$.inner,w=X??U,G=w?a$(w,T,W):T;return G instanceof o?G:$?.basis?.equals(G)?$:$.$.node("intersection",{...Y,[G.kind]:G},{prereduced:!0})})}});class Qk extends q1{basis=this.inner.domain??this.inner.proto??null;refinements=this.children.filter(($)=>$.isRefinement());structure=this.inner.structure;expression=Kh(this);get shallowMorphs(){return this.inner.structure?.structuralMorph?[this.inner.structure.structuralMorph]:[]}get defaultShortDescription(){return this.basis?.defaultShortDescription??"present"}innerToJsonSchema($){return this.children.reduce((T,W)=>W.isBasis()?W.toJsonSchemaRecurse($):W.reduceJsonSchema(T,$),{})}traverseAllows=($,T)=>this.children.every((W)=>W.traverseAllows($,T));traverseApply=($,T)=>{let W=T.currentErrorCount;if(this.basis){if(this.basis.traverseApply($,T),T.currentErrorCount>W)return}if(this.refinements.length){for(let U=0;U<this.refinements.length-1;U++)if(this.refinements[U].traverseApply($,T),T.failFast&&T.currentErrorCount>W)return;if(this.refinements.at(-1).traverseApply($,T),T.currentErrorCount>W)return}if(this.structure){if(this.structure.traverseApply($,T),T.currentErrorCount>W)return}if(this.inner.predicate){for(let U=0;U<this.inner.predicate.length-1;U++)if(this.inner.predicate[U].traverseApply($,T),T.failFast&&T.currentErrorCount>W)return;this.inner.predicate.at(-1).traverseApply($,T)}};compile($){if($.traversalKind==="Allows"){for(let T of this.children)$.check(T);$.return(!0);return}if($.initializeErrorCount(),this.basis){if($.check(this.basis),this.children.length>1)$.returnIfFail()}if(this.refinements.length){for(let T=0;T<this.refinements.length-1;T++)$.check(this.refinements[T]),$.returnIfFailFast();if($.check(this.refinements.at(-1)),this.structure||this.inner.predicate)$.returnIfFail()}if(this.structure){if($.check(this.structure),this.inner.predicate)$.returnIfFail()}if(this.inner.predicate){for(let T=0;T<this.inner.predicate.length-1;T++)$.check(this.inner.predicate[T]),$.returnIfFail();$.check(this.inner.predicate.at(-1))}}}var fZ={implementation:Vh,Node:Qk},Kh=($)=>{let T=$.structure?.expression||`${$.basis&&!$.refinements.some((W)=>W.impl.obviatesBasisExpression)?$.basis.nestableExpression+" ":""}${$.refinements.map((W)=>W.expression).join(" & ")}`||"unknown";if(T==="Array == 0")T="[]";return T},Ok=($,T,W)=>{let U={},X=$.proto??$.domain,Y=T.proto??T.domain,w=X?Y?a$(X,Y,W):X:Y;if(w instanceof o)return w;if(w)U[w.kind]=w;return NU({kind:"intersection",baseInner:U,l:LU($),r:LU(T),roots:[],ctx:W})};var Eh=A$({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:($,T)=>T.$.parseSchema($)},morphs:{parse:yT,serialize:($)=>$.map((T)=>s(T,"root")?T.json:Z4(T))},declaredIn:{child:!1,serialize:($)=>$.json},declaredOut:{child:!1,serialize:($)=>$.json}},normalize:($)=>$,defaults:{description:($)=>`a morph from ${$.in.description} to ${$.out?.description??"unknown"}`},intersections:{morph:($,T,W)=>{if(!$.hasEqualMorphs(T))return B(Ah($.expression,T.expression));let U=a$($.in,T.in,W);if(U instanceof o)return U;let X={morphs:$.morphs};if($.declaredIn||T.declaredIn){let Y=a$($.in,T.in,W);if(Y instanceof o)return Y.throw();else X.declaredIn=Y}if($.declaredOut||T.declaredOut){let Y=a$($.out,T.out,W);if(Y instanceof o)return Y.throw();else X.declaredOut=Y}return U.distribute((Y)=>W.$.node("morph",{...X,in:Y}),W.$.parseSchema)},...Q0("morph",($,T,W)=>{let U=$.inner.in?a$($.inner.in,T,W):T;return U instanceof o?U:U.equals($.inner.in)?$:W.$.node("morph",{...$.inner,in:U})})}});class Zk extends q1{serializedMorphs=this.morphs.map(Z4);compiledMorphs=`[${this.serializedMorphs}]`;lastMorph=this.inner.morphs.at(-1);lastMorphIfNode=s(this.lastMorph,"root")?this.lastMorph:void 0;introspectableIn=this.inner.in;introspectableOut=this.lastMorphIfNode?Object.assign(this.referencesById,this.lastMorphIfNode.referencesById)&&this.lastMorphIfNode.out:void 0;get shallowMorphs(){return Array.isArray(this.inner.in?.shallowMorphs)?[...this.inner.in.shallowMorphs,...this.morphs]:this.morphs}get in(){return this.declaredIn??this.inner.in?.in??b.intrinsic.unknown.internal}get out(){return this.declaredOut??this.introspectableOut??b.intrinsic.unknown.internal}declareIn($){return this.$.node("morph",{...this.inner,declaredIn:$})}declareOut($){return this.$.node("morph",{...this.inner,declaredOut:$})}expression=`(In: ${this.in.expression}) => ${this.lastMorphIfNode?"To":"Out"}<${this.out.expression}>`;get defaultShortDescription(){return this.in.meta.description??this.in.defaultShortDescription}innerToJsonSchema($){return $.fallback.morph({code:"morph",base:this.in.toJsonSchemaRecurse($),out:this.introspectableOut?.toJsonSchemaRecurse($)??null})}compile($){if($.traversalKind==="Allows"){if(!this.introspectableIn)return;$.return($.invoke(this.introspectableIn));return}if(this.introspectableIn)$.line($.invoke(this.introspectableIn));$.line(`ctx.queueMorphs(${this.compiledMorphs})`)}traverseAllows=($,T)=>!this.introspectableIn||this.introspectableIn.traverseAllows($,T);traverseApply=($,T)=>{if(this.introspectableIn)this.introspectableIn.traverseApply($,T);T.queueMorphs(this.morphs)};hasEqualMorphs($){return i0(this.morphs,$.morphs,{isEqual:(T,W)=>T===W||s(T,"root")&&s(W,"root")&&T.equals(W)})}}var yZ={implementation:Eh,Node:Zk},Ah=($,T)=>`The intersection of distinct morphs at a single path is indeterminate:
|
|
136
137
|
Left: ${$}
|
|
137
|
-
Right: ${T}`;var
|
|
138
|
+
Right: ${T}`;var Mh=A$({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:($)=>jY($)??k1($)},dateAllowsInvalid:{}},normalize:($)=>{let T=typeof $==="string"?{proto:lW[$]}:typeof $==="function"?t$($)?$:{proto:$}:typeof $.proto==="string"?{...$,proto:lW[$.proto]}:$;if(typeof T.proto!=="function")B(tY.writeInvalidSchemaMessage(T.proto));if(ZU(T,"dateAllowsInvalid")&&T.proto!==Date)B(tY.writeBadInvalidDateMessage(T.proto));return T},applyConfig:($,T)=>{if($.dateAllowsInvalid===void 0&&$.proto===Date&&T.dateAllowsInvalid)return{...$,dateAllowsInvalid:!0};return $},defaults:{description:($)=>$.builtinName?zR[$.builtinName]:`an instance of ${$.proto.name}`,actual:($)=>$ instanceof Date&&$.toString()==="Invalid Date"?"an invalid Date":SY($)},intersections:{proto:($,T)=>$.proto===Date&&T.proto===Date?$.dateAllowsInvalid?T:$:wZ($.proto,T.proto)?$:wZ(T.proto,$.proto)?T:o.init("proto",$,T),domain:($,T)=>T.domain==="object"?$:o.init("domain",b.intrinsic.object.internal,T)}});class Dk extends iW{builtinName=jY(this.proto);serializedConstructor=this.json.proto;requiresInvalidDateCheck=this.proto===Date&&!this.dateAllowsInvalid;traverseAllows=this.requiresInvalidDateCheck?($)=>$ instanceof Date&&$.toString()!=="Invalid Date":($)=>$ instanceof this.proto;compiledCondition=`data instanceof ${this.serializedConstructor}${this.requiresInvalidDateCheck?' && data.toString() !== "Invalid Date"':""}`;compiledNegation=`!(${this.compiledCondition})`;innerToJsonSchema($){switch(this.builtinName){case"Array":return{type:"array"};case"Date":return $.fallback.date?.({code:"date",base:{}})??$.fallback.proto({code:"proto",base:{},proto:this.proto});default:return $.fallback.proto({code:"proto",base:{},proto:this.proto})}}expression=this.dateAllowsInvalid?"Date | InvalidDate":this.proto.name;get nestableExpression(){return this.dateAllowsInvalid?`(${this.expression})`:this.expression}domain="object";get defaultShortDescription(){return this.description}}var tY={implementation:Mh,Node:Dk,writeBadInvalidDateMessage:($)=>`dateAllowsInvalid may only be specified with constructor Date (was ${$.name})`,writeInvalidSchemaMessage:($)=>`instanceOf operand must be a function (was ${x4($)})`};var Nh=A$({kind:"union",hasAssociatedError:!0,collapsibleKey:"branches",keys:{ordered:{},branches:{child:!0,parse:($,T)=>{let W=[];for(let U of $){let X=s(U,"root")?U.branches:T.$.parseSchema(U).branches;for(let Y of X)if(Y.hasKind("morph")){let w=W.findIndex((G)=>G.hasKind("morph")&&G.hasEqualMorphs(Y));if(w===-1)W.push(Y);else{let G=W[w];W[w]=T.$.node("morph",{...G.inner,in:G.in.rawOr(Y.in)})}}else W.push(Y)}if(!T.def.ordered)W.sort((U,X)=>U.hash<X.hash?-1:1);return W}}},normalize:($)=>d$($)?{branches:$}:$,reduce:($,T)=>{let W=Sh($);if(W.length===1)return W[0];if(W.length===$.branches.length)return;return T.node("union",{...$,branches:W},{prereduced:!0})},defaults:{description:($)=>$.distribute((T)=>T.description,kU),expected:($)=>{let T=$R($.errors,"propString"),W=Object.entries(T).map(([U,X])=>{let Y=[];for(let H of X)F0(Y,H.expected);let w=kU(Y),G=X.every((H)=>H.actual===X[0].actual)?X[0].actual:E$(X[0].data);return`${U&&`${U} `}must be ${w}${G&&` (was ${G})`}`});return kU(W)},problem:($)=>$.expected,message:($)=>$.problem},intersections:{union:($,T,W)=>{if($.isNever!==T.isNever)return o.init("presence",$,T);let U;if($.ordered){if(T.ordered)B(Bh($.expression,T.expression));if(U=hZ(T.branches,$.branches,W),U instanceof o)U.invert()}else U=hZ($.branches,T.branches,W);if(U instanceof o)return U;return W.$.parseSchema($.ordered||T.ordered?{branches:U,ordered:!0}:{branches:U})},...Q0("union",($,T,W)=>{let U=hZ($.branches,[T],W);if(U instanceof o)return U;if(U.length===1)return U[0];return W.$.parseSchema($.ordered?{branches:U,ordered:!0}:{branches:U})})}});class Ek extends q1{isBoolean=this.branches.length===2&&this.branches[0].hasUnit(!1)&&this.branches[1].hasUnit(!0);get branchGroups(){let $=[],T=-1;for(let W of this.branches){if(W.hasKind("unit")&&W.domain==="boolean"){if(T===-1)T=$.length,$.push(W);else $[T]=b.intrinsic.boolean;continue}$.push(W)}return $}unitBranches=this.branches.filter(($)=>$.in.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?qh(this.discriminant):null;expression=this.distribute(($)=>$.nestableExpression,Ch);createBranchedOptimisticRootApply(){return($,T)=>{let W=this.traverseOptimistic($);if(W!==Q1)return W;let U=new u1($,this.$.resolvedConfig);return this.traverseApply($,U),U.finalize(T)}}get shallowMorphs(){return this.branches.reduce(($,T)=>F0($,T.shallowMorphs),[])}get defaultShortDescription(){return this.distribute(($)=>$.defaultShortDescription,kU)}innerToJsonSchema($){if(this.branchGroups.length===1&&this.branchGroups[0].equals(b.intrinsic.boolean))return{type:"boolean"};let T=this.branchGroups.map((W)=>W.toJsonSchemaRecurse($));if(T.every((W)=>Object.keys(W).length===1&&ZU(W,"const")))return{enum:T.map((W)=>W.const)};return{anyOf:T}}traverseAllows=($,T)=>this.branches.some((W)=>W.traverseAllows($,T));traverseApply=($,T)=>{let W=[];for(let U=0;U<this.branches.length;U++){if(T.pushBranch(),this.branches[U].traverseApply($,T),!T.hasError()){if(this.branches[U].includesTransform)return T.queuedMorphs.push(...T.popBranch().queuedMorphs);return T.popBranch()}W.push(T.popBranch().error)}T.errorFromNodeContext({code:"union",errors:W,meta:this.meta})};traverseOptimistic=($)=>{for(let T=0;T<this.branches.length;T++){let W=this.branches[T];if(W.traverseAllows($)){if(W.contextFreeMorph)return W.contextFreeMorph($);return $}}return Q1};compile($){if(!this.discriminant||this.unitBranches.length===this.branches.length&&this.branches.length===2)return this.compileIndiscriminable($);let T=this.discriminant.optionallyChainedPropString;if(this.discriminant.kind==="domain")T=`typeof ${T} === "object" ? ${T} === null ? "null" : "object" : typeof ${T} === "function" ? "object" : typeof ${T}`;let W=this.discriminant.cases,U=Object.keys(W),{optimistic:X}=$;if($.optimistic=!1,$.block(`switch(${T})`,()=>{for(let z in W){let F=W[z],O=z==="default"?z:`case ${z}`;$.line(`${O}: return ${F===!0?X?$.data:F:X?`${$.invoke(F)} ? ${F.contextFreeMorph?`${Z4(F.contextFreeMorph)}(${$.data})`:$.data} : "${Q1}"`:$.invoke(F)}`)}return $}),$.traversalKind==="Allows"){$.return(X?`"${Q1}"`:!1);return}let Y=kU(this.discriminant.kind==="domain"?U.map((z)=>{let F=z.slice(1,-1);return F==="function"?d6.object:d6[F]}):U),w=this.discriminant.path.map((z)=>typeof z==="symbol"?Z4(z):JSON.stringify(z)),G=JSON.stringify(Y),H=this.discriminant.kind==="domain"?`${kh}[${T}]`:`${vh}(${T})`;$.line(`ctx.errorFromNodeContext({
|
|
138
139
|
code: "predicate",
|
|
139
|
-
expected: ${
|
|
140
|
-
actual: ${
|
|
141
|
-
relativePath: [${
|
|
140
|
+
expected: ${G},
|
|
141
|
+
actual: ${H},
|
|
142
|
+
relativePath: [${w}],
|
|
142
143
|
meta: ${this.compiledMeta}
|
|
143
|
-
})`)}compileIndiscriminable($){if($.traversalKind==="Apply"){$.const("errors","[]");for(let T of this.branches)$.line("ctx.pushBranch()").line($.invoke(T)).if("!ctx.hasError()",()=>$.return(T.includesTransform?"ctx.queuedMorphs.push(...ctx.popBranch().queuedMorphs)":"ctx.popBranch()")).line("errors.push(ctx.popBranch().error)");$.line(`ctx.errorFromNodeContext({ code: "union", errors, meta: ${this.compiledMeta} })`)}else{let{optimistic:T}=$;$.optimistic=!1;for(let W of this.branches)$.if(`${$.invoke(W)}`,()=>$.return(T?W.contextFreeMorph?`${
|
|
144
|
+
})`)}compileIndiscriminable($){if($.traversalKind==="Apply"){$.const("errors","[]");for(let T of this.branches)$.line("ctx.pushBranch()").line($.invoke(T)).if("!ctx.hasError()",()=>$.return(T.includesTransform?"ctx.queuedMorphs.push(...ctx.popBranch().queuedMorphs)":"ctx.popBranch()")).line("errors.push(ctx.popBranch().error)");$.line(`ctx.errorFromNodeContext({ code: "union", errors, meta: ${this.compiledMeta} })`)}else{let{optimistic:T}=$;$.optimistic=!1;for(let W of this.branches)$.if(`${$.invoke(W)}`,()=>$.return(T?W.contextFreeMorph?`${Z4(W.contextFreeMorph)}(${$.data})`:$.data:!0));$.return(T?`"${Q1}"`:!1)}}get nestableExpression(){return this.isBoolean?"boolean":`(${this.expression})`}discriminate(){if(this.branches.length<2||this.isCyclic)return null;if(this.unitBranches.length===this.branches.length){let X=K$(this.unitBranches,(Y,w)=>[`${w.in.serializedValue}`,w.hasKind("morph")?w:!0]);return{kind:"unit",path:[],optionallyChainedPropString:"data",cases:X}}let $=[];for(let X=0;X<this.branches.length-1;X++){let Y=this.branches[X];for(let w=X+1;w<this.branches.length;w++){let G=this.branches[w],H=r6(Y.in,G.in,Y.$);if(!(H instanceof o))continue;for(let z of H){if(!z.kind||z.optional)continue;let F,O;if(z.kind==="domain"){let{l:Z,r:V}=z;F=`"${typeof Z==="string"?Z:Z.domain}"`,O=`"${typeof V==="string"?V:V.domain}"`}else if(z.kind==="unit")F=z.l.serializedValue,O=z.r.serializedValue;else continue;let Q=$.find((Z)=>i0(Z.path,z.path)&&Z.kind===z.kind);if(!Q)$.push({kind:z.kind,cases:{[F]:{branchIndices:[X],condition:z.l},[O]:{branchIndices:[w],condition:z.r}},path:z.path});else{if(Q.cases[F])Q.cases[F].branchIndices=F0(Q.cases[F].branchIndices,X);else Q.cases[F]??={branchIndices:[X],condition:z.l};if(Q.cases[O])Q.cases[O].branchIndices=F0(Q.cases[O].branchIndices,w);else Q.cases[O]??={branchIndices:[w],condition:z.r}}}}}let T=this.ordered?_h($,this.branches):$;if(!T.length)return null;let W=Lh(T,this),U={};for(let X in W.best.cases){let Y=Jh(W,X);if(Y===null){U[X]=!0;continue}if(Y.length===this.branches.length)return null;if(this.ordered)Y.sort((H,z)=>H.originalIndex-z.originalIndex);let w=Y.map((H)=>H.branch),G=w.length===1?w[0]:this.$.node("union",this.ordered?{branches:w,ordered:!0}:w);Object.assign(this.referencesById,G.referencesById),U[X]=G}if(W.defaultEntries.length){let X=W.defaultEntries.map((Y)=>Y.branch);U.default=this.$.node("union",this.ordered?{branches:X,ordered:!0}:X,{prereduced:!0}),Object.assign(this.referencesById,U.default.referencesById)}return Object.assign(W.location,{cases:U})}}var Lh=($,T)=>{let W=$.sort((Y,w)=>Object.keys(w.cases).length-Object.keys(Y.cases).length)[0],U={kind:W.kind,path:W.path,optionallyChainedPropString:Ak(W.path)},X=T.branches.map((Y,w)=>({originalIndex:w,branch:Y}));return{best:W,location:U,defaultEntries:X,node:T}},Jh=($,T)=>{let W=$.best.cases[T],U=Rh(W.condition,$.location.path,$.node.$),X=[],Y=[];for(let w=0;w<$.defaultEntries.length;w++){let G=$.defaultEntries[w];if(W.branchIndices.includes(G.originalIndex)){let H=Vk($.node.branches[G.originalIndex],$.location);if(H===null)X=null;else X?.push({originalIndex:G.originalIndex,branch:H})}else if(G.branch.hasKind("alias")&&U.hasKind("domain")&&U.domain==="object")X?.push(G);else{if(G.branch.in.overlaps(U)){let H=Vk(G.branch,$.location);X?.push({originalIndex:G.originalIndex,branch:H})}Y.push(G)}}return $.defaultEntries=Y,X},_h=($,T)=>{return $.filter((U)=>{let X=Object.values(U.cases).map((Y)=>Y.branchIndices);for(let Y=0;Y<X.length-1;Y++){let w=X[Y];for(let G=Y+1;G<X.length;G++){let H=X[G];for(let z of w)for(let F of H)if(z>F){if(T[z].overlaps(T[F]))return!1}}}return!0})},Rh=($,T,W)=>{let U=$==="undefined"?W.node("unit",{unit:void 0}):$==="null"?W.node("unit",{unit:null}):$==="boolean"?W.units([!0,!1]):$;for(let X=T.length-1;X>=0;X--){let Y=T[X];U=W.node("intersection",typeof Y==="number"?{proto:"Array",sequence:[...s_(Y).map((w)=>({})),U]}:{domain:"object",required:[{key:Y,value:U}]})}return U},Ak=($)=>$.reduce((T,W)=>T+ZZ(W,!0),"data"),kh=Z4(TR),vh=Z4(E$),gZ={implementation:Nh,Node:Ek},qh=($)=>({kind:$.kind,path:$.path.map((T)=>typeof T==="string"?T:s0(T)),cases:K$($.cases,(T,W)=>[T,W===!0?W:W.hasKind("union")&&W.discriminantJson?W.discriminantJson:W.json])}),Ph={delimiter:" | ",finalDelimiter:" | "},Ch=($)=>kU($,Ph),kU=($,T)=>{let W=T?.delimiter??", ",U=T?.finalDelimiter??" or ";if($.length===0)return"never";if($.length===1)return $[0];if($.length===2&&$[0]==="false"&&$[1]==="true"||$[0]==="true"&&$[1]==="false")return"boolean";let X={},Y=$.filter((G)=>X[G]?!1:X[G]=!0),w=Y.pop();return`${Y.join(W)}${Y.length?U:""}${w}`},hZ=($,T,W)=>{let U=T.map(()=>[]);for(let Y=0;Y<$.length;Y++){let w={};for(let G=0;G<T.length;G++){if(U[G]===null)continue;if($[Y].equals(T[G])){U[G]=null,w={};break}let H=a$($[Y],T[G],W);if(H instanceof o)continue;if(H.equals($[Y])){U[G].push($[Y]),w={};break}if(H.equals(T[G]))U[G]=null;else w[G]=H}for(let G in w)U[G][Y]=w[G]}let X=U.flatMap((Y,w)=>Y?.flatMap((G)=>G.branches)??T[w]);return X.length===0?o.init("union",$,T):X},Sh=({branches:$,ordered:T})=>{if($.length<2)return $;let W=$.map(()=>!0);for(let U=0;U<$.length;U++)for(let X=U+1;X<$.length&&W[U]&&W[X];X++){if($[U].equals($[X])){W[X]=!1;continue}let Y=r6($[U].in,$[X].in,$[0].$);if(Y instanceof o)continue;if(!T)jh($[U],$[X]);if(Y.equals($[U].in))W[U]=!!T;else if(Y.equals($[X].in))W[X]=!1}return $.filter((U,X)=>W[X])},jh=($,T)=>{if(!$.includesTransform&&!T.includesTransform)return;if(!i0($.shallowMorphs,T.shallowMorphs))B(Kk($.expression,T.expression));if(!i0($.flatMorphs,T.flatMorphs,{isEqual:(W,U)=>W.propString===U.propString&&(W.node.hasKind("morph")&&U.node.hasKind("morph")?W.node.hasEqualMorphs(U.node):W.node.hasKind("intersection")&&U.node.hasKind("intersection")?W.node.structure?.structuralMorphRef===U.node.structure?.structuralMorphRef:!1)}))B(Kk($.expression,T.expression))},Vk=($,T)=>$.transform((W,U)=>{if(W==="domain"||W==="unit")return null;return U},{shouldTransform:(W,U)=>{let X=Ak(U.path);if(!T.optionallyChainedPropString.startsWith(X))return!1;if(W.hasKind("domain")&&W.domain==="object")return!0;if((W.hasKind("domain")||T.kind==="unit")&&X===T.optionallyChainedPropString)return!0;return W.children.length!==0&&W.kind!=="index"}}),Kk=($,T)=>`An unordered union of a type including a morph and a type with overlapping input is indeterminate:
|
|
144
145
|
Left: ${$}
|
|
145
|
-
Right: ${T}`,
|
|
146
|
+
Right: ${T}`,Bh=($,T)=>`The intersection of two ordered unions is indeterminate:
|
|
146
147
|
Left: ${$}
|
|
147
|
-
Right: ${T}`;var CP=G$({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:($)=>$ instanceof Date?$.toISOString():H6($)}},normalize:($)=>$,defaults:{description:($)=>U$($.unit),problem:({expected:$,actual:T})=>`${$===T?`must be reference equal to ${$} (serialized to the same value)`:`must be ${$} (was ${T})`}`},intersections:{unit:($,T)=>f.init("unit",$,T),...c6("unit",($,T)=>{if(T.allows($.unit))return $;let W=T.hasKind("intersection")?T.basis:T;if(W){let X=W.hasKind("domain")?W:I.intrinsic.object;if($.domain!==X.domain){let Y=$.domain==="undefined"||$.domain==="null"||$.domain==="boolean"?$.domain:I.intrinsic[$.domain];return f.init("domain",Y,X)}}return f.init("assignability",$,T.hasKind("intersection")?T.children.find((X)=>!X.allows($.unit)):T)})}});class KK extends y0{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=VK(this.unit,this.serializedValue);compiledNegation=VK(this.unit,this.serializedValue,"negated");expression=U$(this.unit);domain=w4(this.unit);get defaultShortDescription(){return this.domain==="object"?u4.object:this.description}innerToJsonSchema($){return this.unit===null?{type:"null"}:I.intrinsic.jsonPrimitive.allows(this.unit)?{const:this.unit}:$.fallback.unit({code:"unit",base:{},unit:this.unit})}traverseAllows=this.unit instanceof Date?($)=>$ instanceof Date&&$.toISOString()===this.compiledValue:Number.isNaN(this.unit)?($)=>Number.isNaN($):($)=>$===this.unit}var p_={implementation:CP,Node:KK},VK=($,T,W)=>{if($ instanceof Date){let X=`data instanceof Date && data.toISOString() === ${T}`;return W?`!(${X})`:X}if(Number.isNaN($))return`${W?"!":""}Number.isNaN(data)`;return`data ${W?"!":"="}== ${T}`};var vP=G$({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:($,T)=>{let W=T.$.parseSchema($);if(!W.extends(I.intrinsic.key))return L(xP(W.expression));let X=W.branches.filter((Y)=>Y.hasKind("unit"));if(X.length)return L(jP(X.map((Y)=>U$(Y.unit))));return W}},value:{child:!0,parse:($,T)=>T.$.parseSchema($)}},normalize:($)=>$,defaults:{description:($)=>`[${$.signature.expression}]: ${$.value.description}`},intersections:{index:($,T,W)=>{if($.signature.equals(T.signature)){let X=j$($.value,T.value,W),Y=X instanceof f?I.intrinsic.never.internal:X;return W.$.node("index",{signature:$.signature,value:Y})}if($.signature.extends(T.signature)&&$.value.subsumes(T.value))return T;if(T.signature.extends($.signature)&&T.value.subsumes($.value))return $;return null}}});class EK extends F6{impliedBasis=I.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=Q$(this.value.flatRefs.map(($)=>R6([this.signature,...$.path],$.node)),R6([this.signature],this.value));traverseAllows=($,T)=>j0($).every((W)=>{if(this.signature.traverseAllows(W[0],T))return d4(W[0],()=>this.value.traverseAllows(W[1],T),T);return!0});traverseApply=($,T)=>{for(let W of j0($))if(this.signature.traverseAllows(W[0],T))d4(W[0],()=>this.value.traverseApply(W[1],T),T)};_transform($,T){T.path.push(this.signature);let W=super._transform($,T);return T.path.pop(),W}compile(){}}var d_={implementation:vP,Node:EK},jP=($)=>`Index keys ${$.join(", ")} should be specified as named props.`,xP=($)=>`Indexed key definition '${$}' must be a string or symbol`;var bP=G$({kind:"required",hasAssociatedError:!0,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:($,T)=>T.$.parseSchema($)}},normalize:($)=>$,defaults:{description:($)=>`${$.compiledKey}: ${$.value.description}`,expected:($)=>$.missingValueDescription,actual:()=>"missing"},intersections:{required:AX,optional:AX}});class MK extends NX{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=d1(this.errorContext)}var o_={implementation:bP,Node:MK};var fP=G$({kind:"sequence",hasAssociatedError:!1,collapsibleKey:"variadic",keys:{prefix:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}},optionals:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}},defaultables:{child:($)=>$.map((T)=>T[0]),parse:($,T)=>{if($.length===0)return;return $.map((W)=>{let X=T.$.parseSchema(W[0]);return SX(X,W[1],null),[X,W[1]]})},serialize:($)=>$.map((T)=>[T[0].collapsibleJson,H6(T[1])])},variadic:{child:!0,parse:($,T)=>T.$.parseSchema($,T)},minVariadicLength:{parse:($)=>$===0?void 0:$},postfix:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}}},normalize:($)=>{if(typeof $==="string")return{variadic:$};if("variadic"in $||"prefix"in $||"defaultables"in $||"optionals"in $||"postfix"in $||"minVariadicLength"in $){if($.postfix?.length){if(!$.variadic)return L(mP);if($.optionals?.length||$.defaultables?.length)return L(r_)}if($.minVariadicLength&&!$.variadic)return L("minVariadicLength may not be specified without a variadic element");return $}return{variadic:$}},reduce:($,T)=>{let W=$.minVariadicLength??0,X=$.prefix?.slice()??[],Y=$.defaultables?.slice()??[],U=$.optionals?.slice()??[],G=$.postfix?.slice()??[];if($.variadic){while(U.at(-1)?.equals($.variadic))U.pop();if(U.length===0&&Y.length===0)while(X.at(-1)?.equals($.variadic))X.pop(),W++;while(G[0]?.equals($.variadic))G.shift(),W++}else if(U.length===0&&Y.length===0)X.push(...G.splice(0));if(W!==$.minVariadicLength||$.prefix&&$.prefix.length!==X.length)return T.node("sequence",{...$,prefix:X,defaultables:Y,optionals:U,postfix:G,minVariadicLength:W},{prereduced:!0})},defaults:{description:($)=>{if($.isVariadicOnly)return`${$.variadic.nestableExpression}[]`;return`[${$.tuple.map((W)=>W.kind==="defaultables"?`${W.node.nestableExpression} = ${U$(W.default)}`:W.kind==="optionals"?`${W.node.nestableExpression}?`:W.kind==="variadic"?`...${W.node.nestableExpression}[]`:W.node.expression).join(", ")}]`}},intersections:{sequence:($,T,W)=>{let X=kX({l:$.tuple,r:T.tuple,disjoint:new f,result:[],fixedVariants:[],ctx:W}),Y=X.disjoint.length===0?[X,...X.fixedVariants]:X.fixedVariants;return Y.length===0?X.disjoint:Y.length===1?W.$.node("sequence",AK(Y[0].result)):W.$.node("union",Y.map((U)=>({proto:Array,sequence:AK(U.result)})))}}});class NK extends F6{impliedBasis=I.intrinsic.Array.internal;tuple=gP(this.inner);prefixLength=this.prefix?.length??0;defaultablesLength=this.defaultables?.length??0;optionalsLength=this.optionals?.length??0;postfixLength=this.postfix?.length??0;defaultablesAndOptionals=[];prevariadic=this.tuple.filter(($)=>{if($.kind==="defaultables"||$.kind==="optionals")return this.defaultablesAndOptionals.push($.node),!0;return $.kind==="prefix"});variadicOrPostfix=w1(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return M_(this.flatRefs,this.prevariadic.flatMap(($,T)=>Q$($.node.flatRefs.map((W)=>R6([`${T}`,...W.path],W.node)),R6([`${T}`],$.node)))),M_(this.flatRefs,this.variadicOrPostfix.flatMap(($)=>Q$($.flatRefs.map((T)=>R6([I.intrinsic.nonNegativeIntegerString.internal,...T.path],T.node)),R6([I.intrinsic.nonNegativeIntegerString.internal],$)))),this.flatRefs}isVariadicOnly=this.prevariadic.length+this.postfixLength===0;minVariadicLength=this.inner.minVariadicLength??0;minLength=this.prefixLength+this.minVariadicLength+this.postfixLength;minLengthNode=this.minLength===0?null:this.$.node("minLength",this.minLength);maxLength=this.variadic?null:this.tuple.length;maxLengthNode=this.maxLength===null?null:this.$.node("maxLength",this.maxLength);impliedSiblings=this.minLengthNode?this.maxLengthNode?[this.minLengthNode,this.maxLengthNode]:[this.minLengthNode]:this.maxLengthNode?[this.maxLengthNode]:[];defaultValueMorphs=hP(this);defaultValueMorphsReference=this.defaultValueMorphs.length?d$(this.defaultValueMorphs):void 0;elementAtIndex($,T){if(T<this.prevariadic.length)return this.tuple[T];let W=$.length-this.postfixLength;if(T>=W)return{kind:"postfix",node:this.postfix[T-W]};return{kind:"variadic",node:this.variadic??O$(`Unexpected attempt to access index ${T} on ${this}`)}}traverseAllows=($,T)=>{for(let W=0;W<$.length;W++)if(!this.elementAtIndex($,W).node.traverseAllows($[W],T))return!1;return!0};traverseApply=($,T)=>{let W=0;for(;W<$.length;W++)d4(W,()=>this.elementAtIndex($,W).node.traverseApply($[W],T),T)};get element(){return this.cacheGetter("element",this.$.node("union",this.children))}compile($){if(this.prefix)for(let[T,W]of this.prefix.entries())$.traverseKey(`${T}`,`data[${T}]`,W);for(let[T,W]of this.defaultablesAndOptionals.entries()){let X=`${T+this.prefixLength}`;$.if(`${X} >= ${$.data}.length`,()=>$.traversalKind==="Allows"?$.return(!0):$.return()),$.traverseKey(X,`data[${X}]`,W)}if(this.variadic){if(this.postfix)$.const("firstPostfixIndex",`${$.data}.length${this.postfix?`- ${this.postfix.length}`:""}`);if($.for(`i < ${this.postfix?"firstPostfixIndex":"data.length"}`,()=>$.traverseKey("i","data[i]",this.variadic),this.prevariadic.length),this.postfix)for(let[T,W]of this.postfix.entries()){let X=`firstPostfixIndex + ${T}`;$.traverseKey(X,`data[${X}]`,W)}}if($.traversalKind==="Allows")$.return(!0)}_transform($,T){T.path.push(I.intrinsic.nonNegativeIntegerString.internal);let W=super._transform($,T);return T.path.pop(),W}expression=this.description;reduceJsonSchema($,T){if(this.prevariadic.length)$.prefixItems=this.prevariadic.map((W)=>{let X=W.node.toJsonSchemaRecurse(T);if(W.kind==="defaultables"){let Y=typeof W.default==="function"?W.default():W.default;X.default=I.intrinsic.jsonData.allows(Y)?Y:T.fallback.defaultValue({code:"defaultValue",base:X,value:Y})}return X});if(this.minLength)$.minItems=this.minLength;if(this.variadic){let W=Object.assign($,{items:this.variadic.toJsonSchemaRecurse(T)});if(this.maxLength)W.maxItems=this.maxLength;if(this.postfix){let X=this.postfix.map((Y)=>Y.toJsonSchemaRecurse(T));$=T.fallback.arrayPostfix({code:"arrayPostfix",base:W,elements:X})}}else $.items=!1,delete $.maxItems;return $}}var yP={},hP=($)=>{if(!$.defaultables)return[];let T=[],W="[",X=$.prefixLength+$.defaultablesLength-1;for(let Y=$.prefixLength;Y<=X;Y++){let[U,G]=$.defaultables[Y-$.prefixLength];T.push(h_(Y,U,G)),W+=`${Y}: ${U.id} = ${H6(G)}, `}return W+="]",yP[W]??=T},l_={implementation:fP,Node:NK},gP=($)=>{let T=[];if($.prefix)for(let W of $.prefix)T.push({kind:"prefix",node:W});if($.defaultables)for(let[W,X]of $.defaultables)T.push({kind:"defaultables",node:W,default:X});if($.optionals)for(let W of $.optionals)T.push({kind:"optionals",node:W});if($.variadic)T.push({kind:"variadic",node:$.variadic});if($.postfix)for(let W of $.postfix)T.push({kind:"postfix",node:W});return T},AK=($)=>$.reduce((T,W)=>{if(W.kind==="variadic")T.variadic=W.node;else if(W.kind==="defaultables")T.defaultables=Q$(T.defaultables,[[W.node,W.default]]);else T[W.kind]=Q$(T[W.kind],W.node);return T},{}),r_="A postfix required element cannot follow an optional or defaultable element",mP="A postfix element requires a variadic element",kX=($)=>{let[T,...W]=$.l,[X,...Y]=$.r;if(!T||!X)return $;let U=W.at(-1)?.kind==="postfix",G=Y.at(-1)?.kind==="postfix",J=T.kind==="prefix"||X.kind==="prefix"?"prefix":T.kind==="postfix"||X.kind==="postfix"?"postfix":T.kind==="variadic"&&X.kind==="variadic"?"variadic":U||G?"prefix":T.kind==="defaultables"||X.kind==="defaultables"?"defaultables":"optionals";if(T.kind==="prefix"&&X.kind==="variadic"&&G){let _=kX({...$,fixedVariants:[],r:Y.map((F)=>({...F,kind:"prefix"}))});if(_.disjoint.length===0)$.fixedVariants.push(_)}else if(X.kind==="prefix"&&T.kind==="variadic"&&U){let _=kX({...$,fixedVariants:[],l:W.map((F)=>({...F,kind:"prefix"}))});if(_.disjoint.length===0)$.fixedVariants.push(_)}let z=j$(T.node,X.node,$.ctx);if(z instanceof f)if(J==="prefix"||J==="postfix")$.disjoint.push(...z.withPrefixKey(J==="prefix"?$.result.length:`-${W.length+1}`,"required")),$.result=[...$.result,{kind:J,node:I.intrinsic.never.internal}];else if(J==="optionals"||J==="defaultables")return $;else return kX({...$,fixedVariants:[],l:W.map((_)=>({..._,kind:"prefix"})),r:W.map((_)=>({..._,kind:"prefix"}))});else if(J==="defaultables"){if(T.kind==="defaultables"&&X.kind==="defaultables"&&T.default!==X.default)L(y_(T.default,X.default));$.result=[...$.result,{kind:J,node:z,default:T.kind==="defaultables"?T.default:X.kind==="defaultables"?X.default:O$(`Unexpected defaultable intersection from ${T.kind} and ${X.kind} elements.`)}]}else $.result=[...$.result,{kind:J,node:z}];let w=$.l.length,H=$.r.length;if(T.kind!=="variadic"||w>=H&&(X.kind==="variadic"||H===1))$.l=W;if(X.kind!=="variadic"||H>=w&&(T.kind==="variadic"||w===1))$.r=Y;return kX($)};var BK=($)=>(T)=>{if(T.props.length||T.index){let W=T.index?.map((Y)=>Y[$])??[];for(let Y of T.props)W.push(Y[$]);if(T.undeclared)W.push(`+ (undeclared): ${T.undeclared}`);let X=`{ ${W.join(", ")} }`;return T.sequence?`${X} & ${T.sequence.description}`:X}return T.sequence?.description??"{}"},cP=BK("description"),uP=BK("expression"),LK=($,T,W)=>{let X=$.required?"required":"optional";if(!T.signature.allows($.key))return null;let Y=o4($.value,T.value,W);if(Y instanceof f)return X==="optional"?W.node("optional",{key:$.key,value:I.intrinsic.never.internal}):Y.withPrefixKey($.key,$.kind);return null},pP=G$({kind:"structure",hasAssociatedError:!1,normalize:($)=>$,applyConfig:($,T)=>{if(!$.undeclared&&T.onUndeclaredKey!=="ignore")return{...$,undeclared:T.onUndeclaredKey};return $},keys:{required:{child:!0,parse:S4("required"),reduceIo:($,T,W)=>{T.required=Q$(T.required,W.map((X)=>X[$]));return}},optional:{child:!0,parse:S4("optional"),reduceIo:($,T,W)=>{if($==="in"){T.optional=W.map((X)=>X.in);return}for(let X of W)T[X.outProp.kind]=Q$(T[X.outProp.kind],X.outProp.out)}},index:{child:!0,parse:S4("index")},sequence:{child:!0,parse:S4("sequence")},undeclared:{parse:($)=>$==="ignore"?void 0:$,reduceIo:($,T,W)=>{if(W!=="delete")return;if($==="in")delete T.undeclared;else T.undeclared="reject"}}},defaults:{description:cP},intersections:{structure:($,T,W)=>{let X={...$.inner},Y={...T.inner},U=new f;if($.undeclared){let z=$.keyof();for(let w of T.requiredKeys)if(!z.allows(w))U.add("presence",I.intrinsic.never.internal,T.propsByKey[w].value,{path:[w]});if(Y.optional)Y.optional=Y.optional.filter((w)=>z.allows(w.key));if(Y.index)Y.index=Y.index.flatMap((w)=>{if(w.signature.extends(z))return w;let H=o4(z,w.signature,W.$);if(H instanceof f)return[];let _=LU(H,w.value,W.$);if(_.required)Y.required=w1(Y.required,_.required);if(_.optional)Y.optional=w1(Y.optional,_.optional);return _.index??[]})}if(T.undeclared){let z=T.keyof();for(let w of $.requiredKeys)if(!z.allows(w))U.add("presence",$.propsByKey[w].value,I.intrinsic.never.internal,{path:[w]});if(X.optional)X.optional=X.optional.filter((w)=>z.allows(w.key));if(X.index)X.index=X.index.flatMap((w)=>{if(w.signature.extends(z))return w;let H=o4(z,w.signature,W.$);if(H instanceof f)return[];let _=LU(H,w.value,W.$);if(_.required)X.required=w1(X.required,_.required);if(_.optional)X.optional=w1(X.optional,_.optional);return _.index??[]})}let G={};if($.undeclared||T.undeclared)G.undeclared=$.undeclared==="reject"||T.undeclared==="reject"?"reject":"delete";let J=mT({kind:"structure",baseInner:G,l:cT(X),r:cT(Y),roots:[],ctx:W});if(J instanceof f)U.push(...J);if(U.length)return U;return J}},reduce:($,T)=>{if($.index){if(!($.required||$.optional))return;let W=!1,X=$.required??[],Y=$.optional??[],U=[...Y];for(let G of $.index){for(let J of X){let z=LK(J,G,T);if(z instanceof f)return z}for(let[J,z]of Y.entries()){let w=LK(z,G,T);if(w instanceof f)return w;if(w===null)continue;U[J]=w,W=!0}}if(W)return T.node("structure",{...$,optional:U},{prereduced:!0})}}});class RK extends F6{impliedBasis=I.intrinsic.object.internal;impliedSiblings=this.children.flatMap(($)=>$.impliedSiblings??[]);props=w1(this.required,this.optional);propsByKey=Y$(this.props,($,T)=>[T.key,T]);propsByKeyReference=d$(this.propsByKey);expression=uP(this);requiredKeys=this.required?.map(($)=>$.key)??[];optionalKeys=this.optional?.map(($)=>$.key)??[];literalKeys=[...this.requiredKeys,...this.optionalKeys];_keyof;keyof(){if(this._keyof)return this._keyof;let $=this.$.units(this.literalKeys).branches;if(this.index)for(let{signature:T}of this.index)$=$.concat(T.branches);return this._keyof=this.$.node("union",$)}map($){return this.$.node("structure",this.props.flatMap($).reduce((T,W)=>{let X=this.propsByKey[W.key];if(v$(W)){if(W.kind!=="required"&&W.kind!=="optional")return L(`Map result must have kind "required" or "optional" (was ${W.kind})`);return T[W.kind]=Q$(T[W.kind],W),T}let Y=W.kind??X?.kind??"required",U=Y$(W,(G,J)=>(G in LX.implementation.keys)?[G,J]:[]);return T[Y]=Q$(T[Y],this.$.node(Y,U)),T},{}))}assertHasKeys($){let T=$.filter((W)=>!BX(W,this.keyof()));if(T.length)return L(SK(this.expression,T))}get($,...T){let W,X=!1,Y=rP($);if((typeof Y==="string"||typeof Y==="symbol")&&this.propsByKey[Y])W=this.propsByKey[Y].value,X=this.propsByKey[Y].required;if(this.index){for(let G of this.index)if(BX(Y,G.signature))W=W?.and(G.value)??G.value}if(this.sequence&&BX(Y,I.intrinsic.nonNegativeIntegerString))if(o(Y,"root")){if(this.sequence.variadic)W=W?.and(this.sequence.element)??this.sequence.element}else{let G=Number.parseInt(Y);if(G<this.sequence.prevariadic.length){let J=this.sequence.prevariadic[G].node;W=W?.and(J)??J,X||=G<this.sequence.prefixLength}else if(this.sequence.variadic){let J=this.$.node("union",this.sequence.variadicOrPostfix);W=W?.and(J)??J}}if(!W){if(this.sequence?.variadic&&o(Y,"root")&&Y.extends(I.intrinsic.number))return L(iP(Y.expression,this.sequence.expression));return L(SK(this.expression,[Y]))}let U=W.get(...T);return X?U:U.or(I.intrinsic.undefined)}pick(...$){return this.assertHasKeys($),this.$.node("structure",this.filterKeys("pick",$))}omit(...$){return this.assertHasKeys($),this.$.node("structure",this.filterKeys("omit",$))}optionalize(){let{required:$,...T}=this.inner;return this.$.node("structure",{...T,optional:this.props.map((W)=>W.hasKind("required")?this.$.node("optional",W.inner):W)})}require(){let{optional:$,...T}=this.inner;return this.$.node("structure",{...T,required:this.props.map((W)=>W.hasKind("optional")?{key:W.key,value:W.value}:W)})}merge($){let T=this.filterKeys("omit",[$.keyof()]);if($.required)T.required=Q$(T.required,$.required);if($.optional)T.optional=Q$(T.optional,$.optional);if($.index)T.index=Q$(T.index,$.index);if($.sequence)T.sequence=$.sequence;if($.undeclared)T.undeclared=$.undeclared;else delete T.undeclared;return this.$.node("structure",T)}filterKeys($,T){let W=FU(this.inner),X=(Y)=>{let U=T.some((G)=>BX(Y,G));return $==="pick"?U:!U};if(W.required)W.required=W.required.filter((Y)=>X(Y.key));if(W.optional)W.optional=W.optional.filter((Y)=>X(Y.key));if(W.index)W.index=W.index.filter((Y)=>X(Y.signature));return W}traverseAllows=($,T)=>this._traverse("Allows",$,T);traverseApply=($,T)=>this._traverse("Apply",$,T);_traverse=($,T,W)=>{let X=W?.currentErrorCount??0;for(let Y=0;Y<this.props.length;Y++)if($==="Allows"){if(!this.props[Y].traverseAllows(T,W))return!1}else if(this.props[Y].traverseApply(T,W),W.failFast&&W.currentErrorCount>X)return!1;if(this.sequence){if($==="Allows"){if(!this.sequence.traverseAllows(T,W))return!1}else if(this.sequence.traverseApply(T,W),W.failFast&&W.currentErrorCount>X)return!1}if(this.index||this.undeclared==="reject"){let Y=Object.keys(T);Y.push(...Object.getOwnPropertySymbols(T));for(let U=0;U<Y.length;U++){let G=Y[U];if(this.index){for(let J of this.index)if(J.signature.traverseAllows(G,W)){if($==="Allows"){if(!d4(G,()=>J.value.traverseAllows(T[G],W),W))return!1}else if(d4(G,()=>J.value.traverseApply(T[G],W),W),W.failFast&&W.currentErrorCount>X)return!1}}if(this.undeclared==="reject"&&!this.declaresKey(G)){if($==="Allows")return!1;if(W.errorFromNodeContext({code:"predicate",expected:"removed",actual:"",relativePath:[G],meta:this.meta}),W.failFast)return!1}}}if(this.structuralMorph&&W&&!W.hasError())W.queueMorphs([this.structuralMorph]);return!0};get defaultable(){return this.cacheGetter("defaultable",this.optional?.filter(($)=>$.hasDefault())??[])}declaresKey=($)=>($ in this.propsByKey)||this.index?.some((T)=>T.signature.allows($))||this.sequence!==void 0&&I.intrinsic.nonNegativeIntegerString.allows($);_compileDeclaresKey($){let T=[];if(this.props.length)T.push(`k in ${this.propsByKeyReference}`);if(this.index)for(let W of this.index)T.push($.invoke(W.signature,{kind:"Allows",arg:"k"}));if(this.sequence)T.push("$ark.intrinsic.nonNegativeIntegerString.allows(k)");return T.join(" || ")||"false"}get structuralMorph(){return this.cacheGetter("structuralMorph",oP(this))}structuralMorphRef=this.structuralMorph&&d$(this.structuralMorph);compile($){if($.traversalKind==="Apply")$.initializeErrorCount();for(let T of this.props)if($.check(T),$.traversalKind==="Apply")$.returnIfFailFast();if(this.sequence){if($.check(this.sequence),$.traversalKind==="Apply")$.returnIfFailFast()}if(this.index||this.undeclared==="reject")$.const("keys","Object.keys(data)"),$.line("keys.push(...Object.getOwnPropertySymbols(data))"),$.for("i < keys.length",()=>this.compileExhaustiveEntry($));if($.traversalKind==="Allows")return $.return(!0);if(this.structuralMorphRef)$.if("ctx && !ctx.hasError()",()=>{return $.line("ctx.queueMorphs(["),lP($,this),$.line("])")})}compileExhaustiveEntry($){if($.const("k","keys[i]"),this.index)for(let T of this.index)$.if(`${$.invoke(T.signature,{arg:"k",kind:"Allows"})}`,()=>$.traverseKey("k","data[k]",T.value));if(this.undeclared==="reject")$.if(`!(${this._compileDeclaresKey($)})`,()=>{if($.traversalKind==="Allows")return $.return(!1);return $.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if("ctx.failFast",()=>$.return())});return $}reduceJsonSchema($,T){switch($.type){case"object":return this.reduceObjectJsonSchema($,T);case"array":let W=this.sequence?.reduceJsonSchema($,T)??$;if(this.props.length||this.index)return T.fallback.arrayObject({code:"arrayObject",base:W,object:this.reduceObjectJsonSchema({type:"object"},T)});return W;default:return y$.throwInternalOperandError("structure",$)}}reduceObjectJsonSchema($,T){if(this.props.length){$.properties={};for(let W of this.props){let X=W.value.toJsonSchemaRecurse(T);if(typeof W.key==="symbol"){T.fallback.symbolKey({code:"symbolKey",base:$,key:W.key,value:X,optional:W.optional});continue}if(W.hasDefault()){let Y=typeof W.default==="function"?W.default():W.default;X.default=I.intrinsic.jsonData.allows(Y)?Y:T.fallback.defaultValue({code:"defaultValue",base:X,value:Y})}$.properties[W.key]=X}if(this.requiredKeys.length&&$.properties)$.required=this.requiredKeys.filter((W)=>typeof W==="string"&&(W in $.properties))}if(this.index)for(let W of this.index){let X=W.value.toJsonSchemaRecurse(T);if(W.signature.equals(I.intrinsic.string)){$.additionalProperties=X;continue}for(let Y of W.signature.branches){if(!Y.extends(I.intrinsic.string)){$=T.fallback.symbolKey({code:"symbolKey",base:$,key:null,value:X,optional:!1});continue}let U={type:"string"};if(Y.hasKind("morph"))U=T.fallback.morph({code:"morph",base:Y.in.toJsonSchemaRecurse(T),out:Y.out.toJsonSchemaRecurse(T)});if(!Y.hasKind("intersection"))return O$(`Unexpected index branch kind ${Y.kind}.`);let{pattern:G}=Y.inner;if(G){let J=Object.assign(U,{pattern:G[0].rule});for(let z=1;z<G.length;z++)U=T.fallback.patternIntersection({code:"patternIntersection",base:J,pattern:G[z].rule});$.patternProperties??={},$.patternProperties[J.pattern]=X}}}if(this.undeclared&&!$.additionalProperties)$.additionalProperties=!1;return $}}var i_={},dP=($)=>{let T="";for(let W=0;W<$.defaultable.length;W++)T+=$.defaultable[W].defaultValueMorphRef;if($.sequence?.defaultValueMorphsReference)T+=$.sequence?.defaultValueMorphsReference;if($.undeclared==="delete"){if(T+="delete !(",$.required)for(let W of $.required)T+=W.compiledKey+" | ";if($.optional)for(let W of $.optional)T+=W.compiledKey+" | ";if($.index)for(let W of $.index)T+=W.signature.id+" | ";if($.sequence)if($.sequence.maxLength===null)T+=n.nonNegativeIntegerString.id;else for(let W=0;W<$.sequence.tuple.length;W++)T+=W+" | ";T+=")"}return T},oP=($)=>{let T=dP($);if(!T)return;if(i_[T])return i_[T];let W=(X,Y)=>{for(let U=0;U<$.defaultable.length;U++)if(!($.defaultable[U].key in X))$.defaultable[U].defaultValueMorph(X,Y);if($.sequence?.defaultables)for(let U=X.length-$.sequence.prefixLength;U<$.sequence.defaultables.length;U++)$.sequence.defaultValueMorphs[U](X,Y);if($.undeclared==="delete"){for(let U in X)if(!$.declaresKey(U))delete X[U]}return X};return i_[T]=W},lP=($,T)=>{let X=`(data${T.defaultable.some((Y)=>Y.defaultValueMorph.length===2)||T.sequence?.defaultValueMorphs.some((Y)=>Y.length===2)?", ctx":""})`;return $.block(`${X} => `,(Y)=>{for(let U=0;U<T.defaultable.length;U++){let{serializedKey:G,defaultValueMorphRef:J}=T.defaultable[U];Y.if(`!(${G} in data)`,(z)=>z.line(`${J}${X}`))}if(T.sequence?.defaultables)Y.for(`i < ${T.sequence.defaultables.length}`,(U)=>U.set("data[i]",5),`data.length - ${T.sequence.prefixLength}`);if(T.undeclared==="delete")Y.forIn("data",(U)=>U.if(`!(${T._compileDeclaresKey(U)})`,(G)=>G.line("delete data[k]")));return Y.return("data")})},n_={implementation:pP,Node:RK},rP=($)=>{if(o($,"root")&&$.hasKind("unit"))$=$.unit;if(typeof $==="number")$=`${$}`;return $},iP=($,T)=>`${$} is not allowed as an array index on ${T}. Use the 'nonNegativeIntegerString' keyword instead.`,LU=($,T,W)=>{let[X,Y]=nO($.branches,(G)=>G.hasKind("unit"));if(!X.length)return{index:W.node("index",{signature:$,value:T})};let U={};for(let G of X){let J=W.node("required",{key:G.unit,value:T});U[J.kind]=Q$(U[J.kind],J)}if(Y.length)U.index=W.node("index",{signature:Y,value:T});return U},nP=($)=>o($,"root")?$.expression:U$($),SK=($,T)=>`Key${T.length===1?"":"s"} ${T.map(nP).join(", ")} ${T.length===1?"does":"do"} not exist on ${$}`;var pT={...tV,alias:RX.implementation,domain:NU.implementation,unit:p_.implementation,proto:IX.implementation,union:u_.implementation,morph:m_.implementation,intersection:g_.implementation,divisor:B_.implementation,pattern:j_.implementation,predicate:S_.implementation,required:o_.implementation,optional:LX.implementation,index:d_.implementation,sequence:l_.implementation,structure:n_.implementation};I.defaultConfig=YV(Object.assign(Y$(pT,($,T)=>[$,T.defaults]),{jitless:_V(),clone:JV,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:y$.defaultConfig}));I.resolvedConfig=OX(I.defaultConfig,I.config);var WK={...aV,alias:RX.Node,domain:NU.Node,unit:p_.Node,proto:IX.Node,union:u_.Node,morph:m_.Node,intersection:g_.Node,divisor:B_.Node,pattern:j_.Node,predicate:S_.Node,required:o_.Node,optional:LX.Node,index:d_.Node,sequence:l_.Node,structure:n_.Node};class lT extends U_{get[C4](){return"module"}}var t_=($,T)=>new lT(Y$($,(W,X)=>[W,o(X,"module")?t_(X,T):T.bindReference(X)]));var tP=($)=>I$($)?$:("branches"in $)&&I$($.branches)?$.branches:void 0,aP=($,T)=>L(`Node of kind ${T} is not valid as a ${$} definition`),IK=($)=>`#${$} duplicates public alias ${$}`,a_={};I.ambient??={};var kK,PK="function $",sP=($)=>CK($,vK($)),CK=($,T)=>{let W=T.write(PK,4),X=T.compile()();for(let Y of $){if(Y.precompilation)continue;if(Y.traverseAllows=X[`${Y.id}Allows`].bind(X),Y.isRoot()&&!Y.allowsRequiresContext)Y.allows=Y.traverseAllows;if(Y.traverseApply=X[`${Y.id}Apply`].bind(X),X[`${Y.id}Optimistic`])Y.traverseOptimistic=X[`${Y.id}Optimistic`].bind(X);Y.precompilation=W}},vK=($)=>new HU().return($.reduce((T,W)=>{let X=new DX({kind:"Allows"}).indent();W.compile(X);let Y=X.write(`${W.id}Allows`),U=new DX({kind:"Apply"}).indent();W.compile(U);let G=U.write(`${W.id}Apply`),J=`${T}${Y},
|
|
148
|
-
${
|
|
149
|
-
`;if(!W.hasKind("union"))return
|
|
148
|
+
Right: ${T}`;var xh=A$({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:($)=>$ instanceof Date?$.toISOString():k1($)}},normalize:($)=>$,defaults:{description:($)=>E$($.unit),problem:({expected:$,actual:T})=>`${$===T?`must be reference equal to ${$} (serialized to the same value)`:`must be ${$} (was ${T})`}`},intersections:{unit:($,T)=>o.init("unit",$,T),...Q0("unit",($,T)=>{if(T.allows($.unit))return $;let W=T.hasKind("intersection")?T.basis:T;if(W){let U=W.hasKind("domain")?W:b.intrinsic.object;if($.domain!==U.domain){let X=$.domain==="undefined"||$.domain==="null"||$.domain==="boolean"?$.domain:b.intrinsic[$.domain];return o.init("domain",X,U)}}return o.init("assignability",$,T.hasKind("intersection")?T.children.find((U)=>!U.allows($.unit)):T)})}});class Nk extends iW{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=Mk(this.unit,this.serializedValue);compiledNegation=Mk(this.unit,this.serializedValue,"negated");expression=E$(this.unit);domain=x4(this.unit);get defaultShortDescription(){return this.domain==="object"?d6.object:this.description}innerToJsonSchema($){return this.unit===null?{type:"null"}:b.intrinsic.jsonPrimitive.allows(this.unit)?{const:this.unit}:$.fallback.unit({code:"unit",base:{},unit:this.unit})}traverseAllows=this.unit instanceof Date?($)=>$ instanceof Date&&$.toISOString()===this.compiledValue:Number.isNaN(this.unit)?($)=>Number.isNaN($):($)=>$===this.unit}var mZ={implementation:xh,Node:Nk},Mk=($,T,W)=>{if($ instanceof Date){let U=`data instanceof Date && data.toISOString() === ${T}`;return W?`!(${U})`:U}if(Number.isNaN($))return`${W?"!":""}Number.isNaN(data)`;return`data ${W?"!":"="}== ${T}`};var Ih=A$({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:($,T)=>{let W=T.$.parseSchema($);if(!W.extends(b.intrinsic.key))return B(fh(W.expression));let U=W.branches.filter((X)=>X.hasKind("unit"));if(U.length)return B(bh(U.map((X)=>E$(X.unit))));return W}},value:{child:!0,parse:($,T)=>T.$.parseSchema($)}},normalize:($)=>$,defaults:{description:($)=>`[${$.signature.expression}]: ${$.value.description}`},intersections:{index:($,T,W)=>{if($.signature.equals(T.signature)){let U=a$($.value,T.value,W),X=U instanceof o?b.intrinsic.never.internal:U;return W.$.node("index",{signature:$.signature,value:X})}if($.signature.extends(T.signature)&&$.value.subsumes(T.value))return T;if(T.signature.extends($.signature)&&T.value.subsumes($.value))return $;return null}}});class Lk extends v1{impliedBasis=b.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=q$(this.value.flatRefs.map(($)=>p1([this.signature,...$.path],$.node)),p1([this.signature],this.value));traverseAllows=($,T)=>oW($).every((W)=>{if(this.signature.traverseAllows(W[0],T))return l6(W[0],()=>this.value.traverseAllows(W[1],T),T);return!0});traverseApply=($,T)=>{for(let W of oW($))if(this.signature.traverseAllows(W[0],T))l6(W[0],()=>this.value.traverseApply(W[1],T),T)};_transform($,T){T.path.push(this.signature);let W=super._transform($,T);return T.path.pop(),W}compile(){}}var cZ={implementation:Ih,Node:Lk},bh=($)=>`Index keys ${$.join(", ")} should be specified as named props.`,fh=($)=>`Indexed key definition '${$}' must be a string or symbol`;var yh=A$({kind:"required",hasAssociatedError:!0,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:($,T)=>T.$.parseSchema($)}},normalize:($)=>$,defaults:{description:($)=>`${$.compiledKey}: ${$.value.description}`,expected:($)=>$.missingValueDescription,actual:()=>"missing"},intersections:{required:dY,optional:dY}});class Jk extends oY{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=cT(this.errorContext)}var uZ={implementation:yh,Node:Jk};var hh=A$({kind:"sequence",hasAssociatedError:!1,collapsibleKey:"variadic",keys:{prefix:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}},optionals:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}},defaultables:{child:($)=>$.map((T)=>T[0]),parse:($,T)=>{if($.length===0)return;return $.map((W)=>{let U=T.$.parseSchema(W[0]);return rY(U,W[1],null),[U,W[1]]})},serialize:($)=>$.map((T)=>[T[0].collapsibleJson,k1(T[1])])},variadic:{child:!0,parse:($,T)=>T.$.parseSchema($,T)},minVariadicLength:{parse:($)=>$===0?void 0:$},postfix:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}}},normalize:($)=>{if(typeof $==="string")return{variadic:$};if("variadic"in $||"prefix"in $||"defaultables"in $||"optionals"in $||"postfix"in $||"minVariadicLength"in $){if($.postfix?.length){if(!$.variadic)return B(uh);if($.optionals?.length||$.defaultables?.length)return B(dZ)}if($.minVariadicLength&&!$.variadic)return B("minVariadicLength may not be specified without a variadic element");return $}return{variadic:$}},reduce:($,T)=>{let W=$.minVariadicLength??0,U=$.prefix?.slice()??[],X=$.defaultables?.slice()??[],Y=$.optionals?.slice()??[],w=$.postfix?.slice()??[];if($.variadic){while(Y.at(-1)?.equals($.variadic))Y.pop();if(Y.length===0&&X.length===0)while(U.at(-1)?.equals($.variadic))U.pop(),W++;while(w[0]?.equals($.variadic))w.shift(),W++}else if(Y.length===0&&X.length===0)U.push(...w.splice(0));if(W!==$.minVariadicLength||$.prefix&&$.prefix.length!==U.length)return T.node("sequence",{...$,prefix:U,defaultables:X,optionals:Y,postfix:w,minVariadicLength:W},{prereduced:!0})},defaults:{description:($)=>{if($.isVariadicOnly)return`${$.variadic.nestableExpression}[]`;return`[${$.tuple.map((W)=>W.kind==="defaultables"?`${W.node.nestableExpression} = ${E$(W.default)}`:W.kind==="optionals"?`${W.node.nestableExpression}?`:W.kind==="variadic"?`...${W.node.nestableExpression}[]`:W.node.expression).join(", ")}]`}},intersections:{sequence:($,T,W)=>{let U=aY({l:$.tuple,r:T.tuple,disjoint:new o,result:[],fixedVariants:[],ctx:W}),X=U.disjoint.length===0?[U,...U.fixedVariants]:U.fixedVariants;return X.length===0?U.disjoint:X.length===1?W.$.node("sequence",_k(X[0].result)):W.$.node("union",X.map((Y)=>({proto:Array,sequence:_k(Y.result)})))}}});class Rk extends v1{impliedBasis=b.intrinsic.Array.internal;tuple=ch(this.inner);prefixLength=this.prefix?.length??0;defaultablesLength=this.defaultables?.length??0;optionalsLength=this.optionals?.length??0;postfixLength=this.postfix?.length??0;defaultablesAndOptionals=[];prevariadic=this.tuple.filter(($)=>{if($.kind==="defaultables"||$.kind==="optionals")return this.defaultablesAndOptionals.push($.node),!0;return $.kind==="prefix"});variadicOrPostfix=n0(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return EZ(this.flatRefs,this.prevariadic.flatMap(($,T)=>q$($.node.flatRefs.map((W)=>p1([`${T}`,...W.path],W.node)),p1([`${T}`],$.node)))),EZ(this.flatRefs,this.variadicOrPostfix.flatMap(($)=>q$($.flatRefs.map((T)=>p1([b.intrinsic.nonNegativeIntegerString.internal,...T.path],T.node)),p1([b.intrinsic.nonNegativeIntegerString.internal],$)))),this.flatRefs}isVariadicOnly=this.prevariadic.length+this.postfixLength===0;minVariadicLength=this.inner.minVariadicLength??0;minLength=this.prefixLength+this.minVariadicLength+this.postfixLength;minLengthNode=this.minLength===0?null:this.$.node("minLength",this.minLength);maxLength=this.variadic?null:this.tuple.length;maxLengthNode=this.maxLength===null?null:this.$.node("maxLength",this.maxLength);impliedSiblings=this.minLengthNode?this.maxLengthNode?[this.minLengthNode,this.maxLengthNode]:[this.minLengthNode]:this.maxLengthNode?[this.maxLengthNode]:[];defaultValueMorphs=mh(this);defaultValueMorphsReference=this.defaultValueMorphs.length?Z4(this.defaultValueMorphs):void 0;elementAtIndex($,T){if(T<this.prevariadic.length)return this.tuple[T];let W=$.length-this.postfixLength;if(T>=W)return{kind:"postfix",node:this.postfix[T-W]};return{kind:"variadic",node:this.variadic??S$(`Unexpected attempt to access index ${T} on ${this}`)}}traverseAllows=($,T)=>{for(let W=0;W<$.length;W++)if(!this.elementAtIndex($,W).node.traverseAllows($[W],T))return!1;return!0};traverseApply=($,T)=>{let W=0;for(;W<$.length;W++)l6(W,()=>this.elementAtIndex($,W).node.traverseApply($[W],T),T)};get element(){return this.cacheGetter("element",this.$.node("union",this.children))}compile($){if(this.prefix)for(let[T,W]of this.prefix.entries())$.traverseKey(`${T}`,`data[${T}]`,W);for(let[T,W]of this.defaultablesAndOptionals.entries()){let U=`${T+this.prefixLength}`;$.if(`${U} >= ${$.data}.length`,()=>$.traversalKind==="Allows"?$.return(!0):$.return()),$.traverseKey(U,`data[${U}]`,W)}if(this.variadic){if(this.postfix)$.const("firstPostfixIndex",`${$.data}.length${this.postfix?`- ${this.postfix.length}`:""}`);if($.for(`i < ${this.postfix?"firstPostfixIndex":"data.length"}`,()=>$.traverseKey("i","data[i]",this.variadic),this.prevariadic.length),this.postfix)for(let[T,W]of this.postfix.entries()){let U=`firstPostfixIndex + ${T}`;$.traverseKey(U,`data[${U}]`,W)}}if($.traversalKind==="Allows")$.return(!0)}_transform($,T){T.path.push(b.intrinsic.nonNegativeIntegerString.internal);let W=super._transform($,T);return T.path.pop(),W}expression=this.description;reduceJsonSchema($,T){if(this.prevariadic.length)$.prefixItems=this.prevariadic.map((W)=>{let U=W.node.toJsonSchemaRecurse(T);if(W.kind==="defaultables"){let X=typeof W.default==="function"?W.default():W.default;U.default=b.intrinsic.jsonData.allows(X)?X:T.fallback.defaultValue({code:"defaultValue",base:U,value:X})}return U});if(this.minLength)$.minItems=this.minLength;if(this.variadic){let W=Object.assign($,{items:this.variadic.toJsonSchemaRecurse(T)});if(this.maxLength)W.maxItems=this.maxLength;if(this.postfix){let U=this.postfix.map((X)=>X.toJsonSchemaRecurse(T));$=T.fallback.arrayPostfix({code:"arrayPostfix",base:W,elements:U})}}else $.items=!1,delete $.maxItems;return $}}var gh={},mh=($)=>{if(!$.defaultables)return[];let T=[],W="[",U=$.prefixLength+$.defaultablesLength-1;for(let X=$.prefixLength;X<=U;X++){let[Y,w]=$.defaultables[X-$.prefixLength];T.push(bZ(X,Y,w)),W+=`${X}: ${Y.id} = ${k1(w)}, `}return W+="]",gh[W]??=T},pZ={implementation:hh,Node:Rk},ch=($)=>{let T=[];if($.prefix)for(let W of $.prefix)T.push({kind:"prefix",node:W});if($.defaultables)for(let[W,U]of $.defaultables)T.push({kind:"defaultables",node:W,default:U});if($.optionals)for(let W of $.optionals)T.push({kind:"optionals",node:W});if($.variadic)T.push({kind:"variadic",node:$.variadic});if($.postfix)for(let W of $.postfix)T.push({kind:"postfix",node:W});return T},_k=($)=>$.reduce((T,W)=>{if(W.kind==="variadic")T.variadic=W.node;else if(W.kind==="defaultables")T.defaultables=q$(T.defaultables,[[W.node,W.default]]);else T[W.kind]=q$(T[W.kind],W.node);return T},{}),dZ="A postfix required element cannot follow an optional or defaultable element",uh="A postfix element requires a variadic element",aY=($)=>{let[T,...W]=$.l,[U,...X]=$.r;if(!T||!U)return $;let Y=W.at(-1)?.kind==="postfix",w=X.at(-1)?.kind==="postfix",G=T.kind==="prefix"||U.kind==="prefix"?"prefix":T.kind==="postfix"||U.kind==="postfix"?"postfix":T.kind==="variadic"&&U.kind==="variadic"?"variadic":Y||w?"prefix":T.kind==="defaultables"||U.kind==="defaultables"?"defaultables":"optionals";if(T.kind==="prefix"&&U.kind==="variadic"&&w){let O=aY({...$,fixedVariants:[],r:X.map((Q)=>({...Q,kind:"prefix"}))});if(O.disjoint.length===0)$.fixedVariants.push(O)}else if(U.kind==="prefix"&&T.kind==="variadic"&&Y){let O=aY({...$,fixedVariants:[],l:W.map((Q)=>({...Q,kind:"prefix"}))});if(O.disjoint.length===0)$.fixedVariants.push(O)}let H=a$(T.node,U.node,$.ctx);if(H instanceof o)if(G==="prefix"||G==="postfix")$.disjoint.push(...H.withPrefixKey(G==="prefix"?$.result.length:`-${W.length+1}`,"required")),$.result=[...$.result,{kind:G,node:b.intrinsic.never.internal}];else if(G==="optionals"||G==="defaultables")return $;else return aY({...$,fixedVariants:[],l:W.map((O)=>({...O,kind:"prefix"})),r:W.map((O)=>({...O,kind:"prefix"}))});else if(G==="defaultables"){if(T.kind==="defaultables"&&U.kind==="defaultables"&&T.default!==U.default)B(IZ(T.default,U.default));$.result=[...$.result,{kind:G,node:H,default:T.kind==="defaultables"?T.default:U.kind==="defaultables"?U.default:S$(`Unexpected defaultable intersection from ${T.kind} and ${U.kind} elements.`)}]}else $.result=[...$.result,{kind:G,node:H}];let z=$.l.length,F=$.r.length;if(T.kind!=="variadic"||z>=F&&(U.kind==="variadic"||F===1))$.l=W;if(U.kind!=="variadic"||F>=z&&(T.kind==="variadic"||z===1))$.r=X;return aY($)};var qk=($)=>(T)=>{if(T.props.length||T.index){let W=T.index?.map((X)=>X[$])??[];for(let X of T.props)W.push(X[$]);if(T.undeclared)W.push(`+ (undeclared): ${T.undeclared}`);let U=`{ ${W.join(", ")} }`;return T.sequence?`${U} & ${T.sequence.description}`:U}return T.sequence?.description??"{}"},ph=qk("description"),dh=qk("expression"),kk=($,T,W)=>{let U=$.required?"required":"optional";if(!T.signature.allows($.key))return null;let X=r6($.value,T.value,W);if(X instanceof o)return U==="optional"?W.node("optional",{key:$.key,value:b.intrinsic.never.internal}):X.withPrefixKey($.key,$.kind);return null},oh=A$({kind:"structure",hasAssociatedError:!1,normalize:($)=>$,applyConfig:($,T)=>{if(!$.undeclared&&T.onUndeclaredKey!=="ignore")return{...$,undeclared:T.onUndeclaredKey};return $},keys:{required:{child:!0,parse:X6("required"),reduceIo:($,T,W)=>{T.required=q$(T.required,W.map((U)=>U[$]));return}},optional:{child:!0,parse:X6("optional"),reduceIo:($,T,W)=>{if($==="in"){T.optional=W.map((U)=>U.in);return}for(let U of W)T[U.outProp.kind]=q$(T[U.outProp.kind],U.outProp.out)}},index:{child:!0,parse:X6("index")},sequence:{child:!0,parse:X6("sequence")},undeclared:{parse:($)=>$==="ignore"?void 0:$,reduceIo:($,T,W)=>{if(W!=="delete")return;if($==="in")delete T.undeclared;else T.undeclared="reject"}}},defaults:{description:ph},intersections:{structure:($,T,W)=>{let U={...$.inner},X={...T.inner},Y=new o;if($.undeclared){let H=$.keyof();for(let z of T.requiredKeys)if(!H.allows(z))Y.add("presence",b.intrinsic.never.internal,T.propsByKey[z].value,{path:[z]});if(X.optional)X.optional=X.optional.filter((z)=>H.allows(z.key));if(X.index)X.index=X.index.flatMap((z)=>{if(z.signature.extends(H))return z;let F=r6(H,z.signature,W.$);if(F instanceof o)return[];let O=qz(F,z.value,W.$);if(O.required)X.required=n0(X.required,O.required);if(O.optional)X.optional=n0(X.optional,O.optional);return O.index??[]})}if(T.undeclared){let H=T.keyof();for(let z of $.requiredKeys)if(!H.allows(z))Y.add("presence",$.propsByKey[z].value,b.intrinsic.never.internal,{path:[z]});if(U.optional)U.optional=U.optional.filter((z)=>H.allows(z.key));if(U.index)U.index=U.index.flatMap((z)=>{if(z.signature.extends(H))return z;let F=r6(H,z.signature,W.$);if(F instanceof o)return[];let O=qz(F,z.value,W.$);if(O.required)U.required=n0(U.required,O.required);if(O.optional)U.optional=n0(U.optional,O.optional);return O.index??[]})}let w={};if($.undeclared||T.undeclared)w.undeclared=$.undeclared==="reject"||T.undeclared==="reject"?"reject":"delete";let G=NU({kind:"structure",baseInner:w,l:LU(U),r:LU(X),roots:[],ctx:W});if(G instanceof o)Y.push(...G);if(Y.length)return Y;return G}},reduce:($,T)=>{if($.index){if(!($.required||$.optional))return;let W=!1,U=$.required??[],X=$.optional??[],Y=[...X];for(let w of $.index){for(let G of U){let H=kk(G,w,T);if(H instanceof o)return H}for(let[G,H]of X.entries()){let z=kk(H,w,T);if(z instanceof o)return z;if(z===null)continue;Y[G]=z,W=!0}}if(W)return T.node("structure",{...$,optional:Y},{prereduced:!0})}}});class Pk extends v1{impliedBasis=b.intrinsic.object.internal;impliedSiblings=this.children.flatMap(($)=>$.impliedSiblings??[]);props=n0(this.required,this.optional);propsByKey=K$(this.props,($,T)=>[T.key,T]);propsByKeyReference=Z4(this.propsByKey);expression=dh(this);requiredKeys=this.required?.map(($)=>$.key)??[];optionalKeys=this.optional?.map(($)=>$.key)??[];literalKeys=[...this.requiredKeys,...this.optionalKeys];_keyof;keyof(){if(this._keyof)return this._keyof;let $=this.$.units(this.literalKeys).branches;if(this.index)for(let{signature:T}of this.index)$=$.concat(T.branches);return this._keyof=this.$.node("union",$)}map($){return this.$.node("structure",this.props.flatMap($).reduce((T,W)=>{let U=this.propsByKey[W.key];if(t$(W)){if(W.kind!=="required"&&W.kind!=="optional")return B(`Map result must have kind "required" or "optional" (was ${W.kind})`);return T[W.kind]=q$(T[W.kind],W),T}let X=W.kind??U?.kind??"required",Y=K$(W,(w,G)=>(w in lY.implementation.keys)?[w,G]:[]);return T[X]=q$(T[X],this.$.node(X,Y)),T},{}))}assertHasKeys($){let T=$.filter((W)=>!nY(W,this.keyof()));if(T.length)return B(vk(this.expression,T))}get($,...T){let W,U=!1,X=ih($);if((typeof X==="string"||typeof X==="symbol")&&this.propsByKey[X])W=this.propsByKey[X].value,U=this.propsByKey[X].required;if(this.index){for(let w of this.index)if(nY(X,w.signature))W=W?.and(w.value)??w.value}if(this.sequence&&nY(X,b.intrinsic.nonNegativeIntegerString))if(s(X,"root")){if(this.sequence.variadic)W=W?.and(this.sequence.element)??this.sequence.element}else{let w=Number.parseInt(X);if(w<this.sequence.prevariadic.length){let G=this.sequence.prevariadic[w].node;W=W?.and(G)??G,U||=w<this.sequence.prefixLength}else if(this.sequence.variadic){let G=this.$.node("union",this.sequence.variadicOrPostfix);W=W?.and(G)??G}}if(!W){if(this.sequence?.variadic&&s(X,"root")&&X.extends(b.intrinsic.number))return B(th(X.expression,this.sequence.expression));return B(vk(this.expression,[X]))}let Y=W.get(...T);return U?Y:Y.or(b.intrinsic.undefined)}pick(...$){return this.assertHasKeys($),this.$.node("structure",this.filterKeys("pick",$))}omit(...$){return this.assertHasKeys($),this.$.node("structure",this.filterKeys("omit",$))}optionalize(){let{required:$,...T}=this.inner;return this.$.node("structure",{...T,optional:this.props.map((W)=>W.hasKind("required")?this.$.node("optional",W.inner):W)})}require(){let{optional:$,...T}=this.inner;return this.$.node("structure",{...T,required:this.props.map((W)=>W.hasKind("optional")?{key:W.key,value:W.value}:W)})}merge($){let T=this.filterKeys("omit",[$.keyof()]);if($.required)T.required=q$(T.required,$.required);if($.optional)T.optional=q$(T.optional,$.optional);if($.index)T.index=q$(T.index,$.index);if($.sequence)T.sequence=$.sequence;if($.undeclared)T.undeclared=$.undeclared;else delete T.undeclared;return this.$.node("structure",T)}filterKeys($,T){let W=Kz(this.inner),U=(X)=>{let Y=T.some((w)=>nY(X,w));return $==="pick"?Y:!Y};if(W.required)W.required=W.required.filter((X)=>U(X.key));if(W.optional)W.optional=W.optional.filter((X)=>U(X.key));if(W.index)W.index=W.index.filter((X)=>U(X.signature));return W}traverseAllows=($,T)=>this._traverse("Allows",$,T);traverseApply=($,T)=>this._traverse("Apply",$,T);_traverse=($,T,W)=>{let U=W?.currentErrorCount??0;for(let X=0;X<this.props.length;X++)if($==="Allows"){if(!this.props[X].traverseAllows(T,W))return!1}else if(this.props[X].traverseApply(T,W),W.failFast&&W.currentErrorCount>U)return!1;if(this.sequence){if($==="Allows"){if(!this.sequence.traverseAllows(T,W))return!1}else if(this.sequence.traverseApply(T,W),W.failFast&&W.currentErrorCount>U)return!1}if(this.index||this.undeclared==="reject"){let X=Object.keys(T);X.push(...Object.getOwnPropertySymbols(T));for(let Y=0;Y<X.length;Y++){let w=X[Y];if(this.index){for(let G of this.index)if(G.signature.traverseAllows(w,W)){if($==="Allows"){if(!l6(w,()=>G.value.traverseAllows(T[w],W),W))return!1}else if(l6(w,()=>G.value.traverseApply(T[w],W),W),W.failFast&&W.currentErrorCount>U)return!1}}if(this.undeclared==="reject"&&!this.declaresKey(w)){if($==="Allows")return!1;if(W.errorFromNodeContext({code:"predicate",expected:"removed",actual:"",relativePath:[w],meta:this.meta}),W.failFast)return!1}}}if(this.structuralMorph&&W&&!W.hasError())W.queueMorphs([this.structuralMorph]);return!0};get defaultable(){return this.cacheGetter("defaultable",this.optional?.filter(($)=>$.hasDefault())??[])}declaresKey=($)=>($ in this.propsByKey)||this.index?.some((T)=>T.signature.allows($))||this.sequence!==void 0&&b.intrinsic.nonNegativeIntegerString.allows($);_compileDeclaresKey($){let T=[];if(this.props.length)T.push(`k in ${this.propsByKeyReference}`);if(this.index)for(let W of this.index)T.push($.invoke(W.signature,{kind:"Allows",arg:"k"}));if(this.sequence)T.push("$ark.intrinsic.nonNegativeIntegerString.allows(k)");return T.join(" || ")||"false"}get structuralMorph(){return this.cacheGetter("structuralMorph",rh(this))}structuralMorphRef=this.structuralMorph&&Z4(this.structuralMorph);compile($){if($.traversalKind==="Apply")$.initializeErrorCount();for(let T of this.props)if($.check(T),$.traversalKind==="Apply")$.returnIfFailFast();if(this.sequence){if($.check(this.sequence),$.traversalKind==="Apply")$.returnIfFailFast()}if(this.index||this.undeclared==="reject")$.const("keys","Object.keys(data)"),$.line("keys.push(...Object.getOwnPropertySymbols(data))"),$.for("i < keys.length",()=>this.compileExhaustiveEntry($));if($.traversalKind==="Allows")return $.return(!0);if(this.structuralMorphRef)$.if("ctx && !ctx.hasError()",()=>{return $.line("ctx.queueMorphs(["),nh($,this),$.line("])")})}compileExhaustiveEntry($){if($.const("k","keys[i]"),this.index)for(let T of this.index)$.if(`${$.invoke(T.signature,{arg:"k",kind:"Allows"})}`,()=>$.traverseKey("k","data[k]",T.value));if(this.undeclared==="reject")$.if(`!(${this._compileDeclaresKey($)})`,()=>{if($.traversalKind==="Allows")return $.return(!1);return $.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if("ctx.failFast",()=>$.return())});return $}reduceJsonSchema($,T){switch($.type){case"object":return this.reduceObjectJsonSchema($,T);case"array":let W=this.sequence?.reduceJsonSchema($,T)??$;if(this.props.length||this.index)return T.fallback.arrayObject({code:"arrayObject",base:W,object:this.reduceObjectJsonSchema({type:"object"},T)});return W;default:return U4.throwInternalOperandError("structure",$)}}reduceObjectJsonSchema($,T){if(this.props.length){$.properties={};for(let W of this.props){let U=W.value.toJsonSchemaRecurse(T);if(typeof W.key==="symbol"){T.fallback.symbolKey({code:"symbolKey",base:$,key:W.key,value:U,optional:W.optional});continue}if(W.hasDefault()){let X=typeof W.default==="function"?W.default():W.default;U.default=b.intrinsic.jsonData.allows(X)?X:T.fallback.defaultValue({code:"defaultValue",base:U,value:X})}$.properties[W.key]=U}if(this.requiredKeys.length&&$.properties)$.required=this.requiredKeys.filter((W)=>typeof W==="string"&&(W in $.properties))}if(this.index)for(let W of this.index){let U=W.value.toJsonSchemaRecurse(T);if(W.signature.equals(b.intrinsic.string)){$.additionalProperties=U;continue}for(let X of W.signature.branches){if(!X.extends(b.intrinsic.string)){$=T.fallback.symbolKey({code:"symbolKey",base:$,key:null,value:U,optional:!1});continue}let Y={type:"string"};if(X.hasKind("morph"))Y=T.fallback.morph({code:"morph",base:X.in.toJsonSchemaRecurse(T),out:X.out.toJsonSchemaRecurse(T)});if(!X.hasKind("intersection"))return S$(`Unexpected index branch kind ${X.kind}.`);let{pattern:w}=X.inner;if(w){let G=Object.assign(Y,{pattern:w[0].rule});for(let H=1;H<w.length;H++)Y=T.fallback.patternIntersection({code:"patternIntersection",base:G,pattern:w[H].rule});$.patternProperties??={},$.patternProperties[G.pattern]=U}}}if(this.undeclared&&!$.additionalProperties)$.additionalProperties=!1;return $}}var oZ={},lh=($)=>{let T="";for(let W=0;W<$.defaultable.length;W++)T+=$.defaultable[W].defaultValueMorphRef;if($.sequence?.defaultValueMorphsReference)T+=$.sequence?.defaultValueMorphsReference;if($.undeclared==="delete"){if(T+="delete !(",$.required)for(let W of $.required)T+=W.compiledKey+" | ";if($.optional)for(let W of $.optional)T+=W.compiledKey+" | ";if($.index)for(let W of $.index)T+=W.signature.id+" | ";if($.sequence)if($.sequence.maxLength===null)T+=X$.nonNegativeIntegerString.id;else for(let W=0;W<$.sequence.tuple.length;W++)T+=W+" | ";T+=")"}return T},rh=($)=>{let T=lh($);if(!T)return;if(oZ[T])return oZ[T];let W=(U,X)=>{for(let Y=0;Y<$.defaultable.length;Y++)if(!($.defaultable[Y].key in U))$.defaultable[Y].defaultValueMorph(U,X);if($.sequence?.defaultables)for(let Y=U.length-$.sequence.prefixLength;Y<$.sequence.defaultables.length;Y++)$.sequence.defaultValueMorphs[Y](U,X);if($.undeclared==="delete"){for(let Y in U)if(!$.declaresKey(Y))delete U[Y]}return U};return oZ[T]=W},nh=($,T)=>{let U=`(data${T.defaultable.some((X)=>X.defaultValueMorph.length===2)||T.sequence?.defaultValueMorphs.some((X)=>X.length===2)?", ctx":""})`;return $.block(`${U} => `,(X)=>{for(let Y=0;Y<T.defaultable.length;Y++){let{serializedKey:w,defaultValueMorphRef:G}=T.defaultable[Y];X.if(`!(${w} in data)`,(H)=>H.line(`${G}${U}`))}if(T.sequence?.defaultables)X.for(`i < ${T.sequence.defaultables.length}`,(Y)=>Y.set("data[i]",5),`data.length - ${T.sequence.prefixLength}`);if(T.undeclared==="delete")X.forIn("data",(Y)=>Y.if(`!(${T._compileDeclaresKey(Y)})`,(w)=>w.line("delete data[k]")));return X.return("data")})},lZ={implementation:oh,Node:Pk},ih=($)=>{if(s($,"root")&&$.hasKind("unit"))$=$.unit;if(typeof $==="number")$=`${$}`;return $},th=($,T)=>`${$} is not allowed as an array index on ${T}. Use the 'nonNegativeIntegerString' keyword instead.`,qz=($,T,W)=>{let[U,X]=a_($.branches,(w)=>w.hasKind("unit"));if(!U.length)return{index:W.node("index",{signature:$,value:T})};let Y={};for(let w of U){let G=W.node("required",{key:w.unit,value:T});Y[G.kind]=q$(Y[G.kind],G)}if(X.length)Y.index=W.node("index",{signature:X,value:T});return Y},ah=($)=>s($,"root")?$.expression:E$($),vk=($,T)=>`Key${T.length===1?"":"s"} ${T.map(ah).join(", ")} ${T.length===1?"does":"do"} not exist on ${$}`;var _U={...sR,alias:iY.implementation,domain:vz.implementation,unit:mZ.implementation,proto:tY.implementation,union:gZ.implementation,morph:yZ.implementation,intersection:fZ.implementation,divisor:JZ.implementation,pattern:SZ.implementation,predicate:LZ.implementation,required:uZ.implementation,optional:lY.implementation,index:cZ.implementation,sequence:pZ.implementation,structure:lZ.implementation};b.defaultConfig=wR(Object.assign(K$(_U,($,T)=>[$,T.defaults]),{jitless:QR(),clone:HR,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:U4.defaultConfig}));b.resolvedConfig=gY(b.defaultConfig,b.config);var Xk={...eR,alias:iY.Node,domain:vz.Node,unit:mZ.Node,proto:tY.Node,union:gZ.Node,morph:yZ.Node,intersection:fZ.Node,divisor:JZ.Node,pattern:SZ.Node,predicate:LZ.Node,required:uZ.Node,optional:lY.Node,index:cZ.Node,sequence:pZ.Node,structure:lZ.Node};class vU extends WZ{get[q6](){return"module"}}var rZ=($,T)=>new vU(K$($,(W,U)=>[W,s(U,"module")?rZ(U,T):T.bindReference(U)]));var sh=($)=>d$($)?$:("branches"in $)&&d$($.branches)?$.branches:void 0,eh=($,T)=>B(`Node of kind ${T} is not valid as a ${$} definition`),Ck=($)=>`#${$} duplicates public alias ${$}`,nZ={};b.ambient??={};var Sk,Bk="function $",$g=($)=>xk($,Ik($)),xk=($,T)=>{let W=T.write(Bk,4),U=T.compile()();for(let X of $){if(X.precompilation)continue;if(X.traverseAllows=U[`${X.id}Allows`].bind(U),X.isRoot()&&!X.allowsRequiresContext)X.allows=X.traverseAllows;if(X.traverseApply=U[`${X.id}Apply`].bind(U),U[`${X.id}Optimistic`])X.traverseOptimistic=U[`${X.id}Optimistic`].bind(U);X.precompilation=W}},Ik=($)=>new Vz().return($.reduce((T,W)=>{let U=new hY({kind:"Allows"}).indent();W.compile(U);let X=U.write(`${W.id}Allows`),Y=new hY({kind:"Apply"}).indent();W.compile(Y);let w=Y.write(`${W.id}Apply`),G=`${T}${X},
|
|
149
|
+
${w},
|
|
150
|
+
`;if(!W.hasKind("union"))return G;let H=new hY({kind:"Allows",optimistic:!0}).indent();W.compile(H);let z=H.write(`${W.id}Optimistic`);return`${G}${z},
|
|
150
151
|
`},`{
|
|
151
|
-
`)+"}");class SU{config;resolvedConfig;name;get[C4](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor($,T){if(this.config=OX(I.config,T),this.resolvedConfig=OX(I.resolvedConfig,T),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(a_).length}`,this.name in a_)L(`A Scope already named ${this.name} already exists`);a_[this.name]=this;let W=Object.entries($).map((X)=>this.preparseOwnAliasEntry(...X));for(let[X,Y]of W){let U=X;if(X[0]==="#"){if(U=X.slice(1),U in this.aliases)L(IK(U));this.aliases[U]=Y}else{if(U in this.aliases)L(IK(X));this.aliases[U]=Y,this.exportedNames.push(U)}if(!o(Y,"module")&&!o(Y,"generic")&&!c1(Y)){let G=this.preparseOwnDefinitionFormat(Y,{alias:U});this.resolutions[U]=o(G,"root")?this.bindReference(G):this.createParseContext(G).id}}kK??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[kK.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=I.intrinsic?Y$(I.intrinsic,(X,Y)=>X.startsWith("json")?[]:[X,this.bindReference(Y)]):{}}cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema($){return $}generic=(...$)=>{let T=this;return(W,X)=>new l1($,X?new OU(W):W,T,T,X??null)};units=($,T)=>{let W=[];for(let Y of $)if(!W.includes(Y))W.push(Y);let X=W.map((Y)=>this.node("unit",{unit:Y},T));return this.node("union",X,{...T,prereduced:!0})};lazyResolutions=[];lazilyResolve($,T){let W=this.node("alias",{reference:T??"synthetic",resolve:$},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(W);return W}schema=($,T)=>this.finalize(this.parseSchema($,T));parseSchema=($,T)=>this.node(MX($),$,T);preparseNode($,T,W){let X=typeof $==="string"?$:MX(T,$);if(v$(T)&&T.kind===X)return T;if(X==="alias"&&!W?.prereduced){let{reference:G}=RX.implementation.normalize(T,this);if(G.startsWith("$")){let J=this.resolveRoot(G.slice(1));T=J,X=J.kind}}else if(X==="union"&&c4(T,"object")){let G=tP(T);if(G?.length===1)T=G[0],X=MX(T)}if(v$(T)&&T.kind===X)return T;let U=pT[X].normalize?.(T,this)??T;if(v$(U))return U.kind===X?U:aP(X,U.kind);return{...W,$:this,kind:X,def:U,prefix:W.alias??X}}bindReference($){let T;if(v$($))T=$.$===this?$:new $.constructor($.attachments,this);else T=$.$===this?$:new l1($.params,$.bodyDef,$.$,this,$.hkt);if(!this.resolved)Object.assign(this.referencesById,T.referencesById);return T}resolveRoot($){return this.maybeResolveRoot($)??L($5($))}maybeResolveRoot($){let T=this.maybeResolve($);if(o(T,"generic"))return;return T}maybeResolveSubalias($){return s_(this.aliases,$)??s_(this.ambient,$)}get ambient(){return I.ambient}maybeResolve($){let T=this.resolutions[$];if(T){if(typeof T!=="string")return this.bindReference(T);let X=v4[T];if(o(X,"root"))return this.resolutions[$]=X;if(o(X,"context")){if(X.phase==="resolving")return this.node("alias",{reference:`$${$}`},{prereduced:!0});if(X.phase==="resolved")return O$(`Unexpected resolved context for was uncached by its scope: ${U$(X)}`);X.phase="resolving";let Y=this.bindReference(this.parseOwnDefinitionFormat(X.def,X));return X.phase="resolved",v4[Y.id]=Y,v4[X.id]=Y,this.resolutions[$]=Y}return O$(`Unexpected nodesById entry for ${T}: ${U$(X)}`)}let W=this.aliases[$]??this.ambient?.[$];if(!W)return this.maybeResolveSubalias($);if(W=this.normalizeRootScopeValue(W),o(W,"generic"))return this.resolutions[$]=this.bindReference(W);if(o(W,"module")){if(!W.root)L(bK($));return this.resolutions[$]=this.bindReference(W.root)}return this.resolutions[$]=this.parse(W,{alias:$})}createParseContext($){let T=$.id??x_($.prefix);return v4[T]=Object.assign($,{[C4]:"context",$:this,id:T,phase:"unresolved"})}traversal($){return new B6($,this.resolvedConfig)}import(...$){return new lT(Y$(this.export(...$),(T,W)=>[`#${T}`,W]))}precompilation;_exportedResolutions;_exports;export(...$){if(!this._exports){this._exports={};for(let W of this.exportedNames){let X=this.aliases[W];this._exports[W]=o(X,"module")?t_(X,this):qK(this.maybeResolve(W))}for(let W of this.lazyResolutions)W.resolution;if(this._exportedResolutions=xK(this,this._exports),this._json=jK(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let W=vK(this.references);this.precompilation=W.write(PK,4),CK(this.references,W)}this.resolved=!0}let T=$.length?$:this.exportedNames;return new lT(Y$(T,(W,X)=>[X,this._exports[X]]))}resolve($){return this.export()[$]}node=($,T,W={})=>{let X=this.preparseNode($,T,W);if(v$(X))return this.bindReference(X);let Y=this.createParseContext(X),U=b_(Y),G=this.bindReference(U);return v4[Y.id]=G};parse=($,T={})=>this.finalize(this.parseDefinition($,T));parseDefinition($,T={}){if(o($,"root"))return this.bindReference($);let W=this.preparseOwnDefinitionFormat($,T);if(o(W,"root"))return this.bindReference(W);let X=this.createParseContext(W);v4[X.id]=X;let Y=this.bindReference(this.parseOwnDefinitionFormat($,X));if(Y.isCyclic)Y=TK(Y,X.id);return v4[X.id]=Y,Y}finalize($){if(qK($),!$.precompilation&&!this.resolvedConfig.jitless)sP($.references);return $}}class e_ extends SU{parseOwnDefinitionFormat($,T){return b_(T)}preparseOwnDefinitionFormat($,T){return this.preparseNode(MX($),$,T)}preparseOwnAliasEntry($,T){return[$,T]}normalizeRootScopeValue($){return $}}var qK=($)=>{let T=$.references.filter((W)=>W.hasKind("alias"));for(let W of T){Object.assign(W.referencesById,W.resolution.referencesById);for(let X of $.references)if(W.id in X.referencesById)Object.assign(X.referencesById,W.referencesById)}return $},jK=($)=>Y$($,(T,W)=>[T,o(W,"root")||o(W,"generic")?W.json:o(W,"module")?jK(W):O$(`Unexpected resolution ${U$(W)}`)]),s_=($,T)=>{let W=T.indexOf(".");if(W===-1)return;let X=T.slice(0,W),Y=$[X];if(Y===void 0)return;if(!o(Y,"module"))return L(eP(X));let U=T.slice(W+1),G=Y[U];if(G===void 0)return s_(Y,U);if(o(G,"root")||o(G,"generic"))return G;if(o(G,"module"))return G.root??L(bK(T));O$(`Unexpected resolution for alias '${T}': ${U$(G)}`)},BU=($,T)=>new e_($,T),qX=new e_({});var xK=($,T)=>{let W={};for(let X in T){let Y=T[X];if(o(Y,"module")){let U=xK($,Y),G=Y$(U,(J,z)=>[`${X}.${J}`,z]);Object.assign(W,G)}else if(o(Y,"root")||o(Y,"generic"))W[X]=Y;else O$(`Unexpected scope resolution ${U$(Y)}`)}return W},$5=($)=>`'${$}' is unresolvable`,eP=($)=>`'${$}' must reference a module to be accessed using dot syntax`,bK=($)=>`Reference to submodule '${$}' must specify an alias`;qX.export();var{schema:E$,node:rT,defineSchema:R0$,generic:Z6}=qX;var T5="^(?:0|[1-9]\\d*)$",$C=new RegExp(T5),q0$=d$($C);var fK=BU({bigint:"bigint",boolean:[{unit:!1},{unit:!0}],false:{unit:!1},never:[],null:{unit:null},number:"number",object:"object",string:"string",symbol:"symbol",true:{unit:!0},unknown:{},undefined:{unit:void 0},Array,Date},{prereducedAliases:!0}).export();I.intrinsic={...fK};var yK=BU({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:T5}},{prereducedAliases:!0}).export();Object.assign(I.intrinsic,yK);var TC=BU({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),n={...fK,...yK,...TC,emptyStructure:rT("structure",{},{prereduced:!0})};I.intrinsic={...n};var gK=($)=>typeof $==="string"&&$[0]==="d"&&($[1]==="'"||$[1]==='"')&&$.at(-1)===$[1],hK=($)=>$.toString()!=="Invalid Date",mK=($)=>$.slice(2,-1),W5=($)=>`'${$}' could not be parsed by the Date constructor`,cK=($,T)=>WC($,T),WC=($,T)=>{let W=new Date($);if(hK(W))return W;let X=EV($);if(X!==void 0){let Y=new Date(X);if(hK(Y))return Y}return T?L(T===!0?W5($):T):void 0};var X5=($,T)=>{let W=$.scanner.shiftUntil(XC[pK[T]]);if($.scanner.lookahead==="")return $.error(UC(W,T));if($.scanner.shift(),T==="/"){try{new RegExp(W)}catch(X){L(String(X))}$.root=$.ctx.$.node("intersection",{domain:"string",pattern:W},{prereduced:!0})}else if(z4(T,Y5))$.root=$.ctx.$.node("unit",{unit:W});else{let X=cK(W,W5(W));$.root=$.ctx.$.node("unit",{meta:W,unit:X})}},Y5={"'":1,'"':1},uK={"/":1,"'":1,'"':1},pK={"d'":"'",'d"':'"',"'":"'",'"':'"',"/":"/"},XC={"'":($)=>$.lookahead==="'",'"':($)=>$.lookahead==='"',"/":($)=>$.lookahead==="/"},YC={'"':"double-quote","'":"single-quote","/":"forward slash"},UC=($,T)=>`${T}${$} requires a closing ${YC[pK[T]]}`;var dK=($)=>`Private type references should not include '#'. Use '${$}' instead.`,RU="Optional definitions like 'string?' are only valid as properties in an object or tuple",IU="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var oK={">":!0,">=":!0},lK={"<":!0,"<=":!0};var iT={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},rK=($)=>`Unmatched )${$===""?"":` before ${$}`}`,kU=($)=>`Missing ${$}`,iK=($,T)=>`Left bounds are only valid when paired with right bounds (try ...${T}${$})`,qU=($)=>`Left-bounded expressions must specify their limits using < or <= (was ${$})`,nK=($,T,W,X)=>`An expression may have at most one left bound (parsed ${$}${iT[T]}, ${W}${iT[X]})`;var tK=($,T,W)=>aK($,T,W,[]),aK=($,T,W,X)=>{let Y=W.parseUntilFinalizer();if(X.push(Y.root),Y.finalizer===">"){if(X.length!==T.params.length)return W.error(U5($,T.names,X.map((U)=>U.expression)));return X}if(Y.finalizer===",")return aK($,T,W,X);return Y.error(kU(">"))},U5=($,T,W)=>`${$}<${T.join(", ")}> requires exactly ${T.length} args (got ${W.length}${W.length===0?"":`: ${W.join(", ")}`})`;var G5=($)=>{let T=$.scanner.shiftUntilNextTerminator();if(T==="keyof")$.addPrefix("keyof");else $.root=JC($,T)},GC=($,T,W)=>{if(W.scanner.shiftUntilNonWhitespace(),W.scanner.shift()!=="<")return W.error(U5($,T.names,[]));let Y=tK($,T,W);return T(...Y)},JC=($,T)=>wC($,T)??zC($,T)??$.error(T===""?$.scanner.lookahead==="#"?dK($.shiftedByOne().scanner.shiftUntilNextTerminator()):J5($):$5(T)),wC=($,T)=>{if($.ctx.args?.[T]){let X=$.ctx.args[T];if(typeof X!=="string")return X;return $.ctx.$.node("alias",{reference:X},{prereduced:!0})}let W=$.ctx.$.maybeResolve(T);if(o(W,"root"))return W;if(W===void 0)return;if(o(W,"generic"))return GC(T,W,$);return L(`Unexpected resolution ${U$(W)}`)},zC=($,T)=>{let W=MV(T);if(W!==void 0)return $.ctx.$.node("unit",{unit:W});let X=NV(T);if(X!==void 0)return $.ctx.$.node("unit",{unit:X})},J5=($)=>{let T=$.previousOperator();return T?w5(T,$.scanner.unscanned):_C($.scanner.unscanned)},w5=($,T="")=>`Token '${$}' requires a right operand${T?` before '${T}'`:""}`,_C=($)=>`Expected an expression${$?` before '${$}'`:""}`;var z5=($)=>$.scanner.lookahead===""?$.error(J5($)):$.scanner.lookahead==="("?$.shiftedByOne().reduceGroupOpen():$.scanner.lookaheadIsIn(uK)?X5($,$.scanner.shift()):$.scanner.lookaheadIsIn(u1)?z5($.shiftedByOne()):$.scanner.lookahead==="d"?$.scanner.nextLookahead in Y5?X5($,`${$.scanner.shift()}${$.scanner.shift()}`):G5($):G5($);class Z1 extends Z_{shiftUntilNextTerminator(){return this.shiftUntilNonWhitespace(),this.shiftUntil(()=>(this.lookahead in Z1.terminatingChars))}static terminatingChars={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...u1};static finalizingLookaheads={">":1,",":1,"":1,"=":1,"?":1};static lookaheadIsFinalizing=($,T)=>$===">"?T[0]==="="?T[1]==="=":T.trimStart()===""||z4(T.trimStart()[0],Z1.terminatingChars):$==="="?T[0]!=="=":$===","||$==="?"}var eK=($,T)=>{let W=HC($,T);if($.root.hasKind("unit")){if(typeof $.root.unit==="number"){$.reduceLeftBound($.root.unit,W),$.unsetRoot();return}if($.root.unit instanceof Date){let X=`d'${$.root.description??$.root.unit.toISOString()}'`;$.unsetRoot(),$.reduceLeftBound(X,W);return}}return QC($,W)},$E={"<":1,">":1,"=":1},HC=($,T)=>$.scanner.lookaheadIs("=")?`${T}${$.scanner.shift()}`:T;var sK=($,T,W,X)=>{if(W.extends(I.intrinsic.number)){if(typeof T!=="number")return L(_5($,T,X));return $==="=="?["min","max"]:$[0]===">"?["min"]:["max"]}if(W.extends(I.intrinsic.lengthBoundable)){if(typeof T!=="number")return L(_5($,T,X));return $==="=="?["exactLength"]:$[0]===">"?["minLength"]:["maxLength"]}if(W.extends(I.intrinsic.Date))return $==="=="?["after","before"]:$[0]===">"?["after"]:["before"];return L(uV(W.expression))},FC=($)=>({rule:gK($.limit)?mK($.limit):$.limit,exclusive:$.comparator.length===1}),QC=($,T)=>{let W=$.unsetRoot(),X=$.scanner.location;$.parseOperand();let Y=$.unsetRoot(),U=$.scanner.sliceChars(X,$.scanner.location);if($.root=W,!Y.hasKind("unit")||typeof Y.unit!=="number"&&!(Y.unit instanceof Date))return $.error(_5(T,U,"right"));let G=Y.unit,J=T.length===1,z=sK(T,typeof G==="number"?G:U,W,"right");for(let H of z)$.constrainRoot(H,T==="=="?{rule:G}:{rule:G,exclusive:J});if(!$.branches.leftBound)return;if(!z4(T,lK))return $.error(qU(T));let w=sK($.branches.leftBound.comparator,$.branches.leftBound.limit,W,"left");$.constrainRoot(w[0],FC($.branches.leftBound)),$.branches.leftBound=null},_5=($,T,W)=>`Comparator ${W==="left"?iT[$]:$} must be ${W==="left"?"preceded":"followed"} by a corresponding literal (was ${T})`;var TE=($)=>{$.scanner.shiftUntilNonWhitespace();let T=$.scanner.shiftUntilNextTerminator();$.root=$.root.brand(T)};var XE=($)=>{let T=$.scanner.shiftUntilNextTerminator(),W=AV(T,{errorOnFail:WE(T)});if(W===0)$.error(WE(0));$.root=$.root.constrain("divisor",W)},WE=($)=>`% operator must be followed by a non-zero integer literal (was ${$})`;var H5=($)=>{let T=$.scanner.shift();return T===""?$.finalize(""):T==="["?$.scanner.shift()==="]"?$.setRoot($.root.array()):$.error(ZC):T==="|"?$.scanner.lookahead===">"?$.shiftedByOne().pushRootToBranch("|>"):$.pushRootToBranch(T):T==="&"?$.pushRootToBranch(T):T===")"?$.finalizeGroup():Z1.lookaheadIsFinalizing(T,$.scanner.unscanned)?$.finalize(T):z4(T,$E)?eK($,T):T==="%"?XE($):T==="#"?TE($):(T in u1)?H5($):$.error(PU(T))},PU=($,T="")=>`'${$}' is not allowed here${T&&` (should be ${T})`}`,ZC="Missing expected ']'";var YE=($)=>{let T=$.unsetRoot();$.parseOperand();let W=$.unsetRoot();if(!W.hasKind("unit"))return $.error(DC(W.expression));let X=W.unit instanceof Date?()=>new Date(W.unit):W.unit;return[T,"=",X]},DC=($)=>`Default value '${$}' must a literal value`;var F5=($,T)=>{let W=T.$.maybeResolveRoot($);if(W)return W;if($.endsWith("[]")){let U=T.$.maybeResolveRoot($.slice(0,-2));if(U)return U.array()}let X=new nT(new Z1($),T),Y=OC(X);if(X.finalizer===">")L(PU(">"));return Y},OC=($)=>{$.parseOperand();let T=PX($).root;if(!T)return O$(`Root was unexpectedly unset after parsing string '${$.scanner.scanned}'`);if($.finalizer==="=")T=YE($);else if($.finalizer==="?")T=[T,"?"];if($.scanner.shiftUntilNonWhitespace(),$.scanner.lookahead)L(PU($.scanner.lookahead));return T},PX=($)=>{while($.finalizer===void 0)VC($);return $},VC=($)=>$.hasRoot()?$.parseOperator():$.parseOperand();class nT{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor($,T){this.scanner=$,this.ctx=T}error($){return L($)}hasRoot(){return this.root!==void 0}setRoot($){this.root=$}unsetRoot(){let $=this.root;return this.root=void 0,$}constrainRoot(...$){this.root=this.root.constrain($[0],$[1])}finalize($){if(this.groups.length)return this.error(kU(")"));this.finalizeBranches(),this.finalizer=$}reduceLeftBound($,T){let W=iT[T];if(!z4(W,oK))return this.error(qU(T));if(this.branches.leftBound)return this.error(nK(this.branches.leftBound.limit,this.branches.leftBound.comparator,$,W));this.branches.leftBound={comparator:W,limit:$}}finalizeBranches(){if(this.assertRangeUnset(),this.branches.pipe){this.pushRootToBranch("|>"),this.root=this.branches.pipe;return}if(this.branches.union){this.pushRootToBranch("|"),this.root=this.branches.union;return}if(this.branches.intersection){this.pushRootToBranch("&"),this.root=this.branches.intersection;return}this.applyPrefixes()}finalizeGroup(){this.finalizeBranches();let $=this.groups.pop();if(!$)return this.error(rK(this.scanner.unscanned));this.branches=$}addPrefix($){this.branches.prefixes.push($)}applyPrefixes(){while(this.branches.prefixes.length){let $=this.branches.prefixes.pop();this.root=$==="keyof"?this.root.keyof():O$(`Unexpected prefix '${$}'`)}}pushRootToBranch($){this.assertRangeUnset(),this.applyPrefixes();let T=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(T)??T,$==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,$==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return PX(new nT(this.scanner,this.ctx))}parseOperator(){return H5(this)}parseOperand(){return z5(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(iK(this.branches.leftBound.limit,this.branches.leftBound.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={prefixes:[],leftBound:null,union:null,intersection:null,pipe:null}}previousOperator(){return this.branches.leftBound?.comparator??this.branches.prefixes.at(-1)??(this.branches.intersection?"&":this.branches.union?"|":this.branches.pipe?"|>":void 0)}shiftedByOne(){return this.scanner.shift(),this}}var KC="An empty string is not a valid generic parameter name",CU=($,T,W)=>{$.shiftUntilNonWhitespace();let X=$.shiftUntilNextTerminator();if(X===""){if($.lookahead===""&&T.length)return T;return L(KC)}return $.shiftUntilNonWhitespace(),EC($,X,T,W)},UE="extends ",EC=($,T,W,X)=>{if($.shiftUntilNonWhitespace(),$.unscanned.startsWith(UE))$.jumpForward(UE.length);else{if($.lookahead===",")$.shift();return W.push(T),CU($,W,X)}let Y=PX(new nT($,X));return W.push([T,Y.root]),CU($,W,X)};class Q5 extends S6{$;constructor($){super((...T)=>new CX($)(...T),{bind:$});this.$=$}in($){return new CX(this.$,$===void 0?void 0:this.$.parse($))}at($,T){return new CX(this.$).at($,T)}case($,T){return new CX(this.$).case($,T)}}class CX extends S6{$;in;key;branches=[];constructor($,T){super((W)=>this.caseEntries(Object.entries(W).map(([X,Y])=>X==="default"?[X,Y]:[this.$.parse(X),Y])));this.$=$,this.in=T}at($,T){if(this.key)L(AC);if(this.branches.length)L(MC);return this.key=$,T?this.match(T):this}case($,T){return this.caseEntry(this.$.parse($),T)}caseEntry($,T){let X=(this.key?this.$.parse({[this.key]:$}):$).pipe(T);return this.branches.push(X),this}match($){return this($)}strings($){return this.caseEntries(Object.entries($).map(([T,W])=>T==="default"?[T,W]:[this.$.node("unit",{unit:T}),W]))}caseEntries($){for(let T=0;T<$.length;T++){let[W,X]=$[T];if(W==="default"){if(T!==$.length-1)L("default may only be specified as the last key of a switch definition");return this.default(X)}if(typeof X!=="function")return L(`Value for case "${W}" must be a function (was ${w4(X)})`);this.caseEntry(W,X)}return this}default($){if(typeof $==="function")this.case(n.unknown,$);let T={branches:this.branches,ordered:!0};if($==="never"||$==="assert")T.meta={onFail:GE};let W=this.$.node("union",T);if(!this.in)return this.$.finalize(W);let X=this.in.pipe(W);if($==="never"||$==="assert")X=X.configureReferences({onFail:GE},"self");return this.$.finalize(X)}}var GE=($)=>$.throw(),MC="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",AC="At most one key matcher may be specified per expression";var vU=($,T)=>{if(I$($)){if($[1]==="=")return[T.$.parseOwnDefinitionFormat($[0],T),"=",$[2]];if($[1]==="?")return[T.$.parseOwnDefinitionFormat($[0],T),"?"]}return jU($,T)},JE="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",wE="Only required keys may specify default values, e.g. { value: 'number = 0' }";var zE=($,T)=>{let W,X={},Y=j0($);for(let[G,J]of Y){let z=SC(G);if(z.kind==="spread"){if(!m6(X))return L(LC);let D=T.$.parseOwnDefinitionFormat(J,T);if(D.equals(n.object))continue;if(!D.hasKind("intersection")||!D.basis?.equals(n.object))return L(BC(D.expression));W=D.structure;continue}if(z.kind==="undeclared"){if(J!=="reject"&&J!=="delete"&&J!=="ignore")L(NC(J));X.undeclared=J;continue}let w=vU(J,T),H=z;if(z.kind==="required"){if(!I$(w))Z5(X,"required",{key:z.normalized,value:w},T);else Z5(X,"optional",w[1]==="="?{key:z.normalized,value:w[0],default:w[2]}:{key:z.normalized,value:w[0]},T);continue}if(I$(w)){if(w[1]==="?")L(JE);if(w[1]==="=")L(wE)}if(z.kind==="optional"){Z5(X,"optional",{key:z.normalized,value:w},T);continue}let _=T.$.parseOwnDefinitionFormat(H.normalized,T),F=LU(_,w,T.$);if(F.index)X.index=Q$(X.index,F.index);if(F.required)X.required=Q$(X.required,F.required)}let U=T.$.node("structure",X);return T.$.parseSchema({domain:"object",structure:W?.merge(U)??U})},Z5=($,T,W,X)=>{$[T]=Q$($[T],X.$.node(T,W))},NC=($)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${U$($)})`,LC="Spread operator may only be used as the first key in an object",SC=($)=>typeof $==="symbol"?{kind:"required",normalized:$}:$.at(-1)==="?"?$.at(-2)===zX?{kind:"required",normalized:`${$.slice(0,-2)}?`}:{kind:"optional",normalized:$.slice(0,-1)}:$[0]==="["&&$.at(-1)==="]"?{kind:"index",normalized:$.slice(1,-1)}:$[0]===zX&&$[1]==="["&&$.at(-1)==="]"?{kind:"required",normalized:$.slice(1)}:$==="..."?{kind:"spread"}:$==="+"?{kind:"undeclared"}:{kind:"required",normalized:$==="\\..."?"...":$==="\\+"?"+":$},BC=($)=>`Spread operand must resolve to an object literal type (was ${$})`;var HE=($,T)=>bC($)?DE[$[0]]($,T):jC($)?ZE[$[1]]($,T):null,RC=($,T)=>T.$.parseOwnDefinitionFormat($[1],T).keyof(),D5=($,T)=>{if($[2]===void 0)return L(w5($[1],""));let W=T.$.parseOwnDefinitionFormat($[0],T),X=T.$.parseOwnDefinitionFormat($[2],T);if($[1]==="|")return T.$.node("union",{branches:[W,X]});let Y=$[1]==="&"?o4(W,X,T.$):EX(W,X,T.$);if(Y instanceof f)return Y.throw();return Y},IC=($,T)=>T.$.parseOwnDefinitionFormat($[0],T).array(),kC=($,T)=>{if(typeof $[2]!=="function")return L(FE("=>",$[2]));return T.$.parseOwnDefinitionFormat($[0],T).pipe($[2])},FE=($,T)=>`${$===":"?"Narrow":"Morph"} expression requires a function following '${$}' (was ${typeof T})`,qC=($,T)=>{if(typeof $[2]!=="function")return L(FE(":",$[2]));return T.$.parseOwnDefinitionFormat($[0],T).constrain("predicate",$[2])},PC=($,T)=>T.$.parseOwnDefinitionFormat($[0],T).configureReferences($[2],"shallow"),QE=($)=>$,CC=QE({"[]":IC,"?":()=>L(RU)}),vC=QE({"|":D5,"&":D5,":":qC,"=>":kC,"|>":D5,"@":PC,"=":()=>L(IU)}),ZE={...CC,...vC},jC=($)=>ZE[$[1]]!==void 0,xC=($)=>$,DE=xC({keyof:RC,instanceof:($,T)=>{if(typeof $[1]!=="function")return L(_E(JX($[1])));let W=$.slice(1).map((X)=>typeof X==="function"?T.$.node("proto",{proto:X}):L(_E(JX(X))));return W.length===1?W[0]:T.$.node("union",{branches:W})},"===":($,T)=>T.$.units($.slice(1))}),bC=($)=>DE[$[0]]!==void 0,_E=($)=>`Expected a constructor following 'instanceof' operator (was ${$})`;var KE=($,T)=>{let W=[{}],X=0;while(X<$.length){let Y=!1;if($[X]==="..."&&X<$.length-1)Y=!0,X++;let U=vU($[X],T),[G,J,z]=!I$(U)?[U]:U;if(X++,Y){if(!G.extends(I.intrinsic.Array))return L(hC(G.expression));W=W.flatMap((w)=>G.distribute((H)=>yC(FU(w),H)))}else W=W.map((w)=>{if(J==="?")return EE(w,G);if(J==="=")return fC(w,G,z);return O5(w,G)})}return T.$.parseSchema(W.map((Y)=>m6(Y)?{proto:Array,exactLength:0}:{proto:Array,sequence:Y}))},O5=($,T)=>{if($.defaultables||$.optionals)return L($.variadic?r_:gC);if($.variadic)$.postfix=Q$($.postfix,T);else $.prefix=Q$($.prefix,T);return $},EE=($,T)=>{if($.variadic)return L(ME);return $.optionals=Q$($.optionals,T),$},fC=($,T,W)=>{if($.variadic)return L(ME);if($.optionals)return L(mC);return $.defaultables=Q$($.defaultables,[[T,W]]),$},OE=($,T)=>{if($.postfix)L(VE);if($.variadic){if(!$.variadic.equals(T))L(VE)}else $.variadic=T.internal;return $},yC=($,T)=>{let W=T.select({method:"find",kind:"sequence"});if(!W)return OE($,I.intrinsic.unknown);if(W.prefix)for(let X of W.prefix)O5($,X);if(W.optionals)for(let X of W.optionals)EE($,X);if(W.variadic)OE($,W.variadic);if(W.postfix)for(let X of W.postfix)O5($,X);return $},hC=($)=>`Spread element must be an array (was ${$})`,VE="A tuple may have at most one variadic element",gC="A required element may not follow an optional element",ME="An optional element may not follow a variadic element";var mC="A defaultable element may not follow an optional element without a default";var cC={},jU=($,T)=>{if(typeof $==="string"){if(T.args&&Object.keys(T.args).some((X)=>$.includes(X)))return F5($,T);let W=cC[T.$.name]??={};return W[$]??=F5($,T)}return c4($,"object")?uC($,T):L(V5(w4($)))},uC=($,T)=>{let W=GX($);switch(W){case void 0:if(o($,"root"))return $;return zE($,T);case"Array":return pC($,T);case"RegExp":return T.$.node("intersection",{domain:"string",pattern:$},{prereduced:!0});case"Function":{let X=c1($)?$():$;if(o(X,"root"))return X;return L(V5("Function"))}default:return L(V5(W??U$($)))}},pC=($,T)=>HE($,T)??KE($,T),V5=($)=>`Type definitions must be strings or objects (was ${$})`;class K5 extends S6{constructor($){let T=Object.assign({errors:p4,hkt:L4,$,raw:$.parse,module:$.constructor.module,scope:$.constructor.scope,define:$.define,match:$.match,generic:$.generic,schema:$.schema,keywords:$.ambient,unit:$.unit,enumerated:$.enumerated,instanceOf:$.instanceOf,valueOf:$.valueOf,or:$.or,and:$.and,merge:$.merge,pipe:$.pipe},$.ambientAttachments);super((...W)=>{if(W.length===1)return $.parse(W[0]);if(W.length===2&&typeof W[0]==="string"&&W[0][0]==="<"&&W[0].at(-1)===">"){let X=W[0].slice(1,-1),Y=$.parseGenericParams(X,{});return new l1(Y,W[1],$,$,null)}return $.parse(W)},{bind:$,attach:T})}}var tT=I;class xU extends SU{get ambientAttachments(){if(!tT.typeAttachments)return;return this.cacheGetter("ambientAttachments",Y$(tT.typeAttachments,($,T)=>[$,this.bindReference(T)]))}preparseOwnAliasEntry($,T){let W=$.indexOf("<");if(W===-1){if(o(T,"module")||o(T,"generic"))return[$,T];let U=this.name==="ark"?$:$==="root"?this.name:`${this.name}.${$}`,G=this.resolvedConfig.keywords?.[U];if(G)T=[T,"@",G];return[$,T]}if($.at(-1)!==">")L("'>' must be the last character of a generic declaration in a scope");let X=$.slice(0,W),Y=$.slice(W+1,-1);return[X,()=>{let U=this.parseGenericParams(Y,{alias:X});return gV(U,T,this)}]}parseGenericParams($,T){return CU(new Z1($),[],this.createParseContext({...T,def:$,prefix:"generic"}))}normalizeRootScopeValue($){if(c1($)&&!o($,"generic"))return $();return $}preparseOwnDefinitionFormat($,T){return{...T,def:$,prefix:T.alias??"type"}}parseOwnDefinitionFormat($,T){if(!(T.alias&&(T.alias in this.aliases))&&!T.args)T.args={this:T.id};let X=jU($,T);if(I$(X)){if(X[1]==="=")return L(IU);if(X[1]==="?")return L(RU)}return X}unit=($)=>this.units([$]);valueOf=($)=>this.units(UV($));enumerated=(...$)=>this.units($);instanceOf=($)=>this.node("proto",{proto:$},{prereduced:!0});or=(...$)=>this.schema($.map((T)=>this.parse(T)));and=(...$)=>$.reduce((T,W)=>T.and(this.parse(W)),this.intrinsic.unknown);merge=(...$)=>$.reduce((T,W)=>T.merge(this.parse(W)),this.intrinsic.object);pipe=(...$)=>this.intrinsic.unknown.pipe(...$);match=new Q5(this);declare=()=>({type:this.type});define($){return $}type=new K5(this);static scope=($,T={})=>new xU($,T);static module=($,T={})=>this.scope($,T).export()}var E5=Object.assign(xU.scope,{define:($)=>$}),_$=xU;class AE extends L4{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var dC=Z6(["base",n.object],["props",n.object])(($)=>$.base.merge($.props),AE),NE=_$.module({Key:n.key,Merge:dC});class LE extends L4{}var oC=Z6("element")(($)=>{let T=$.element.exclude(n.Array),W=T.array();return T.rawOr(W).pipe(m1).distribute((X)=>X.assertHasKind("morph").declareOut(W),E$)},LE),SE=_$.module({root:n.Array,readonly:"root",index:n.nonNegativeIntegerString,liftFrom:oC},{name:"Array"});var M5=E$(["string",b0.FileConstructor]),lC=M5.rawOr(M5.array()),BE=E$({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:lC}}),RE=_$.module({root:["instanceof",FormData],value:M5,parsed:BE,parse:E$({in:FormData,morphs:($)=>{let T={};for(let[W,X]of $)if(W in T){let Y=T[W];if(typeof Y==="string"||Y instanceof b0.FileConstructor)T[W]=[Y,X];else Y.push(X)}else T[W]=X;return T},declaredOut:BE})},{name:"FormData"});var IE=_$.module({Int8:["instanceof",Int8Array],Uint8:["instanceof",Uint8Array],Uint8Clamped:["instanceof",Uint8ClampedArray],Int16:["instanceof",Int16Array],Uint16:["instanceof",Uint16Array],Int32:["instanceof",Int32Array],Uint32:["instanceof",Uint32Array],Float32:["instanceof",Float32Array],Float64:["instanceof",Float64Array],BigInt64:["instanceof",BigInt64Array],BigUint64:["instanceof",BigUint64Array]},{name:"TypedArray"});var rC={Boolean:1,Number:1,String:1},kE=_$.module({...Y$({...G_,...w_},($,T)=>($ in rC)?[]:[$,["instanceof",T]]),Array:SE,TypedArray:IE,FormData:RE});var iC=E$({domain:{domain:"number",meta:"a number representing a Unix timestamp"},divisor:{rule:1,meta:"an integer representing a Unix timestamp"},min:{rule:-8640000000000000,meta:"a Unix timestamp after -8640000000000000"},max:{rule:8640000000000000,meta:"a Unix timestamp before 8640000000000000"},meta:"an integer representing a safe Unix timestamp"}),nC=E$({domain:"number",divisor:1}),bU=_$.module({root:n.number,integer:nC,epoch:iC,safe:E$({domain:{domain:"number",numberAllowsNaN:!1},min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}),NaN:["===",Number.NaN],Infinity:["===",Number.POSITIVE_INFINITY],NegativeInfinity:["===",Number.NEGATIVE_INFINITY]},{name:"number"});var h$=($,T,W)=>{let X={domain:"string",pattern:{rule:$.source,flags:$.flags,meta:T}};if(W)X.meta={format:W};return rT("intersection",X)},qE=h$(_X,"a well-formed integer string"),cE=_$.module({root:qE,parse:E$({in:qE,morphs:($,T)=>{let W=Number.parseInt($);return Number.isSafeInteger(W)?W:T.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:n.integer})},{name:"string.integer"}),tC=h$(/^[\dA-Fa-f]+$/,"hex characters only"),aC=_$.module({root:h$(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:h$(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),PE=h$(/^[A-Z].*$/,"capitalized"),sC=_$.module({root:E$({in:"string",morphs:($)=>$.charAt(0).toUpperCase()+$.slice(1),declaredOut:PE}),preformatted:PE},{name:"string.capitalize"}),eC=($)=>{let T=$.replaceAll(/[ -]+/g,""),W=0,X,Y,U=!1;for(let G=T.length-1;G>=0;G--){if(X=T.substring(G,G+1),Y=Number.parseInt(X,10),U)Y*=2,W+=Y>=10?Y%10+1:Y;else W+=Y;U=!U}return!!(W%10===0?T:!1)},$v=/^(?:4\d{12}(?:\d{3,6})?|5[1-5]\d{14}|(222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}|6(?:011|5\d\d)\d{12,15}|3[47]\d{13}|3(?:0[0-5]|[68]\d)\d{11}|(?:2131|1800|35\d{3})\d{11}|6[27]\d{14}|^(81\d{14,17}))$/,Tv=E$({domain:"string",pattern:{meta:"a credit card number",rule:$v.source},predicate:{meta:"a credit card number",predicate:eC}});var Wv=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(T((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([,.]\d+(?!:))?)?(\17[0-5]\d([,.]\d+)?)?([Zz]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;var Xv=($)=>!Number.isNaN(new Date($).valueOf()),CE=E$({domain:"string",predicate:{meta:"a parsable date",predicate:Xv}}).assertHasKind("intersection"),vE=cE.root.internal.narrow(($,T)=>{let W=Number.parseInt($),X=bU.epoch(W);if(X instanceof p4)return T.errors.merge(X),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),Yv=_$.module({root:vE,parse:E$({in:vE,morphs:($)=>new Date($),declaredOut:n.Date})},{name:"string.date.epoch"}),jE=h$(Wv,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),Uv=_$.module({root:jE,parse:E$({in:jE,morphs:($)=>new Date($),declaredOut:n.Date})},{name:"string.date.iso"}),Gv=_$.module({root:CE,parse:E$({declaredIn:CE,in:"string",morphs:($,T)=>{let W=new Date($);if(Number.isNaN(W.valueOf()))return T.error("a parsable date");return W},declaredOut:n.Date}),iso:Uv,epoch:Yv},{name:"string.date"}),Jv=h$(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),xE="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",r1=`(${xE}[.]){3}${xE}`,wv=new RegExp(`^${r1}$`),s$="(?:[0-9a-fA-F]{1,4})",zv=new RegExp(`^((?:${s$}:){7}(?:${s$}|:)|(?:${s$}:){6}(?:${r1}|:${s$}|:)|(?:${s$}:){5}(?::${r1}|(:${s$}){1,2}|:)|(?:${s$}:){4}(?:(:${s$}){0,1}:${r1}|(:${s$}){1,3}|:)|(?:${s$}:){3}(?:(:${s$}){0,2}:${r1}|(:${s$}){1,4}|:)|(?:${s$}:){2}(?:(:${s$}){0,3}:${r1}|(:${s$}){1,5}|:)|(?:${s$}:){1}(?:(:${s$}){0,4}:${r1}|(:${s$}){1,6}|:)|(?::((?::${s$}){0,5}:${r1}|(?::${s$}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),_v=_$.module({root:["v4 | v6","@","an IP address"],v4:h$(wv,"an IPv4 address","ipv4"),v6:h$(zv,"an IPv6 address","ipv6")},{name:"string.ip"}),aT="a JSON string",uE=($)=>{if(!($ instanceof SyntaxError))throw $;return`must be ${aT} (${$})`},Hv=E$({meta:aT,domain:"string",predicate:{meta:aT,predicate:($,T)=>{try{return JSON.parse($),!0}catch(W){return T.reject({code:"predicate",expected:aT,problem:uE(W)})}}}}),Fv=($,T)=>{if($.length===0)return T.error({code:"predicate",expected:aT,actual:"empty"});try{return JSON.parse($)}catch(W){return T.error({code:"predicate",expected:aT,problem:uE(W)})}},Qv=_$.module({root:Hv,parse:E$({meta:"safe JSON string parser",in:"string",morphs:Fv,declaredOut:n.jsonObject})},{name:"string.json"}),bE=h$(/^[a-z]*$/,"only lowercase letters"),Zv=_$.module({root:E$({in:"string",morphs:($)=>$.toLowerCase(),declaredOut:bE}),preformatted:bE},{name:"string.lower"}),pE=["NFC","NFD","NFKC","NFKD"],vX=Y$(pE,($,T)=>[T,E$({domain:"string",predicate:(W)=>W.normalize(T)===W,meta:`${T}-normalized unicode`})]),fU=Y$(pE,($,T)=>[T,E$({in:"string",morphs:(W)=>W.normalize(T),declaredOut:vX[T]})]),Dv=_$.module({root:fU.NFC,preformatted:vX.NFC},{name:"string.normalize.NFC"}),Ov=_$.module({root:fU.NFD,preformatted:vX.NFD},{name:"string.normalize.NFD"}),Vv=_$.module({root:fU.NFKC,preformatted:vX.NFKC},{name:"string.normalize.NFKC"}),Kv=_$.module({root:fU.NFKD,preformatted:vX.NFKD},{name:"string.normalize.NFKD"}),Ev=_$.module({root:"NFC",NFC:Dv,NFD:Ov,NFKC:Vv,NFKD:Kv},{name:"string.normalize"}),fE=h$(zU,"a well-formed numeric string"),Mv=_$.module({root:fE,parse:E$({in:fE,morphs:($)=>Number.parseFloat($),declaredOut:n.number})},{name:"string.numeric"}),yE="a regex pattern",Av=E$({domain:"string",predicate:{meta:yE,predicate:($,T)=>{try{return new RegExp($),!0}catch(W){return T.reject({code:"predicate",expected:yE,problem:String(W)})}}},meta:{format:"regex"}}),Nv=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*))*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/,Lv=h$(Nv,"a semantic version (see https://semver.org/)"),hE=h$(/^\S.*\S$|^\S?$/,"trimmed"),Sv=_$.module({root:E$({in:"string",morphs:($)=>$.trim(),declaredOut:hE}),preformatted:hE},{name:"string.trim"}),gE=h$(/^[A-Z]*$/,"only uppercase letters"),Bv=_$.module({root:E$({in:"string",morphs:($)=>$.toUpperCase(),declaredOut:gE}),preformatted:gE},{name:"string.upper"}),Rv=($)=>{if(URL.canParse)return URL.canParse($);try{return new URL($),!0}catch{return!1}},mE=E$({domain:"string",predicate:{meta:"a URL string",predicate:Rv},meta:{format:"uri"}}),Iv=_$.module({root:mE,parse:E$({declaredIn:mE,in:"string",morphs:($,T)=>{try{return new URL($)}catch{return T.error("a URL string")}},declaredOut:E$(URL)})},{name:"string.url"}),kv=_$.module({root:["versioned | nil | max","@",{description:"a UUID",format:"uuid"}],"#nil":"'00000000-0000-0000-0000-000000000000'","#max":"'ffffffff-ffff-ffff-ffff-ffffffffffff'","#versioned":/[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}/i,v1:h$(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:h$(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:h$(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:h$(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:h$(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:h$(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:h$(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:h$(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),dE=_$.module({root:n.string,alpha:h$(/^[A-Za-z]*$/,"only letters"),alphanumeric:h$(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:tC,base64:aC,capitalize:sC,creditCard:Tv,date:Gv,digits:h$(/^\d*$/,"only digits 0-9"),email:Jv,integer:cE,ip:_v,json:Qv,lower:Zv,normalize:Ev,numeric:Mv,regex:Av,semver:Lv,trim:Sv,upper:Bv,url:Iv,uuid:kv},{name:"string"});var oE=_$.module({bigint:n.bigint,boolean:n.boolean,false:n.false,never:n.never,null:n.null,number:n.number,object:n.object,string:n.string,symbol:n.symbol,true:n.true,unknown:n.unknown,undefined:n.undefined}),lE=_$.module({root:n.unknown,any:n.unknown},{name:"unknown"}),qv=_$.module({root:n.jsonObject,stringify:rT("morph",{in:n.jsonObject,morphs:($)=>JSON.stringify($),declaredOut:n.string})},{name:"object.json"}),rE=_$.module({root:n.object,json:qv},{name:"object"});class iE extends L4{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var Pv=Z6(["K",n.key],"V")(($)=>({domain:"object",index:{signature:$.K,value:$.V}}),iE);class nE extends L4{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var Cv=Z6(["T",n.object],["K",n.key])(($)=>$.T.pick($.K),nE);class tE extends L4{description='omit a set of properties from an object like `Omit(User, "age")`'}var vv=Z6(["T",n.object],["K",n.key])(($)=>$.T.omit($.K),tE);class aE extends L4{description="make all named properties of an object optional like `Partial(User)`"}var jv=Z6(["T",n.object])(($)=>$.T.partial(),aE);class sE extends L4{description="make all named properties of an object required like `Required(User)`"}var xv=Z6(["T",n.object])(($)=>$.T.required(),sE);class eE extends L4{description='exclude branches of a union like `Exclude("boolean", "true")`'}var bv=Z6("T","U")(($)=>$.T.exclude($.U),eE);class $M extends L4{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var fv=Z6("T","U")(($)=>$.T.extract($.U),$M),TM=_$.module({Exclude:bv,Extract:fv,Omit:vv,Partial:jv,Pick:Cv,Record:Pv,Required:xv});var i1=E5({...oE,...TM,...kE,...NE,string:dE,number:bU,object:rE,unknown:lE},{prereducedAliases:!0,name:"ark"}),_4=i1.export();Object.assign(tT.ambient,_4);tT.typeAttachments={string:_4.string.root,number:_4.number.root,bigint:_4.bigint,boolean:_4.boolean,symbol:_4.symbol,undefined:_4.undefined,null:_4.null,object:_4.object.root,unknown:_4.unknown.root,false:_4.false,true:_4.true,never:_4.never,arrayIndex:_4.Array.index,Key:_4.Key,Record:_4.Record,Array:_4.Array.root,Date:_4.Date};var I6=Object.assign(i1.type,tT.typeAttachments),yv=i1.match,hv=i1.generic,a2$=i1.schema,gv=i1.define,mv=i1.declare;var cv="__vite_start_time"in globalThis,uv=typeof window!=="undefined",DX$="vitest"in globalThis,D1=I6("string"),WM=I6('"true" | "false" | undefined'),O1=X_({isServer:!cv&&!uv,server:{CI:I6("string | undefined").pipe(Boolean),POSTGRES_USER:D1,POSTGRES_PASSWORD:D1,POSTGRES_DATABASE:D1,POSTGRES_HOST:D1,POSTGRES_PORT:D1.pipe(($)=>Number.parseInt($,10)),BACKEND_PORT:D1.pipe(($)=>Number.parseInt($,10)),RUN_WORKERS_FROM_SOURCE:WM.pipe(($)=>$==="true"),FRONTEND_PORT:D1.pipe(($)=>Number.parseInt($,10)),FRONTEND_ORIGINS:D1.pipe.try(($)=>JSON.parse($),I6("string[]")),API_KEY_OPENAI:I6("string | undefined"),API_KEY_RESEND:I6("string | undefined")},clientPrefix:"VITE_",client:{VITE_BACKEND_ORIGIN:D1,VITE_DEV_FRONTEND_HOST:I6("string | undefined"),VITE_DEV_HTTPS:WM.pipe(($)=>$==="true")},runtimeEnv:import.meta.env,emptyStringAsUndefined:!0});var N5={};M1(N5,{users:()=>h0,untrackedUserColumnNames:()=>pv,twoFactorMethod:()=>JM,trackedUserColumnName:()=>dv,trackableUserColumnNames:()=>UM,signInHistory:()=>lv,role:()=>YM,players:()=>A5,passwordResetAttempts:()=>rv,games:()=>yU,banishedIps:()=>hU,accountActions:()=>ov,accountAction:()=>GM});function XM($){return O`lower(${$})`}var YM=y2("role",["admin","user"]),h0=y1("users",{id:z6().primaryKey().defaultRandom(),username:q4({length:16}).notNull(),emailOffered:q4({length:254}).notNull(),emailVerified:q4({length:254}),password:q4({length:254}),createdAt:N6({withTimezone:!0}).notNull().defaultNow(),createdIp:q4({length:45}).notNull(),isActive:p2().notNull().default(!1),verifiedAt:N6({withTimezone:!0}),userRole:YM().default("user")},($)=>[s7("usernameUniqueIndex").on(XM($.username)),s7("emailVerifiedUniqueIndex").on(XM($.emailVerified))]),pv=["id","createdAt","createdIp","isActive","verifiedAt"],UM=["username","emailOffered","emailVerified","password","userRole"],dv=y2("trackedUserColumnName",UM),GM=y2("accountAction",["cooldown","confirmEmail","signIn","resetPassword"]),ov=y1("accountActions",{userId:z6().references(()=>h0.id).primaryKey(),action:GM().notNull(),code:q4({length:254}).notNull(),wrongCodeCount:d2().notNull().default(0),expiresAt:N6({withTimezone:!0}).notNull()}),yU=y1("games",{id:z6().primaryKey().defaultRandom()}),A5=y1("players",{userId:z6().notNull().references(()=>h0.id,{onDelete:"cascade"}),gameId:z6().notNull().references(()=>yU.id,{onDelete:"cascade"}),score:d2().notNull()},($)=>[iD({name:"players_userId_gameId_pk",columns:[$.userId,$.gameId]})]),lv=y1("signInHistory",{id:z6().primaryKey().defaultRandom(),userId:z6().references(()=>h0.id,{onDelete:"cascade"}),signInTime:N6({withTimezone:!0}).notNull().defaultNow(),ipAddress:q4({length:45}).notNull(),userAgent:q4({length:1024}),successful:p2().notNull().default(!1)}),JM=y2("twoFactorMethod",["email","phone"]),rv=y1("passwordResetAttempts",{id:z6().primaryKey().defaultRandom(),userId:z6().notNull().references(()=>h0.id,{onDelete:"cascade"}),requestedIp:q4({length:45}).notNull(),requestedAt:N6({withTimezone:!0}).notNull().defaultNow(),succeededIp:q4({length:45}),succeededAt:N6({withTimezone:!0}),verificationMethod:JM().notNull()}),hU=y1("banishedIps",{ip:q4({length:45}).primaryKey(),reason:q4({length:2048}).notNull(),banishedAt:N6({withTimezone:!0}).notNull().defaultNow(),banishedUntil:N6({withTimezone:!0})});var __dirname="/home/runner/work/wayforge/wayforge/apps/tempest.games/src/database";class L5{options;sql;drizzle;observers=new Map;async setupTriggersAndNotifications(){await this.sql.file(iv.resolve(__dirname,"notify_update.sql"));let $=[F4(h0),F4(yU),F4(A5)];await this.sql`SELECT create_notify_triggers(${this.sql.array($)})`,await this.sql.listen("table_update",(T)=>{let W=T.split(","),X=W[0],Y=W[1],U=`${X}("${Y}")`;if(this.observers.has(U))this.observers.get(U).next(U)})}constructor($=!1,T={host:O1.POSTGRES_HOST,port:O1.POSTGRES_PORT,user:O1.POSTGRES_USER,password:O1.POSTGRES_PASSWORD,database:O1.POSTGRES_DATABASE}){this.options=T,this.sql=PT(T),this.drizzle=JU(this.sql,{schema:N5,logger:$})}observe($,T){if(!this.observers.has($))this.observers.set($,new K$);this.observers.get($).subscribe("SINGLETON",T)}}import{resolve as av}from"path";import{existsSync as S5,mkdirSync as wM,readFileSync as nv,readdirSync as zM,rmSync as _M,statSync as HM,writeFileSync as tv}from"fs";import{resolve as B5}from"path";var FM=class{rootDir;get initialized(){return S5(this.rootDir)}initialize(){if(!this.initialized)wM(this.rootDir,{recursive:!0})}constructor($){if(this.rootDir=$.path,$.eagerInit)this.initialize()}getItem($){let T=B5(this.rootDir,$);if(S5(T))return nv(T,"utf-8");return null}setItem($,T){this.initialize();let W=B5(this.rootDir,$);tv(W,T)}removeItem($){let T=B5(this.rootDir,$);if(S5(T))this.initialize(),_M(T)}key($){return zM(this.rootDir).sort((X,Y)=>{let U=HM(X);return HM(Y).ctimeMs-U.ctimeMs})[$]??null}clear(){_M(this.rootDir,{recursive:!0}),wM(this.rootDir,{recursive:!0})}get length(){return zM(this.rootDir).length}};var R5=new FM({path:av(process.cwd(),"storage")});import*as gU from"fs";import*as QM from"readline";function sv($){let W=$.replace(":","T").replace(" ","").replace(/(\d{2})\/(\w{3})\/(\d{4})T(.+)/,(X,Y,U,G,J)=>{let w={Jan:"01",Feb:"02",Mar:"03",Apr:"04",May:"05",Jun:"06",Jul:"07",Aug:"08",Sep:"09",Oct:"10",Nov:"11",Dec:"12"}[U];return`${G}-${w}-${Y}T${J}`});return new Date(W)}async function ZM($,T="/var/log/nginx/access.log",W=new Date){let X=new Map;if(!gU.existsSync(T))return $.error(`Log file not found: ${T}`),X;let Y=gU.createReadStream(T),U=QM.createInterface({input:Y,crlfDelay:Number.POSITIVE_INFINITY}),G=new Date(W.getTime()-3600000);return U.on("line",(J)=>{let z=/^(?<ip>\S+) \S+ \S+ \[(?<dateTime>.*?)\]/,w=J.match(z);if(w?.groups){let H=w.groups.ip,_=w.groups.dateTime,F=sv(_);if(!Number.isNaN(F.getTime())){if(F>=G&&F<=W){let D=X.get(H);if(!D)D=[],X.set(H,D);D.push(J)}}else $.error(`Failed to parse date: ${_}`)}}),new Promise((J,z)=>{U.on("error",(w)=>{z(w)}),U.on("close",()=>{J(X)})})}function DM($){return $.toJsonSchema()}var ev=["Network security adjudicator, your job is to determine if an IP address should be banned.","The IP address in question created the following logs on our server today:","```nginx.log\n"].join(`
|
|
152
|
-
`);function
|
|
152
|
+
`)+"}");class Pz{config;resolvedConfig;name;get[q6](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor($,T){if(this.config=gY(b.config,T),this.resolvedConfig=gY(b.resolvedConfig,T),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(nZ).length}`,this.name in nZ)B(`A Scope already named ${this.name} already exists`);nZ[this.name]=this;let W=Object.entries($).map((U)=>this.preparseOwnAliasEntry(...U));for(let[U,X]of W){let Y=U;if(U[0]==="#"){if(Y=U.slice(1),Y in this.aliases)B(Ck(Y));this.aliases[Y]=X}else{if(Y in this.aliases)B(Ck(U));this.aliases[Y]=X,this.exportedNames.push(Y)}if(!s(X,"module")&&!s(X,"generic")&&!hT(X)){let w=this.preparseOwnDefinitionFormat(X,{alias:Y});this.resolutions[Y]=s(w,"root")?this.bindReference(w):this.createParseContext(w).id}}Sk??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[Sk.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=b.intrinsic?K$(b.intrinsic,(U,X)=>U.startsWith("json")?[]:[U,this.bindReference(X)]):{}}cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema($){return $}generic=(...$)=>{let T=this;return(W,U)=>new pT($,U?new Nz(W):W,T,T,U??null)};units=($,T)=>{let W=[];for(let X of $)if(!W.includes(X))W.push(X);let U=W.map((X)=>this.node("unit",{unit:X},T));return this.node("union",U,{...T,prereduced:!0})};lazyResolutions=[];lazilyResolve($,T){let W=this.node("alias",{reference:T??"synthetic",resolve:$},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(W);return W}schema=($,T)=>this.finalize(this.parseSchema($,T));parseSchema=($,T)=>this.node(pY($),$,T);preparseNode($,T,W){let U=typeof $==="string"?$:pY(T,$);if(t$(T)&&T.kind===U)return T;if(U==="alias"&&!W?.prereduced){let{reference:w}=iY.implementation.normalize(T,this);if(w.startsWith("$")){let G=this.resolveRoot(w.slice(1));T=G,U=G.kind}}else if(U==="union"&&p6(T,"object")){let w=sh(T);if(w?.length===1)T=w[0],U=pY(T)}if(t$(T)&&T.kind===U)return T;let Y=_U[U].normalize?.(T,this)??T;if(t$(Y))return Y.kind===U?Y:eh(U,Y.kind);return{...W,$:this,kind:U,def:Y,prefix:W.alias??U}}bindReference($){let T;if(t$($))T=$.$===this?$:new $.constructor($.attachments,this);else T=$.$===this?$:new pT($.params,$.bodyDef,$.$,this,$.hkt);if(!this.resolved)Object.assign(this.referencesById,T.referencesById);return T}resolveRoot($){return this.maybeResolveRoot($)??B(aZ($))}maybeResolveRoot($){let T=this.maybeResolve($);if(s(T,"generic"))return;return T}maybeResolveSubalias($){return iZ(this.aliases,$)??iZ(this.ambient,$)}get ambient(){return b.ambient}maybeResolve($){let T=this.resolutions[$];if(T){if(typeof T!=="string")return this.bindReference(T);let U=P6[T];if(s(U,"root"))return this.resolutions[$]=U;if(s(U,"context")){if(U.phase==="resolving")return this.node("alias",{reference:`$${$}`},{prereduced:!0});if(U.phase==="resolved")return S$(`Unexpected resolved context for was uncached by its scope: ${E$(U)}`);U.phase="resolving";let X=this.bindReference(this.parseOwnDefinitionFormat(U.def,U));return U.phase="resolved",P6[X.id]=X,P6[U.id]=X,this.resolutions[$]=X}return S$(`Unexpected nodesById entry for ${T}: ${E$(U)}`)}let W=this.aliases[$]??this.ambient?.[$];if(!W)return this.maybeResolveSubalias($);if(W=this.normalizeRootScopeValue(W),s(W,"generic"))return this.resolutions[$]=this.bindReference(W);if(s(W,"module")){if(!W.root)B(yk($));return this.resolutions[$]=this.bindReference(W.root)}return this.resolutions[$]=this.parse(W,{alias:$})}createParseContext($){let T=$.id??jZ($.prefix);return P6[T]=Object.assign($,{[q6]:"context",$:this,id:T,phase:"unresolved"})}traversal($){return new u1($,this.resolvedConfig)}import(...$){return new vU(K$(this.export(...$),(T,W)=>[`#${T}`,W]))}precompilation;_exportedResolutions;_exports;export(...$){if(!this._exports){this._exports={};for(let W of this.exportedNames){let U=this.aliases[W];this._exports[W]=s(U,"module")?rZ(U,this):jk(this.maybeResolve(W))}for(let W of this.lazyResolutions)W.resolution;if(this._exportedResolutions=fk(this,this._exports),this._json=bk(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let W=Ik(this.references);this.precompilation=W.write(Bk,4),xk(this.references,W)}this.resolved=!0}let T=$.length?$:this.exportedNames;return new vU(K$(T,(W,U)=>[U,this._exports[U]]))}resolve($){return this.export()[$]}node=($,T,W={})=>{let U=this.preparseNode($,T,W);if(t$(U))return this.bindReference(U);let X=this.createParseContext(U),Y=BZ(X),w=this.bindReference(Y);return P6[X.id]=w};parse=($,T={})=>this.finalize(this.parseDefinition($,T));parseDefinition($,T={}){if(s($,"root"))return this.bindReference($);let W=this.preparseOwnDefinitionFormat($,T);if(s(W,"root"))return this.bindReference(W);let U=this.createParseContext(W);P6[U.id]=U;let X=this.bindReference(this.parseOwnDefinitionFormat($,U));if(X.isCyclic)X=Uk(X,U.id);return P6[U.id]=X,X}finalize($){if(jk($),!$.precompilation&&!this.resolvedConfig.jitless)$g($.references);return $}}class tZ extends Pz{parseOwnDefinitionFormat($,T){return BZ(T)}preparseOwnDefinitionFormat($,T){return this.preparseNode(pY($),$,T)}preparseOwnAliasEntry($,T){return[$,T]}normalizeRootScopeValue($){return $}}var jk=($)=>{let T=$.references.filter((W)=>W.hasKind("alias"));for(let W of T){Object.assign(W.referencesById,W.resolution.referencesById);for(let U of $.references)if(W.id in U.referencesById)Object.assign(U.referencesById,W.referencesById)}return $},bk=($)=>K$($,(T,W)=>[T,s(W,"root")||s(W,"generic")?W.json:s(W,"module")?bk(W):S$(`Unexpected resolution ${E$(W)}`)]),iZ=($,T)=>{let W=T.indexOf(".");if(W===-1)return;let U=T.slice(0,W),X=$[U];if(X===void 0)return;if(!s(X,"module"))return B(Tg(U));let Y=T.slice(W+1),w=X[Y];if(w===void 0)return iZ(X,Y);if(s(w,"root")||s(w,"generic"))return w;if(s(w,"module"))return w.root??B(yk(T));S$(`Unexpected resolution for alias '${T}': ${E$(w)}`)},Cz=($,T)=>new tZ($,T),sY=new tZ({});var fk=($,T)=>{let W={};for(let U in T){let X=T[U];if(s(X,"module")){let Y=fk($,X),w=K$(Y,(G,H)=>[`${U}.${G}`,H]);Object.assign(W,w)}else if(s(X,"root")||s(X,"generic"))W[U]=X;else S$(`Unexpected scope resolution ${E$(X)}`)}return W},aZ=($)=>`'${$}' is unresolvable`,Tg=($)=>`'${$}' must reference a module to be accessed using dot syntax`,yk=($)=>`Reference to submodule '${$}' must specify an alias`;sY.export();var{schema:f$,node:qU,defineSchema:$G$,generic:P1}=sY;var sZ="^(?:0|[1-9]\\d*)$",Wg=new RegExp(sZ),UG$=Z4(Wg);var hk=Cz({bigint:"bigint",boolean:[{unit:!1},{unit:!0}],false:{unit:!1},never:[],null:{unit:null},number:"number",object:"object",string:"string",symbol:"symbol",true:{unit:!0},unknown:{},undefined:{unit:void 0},Array,Date},{prereducedAliases:!0}).export();b.intrinsic={...hk};var gk=Cz({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:sZ}},{prereducedAliases:!0}).export();Object.assign(b.intrinsic,gk);var Ug=Cz({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),X$={...hk,...gk,...Ug,emptyStructure:qU("structure",{},{prereduced:!0})};b.intrinsic={...X$};var ck=($)=>typeof $==="string"&&$[0]==="d"&&($[1]==="'"||$[1]==='"')&&$.at(-1)===$[1],mk=($)=>$.toString()!=="Invalid Date",uk=($)=>$.slice(2,-1),eZ=($)=>`'${$}' could not be parsed by the Date constructor`,pk=($,T)=>Xg($,T),Xg=($,T)=>{let W=new Date($);if(mk(W))return W;let U=LR($);if(U!==void 0){let X=new Date(U);if(mk(X))return X}return T?B(T===!0?eZ($):T):void 0};var $D=($,T)=>{let W=$.scanner.shiftUntil(Yg[ok[T]]);if($.scanner.lookahead==="")return $.error(Gg(W,T));if($.scanner.shift(),T==="/"){try{new RegExp(W)}catch(U){B(String(U))}$.root=$.ctx.$.node("intersection",{domain:"string",pattern:W},{prereduced:!0})}else if(I4(T,TD))$.root=$.ctx.$.node("unit",{unit:W});else{let U=pk(W,eZ(W));$.root=$.ctx.$.node("unit",{meta:W,unit:U})}},TD={"'":1,'"':1},dk={"/":1,"'":1,'"':1},ok={"d'":"'",'d"':'"',"'":"'",'"':'"',"/":"/"},Yg={"'":($)=>$.lookahead==="'",'"':($)=>$.lookahead==='"',"/":($)=>$.lookahead==="/"},wg={'"':"double-quote","'":"single-quote","/":"forward slash"},Gg=($,T)=>`${T}${$} requires a closing ${wg[ok[T]]}`;var lk=($)=>`Private type references should not include '#'. Use '${$}' instead.`,Sz="Optional definitions like 'string?' are only valid as properties in an object or tuple",jz="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var rk={">":!0,">=":!0},nk={"<":!0,"<=":!0};var PU={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},ik=($)=>`Unmatched )${$===""?"":` before ${$}`}`,Bz=($)=>`Missing ${$}`,tk=($,T)=>`Left bounds are only valid when paired with right bounds (try ...${T}${$})`,xz=($)=>`Left-bounded expressions must specify their limits using < or <= (was ${$})`,ak=($,T,W,U)=>`An expression may have at most one left bound (parsed ${$}${PU[T]}, ${W}${PU[U]})`;var sk=($,T,W)=>ek($,T,W,[]),ek=($,T,W,U)=>{let X=W.parseUntilFinalizer();if(U.push(X.root),X.finalizer===">"){if(U.length!==T.params.length)return W.error(WD($,T.names,U.map((Y)=>Y.expression)));return U}if(X.finalizer===",")return ek($,T,W,U);return X.error(Bz(">"))},WD=($,T,W)=>`${$}<${T.join(", ")}> requires exactly ${T.length} args (got ${W.length}${W.length===0?"":`: ${W.join(", ")}`})`;var UD=($)=>{let T=$.scanner.shiftUntilNextTerminator();if(T==="keyof")$.addPrefix("keyof");else $.root=Hg($,T)},zg=($,T,W)=>{if(W.scanner.shiftUntilNonWhitespace(),W.scanner.shift()!=="<")return W.error(WD($,T.names,[]));let X=sk($,T,W);return T(...X)},Hg=($,T)=>Fg($,T)??Og($,T)??$.error(T===""?$.scanner.lookahead==="#"?lk($.shiftedByOne().scanner.shiftUntilNextTerminator()):XD($):aZ(T)),Fg=($,T)=>{if($.ctx.args?.[T]){let U=$.ctx.args[T];if(typeof U!=="string")return U;return $.ctx.$.node("alias",{reference:U},{prereduced:!0})}let W=$.ctx.$.maybeResolve(T);if(s(W,"root"))return W;if(W===void 0)return;if(s(W,"generic"))return zg(T,W,$);return B(`Unexpected resolution ${E$(W)}`)},Og=($,T)=>{let W=JR(T);if(W!==void 0)return $.ctx.$.node("unit",{unit:W});let U=RR(T);if(U!==void 0)return $.ctx.$.node("unit",{unit:U})},XD=($)=>{let T=$.previousOperator();return T?YD(T,$.scanner.unscanned):Qg($.scanner.unscanned)},YD=($,T="")=>`Token '${$}' requires a right operand${T?` before '${T}'`:""}`,Qg=($)=>`Expected an expression${$?` before '${$}'`:""}`;var wD=($)=>$.scanner.lookahead===""?$.error(XD($)):$.scanner.lookahead==="("?$.shiftedByOne().reduceGroupOpen():$.scanner.lookaheadIsIn(dk)?$D($,$.scanner.shift()):$.scanner.lookaheadIsIn(gT)?wD($.shiftedByOne()):$.scanner.lookahead==="d"?$.scanner.nextLookahead in TD?$D($,`${$.scanner.shift()}${$.scanner.shift()}`):UD($):UD($);class $T extends OZ{shiftUntilNextTerminator(){return this.shiftUntilNonWhitespace(),this.shiftUntil(()=>(this.lookahead in $T.terminatingChars))}static terminatingChars={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...gT};static finalizingLookaheads={">":1,",":1,"":1,"=":1,"?":1};static lookaheadIsFinalizing=($,T)=>$===">"?T[0]==="="?T[1]==="=":T.trimStart()===""||I4(T.trimStart()[0],$T.terminatingChars):$==="="?T[0]!=="=":$===","||$==="?"}var Tv=($,T)=>{let W=Zg($,T);if($.root.hasKind("unit")){if(typeof $.root.unit==="number"){$.reduceLeftBound($.root.unit,W),$.unsetRoot();return}if($.root.unit instanceof Date){let U=`d'${$.root.description??$.root.unit.toISOString()}'`;$.unsetRoot(),$.reduceLeftBound(U,W);return}}return Vg($,W)},Wv={"<":1,">":1,"=":1},Zg=($,T)=>$.scanner.lookaheadIs("=")?`${T}${$.scanner.shift()}`:T;var $v=($,T,W,U)=>{if(W.extends(b.intrinsic.number)){if(typeof T!=="number")return B(GD($,T,U));return $==="=="?["min","max"]:$[0]===">"?["min"]:["max"]}if(W.extends(b.intrinsic.lengthBoundable)){if(typeof T!=="number")return B(GD($,T,U));return $==="=="?["exactLength"]:$[0]===">"?["minLength"]:["maxLength"]}if(W.extends(b.intrinsic.Date))return $==="=="?["after","before"]:$[0]===">"?["after"]:["before"];return B(dR(W.expression))},Dg=($)=>({rule:ck($.limit)?uk($.limit):$.limit,exclusive:$.comparator.length===1}),Vg=($,T)=>{let W=$.unsetRoot(),U=$.scanner.location;$.parseOperand();let X=$.unsetRoot(),Y=$.scanner.sliceChars(U,$.scanner.location);if($.root=W,!X.hasKind("unit")||typeof X.unit!=="number"&&!(X.unit instanceof Date))return $.error(GD(T,Y,"right"));let w=X.unit,G=T.length===1,H=$v(T,typeof w==="number"?w:Y,W,"right");for(let F of H)$.constrainRoot(F,T==="=="?{rule:w}:{rule:w,exclusive:G});if(!$.branches.leftBound)return;if(!I4(T,nk))return $.error(xz(T));let z=$v($.branches.leftBound.comparator,$.branches.leftBound.limit,W,"left");$.constrainRoot(z[0],Dg($.branches.leftBound)),$.branches.leftBound=null},GD=($,T,W)=>`Comparator ${W==="left"?PU[$]:$} must be ${W==="left"?"preceded":"followed"} by a corresponding literal (was ${T})`;var Uv=($)=>{$.scanner.shiftUntilNonWhitespace();let T=$.scanner.shiftUntilNextTerminator();$.root=$.root.brand(T)};var Yv=($)=>{let T=$.scanner.shiftUntilNextTerminator(),W=_R(T,{errorOnFail:Xv(T)});if(W===0)$.error(Xv(0));$.root=$.root.constrain("divisor",W)},Xv=($)=>`% operator must be followed by a non-zero integer literal (was ${$})`;var zD=($)=>{let T=$.scanner.shift();return T===""?$.finalize(""):T==="["?$.scanner.shift()==="]"?$.setRoot($.root.array()):$.error(Kg):T==="|"?$.scanner.lookahead===">"?$.shiftedByOne().pushRootToBranch("|>"):$.pushRootToBranch(T):T==="&"?$.pushRootToBranch(T):T===")"?$.finalizeGroup():$T.lookaheadIsFinalizing(T,$.scanner.unscanned)?$.finalize(T):I4(T,Wv)?Tv($,T):T==="%"?Yv($):T==="#"?Uv($):(T in gT)?zD($):$.error(Iz(T))},Iz=($,T="")=>`'${$}' is not allowed here${T&&` (should be ${T})`}`,Kg="Missing expected ']'";var wv=($)=>{let T=$.unsetRoot();$.parseOperand();let W=$.unsetRoot();if(!W.hasKind("unit"))return $.error(Eg(W.expression));let U=W.unit instanceof Date?()=>new Date(W.unit):W.unit;return[T,"=",U]},Eg=($)=>`Default value '${$}' must a literal value`;var HD=($,T)=>{let W=T.$.maybeResolveRoot($);if(W)return W;if($.endsWith("[]")){let Y=T.$.maybeResolveRoot($.slice(0,-2));if(Y)return Y.array()}let U=new CU(new $T($),T),X=Ag(U);if(U.finalizer===">")B(Iz(">"));return X},Ag=($)=>{$.parseOperand();let T=eY($).root;if(!T)return S$(`Root was unexpectedly unset after parsing string '${$.scanner.scanned}'`);if($.finalizer==="=")T=wv($);else if($.finalizer==="?")T=[T,"?"];if($.scanner.shiftUntilNonWhitespace(),$.scanner.lookahead)B(Iz($.scanner.lookahead));return T},eY=($)=>{while($.finalizer===void 0)Mg($);return $},Mg=($)=>$.hasRoot()?$.parseOperator():$.parseOperand();class CU{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor($,T){this.scanner=$,this.ctx=T}error($){return B($)}hasRoot(){return this.root!==void 0}setRoot($){this.root=$}unsetRoot(){let $=this.root;return this.root=void 0,$}constrainRoot(...$){this.root=this.root.constrain($[0],$[1])}finalize($){if(this.groups.length)return this.error(Bz(")"));this.finalizeBranches(),this.finalizer=$}reduceLeftBound($,T){let W=PU[T];if(!I4(W,rk))return this.error(xz(T));if(this.branches.leftBound)return this.error(ak(this.branches.leftBound.limit,this.branches.leftBound.comparator,$,W));this.branches.leftBound={comparator:W,limit:$}}finalizeBranches(){if(this.assertRangeUnset(),this.branches.pipe){this.pushRootToBranch("|>"),this.root=this.branches.pipe;return}if(this.branches.union){this.pushRootToBranch("|"),this.root=this.branches.union;return}if(this.branches.intersection){this.pushRootToBranch("&"),this.root=this.branches.intersection;return}this.applyPrefixes()}finalizeGroup(){this.finalizeBranches();let $=this.groups.pop();if(!$)return this.error(ik(this.scanner.unscanned));this.branches=$}addPrefix($){this.branches.prefixes.push($)}applyPrefixes(){while(this.branches.prefixes.length){let $=this.branches.prefixes.pop();this.root=$==="keyof"?this.root.keyof():S$(`Unexpected prefix '${$}'`)}}pushRootToBranch($){this.assertRangeUnset(),this.applyPrefixes();let T=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(T)??T,$==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,$==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return eY(new CU(this.scanner,this.ctx))}parseOperator(){return zD(this)}parseOperand(){return wD(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(tk(this.branches.leftBound.limit,this.branches.leftBound.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={prefixes:[],leftBound:null,union:null,intersection:null,pipe:null}}previousOperator(){return this.branches.leftBound?.comparator??this.branches.prefixes.at(-1)??(this.branches.intersection?"&":this.branches.union?"|":this.branches.pipe?"|>":void 0)}shiftedByOne(){return this.scanner.shift(),this}}var Ng="An empty string is not a valid generic parameter name",bz=($,T,W)=>{$.shiftUntilNonWhitespace();let U=$.shiftUntilNextTerminator();if(U===""){if($.lookahead===""&&T.length)return T;return B(Ng)}return $.shiftUntilNonWhitespace(),Lg($,U,T,W)},Gv="extends ",Lg=($,T,W,U)=>{if($.shiftUntilNonWhitespace(),$.unscanned.startsWith(Gv))$.jumpForward(Gv.length);else{if($.lookahead===",")$.shift();return W.push(T),bz($,W,U)}let X=eY(new CU($,U));return W.push([T,X.root]),bz($,W,U)};class FD extends c1{$;constructor($){super((...T)=>new $w($)(...T),{bind:$});this.$=$}in($){return new $w(this.$,$===void 0?void 0:this.$.parse($))}at($,T){return new $w(this.$).at($,T)}case($,T){return new $w(this.$).case($,T)}}class $w extends c1{$;in;key;branches=[];constructor($,T){super((W)=>this.caseEntries(Object.entries(W).map(([U,X])=>U==="default"?[U,X]:[this.$.parse(U),X])));this.$=$,this.in=T}at($,T){if(this.key)B(_g);if(this.branches.length)B(Jg);return this.key=$,T?this.match(T):this}case($,T){return this.caseEntry(this.$.parse($),T)}caseEntry($,T){let U=(this.key?this.$.parse({[this.key]:$}):$).pipe(T);return this.branches.push(U),this}match($){return this($)}strings($){return this.caseEntries(Object.entries($).map(([T,W])=>T==="default"?[T,W]:[this.$.node("unit",{unit:T}),W]))}caseEntries($){for(let T=0;T<$.length;T++){let[W,U]=$[T];if(W==="default"){if(T!==$.length-1)B("default may only be specified as the last key of a switch definition");return this.default(U)}if(typeof U!=="function")return B(`Value for case "${W}" must be a function (was ${x4(U)})`);this.caseEntry(W,U)}return this}default($){if(typeof $==="function")this.case(X$.unknown,$);let T={branches:this.branches,ordered:!0};if($==="never"||$==="assert")T.meta={onFail:zv};let W=this.$.node("union",T);if(!this.in)return this.$.finalize(W);let U=this.in.pipe(W);if($==="never"||$==="assert")U=U.configureReferences({onFail:zv},"self");return this.$.finalize(U)}}var zv=($)=>$.throw(),Jg="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",_g="At most one key matcher may be specified per expression";var fz=($,T)=>{if(d$($)){if($[1]==="=")return[T.$.parseOwnDefinitionFormat($[0],T),"=",$[2]];if($[1]==="?")return[T.$.parseOwnDefinitionFormat($[0],T),"?"]}return yz($,T)},Hv="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",Fv="Only required keys may specify default values, e.g. { value: 'number = 0' }";var Ov=($,T)=>{let W,U={},X=oW($);for(let[w,G]of X){let H=vg(w);if(H.kind==="spread"){if(!O0(U))return B(kg);let Z=T.$.parseOwnDefinitionFormat(G,T);if(Z.equals(X$.object))continue;if(!Z.hasKind("intersection")||!Z.basis?.equals(X$.object))return B(qg(Z.expression));W=Z.structure;continue}if(H.kind==="undeclared"){if(G!=="reject"&&G!=="delete"&&G!=="ignore")B(Rg(G));U.undeclared=G;continue}let z=fz(G,T),F=H;if(H.kind==="required"){if(!d$(z))OD(U,"required",{key:H.normalized,value:z},T);else OD(U,"optional",z[1]==="="?{key:H.normalized,value:z[0],default:z[2]}:{key:H.normalized,value:z[0]},T);continue}if(d$(z)){if(z[1]==="?")B(Hv);if(z[1]==="=")B(Fv)}if(H.kind==="optional"){OD(U,"optional",{key:H.normalized,value:z},T);continue}let O=T.$.parseOwnDefinitionFormat(F.normalized,T),Q=qz(O,z,T.$);if(Q.index)U.index=q$(U.index,Q.index);if(Q.required)U.required=q$(U.required,Q.required)}let Y=T.$.node("structure",U);return T.$.parseSchema({domain:"object",structure:W?.merge(Y)??Y})},OD=($,T,W,U)=>{$[T]=q$($[T],U.$.node(T,W))},Rg=($)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${E$($)})`,kg="Spread operator may only be used as the first key in an object",vg=($)=>typeof $==="symbol"?{kind:"required",normalized:$}:$.at(-1)==="?"?$.at(-2)===BY?{kind:"required",normalized:`${$.slice(0,-2)}?`}:{kind:"optional",normalized:$.slice(0,-1)}:$[0]==="["&&$.at(-1)==="]"?{kind:"index",normalized:$.slice(1,-1)}:$[0]===BY&&$[1]==="["&&$.at(-1)==="]"?{kind:"required",normalized:$.slice(1)}:$==="..."?{kind:"spread"}:$==="+"?{kind:"undeclared"}:{kind:"required",normalized:$==="\\..."?"...":$==="\\+"?"+":$},qg=($)=>`Spread operand must resolve to an object literal type (was ${$})`;var Zv=($,T)=>yg($)?Ev[$[0]]($,T):bg($)?Kv[$[1]]($,T):null,Pg=($,T)=>T.$.parseOwnDefinitionFormat($[1],T).keyof(),QD=($,T)=>{if($[2]===void 0)return B(YD($[1],""));let W=T.$.parseOwnDefinitionFormat($[0],T),U=T.$.parseOwnDefinitionFormat($[2],T);if($[1]==="|")return T.$.node("union",{branches:[W,U]});let X=$[1]==="&"?r6(W,U,T.$):uY(W,U,T.$);if(X instanceof o)return X.throw();return X},Cg=($,T)=>T.$.parseOwnDefinitionFormat($[0],T).array(),Sg=($,T)=>{if(typeof $[2]!=="function")return B(Dv("=>",$[2]));return T.$.parseOwnDefinitionFormat($[0],T).pipe($[2])},Dv=($,T)=>`${$===":"?"Narrow":"Morph"} expression requires a function following '${$}' (was ${typeof T})`,jg=($,T)=>{if(typeof $[2]!=="function")return B(Dv(":",$[2]));return T.$.parseOwnDefinitionFormat($[0],T).constrain("predicate",$[2])},Bg=($,T)=>T.$.parseOwnDefinitionFormat($[0],T).configureReferences($[2],"shallow"),Vv=($)=>$,xg=Vv({"[]":Cg,"?":()=>B(Sz)}),Ig=Vv({"|":QD,"&":QD,":":jg,"=>":Sg,"|>":QD,"@":Bg,"=":()=>B(jz)}),Kv={...xg,...Ig},bg=($)=>Kv[$[1]]!==void 0,fg=($)=>$,Ev=fg({keyof:Pg,instanceof:($,T)=>{if(typeof $[1]!=="function")return B(Qv(SY($[1])));let W=$.slice(1).map((U)=>typeof U==="function"?T.$.node("proto",{proto:U}):B(Qv(SY(U))));return W.length===1?W[0]:T.$.node("union",{branches:W})},"===":($,T)=>T.$.units($.slice(1))}),yg=($)=>Ev[$[0]]!==void 0,Qv=($)=>`Expected a constructor following 'instanceof' operator (was ${$})`;var Nv=($,T)=>{let W=[{}],U=0;while(U<$.length){let X=!1;if($[U]==="..."&&U<$.length-1)X=!0,U++;let Y=fz($[U],T),[w,G,H]=!d$(Y)?[Y]:Y;if(U++,X){if(!w.extends(b.intrinsic.Array))return B(mg(w.expression));W=W.flatMap((z)=>w.distribute((F)=>gg(Kz(z),F)))}else W=W.map((z)=>{if(G==="?")return Lv(z,w);if(G==="=")return hg(z,w,H);return ZD(z,w)})}return T.$.parseSchema(W.map((X)=>O0(X)?{proto:Array,exactLength:0}:{proto:Array,sequence:X}))},ZD=($,T)=>{if($.defaultables||$.optionals)return B($.variadic?dZ:cg);if($.variadic)$.postfix=q$($.postfix,T);else $.prefix=q$($.prefix,T);return $},Lv=($,T)=>{if($.variadic)return B(Jv);return $.optionals=q$($.optionals,T),$},hg=($,T,W)=>{if($.variadic)return B(Jv);if($.optionals)return B(ug);return $.defaultables=q$($.defaultables,[[T,W]]),$},Av=($,T)=>{if($.postfix)B(Mv);if($.variadic){if(!$.variadic.equals(T))B(Mv)}else $.variadic=T.internal;return $},gg=($,T)=>{let W=T.select({method:"find",kind:"sequence"});if(!W)return Av($,b.intrinsic.unknown);if(W.prefix)for(let U of W.prefix)ZD($,U);if(W.optionals)for(let U of W.optionals)Lv($,U);if(W.variadic)Av($,W.variadic);if(W.postfix)for(let U of W.postfix)ZD($,U);return $},mg=($)=>`Spread element must be an array (was ${$})`,Mv="A tuple may have at most one variadic element",cg="A required element may not follow an optional element",Jv="An optional element may not follow a variadic element";var ug="A defaultable element may not follow an optional element without a default";var pg={},yz=($,T)=>{if(typeof $==="string"){if(T.args&&Object.keys(T.args).some((U)=>$.includes(U)))return HD($,T);let W=pg[T.$.name]??={};return W[$]??=HD($,T)}return p6($,"object")?dg($,T):B(DD(x4($)))},dg=($,T)=>{let W=CY($);switch(W){case void 0:if(s($,"root"))return $;return Ov($,T);case"Array":return og($,T);case"RegExp":return T.$.node("intersection",{domain:"string",pattern:$},{prereduced:!0});case"Function":{let U=hT($)?$():$;if(s(U,"root"))return U;return B(DD("Function"))}default:return B(DD(W??E$($)))}},og=($,T)=>Zv($,T)??Nv($,T),DD=($)=>`Type definitions must be strings or objects (was ${$})`;class VD extends c1{constructor($){let T=Object.assign({errors:o6,hkt:U6,$,raw:$.parse,module:$.constructor.module,scope:$.constructor.scope,define:$.define,match:$.match,generic:$.generic,schema:$.schema,keywords:$.ambient,unit:$.unit,enumerated:$.enumerated,instanceOf:$.instanceOf,valueOf:$.valueOf,or:$.or,and:$.and,merge:$.merge,pipe:$.pipe},$.ambientAttachments);super((...W)=>{if(W.length===1)return $.parse(W[0]);if(W.length===2&&typeof W[0]==="string"&&W[0][0]==="<"&&W[0].at(-1)===">"){let U=W[0].slice(1,-1),X=$.parseGenericParams(U,{});return new pT(X,W[1],$,$,null)}return $.parse(W)},{bind:$,attach:T})}}var SU=b;class hz extends Pz{get ambientAttachments(){if(!SU.typeAttachments)return;return this.cacheGetter("ambientAttachments",K$(SU.typeAttachments,($,T)=>[$,this.bindReference(T)]))}preparseOwnAliasEntry($,T){let W=$.indexOf("<");if(W===-1){if(s(T,"module")||s(T,"generic"))return[$,T];let Y=this.name==="ark"?$:$==="root"?this.name:`${this.name}.${$}`,w=this.resolvedConfig.keywords?.[Y];if(w)T=[T,"@",w];return[$,T]}if($.at(-1)!==">")B("'>' must be the last character of a generic declaration in a scope");let U=$.slice(0,W),X=$.slice(W+1,-1);return[U,()=>{let Y=this.parseGenericParams(X,{alias:U});return cR(Y,T,this)}]}parseGenericParams($,T){return bz(new $T($),[],this.createParseContext({...T,def:$,prefix:"generic"}))}normalizeRootScopeValue($){if(hT($)&&!s($,"generic"))return $();return $}preparseOwnDefinitionFormat($,T){return{...T,def:$,prefix:T.alias??"type"}}parseOwnDefinitionFormat($,T){if(!(T.alias&&(T.alias in this.aliases))&&!T.args)T.args={this:T.id};let U=yz($,T);if(d$(U)){if(U[1]==="=")return B(jz);if(U[1]==="?")return B(Sz)}return U}unit=($)=>this.units([$]);valueOf=($)=>this.units(GR($));enumerated=(...$)=>this.units($);instanceOf=($)=>this.node("proto",{proto:$},{prereduced:!0});or=(...$)=>this.schema($.map((T)=>this.parse(T)));and=(...$)=>$.reduce((T,W)=>T.and(this.parse(W)),this.intrinsic.unknown);merge=(...$)=>$.reduce((T,W)=>T.merge(this.parse(W)),this.intrinsic.object);pipe=(...$)=>this.intrinsic.unknown.pipe(...$);match=new FD(this);declare=()=>({type:this.type});define($){return $}type=new VD(this);static scope=($,T={})=>new hz($,T);static module=($,T={})=>this.scope($,T).export()}var KD=Object.assign(hz.scope,{define:($)=>$}),k$=hz;class _v extends U6{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var lg=P1(["base",X$.object],["props",X$.object])(($)=>$.base.merge($.props),_v),Rv=k$.module({Key:X$.key,Merge:lg});class kv extends U6{}var rg=P1("element")(($)=>{let T=$.element.exclude(X$.Array),W=T.array();return T.rawOr(W).pipe(yT).distribute((U)=>U.assertHasKind("morph").declareOut(W),f$)},kv),vv=k$.module({root:X$.Array,readonly:"root",index:X$.nonNegativeIntegerString,liftFrom:rg},{name:"Array"});var ED=f$(["string",rW.FileConstructor]),ng=ED.rawOr(ED.array()),qv=f$({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:ng}}),Pv=k$.module({root:["instanceof",FormData],value:ED,parsed:qv,parse:f$({in:FormData,morphs:($)=>{let T={};for(let[W,U]of $)if(W in T){let X=T[W];if(typeof X==="string"||X instanceof rW.FileConstructor)T[W]=[X,U];else X.push(U)}else T[W]=U;return T},declaredOut:qv})},{name:"FormData"});var Cv=k$.module({Int8:["instanceof",Int8Array],Uint8:["instanceof",Uint8Array],Uint8Clamped:["instanceof",Uint8ClampedArray],Int16:["instanceof",Int16Array],Uint16:["instanceof",Uint16Array],Int32:["instanceof",Int32Array],Uint32:["instanceof",Uint32Array],Float32:["instanceof",Float32Array],Float64:["instanceof",Float64Array],BigInt64:["instanceof",BigInt64Array],BigUint64:["instanceof",BigUint64Array]},{name:"TypedArray"});var ig={Boolean:1,Number:1,String:1},Sv=k$.module({...K$({...UZ,...YZ},($,T)=>($ in ig)?[]:[$,["instanceof",T]]),Array:vv,TypedArray:Cv,FormData:Pv});var tg=f$({domain:{domain:"number",meta:"a number representing a Unix timestamp"},divisor:{rule:1,meta:"an integer representing a Unix timestamp"},min:{rule:-8640000000000000,meta:"a Unix timestamp after -8640000000000000"},max:{rule:8640000000000000,meta:"a Unix timestamp before 8640000000000000"},meta:"an integer representing a safe Unix timestamp"}),ag=f$({domain:"number",divisor:1}),gz=k$.module({root:X$.number,integer:ag,epoch:tg,safe:f$({domain:{domain:"number",numberAllowsNaN:!1},min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}),NaN:["===",Number.NaN],Infinity:["===",Number.POSITIVE_INFINITY],NegativeInfinity:["===",Number.NEGATIVE_INFINITY]},{name:"number"});var X4=($,T,W)=>{let U={domain:"string",pattern:{rule:$.source,flags:$.flags,meta:T}};if(W)U.meta={format:W};return qU("intersection",U)},jv=X4(xY,"a well-formed integer string"),pv=k$.module({root:jv,parse:f$({in:jv,morphs:($,T)=>{let W=Number.parseInt($);return Number.isSafeInteger(W)?W:T.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:X$.integer})},{name:"string.integer"}),sg=X4(/^[\dA-Fa-f]+$/,"hex characters only"),eg=k$.module({root:X4(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:X4(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),Bv=X4(/^[A-Z].*$/,"capitalized"),$m=k$.module({root:f$({in:"string",morphs:($)=>$.charAt(0).toUpperCase()+$.slice(1),declaredOut:Bv}),preformatted:Bv},{name:"string.capitalize"}),Tm=($)=>{let T=$.replaceAll(/[ -]+/g,""),W=0,U,X,Y=!1;for(let w=T.length-1;w>=0;w--){if(U=T.substring(w,w+1),X=Number.parseInt(U,10),Y)X*=2,W+=X>=10?X%10+1:X;else W+=X;Y=!Y}return!!(W%10===0?T:!1)},Wm=/^(?:4\d{12}(?:\d{3,6})?|5[1-5]\d{14}|(222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}|6(?:011|5\d\d)\d{12,15}|3[47]\d{13}|3(?:0[0-5]|[68]\d)\d{11}|(?:2131|1800|35\d{3})\d{11}|6[27]\d{14}|^(81\d{14,17}))$/,Um=f$({domain:"string",pattern:{meta:"a credit card number",rule:Wm.source},predicate:{meta:"a credit card number",predicate:Tm}});var Xm=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(T((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([,.]\d+(?!:))?)?(\17[0-5]\d([,.]\d+)?)?([Zz]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;var Ym=($)=>!Number.isNaN(new Date($).valueOf()),xv=f$({domain:"string",predicate:{meta:"a parsable date",predicate:Ym}}).assertHasKind("intersection"),Iv=pv.root.internal.narrow(($,T)=>{let W=Number.parseInt($),U=gz.epoch(W);if(U instanceof o6)return T.errors.merge(U),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),wm=k$.module({root:Iv,parse:f$({in:Iv,morphs:($)=>new Date($),declaredOut:X$.Date})},{name:"string.date.epoch"}),bv=X4(Xm,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),Gm=k$.module({root:bv,parse:f$({in:bv,morphs:($)=>new Date($),declaredOut:X$.Date})},{name:"string.date.iso"}),zm=k$.module({root:xv,parse:f$({declaredIn:xv,in:"string",morphs:($,T)=>{let W=new Date($);if(Number.isNaN(W.valueOf()))return T.error("a parsable date");return W},declaredOut:X$.Date}),iso:Gm,epoch:wm},{name:"string.date"}),Hm=X4(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),fv="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",dT=`(${fv}[.]){3}${fv}`,Fm=new RegExp(`^${dT}$`),_4="(?:[0-9a-fA-F]{1,4})",Om=new RegExp(`^((?:${_4}:){7}(?:${_4}|:)|(?:${_4}:){6}(?:${dT}|:${_4}|:)|(?:${_4}:){5}(?::${dT}|(:${_4}){1,2}|:)|(?:${_4}:){4}(?:(:${_4}){0,1}:${dT}|(:${_4}){1,3}|:)|(?:${_4}:){3}(?:(:${_4}){0,2}:${dT}|(:${_4}){1,4}|:)|(?:${_4}:){2}(?:(:${_4}){0,3}:${dT}|(:${_4}){1,5}|:)|(?:${_4}:){1}(?:(:${_4}){0,4}:${dT}|(:${_4}){1,6}|:)|(?::((?::${_4}){0,5}:${dT}|(?::${_4}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),Qm=k$.module({root:["v4 | v6","@","an IP address"],v4:X4(Fm,"an IPv4 address","ipv4"),v6:X4(Om,"an IPv6 address","ipv6")},{name:"string.ip"}),jU="a JSON string",dv=($)=>{if(!($ instanceof SyntaxError))throw $;return`must be ${jU} (${$})`},Zm=f$({meta:jU,domain:"string",predicate:{meta:jU,predicate:($,T)=>{try{return JSON.parse($),!0}catch(W){return T.reject({code:"predicate",expected:jU,problem:dv(W)})}}}}),Dm=($,T)=>{if($.length===0)return T.error({code:"predicate",expected:jU,actual:"empty"});try{return JSON.parse($)}catch(W){return T.error({code:"predicate",expected:jU,problem:dv(W)})}},Vm=k$.module({root:Zm,parse:f$({meta:"safe JSON string parser",in:"string",morphs:Dm,declaredOut:X$.jsonObject})},{name:"string.json"}),yv=X4(/^[a-z]*$/,"only lowercase letters"),Km=k$.module({root:f$({in:"string",morphs:($)=>$.toLowerCase(),declaredOut:yv}),preformatted:yv},{name:"string.lower"}),ov=["NFC","NFD","NFKC","NFKD"],Tw=K$(ov,($,T)=>[T,f$({domain:"string",predicate:(W)=>W.normalize(T)===W,meta:`${T}-normalized unicode`})]),mz=K$(ov,($,T)=>[T,f$({in:"string",morphs:(W)=>W.normalize(T),declaredOut:Tw[T]})]),Em=k$.module({root:mz.NFC,preformatted:Tw.NFC},{name:"string.normalize.NFC"}),Am=k$.module({root:mz.NFD,preformatted:Tw.NFD},{name:"string.normalize.NFD"}),Mm=k$.module({root:mz.NFKC,preformatted:Tw.NFKC},{name:"string.normalize.NFKC"}),Nm=k$.module({root:mz.NFKD,preformatted:Tw.NFKD},{name:"string.normalize.NFKD"}),Lm=k$.module({root:"NFC",NFC:Em,NFD:Am,NFKC:Mm,NFKD:Nm},{name:"string.normalize"}),hv=X4(Zz,"a well-formed numeric string"),Jm=k$.module({root:hv,parse:f$({in:hv,morphs:($)=>Number.parseFloat($),declaredOut:X$.number})},{name:"string.numeric"}),gv="a regex pattern",_m=f$({domain:"string",predicate:{meta:gv,predicate:($,T)=>{try{return new RegExp($),!0}catch(W){return T.reject({code:"predicate",expected:gv,problem:String(W)})}}},meta:{format:"regex"}}),Rm=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*))*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/,km=X4(Rm,"a semantic version (see https://semver.org/)"),mv=X4(/^\S.*\S$|^\S?$/,"trimmed"),vm=k$.module({root:f$({in:"string",morphs:($)=>$.trim(),declaredOut:mv}),preformatted:mv},{name:"string.trim"}),cv=X4(/^[A-Z]*$/,"only uppercase letters"),qm=k$.module({root:f$({in:"string",morphs:($)=>$.toUpperCase(),declaredOut:cv}),preformatted:cv},{name:"string.upper"}),Pm=($)=>{if(URL.canParse)return URL.canParse($);try{return new URL($),!0}catch{return!1}},uv=f$({domain:"string",predicate:{meta:"a URL string",predicate:Pm},meta:{format:"uri"}}),Cm=k$.module({root:uv,parse:f$({declaredIn:uv,in:"string",morphs:($,T)=>{try{return new URL($)}catch{return T.error("a URL string")}},declaredOut:f$(URL)})},{name:"string.url"}),Sm=k$.module({root:["versioned | nil | max","@",{description:"a UUID",format:"uuid"}],"#nil":"'00000000-0000-0000-0000-000000000000'","#max":"'ffffffff-ffff-ffff-ffff-ffffffffffff'","#versioned":/[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}/i,v1:X4(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:X4(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:X4(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:X4(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:X4(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:X4(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:X4(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:X4(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),lv=k$.module({root:X$.string,alpha:X4(/^[A-Za-z]*$/,"only letters"),alphanumeric:X4(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:sg,base64:eg,capitalize:$m,creditCard:Um,date:zm,digits:X4(/^\d*$/,"only digits 0-9"),email:Hm,integer:pv,ip:Qm,json:Vm,lower:Km,normalize:Lm,numeric:Jm,regex:_m,semver:km,trim:vm,upper:qm,url:Cm,uuid:Sm},{name:"string"});var rv=k$.module({bigint:X$.bigint,boolean:X$.boolean,false:X$.false,never:X$.never,null:X$.null,number:X$.number,object:X$.object,string:X$.string,symbol:X$.symbol,true:X$.true,unknown:X$.unknown,undefined:X$.undefined}),nv=k$.module({root:X$.unknown,any:X$.unknown},{name:"unknown"}),jm=k$.module({root:X$.jsonObject,stringify:qU("morph",{in:X$.jsonObject,morphs:($)=>JSON.stringify($),declaredOut:X$.string})},{name:"object.json"}),iv=k$.module({root:X$.object,json:jm},{name:"object"});class tv extends U6{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var Bm=P1(["K",X$.key],"V")(($)=>({domain:"object",index:{signature:$.K,value:$.V}}),tv);class av extends U6{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var xm=P1(["T",X$.object],["K",X$.key])(($)=>$.T.pick($.K),av);class sv extends U6{description='omit a set of properties from an object like `Omit(User, "age")`'}var Im=P1(["T",X$.object],["K",X$.key])(($)=>$.T.omit($.K),sv);class ev extends U6{description="make all named properties of an object optional like `Partial(User)`"}var bm=P1(["T",X$.object])(($)=>$.T.partial(),ev);class $q extends U6{description="make all named properties of an object required like `Required(User)`"}var fm=P1(["T",X$.object])(($)=>$.T.required(),$q);class Tq extends U6{description='exclude branches of a union like `Exclude("boolean", "true")`'}var ym=P1("T","U")(($)=>$.T.exclude($.U),Tq);class Wq extends U6{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var hm=P1("T","U")(($)=>$.T.extract($.U),Wq),Uq=k$.module({Exclude:ym,Extract:hm,Omit:Im,Partial:bm,Pick:xm,Record:Bm,Required:fm});var oT=KD({...rv,...Uq,...Sv,...Rv,string:lv,number:gz,object:iv,unknown:nv},{prereducedAliases:!0,name:"ark"}),b4=oT.export();Object.assign(SU.ambient,b4);SU.typeAttachments={string:b4.string.root,number:b4.number.root,bigint:b4.bigint,boolean:b4.boolean,symbol:b4.symbol,undefined:b4.undefined,null:b4.null,object:b4.object.root,unknown:b4.unknown.root,false:b4.false,true:b4.true,never:b4.never,arrayIndex:b4.Array.index,Key:b4.Key,Record:b4.Record,Array:b4.Array.root,Date:b4.Date};var d1=Object.assign(oT.type,SU.typeAttachments),gm=oT.match,mm=oT.generic,k5$=oT.schema,cm=oT.define,um=oT.declare;var pm="__vite_start_time"in globalThis,dm=typeof window!=="undefined",p5$="vitest"in globalThis,TT=d1("string"),Xq=d1('"true" | "false" | undefined'),WT=$Z({isServer:!pm&&!dm,server:{CI:d1("string | undefined").pipe(Boolean),POSTGRES_USER:TT,POSTGRES_PASSWORD:TT,POSTGRES_DATABASE:TT,POSTGRES_HOST:TT,POSTGRES_PORT:TT.pipe(($)=>Number.parseInt($,10)),BACKEND_PORT:TT.pipe(($)=>Number.parseInt($,10)),RUN_WORKERS_FROM_SOURCE:Xq.pipe(($)=>$==="true"),FRONTEND_PORT:TT.pipe(($)=>Number.parseInt($,10)),FRONTEND_ORIGINS:TT.pipe.try(($)=>JSON.parse($),d1("string[]")),API_KEY_OPENAI:d1("string | undefined"),API_KEY_RESEND:d1("string | undefined")},clientPrefix:"VITE_",client:{VITE_BACKEND_ORIGIN:TT,VITE_DEV_FRONTEND_HOST:d1("string | undefined"),VITE_DEV_HTTPS:Xq.pipe(($)=>$==="true")},runtimeEnv:import.meta.env,emptyStringAsUndefined:!0});var MD={};wT(MD,{users:()=>tW,untrackedUserColumnNames:()=>om,twoFactorMethod:()=>Hq,trackedUserColumnName:()=>lm,trackableUserColumnNames:()=>Gq,signInHistory:()=>nm,role:()=>wq,players:()=>AD,passwordResetAttempts:()=>im,games:()=>uz,banishedIps:()=>pz,accountActions:()=>rm,accountAction:()=>zq});function lT(){return T6({length:24}).$type()}function Yq($){return L`lower(${$})`}var cz=L`TO_CHAR(NOW() AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')`,wq=YY("role",["admin","user"]),tW=IT("users",{id:_1().primaryKey().defaultRandom(),username:T6({length:16}).notNull(),emailOffered:T6({length:254}).notNull(),emailVerified:T6({length:254}),password:T6({length:254}),createdAtIso:lT().notNull().default(cz),createdIp:T6({length:45}).notNull(),isActive:OY().notNull().default(!1),verifiedAtIso:lT(),userRole:wq().default("user")},($)=>[mQ("usernameUniqueIndex").on(Yq($.username)),mQ("emailVerifiedUniqueIndex").on(Yq($.emailVerified))]),om=["id","createdAtIso","createdIp","isActive","verifiedAtIso"],Gq=["username","emailOffered","emailVerified","password","userRole"],lm=YY("trackedUserColumnName",Gq),zq=YY("accountAction",["cooldown","confirmEmail","signIn","resetPassword"]),rm=IT("accountActions",{userId:_1().references(()=>tW.id).primaryKey(),action:zq().notNull(),code:T6({length:254}).notNull(),wrongCodeCount:QY().notNull().default(0),expiresAtIso:lT().notNull()}),uz=IT("games",{id:_1().primaryKey().defaultRandom()}),AD=IT("players",{userId:_1().notNull().references(()=>tW.id,{onDelete:"cascade"}),gameId:_1().notNull().references(()=>uz.id,{onDelete:"cascade"}),score:QY().notNull()},($)=>[iJ({name:"players_userId_gameId_pk",columns:[$.userId,$.gameId]})]),nm=IT("signInHistory",{id:_1().primaryKey().defaultRandom(),userId:_1().references(()=>tW.id,{onDelete:"cascade"}),signInTimeIso:lT().notNull().default(cz),ipAddress:T6({length:45}).notNull(),userAgent:T6({length:1024}),successful:OY().notNull().default(!1)}),Hq=YY("twoFactorMethod",["email","phone"]),im=IT("passwordResetAttempts",{id:_1().primaryKey().defaultRandom(),userId:_1().notNull().references(()=>tW.id,{onDelete:"cascade"}),requestedIp:T6({length:45}).notNull(),requestedAtIso:lT().notNull().default(cz),succeededIp:T6({length:45}),succeededAtIso:lT(),verificationMethod:Hq().notNull()}),pz=IT("banishedIps",{ip:T6({length:45}).primaryKey(),reason:T6({length:2048}).notNull(),banishedAtIso:lT().notNull().default(cz),banishedUntilIso:lT()});var __dirname="/home/runner/work/wayforge/wayforge/apps/tempest.games/src/database";class ND{options;sql;drizzle;observers=new Map;async setupTriggersAndNotifications(){await this.sql.file(tm.resolve(__dirname,"notify_update.sql"));let $=[m4(tW),m4(uz),m4(AD)];await this.sql`SELECT create_notify_triggers(${this.sql.array($)})`,await this.sql.listen("table_update",(T)=>{let W=T.split(","),U=W[0],X=W[1],Y=`${U}("${X}")`;if(this.observers.has(Y))this.observers.get(Y).next(Y)})}constructor($=!1,T={host:WT.POSTGRES_HOST,port:WT.POSTGRES_PORT,user:WT.POSTGRES_USER,password:WT.POSTGRES_PASSWORD,database:WT.POSTGRES_DATABASE}){this.options=T,this.sql=FU(T),this.drizzle=Oz(this.sql,{schema:MD,logger:$})}observe($,T){if(!this.observers.has($))this.observers.set($,new I$);this.observers.get($).subscribe("SINGLETON",T)}}import{resolve as em}from"path";import{existsSync as LD,mkdirSync as Fq,readFileSync as am,readdirSync as Oq,rmSync as Qq,statSync as Zq,writeFileSync as sm}from"fs";import{resolve as JD}from"path";var Dq=class{rootDir;get initialized(){return LD(this.rootDir)}initialize(){if(!this.initialized)Fq(this.rootDir,{recursive:!0})}constructor($){if(this.rootDir=$.path,$.eagerInit)this.initialize()}getItem($){let T=JD(this.rootDir,$);if(LD(T))return am(T,"utf-8");return null}setItem($,T){this.initialize();let W=JD(this.rootDir,$);sm(W,T)}removeItem($){let T=JD(this.rootDir,$);if(LD(T))this.initialize(),Qq(T)}key($){return Oq(this.rootDir).sort((U,X)=>{let Y=Zq(U);return Zq(X).ctimeMs-Y.ctimeMs})[$]??null}clear(){Qq(this.rootDir,{recursive:!0}),Fq(this.rootDir,{recursive:!0})}get length(){return Oq(this.rootDir).length}};var _D=new Dq({path:em(process.cwd(),"storage")});function Vq($){return $.toString({smallestUnit:"millisecond"})}function H7$($){return C9.Instant.from($)}import*as dz from"fs";import*as Kq from"readline";function $c($){let W=$.replace(":","T").replace(" ","").replace(/(\d{2})\/(\w{3})\/(\d{4})T(.+)/,(U,X,Y,w,G)=>{let z={Jan:"01",Feb:"02",Mar:"03",Apr:"04",May:"05",Jun:"06",Jul:"07",Aug:"08",Sep:"09",Oct:"10",Nov:"11",Dec:"12"}[Y];return`${w}-${z}-${X}T${G}`});return new Date(W)}async function Eq($,T="/var/log/nginx/access.log",W=new Date){let U=new Map;if(!dz.existsSync(T))return $.error(`Log file not found: ${T}`),U;let X=dz.createReadStream(T),Y=Kq.createInterface({input:X,crlfDelay:Number.POSITIVE_INFINITY}),w=new Date(W.getTime()-3600000);return Y.on("line",(G)=>{let H=/^(?<ip>\S+) \S+ \S+ \[(?<dateTime>.*?)\]/,z=G.match(H);if(z?.groups){let F=z.groups.ip,O=z.groups.dateTime,Q=$c(O);if(!Number.isNaN(Q.getTime())){if(Q>=w&&Q<=W){let Z=U.get(F);if(!Z)Z=[],U.set(F,Z);Z.push(G)}}else $.error(`Failed to parse date: ${O}`)}}),new Promise((G,H)=>{Y.on("error",(z)=>{H(z)}),Y.on("close",()=>{G(U)})})}function Aq($){return $.toJsonSchema()}var Tc=["Network security adjudicator, your job is to determine if an IP address should be banned.","The IP address in question created the following logs on our server today:","```nginx.log\n"].join(`
|
|
153
|
+
`);function Mq($){return Tc+$.join(`
|
|
153
154
|
|
|
154
|
-
`)}var
|
|
155
|
-
`));let
|
|
156
|
-
`),
|
|
157
|
-
`);else
|
|
158
|
-
`);
|
|
159
|
-
`);break}}let
|
|
155
|
+
`)}var Nq={schema:d1([{shouldBanIp:"false"},"|",{shouldBanIp:"true",veryConciseReason:"string"}]),toJsonSchema:Aq,fallback:{shouldBanIp:!1}};var Uc=[".env","php"];async function Lq({generator:$,logFilePath:T,logger:W,now:U=new Date}){let X=$.usdBudget,Y=new ND({logQuery(R,P){W.info("\uD83D\uDCDD query",R,P)}}),w=await Eq(W,T,U),G=[],H=$.from(Nq),z=0,F=0;for(let[R,P]of w){W.info(`\uD83D\uDD0D ruling on ${R}. logs:`),W.info(P.map((f)=>` ${f}`).join(`
|
|
156
|
+
`));let x=!1;for(let f of Uc)if(P.some((h)=>h.includes(f))){G.push({ip:R,reason:`Always ban ${f}`}),W.info(` \uD83E\uDDD1\u200D\u2696\uFE0F banning ${R}--always ban ${f}
|
|
157
|
+
`),x=!0;break}if(x)continue;if($.usdBudget>$.usdMinimum){let f=Mq(P),h=await H(f);if(h.shouldBanIp)G.push({ip:R,reason:h.veryConciseReason}),W.info(` \uD83E\uDDD1\u200D\u2696\uFE0F banning ${R}--${h.veryConciseReason}
|
|
158
|
+
`);else F++,W.info(` \uD83D\uDD4A\uFE0F not banning ${R}
|
|
159
|
+
`);z++}else{W.warn("\uD83D\uDCB0 insufficient funds to process all logs"),W.warn(`\uD83D\uDCB0 got through ${z}/${w.size} ips
|
|
160
|
+
`);break}}let O=G.length;if(G.length>0)await Y.drizzle.insert(pz).values(G).onConflictDoNothing();let Q=[],Z=_D.getItem("lastTribunalProcessedDate"),V=Vq(C9.Instant.from(Z??"1970-01-01"));try{Q.push(...await Y.drizzle.query.banishedIps.findMany({columns:{ip:!0},where:n9(pz.banishedAtIso,V)}))}catch(R){W.error(R)}try{if(process.env.EXPERIMENTAL_BAN_IPS)await Promise.all(Q.map((R)=>new Promise((P,x)=>Wc(`iptables -D INPUT -s ${R.ip} -j DROP`).on("exit",(f)=>{if(f===0)W.info(`\uD83E\uDDD1\u200D\u2696\uFE0F banned ${R.ip}`),P();else x(new Error(`iptables exited with code ${f}`))}))));else W.info("\uD83E\uDDD1\u200D\u2696\uFE0F skipping iptables update")}catch(R){if(R instanceof Error)W.error(R.message);else{let P=CN(R);W.error("iptables exited with error",P)}}_D.setItem("lastTribunalProcessedDate",U.toISOString()),W.info(`\u2728 banned ${O} ips, didn't ban ${F} ips`);let E=X-$.usdBudget,N=E.toLocaleString("en",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:6}),J=X.toLocaleString("en",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:6}),_=Math.round(E/X*100);W.info(`\uD83D\uDCB8 spent ${N}, ${_}% of ${J} budget`)}var UT=new z5;Object.assign(console,UT.logger,{log:UT.logger.info});process.on("SIGINT",()=>{UT.logger.info("\u2757 received SIGINT; exiting gracefully"),oz()});process.on("SIGTERM",()=>{UT.logger.info("\u2757 received SIGTERM; exiting gracefully"),oz()});process.on("exit",()=>{UT.logger.info("\u2757 received exit; exiting gracefully"),oz()});UT.logger.info("\uD83D\uDEEB tribunal worker ready");var Xc=new PA({usdBudget:0.01,usdMinimum:0,model:"gpt-4o-mini",apiKey:WT.API_KEY_OPENAI,cachingMode:"off",logger:UT.logger});if(WT.API_KEY_OPENAI===void 0&&!("VITEST"in import.meta.env))throw new Error("OPENAI_API_KEY is not set and vitest is not running.");await Lq({generator:Xc,logFilePath:"/var/log/nginx/access.log",logger:UT.logger});oz();function oz(){UT.logger.info("\uD83D\uDEEC tribunal server exiting"),process.exit(0)}
|