pixelclaw 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,666 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __pclawRequire } from 'node:module'; const require = __pclawRequire(import.meta.url);
3
+ var WN=Object.defineProperty;var eo=(e,t)=>{for(var r in t)WN(e,r,{get:t[r],enumerable:!0})};import{randomBytes as vH}from"node:crypto";import{existsSync as $H}from"node:fs";import{join as xH,resolve as NN}from"node:path";var JN=Object.create,Ed=Object.defineProperty,GN=Object.getOwnPropertyDescriptor,KN=Object.getOwnPropertyNames,YN=Object.getPrototypeOf,XN=Object.prototype.hasOwnProperty,ue=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),F1=(e,t)=>{let r={};for(var o in e)Ed(r,o,{get:e[o],enumerable:!0});return t&&Ed(r,Symbol.toStringTag,{value:"Module"}),r},QN=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(var n=KN(t),i=0,s=n.length,a;i<s;i++)a=n[i],!XN.call(e,a)&&a!==r&&Ed(e,a,{get:(c=>t[c]).bind(null,a),enumerable:!(o=GN(t,a))||o.enumerable});return e},Td=(e,t,r)=>(r=e!=null?JN(YN(e)):{},QN(t||!e||!e.__esModule?Ed(r,"default",{value:e,enumerable:!0}):r,e));var e2=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),V1=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),t2=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),n2=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Z1(e){return typeof e=="string"&&V1.has(e.replace(/#$/,""))}function H1(e,t){if(!("$schema"in e)||typeof e.$schema!="string")return"2020-12";let r=e.$schema.replace(/#$/,"");if(e2.has(r))return"2020-12";if(V1.has(r))return"2019-09";if(t2.has(r)||n2.has(r))return"draft-7";throw new Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var ce={};eo(ce,{$brand:()=>Jb,$input:()=>v$,$output:()=>w$,INVALID:()=>mn,NEVER:()=>zl,TimePrecision:()=>T$,ZodAny:()=>hx,ZodArray:()=>wx,ZodBase64:()=>Pp,ZodBase64URL:()=>jp,ZodBigInt:()=>Ha,ZodBigIntFormat:()=>Cp,ZodBoolean:()=>Za,ZodCIDRv4:()=>Rp,ZodCIDRv6:()=>Ip,ZodCUID:()=>vp,ZodCUID2:()=>$p,ZodCatch:()=>Dx,ZodCodec:()=>uu,ZodCompileAsyncError:()=>fr,ZodCompileUnsupportedError:()=>He,ZodCreditCard:()=>ux,ZodCustom:()=>mu,ZodCustomStringFormat:()=>rs,ZodDate:()=>iu,ZodDefault:()=>Tx,ZodDiscriminatedUnion:()=>$x,ZodE164:()=>Ep,ZodEmail:()=>hp,ZodEmoji:()=>bp,ZodEnum:()=>Ua,ZodError:()=>$q,ZodExactOptional:()=>Mp,ZodFile:()=>Ix,ZodFirstPartyTypeKind:()=>Yx,ZodFunction:()=>Wx,ZodGUID:()=>yp,ZodIBAN:()=>mx,ZodIPv4:()=>kp,ZodIPv6:()=>zp,ZodISODate:()=>Wo,ZodISODateTime:()=>Bo,ZodISODuration:()=>Go,ZodISOTime:()=>Jo,ZodInstanceOf:()=>Kx,ZodIntersection:()=>xx,ZodIssueCode:()=>Xx,ZodJWT:()=>Tp,ZodKSUID:()=>Sp,ZodLazy:()=>Hx,ZodLiteral:()=>Rx,ZodMAC:()=>lx,ZodMap:()=>kx,ZodNaN:()=>Ux,ZodNanoID:()=>wp,ZodNever:()=>yx,ZodNonOptional:()=>Dp,ZodNull:()=>px,ZodNullable:()=>Ex,ZodNumber:()=>Va,ZodNumberFormat:()=>os,ZodObject:()=>su,ZodOptional:()=>cu,ZodPipe:()=>lu,ZodPrefault:()=>Ax,ZodPreprocess:()=>Lx,ZodPromise:()=>Bx,ZodReadonly:()=>Fx,ZodRealError:()=>kn,ZodRecord:()=>qa,ZodSet:()=>zx,ZodString:()=>La,ZodStringFormat:()=>st,ZodSuccess:()=>Mx,ZodSymbol:()=>dx,ZodTemplateLiteral:()=>Zx,ZodTransform:()=>Px,ZodTuple:()=>_x,ZodType:()=>Fe,ZodULID:()=>xp,ZodURL:()=>ou,ZodUUID:()=>Ar,ZodUndefined:()=>fx,ZodUnion:()=>au,ZodUnknown:()=>gx,ZodVoid:()=>bx,ZodXID:()=>_p,ZodXor:()=>vx,_ZodString:()=>pp,_default:()=>Cx,_function:()=>bP,any:()=>Ap,array:()=>te,base64:()=>AI,base64url:()=>OI,bigint:()=>GI,boolean:()=>$e,catch:()=>qx,check:()=>wP,cidrv4:()=>TI,cidrv6:()=>CI,clone:()=>tt,codec:()=>pP,coerce:()=>pu,compile:()=>S$,config:()=>wt,core:()=>io,creditCard:()=>MI,cuid:()=>SI,cuid2:()=>kI,currencyCode:()=>VI,custom:()=>vP,date:()=>tP,decode:()=>nx,decodeAsync:()=>ox,deepPartial:()=>TP,describe:()=>$P,discriminatedUnion:()=>Ko,e164:()=>NI,email:()=>gp,emoji:()=>xI,encode:()=>tx,encodeAsync:()=>rx,endsWith:()=>Ia,enum:()=>Ce,exactOptional:()=>jx,file:()=>uP,flattenError:()=>Rl,float32:()=>HI,float64:()=>BI,formatError:()=>Il,fromJSONSchema:()=>jP,function:()=>bP,getDiscriminatedOption:()=>Wv,getErrorMap:()=>kq,globalRegistry:()=>Zt,gt:()=>Tr,gte:()=>Mn,guid:()=>gI,hash:()=>ZI,hex:()=>FI,hostname:()=>LI,httpUrl:()=>$I,iban:()=>DI,includes:()=>za,input:()=>AP,instanceof:()=>_P,int:()=>dp,int32:()=>WI,int64:()=>KI,intersection:()=>hr,invertCodec:()=>hP,ipv4:()=>PI,ipv6:()=>EI,iso:()=>Kn,json:()=>kP,jwt:()=>qI,keyof:()=>nP,ksuid:()=>II,lazy:()=>Yo,length:()=>Qi,literal:()=>ne,locales:()=>Jl,looseObject:()=>je,looseRecord:()=>sP,lowercase:()=>Sa,lt:()=>Er,lte:()=>Nn,mac:()=>jI,map:()=>aP,maxLength:()=>Xi,maxSize:()=>Fo,memoizer:()=>Bl,meta:()=>xP,mime:()=>ja,minLength:()=>oo,minSize:()=>Cr,multipleOf:()=>Lo,nan:()=>fP,nanoid:()=>_I,nativeEnum:()=>lP,negative:()=>np,never:()=>Op,nonnegative:()=>op,nonoptional:()=>Nx,nonpositive:()=>rp,normalize:()=>Ea,null:()=>Or,nullable:()=>ru,nullish:()=>mP,number:()=>me,object:()=>J,optional:()=>ze,output:()=>OP,overwrite:()=>pr,parse:()=>X0,parseAsync:()=>Q0,partialRecord:()=>iP,pipe:()=>fp,positive:()=>tp,prefault:()=>Ox,preprocess:()=>so,prettifyError:()=>Qb,promise:()=>yP,properties:()=>Pa,property:()=>ip,readonly:()=>Vx,record:()=>ve,refine:()=>Jx,regex:()=>_a,regexes:()=>Gn,registry:()=>jf,safeDecode:()=>sx,safeDecodeAsync:()=>cx,safeEncode:()=>ix,safeEncodeAsync:()=>ax,safeParse:()=>nu,safeParseAsync:()=>ex,set:()=>cP,setErrorMap:()=>Sq,size:()=>Yi,slugify:()=>Oa,startsWith:()=>Ra,strictObject:()=>rP,string:()=>j,stringFormat:()=>UI,stringbool:()=>SP,success:()=>dP,superRefine:()=>Gx,symbol:()=>XI,templateLiteral:()=>gP,toJSONSchema:()=>ts,toLowerCase:()=>Ca,toUpperCase:()=>Aa,toZod:()=>gl,transform:()=>Np,treeifyError:()=>Xb,trim:()=>Ta,tuple:()=>Sx,uint32:()=>JI,uint64:()=>YI,ulid:()=>zI,undefined:()=>QI,union:()=>xe,unknown:()=>Re,uppercase:()=>ka,url:()=>Fa,util:()=>oe,uuid:()=>yI,uuidv4:()=>bI,uuidv6:()=>wI,uuidv7:()=>vI,validate:()=>Pl,validateAsync:()=>jl,void:()=>eP,withParser:()=>Ef,xid:()=>RI,xor:()=>oP});var io={};eo(io,{$ZodAny:()=>Dv,$ZodArray:()=>Zv,$ZodAsyncError:()=>_n,$ZodBase64:()=>zv,$ZodBase64URL:()=>Rv,$ZodBigInt:()=>gf,$ZodBigIntFormat:()=>Av,$ZodBoolean:()=>Ul,$ZodCIDRv4:()=>Sv,$ZodCIDRv6:()=>kv,$ZodCUID:()=>dv,$ZodCUID2:()=>fv,$ZodCatch:()=>l$,$ZodCheck:()=>lt,$ZodCheckBigIntFormat:()=>qw,$ZodCheckEndsWith:()=>Yw,$ZodCheckGreaterThan:()=>Qd,$ZodCheckIncludes:()=>Gw,$ZodCheckLengthEquals:()=>Hw,$ZodCheckLessThan:()=>Xd,$ZodCheckLowerCase:()=>Ww,$ZodCheckMaxLength:()=>Vw,$ZodCheckMaxSize:()=>Uw,$ZodCheckMimeType:()=>ev,$ZodCheckMinLength:()=>Zw,$ZodCheckMinSize:()=>Lw,$ZodCheckMultipleOf:()=>Mw,$ZodCheckNumberFormat:()=>Dw,$ZodCheckOverwrite:()=>tv,$ZodCheckProperties:()=>Qw,$ZodCheckProperty:()=>Xw,$ZodCheckRegex:()=>Bw,$ZodCheckSizeEquals:()=>Fw,$ZodCheckStartsWith:()=>Kw,$ZodCheckStringFormat:()=>ba,$ZodCheckUpperCase:()=>Jw,$ZodCodec:()=>Fl,$ZodCreditCard:()=>Pv,$ZodCustom:()=>g$,$ZodCustomStringFormat:()=>Tv,$ZodCyclicError:()=>_f,$ZodDate:()=>Fv,$ZodDefault:()=>i$,$ZodDiscriminatedUnion:()=>Jv,$ZodE164:()=>Iv,$ZodEmail:()=>sv,$ZodEmoji:()=>uv,$ZodEncodeError:()=>qo,$ZodEnum:()=>Qv,$ZodError:()=>Yb,$ZodExactOptional:()=>r$,$ZodFile:()=>t$,$ZodFunction:()=>p$,$ZodGUID:()=>ov,$ZodIBAN:()=>jv,$ZodIPv4:()=>$v,$ZodIPv6:()=>xv,$ZodISODate:()=>bv,$ZodISODateTime:()=>yv,$ZodISODuration:()=>vv,$ZodISOTime:()=>wv,$ZodIntersection:()=>Gv,$ZodJWT:()=>Ev,$ZodKSUID:()=>gv,$ZodLazy:()=>Vl,$ZodLiteral:()=>e$,$ZodMAC:()=>_v,$ZodMap:()=>Yv,$ZodNaN:()=>u$,$ZodNanoID:()=>mv,$ZodNever:()=>Uv,$ZodNonOptional:()=>a$,$ZodNull:()=>Mv,$ZodNullable:()=>o$,$ZodNumber:()=>hf,$ZodNumberFormat:()=>Cv,$ZodObject:()=>zz,$ZodObjectJIT:()=>Hv,$ZodOptional:()=>bf,$ZodPipe:()=>wf,$ZodPrefault:()=>s$,$ZodPreprocess:()=>m$,$ZodPromise:()=>h$,$ZodReadonly:()=>d$,$ZodRealError:()=>Sn,$ZodRecord:()=>Kv,$ZodRegistry:()=>Pf,$ZodSet:()=>Xv,$ZodString:()=>Wi,$ZodStringFormat:()=>nt,$ZodSuccess:()=>c$,$ZodSymbol:()=>Ov,$ZodTemplateLiteral:()=>f$,$ZodTransform:()=>n$,$ZodTuple:()=>yf,$ZodType:()=>Ne,$ZodULID:()=>pv,$ZodURL:()=>lv,$ZodUUID:()=>iv,$ZodUndefined:()=>Nv,$ZodUnion:()=>Ll,$ZodUnknown:()=>qv,$ZodVoid:()=>Lv,$ZodXID:()=>hv,$ZodXor:()=>Bv,$brand:()=>Jb,$constructor:()=>G,$input:()=>v$,$output:()=>w$,Doc:()=>Bi,INVALID:()=>mn,JSONSchema:()=>fI,JSONSchemaGenerator:()=>lp,NEVER:()=>zl,TimePrecision:()=>T$,URL_BAD_FORMAT:()=>av,URL_UNPARSEABLE:()=>Ol,ZodCompileAsyncError:()=>fr,ZodCompileUnsupportedError:()=>He,_any:()=>G$,_array:()=>n0,_base64:()=>Yf,_base64url:()=>Xf,_bigint:()=>F$,_boolean:()=>U$,_catch:()=>lq,_check:()=>YR,_cidrv4:()=>Gf,_cidrv6:()=>Kf,_coercedBigint:()=>V$,_coercedBoolean:()=>L$,_coercedDate:()=>e0,_coercedNumber:()=>A$,_coercedString:()=>I$,_creditCard:()=>j$,_cuid:()=>Ff,_cuid2:()=>Vf,_custom:()=>o0,_date:()=>Q$,_decode:()=>Ld,_decodeAsync:()=>Vd,_default:()=>sq,_discriminatedUnion:()=>J4,_e164:()=>Qf,_email:()=>Af,_emoji:()=>Uf,_encode:()=>Ud,_encodeAsync:()=>Fd,_endsWith:()=>Ia,_enum:()=>eq,_file:()=>r0,_float32:()=>N$,_float64:()=>M$,_gt:()=>Tr,_gte:()=>Mn,_guid:()=>Of,_iban:()=>E$,_includes:()=>za,_int:()=>O$,_int32:()=>D$,_int64:()=>Z$,_intersection:()=>G4,_ipv4:()=>Wf,_ipv6:()=>Jf,_isoDate:()=>Yl,_isoDateTime:()=>Kl,_isoDuration:()=>Ql,_isoTime:()=>Xl,_jwt:()=>ep,_ksuid:()=>Bf,_lazy:()=>fq,_length:()=>Qi,_literal:()=>nq,_lowercase:()=>Sa,_lt:()=>Er,_lte:()=>Nn,_mac:()=>P$,_map:()=>X4,_max:()=>Nn,_maxLength:()=>Xi,_maxSize:()=>Fo,_mime:()=>ja,_min:()=>Mn,_minLength:()=>oo,_minSize:()=>Cr,_multipleOf:()=>Lo,_nan:()=>t0,_nanoid:()=>Lf,_nativeEnum:()=>tq,_negative:()=>np,_never:()=>Y$,_nonnegative:()=>op,_nonoptional:()=>aq,_nonpositive:()=>rp,_normalize:()=>Ea,_null:()=>J$,_nullable:()=>iq,_number:()=>C$,_optional:()=>oq,_overwrite:()=>pr,_parse:()=>pa,_parseAsync:()=>ha,_pipe:()=>uq,_positive:()=>tp,_promise:()=>pq,_properties:()=>Pa,_property:()=>ip,_readonly:()=>mq,_record:()=>Y4,_refine:()=>i0,_regex:()=>_a,_safeDecode:()=>Hd,_safeDecodeAsync:()=>Wd,_safeEncode:()=>Zd,_safeEncodeAsync:()=>Bd,_safeParse:()=>ga,_safeParseAsync:()=>ya,_set:()=>Q4,_size:()=>Yi,_slugify:()=>Oa,_startsWith:()=>Ra,_string:()=>R$,_stringFormat:()=>es,_stringbool:()=>l0,_success:()=>cq,_superRefine:()=>s0,_symbol:()=>B$,_templateLiteral:()=>dq,_toLowerCase:()=>Ca,_toUpperCase:()=>Aa,_transform:()=>rq,_trim:()=>Ta,_tuple:()=>K4,_uint32:()=>q$,_uint64:()=>H$,_ulid:()=>Zf,_undefined:()=>W$,_union:()=>B4,_unknown:()=>K$,_uppercase:()=>ka,_url:()=>Gl,_uuid:()=>Nf,_uuidv4:()=>Mf,_uuidv6:()=>Df,_uuidv7:()=>qf,_void:()=>X$,_xid:()=>Hf,_xor:()=>W4,base64Charset:()=>uf,base64urlCharset:()=>ql,canParseURL:()=>cv,clone:()=>tt,compile:()=>S$,compileFn:()=>Tf,config:()=>wt,createStandardJSONSchemaMethod:()=>Na,createToJSONSchemaMethod:()=>m0,decode:()=>W2,decodeAsync:()=>G2,describe:()=>a0,encode:()=>B2,encodeAsync:()=>J2,extractDefs:()=>Zo,finalize:()=>Ho,flattenError:()=>Rl,formatError:()=>Il,getDiscriminatedOption:()=>Wv,globalConfig:()=>Nt,globalRegistry:()=>Zt,handleUnrepresentable:()=>jt,initializeContext:()=>Vo,isBackEdge:()=>kf,isRecursiveSchema:()=>Sf,isValidBase64:()=>Dl,isValidBase64URL:()=>mf,isValidCIDRv6:()=>lf,isValidCreditCard:()=>df,isValidIBAN:()=>ff,isValidIPv6:()=>Ml,isValidJWT:()=>pf,locales:()=>Jl,memoizer:()=>Bl,mergeValues:()=>wa,meta:()=>c0,parse:()=>Dd,parseAsync:()=>qd,parseURLObject:()=>_z,prettifyError:()=>Qb,process:()=>rt,processSchema:()=>rt,regexes:()=>Gn,registry:()=>jf,safeDecode:()=>Y2,safeDecodeAsync:()=>Q2,safeEncode:()=>K2,safeEncodeAsync:()=>X2,safeParse:()=>L2,safeParseAsync:()=>F2,standardProps:()=>of,stripTabAndNewline:()=>Nl,toDotPath:()=>nz,toJSONSchema:()=>ts,toZod:()=>gl,treeifyError:()=>Xb,urlHostnameOk:()=>af,urlProtocolOk:()=>cf,util:()=>oe,validate:()=>Pl,validateAsync:()=>jl,validateURL:()=>sf,version:()=>nv,withParser:()=>Ef});var oe={};eo(oe,{BIGINT_FORMAT_RANGES:()=>$l,CONSTANT_CATCH:()=>Nd,Class:()=>Db,NUMBER_FORMAT_RANGES:()=>vl,aborted:()=>un,allowsEval:()=>Lb,assert:()=>a2,assertEqual:()=>r2,assertIs:()=>i2,assertNever:()=>s2,assertNotEqual:()=>o2,assignProp:()=>Vt,attachSchema:()=>xl,base64ToUint8Array:()=>K1,base64urlToUint8Array:()=>z2,cached:()=>ua,captureStackTrace:()=>Ad,cleanEnum:()=>k2,cleanRegex:()=>no,clone:()=>tt,cloneDef:()=>u2,codePointLength:()=>Zi,constantCatch:()=>Bb,createTransparentProxy:()=>g2,defineLazy:()=>qb,defineLazyInternal:()=>Ve,derived:()=>j2,esc:()=>ln,escapeRegex:()=>Jn,explicitlyAborted:()=>Zb,extend:()=>w2,finalizeIssue:()=>xn,floatSafeRemainder:()=>yl,getElementAtPath:()=>m2,getEnumValues:()=>ca,getLengthableOrigin:()=>Sl,getParsedType:()=>h2,getSizableOrigin:()=>_l,hexToUint8Array:()=>I2,hide:()=>kl,installLazyProp:()=>A2,isObject:()=>Vi,isPlainObject:()=>Wn,issue:()=>fa,joinValues:()=>K,jsonStringifyReplacer:()=>la,members:()=>Hb,merge:()=>$2,mergeDefs:()=>dr,normalizeParams:()=>he,nullish:()=>Cd,numKeys:()=>p2,objectClone:()=>c2,omit:()=>b2,optionalKeys:()=>Vb,own:()=>Do,parsedType:()=>se,partial:()=>x2,pick:()=>y2,prefixIssues:()=>$n,primitiveTypes:()=>Fb,promiseAllObject:()=>d2,propertyKeyTypes:()=>wl,randomString:()=>f2,rawShape:()=>ma,required:()=>_2,safeExtend:()=>v2,shallowClone:()=>bl,sizeCaps:()=>da,slugify:()=>Ub,stringifyPrimitive:()=>ie,toZod:()=>gl,uint8ArrayToBase64:()=>Y1,uint8ArrayToBase64url:()=>R2,uint8ArrayToHex:()=>P2,unwrapMessage:()=>aa});function r2(e){return e}function o2(e){return e}function gl(){return e=>e}function i2(e){}function s2(e){throw new Error("Unexpected value in exhaustive check")}function a2(e){}function ca(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function K(e,t="|"){return e.map(r=>ie(r)).join(t)}function la(e,t){return typeof t=="bigint"?t.toString():t}var Mb=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function ua(e){return new Mb(e)}function Cd(e){return e==null}function no(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function yl(e,t){let r=e/t,o=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-o)<n?0:r-o}var B1=Symbol("evaluating");function qb(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==B1)return o===void 0&&(o=B1,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function c2(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Vt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ma(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function to(e){return ma(e._zod.def)??e._zod.def.shape}function W1(e,t,r){Object.defineProperty(e,t,{get(){let o=r();return Vt(this,t,o),o},enumerable:!0,configurable:!0})}function J1(e,t,r){t in e?Vt(e,t,r):e[t]=r}function Fi(e,t,r,o){let n=to(t);for(let i of r){let s=Object.getOwnPropertyDescriptor(n,i);s.enumerable&&(s.get?W1(e,i,()=>{let a=t._zod.def.shape[i];return o?o(a,i):a}):J1(e,i,o?o(s.value,i):s.value))}}function l2(e,t){for(let r of Reflect.ownKeys(t)){let o=Object.getOwnPropertyDescriptor(t,r);o.enumerable&&(o.get?W1(e,r,()=>t[r]):J1(e,r,o.value))}}function dr(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function u2(e){return dr(e._zod.def)}function m2(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function d2(e){let t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{let n={};for(let i=0;i<t.length;i++)n[t[i]]=o[i];return n})}function f2(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function ln(e){return JSON.stringify(e)}function Ub(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Ad="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Vi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Lb=ua(()=>{if(Nt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Wn(e){if(Vi(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Vi(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function bl(e){return Wn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function p2(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var h2=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},wl=new Set(["string","number","symbol"]),Fb=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Jn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tt(e,t,r){let o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function he(e){let t=e;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}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function g2(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,i){return t??(t=e()),Reflect.set(t,o,n,i)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}function ie(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Vb(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var vl={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},$l={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function y2(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i={};return Fi(i,e,Od(e,t)),tt(e,dr(r,{shape:i,checks:[]}))}function Od(e,t){let r=to(e),o=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw new Error(`Unrecognized key: "${String(n)}"`);t[n]&&o.push(n)}return o}function b2(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(Od(e,t)),s={};return Fi(s,e,Reflect.ownKeys(to(e)).filter(a=>!i.has(a))),tt(e,dr(r,{shape:s,checks:[]}))}function w2(e,t){if(!Wn(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=to(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return tt(e,dr(e._zod.def,{shape:G1(e,t)}))}function G1(e,t){let r={};return Fi(r,e,Reflect.ownKeys(to(e))),l2(r,t),r}function v2(e,t){if(!Wn(t))throw new Error("Invalid input to safeExtend: expected a plain object");return tt(e,dr(e._zod.def,{shape:G1(e,t)}))}function $2(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Fi(r,e,Reflect.ownKeys(to(e))),Fi(r,t,Reflect.ownKeys(to(t)));let o=dr(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return tt(e,o)}function x2(e,t,r,o="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${o}() cannot be used on object schemas containing refinements`);let a=r?new Set(Od(t,r)):void 0,c={};return Fi(c,t,Reflect.ownKeys(to(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),tt(t,dr(t._zod.def,{shape:c,checks:[]}))}function _2(e,t,r){let o=r?new Set(Od(t,r)):void 0,n={};return Fi(n,t,Reflect.ownKeys(to(t)),(i,s)=>o&&!o.has(s)?i:new e({type:"nonoptional",innerType:i})),tt(t,dr(t._zod.def,{shape:n}))}function un(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Zb(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function $n(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function aa(e){return typeof e=="string"?e:e?.message}function da(e){let t=[];for(let r of e??[]){let o=r._zod.def;if(!/_(length|size)$|_equals$/.test(o.check))break;let n=o.maximum??o.length??o.size;n>=0&&t.push([n,r])}return t}function xl(e,t,r){var o;for(let n=t;n<e.length;n++)(o=e[n]).schema??(o.schema=r)}function xn(e,t,r){var o;let n=e.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?(o=e).schema??(o.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:aa(e.inst?._zod.def?.error?.(e))??aa(i?.(e))??aa(t?.error?.(e))??aa(r.customError?.(e))??aa(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}function _l(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var S2=/[\uD800-\uDBFF]/;function Zi(e){let t=e.length;if(!S2.test(e))return t;let r=t;for(let o=0;o<t-1;o++)(e.charCodeAt(o)&64512)===55296&&(e.charCodeAt(o+1)&64512)===56320&&(r--,o++);return r}function Sl(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function se(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function fa(...e){let[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function k2(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function K1(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function Y1(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function z2(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return K1(t+r)}function R2(e){return Y1(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function I2(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function P2(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Db=class{constructor(...t){}};function Hb(e,t){for(let r in t){let o=Object.getOwnPropertyDescriptor(t,r);o.get?Object.defineProperty(e,r,{...o,enumerable:!1}):E2(e,r,o.value)}}function Do(e,t,r,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:r}),r}function kl(e,t,r){return Do(e,t,r,!1)}function j2(e,t){for(let r in e){let o=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Do(this,r,o(this))},set(n){Do(this,r,n)}})}return t}function E2(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Do(this,t,r.bind(this))},set(o){Do(this,t,o)}})}function T2(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Nb,Mo=!1,C2={configurable:!0,get(){Mo=!0}};function Ve(e,t,r){let o=Object.getPrototypeOf(e._zod);if(t in o&&Nb!==e._zod){Nb=void 0;return}Nb=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,C2);let n=Mo;Mo=!1;try{let i=r(this);return Mo?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),Mo=Mo||n,i}catch(i){throw delete this[t],Mo=Mo||n,i}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function A2(e,t,r,o){let n=T2(e,t);n&&Object.defineProperty(n,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:o,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:o,value:i})}})}var Nd="~constantCatch";function Bb(e){let t=()=>e;return t[Nd]=!0,t}var X1,zl=Object.freeze({status:"aborted"}),Wb={value:void 0,enumerable:!1},Q1="captureStackTrace"in Error?Error:null;function O2(e){let t=Q1;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Q1=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function G(e,t,r,o){let n={};function i(d){this.def=d,this.constr=m,this.traits=new Set}i.prototype=n;let s=r,a=s&&new WeakSet;function c(d,f){if(d._zod){if(d._zod.traits.has(e))return}else{Wb.value=new i(f);try{Object.defineProperty(d,"_zod",Wb)}finally{Wb.value=void 0}}if(d._zod.traits.add(e),t(d,f),a){let h=Object.getPrototypeOf(d),g=d._zod.constr.prototype,b=h;for(;b&&b!==g;)b=Object.getPrototypeOf(b);let y=b??h;a.has(y)||(a.add(y),Hb(y,s))}let p=m.prototype;for(let h in p)Object.prototype.hasOwnProperty.call(p,h)&&(h in d||(d[h]=p[h].bind(d)))}let l=o?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function m(d){let f=o?.Parent?O2(u):this;c(f,d);let p=f._zod.deferred;if(p){for(let g of p)g();f._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(f),f}return Object.defineProperty(m,"init",{value:c}),Object.defineProperty(m,Symbol.hasInstance,{value:d=>o?.Parent&&d instanceof o.Parent?!0:d?._zod?.traits?.has(e)}),Object.defineProperty(m,"name",{value:e}),m}var Jb=Symbol("zod_brand"),_n=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},qo=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(X1=globalThis).__zod_globalConfig??(X1.__zod_globalConfig={});var Nt=globalThis.__zod_globalConfig;function wt(e){return e&&Object.assign(Nt,e),Nt}function N2(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,la,2)),e.message}function M2(e){this._zod.message=e}var D2={get:N2,set:M2,enumerable:!0,configurable:!0},Kb={value:void 0,enumerable:!1},ez=new WeakSet([Object.prototype,Error.prototype]),tz=(e,t)=>{e.name="$ZodError",Kb.value=t,Object.defineProperty(e,"issues",Kb),Kb.value=void 0,Object.defineProperty(e,"message",D2);let r=Object.getPrototypeOf(e);ez.has(r)||(ez.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let o=()=>this.message;return Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0})}}))},Yb=G("$ZodError",tz),Sn=G("$ZodError",tz,void 0,{Parent:Error});function q2(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Rl(e,t=r=>r.message){let r={},o=[];for(let n of e.issues)n.path.length>0?q2(r,n.path[0],()=>[]).push(t(n)):o.push(t(n));return{formErrors:o,fieldErrors:r}}function Il(e,t=r=>r.message){let r={_errors:[]},o=(n,i=[])=>{for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>o({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")o({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")o({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,l=0;for(;l<a.length;){let u=a[l],m=l===a.length-1;if(u==="_errors"){m&&c._errors.push(t(s)),l++;continue}Object.prototype.hasOwnProperty.call(c,u)||Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];m&&d._errors.push(t(s)),c=d,l++}}}};return o(e),r}function Xb(e,t=r=>r.message){let r={errors:[]},o=(n,i=[])=>{var s;for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(c=>o({issues:c},[...i,...a.path]));else if(a.code==="invalid_key")o({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")o({issues:a.issues},[...i,...a.path]);else{let c=[...i,...a.path];if(c.length===0){r.errors.push(t(a));continue}let l=r,u=0;for(;u<c.length;){let m=c[u],d=u===c.length-1;typeof m=="string"?(l.properties??(l.properties={}),Object.prototype.hasOwnProperty.call(l.properties,m)||Object.defineProperty(l.properties,m,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),l=l.properties[m]):(l.items??(l.items=[]),(s=l.items)[m]??(s[m]={errors:[]}),l=l.items[m]),d&&l.errors.push(t(a)),u++}}};return o(e),r}function nz(e){let t=[],r=e.map(o=>typeof o=="object"?o.key:o);for(let o of r)typeof o=="number"?t.push(`[${o}]`):typeof o=="symbol"?t.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?t.push(`[${JSON.stringify(o)}]`):(t.length&&t.push("."),t.push(o));return t.join("")}function Qb(e){let t=[],r=[...e.issues].sort((o,n)=>(o.path??[]).length-(n.path??[]).length);for(let o of r)t.push(`\u2716 ${o.message}`),o.path?.length&&t.push(` \u2192 at ${nz(o.path)}`);return t.join(`
4
+ `)}function Md(e,t){return{callee:t?.callee??e,Err:t?.Err}}var pa=e=>{let t=(r,o,n,i)=>{let s=n?{...n,async:!1}:{async:!1},a=r._zod.run({value:o,issues:[]},s);if(a instanceof Promise)throw new _n;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map(l=>xn(l,s,wt())));throw Ad(c,i?.callee??t),c}return a.value};return t},Dd=pa(Sn),ha=e=>{let t=async(r,o,n,i)=>{let s=n?{...n,async:!0}:{async:!0},a=r._zod.run({value:o,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(i?.Err??e)(a.issues.map(l=>xn(l,s,wt())));throw Ad(c,i?.callee??t),c}return a.value};return t},qd=ha(Sn),ga=e=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new _n;return i.issues.length?rz(e,i.issues,n):{success:!0,data:i.value}},L2=ga(Sn);function rz(e,t,r){let o;return{success:!1,get error(){return o||(o=new e(t.map(n=>xn(n,r,wt()))),t=void 0,r=void 0),o},set error(n){o=n,t=void 0,r=void 0}}}var ya=e=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length?rz(e,i.issues,n):{success:!0,data:i.value}},F2=ya(Sn),V2=Symbol.for("zod.compile.invalid"),Z2=Symbol.for("zod.compile.fallback"),Pl=((e,t,r)=>{let o=e._zod.bag.validator;if(o!==void 0){if(o(t)!==V2)return!0;if(o.definite===!0&&r===void 0)return!1}return H2(e,t,r)});function H2(e,t,r){let o=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=e._zod.bag.fallbackRun,i;if(n?(o[Z2]=!0,i=n({value:t,issues:[]},o)):i=e._zod.run({value:t,issues:[]},o),i instanceof Promise)throw new _n;return i.issues.length===0}var jl=async(e,t,r)=>{let o=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},o);return n instanceof Promise&&(n=await n),n.issues.length===0},Ud=e=>{let t=pa(e),r=(o,n,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(o,n,a,Md(r,s))};return r},B2=Ud(Sn),Ld=e=>{let t=pa(e),r=(o,n,i,s)=>t(o,n,i,Md(r,s));return r},W2=Ld(Sn),Fd=e=>{let t=ha(e),r=async(o,n,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(o,n,a,Md(r,s))};return r},J2=Fd(Sn),Vd=e=>{let t=ha(e),r=async(o,n,i,s)=>await t(o,n,i,Md(r,s));return r},G2=Vd(Sn),Zd=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return ga(e)(t,r,n)},K2=Zd(Sn),Hd=e=>(t,r,o)=>ga(e)(t,r,o),Y2=Hd(Sn),Bd=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return ya(e)(t,r,n)},X2=Bd(Sn),Wd=e=>async(t,r,o)=>ya(e)(t,r,o),Q2=Wd(Sn);var Gn={};eo(Gn,{anyString:()=>zw,base64:()=>yw,base64url:()=>bw,bigint:()=>Iw,boolean:()=>Pw,browserEmail:()=>aM,cidrv4:()=>hw,cidrv6:()=>gw,creditCard:()=>Jd,cuid:()=>tw,cuid2:()=>nw,currencyCode:()=>xw,date:()=>_w,datetime:()=>kw,domain:()=>vw,duration:()=>cw,e164:()=>$w,email:()=>uw,emoji:()=>mw,extendedDuration:()=>eM,guid:()=>lw,hex:()=>Aw,hostname:()=>ww,html5Email:()=>oM,httpProtocol:()=>El,iban:()=>Gd,idnEmail:()=>sM,integer:()=>Tl,ipv4:()=>dw,ipv6:()=>fw,ksuid:()=>iw,lowercase:()=>Tw,mac:()=>pw,md5_base64:()=>mM,md5_base64url:()=>dM,md5_hex:()=>uM,nanoid:()=>sw,nanoidOfLength:()=>aw,null:()=>jw,number:()=>ro,rfc5322Email:()=>iM,sha1_base64:()=>pM,sha1_base64url:()=>hM,sha1_hex:()=>fM,sha256_base64:()=>yM,sha256_base64url:()=>bM,sha256_hex:()=>gM,sha384_base64:()=>vM,sha384_base64url:()=>$M,sha384_hex:()=>wM,sha512_base64:()=>_M,sha512_base64url:()=>SM,sha512_hex:()=>xM,string:()=>Rw,time:()=>Sw,ulid:()=>rw,undefined:()=>Ew,unicodeEmail:()=>oz,uppercase:()=>Cw,uuid:()=>Hi,uuid4:()=>tM,uuid6:()=>nM,uuid7:()=>rM,xid:()=>ow});var tw=/^[cC][0-9a-z]{6,}$/,nw=/^[0-9a-z]+$/,rw=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ow=/^[0-9a-vA-V]{20}$/,iw=/^[A-Za-z0-9]{27}$/,sw=/^[a-zA-Z0-9_-]{21}$/;function aw(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var cw=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,eM=/^[-+]?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)?)??$/,lw=/^([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})$/,Hi=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([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|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,tM=Hi(4),nM=Hi(6),rM=Hi(7),uw=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,oM=/^[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])?)*$/,iM=/^(([^<>()\[\]\\.,;:\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,}))$/,oz=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,sM=oz,aM=/^[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])?)*$/,cM="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function mw(){return new RegExp(cM,"u")}var dw=/^(?:(?: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])$/,fw=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,pw=e=>{let t=Jn(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},hw=/^((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])$/,gw=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yw=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bw=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,ww=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,vw=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,El=/^https?$/,$w=/^\+[1-9]\d{6,14}$/,Jd=/^\d(?:[ -]?\d){11,18}$/,xw=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,Gd=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,iz="(?:(?:\\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])))";function lM(e){return new RegExp(`^${e}$`)}var _w=lM(iz);function ew(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Sw(e){return new RegExp(`^${ew(e)}$`)}function kw(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${ew({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,o=e.local?`${r}|${ew({precision:e.precision})}`:r;return new RegExp(`^${iz}T(?:${o})$`)}var zw=/^[\s\S]{0,}$/,Rw=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Iw=/^-?\d+n?$/,Tl=/^-?\d+$/,ro=/^-?\d+(?:\.\d+)?$/,Pw=/^(?:true|false)$/i,jw=/^null$/i;var Ew=/^undefined$/i;var Tw=/^[^A-Z]*$/,Cw=/^[^a-z]*$/,Aw=/^[0-9a-fA-F]*$/;function Cl(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Al(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var uM=/^[0-9a-fA-F]{32}$/,mM=Cl(22,"=="),dM=Al(22),fM=/^[0-9a-fA-F]{40}$/,pM=Cl(27,"="),hM=Al(27),gM=/^[0-9a-fA-F]{64}$/,yM=Cl(43,"="),bM=Al(43),wM=/^[0-9a-fA-F]{96}$/,vM=Cl(64,""),$M=Al(64),xM=/^[0-9a-fA-F]{128}$/,_M=Cl(86,"=="),SM=Al(86);var lt=G("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Ow=e=>{let t=e.value;return!Cd(t)&&t.size!==void 0},Nw=e=>{let t=e.value;return!Cd(t)&&t.length!==void 0},Kd={number:"number",bigint:"bigint",object:"date"},Xd=G("$ZodCheckLessThan",(e,t)=>{lt.init(e,t);let r=Kd[typeof t.value];e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:Kd[typeof o.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Qd=G("$ZodCheckGreaterThan",(e,t)=>{lt.init(e,t);let r=Kd[typeof t.value];e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:Kd[typeof o.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Mw=G("$ZodCheckMultipleOf",(e,t)=>{lt.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):yl(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Dw=G("$ZodCheckNumberFormat",(e,t)=>{lt.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,i]=vl[t.format];e._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}a<n&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),qw=G("$ZodCheckBigIntFormat",(e,t)=>{lt.init(e,t);let[r,o]=$l[t.format];e._zod.check=n=>{let i=n.value;i<r&&n.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>o&&n.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Uw=G("$ZodCheckMaxSize",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Ow),e._zod.check=o=>{let n=o.value;n.size<=t.maximum||o.issues.push({origin:_l(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Lw=G("$ZodCheckMinSize",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Ow),e._zod.check=o=>{let n=o.value;n.size>=t.minimum||o.issues.push({origin:_l(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Fw=G("$ZodCheckSizeEquals",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Ow),e._zod.check=o=>{let n=o.value,i=n.size;if(i===t.size)return;let s=i>t.size;o.issues.push({origin:_l(n),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Vw=G("$ZodCheckMaxLength",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Nw),e._zod.check=o=>{let n=o.value,i=n.length;if((typeof n=="string"&&i>t.maximum?Zi(n):i)<=t.maximum)return;let a=Sl(n);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Zw=G("$ZodCheckMinLength",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Nw),e._zod.check=o=>{let n=o.value,i=n.length;if((typeof n=="string"&&i>=t.minimum&&i<t.minimum*2?Zi(n):i)>=t.minimum)return;let a=Sl(n);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Hw=G("$ZodCheckLengthEquals",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Nw),e._zod.check=o=>{let n=o.value,i=n.length,s=typeof n=="string"&&i>=t.length&&i<=t.length*2?Zi(n):i;if(s===t.length)return;let a=Sl(n),c=s>t.length;o.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),ba=G("$ZodCheckStringFormat",(e,t)=>{var r,o;lt.init(e,t),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Bw=G("$ZodCheckRegex",(e,t)=>{ba.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ww=G("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Tw),ba.init(e,t)}),Jw=G("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Cw),ba.init(e,t)}),Gw=G("$ZodCheckIncludes",(e,t)=>{lt.init(e,t);let r=Jn(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=o,e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Kw=G("$ZodCheckStartsWith",(e,t)=>{lt.init(e,t);let r=new RegExp(`^${Jn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Yw=G("$ZodCheckEndsWith",(e,t)=>{lt.init(e,t);let r=new RegExp(`.*${Jn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});function Yd(e,t,r){e.issues.length&&t.issues.push(...$n(r,e.issues))}var Xw=G("$ZodCheckProperty",(e,t)=>{lt.init(e,t),e._zod.check=r=>{let o=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then(n=>Yd(n,r,t.property));Yd(o,r,t.property)}}),Qw=G("$ZodCheckProperties",(e,t)=>{lt.init(e,t),kl(e,Symbol.iterator,function*(){yield e});let r;e._zod.check=o=>{if(o.value==null){o.issues.push({expected:"object",code:"invalid_type",input:o.value,inst:e});return}r??(r=Reflect.ownKeys(t.shape).map(s=>[s,t.shape[s]]));let n=o.value,i;for(let[s,a]of r){let c=a._zod.run({value:n[s],issues:[]},{});c instanceof Promise?(i??(i=[]),i.push(c.then(l=>Yd(l,o,s)))):Yd(c,o,s)}if(i)return Promise.all(i).then(()=>{})}}),ev=G("$ZodCheckMimeType",(e,t)=>{lt.init(e,t);let r=new Set(t.mime);e._zod.check=o=>{r.has(o.value.type)||o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e,continue:!t.abort})}}),tv=G("$ZodCheckOverwrite",(e,t)=>{lt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Bi=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let o=t.split(`
5
+ `).filter(s=>s),n=Math.min(...o.map(s=>s.length-s.trimStart().length)),i=o.map(s=>s.slice(n)).map(s=>" ".repeat(this.indent*2)+s);for(let s of i)this.content.push(s)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
6
+ ${r.join(`
7
+ `)}
8
+ };`)(...Object.values(this.closed))}};var nv={major:4,minor:6,patch:7};var Ne=G("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nv;let o=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...o??[]]:o?.length?[...o]:[];for(let i of n)for(let s of i._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,l)=>{if(a.memo)return a;let u=un(a),m;for(let d of c){if(d._zod.def.when){if(Zb(a)||!d._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,p=d._zod.check(a);if(p instanceof Promise&&l?.async===!1)throw new _n;if(m||p instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(xl(a.issues,f,e),u||(u=un(a,f)))});else{if(a.issues.length===f)continue;xl(a.issues,f,e),u||(u=un(a,f))}}return m?m.then(()=>a):a},s=(a,c,l)=>{if(un(a))return a.aborted=!0,a;let u=i(c,n,l);if(u instanceof Promise){if(l.async===!1)throw new _n;return u.then(m=>e._zod.parse(m,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(m=>s(m,a,c)):s(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new _n;return l.then(u=>i(u,n,c))}return i(l,n,c)}}},{get"~standard"(){return kl(this,"~standard",of(this))},set"~standard"(e){Do(this,"~standard",e)}}),xz=(e,t)=>e.issues.length?{issues:e.issues.map(r=>xn(r,t,wt()))}:{value:e.value};async function kM(e,t){let r={async:!0};return xz(await e._zod.run({value:t,issues:[]},r),r)}function of(e){return{validate:t=>{let r={async:!1};try{let o=e._zod.run({value:t,issues:[]},r);if(!(o instanceof Promise))return xz(o,r)}catch{}return kM(e,t)},vendor:"zod",version:1}}var Wi=G("$ZodString",(e,t)=>{Ne.init(e,t),e._zod.pattern=t.pattern??zw,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),nt=G("$ZodStringFormat",(e,t)=>{ba.init(e,t),Wi.init(e,t)}),ov=G("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=lw),nt.init(e,t)}),iv=G("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Hi(o))}else t.pattern??(t.pattern=Hi());nt.init(e,t)}),sv=G("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=uw),nt.init(e,t)}),av=1,Ol=2;function cv(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function sf(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?cv(e)||Ol:_z(e,t)}function _z(e,t){if(!t.normalize&&t.protocol?.source===El.source&&!/^https?:\/\//i.test(e))return av;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Ol}return new URL(e)}catch{return Ol}}var zM=/[\t\n\r]/g;function Nl(e){return e.replace(zM,"")}function af(e,t){return t.lastIndex=0,t.test(e.hostname)}function cf(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var lv=G("$ZodURL",(e,t)=>{nt.init(e,t),e._zod.check=r=>{try{let o=r.value.trim(),n=sf(o,t);if(n===av){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(n===Ol){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(n===!0){r.value=Nl(o);return}t.hostname&&!af(n,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!cf(n,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?n.href:Nl(o);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),uv=G("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=mw()),nt.init(e,t)}),mv=G("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?sw:aw(t.length)),nt.init(e,t)}),dv=G("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=tw),nt.init(e,t)}),fv=G("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=nw),nt.init(e,t)}),pv=G("$ZodULID",(e,t)=>{t.pattern??(t.pattern=rw),nt.init(e,t)}),hv=G("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ow),nt.init(e,t)}),gv=G("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=iw),nt.init(e,t)}),yv=G("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=kw(t)),nt.init(e,t)}),bv=G("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=_w),nt.init(e,t)}),wv=G("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Sw(t)),nt.init(e,t)}),vv=G("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=cw),nt.init(e,t)}),$v=G("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=dw),nt.init(e,t)}),RM=/^[0-9a-fA-F:.]+$/;function Ml(e){return RM.test(e)?cv(`http://[${e}]`):!1}var xv=G("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=fw),nt.init(e,t),e._zod.check=r=>{Ml(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),_v=G("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=pw(t.delimiter)),nt.init(e,t)}),Sv=G("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=hw),nt.init(e,t)});function lf(e){let t=e.split("/");if(t.length!==2)return!1;let[r,o]=t;if(!o)return!1;let n=Number(o);return`${n}`!==o||n<0||n>128?!1:Ml(r)}var kv=G("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=gw),nt.init(e,t),e._zod.check=r=>{lf(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Dl(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var uf=/^[0-9a-zA-Z+/]*={0,2}$/,zv=G("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=uf),nt.init(e,t),e._zod.check=r=>{Dl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),ql=/^[A-Za-z0-9_-]*$/;function mf(e){if(!ql.test(e))return!1;let t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Dl(r)}var Rv=G("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ql),nt.init(e,t),e._zod.check=r=>{mf(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Iv=G("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$w),nt.init(e,t)}),IM=/[- ]/g;function PM(e){let t=e.length,r=1,o=0;for(;t;){let n=e.charCodeAt(--t)-48;r^=1,o+=r?[0,2,4,6,8,1,3,5,7,9][n]:n}return o%10===0}function df(e){return Jd.test(e)?PM(e.replace(IM,"")):!1}var Pv=G("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=Jd),nt.init(e,t),e._zod.check=r=>{df(r.value)||r.issues.push({code:"invalid_format",format:"credit_card",input:r.value,inst:e,continue:!t.abort})}});function jM(e){let t=0,r=e.length;for(let o=4;o<r;o++){let n=e.charCodeAt(o);t=(n>=65?t*100+(n-55):t*10+(n-48))%97}for(let o=0;o<4;o++){let n=e.charCodeAt(o);t=(n>=65?t*100+(n-55):t*10+(n-48))%97}return t===1}function ff(e){return Gd.test(e)?jM(e):!1}var jv=G("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=Gd),nt.init(e,t),e._zod.check=r=>{ff(r.value)||r.issues.push({code:"invalid_format",format:"iban",input:r.value,inst:e,continue:!t.abort})}});function pf(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}var Ev=G("$ZodJWT",(e,t)=>{nt.init(e,t),e._zod.check=r=>{pf(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Tv=G("$ZodCustomStringFormat",(e,t)=>{nt.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),hf=G("$ZodNumber",(e,t)=>{Ne.init(e,t),e._zod.pattern=ro,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let i=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:String(n):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}}),Cv=G("$ZodNumberFormat",(e,t)=>{Dw.init(e,t),hf.init(e,t)}),Ul=G("$ZodBoolean",(e,t)=>{Ne.init(e,t),e._zod.pattern=Pw,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=!!r.value}catch{}let n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),gf=G("$ZodBigInt",(e,t)=>{Ne.init(e,t),e._zod.pattern=Iw,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),Av=G("$ZodBigIntFormat",(e,t)=>{qw.init(e,t),gf.init(e,t)}),Ov=G("$ZodSymbol",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;return typeof n=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),Nv=G("$ZodUndefined",(e,t)=>{Ne.init(e,t),e._zod.pattern=Ew,e._zod.values=new Set([void 0]),e._zod.parse=(r,o)=>{let n=r.value;return typeof n>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),Mv=G("$ZodNull",(e,t)=>{Ne.init(e,t),e._zod.pattern=jw,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),Dv=G("$ZodAny",(e,t)=>{Ne.init(e,t),e._zod.parse=r=>r}),qv=G("$ZodUnknown",(e,t)=>{Ne.init(e,t),e._zod.parse=r=>r}),Uv=G("$ZodNever",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Lv=G("$ZodVoid",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;return typeof n>"u"||r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),Fv=G("$ZodDate",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let n=r.value,i=n instanceof Date;return i&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...i?{received:"Invalid Date"}:{},inst:e}),r}});function Vv(e,t){let r=da(e._zod.def.checks);if(!r.length)return;let o=Math.min(...r.map(i=>i[0])),n=e._zod.parse;e._zod.parse=(i,s)=>{let a=t(i.value);if(a>o&&!s?.skipChecks&&s?.direction!=="backward"){for(let[c,l]of da(e._zod.def.checks))if(a>c&&l._zod.def.when(i)){let u=i.issues.length;return l._zod.check(i),i.issues[u].continue=!1,xl(i.issues,u,e),i}}return n(i,s)}}var EM=e=>Array.isArray(e)?e.length:-1,TM=e=>e instanceof Map?e.size:-1,CM=e=>e instanceof Set?e.size:-1;function az(e,t,r){e.issues.length&&t.issues.push(...$n(r,e.issues)),t.value[r]=e.value}var Zv=G("$ZodArray",(e,t)=>{Ne.init(e,t);let r=Nt.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),o;o.value=r?r.alloc(e,o,Array(i.length),n):Array(i.length);let s=[],a=n?.abortEarly;for(let c=0;c<i.length;c++){let l=i[c],u=t.element._zod.run({value:l,issues:[]},n);if(u instanceof Promise)s.push(u.then(m=>az(m,o,c)));else if(az(u,o,c),a&&u.issues.length!==0&&un(u))break}return s.length?Promise.all(s).then(()=>o):o},Vv(e,EM)});function rf(e,t,r,o,n,i){let s=r in o,a=i==="optional";if(!(!s&&a&&n==="optional")){if(e.issues.length){if(n!==void 0&&a&&!s)return;t.issues.push(...$n(r,e.issues))}if(!s&&n===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(s||n==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var AM=[];function Sz(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),o=r.length?r:AM,n=o.length?[...t,...o]:t;for(let s of n)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Vb(e.shape);return{...e,allKeys:n,symbolKeys:o,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function kz(e,t,r,o,n,i,s){let a=[],c=n.keySet,l=n.catchall._zod,u=l.def.type,m=l.optin,d=l.optout,f=0;for(let p in t){if(s&&r.issues.length!==f){if(un(r,f))break;f=r.issues.length}if(c.has(p))continue;if(p==="__proto__"){u==="never"&&a.push(p);continue}if(u==="never"){a.push(p);continue}let h=l.run({value:t[p],issues:[]},o);h instanceof Promise?e.push(h.then(g=>rf(g,r,p,t,m,d))):rf(h,r,p,t,m,d)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var zz=G("$ZodObject",(e,t)=>{Ne.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),o=r?.get?r.get.raw:t.shape??{};if(o){let l=()=>{let u={...o};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=o,Object.defineProperty(t,"shape",{get:l})}let n=ua(()=>Sz(t));Ve(e,"propValues",l=>{let u=l.def.shape,m={};for(let d in u){let f=u[d]._zod;if(f.values){Object.prototype.hasOwnProperty.call(m,d)||Vt(m,d,new Set);for(let p of f.values)m[d].add(p);f.optin!==void 0&&m[d].add(void 0)}}return m});let i=Vi,s=t.catchall,a,c=Nt.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=n.value);let m=l.value;if(!i(m))return l.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],f=a.shape,p=u?.abortEarly,h=l.issues.length;for(let g of a.allKeys){if(p&&l.issues.length!==h){if(un(l,h))break;h=l.issues.length}if(g==="__proto__")continue;let b=f[g],y=b._zod.optin,w=b._zod.optout,v=b._zod.run({value:m[g],issues:[]},u);v instanceof Promise?d.push(v.then(S=>rf(S,l,g,m,y,w))):rf(v,l,g,m,y,w)}return s?kz(d,m,l,u,n.value,e,p===!0):d.length?Promise.all(d).then(()=>l):l}}),Hv=G("$ZodObjectJIT",(e,t)=>{zz.init(e,t);let r=e._zod.parse,o=ua(()=>Sz(t)),n=Nt.memoizer,i=f=>{let p=o.value,h=p.symbolKeys,g=new Bi(["payload","ctx"],{shape:f,inst:e,memo:n,syms:h}),b=S=>`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`,y=(S,_)=>`
9
+ let ${S}_ab = false;
10
+ for (let i = 0; i < ${S}.issues.length; i++) {
11
+ const iss = ${S}.issues[i];
12
+ iss.path = iss.path ? [${_}, ...iss.path] : [${_}];
13
+ payload.issues.push(iss);
14
+ if (iss.continue !== true) ${S}_ab = true;
15
+ }
16
+ if (${S}_ab && ctx && ctx.abortEarly) {
17
+ payload.value = newResult;
18
+ return payload;
19
+ }`;g.write("const input = payload.value;");let w=Object.create(null),v=0;for(let S of p.allKeys)w[S]=`key_${v++}`;g.write(n?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let S of p.allKeys){if(S==="__proto__")continue;let _=w[S],$=typeof S=="symbol"?`syms[${h.indexOf(S)}]`:ln(S),x=`${$} in input`,k=f[S],P=k?._zod?.optin,I=P!==void 0,E=k?._zod?.optout==="optional";if(g.write(`const ${_} = ${b($)};`),I&&E){let N=P==="optional"?`${_}_present`:`${_}.value !== undefined || ${_}_present`;g.write(`
20
+ const ${_}_present = ${x};
21
+ if (!${_}.issues.length || ${_}_present) {
22
+ if (${_}.issues.length) {${y(_,$)}
23
+ }
24
+
25
+ if (${N}) {
26
+ newResult[${$}] = ${_}.value;
27
+ }
28
+ }
29
+
30
+ `)}else I?(g.write(`
31
+ if (${_}.issues.length) {${y(_,$)}
32
+ }
33
+ `),P==="defaulted"?g.write(`newResult[${$}] = ${_}.value;`):g.write(`
34
+ if (${_}.value !== undefined || ${x}) {
35
+ newResult[${$}] = ${_}.value;
36
+ }
37
+ `)):g.write(`
38
+ const ${_}_present = ${x};
39
+ if (${_}.issues.length) {${y(_,$)}
40
+ }
41
+ if (!${_}_present && !${_}.issues.length) {
42
+ payload.issues.push({
43
+ code: "invalid_type",
44
+ expected: "nonoptional",
45
+ input: undefined,
46
+ path: [${$}]
47
+ });
48
+ if (ctx && ctx.abortEarly) {
49
+ payload.value = newResult;
50
+ return payload;
51
+ }
52
+ }
53
+
54
+ if (${_}_present) {
55
+ newResult[${$}] = ${_}.value;
56
+ }
57
+
58
+ `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},s,a=Vi,c=!Nt.jitless,u=c&&Lb.value,m=t.catchall,d;e._zod.parse=(f,p)=>{d??(d=o.value);let h=f.value;return a(h)?c&&u&&p?.async===!1&&p.jitless!==!0?(s||(s=i(t.shape)),f=s(f,p),m?kz([],h,f,p,d,e,p?.abortEarly===!0):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),f)}});function cz(e,t,r,o){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter(i=>!un(i));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>xn(s,o,wt())))}),t)}var Ll=G("$ZodUnion",(e,t)=>{Ne.init(e,t),Ve(e,"optin",o=>o.def.options.some(n=>n._zod.optin==="defaulted")?"defaulted":o.def.options.some(n=>n._zod.optin!==void 0)?"optional":void 0),Ve(e,"optout",o=>o.def.options.some(n=>n._zod.optout==="optional")?"optional":void 0),Ve(e,"values",o=>{if(o.def.options.every(n=>n._zod.values))return new Set(o.def.options.flatMap(n=>Array.from(n._zod.values)))}),Ve(e,"pattern",o=>{if(o.def.options.every(n=>n._zod.pattern)){let n=o.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${n.map(i=>no(i.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>cz(a,o,e,n)):cz(s,o,e,n)}});function lz(e,t,r,o){let n=[];for(let i=0;i<e.length;i++)e[i].issues.length===0&&n.push(i);return n.length===1?(t.value=e[n[0]].value,t):(n.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>xn(s,o,wt())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1,matches:n}),t)}var Bv=G("$ZodXor",(e,t)=>{Ll.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);c instanceof Promise?(s.push(c),i=!0):s.push(c)}return i?Promise.all(s).then(a=>lz(a,o,e,n)):lz(s,o,e,n)}});function Wv(e,t){let r=e._zod,o=r.bag.optionsMap;o||(o=Rz(r.def),r.bag.optionsMap=o);let n=o.get(t);if(n===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return n}function Rz(e){let t=new Map;for(let r of e.options){let o=r._zod.propValues?.[e.discriminator];if(!o||o.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let n of o)if(t.has(n)){if(n!==void 0)throw new Error(`Duplicate discriminator value "${String(n)}"`);t.set(n,null)}else t.set(n,r)}return t}var Jv=G("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ll.init(e,t);let r=e._zod.parse;Ve(e,"propValues",n=>{let i={},s=0;for(let a of n.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${n.def.options.indexOf(a)}"`);c[n.def.discriminator]?.has(void 0)&&s++;for(let[l,u]of Object.entries(c)){Object.prototype.hasOwnProperty.call(i,l)||Vt(i,l,new Set);for(let m of u)i[l].add(m)}}return!n.def.unionFallback&&s>1&&i[n.def.discriminator]?.delete(void 0),i}),t.options.forEach((n,i)=>{let s=ma(n._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});let o=ua(()=>Rz(t));e._zod.parse=(n,i)=>{let s=n.value;if(!Vi(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let a=s?.[t.discriminator],c=o.value.get(a);return c&&(a!==void 0||i.direction!=="backward")?c._zod.run(n,i):t.unionFallback||i.direction==="backward"?r(n,i):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()).filter(l=>o.value.get(l)!==null),input:s,path:[t.discriminator],inst:e}),n)}}),Gv=G("$ZodIntersection",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,i=t.left._zod.run({value:n,issues:[]},o),s=t.right._zod.run({value:n,issues:[]},o);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,l])=>uz(r,c,l)):uz(r,i,s)}});function wa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Wn(e)&&Wn(t)){let r=Object.keys(t),o=Object.keys(e).filter(i=>r.indexOf(i)!==-1),n={...e,...t};Object.prototype.hasOwnProperty.call(n,"__proto__")&&delete n.__proto__;for(let i of o){if(i==="__proto__")continue;let s=wa(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n[i]=s.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<e.length;o++){let n=e[o],i=t[o],s=wa(n,i);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function uz(e,t,r){let o=new Map,n,i=new Map,s=(l,u)=>{let m;if(l.code==="unrecognized_keys"&&!l.path?.length)n??(n=l),m=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);i.has(d)||i.set(d,l),m=[d]}else return!1;for(let d of m)o.has(d)||o.set(d,{}),o.get(d)[u]=!0;return!0};for(let l of t.issues)s(l,"l")||e.issues.push(l);for(let l of r.issues)s(l,"r")||e.issues.push(l);let a=[...o].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=n?a.filter(u=>n.keys.includes(u)):[];l.length&&e.issues.push({...n,keys:l});for(let u of a)!l.includes(u)&&i.has(u)&&e.issues.push(i.get(u))}let c=wa(t.value,r.value);if(!c.valid){if(un(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var yf=G("$ZodTuple",(e,t)=>{Ne.init(e,t);let r=t.items,o=Nt.memoizer;o?.attach(e),e._zod.parse=(n,i)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=o?o.alloc(e,n,[],i):[];let a=[],c=mz(r,"optin"),l=mz(r,"optout");if(!t.rest){if(s.length<c)return n.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),n;s.length>r.length&&n.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:s,inst:e,origin:"array"})}let u=new Array(r.length),m=t.rest?i?.abortEarly:void 0,d=!1;for(let f=0;f<r.length;f++){let p=r[f]._zod.run({value:s[f],issues:[]},i);p instanceof Promise?a.push(p.then(h=>{u[f]=h})):(u[f]=p,m&&!d&&p.issues.length&&(d=un(p)))}if(t.rest&&!d){let f=r.length-1,p=s.slice(r.length),h=n.issues.length;for(let g of p){if(m&&n.issues.length!==h){if(un(n,h))break;h=n.issues.length}f++;let b=t.rest._zod.run({value:g,issues:[]},i);b instanceof Promise?a.push(b.then(y=>dz(y,n,f))):dz(b,n,f)}}return a.length?Promise.all(a).then(()=>fz(u,n,r,s,l)):fz(u,n,r,s,l)}});function mz(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function dz(e,t,r){e.issues.length&&t.issues.push(...$n(r,e.issues)),t.value[r]=e.value}function fz(e,t,r,o,n){for(let i=0;i<r.length;i++){let s=e[i],a=i<o.length;if(!a&&i>=n&&r[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=n){t.value.length=i;break}t.issues.push(...$n(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=o.length&&(r[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}var Kv=G("$ZodRecord",(e,t)=>{Ne.init(e,t);let r=Nt.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let i=o.value;if(!Wn(i))return o.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),o;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){o.value=r?r.alloc(e,o,{},n):{};let c=new Set;for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){if(c.add(typeof u=="number"?u.toString():u),u==="__proto__")continue;let m=t.keyType._zod.run({value:u,issues:[]},n);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(m.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:m.issues.map(p=>xn(p,n,wt())),input:u,path:[u],inst:e});continue}let d=m.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:i[u],issues:[]},n);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&o.issues.push(...$n(u,p.issues)),o.value[d]=p.value})):(f.issues.length&&o.issues.push(...$n(u,f.issues)),o.value[d]=f.value)}let l;for(let u in i)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;o.value[u]=i[u]}else l=l??[],l.push(u);l&&l.length>0&&o.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l,continue:!0})}else{o.value=r?r.alloc(e,o,{},n):{};let c;for(let l of Reflect.ownKeys(i)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},n);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&ro.test(l)&&u.issues.length){let p=t.keyType._zod.run({value:Number(l),issues:[]},n);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(u=p)}if(u.issues.length){t.mode==="loose"?o.value[l]=i[l]:a?(c=c??[],c.push(l)):o.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>xn(p,n,wt())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:i[l],issues:[]},n);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&o.issues.push(...$n(l,p.issues)),o.value[d]=p.value})):(f.issues.length&&o.issues.push(...$n(l,f.issues)),o.value[d]=f.value)}c&&c.length>0&&o.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}return s.length?Promise.all(s).then(()=>o):o}}),Yv=G("$ZodMap",(e,t)=>{Ne.init(e,t);let r=Nt.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let i=o.value;if(!(i instanceof Map))return o.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),o;let s=[];o.value=r?r.alloc(e,o,new Map,n):new Map;let a=n?.abortEarly,c=o.issues.length;for(let[l,u]of i){if(a&&o.issues.length!==c){if(un(o,c))break;c=o.issues.length}let m=t.keyType._zod.run({value:l,issues:[]},n),d=t.valueType._zod.run({value:u,issues:[]},n);m instanceof Promise||d instanceof Promise?s.push(Promise.all([m,d]).then(([f,p])=>{pz(f,p,o,l,i,e,n)})):pz(m,d,o,l,i,e,n)}return s.length?Promise.all(s).then(()=>o):o},Vv(e,TM)});function pz(e,t,r,o,n,i,s){e.issues.length&&(wl.has(typeof o)?r.issues.push(...$n(o,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:i,issues:e.issues.map(a=>xn(a,s,wt()))})),t.issues.length&&(wl.has(typeof o)?r.issues.push(...$n(o,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:i,key:o,issues:t.issues.map(a=>xn(a,s,wt()))})),r.value.set(e.value,t.value)}var Xv=G("$ZodSet",(e,t)=>{Ne.init(e,t);let r=Nt.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let i=o.value;if(!(i instanceof Set))return o.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),o;let s=[];o.value=r?r.alloc(e,o,new Set,n):new Set;let a=n?.abortEarly,c=o.issues.length;for(let l of i){if(a&&o.issues.length!==c){if(un(o,c))break;c=o.issues.length}let u=t.valueType._zod.run({value:l,issues:[]},n);u instanceof Promise?s.push(u.then(m=>hz(m,o))):hz(u,o)}return s.length?Promise.all(s).then(()=>o):o},Vv(e,CM)});function hz(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Qv=G("$ZodEnum",(e,t)=>{Ne.init(e,t);let r=ca(t.entries),o=new Set(r);e._zod.values=o,Ve(e,"pattern",n=>{let i=ca(n.def.entries).filter(s=>wl.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>Jn(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,i)=>{let s=n.value;return o.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),e$=G("$ZodLiteral",(e,t)=>{Ne.init(e,t);let r=new Set(t.values);e._zod.values=r,Ve(e,"pattern",o=>{let n=o.def.values;return new RegExp(n.length?`^(${n.map(i=>typeof i=="string"?Jn(i):i?Jn(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,n)=>{let i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),t$=G("$ZodFile",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;return n instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),n$=G("$ZodTransform",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",Nt.memoizer?.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new qo(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then(s=>(r.value=s,r));if(n instanceof Promise)throw new _n;return r.value=n,r}});function gz(e,t){return e.value=t.issues.length?void 0:t.value,e}var bf=G("$ZodOptional",(e,t)=>{Ne.init(e,t),Ve(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Ve(e,"values",r=>{let o=r.def.innerType._zod.values;return o?new Set([...o,void 0]):void 0}),Ve(e,"pattern",r=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${no(o.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let n=t.innerType._zod.run({value:r.value,issues:[]},o);return n instanceof Promise?n.then(i=>gz(r,i)):gz(r,n)}return t.innerType._zod.run(r,o)}}),r$=G("$ZodExactOptional",(e,t)=>{bf.init(e,t),Ve(e,"values",r=>r.def.innerType._zod.values),Ve(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),o$=G("$ZodNullable",(e,t)=>{Ne.init(e,t),Ve(e,"optin",r=>r.def.innerType._zod.optin),Ve(e,"optout",r=>r.def.innerType._zod.optout),Ve(e,"pattern",r=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${no(o.source)}|null)$`):void 0}),Ve(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>r.value===null?r:t.innerType._zod.run(r,o)}),i$=G("$ZodDefault",(e,t)=>{Ne.init(e,t),e._zod.optin="defaulted",Ve(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>yz(i,t)):yz(n,t)}});function yz(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var s$=G("$ZodPrefault",(e,t)=>{Ne.init(e,t),e._zod.optin="defaulted",Ve(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>(o.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,o))}),a$=G("$ZodNonOptional",(e,t)=>{Ne.init(e,t),Ve(e,"values",r=>{let o=r.def.innerType._zod.values;return o?new Set([...o].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>bz(i,e)):bz(n,e)}});function bz(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var c$=G("$ZodSuccess",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new qo("ZodSuccess");let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>(r.value=i.issues.length===0,r)):(r.value=n.issues.length===0,r)}});function wz(e,t,r,o){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(n=>xn(n,o,wt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var l$=G("$ZodCatch",(e,t)=>{Ne.init(e,t),Ve(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Ve(e,"optout",r=>r.def.innerType._zod.optout),Ve(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run({value:r.value,issues:[]},o);return n instanceof Promise?n.then(i=>wz(r,i,t,o)):wz(r,n,t,o)}}),u$=G("$ZodNaN",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),wf=G("$ZodPipe",(e,t)=>{Ne.init(e,t),Ve(e,"values",r=>r.def.in._zod.values),Ve(e,"optin",r=>r.def.in._zod.optin),Ve(e,"optout",r=>r.def.out._zod.optout),Ve(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let i=t.out._zod.run(r,o);return i instanceof Promise?i.then(s=>ef(s,t.in,o)):ef(i,t.in,o)}let n=t.in._zod.run(r,o);return n instanceof Promise?n.then(i=>ef(i,t.out,o)):ef(n,t.out,o)}});function ef(e,t,r){return e.issues.some(o=>o.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Fl=G("$ZodCodec",(e,t)=>{Ne.init(e,t),Ve(e,"values",r=>r.def.in._zod.values),Ve(e,"optin",r=>r.def.in._zod.optin),Ve(e,"optout",r=>r.def.out._zod.optout),Ve(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,o)=>{if((o.direction||"forward")==="forward"){let i=t.in._zod.run(r,o);return i instanceof Promise?i.then(s=>tf(s,t,o)):tf(i,t,o)}else{let i=t.out._zod.run(r,o);return i instanceof Promise?i.then(s=>tf(s,t,o)):tf(i,t,o)}}});function tf(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let n=t.transform(e.value,e);return n instanceof Promise?n.then(i=>nf(e,i,t.out,r)):nf(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(i=>nf(e,i,t.in,r)):nf(e,n,t.in,r)}}function nf(e,t,r,o){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},o)}var m$=G("$ZodPreprocess",(e,t)=>{wf.init(e,t)}),d$=G("$ZodReadonly",(e,t)=>{Ne.init(e,t),Ve(e,"propValues",r=>r.def.innerType._zod.propValues),Ve(e,"values",r=>r.def.innerType._zod.values),Ve(e,"optin",r=>r.def.innerType?._zod?.optin),Ve(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(vz):vz(n)}});function vz(e){return e.memo||(e.value=Object.freeze(e.value)),e}function OM(e){let t=e._zod.def,r=t.pattern,o=!!t.format?.includes("int"),n,i;for(let a of t.checks??[]){let c=a._zod.def;c.pattern&&(r=c.pattern),o||(o=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;l!==void 0&&(n===void 0||l>n)&&(n=l),u!==void 0&&(i===void 0||u<i)&&(i=u)}if(r)return r.source;if(n!==void 0&&i!==void 0&&n>i)return"(?!)";if(n!==void 0||i!==void 0)return Rw({minimum:n,maximum:i}).source;let s=e._zod.pattern;return(o&&s===ro?Tl:s)?.source}function rv(e){let t=e._zod.def,r=e._zod.pattern?.source,o=t.innerType??e._zod.innerType;if(o){let n=o._zod.pattern?.source,i=rv(o);return r&&n&&i&&i!==n?r.replace(no(n),()=>no(i)):r}if(t.options){let n=t.options.map(rv);if(n.every(Boolean))return`^(${n.map(i=>no(i)).join("|")})$`}return OM(e)}var f$=G("$ZodTemplateLiteral",(e,t)=>{Ne.init(e,t);let r=[];for(let o of t.parts)if(typeof o=="object"&&o!==null){let n=rv(o);if(!n)throw new Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);r.push(no(n))}else if(o===null||Fb.has(typeof o))r.push(Jn(`${o}`));else throw new Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(o,n)=>typeof o.value!="string"?(o.issues.push({input:o.value,inst:e,expected:"string",code:"invalid_type"}),o):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(o.value)||o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o)}),p$=G("$ZodFunction",(e,t)=>(Ne.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...o){let n=e._def.input?Dd(e._def.input,o):o,i=Reflect.apply(r,this,n);return e._def.output?Dd(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...o){let n=e._def.input?await qd(e._def.input,o):o,i=await Reflect.apply(r,this,n);return e._def.output?await qd(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(r,o)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let o=e.constructor;return Array.isArray(r[0])?new o({type:"function",input:new yf({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new o({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let o=e.constructor;return new o({type:"function",input:e._def.input,output:r})},e)),h$=G("$ZodPromise",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>Promise.resolve(r.value).then(n=>t.innerType._zod.run({value:n,issues:[]},o))}),Vl=G("$ZodLazy",(e,t)=>{Ne.init(e,t),qb(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),Ve(e,"pattern",r=>r.innerType?._zod?.pattern),Ve(e,"propValues",r=>r.innerType?._zod?.propValues),Ve(e,"optin",r=>r.innerType?._zod?.optin??void 0),Ve(e,"optout",r=>r.innerType?._zod?.optout??void 0),e._zod.parse=(r,o)=>e._zod.innerType._zod.run(r,o)}),g$=G("$ZodCustom",(e,t)=>{lt.init(e,t),Ne.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=r=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then(i=>$z(i,r,o,e));$z(n,r,o,e)}});function $z(e,t,r,o){if(!e){let n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(n.params=o._zod.def.params),t.issues.push(fa(n))}}var _f=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},b$="~memo",Pz=[];function jz(e){return e!==null&&typeof e=="object"}function y$(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var Ez=new WeakMap,va=0,xf=1,Zl=2;function Hl(e,t,r){let o=Ez.get(e);if(o!==void 0)return o?Zl:va;if(t.has(e))return Zl;t.add(e);let n=va,i=u=>{if(n!==Zl&&u?._zod){let m=Hl(u,t,r);m>n&&(n=m)}},s=(u,m)=>{let d=va;for(let f of Reflect.ownKeys(u)){let p=Object.getOwnPropertyDescriptor(u,f);if(m&&!p.enumerable)continue;let h=p.get?xf:p.value?._zod?Hl(p.value,t,r):va;h>d&&(d=h)}return d},a=u=>{u>n&&(n=u)},c=e._zod.def,l=c.type;switch(l){case"object":{let u=ma(c);a(u?s(u,!0):xf),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let u of c.items)i(u);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let u of c.options)i(u);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let u=c._cachedInner??(r?e._zod.innerType:void 0);a(u?Hl(u,t,!1):xf);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let m=Object.getOwnPropertyDescriptor(c,u);if(!m||m.get)continue;let d=m.value;if(!(!d||typeof d!="object")){if(d._zod)i(d);else if(Array.isArray(d))for(let f of d)i(f)}}}return t.delete(e),NM(e,n)}function NM(e,t){return t!==xf&&Ez.set(e,t===Zl),t}function Sf(e){return Hl(e,new Set,!0)!==va}function MM(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var vf,$f=[],DM={alloc(e,t,r){let o=vf;if(!o)return r;vf=void 0;let n={value:r,issues:null};return o.set(t.value,n),$f.push(n),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,o=(n,i)=>{if(i.direction!=="backward"&&kf(i,n.value))throw new _f;return r(n,i)};e._zod.parse=o,e._zod.run===r&&(e._zod.run=o)})},attach(e){var t;let r,o=!1,n,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,l)=>{if(r===void 0){let b=Hl(e,new Set,!1);if(b===va)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,l);b===Zl||o?r=!0:o=!0}let u=c.value;if(!jz(u))return s(c,l);let m=l[b$];m||(m={buckets:new WeakMap,backEdges:void 0},l[b$]=m);let d;n===l?d=i:(d=MM(m,e),n=l,i=d);let f=d.get(u);if(f)return c.value=f.value,f.issues?f.issues.length&&c.issues.push(...y$(f.issues)):(c.memo=!0,m.backEdges??(m.backEdges=new WeakSet),m.backEdges.add(f.value)),c;vf=d;let p=$f.length,h=s(c,l);vf=void 0;let g=$f.length>p?$f.pop():void 0;return h instanceof Promise?h.then(b=>(g&&(g.issues=b.issues.length?y$(b.issues):Pz),b)):(g&&(g.issues=h.issues.length?y$(h.issues):Pz),h)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function Bl(){return DM}function kf(e,t){let r=e[b$]?.backEdges;return r!==void 0&&jz(t)&&r.has(t)}var Jl={};eo(Jl,{ar:()=>Tz,az:()=>Cz,be:()=>Oz,bg:()=>Nz,bn:()=>Mz,ca:()=>Dz,ckb:()=>qz,cs:()=>Uz,da:()=>Lz,de:()=>Fz,el:()=>Vz,en:()=>zf,eo:()=>Zz,es:()=>Hz,fa:()=>Bz,fi:()=>Wz,fr:()=>Jz,frCA:()=>Gz,gu:()=>Kz,he:()=>Yz,hi:()=>Xz,hr:()=>Qz,hu:()=>eR,hy:()=>nR,id:()=>rR,is:()=>oR,it:()=>iR,ja:()=>sR,ka:()=>aR,kh:()=>cR,km:()=>Rf,kn:()=>lR,ko:()=>uR,lt:()=>dR,mk:()=>fR,ms:()=>pR,ne:()=>hR,nl:()=>gR,nn:()=>yR,no:()=>bR,ota:()=>wR,pl:()=>$R,ps:()=>vR,pt:()=>xR,ptBR:()=>_R,ro:()=>SR,ru:()=>zR,sk:()=>RR,sl:()=>IR,sv:()=>PR,ta:()=>jR,tg:()=>ER,th:()=>TR,tk:()=>CR,tr:()=>AR,ua:()=>OR,uk:()=>If,ur:()=>NR,uz:()=>MR,vi:()=>DR,yo:()=>LR,zhCN:()=>qR,zhTW:()=>UR});var qM=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},map:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",mac:"\u0639\u0646\u0648\u0627\u0646 MAC",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",credit_card:"\u0631\u0642\u0645 \u0628\u0637\u0627\u0642\u0629 \u0627\u0644\u0627\u0626\u062A\u0645\u0627\u0646",currency_code:"\u0631\u0645\u0632 \u0627\u0644\u0639\u0645\u0644\u0629",iban:"IBAN",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${n.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${i}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`}case"invalid_value":return n.values.length===1?`\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 ${ie(n.values[0])}`:`\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: ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${i} ${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${i} ${n.minimum.toString()} ${s.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${n.prefix}"`:i.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${i.suffix}"`:i.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${i.includes}"`:i.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${i.pattern}`:`${r[i.format]??n.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${n.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${n.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${n.keys.length>1?"\u0629":""}: ${K(n.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function Tz(){return{localeError:qM()}}var UM=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"},map:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"kredit kart\u0131 n\xF6mr\u0259si",currency_code:"valyuta kodu",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${n.expected}, daxil olan ${a}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${i}, daxil olan ${a}`}case"invalid_value":return n.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${ie(n.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${i}${n.maximum.toString()} ${s.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${i}${n.minimum.toString()} ${s.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${i.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:i.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${i.suffix}" il\u0259 bitm\u0259lidir`:i.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${i.includes}" daxil olmal\u0131d\u0131r`:i.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${i.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[i.format]??n.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${n.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${n.keys.length>1?"lar":""}: ${K(n.keys,", ")}`;case"invalid_key":return`${n.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${n.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function Cz(){return{localeError:UM()}}function Az(e,t,r,o){let n=Math.abs(e),i=n%10,s=n%100;return s>=11&&s<=19?o:i===1?t:i>=2&&i<=4?r:o}var LM=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},map:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",mac:"MAC \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",credit_card:"\u043D\u0443\u043C\u0430\u0440 \u043A\u0440\u044D\u0434\u044B\u0442\u043D\u0430\u0439 \u043A\u0430\u0440\u0442\u044B",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u044B",iban:"IBAN",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},o={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${n.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${i}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`}case"invalid_value":return n.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${ie(n.values[0])}`:`\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 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s){let a=Number(n.maximum),c=Az(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${i}${n.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s){let a=Number(n.minimum),c=Az(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${i}${n.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${i.prefix}"`:i.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${i.suffix}"`:i.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${i.includes}"`:i.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${n.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${K(n.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${n.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function Oz(){return{localeError:LM()}}var FM=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},map:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",mac:"MAC \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043D\u0430 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u0430 \u043A\u0430\u0440\u0442\u0430",currency_code:"\u043A\u043E\u0434 \u043D\u0430 \u0432\u0430\u043B\u0443\u0442\u0430",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},o={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${i}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${ie(n.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${i}${n.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${i}${n.minimum.toString()} ${s.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${i.suffix}"`;if(i.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${i.includes}"`;if(i.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${i.pattern}`;let s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return i.format==="emoji"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),i.format==="datetime"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),i.format==="date"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),i.format==="time"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),i.format==="duration"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${s} ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${n.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u043E\u0432\u0435":""}: ${K(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function Nz(){return{localeError:FM()}}var VM=()=>{let e={string:{unit:"\u0985\u0995\u09CD\u09B7\u09B0",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},file:{unit:"\u09AC\u09BE\u0987\u099F",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},array:{unit:"\u0986\u0987\u099F\u09C7\u09AE",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},set:{unit:"\u0986\u0987\u099F\u09C7\u09AE",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},map:{unit:"\u098F\u09A8\u09CD\u099F\u09CD\u09B0\u09BF",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"}};function t(n){return e[n]??null}let r={regex:"\u0987\u09A8\u09AA\u09C1\u099F",email:"\u0987\u09AE\u09C7\u0987\u09B2 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",url:"URL",emoji:"\u0987\u09AE\u09CB\u099C\u09BF",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u09A4\u09BE\u09B0\u09BF\u0996 \u0993 \u09B8\u09AE\u09AF\u09BC",date:"ISO \u09A4\u09BE\u09B0\u09BF\u0996",time:"ISO \u09B8\u09AE\u09AF\u09BC",duration:"ISO \u09B8\u09AE\u09AF\u09BC\u0995\u09BE\u09B2",ipv4:"IPv4 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",ipv6:"IPv6 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",mac:"MAC \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",cidrv4:"IPv4 \u09B0\u09C7\u099E\u09CD\u099C",cidrv6:"IPv6 \u09B0\u09C7\u099E\u09CD\u099C",base64:"base64-\u098F\u09A8\u0995\u09CB\u09A1\u09C7\u09A1 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",base64url:"base64url-\u098F\u09A8\u0995\u09CB\u09A1\u09C7\u09A1 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",json_string:"JSON \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",e164:"E.164 \u09A8\u09AE\u09CD\u09AC\u09B0",credit_card:"\u0995\u09CD\u09B0\u09C7\u09A1\u09BF\u099F \u0995\u09BE\u09B0\u09CD\u09A1 \u09A8\u09AE\u09CD\u09AC\u09B0",currency_code:"\u09AE\u09C1\u09A6\u09CD\u09B0\u09BE \u0995\u09CB\u09A1",iban:"IBAN",jwt:"JWT",template_literal:"\u0987\u09A8\u09AA\u09C1\u099F"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return`\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F: \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${i}, \u09AA\u09CD\u09B0\u09BE\u09AA\u09CD\u09A4 ${a}`}case"invalid_value":return n.values.length===1?`\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F: \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${ie(n.values[0])}`:`\u0985\u09AC\u09C8\u09A7 \u0985\u09AA\u09B6\u09A8: ${K(n.values," | ")} \u098F\u09B0 \u09AE\u09A7\u09CD\u09AF\u09C7 \u098F\u0995\u099F\u09BF \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u0985\u09A8\u09C7\u0995 \u09AC\u09A1\u09BC: ${n.origin??"\u09AE\u09BE\u09A8"} ${i}${n.maximum.toString()} ${s.unit??"\u098F\u09B2\u09BF\u09AE\u09C7\u09A8\u09CD\u099F"} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09A8\u09C7\u0995 \u09AC\u09A1\u09BC: ${n.origin??"\u09AE\u09BE\u09A8"} ${i}${n.maximum.toString()} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0985\u09A8\u09C7\u0995 \u099B\u09CB\u099F: ${n.origin} ${i}${n.minimum.toString()} ${s.unit} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09A8\u09C7\u0995 \u099B\u09CB\u099F: ${n.origin} ${i}${n.minimum.toString()} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${i.prefix}" \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B6\u09C1\u09B0\u09C1 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:i.format==="ends_with"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${i.suffix}" \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B6\u09C7\u09B7 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:i.format==="includes"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${i.includes}" \u0985\u09A8\u09CD\u09A4\u09B0\u09CD\u09AD\u09C1\u0995\u09CD\u09A4 \u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7`:i.format==="regex"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: ${i.pattern} \u09AA\u09CD\u09AF\u09BE\u099F\u09BE\u09B0\u09CD\u09A8 \u09AE\u09BF\u09B2\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09AC\u09C8\u09A7 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0985\u09AC\u09C8\u09A7 \u09A8\u09AE\u09CD\u09AC\u09B0: ${n.divisor} \u098F\u09B0 \u0997\u09C1\u09A3\u09BF\u09A4\u0995 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`;case"unrecognized_keys":return`\u0985\u099A\u09C7\u09A8\u09BE \u0995\u09C0${n.keys.length>1?"\u0997\u09C1\u09B2\u09CB":""}: ${K(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u098F \u0985\u09AC\u09C8\u09A7 \u0995\u09C0`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0985\u09AC\u09C8\u09A7 \u09A1\u09BF\u09B8\u0995\u09CD\u09B0\u09BF\u09AE\u09BF\u09A8\u09C7\u099F\u09B0 \u09AE\u09BE\u09A8\u0964 \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${n.options.map(s=>`'${s}'`).join(" | ")}`:"\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F";case"invalid_element":return`${n.origin} \u098F \u0985\u09AC\u09C8\u09A7 \u09AE\u09BE\u09A8`;default:return"\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F"}}};function Mz(){return{localeError:VM()}}var ZM=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"},map:{unit:"elements",verb:"contenir"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",mac:"adre\xE7a MAC",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",credit_card:"n\xFAmero de targeta de cr\xE8dit",currency_code:"codi de moneda",iban:"IBAN",jwt:"JWT",template_literal:"entrada"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${n.expected}, s'ha rebut ${a}`:`Tipus inv\xE0lid: s'esperava ${i}, s'ha rebut ${a}`}case"invalid_value":return n.values.length===1?`Valor inv\xE0lid: s'esperava ${ie(n.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${K(n.values," o ")}`;case"too_big":{let i=n.inclusive?"com a m\xE0xim":"menys de",s=t(n.origin);return s?`Massa gran: s'esperava que ${n.origin??"el valor"} contingu\xE9s ${i} ${n.maximum.toString()} ${s.unit??"elements"}`:`Massa gran: s'esperava que ${n.origin??"el valor"} fos ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?"com a m\xEDnim":"m\xE9s de",s=t(n.origin);return s?`Massa petit: s'esperava que ${n.origin} contingu\xE9s ${i} ${n.minimum.toString()} ${s.unit}`:`Massa petit: s'esperava que ${n.origin} fos ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${i.prefix}"`:i.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${i.suffix}"`:i.format==="includes"?`Format inv\xE0lid: ha d'incloure "${i.includes}"`:i.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${i.pattern}`:`Format inv\xE0lid per a ${r[i.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${n.divisor}`;case"unrecognized_keys":return`Clau${n.keys.length>1?"s":""} no reconeguda${n.keys.length>1?"s":""}: ${K(n.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${n.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${n.origin}`;default:return"Entrada inv\xE0lida"}}};function Dz(){return{localeError:ZM()}}var HM=()=>{let e={string:{unit:"\u067E\u06CC\u062A",verb:"\u0628\u06CE\u062A"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u0628\u06CE\u062A"},array:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"},set:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"},map:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"}};function t(n){return e[n]??null}let r={regex:"regex",email:"\u0626\u06CC\u0645\u06D5\u06CC\u06B5",url:"\u0628\u06D5\u0633\u062A\u06D5\u0631 (URL)",emoji:"\u0626\u06CC\u0645\u06C6\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0695\u06CE\u06A9\u06D5\u0648\u062A \u0648 \u06A9\u0627\u062A",date:"\u0695\u06CE\u06A9\u06D5\u0648\u062A",time:"\u06A9\u0627\u062A",duration:"\u0645\u0627\u0648\u06D5",ipv4:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC IPv4",ipv6:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC IPv6",mac:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC MAC",cidrv4:"\u0645\u06D5\u0648\u062F\u0627\u06CC IPv4",cidrv6:"\u0645\u06D5\u0648\u062F\u0627\u06CC IPv6",base64:"\u062F\u06D5\u0642\u06CC base64",base64url:"\u062F\u06D5\u0642\u06CC base64url",json_string:"\u062F\u06D5\u0642\u06CC JSON",e164:"\u0698\u0645\u0627\u0631\u06D5\u06CC E.164",credit_card:"\u0698\u0645\u0627\u0631\u06D5\u06CC \u06A9\u0627\u0631\u062A\u06CC \u06A9\u0631\u06CE\u062F\u06CC\u062A",currency_code:"\u06A9\u06C6\u062F\u06CC \u062F\u0631\u0627\u0648",iban:"IBAN",jwt:"JWT",template_literal:"\u062A\u06CE\u06A9\u0631\u062F\u06D5"},o={nan:"NaN",string:"\u0646\u0648\u0648\u0633\u06CC\u0646",number:"\u0698\u0645\u0627\u0631\u06D5",boolean:"boolean",array:"array",object:"object",date:"\u0695\u06CE\u06A9\u06D5\u0648\u062A",integer:"\u0698\u0645\u0627\u0631\u06D5",float:"\u0698\u0645\u0627\u0631\u06D5",null:"null",undefined:"undefined",function:"function",symbol:"symbol",unknown:"unknown",promise:"promise",void:"void",never:"never",map:"map",set:"set"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s,c=["\u0627","\u0648","\u06C6","\u0648\u0648","\u06D5","\u06CC","\u06CE"].some(u=>a.endsWith(u))?"\u06CC\u06D5":"\u06D5",l=/^[a-zA-Z]+$/.test(a);return s==="null"||s==="undefined"?"\u062F\u0627\u0648\u0627\u06A9\u0631\u0627\u0648\u06D5":`\u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 ${i} \u0628\u06CE\u062A\u060C \u0628\u06D5\u06B5\u0627\u0645 ${a}${l?"":c}`}case"invalid_value":return n.values.length===1?`\u0628\u06D5\u0647\u0627\u06A9\u06D5 \u0646\u0627\u062F\u0631\u0648\u0648\u0633\u062A\u06D5: \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 ${ie(n.values[0])} \u0628\u06CE\u062A`:`\u0647\u06D5\u06B5\u0628\u0698\u0627\u0631\u062F\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 \u06CC\u06D5\u06A9\u06CE\u06A9 \u0628\u06CE\u062A \u0644\u06D5 ${K(n.values,"|")}`;case"too_big":{let i=t(n.origin);return i?`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u0632\u06C6\u0631\u06D5\u0648\u06D5 ${n.maximum.toString()} ${i.unit} ${i.verb}`:`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u0632\u06C6\u0631\u06D5\u0648\u06D5 ${n.maximum.toString()} \u0628\u06CE\u062A`}case"too_small":{let i=t(n.origin);return i?`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u06A9\u06D5\u0645\u06D5\u0648\u06D5 ${n.minimum.toString()} ${i.unit} ${i.verb}`:`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u06A9\u06D5\u0645\u06D5\u0648\u06D5 ${n.minimum.toString()} \u0628\u06CE\u062A`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u062F\u06D5\u0633\u062A\u067E\u06CE\u0628\u06A9\u0627\u062A \u0628\u06D5 "${i.prefix}"`:i.format==="ends_with"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u06A9\u06C6\u062A\u0627\u06CC\u06CC\u0628\u06CE\u062A \u0628\u06D5 "${i.suffix}"`:i.format==="includes"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 "${i.includes}" \u0644\u06D5\u062E\u06C6\u0628\u06AF\u0631\u06CE\u062A`:i.format==="regex"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0644\u06D5\u06AF\u06D5\u06B5 \u067E\u0627\u062A\u06CE\u0631\u0646\u06CC ${i.pattern} \u0628\u06AF\u0648\u0646\u062C\u06CE\u062A`:`\u0628\u06D5\u0647\u0627\u06CC ${r[i.format]??n.format} \u0646\u0627\u062F\u0631\u0648\u0633\u062A\u06D5`}case"not_multiple_of":return`\u0698\u0645\u0627\u0631\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u062F\u06D5\u0628\u06CE\u062A \u0686\u06D5\u0646\u062F \u0647\u06CE\u0646\u062F\u06D5 \u0628\u06CE\u062A \u0628\u06C6 ${n.divisor}`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u0644\u06CC \u0646\u06D5\u0646\u0627\u0633\u0631\u0627\u0648: ${K(n.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u0644\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A \u0644\u06D5 ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0628\u06D5\u0647\u0627\u06CC \u0646\u06D5\u0646\u0627\u0633\u0631\u0627\u0648 \u0647\u06D5\u06CC\u06D5. \u0628\u06D5\u0647\u0627\u06CC \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648: ${n.options.map(s=>`'${s}'`).join(" | ")}`:"\u06CC\u06D5\u06A9\u06AF\u0631\u062A\u0646\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A";case"invalid_element":return`${n.origin} \u0628\u06D5\u0647\u0627\u06A9\u06D5 \u0646\u0627\u062F\u0631\u0648\u0633\u062A\u06D5`;default:return"\u062A\u06CE\u06A9\u0631\u062F\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A"}}};function qz(){return{localeError:HM()}}var BM=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"},map:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(n){return e[n]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC 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",credit_card:"\u010D\xEDslo kreditn\xED karty",currency_code:"k\xF3d m\u011Bny",iban:"IBAN",jwt:"JWT",template_literal:"vstup"},o={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${n.expected}, obdr\u017Eeno ${a}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${i}, obdr\u017Eeno ${a}`}case"invalid_value":return n.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${ie(n.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${i}${n.maximum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${i}${n.minimum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${i.prefix}"`:i.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${i.suffix}"`:i.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${i.includes}"`:i.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${i.pattern}`:`Neplatn\xFD form\xE1t ${r[i.format]??n.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${n.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${K(n.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${n.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${n.origin}`;default:return"Neplatn\xFD vstup"}}};function Uz(){return{localeError:BM()}}var WM=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"},map:{unit:"elementer",verb:"indeholdt"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kreditkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Ugyldigt input: forventede instanceof ${n.expected}, fik ${a}`:`Ugyldigt input: forventede ${i}, fik ${a}`}case"invalid_value":return n.values.length===1?`Ugyldig v\xE6rdi: forventede ${ie(n.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=o[n.origin]??n.origin;return s?`For stor: forventede ${a??"value"} ${s.verb} ${i} ${n.maximum.toString()} ${s.unit??"elementer"}`:`For stor: forventede ${a??"value"} havde ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=o[n.origin]??n.origin;return s?`For lille: forventede ${a} ${s.verb} ${i} ${n.minimum.toString()} ${s.unit}`:`For lille: forventede ${a} havde ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Ugyldig streng: skal starte med "${i.prefix}"`:i.format==="ends_with"?`Ugyldig streng: skal ende med "${i.suffix}"`:i.format==="includes"?`Ugyldig streng: skal indeholde "${i.includes}"`:i.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${i.pattern}`:`Ugyldig ${r[i.format]??n.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${K(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${n.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${n.origin}`;default:return"Ugyldigt input"}}};function Lz(){return{localeError:WM()}}var JM=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"},map:{unit:"Elemente",verb:"zu haben"}};function t(n){return e[n]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",mac:"MAC-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",credit_card:"Kreditkartennummer",currency_code:"W\xE4hrungscode",iban:"IBAN",jwt:"JWT",template_literal:"Eingabe"},o={nan:"NaN",number:"Zahl",array:"Array"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${n.expected}, erhalten ${a}`:`Ung\xFCltige Eingabe: erwartet ${i}, erhalten ${a}`}case"invalid_value":return n.values.length===1?`Ung\xFCltige Eingabe: erwartet ${ie(n.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ${s.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ist`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ${s.unit} hat`:`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ist`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Ung\xFCltiger String: muss mit "${i.prefix}" beginnen`:i.format==="ends_with"?`Ung\xFCltiger String: muss mit "${i.suffix}" enden`:i.format==="includes"?`Ung\xFCltiger String: muss "${i.includes}" enthalten`:i.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${i.pattern} entsprechen`:`Ung\xFCltig: ${r[i.format]??n.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${n.divisor} sein`;case"unrecognized_keys":return`${n.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${K(n.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${n.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${n.origin}`;default:return"Ung\xFCltige Eingabe"}}};function Fz(){return{localeError:JM()}}var GM=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(n){return e[n]??null}let r={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",credit_card:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 \u03C0\u03B9\u03C3\u03C4\u03C9\u03C4\u03B9\u03BA\u03AE\u03C2 \u03BA\u03AC\u03C1\u03C4\u03B1\u03C2",currency_code:"\u03BA\u03C9\u03B4\u03B9\u03BA\u03CC\u03C2 \u03BD\u03BF\u03BC\u03AF\u03C3\u03BC\u03B1\u03C4\u03BF\u03C2",iban:"IBAN",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return typeof n.expected=="string"&&/^[A-Z]/.test(n.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${n.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`}case"invalid_value":return n.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${ie(n.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${i}${n.maximum.toString()} ${s.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${i}${n.minimum.toString()} ${s.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${i.prefix}"`:i.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${i.suffix}"`:i.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${i.includes}"`:i.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${i.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[i.format]??n.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${n.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${n.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${n.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${K(n.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${n.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${n.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function Vz(){return{localeError:GM()}}var KM=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};function n(i,s){return i==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):o[i]??i}return i=>{switch(i.code){case"invalid_type":{let s=n(i.expected),a=se(i.input),c=n(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${ie(i.values[0])}`:`Invalid option: expected one of ${K(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);return a?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${K(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(a=>`'${a}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function zf(){return{localeError:KM()}}var YM=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"},map:{unit:"elementojn",verb:"havi"}};function t(n){return e[n]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",mac:"MAC-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",credit_card:"kreditkarta numero",currency_code:"valuta kodo",iban:"IBAN",jwt:"JWT",template_literal:"enigo"},o={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${n.expected}, ricevi\u011Dis ${a}`:`Nevalida enigo: atendi\u011Dis ${i}, ricevi\u011Dis ${a}`}case"invalid_value":return n.values.length===1?`Nevalida enigo: atendi\u011Dis ${ie(n.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${i}${n.maximum.toString()} ${s.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Tro malgranda: atendi\u011Dis ke ${n.origin} havu ${i}${n.minimum.toString()} ${s.unit}`:`Tro malgranda: atendi\u011Dis ke ${n.origin} estu ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${i.prefix}"`:i.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${i.suffix}"`:i.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${i.includes}"`:i.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${i.pattern}`:`Nevalida ${r[i.format]??n.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${n.divisor}`;case"unrecognized_keys":return`Nekonata${n.keys.length>1?"j":""} \u015Dlosilo${n.keys.length>1?"j":""}: ${K(n.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${n.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${n.origin}`;default:return"Nevalida enigo"}}};function Zz(){return{localeError:YM()}}var XM=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",mac:"direcci\xF3n MAC",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",credit_card:"n\xFAmero de tarjeta de cr\xE9dito",currency_code:"c\xF3digo de moneda",iban:"IBAN",jwt:"JWT",template_literal:"entrada"},o={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${n.expected}, recibido ${a}`:`Entrada inv\xE1lida: se esperaba ${i}, recibido ${a}`}case"invalid_value":return n.values.length===1?`Entrada inv\xE1lida: se esperaba ${ie(n.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=o[n.origin]??n.origin;return s?`Demasiado grande: se esperaba que ${a??"valor"} tuviera ${i}${n.maximum.toString()} ${s.unit??"elementos"}`:`Demasiado grande: se esperaba que ${a??"valor"} fuera ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=o[n.origin]??n.origin;return s?`Demasiado peque\xF1o: se esperaba que ${a} tuviera ${i}${n.minimum.toString()} ${s.unit}`:`Demasiado peque\xF1o: se esperaba que ${a} fuera ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${i.prefix}"`:i.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${i.suffix}"`:i.format==="includes"?`Cadena inv\xE1lida: debe incluir "${i.includes}"`:i.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${i.pattern}`:`Inv\xE1lido ${r[i.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Llave${n.keys.length>1?"s":""} desconocida${n.keys.length>1?"s":""}: ${K(n.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${o[n.origin]??n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${o[n.origin]??n.origin}`;default:return"Entrada inv\xE1lida"}}};function Hz(){return{localeError:XM()}}var QM=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},map:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",mac:"MAC \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",credit_card:"\u0634\u0645\u0627\u0631\u0647 \u06A9\u0627\u0631\u062A \u0627\u0639\u062A\u0628\u0627\u0631\u06CC",currency_code:"\u06A9\u062F \u0627\u0631\u0632",iban:"IBAN",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},o={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${n.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${i} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return n.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${ie(n.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\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 ${K(n.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} ${s.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${i.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:i.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${i.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:i.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${i.includes}" \u0628\u0627\u0634\u062F`:i.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${i.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[i.format]??n.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${n.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${n.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${K(n.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${n.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${n.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function Bz(){return{localeError:QM()}}var eD=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},map:{unit:"alkiota",subject:"kuvauksen"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(n){return e[n]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",mac:"MAC-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",credit_card:"luottokortin numero",currency_code:"valuuttakoodi",iban:"IBAN",jwt:"JWT",template_literal:"templaattimerkkijono"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Virheellinen tyyppi: odotettiin instanceof ${n.expected}, oli ${a}`:`Virheellinen tyyppi: odotettiin ${i}, oli ${a}`}case"invalid_value":return n.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${ie(n.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Liian suuri: ${s.subject} t\xE4ytyy olla ${i}${n.maximum.toString()} ${s.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Liian pieni: ${s.subject} t\xE4ytyy olla ${i}${n.minimum.toString()} ${s.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${i.prefix}"`:i.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${i.suffix}"`:i.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${i.includes}"`:i.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${i.pattern}`:`Virheellinen ${r[i.format]??n.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${n.divisor} monikerta`;case"unrecognized_keys":return`${n.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${K(n.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function Wz(){return{localeError:eD()}}var tD=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"expression r\xE9guli\xE8re",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",mac:"adresse MAC",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne de caract\xE8res encod\xE9e en base64",base64url:"cha\xEEne de caract\xE8res encod\xE9e en base64url",json_string:"cha\xEEne de caract\xE8res JSON",e164:"num\xE9ro au format E.164",credit_card:"num\xE9ro de carte de cr\xE9dit",currency_code:"code de devise",iban:"IBAN",jwt:"JWT",template_literal:"entr\xE9e"},o={string:"cha\xEEne de caract\xE8res",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"record",map:"map",set:"ensemble",file:"fichier",nonoptional:"non optionnel",nan:"NaN",function:"fonction"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Entr\xE9e invalide : instance de ${n.expected} attendu, ${a} re\xE7u`:`Entr\xE9e invalide : ${i} attendu, ${a} re\xE7u`}case"invalid_value":return n.values.length===1?`Entr\xE9e invalide : ${ie(n.values[0])} attendu`:`Option invalide : une valeur parmi ${K(n.values,"|")} attendue`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Trop grand : ${o[n.origin]??"valeur"} doit ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${o[n.origin]??"valeur"} doit \xEAtre ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Trop petit : ${o[n.origin]??"valeur"} doit ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`:`Trop petit : ${o[n.origin]??"valeur"} doit \xEAtre ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Cha\xEEne de caract\xE8res invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Cha\xEEne de caract\xE8res invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Cha\xEEne de caract\xE8res invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Cha\xEEne de caract\xE8res invalide : doit correspondre au motif ${i.pattern}`:`${r[i.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${K(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};function Jz(){return{localeError:tD()}}var nD=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"},map:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",mac:"adresse MAC",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",credit_card:"num\xE9ro de carte de cr\xE9dit",currency_code:"code de devise",iban:"IBAN",jwt:"JWT",template_literal:"entr\xE9e"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Entr\xE9e invalide : attendu instanceof ${n.expected}, re\xE7u ${a}`:`Entr\xE9e invalide : attendu ${i}, re\xE7u ${a}`}case"invalid_value":return n.values.length===1?`Entr\xE9e invalide : attendu ${ie(n.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"\u2264":"<",s=t(n.origin);return s?`Trop grand : attendu que ${n.origin??"la valeur"} ait ${i}${n.maximum.toString()} ${s.unit}`:`Trop grand : attendu que ${n.origin??"la valeur"} soit ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?"\u2265":">",s=t(n.origin);return s?`Trop petit : attendu que ${n.origin} ait ${i}${n.minimum.toString()} ${s.unit}`:`Trop petit : attendu que ${n.origin} soit ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Cha\xEEne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${i.pattern}`:`${r[i.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${K(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};function Gz(){return{localeError:nD()}}var rD=()=>{let e={string:{unit:"\u0A85\u0A95\u0ACD\u0AB7\u0AB0",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},file:{unit:"\u0AAC\u0ABE\u0AAF\u0A9F",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},array:{unit:"\u0A86\u0A87\u0A9F\u0AAE",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},set:{unit:"\u0A86\u0A87\u0A9F\u0AAE",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},map:{unit:"\u0A8F\u0AA8\u0ACD\u0A9F\u0ACD\u0AB0\u0AC0",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"}};function t(n){return e[n]??null}let r={regex:"\u0A87\u0AA8\u0AAA\u0AC1\u0A9F",email:"\u0A88\u0AAE\u0AC7\u0A87\u0AB2 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",url:"URL",emoji:"\u0A87\u0AAE\u0ACB\u0A9C\u0AC0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0AA4\u0ABE\u0AB0\u0AC0\u0A96 \u0A85\u0AA8\u0AC7 \u0AB8\u0AAE\u0AAF",date:"ISO \u0AA4\u0ABE\u0AB0\u0AC0\u0A96",time:"ISO \u0AB8\u0AAE\u0AAF",duration:"ISO \u0A85\u0AB5\u0AA7\u0ABF",ipv4:"IPv4 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",ipv6:"IPv6 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",mac:"MAC \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",cidrv4:"IPv4 \u0AB6\u0ACD\u0AB0\u0AC7\u0AA3\u0AC0",cidrv6:"IPv6 \u0AB6\u0ACD\u0AB0\u0AC7\u0AA3\u0AC0",base64:"base64-\u0A8F\u0AA8\u0ACD\u0A95\u0ACB\u0AA1\u0AC7\u0AA1 \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",base64url:"base64url-\u0A8F\u0AA8\u0ACD\u0A95\u0ACB\u0AA1\u0AC7\u0AA1 \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",json_string:"JSON \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",e164:"E.164 \u0AA8\u0A82\u0AAC\u0AB0",credit_card:"\u0A95\u0ACD\u0AB0\u0AC7\u0AA1\u0ABF\u0A9F \u0A95\u0ABE\u0AB0\u0ACD\u0AA1 \u0AA8\u0A82\u0AAC\u0AB0",currency_code:"\u0A9A\u0AB2\u0AA3 \u0A95\u0ACB\u0AA1",iban:"IBAN",jwt:"JWT",template_literal:"\u0A87\u0AA8\u0AAA\u0AC1\u0A9F"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F: \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${i}, \u0AAA\u0ACD\u0AB0\u0ABE\u0AAA\u0ACD\u0AA4 ${a}`}case"invalid_value":return n.values.length===1?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F: \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${ie(n.values[0])}`:`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB5\u0ABF\u0A95\u0AB2\u0ACD\u0AAA: ${K(n.values," | ")} \u0AAE\u0ABE\u0AA7\u0ACD\u0AAF\u0AAE\u0AA5\u0AC0 \u0A8F\u0A95 \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u0A96\u0AC2\u0AAC \u0AAE\u0ACB\u0A9F\u0AC1\u0A82: ${n.origin??"\u0AAE\u0AC2\u0AB2\u0ACD\u0AAF"} ${i}${n.maximum.toString()} ${s.unit??"\u0A8F\u0AB2\u0ABF\u0AAE\u0AC7\u0AA8\u0ACD\u0A9F"} \u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A96\u0AC2\u0AAC \u0AAE\u0ACB\u0A9F\u0AC1\u0A82: ${n.origin??"\u0AAE\u0AC2\u0AB2\u0ACD\u0AAF"} ${i}${n.maximum.toString()} \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0A96\u0AC2\u0AAC \u0AA8\u0ABE\u0AA8\u0AC1\u0A82: ${n.origin} ${i}${n.minimum.toString()} ${s.unit} \u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A96\u0AC2\u0AAC \u0AA8\u0ABE\u0AA8\u0AC1\u0A82: ${n.origin} ${i}${n.minimum.toString()} \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${i.prefix}" \u0AA5\u0AC0 \u0AB6\u0AB0\u0AC2 \u0AA5\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:i.format==="ends_with"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${i.suffix}" \u0AAA\u0AB0 \u0AB8\u0AAE\u0ABE\u0AAA\u0ACD\u0AA4 \u0AA5\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:i.format==="includes"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${i.includes}" \u0AB6\u0ABE\u0AAE\u0AC7\u0AB2 \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:i.format==="regex"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: \u0AAA\u0AC7\u0A9F\u0AB0\u0ACD\u0AA8 ${i.pattern} \u0AB8\u0ABE\u0AA5\u0AC7 \u0AAE\u0AC7\u0AB3 \u0A96\u0ABE\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AA8\u0A82\u0AAC\u0AB0: ${n.divisor} \u0AA8\u0ACB \u0A97\u0AC1\u0AA3\u0ABE\u0A82\u0A95 \u0AB9\u0ACB\u0AB5\u0ACB \u0A9C\u0ACB\u0A88\u0A8F`;case"unrecognized_keys":return`\u0A93\u0AB3\u0A96\u0AC0 \u0AB6\u0A95\u0ABE\u0AA4\u0ABE \u0AA8\u0AB9\u0AC0\u0A82 \u0AA4\u0AC7 \u0A95\u0AC0${n.keys.length>1?"\u0A93":""}: ${K(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u0AAE\u0ABE\u0A82 \u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A95\u0AC0`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AA1\u0ABF\u0AB8\u0ACD\u0A95\u0ACD\u0AB0\u0ABF\u0AAE\u0ABF\u0AA8\u0AC7\u0A9F\u0AB0 \u0AAE\u0AC2\u0AB2\u0ACD\u0AAF. \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${n.options.map(s=>`'${s}'`).join(" | ")}`:"\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F";case"invalid_element":return`${n.origin} \u0AAE\u0ABE\u0A82 \u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AAE\u0AC2\u0AB2\u0ACD\u0AAF`;default:return"\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F"}}};function Kz(){return{localeError:rD()}}var oD=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=l=>l?e[l]:void 0,o=l=>{let u=r(l);return u?u.label:l??e.unknown.label},n=l=>`\u05D4${o(l)}`,i=l=>(r(l)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",s=l=>l?t[l]??null:null,a={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},uuidv4:{label:"UUIDv4",gender:"m"},uuidv6:{label:"UUIDv6",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},mac:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA MAC",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},credit_card:{label:"\u05DE\u05E1\u05E4\u05E8 \u05DB\u05E8\u05D8\u05D9\u05E1 \u05D0\u05E9\u05E8\u05D0\u05D9",gender:"m"},currency_code:{label:"\u05E7\u05D5\u05D3 \u05DE\u05D8\u05D1\u05E2",gender:"m"},iban:{label:"IBAN",gender:"m"},jwt:{label:"JWT",gender:"m"},template_literal:{label:"\u05E7\u05DC\u05D8",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return l=>{switch(l.code){case"invalid_type":{let u=l.expected,m=c[u??""]??o(u),d=se(l.input),f=c[d]??e[d]?.label??d;return/^[A-Z]/.test(l.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${l.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${m}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`}case"invalid_value":{if(l.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${ie(l.values[0])}`;let u=l.values.map(f=>ie(f));if(l.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u[0]} \u05D0\u05D5 ${u[1]}`;let m=u[u.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u.slice(0,-1).join(", ")} \u05D0\u05D5 ${m}`}case"too_big":{let u=s(l.origin),m=n(l.origin??"value");if(l.origin==="string")return`${u?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${m} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.maximum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(l.origin==="number"){let p=l.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${l.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${m} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${p}`}if(l.origin==="array"||l.origin==="set"){let p=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=l.inclusive?`${l.maximum} ${u?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${l.maximum} ${u?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${m} ${p} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let d=l.inclusive?"<=":"<",f=i(l.origin??"value");return u?.unit?`${u.longLabel} \u05DE\u05D3\u05D9: ${m} ${f} ${d}${l.maximum.toString()} ${u.unit}`:`${u?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${m} ${f} ${d}${l.maximum.toString()}`}case"too_small":{let u=s(l.origin),m=n(l.origin??"value");if(l.origin==="string")return`${u?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${m} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.minimum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(l.origin==="number"){let p=l.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${l.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${m} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${p}`}if(l.origin==="array"||l.origin==="set"){let p=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(l.minimum===1&&l.inclusive){let g=(l.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${m} ${p} \u05DC\u05D4\u05DB\u05D9\u05DC ${g}`}let h=l.inclusive?`${l.minimum} ${u?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${l.minimum} ${u?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${m} ${p} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let d=l.inclusive?">=":">",f=i(l.origin??"value");return u?.unit?`${u.shortLabel} \u05DE\u05D3\u05D9: ${m} ${f} ${d}${l.minimum.toString()} ${u.unit}`:`${u?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${m} ${f} ${d}${l.minimum.toString()}`}case"invalid_format":{let u=l;if(u.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${u.prefix}"`;if(u.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${u.suffix}"`;if(u.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${u.includes}"`;if(u.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${u.pattern}`;let m=a[u.format],d=m?.label??u.format,p=(m?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${d} \u05DC\u05D0 ${p}`}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 ${l.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${l.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${l.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${K(l.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${n(l.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function Yz(){return{localeError:oD()}}var iD=()=>{let e={string:{unit:"\u0905\u0915\u094D\u0937\u0930",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},file:{unit:"\u092C\u093E\u0907\u091F\u094D\u0938",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},array:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},set:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},map:{unit:"\u092A\u094D\u0930\u0935\u093F\u0937\u094D\u091F\u093F\u092F\u093E\u0901",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"}};function t(n){return e[n]??null}let r={regex:"\u0907\u0928\u092A\u0941\u091F",email:"\u0908\u092E\u0947\u0932 \u092A\u0924\u093E",url:"URL",emoji:"\u0907\u092E\u094B\u091C\u0940",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0924\u093F\u0925\u093F \u0914\u0930 \u0938\u092E\u092F",date:"ISO \u0924\u093F\u0925\u093F",time:"ISO \u0938\u092E\u092F",duration:"ISO \u0905\u0935\u0927\u093F",ipv4:"IPv4 \u092A\u0924\u093E",ipv6:"IPv6 \u092A\u0924\u093E",mac:"MAC \u092A\u0924\u093E",cidrv4:"IPv4 \u0936\u094D\u0930\u0947\u0923\u0940",cidrv6:"IPv6 \u0936\u094D\u0930\u0947\u0923\u0940",base64:"Base64-\u090F\u0928\u094D\u0915\u094B\u0921\u0947\u0921 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",base64url:"Base64URL-\u090F\u0928\u094D\u0915\u094B\u0921\u0947\u0921 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",json_string:"JSON \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",e164:"E.164 \u0938\u0902\u0916\u094D\u092F\u093E",credit_card:"\u0915\u094D\u0930\u0947\u0921\u093F\u091F \u0915\u093E\u0930\u094D\u0921 \u0938\u0902\u0916\u094D\u092F\u093E",currency_code:"\u092E\u0941\u0926\u094D\u0930\u093E \u0915\u094B\u0921",iban:"IBAN",jwt:"JWT",template_literal:"\u0907\u0928\u092A\u0941\u091F"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${i}, \u092A\u094D\u0930\u093E\u092A\u094D\u0924 ${a}`}case"invalid_value":return n.values.length===1?`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${ie(n.values[0])}`:`\u0905\u092E\u093E\u0928\u094D\u092F \u0935\u093F\u0915\u0932\u094D\u092A: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u092E\u093E\u0928\u094B\u0902 \u092E\u0947\u0902 \u0938\u0947 \u090F\u0915 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u092C\u0939\u0941\u0924 \u092C\u0921\u093C\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${n.origin??"\u092E\u093E\u0928"} \u092E\u0947\u0902 ${i}${n.maximum} ${s.unit} \u0939\u094B\u0902`:`\u092C\u0939\u0941\u0924 \u092C\u0921\u093C\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${n.origin??"\u092E\u093E\u0928"} ${i}${n.maximum} \u0939\u094B`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u092C\u0939\u0941\u0924 \u091B\u094B\u091F\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${n.origin} \u092E\u0947\u0902 ${i}${n.minimum} ${s.unit} \u0939\u094B\u0902`:`\u092C\u0939\u0941\u0924 \u091B\u094B\u091F\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${n.origin} ${i}${n.minimum} \u0939\u094B`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: "${i.prefix}" \u0938\u0947 \u0936\u0941\u0930\u0942 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:i.format==="ends_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: "${i.suffix}" \u092A\u0930 \u0938\u092E\u093E\u092A\u094D\u0924 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:i.format==="includes"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: \u0907\u0938\u092E\u0947\u0902 "${i.includes}" \u0936\u093E\u092E\u093F\u0932 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:i.format==="regex"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: \u092A\u0948\u091F\u0930\u094D\u0928 ${i.pattern} \u0938\u0947 \u092E\u0947\u0932 \u0916\u093E\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:`\u0905\u092E\u093E\u0928\u094D\u092F ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u0902\u0916\u094D\u092F\u093E: \u092F\u0939 ${n.divisor} \u0915\u093E \u0917\u0941\u0923\u091C \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`;case"unrecognized_keys":return`\u0905\u092A\u0930\u093F\u091A\u093F\u0924 \u0915\u0941\u0902\u091C\u0940${n.keys.length>1?"\u092F\u093E\u0901":""}: ${K(n.keys,", ")}`;case"invalid_key":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0915\u0941\u0902\u091C\u0940: ${n.origin} \u092E\u0947\u0902`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0905\u092E\u093E\u0928\u094D\u092F \u0921\u093F\u0938\u094D\u0915\u094D\u0930\u093F\u092E\u093F\u0928\u0947\u091F\u0930 \u092E\u093E\u0928: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${n.options.map(s=>`'${s}'`).join(" | ")}`:"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F";case"invalid_element":return`\u0905\u092E\u093E\u0928\u094D\u092F \u092E\u093E\u0928: ${n.origin} \u092E\u0947\u0902`;default:return"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F"}}};function Xz(){return{localeError:iD()}}var sD=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(n){return e[n]??null}let r={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",credit_card:"broj kreditne kartice",currency_code:"kod valute",iban:"IBAN",jwt:"JWT",template_literal:"unos"},o={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${n.expected}, a primljeno je ${a}`:`Neispravan unos: o\u010Dekuje se ${i}, a primljeno je ${a}`}case"invalid_value":return n.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${ie(n.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=o[n.origin]??n.origin;return s?`Preveliko: o\u010Dekivano da ${a??"vrijednost"} ima ${i}${n.maximum.toString()} ${s.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${a??"vrijednost"} bude ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=o[n.origin]??n.origin;return s?`Premalo: o\u010Dekivano da ${a} ima ${i}${n.minimum.toString()} ${s.unit}`:`Premalo: o\u010Dekivano da ${a} bude ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${i.prefix}"`:i.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${i.suffix}"`:i.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${i.includes}"`:i.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${i.pattern}`:`Neispravna ${r[i.format]??n.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${n.divisor}`;case"unrecognized_keys":return`Neprepoznat${n.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${K(n.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${o[n.origin]??n.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${o[n.origin]??n.origin}`;default:return"Neispravan unos"}}};function Qz(){return{localeError:sD()}}var aD=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"},map:{unit:"elem",verb:"legyen"}};function t(n){return e[n]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",mac:"MAC 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",credit_card:"hitelk\xE1rtyasz\xE1m",currency_code:"p\xE9nznemk\xF3d",iban:"IBAN",jwt:"JWT",template_literal:"bemenet"},o={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${n.expected}, a kapott \xE9rt\xE9k ${a}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${i}, a kapott \xE9rt\xE9k ${a}`}case"invalid_value":return n.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${ie(n.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`T\xFAl nagy: ${n.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${i}${n.maximum.toString()} ${s.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${n.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} m\xE9rete t\xFAl kicsi ${i}${n.minimum.toString()} ${s.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} t\xFAl kicsi ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\xC9rv\xE9nytelen string: "${i.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:i.format==="ends_with"?`\xC9rv\xE9nytelen string: "${i.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:i.format==="includes"?`\xC9rv\xE9nytelen string: "${i.includes}" \xE9rt\xE9ket kell tartalmaznia`:i.format==="regex"?`\xC9rv\xE9nytelen string: ${i.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[i.format]??n.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${n.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${n.keys.length>1?"s":""}: ${K(n.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${n.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${n.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function eR(){return{localeError:aD()}}function tR(e,t,r){return Math.abs(e)===1?t:r}function $a(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=e[e.length-1];return e+(t.includes(r)?"\u0576":"\u0568")}var cD=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},map:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(n){return e[n]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",mac:"MAC \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",credit_card:"\u056F\u0580\u0565\u0564\u056B\u057F \u0584\u0561\u0580\u057F\u056B \u0570\u0561\u0574\u0561\u0580",currency_code:"\u0561\u0580\u056A\u0578\u0582\u0575\u0569\u056B \u056F\u0578\u0564",iban:"IBAN",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},o={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${n.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${i}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`}case"invalid_value":return n.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${ie(n.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s){let a=Number(n.maximum),c=tR(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${$a(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${i}${n.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${$a(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s){let a=Number(n.minimum),c=tR(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${$a(n.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${i}${n.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${$a(n.origin)} \u056C\u056B\u0576\u056B ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${i.prefix}"-\u0578\u057E`:i.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${i.suffix}"-\u0578\u057E`:i.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${i.includes}"`:i.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${i.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[i.format]??n.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${n.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${n.keys.length>1?"\u0576\u0565\u0580":""}. ${K(n.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${$a(n.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${$a(n.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function nR(){return{localeError:cD()}}var lD=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"},map:{unit:"item",verb:"memiliki"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",mac:"alamat MAC",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",credit_card:"nomor kartu kredit",currency_code:"kode mata uang",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Input tidak valid: diharapkan instanceof ${n.expected}, diterima ${a}`:`Input tidak valid: diharapkan ${i}, diterima ${a}`}case"invalid_value":return n.values.length===1?`Input tidak valid: diharapkan ${ie(n.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Terlalu besar: diharapkan ${n.origin??"value"} memiliki ${i}${n.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: diharapkan ${n.origin??"value"} menjadi ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Terlalu kecil: diharapkan ${n.origin} memiliki ${i}${n.minimum.toString()} ${s.unit}`:`Terlalu kecil: diharapkan ${n.origin} menjadi ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`String tidak valid: harus dimulai dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak valid: harus berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak valid: harus menyertakan "${i.includes}"`:i.format==="regex"?`String tidak valid: harus sesuai pola ${i.pattern}`:`${r[i.format]??n.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${n.keys.length>1?"s":""}: ${K(n.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${n.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${n.origin}`;default:return"Input tidak valid"}}};function rR(){return{localeError:lD()}}var uD=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"},map:{unit:"hluti",verb:"a\xF0 hafa"}};function t(n){return e[n]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",credit_card:"kreditkortan\xFAmer",currency_code:"gjaldmi\xF0ilsk\xF3\xF0i",iban:"IBAN",jwt:"JWT",template_literal:"gildi"},o={nan:"NaN",number:"n\xFAmer",array:"fylki"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera instanceof ${n.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera ${i}`}case"invalid_value":return n.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${ie(n.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} hafi ${i}${n.maximum.toString()} ${s.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} s\xE9 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} hafi ${i}${n.minimum.toString()} ${s.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} s\xE9 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${i.prefix}"`:i.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${i.suffix}"`:i.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${i.includes}"`:i.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${i.pattern}`:`Rangt ${r[i.format]??n.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${n.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${n.keys.length>1?"ir lyklar":"ur lykill"}: ${K(n.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${n.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${n.origin}`;default:return"Rangt gildi"}}};function oR(){return{localeError:uD()}}var mD=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"},map:{unit:"elementi",verb:"avere"}};function t(n){return e[n]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",mac:"indirizzo MAC",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",credit_card:"numero di carta di credito",currency_code:"codice valuta",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"numero",array:"vettore"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Input non valido: atteso instanceof ${n.expected}, ricevuto ${a}`:`Input non valido: atteso ${i}, ricevuto ${a}`}case"invalid_value":return n.values.length===1?`Input non valido: atteso ${ie(n.values[0])}`:`Opzione non valida: atteso uno tra ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Troppo grande: ${n.origin??"valore"} deve avere ${i}${n.maximum.toString()} ${s.unit??"elementi"}`:`Troppo grande: ${n.origin??"valore"} deve essere ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Troppo piccolo: ${n.origin} deve avere ${i}${n.minimum.toString()} ${s.unit}`:`Troppo piccolo: ${n.origin} deve essere ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Stringa non valida: deve iniziare con "${i.prefix}"`:i.format==="ends_with"?`Stringa non valida: deve terminare con "${i.suffix}"`:i.format==="includes"?`Stringa non valida: deve includere "${i.includes}"`:i.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${i.pattern}`:`Input non valido: ${r[i.format]??n.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${n.divisor}`;case"unrecognized_keys":return`Chiav${n.keys.length>1?"i":"e"} non riconosciut${n.keys.length>1?"e":"a"}: ${K(n.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${n.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${n.origin}`;default:return"Input non valido"}}};function iR(){return{localeError:mD()}}var dD=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},map:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(n){return e[n]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",mac:"MAC\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",credit_card:"\u30AF\u30EC\u30B8\u30C3\u30C8\u30AB\u30FC\u30C9\u756A\u53F7",currency_code:"\u901A\u8CA8\u30B3\u30FC\u30C9",iban:"IBAN",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},o={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${n.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${i}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return n.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${ie(n.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${K(n.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let i=n.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",s=t(n.origin);return s?`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${s.unit??"\u8981\u7D20"}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let i=n.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",s=t(n.origin);return s?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${s.unit}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:i.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:i.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:i.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${i.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[i.format]??n.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${n.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${n.keys.length>1?"\u7FA4":""}: ${K(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function sR(){return{localeError:dD()}}var fD=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},map:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(n){return e[n]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",mac:"MAC \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",credit_card:"\u10E1\u10D0\u10D9\u10E0\u10D4\u10D3\u10D8\u10E2\u10DD \u10D1\u10D0\u10E0\u10D0\u10D7\u10D8\u10E1 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",currency_code:"\u10D5\u10D0\u10DA\u10E3\u10E2\u10D8\u10E1 \u10D9\u10DD\u10D3\u10D8",iban:"IBAN",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},o={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${n.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`}case"invalid_value":return n.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${ie(n.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${K(n.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} \u10D8\u10E7\u10DD\u10E1 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${i.prefix}"-\u10D8\u10D7`:i.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${i.suffix}"-\u10D8\u10D7`:i.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${i.includes}"-\u10E1`:i.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${i.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${n.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${n.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${K(n.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${n.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${n.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function aR(){return{localeError:fD()}}var pD=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},map:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(n){return e[n]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",mac:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 MAC",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",credit_card:"\u179B\u17C1\u1781\u1794\u17D0\u178E\u17D2\u178E\u17A5\u178E\u1791\u17B6\u1793",currency_code:"\u1780\u17BC\u178A\u179A\u17BC\u1794\u17B7\u1799\u1794\u17D0\u178E\u17D2\u178E",iban:"IBAN",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},o={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${n.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`}case"invalid_value":return n.values.length===1?`\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 ${ie(n.values[0])}`:`\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 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${i} ${n.maximum.toString()} ${s.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${i} ${n.minimum.toString()} ${s.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${i.prefix}"`:i.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${i.suffix}"`:i.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${i.includes}"`:i.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${i.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${n.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${K(n.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function Rf(){return{localeError:pD()}}function cR(){return Rf()}var hD=()=>{let e={string:{unit:"\u0C85\u0C95\u0CCD\u0CB7\u0CB0\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},file:{unit:"\u0CAC\u0CC8\u0C9F\u0CCD\u200C\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},array:{unit:"\u0CB5\u0CB8\u0CCD\u0CA4\u0CC1\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},set:{unit:"\u0CB5\u0CB8\u0CCD\u0CA4\u0CC1\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},map:{unit:"entries",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"}};function t(n){return e[n]??null}let r={regex:"\u0C87\u0CA8\u0CCD\u0CAA\u0CC1\u0C9F\u0CCD",email:"email \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",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 \u0CA6\u0CBF\u0CA8\u0CBE\u0C82\u0C95\u0CA6 \u0CB8\u0CAE\u0CAF",date:"ISO \u0CA6\u0CBF\u0CA8\u0CBE\u0C82\u0C95",time:"ISO \u0CB8\u0CAE\u0CAF",duration:"ISO \u0C85\u0CB5\u0CA7\u0CBF",ipv4:"IPv4 \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",ipv6:"IPv6 \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",mac:"MAC \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",cidrv4:"IPv4 \u0CB5\u0CCD\u0CAF\u0CBE\u0CAA\u0CCD\u0CA4\u0CBF\u0CAF",cidrv6:"IPv6 \u0CB5\u0CCD\u0CAF\u0CBE\u0CAA\u0CCD\u0CA4\u0CBF\u0CAF",base64:"base64-encoded\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",base64url:"base64url-encoded\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",json_string:"JSON\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",e164:"E.164 \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6",credit_card:"\u0C95\u0CCD\u0CB0\u0CC6\u0CA1\u0CBF\u0C9F\u0CCD \u0C95\u0CBE\u0CB0\u0CCD\u0CA1\u0CCD \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6",currency_code:"\u0C95\u0CB0\u0CC6\u0CA8\u0CCD\u0CB8\u0CBF \u0C95\u0CCB\u0CA1\u0CCD",iban:"IBAN",jwt:"JWT",template_literal:"\u0C87\u0CA8\u0CCD\u0CAA\u0CC1\u0C9F\u0CCD"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${i}, \u0CB8\u0CCD\u0CB5\u0CC0\u0C95\u0CB0\u0CBF\u0CB8\u0CBF\u0CA6\u0CA8\u0CC1 ${a}`}case"invalid_value":return n.values.length===1?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${ie(n.values[0])}`:`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C86\u0CAF\u0CCD\u0C95\u0CC6: \u0C87\u0CB5\u0CC1\u0C97\u0CB3\u0CB2\u0CCD\u0CB2\u0CBF \u0C92\u0C82\u0CA6\u0CA8\u0CCD\u0CA8\u0CC1 \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0CA6\u0CCA\u0CA1\u0CCD\u0CA1\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${n.origin??"value"} \u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1 ${i}${n.maximum.toString()} ${s.unit??"\u0C85\u0C82\u0CB6\u0C97\u0CB3\u0CC1"}`:`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0CA6\u0CCA\u0CA1\u0CCD\u0CA1\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${n.origin??"value"} \u0C8E\u0C82\u0CA6\u0CC1 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0C9A\u0CBF\u0C95\u0CCD\u0C95\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${n.origin} \u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1 ${i}${n.minimum.toString()} ${s.unit}`:`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0C9A\u0CBF\u0C95\u0CCD\u0C95\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${n.origin} \u0C8E\u0C82\u0CA6\u0CC1 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C87\u0CA6\u0CB0\u0CCA\u0C82\u0CA6\u0CBF\u0C97\u0CC6 \u0CAA\u0CCD\u0CB0\u0CBE\u0CB0\u0C82\u0CAD\u0CBF\u0CB8\u0CAC\u0CC7\u0C95\u0CC1 "${i.prefix}"`:i.format==="ends_with"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C87\u0CA6\u0CB0\u0CCA\u0C82\u0CA6\u0CBF\u0C97\u0CC6 \u0C95\u0CCA\u0CA8\u0CC6\u0C97\u0CCA\u0CB3\u0CCD\u0CB3\u0CAC\u0CC7\u0C95\u0CC1 "${i.suffix}"`:i.format==="includes"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C92\u0CB3\u0C97\u0CCA\u0C82\u0CA1\u0CBF\u0CB0\u0CAC\u0CC7\u0C95\u0CC1 "${i.includes}"`:i.format==="regex"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0CAE\u0CBE\u0CA6\u0CB0\u0CBF\u0C97\u0CC6 \u0CB9\u0CCA\u0C82\u0CA6\u0CBF\u0C95\u0CC6\u0CAF\u0CBE\u0C97\u0CAC\u0CC7\u0C95\u0CC1 ${i.pattern}`:`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6: \u0CAC\u0CB9\u0CC1\u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6\u0CAF\u0CBE\u0C97\u0CBF\u0CB0\u0CAC\u0CC7\u0C95\u0CC1 ${n.divisor}`;case"unrecognized_keys":return`\u0C97\u0CC1\u0CB0\u0CC1\u0CA4\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CA6 \u0C95\u0CC0 ${n.keys.length>1?"s":""}: ${K(n.keys,", ")}`;case"invalid_key":return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0C95\u0CC0 \u0C87\u0CA8\u0CCD ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CA4\u0CBE\u0CB0\u0CA4\u0CAE\u0CCD\u0CAF \u0CAE\u0CCC\u0CB2\u0CCD\u0CAF. \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${n.options.map(s=>`'${s}'`).join(" | ")}`:"\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD";case"invalid_element":return`\u0CB0\u0CB2\u0CCD\u0CB2\u0CBF \u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CAE\u0CCC\u0CB2\u0CCD\u0CAF ${n.origin}`;default:return"\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD"}}};function lR(){return{localeError:hD()}}var gD=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"},map:{unit:"\uAC1C",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",mac:"MAC \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",credit_card:"\uC2E0\uC6A9\uCE74\uB4DC \uBC88\uD638",currency_code:"\uD1B5\uD654 \uCF54\uB4DC",iban:"IBAN",jwt:"JWT",template_literal:"\uC785\uB825"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${n.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${i}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`}case"invalid_value":return n.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${ie(n.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${K(n.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let i=n.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",s=i==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(n.origin),c=a?.unit??"\uC694\uC18C";return a?`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()}${c} ${i}${s}`:`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()} ${i}${s}`}case"too_small":{let i=n.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",s=i==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(n.origin),c=a?.unit??"\uC694\uC18C";return a?`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()}${c} ${i}${s}`:`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()} ${i}${s}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:i.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:i.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:i.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${i.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[i.format]??n.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${n.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${K(n.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${n.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${n.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function uR(){return{localeError:gD()}}var Wl=e=>e.charAt(0).toUpperCase()+e.slice(1);function mR(e){let t=Math.abs(e),r=t%10,o=t%100;return o>=11&&o<=19||r===0?"many":r===1?"one":"few"}var yD=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(n,i,s,a){let c=e[n]??null;return c===null?c:{unit:c.unit[i],verb:c.verb[a][s?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",mac:"MAC adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",credit_card:"kredito kortel\u0117s numeris",currency_code:"valiutos kodas",iban:"IBAN",jwt:"JWT",template_literal:"\u012Fvestis"},o={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Gautas tipas ${a}, o tik\u0117tasi - instanceof ${n.expected}`:`Gautas tipas ${a}, o tik\u0117tasi - ${i}`}case"invalid_value":return n.values.length===1?`Privalo b\u016Bti ${ie(n.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${K(n.values,"|")} pasirinkim\u0173`;case"too_big":{let i=o[n.origin]??n.origin,s=t(n.origin,mR(Number(n.maximum)),n.inclusive??!1,"smaller");if(s?.verb)return`${Wl(i??n.origin??"reik\u0161m\u0117")} ${s.verb} ${n.maximum.toString()} ${s.unit??"element\u0173"}`;let a=n.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${Wl(i??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${n.maximum.toString()} ${s?.unit}`}case"too_small":{let i=o[n.origin]??n.origin,s=t(n.origin,mR(Number(n.minimum)),n.inclusive??!1,"bigger");if(s?.verb)return`${Wl(i??n.origin??"reik\u0161m\u0117")} ${s.verb} ${n.minimum.toString()} ${s.unit??"element\u0173"}`;let a=n.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${Wl(i??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${n.minimum.toString()} ${s?.unit}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${i.prefix}"`:i.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${i.suffix}"`:i.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${i.includes}"`:i.format==="regex"?`Eilut\u0117 privalo atitikti ${i.pattern}`:`Neteisingas ${r[i.format]??n.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${n.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${n.keys.length>1?"i":"as"} rakt${n.keys.length>1?"ai":"as"}: ${K(n.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let i=o[n.origin]??n.origin;return`${Wl(i??n.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function dR(){return{localeError:yD()}}var bD=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},map:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(n){return e[n]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",mac:"MAC \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",credit_card:"\u0431\u0440\u043E\u0458 \u043D\u0430 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u0430 \u043A\u0430\u0440\u0442\u0438\u0447\u043A\u0430",currency_code:"\u043A\u043E\u0434 \u043D\u0430 \u0432\u0430\u043B\u0443\u0442\u0430",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},o={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${n.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${ie(n.values[0])}`:`\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 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${i}${n.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0438\u043C\u0430 ${i}${n.minimum.toString()} ${s.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${i.prefix}"`:i.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${i.suffix}"`:i.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${i.includes}"`:i.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${i.pattern}`:`Invalid ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${K(n.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${n.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${n.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function fR(){return{localeError:bD()}}var wD=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"},map:{unit:"elemen",verb:"mempunyai"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",mac:"alamat MAC",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",credit_card:"nombor kad kredit",currency_code:"kod mata wang",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"nombor"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Input tidak sah: dijangka instanceof ${n.expected}, diterima ${a}`:`Input tidak sah: dijangka ${i}, diterima ${a}`}case"invalid_value":return n.values.length===1?`Input tidak sah: dijangka ${ie(n.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Terlalu besar: dijangka ${n.origin??"nilai"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: dijangka ${n.origin??"nilai"} adalah ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Terlalu kecil: dijangka ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`:`Terlalu kecil: dijangka ${n.origin} adalah ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`String tidak sah: mesti bermula dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak sah: mesti mengandungi "${i.includes}"`:i.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${i.pattern}`:`${r[i.format]??n.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${K(n.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${n.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${n.origin}`;default:return"Input tidak sah"}}};function pR(){return{localeError:wD()}}var vD=()=>{let e={string:{unit:"\u0905\u0915\u094D\u0937\u0930",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},file:{unit:"\u092C\u093E\u0907\u091F",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},array:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},set:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},map:{unit:"\u092A\u094D\u0930\u0935\u093F\u0937\u094D\u091F\u093F",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"}};function t(n){return e[n]??null}let r={regex:"\u0907\u0928\u092A\u0941\u091F",email:"\u0907\u092E\u0947\u0932 \u0920\u0947\u0917\u093E\u0928\u093E",url:"URL",emoji:"\u0907\u092E\u094B\u091C\u0940",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u092E\u093F\u0924\u093F \u0930 \u0938\u092E\u092F",date:"ISO \u092E\u093F\u0924\u093F",time:"ISO \u0938\u092E\u092F",duration:"ISO \u0905\u0935\u0927\u093F",ipv4:"IPv4 \u0920\u0947\u0917\u093E\u0928\u093E",ipv6:"IPv6 \u0920\u0947\u0917\u093E\u0928\u093E",mac:"MAC \u0920\u0947\u0917\u093E\u0928\u093E",cidrv4:"IPv4 \u0926\u093E\u092F\u0930\u093E",cidrv6:"IPv6 \u0926\u093E\u092F\u0930\u093E",base64:"base64-\u0907\u0928\u094D\u0915\u094B\u0921 \u0917\u0930\u093F\u090F\u0915\u094B \u0938\u094D\u091F\u094D\u0930\u093F\u0919",base64url:"base64url-\u0907\u0928\u094D\u0915\u094B\u0921 \u0917\u0930\u093F\u090F\u0915\u094B \u0938\u094D\u091F\u094D\u0930\u093F\u0919",json_string:"JSON \u0938\u094D\u091F\u094D\u0930\u093F\u0919",e164:"E.164 \u0928\u092E\u094D\u092C\u0930",credit_card:"\u0915\u094D\u0930\u0947\u0921\u093F\u091F \u0915\u093E\u0930\u094D\u0921 \u0928\u092E\u094D\u092C\u0930",currency_code:"\u092E\u0941\u0926\u094D\u0930\u093E \u0915\u094B\u0921",iban:"IBAN",jwt:"JWT",template_literal:"\u0907\u0928\u092A\u0941\u091F"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${i}, \u092A\u094D\u0930\u093E\u092A\u094D\u0924 ${a}`}case"invalid_value":return n.values.length===1?`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${ie(n.values[0])}`:`\u0905\u092E\u093E\u0928\u094D\u092F \u0935\u093F\u0915\u0932\u094D\u092A: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u092E\u093E\u0928\u0939\u0930\u0942 \u092E\u0927\u094D\u092F\u0947 \u090F\u0915 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u0927\u0947\u0930\u0948 \u0920\u0942\u0932\u094B: ${n.origin??"\u092E\u093E\u0928"} \u092E\u093E ${i}${n.maximum.toString()} ${s.unit} ${s.verb}`:`\u0927\u0947\u0930\u0948 \u0920\u0942\u0932\u094B: ${n.origin??"\u092E\u093E\u0928"} ${i}${n.maximum.toString()} \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0927\u0947\u0930\u0948 \u0938\u093E\u0928\u094B: ${n.origin} \u092E\u093E ${i}${n.minimum.toString()} ${s.unit} ${s.verb}`:`\u0927\u0947\u0930\u0948 \u0938\u093E\u0928\u094B: ${n.origin} ${i}${n.minimum.toString()} \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${i.prefix}" \u092C\u093E\u091F \u0938\u0941\u0930\u0941 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:i.format==="ends_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${i.suffix}" \u092E\u093E \u0938\u092E\u093E\u092A\u094D\u0924 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:i.format==="includes"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${i.includes}" \u0938\u092E\u093E\u0935\u0947\u0936 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:i.format==="regex"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: \u0922\u093E\u0901\u091A\u093E ${i.pattern} \u0938\u0901\u0917 \u092E\u0947\u0932 \u0916\u093E\u0928\u0941\u092A\u0930\u094D\u091B`:`\u0905\u092E\u093E\u0928\u094D\u092F ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u0902\u0916\u094D\u092F\u093E: ${n.divisor} \u0915\u094B \u0917\u0941\u0923\u091C \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`;case"unrecognized_keys":return`\u0905\u092A\u0930\u093F\u091A\u093F\u0924 \u0915\u0941\u091E\u094D\u091C\u0940${n.keys.length>1?"\u0939\u0930\u0942":""}: ${K(n.keys,", ")}`;case"invalid_key":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0915\u0941\u091E\u094D\u091C\u0940: ${n.origin} \u092E\u093E`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u0905\u092E\u093E\u0928\u094D\u092F \u0921\u093F\u0938\u094D\u0915\u094D\u0930\u093F\u092E\u093F\u0928\u0947\u091F\u0930 \u092E\u093E\u0928: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${n.options.map(s=>`'${s}'`).join(" | ")}`:"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F";case"invalid_element":return`\u0905\u092E\u093E\u0928\u094D\u092F \u092E\u093E\u0928: ${n.origin} \u092E\u093E`;default:return"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F"}}};function hR(){return{localeError:vD()}}var $D=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"},map:{unit:"elementen",verb:"heeft"}};function t(n){return e[n]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",mac:"MAC-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",credit_card:"creditcardnummer",currency_code:"valutacode",iban:"IBAN",jwt:"JWT",template_literal:"invoer"},o={nan:"NaN",number:"getal"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Ongeldige invoer: verwacht instanceof ${n.expected}, ontving ${a}`:`Ongeldige invoer: verwacht ${i}, ontving ${a}`}case"invalid_value":return n.values.length===1?`Ongeldige invoer: verwacht ${ie(n.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=n.origin==="date"?"laat":n.origin==="string"?"lang":"groot";return s?`Te ${a}: verwacht dat ${n.origin??"waarde"} ${i}${n.maximum.toString()} ${s.unit??"elementen"} ${s.verb}`:`Te ${a}: verwacht dat ${n.origin??"waarde"} ${i}${n.maximum.toString()} is`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=n.origin==="date"?"vroeg":n.origin==="string"?"kort":"klein";return s?`Te ${a}: verwacht dat ${n.origin} ${i}${n.minimum.toString()} ${s.unit} ${s.verb}`:`Te ${a}: verwacht dat ${n.origin} ${i}${n.minimum.toString()} is`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Ongeldige tekst: moet met "${i.prefix}" beginnen`:i.format==="ends_with"?`Ongeldige tekst: moet op "${i.suffix}" eindigen`:i.format==="includes"?`Ongeldige tekst: moet "${i.includes}" bevatten`:i.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${i.pattern}`:`Ongeldig: ${r[i.format]??n.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${n.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${n.keys.length>1?"s":""}: ${K(n.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${n.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${n.origin}`;default:return"Ongeldige invoer"}}};function gR(){return{localeError:$D()}}var xD=()=>{let e={string:{unit:"teikn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"element",verb:"\xE5 innehalde"},set:{unit:"element",verb:"\xE5 innehalde"},map:{unit:"element",verb:"\xE5 innehalde"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varigheit",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkoda streng",base64url:"base64url-enkoda streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kredittkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"tal",array:"liste"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Ugyldig input: forventa instanceof ${n.expected}, fekk ${a}`:`Ugyldig input: forventa ${i}, fekk ${a}`}case"invalid_value":return n.values.length===1?`Ugyldig verdi: forventa ${ie(n.values[0])}`:`Ugyldig val: forventa eitt av ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`For stor(t): forventa ${n.origin??"value"} til \xE5 ha ${i}${n.maximum.toString()} ${s.unit??"element"}`:`For stor(t): forventa ${n.origin??"value"} til \xE5 ha ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`For lite(n): forventa ${n.origin} til \xE5 ha ${i}${n.minimum.toString()} ${s.unit}`:`For lite(n): forventa ${n.origin} til \xE5 ha ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${i.prefix}"`:i.format==="ends_with"?`Ugyldig streng: m\xE5 slutte med "${i.suffix}"`:i.format==="includes"?`Ugyldig streng: m\xE5 innehalde "${i.includes}"`:i.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${i.pattern}`:`Ugyldig ${r[i.format]??n.format}`}case"not_multiple_of":return`Ugyldig tal: m\xE5 vere eit multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjende n\xF8klar":"Ukjend n\xF8kkel"}: ${K(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};function yR(){return{localeError:xD()}}var _D=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"},map:{unit:"elementer",verb:"\xE5 inneholde"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kredittkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"tall",array:"liste"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Ugyldig input: forventet instanceof ${n.expected}, fikk ${a}`:`Ugyldig input: forventet ${i}, fikk ${a}`}case"invalid_value":return n.values.length===1?`Ugyldig verdi: forventet ${ie(n.values[0])}`:`Ugyldig valg: forventet en av ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${i}${n.maximum.toString()} ${s.unit??"elementer"}`:`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`For lite(n): forventet ${n.origin} til \xE5 ha ${i}${n.minimum.toString()} ${s.unit}`:`For lite(n): forventet ${n.origin} til \xE5 ha ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${i.prefix}"`:i.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${i.suffix}"`:i.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${i.includes}"`:i.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${i.pattern}`:`Ugyldig ${r[i.format]??n.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${K(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};function bR(){return{localeError:_D()}}var SD=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"},map:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",mac:"MAC 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",credit_card:"i'tib\xE2r kart\u0131 numaras\u0131",currency_code:"para birimi kodu",iban:"IBAN",jwt:"JWT",template_literal:"giren"},o={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`F\xE2sit giren: umulan instanceof ${n.expected}, al\u0131nan ${a}`:`F\xE2sit giren: umulan ${i}, al\u0131nan ${a}`}case"invalid_value":return n.values.length===1?`F\xE2sit giren: umulan ${ie(n.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${i}${n.maximum.toString()} ${s.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${i}${n.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${i}${n.minimum.toString()} ${s.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${i}${n.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let i=n;return i.format==="starts_with"?`F\xE2sit metin: "${i.prefix}" ile ba\u015Flamal\u0131.`:i.format==="ends_with"?`F\xE2sit metin: "${i.suffix}" ile bitmeli.`:i.format==="includes"?`F\xE2sit metin: "${i.includes}" ihtiv\xE2 etmeli.`:i.format==="regex"?`F\xE2sit metin: ${i.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[i.format]??n.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${n.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${n.keys.length>1?"s":""}: ${K(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${n.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function wR(){return{localeError:SD()}}var kD=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},map:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",mac:"\u062F MAC \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",credit_card:"\u062F \u06A9\u0631\u06CC\u0689\u06CC\u067C \u06A9\u0627\u0631\u062A \u0634\u0645\u06CC\u0631\u0647",currency_code:"\u062F \u0627\u0633\u0639\u0627\u0631\u0648 \u06A9\u0648\u0689",iban:"IBAN",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},o={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${n.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${i} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return n.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${ie(n.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${K(n.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} \u0648\u064A`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} ${s.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} \u0648\u064A`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${i.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:i.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${i.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:i.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${i.includes}" \u0648\u0644\u0631\u064A`:i.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${i.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[i.format]??n.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${n.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${n.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${K(n.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${n.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${n.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function vR(){return{localeError:kD()}}var zD=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"},map:{unit:"element\xF3w",verb:"mie\u0107"}};function t(n){return e[n]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",mac:"adres MAC",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",credit_card:"numer karty kredytowej",currency_code:"kod waluty",iban:"IBAN",jwt:"JWT",template_literal:"wej\u015Bcie"},o={nan:"NaN",number:"liczba",array:"tablica"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${n.expected}, otrzymano ${a}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${i}, otrzymano ${a}`}case"invalid_value":return n.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${ie(n.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${i}${n.maximum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${i}${n.minimum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${i.prefix}"`:i.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${i.suffix}"`:i.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${i.includes}"`:i.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${i.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[i.format]??n.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${n.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${n.keys.length>1?"s":""}: ${K(n.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${n.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${n.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function $R(){return{localeError:zD()}}var RD=()=>{let e={string:{unit:"caracteres"},file:{unit:"bytes"},array:{unit:"elementos"},set:{unit:"elementos"},map:{unit:"entradas"}};function t(s){return e[s]??null}let r={regex:"a entrada",email:"o endere\xE7o de e-mail",url:"o URL",emoji:"o emoji",uuid:"o UUID",uuidv4:"o UUIDv4",uuidv6:"o UUIDv6",nanoid:"o nanoid",guid:"o GUID",cuid:"o cuid",cuid2:"o cuid2",ulid:"o ULID",xid:"o XID",ksuid:"o KSUID",datetime:"a data e hora ISO",date:"a data ISO",time:"a hora ISO",duration:"a dura\xE7\xE3o ISO",ipv4:"o endere\xE7o IPv4",ipv6:"o endere\xE7o IPv6",mac:"o endere\xE7o MAC",cidrv4:"o intervalo de endere\xE7os IPv4",cidrv6:"o intervalo de endere\xE7os IPv6",base64:"o texto codificado em base64",base64url:"o texto codificado em base64url",json_string:"o texto JSON",e164:"o n\xFAmero E.164",credit_card:"o n\xFAmero de cart\xE3o de cr\xE9dito",currency_code:"o c\xF3digo de moeda",iban:"o IBAN",jwt:"o JWT",template_literal:"a entrada"},o={masculine:{definite:"o",indefinite:"um"},feminine:{definite:"a",indefinite:"uma"}},n={string:{name:"texto",articles:o.masculine},number:{name:"n\xFAmero",articles:o.masculine},int:{name:"n\xFAmero inteiro",articles:o.masculine},boolean:{name:"valor booleano",articles:o.masculine},bigint:{name:"n\xFAmero bigint",articles:o.masculine},symbol:{name:"s\xEDmbolo",articles:o.masculine},undefined:{name:'valor "undefined"',articles:o.masculine},null:{name:'valor "nulo"',articles:o.masculine},never:{name:'valor "never"',articles:o.masculine},void:{name:'valor "void"',articles:o.masculine},date:{name:"data",articles:o.feminine},array:{name:"vetor",articles:o.masculine},object:{name:"objeto",articles:o.masculine},tuple:{name:"tuplo",articles:o.masculine},record:{name:"registo",articles:o.masculine},map:{name:"mapa",articles:o.masculine},set:{name:"conjunto",articles:o.masculine},file:{name:"ficheiro",articles:o.masculine},nonoptional:{name:"valor n\xE3o opcional",articles:o.masculine},nan:{name:'valor "NaN"',articles:o.masculine},function:{name:"fun\xE7\xE3o",articles:o.feminine}};function i(s,a){let c=n[s]??{name:`valor "${s}"`,articles:o.masculine};return`${c.articles[a]} ${c.name}`}return s=>{switch(s.code){case"invalid_type":{let a=i(s.expected,"indefinite"),c=se(s.input),l=i(c,"indefinite");return`Entrada inv\xE1lida: esperava ${a}, recebeu ${l}`}case"invalid_value":return s.values.length===1?`Entrada inv\xE1lida: esperava ${ie(s.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperava uma das seguintes op\xE7\xF5es: ${K(s.values,"|")}`;case"too_big":{let a=s.inclusive?"<=":"<",c=t(s.origin);return c?`Demasiado grande: esperava que ${i(s.origin,"definite")} tivesse ${a} ${s.maximum.toString()} ${c.unit??"elementos"}`:`Demasiado grande: esperava que ${i(s.origin,"definite")} fosse ${a} ${s.maximum.toString()}`}case"too_small":{let a=s.inclusive?">=":">",c=t(s.origin);return c?`Demasiado pequeno: esperava que ${i(s.origin,"definite")} tivesse ${a} ${s.minimum.toString()} ${c.unit??"elementos"}`:`Demasiado pequeno: esperava que ${i(s.origin,"definite")} fosse ${a} ${s.minimum.toString()}`}case"invalid_format":{let a=s;return a.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar por "${a.prefix}"`:a.format==="ends_with"?`Texto inv\xE1lido: deve terminar em "${a.suffix}"`:a.format==="includes"?`Texto inv\xE1lido: deve incluir "${a.includes}"`:a.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${a.pattern}`:`Formato d${r[a.format]??s.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${s.divisor}`;case"unrecognized_keys":{let a=s.keys.length>1?"s":"";return`Chave${a} inv\xE1lida${a}: ${K(s.keys,", ")}`}case"invalid_key":return`Entrada inv\xE1lida n${i(s.origin,"definite")}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Valor de discrimina\xE7\xE3o inv\xE1lido. Esperava ${s.options.map(c=>`'${c}'`).join(" | ")}`:"Entrada inv\xE1lida";case"invalid_element":return`Entrada inv\xE1lida n${i(s.origin,"definite")}`;default:return"Entrada inv\xE1lida"}}};function xR(){return{localeError:RD()}}var ID=()=>{let e={string:{unit:"caracteres"},file:{unit:"bytes"},array:{unit:"elementos"},set:{unit:"elementos"},map:{unit:"entradas"}};function t(s){return e[s]??null}let r={regex:"a entrada",email:"o endere\xE7o de e-mail",url:"o URL",emoji:"o emoji",uuid:"o UUID",uuidv4:"o UUIDv4",uuidv6:"o UUIDv6",nanoid:"o nanoid",guid:"o GUID",cuid:"o cuid",cuid2:"o cuid2",ulid:"o ULID",xid:"o XID",ksuid:"o KSUID",datetime:"a data e hora ISO",date:"a data ISO",time:"a hora ISO",duration:"a dura\xE7\xE3o ISO",ipv4:"o endere\xE7o IPv4",ipv6:"o endere\xE7o IPv6",mac:"o endere\xE7o MAC",cidrv4:"a faixa de endere\xE7os IPv4",cidrv6:"a faixa de endere\xE7os IPv6",base64:"o texto codificado em base64",base64url:"o texto codificado em base64url",json_string:"o texto JSON",e164:"o n\xFAmero E.164",credit_card:"o n\xFAmero de cart\xE3o de cr\xE9dito",currency_code:"o c\xF3digo de moeda",iban:"o IBAN",jwt:"o JWT",template_literal:"a entrada"},o={masculine:{definite:"o",indefinite:"um"},feminine:{definite:"a",indefinite:"uma"}},n={string:{name:"texto",articles:o.masculine},number:{name:"n\xFAmero",articles:o.masculine},int:{name:"n\xFAmero inteiro",articles:o.masculine},boolean:{name:"valor booleano",articles:o.masculine},bigint:{name:"n\xFAmero bigint",articles:o.masculine},symbol:{name:"s\xEDmbolo",articles:o.masculine},undefined:{name:'valor "undefined"',articles:o.masculine},null:{name:'valor "nulo"',articles:o.masculine},never:{name:'valor "never"',articles:o.masculine},void:{name:'valor "void"',articles:o.masculine},date:{name:"data",articles:o.feminine},array:{name:"vetor",articles:o.masculine},object:{name:"objeto",articles:o.masculine},tuple:{name:"tupla",articles:o.feminine},record:{name:"registro",articles:o.masculine},map:{name:"mapa",articles:o.masculine},set:{name:"conjunto",articles:o.masculine},file:{name:"arquivo",articles:o.masculine},nonoptional:{name:"valor n\xE3o opcional",articles:o.masculine},nan:{name:'valor "NaN"',articles:o.masculine},function:{name:"fun\xE7\xE3o",articles:o.feminine}};function i(s,a){let c=n[s]??{name:`valor "${s}"`,articles:o.masculine};return`${c.articles[a]} ${c.name}`}return s=>{switch(s.code){case"invalid_type":{let a=i(s.expected,"indefinite"),c=se(s.input),l=i(c,"indefinite");return`Entrada inv\xE1lida: esperava ${a}, recebeu ${l}`}case"invalid_value":return s.values.length===1?`Entrada inv\xE1lida: esperava ${ie(s.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperava uma das seguintes op\xE7\xF5es: ${K(s.values,"|")}`;case"too_big":{let a=s.inclusive?"<=":"<",c=t(s.origin);return c?`Grande demais: esperava que ${i(s.origin,"definite")} tivesse ${a} ${s.maximum.toString()} ${c.unit??"elementos"}`:`Grande demais: esperava que ${i(s.origin,"definite")} fosse ${a} ${s.maximum.toString()}`}case"too_small":{let a=s.inclusive?">=":">",c=t(s.origin);return c?`Pequeno demais: esperava que ${i(s.origin,"definite")} tivesse ${a} ${s.minimum.toString()} ${c.unit??"elementos"}`:`Pequeno demais: esperava que ${i(s.origin,"definite")} fosse ${a} ${s.minimum.toString()}`}case"invalid_format":{let a=s;return a.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${a.prefix}"`:a.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${a.suffix}"`:a.format==="includes"?`Texto inv\xE1lido: deve incluir "${a.includes}"`:a.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${a.pattern}`:`Formato d${r[a.format]??s.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${s.divisor}`;case"unrecognized_keys":{let a=s.keys.length>1?"s":"";return`Chave${a} inv\xE1lida${a}: ${K(s.keys,", ")}`}case"invalid_key":return`Entrada inv\xE1lida n${i(s.origin,"definite")}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Valor de discrimina\xE7\xE3o inv\xE1lido. Esperava ${s.options.map(c=>`'${c}'`).join(" | ")}`:"Entrada inv\xE1lida";case"invalid_element":return`Entrada inv\xE1lida n${i(s.origin,"definite")}`;default:return"Entrada inv\xE1lida"}}};function _R(){return{localeError:ID()}}var PD=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(n){return e[n]??null}let r={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",credit_card:"num\u0103r de card de credit",currency_code:"cod valutar",iban:"IBAN",jwt:"JWT",template_literal:"intrare"},o={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return`Intrare invalid\u0103: a\u0219teptat ${i}, primit ${a}`}case"invalid_value":return n.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${ie(n.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} s\u0103 fie ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Prea mic: a\u0219teptat ca ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`:`Prea mic: a\u0219teptat ca ${n.origin} s\u0103 fie ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${i.prefix}"`:i.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${i.suffix}"`:i.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${i.includes}"`:i.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${i.pattern}`:`Format invalid: ${r[i.format]??n.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${n.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${K(n.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${n.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${n.origin}`;default:return"Intrare invalid\u0103"}}};function SR(){return{localeError:PD()}}function kR(e,t,r,o){let n=Math.abs(e),i=n%10,s=n%100;return s>=11&&s<=19?o:i===1?t:i>=2&&i<=4?r:o}var jD=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},map:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",mac:"MAC \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",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u043E\u0439 \u043A\u0430\u0440\u0442\u044B",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u044B",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},o={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${i}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`}case"invalid_value":return n.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${ie(n.values[0])}`:`\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 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s){let a=Number(n.maximum),c=kR(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${i}${n.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s){let a=Number(n.minimum),c=kR(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${i}${n.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${i.prefix}"`:i.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${i.suffix}"`:i.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${i.includes}"`:i.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${n.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0438":""}: ${K(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function zR(){return{localeError:jD()}}var ED=()=>{let e={string:{unit:"znakov",verb:"ma\u0165"},file:{unit:"bajtov",verb:"ma\u0165"},array:{unit:"prvkov",verb:"ma\u0165"},set:{unit:"prvkov",verb:"ma\u0165"},map:{unit:"polo\u017Eiek",verb:"ma\u0165"}};function t(n){return e[n]??null}let r={regex:"regul\xE1rny 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:"d\xE1tum a \u010Das vo form\xE1te ISO",date:"d\xE1tum vo form\xE1te ISO",time:"\u010Das vo form\xE1te ISO",duration:"doba trvania ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"re\u0165azec zak\xF3dovan\xFD vo form\xE1te base64",base64url:"re\u0165azec zak\xF3dovan\xFD vo form\xE1te base64url",json_string:"re\u0165azec vo form\xE1te JSON",e164:"\u010D\xEDslo E.164",credit_card:"\u010D\xEDslo kreditnej karty",currency_code:"k\xF3d meny",iban:"IBAN",jwt:"JWT",template_literal:"vstup"},o={nan:"NaN",number:"\u010D\xEDslo",string:"re\u0165azec",function:"funkcia",array:"pole"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 instanceof ${n.expected}, obdr\u017Ean\xE9 ${a}`:`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 ${i}, obdr\u017Ean\xE9 ${a}`}case"invalid_value":return n.values.length===1?`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 ${ie(n.values[0])}`:`Neplatn\xFD vstup: o\u010Dak\xE1van\xE1 jedna z hodn\xF4t ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Hodnota je pr\xEDli\u0161 ve\u013Ek\xE1: ${n.origin??"hodnota"} mus\xED ma\u0165 ${i}${n.maximum.toString()} ${s.unit??"prvkov"}`:`Hodnota je pr\xEDli\u0161 ve\u013Ek\xE1: ${n.origin??"hodnota"} mus\xED by\u0165 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Hodnota je pr\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED ma\u0165 ${i}${n.minimum.toString()} ${s.unit??"prvkov"}`:`Hodnota je pr\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED by\u0165 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Neplatn\xFD re\u0165azec: mus\xED za\u010D\xEDna\u0165 na "${i.prefix}"`:i.format==="ends_with"?`Neplatn\xFD re\u0165azec: mus\xED kon\u010Di\u0165 na "${i.suffix}"`:i.format==="includes"?`Neplatn\xFD re\u0165azec: mus\xED obsahova\u0165 "${i.includes}"`:i.format==="regex"?`Neplatn\xFD re\u0165azec: mus\xED zodpoveda\u0165 vzoru ${i.pattern}`:`Neplatn\xFD form\xE1t ${r[i.format]??n.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED by\u0165 n\xE1sobkom ${n.divisor}`;case"unrecognized_keys":return`Nezn\xE1me kl\xFA\u010De: ${K(n.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xFA\u010D v ${n.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${n.origin}`;default:return"Neplatn\xFD vstup"}}};function RR(){return{localeError:ED()}}var TD=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"},map:{unit:"elementov",verb:"imeti"}};function t(n){return e[n]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",mac:"MAC naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",credit_card:"\u0161tevilka kreditne kartice",currency_code:"koda valute",iban:"IBAN",jwt:"JWT",template_literal:"vnos"},o={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${n.expected}, prejeto ${a}`:`Neveljaven vnos: pri\u010Dakovano ${i}, prejeto ${a}`}case"invalid_value":return n.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${ie(n.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} imelo ${i}${n.maximum.toString()} ${s.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Premajhno: pri\u010Dakovano, da bo ${n.origin} imelo ${i}${n.minimum.toString()} ${s.unit}`:`Premajhno: pri\u010Dakovano, da bo ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${i.prefix}"`:i.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${i.suffix}"`:i.format==="includes"?`Neveljaven niz: mora vsebovati "${i.includes}"`:i.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${i.pattern}`:`Neveljaven ${r[i.format]??n.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${n.divisor}`;case"unrecognized_keys":return`Neprepoznan${n.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${K(n.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${n.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${n.origin}`;default:return"Neveljaven vnos"}}};function IR(){return{localeError:TD()}}var CD=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"},map:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(n){return e[n]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-adress",ipv6:"IPv6-adress",mac:"MAC-adress",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",credit_card:"kreditkortsnummer",currency_code:"valutakod",iban:"IBAN",jwt:"JWT",template_literal:"mall-literal"},o={nan:"NaN",number:"antal",array:"lista"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${n.expected}, fick ${a}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${i}, fick ${a}`}case"invalid_value":return n.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${ie(n.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`F\xF6r stor(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${i}${n.maximum.toString()} ${s.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${n.origin??"v\xE4rdet"} att ha ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${i}${n.minimum.toString()} ${s.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${i.prefix}"`:i.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${i.suffix}"`:i.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${i.includes}"`:i.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${i.pattern}"`:`Ogiltig(t) ${r[i.format]??n.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${K(n.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${n.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${n.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function PR(){return{localeError:CD()}}var AD=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},map:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(n){return e[n]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",mac:"MAC \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",credit_card:"\u0B95\u0B9F\u0BA9\u0BCD \u0B85\u0B9F\u0BCD\u0B9F\u0BC8 \u0B8E\u0BA3\u0BCD",currency_code:"\u0BA8\u0BBE\u0BA3\u0BAF\u0B95\u0BCD \u0B95\u0BC1\u0BB1\u0BBF\u0BAF\u0BC0\u0B9F\u0BC1",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${n.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`}case"invalid_value":return n.values.length===1?`\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 ${ie(n.values[0])}`:`\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 ${K(n.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${i}${n.maximum.toString()} ${s.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${i}${n.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${i}${n.minimum.toString()} ${s.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${i}${n.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:i.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:i.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:i.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${i.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${n.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${n.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${K(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function jR(){return{localeError:AD()}}var OD=()=>{let e={string:{unit:"\u0430\u043B\u043E\u043C\u0430\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},file:{unit:"\u0431\u0430\u0439\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},array:{unit:"\u0443\u043D\u0441\u0443\u0440",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},set:{unit:"\u0443\u043D\u0441\u0443\u0440",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},map:{unit:"\u0441\u0430\u0431\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0443\u0440\u0443\u0434",email:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 email",url:"URL",emoji:"\u044D\u043C\u043E\u04B7\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0441\u0430\u043D\u0430\u0432\u0443 \u0432\u0430\u049B\u0442\u0438 ISO",date:"\u0441\u0430\u043D\u0430\u0438 ISO",time:"\u0432\u0430\u049B\u0442\u0438 ISO",duration:"\u0434\u0430\u0432\u043E\u043C\u043D\u043E\u043A\u0438\u0438 ISO",ipv4:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv4",ipv6:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv6",mac:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 MAC",cidrv4:"\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv4",cidrv6:"\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv6",base64:"\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64",base64url:"\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64url",json_string:"\u0441\u0430\u0442\u0440\u0438 JSON",e164:"\u0440\u0430\u049B\u0430\u043C\u0438 E.164",credit_card:"\u0440\u0430\u049B\u0430\u043C\u0438 \u043A\u043E\u0440\u0442\u0438 \u043A\u0440\u0435\u0434\u0438\u0442\u04E3",currency_code:"\u0440\u0430\u043C\u0437\u0438 \u0430\u0441\u044A\u043E\u0440",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0443\u0440\u0443\u0434"},o={nan:"NaN",number:"\u0440\u0430\u049B\u0430\u043C",string:"\u0441\u0430\u0442\u0440",array:"\u043C\u0430\u0441\u0441\u0438\u0432",object:"\u043E\u0431\u044A\u0435\u043A\u0442",date:"\u0441\u0430\u043D\u0430"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return`\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${i} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442, ${a} \u0433\u0438\u0440\u0438\u0444\u0442\u0430 \u0448\u0443\u0434`}case"invalid_value":return n.values.length===1?`\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${ie(n.values[0])} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`:`\u0418\u043D\u0442\u0438\u0445\u043E\u0431\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u044F\u043A\u0435 \u0430\u0437 ${K(n.values,"|")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${n.origin??"\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${i}${n.maximum.toString()} ${s.unit} ${s.verb}`:`\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${n.origin??"\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${i}${n.maximum.toString()} \u0431\u043E\u0448\u0430\u0434`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${n.origin} \u0431\u043E\u044F\u0434 ${i}${n.minimum.toString()} ${s.unit} ${s.verb}`:`\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${n.origin} \u0431\u043E\u044F\u0434 ${i}${n.minimum.toString()} \u0431\u043E\u0448\u0430\u0434`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${i.prefix}" \u043E\u0493\u043E\u0437 \u0448\u0430\u0432\u0430\u0434`:i.format==="ends_with"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${i.suffix}" \u0430\u043D\u04B7\u043E\u043C \u0451\u0431\u0430\u0434`:i.format==="includes"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 "${i.includes}"-\u0440\u043E \u0434\u0430\u0440 \u0431\u0430\u0440 \u0433\u0438\u0440\u0430\u0434`:i.format==="regex"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 \u043D\u0430\u043C\u0443\u043D\u0430\u0438 ${i.pattern} \u043C\u0443\u0432\u043E\u0444\u0438\u049B\u0430\u0442 \u043A\u0443\u043D\u0430\u0434`:`${r[i.format]??n.format}-\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442`}case"not_multiple_of":return`\u0420\u0430\u049B\u0430\u043C\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 ${n.divisor} \u0431\u0435 \u0431\u0430\u049B\u0438\u044F \u0442\u0430\u049B\u0441\u0438\u043C \u0448\u0430\u0432\u0430\u0434`;case"unrecognized_keys":return`\u041A\u0430\u043B\u0438\u0434${n.keys.length>1?"\u04B3\u043E\u0438":"\u0438"} \u043D\u043E\u043C\u0430\u044A\u043B\u0443\u043C: ${K(n.keys,", ")}`;case"invalid_key":return`\u041A\u0430\u043B\u0438\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442\u0438 \u0434\u0438\u0441\u043A\u0440\u0438\u043C\u0438\u043D\u0430\u0442\u043E\u0440: ${n.options.map(s=>`'${s}'`).join(" | ")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`:"\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442";case"invalid_element":return`\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${n.origin}`;default:return"\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442"}}};function ER(){return{localeError:OD()}}var ND=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},map:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(n){return e[n]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",mac:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 MAC",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)",credit_card:"\u0E2B\u0E21\u0E32\u0E22\u0E40\u0E25\u0E02\u0E1A\u0E31\u0E15\u0E23\u0E40\u0E04\u0E23\u0E14\u0E34\u0E15",currency_code:"\u0E23\u0E2B\u0E31\u0E2A\u0E2A\u0E01\u0E38\u0E25\u0E40\u0E07\u0E34\u0E19",iban:"IBAN",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},o={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${n.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${i} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`}case"invalid_value":return n.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${ie(n.values[0])}`:`\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 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",s=t(n.origin);return s?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.maximum.toString()} ${s.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",s=t(n.origin);return s?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.minimum.toString()} ${s.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${i.prefix}"`:i.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${i.suffix}"`:i.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${i.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:i.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${i.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${n.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${K(n.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function TR(){return{localeError:ND()}}var MD=()=>{let e={string:{unit:"simwol",verb:"bolmaly"},file:{unit:"ba\xFDt",verb:"bolmaly"},array:{unit:"elementler",verb:"bolmaly"},set:{unit:"elementler",verb:"bolmaly"},map:{unit:"elementler",verb:"bolmaly"}};function t(n){return e[n]??null}let r={regex:"giri\u015F",email:"e-po\xE7ta salgysy",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 sene we wagt",date:"ISO sene",time:"ISO wagt",duration:"ISO wagt aralygy",ipv4:"IPv4 salgysy",ipv6:"IPv6 salgysy",mac:"MAC salgysy",cidrv4:"IPv4 aralygy",cidrv6:"IPv6 aralygy",base64:"base64 bilen \u015Fifrlenen setir",base64url:"base64url bilen \u015Fifrlenen setir",json_string:"JSON setiri",e164:"E.164 nomeri",credit_card:"kredit kartyny\u0148 nomeri",currency_code:"wal\xFDuta kody",iban:"IBAN",jwt:"JWT",template_literal:"\u015Fablon"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return`N\xE4dogry baha: gara\u015Fylan ${i} \xFDerine ${a} alyndy`}case"invalid_value":return n.values.length===1?`N\xE4dogry baha: ${ie(n.values[0])} bolmaly`:`N\xE4dogry sa\xFDlaw: a\u015Fakdakylardan biri bolmaly: ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Has uly: gara\u015Fyl\xFDan ${n.origin??"baha"} ${i} ${n.maximum.toString()} ${s.unit??"element"}`:`Has uly: gara\u015Fyl\xFDan ${n.origin??"baha"} ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Has ki\xE7i: gara\u015Fyl\xFDan ${n.origin} ${i} ${n.minimum.toString()} ${s.unit}`:`Has ki\xE7i: gara\u015Fyl\xFDan ${n.origin} ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`N\xE4dogry setir: "${i.prefix}" bilen ba\u015Flamaly`:i.format==="ends_with"?`N\xE4dogry setir: "${i.suffix}" bilen gutarmaly`:i.format==="includes"?`N\xE4dogry setir: "${i.includes}" saklamaly`:i.format==="regex"?`N\xE4dogry setir: ${i.pattern} nusga la\xFDyk bolmaly`:`N\xE4dogry ${r[i.format]??n.format}`}case"not_multiple_of":return`N\xE4dogry san: ${n.divisor} bilen galyndysyz b\xF6l\xFCnmeli`;case"unrecognized_keys":return`Tanalma\xFDan a\xE7ar${n.keys.length>1?"lar":""}: ${K(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7inde n\xE4dogry a\xE7ar`;case"invalid_union":return"N\xE4dogry baha";case"invalid_element":return`${n.origin} i\xE7inde n\xE4dogry baha`;default:return"N\xE4dogry baha"}}};function CR(){return{localeError:MD()}}var DD=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},map:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(n){return e[n]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",mac:"MAC 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",credit_card:"kredi kart\u0131 numaras\u0131",currency_code:"para birimi kodu",iban:"IBAN",jwt:"JWT",template_literal:"\u015Eablon dizesi"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${n.expected}, al\u0131nan ${a}`:`Ge\xE7ersiz de\u011Fer: beklenen ${i}, al\u0131nan ${a}`}case"invalid_value":return n.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${ie(n.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${i}${n.maximum.toString()} ${s.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${i}${n.minimum.toString()} ${s.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Ge\xE7ersiz metin: "${i.prefix}" ile ba\u015Flamal\u0131`:i.format==="ends_with"?`Ge\xE7ersiz metin: "${i.suffix}" ile bitmeli`:i.format==="includes"?`Ge\xE7ersiz metin: "${i.includes}" i\xE7ermeli`:i.format==="regex"?`Ge\xE7ersiz metin: ${i.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[i.format]??n.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${n.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${n.keys.length>1?"lar":""}: ${K(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${n.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function AR(){return{localeError:DD()}}var qD=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},map:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",mac:"\u0430\u0434\u0440\u0435\u0441\u0430 MAC",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",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u043E\u0457 \u043A\u0430\u0440\u0442\u043A\u0438",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u0438",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},o={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${n.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${i}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`}case"invalid_value":return n.values.length===1?`\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 ${ie(n.values[0])}`:`\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 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} \u0431\u0443\u0434\u0435 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${i.prefix}"`:i.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${i.suffix}"`:i.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${i.includes}"`:i.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0456":""}: ${K(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${n.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function If(){return{localeError:qD()}}function OR(){return If()}var UD=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},map:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(n){return e[n]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",mac:"\u0627\u06CC\u0645 \u0627\u06D2 \u0633\u06CC \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",credit_card:"\u06A9\u0631\u06CC\u0688\u0679 \u06A9\u0627\u0631\u0688 \u0646\u0645\u0628\u0631",currency_code:"\u06A9\u0631\u0646\u0633\u06CC \u06A9\u0648\u0688",iban:"IBAN",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},o={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${n.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${i} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return n.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${ie(n.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${K(n.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${i}${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${i}${n.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u06D2 ${i}${n.minimum.toString()} ${s.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u0627 ${i}${n.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:i.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:i.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:i.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${i.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${n.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${n.keys.length>1?"\u0632":""}: ${K(n.keys,"\u060C ")}`;case"invalid_key":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function NR(){return{localeError:UD()}}var LD=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(n){return e[n]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",credit_card:"kredit karta raqami",currency_code:"valyuta kodi",iban:"IBAN",jwt:"JWT",template_literal:"kirish"},o={nan:"NaN",number:"raqam",array:"massiv"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${n.expected}, qabul qilingan ${a}`:`Noto\u2018g\u2018ri kirish: kutilgan ${i}, qabul qilingan ${a}`}case"invalid_value":return n.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${ie(n.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Juda katta: kutilgan ${n.origin??"qiymat"} ${i}${n.maximum.toString()} ${s.unit} ${s.verb}`:`Juda katta: kutilgan ${n.origin??"qiymat"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Juda kichik: kutilgan ${n.origin} ${i}${n.minimum.toString()} ${s.unit} ${s.verb}`:`Juda kichik: kutilgan ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${i.prefix}" bilan boshlanishi kerak`:i.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${i.suffix}" bilan tugashi kerak`:i.format==="includes"?`Noto\u2018g\u2018ri satr: "${i.includes}" ni o\u2018z ichiga olishi kerak`:i.format==="regex"?`Noto\u2018g\u2018ri satr: ${i.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[i.format]??n.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${n.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${n.keys.length>1?"lar":""}: ${K(n.keys,", ")}`;case"invalid_key":return`${n.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${n.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function MR(){return{localeError:LD()}}var FD=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},map:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(n){return e[n]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",mac:"\u0111\u1ECBa ch\u1EC9 MAC",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",credit_card:"s\u1ED1 th\u1EBB t\xEDn d\u1EE5ng",currency_code:"m\xE3 ti\u1EC1n t\u1EC7",iban:"IBAN",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},o={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${n.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${i}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`}case"invalid_value":return n.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${ie(n.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${i.prefix}"`:i.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${i.suffix}"`:i.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${i.includes}"`:i.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${i.pattern}`:`${r[i.format]??n.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${n.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${K(n.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function DR(){return{localeError:FD()}}var VD=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"},map:{unit:"\u9879",verb:"\u5305\u542B"}};function t(n){return e[n]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",mac:"MAC\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",credit_card:"\u4FE1\u7528\u5361\u53F7",currency_code:"\u8D27\u5E01\u4EE3\u7801",iban:"IBAN",jwt:"JWT",template_literal:"\u8F93\u5165"},o={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${n.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${i}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`}case"invalid_value":return n.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${ie(n.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${i}${n.maximum.toString()} ${s.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${i}${n.minimum.toString()} ${s.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${i.prefix}" \u5F00\u5934`:i.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${i.suffix}" \u7ED3\u5C3E`:i.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${i.includes}"`:i.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${i.pattern}`:`\u65E0\u6548${r[i.format]??n.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${n.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${K(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${n.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function qR(){return{localeError:VD()}}var ZD=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},map:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(n){return e[n]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",mac:"MAC \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",credit_card:"\u4FE1\u7528\u5361\u865F",currency_code:"\u8CA8\u5E63\u4EE3\u78BC",iban:"IBAN",jwt:"JWT",template_literal:"\u8F38\u5165"},o={nan:"NaN"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${n.expected}\uFF0C\u4F46\u6536\u5230 ${a}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${i}\uFF0C\u4F46\u6536\u5230 ${a}`}case"invalid_value":return n.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${ie(n.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${i}${n.maximum.toString()} ${s.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${i}${n.minimum.toString()} ${s.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${i.prefix}" \u958B\u982D`:i.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${i.suffix}" \u7D50\u5C3E`:i.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${i.includes}"`:i.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${i.pattern}`:`\u7121\u6548\u7684 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${n.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${n.keys.length>1?"\u5011":""}\uFF1A${K(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function UR(){return{localeError:ZD()}}var HD=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"},map:{unit:"nkan",verb:"n\xED"}};function t(n){return e[n]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",mac:"\xE0d\xEDr\u1EB9\u0301s\xEC MAC",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",credit_card:"n\u1ECDmba kaadi gbese",currency_code:"koodu ow\xF3",iban:"IBAN",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},o={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return n=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=se(n.input),a=o[s]??s;return/^[A-Z]/.test(n.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${n.expected}, \xE0m\u1ECD\u0300 a r\xED ${a}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${i}, \xE0m\u1ECD\u0300 a r\xED ${a}`}case"invalid_value":return n.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${ie(n.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${K(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);return s?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin??"iye"} ${s.verb} ${i}${n.maximum} ${s.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${i}${n.maximum}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);return s?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin} ${s.verb} ${i}${n.minimum} ${s.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${i}${n.minimum}`}case"invalid_format":{let i=n;return i.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${i.prefix}"`:i.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${i.suffix}"`:i.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${i.includes}"`:i.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${i.pattern}`:`A\u1E63\xEC\u1E63e: ${r[i.format]??n.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${n.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${K(n.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function LR(){return{localeError:HD()}}var FR,w$=Symbol("ZodOutput"),v$=Symbol("ZodInput"),Pf=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let o=r[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let o={...this.get(r)??{}};delete o.id;let n={...o,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function jf(){return new Pf}(FR=globalThis).__zod_globalRegistry??(FR.__zod_globalRegistry=jf());var Zt=globalThis.__zod_globalRegistry;var mn=Symbol.for("zod.compile.invalid"),VR=Symbol.for("zod.compile.fallback"),fr=class extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}},He=class extends Error{constructor(t,r=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=r}};function WD(e,t){try{return Tf(e,{assertOnly:!0})}catch{return t}}function S$(e,t){try{let r=Tf(e),o=Ef(e,r);return o._zod.bag.validator=WD(e,r),o}catch(r){if(t?.strict)throw r;return e}}function Ef(e,t){if(Sf(e))throw new He("a schema whose subtree contains a reference cycle");let r=tt(e),o=e._zod.run,n=o.__originalRun??o,i=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[VR]||a&&kf(a,s.value))return n(s,a);let c=t(s.value);return c!==mn?(s.value=c,s):(a&&(a[VR]=!0),n(s,a))};return i.__originalRun=n,r._zod.bag.fallbackRun=n,r._zod.bag.validator=t,r._zod.run=i,o.__originalRun||JD(r,e,t),r}function JD(e,t,r){let o=e,n=t;if(typeof n.safeParse=="function"){let i=n.safeParse;o.safeParse=(s,a)=>{let c=r(s);return c!==mn?{success:!0,data:c}:i(s,a)}}if(typeof n.parse=="function"){let i=n.parse;o.parse=(s,a)=>{let c=r(s);return c!==mn?c:i(s,a)}}}function Tf(e,t){let r=!0;try{r=Sf(e)}catch{}if(r)throw new He("a schema whose subtree contains a reference cycle");let o={constants:new Map,constantCounter:0,varCounter:0,definite:!0},n=new Bi(["input"]),i=gt(n,o,e,"input",!t?.assertOnly);n.write(i===null?"return true;":`return ${i};`);let s=["INVALID",...o.constants.keys()],a=[mn,...o.constants.values()],c=n.content.join(`
59
+ `),l=t?.debug?s.length>0?`// Constants: ${s.join(", ")}
60
+ ${c}`:c:"",u=Function,m=`return (input) => {
61
+ ${c}
62
+ }`,d;try{d=new u(...s,m)(...a)}catch(f){throw new He(`this schema (generated code failed to evaluate: ${f.message})`)}return t?.debug&&(d.code=l),d.definite=o.definite,d}function Ae(e,t){for(let[o,n]of e.constants)if(n===t)return o;let r=`c${e.constantCounter++}`;return e.constants.set(r,t),r}function Gi(e,t){return e.definite=!1,Ae(e,t)}function Ee(e){return`v${e.varCounter++}`}function GD(e,t){let r=e._zod.run({value:t,issues:[]},{});if(r&&typeof r.then=="function")return mn;let o=r;return o.issues.length===0?o.value:mn}function Xt(e,t,r,o,n=!0){let i=e.content.length,s=t.constants.size,a=t.constantCounter,c=t.varCounter;try{return gt(e,t,r,o,n)}catch(l){if(!(l instanceof He)||!l.islandable)throw l;if(e.content.length=i,t.constants.size>s){let u=Array.from(t.constants.keys()).slice(s);for(let m of u)t.constants.delete(m)}return t.constantCounter=a,t.varCounter=c,KD(e,t,r,o)}}function KD(e,t,r,o){t.definite=!1;let n=Ae(t,r),i=Ae(t,GD),s=Ee(t);return e.write(`const ${s} = ${i}(${n}, ${o});`),e.write(`if (${s} === INVALID) return INVALID;`),s}var YD=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function XD(e,t,r,o){let n=r._zod.def.checks;if(!n||n.length===0)return o;let i=o;for(let s of n){let a=s._zod.def;if(a.when&&!YD.has(a.check))throw new He('check with a custom "when" condition');switch(a.check){case"greater_than":QD(e,t,a,i);break;case"less_than":e4(e,t,a,i);break;case"multiple_of":t4(e,t,a,i);break;case"number_format":GR(e,a,i);break;case"min_length":{let c=Uo(a.minimum,"min_length"),l=$$(e,t,i,`${i}.length >= ${c} && ${i}.length < ${a.minimum*2}`);e.write(`if (${l} < ${c}) return INVALID;`);break}case"max_length":{let c=Uo(a.maximum,"max_length"),l=$$(e,t,i,`${i}.length > ${c}`);e.write(`if (${l} > ${c}) return INVALID;`);break}case"length_equals":{let c=Uo(a.length,"length_equals"),l=$$(e,t,i,`${i}.length >= ${c} && ${i}.length <= ${a.length*2}`);e.write(`if (${l} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${i}.size < ${Uo(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${i}.size > ${Uo(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${i}.size !== ${Uo(a.size,"size_equals")}) return INVALID;`);break;case"string_format":i=KR(e,t,a,i);break;case"custom":i=a4(e,t,s,i);break;case"bigint_format":n4(e,a,i);break;case"mime_type":r4(e,t,a,i);break;case"property":i4(e,t,a,i);break;case"properties":o4(e,t,a,i);break;case"overwrite":{let c=Ee(t);s4(e,t,s,i,c),i=c;break}default:throw new He(`check type ${a.check}`)}}return i}function $$(e,t,r,o){let n=Ae(t,Zi),i=Ee(t);return e.write(`const ${i} = typeof ${r} === "string" && ${o} ? ${n}(${r}) : ${r}.length;`),i}function Uo(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new He(`${t} bound of type ${typeof e}`);return`${e}`}function JR(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new He("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new He("comparison check with Invalid Date bound");return Ae(e,t)}throw new He(`comparison check bound of type ${typeof t}`)}function QD(e,t,r,o){let n=r.inclusive?"<":"<=";e.write(`if (${o} ${n} ${JR(t,r.value)}) return INVALID;`)}function e4(e,t,r,o){let n=r.inclusive?">":">=";e.write(`if (${o} ${n} ${JR(t,r.value)}) return INVALID;`)}function t4(e,t,r,o){if(typeof r.value=="bigint"){if(r.value===BigInt(0))throw new He("multiple_of check with a zero divisor");e.write(`if (${o} % ${r.value}n !== 0n) return INVALID;`)}else{let n=Ae(t,yl);e.write(`if (${n}(${o}, ${Uo(r.value,"multiple_of")}) !== 0) return INVALID;`)}}function GR(e,t,r){let o=t.format;switch(o){case"safeint":e.write(`if (!Number.isSafeInteger(${r})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${r}) || ${r} < -2147483648 || ${r} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${r}) || ${r} < 0 || ${r} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${r}) || ${r} < -3.4028234663852886e38 || ${r} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${r})) return INVALID;`);break;default:throw new He(`number format ${o}`)}}function n4(e,t,r){let o=t.format;if(o)switch(o){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break;default:throw new He(`bigint format ${o}`)}}function r4(e,t,r,o){let n=r.mime;if(n&&n.length>0){let i=Ae(t,new Set(n));e.write(`if (!${i}.has(${o}.type)) return INVALID;`)}}function o4(e,t,r,o){if(r.when)throw new He('check with a custom "when" condition');e.write(`if (${o} == null) return INVALID;`);let n=r.shape;for(let i of Reflect.ownKeys(n)){let s=typeof i=="symbol"?Ae(t,i):ln(i),a=Ee(t);e.write(`const ${a} = ${o}[${s}];`),Xt(e,t,n[i],a,!1)}}function i4(e,t,r,o){let n=`${o}[${JSON.stringify(r.property)}]`;gt(e,t,r.schema,n)}function s4(e,t,r,o,n){let i=r._zod.def.tx;if(!i)throw new He("overwrite check without a transform function");if(Ki(i))throw new fr("z.compile: async overwrite transforms are not supported");let s=Ae(t,i);e.write(`const ${n} = ${s}(${o});`)}function x$(){throw new _n}function k$(e){this.issues.push(e)}function a4(e,t,r,o){let n=r._zod.def;if(n.fn){if(Ki(n.fn))throw new fr("z.compile: async .refine() predicates are not supported");let i=Gi(t,n.fn),s=Ae(t,x$),a=Ee(t);return e.write(`const ${a} = ${i}(${o});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`),o}if(r._zod.check){if(Ki(r._zod.check))throw new fr("z.compile: async .superRefine() / check functions are not supported");let i=r._zod.check,a=Gi(t,l=>{let u={value:l,issues:[],addIssue:k$};return i(u)instanceof Promise&&x$(),u.issues.length===0?u.value:mn}),c=Ee(t);return e.write(`const ${c} = ${a}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new He("custom check without a predicate or check function")}var c4=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function KR(e,t,r,o,n=!0){let i=r.format;if(i==="base64"){let l=Ae(t,Dl);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="base64url"){let l=Ae(t,mf);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="jwt"){let l=Ae(t,pf),u=Ae(t,r.alg??null);return e.write(`if (!${l}(${o}, ${u})) return INVALID;`),o}if(i==="ipv6"){let l=Ae(t,Ml);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="cidrv6"){let l=Ae(t,lf);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="credit_card"){let l=Ae(t,df);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="iban"){let l=Ae(t,ff);return e.write(`if (!${l}(${o})) return INVALID;`),o}let s=r;if(i==="url"||i==="httpurl"||s.normalize||s.hostname!==void 0||s.protocol!==void 0){let l=Ae(t,sf),u=Ae(t,r),m=Ee(t),d=Ee(t);if(e.write(`const ${m} = ${o}.trim();`),e.write(`const ${d} = ${l}(${m}, ${u});`),e.write(`if (typeof ${d} === "number") return INVALID;`),s.hostname!==void 0){let h=Ae(t,af);e.write(`if (!${h}(${d}, ${u}.hostname)) return INVALID;`)}if(s.protocol!==void 0){let h=Ae(t,cf);e.write(`if (!${h}(${d}, ${u}.protocol)) return INVALID;`)}if(!n)return null;let f=Ee(t),p=s.normalize?`${d}.href`:`${Ae(t,Nl)}(${m})`;return e.write(`const ${f} = ${p};`),f}let a=r.fn;if(a){if(Ki(a))throw new He(`async string format ${i}`);let l=Ae(t,a);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(c4.has(i)&&r.pattern){let l=Ae(t,r.pattern);return e.write(`${l}.lastIndex = 0;`),e.write(`if (!${l}.test(${o})) return INVALID;`),o}let c=r.format;switch(c){case"regex":throw new He("regex format without a pattern");case"lowercase":e.write(`if (${o} !== ${o}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${o} !== ${o}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${o}.includes(${ln(r.includes)})) return INVALID;`);break;case"starts_with":{let l=r.prefix;e.write(`if (${o}.slice(0, ${l.length}) !== ${ln(l)}) return INVALID;`);break}case"ends_with":{let l=r.suffix;e.write(`if (${o}.slice(-${l.length}) !== ${ln(l)}) return INVALID;`);break}default:throw new He(`string format ${c}`)}return o}function gt(e,t,r,o,n=!0){let i=r._zod.def,s=i.type;if(i.coerce)throw new He(`coercion (z.coerce.${s}())`);let a=n||!!i.checks?.length,c;switch(s){case"string":c=l4(e,t,r,o,a);break;case"number":c=u4(e,r,o);break;case"boolean":c=m4(e,o);break;case"bigint":c=d4(e,r,o);break;case"symbol":c=f4(e,o);break;case"undefined":c=p4(e,o);break;case"null":c=h4(e,o);break;case"any":case"unknown":c=o;break;case"never":e.write("return INVALID;"),c=o;break;case"void":c=g4(e,o);break;case"nan":c=y4(e,o);break;case"date":c=b4(e,o);break;case"object":c=w4(e,t,r,o,a);break;case"optional":c=v4(e,t,r,o,a);break;case"nullable":c=_4(e,t,r,o,a);break;case"array":c=S4(e,t,r,o,a);break;case"literal":c=k4(e,t,r,o);break;case"enum":c=z4(e,t,r,o);break;case"readonly":{let l=HR(e,t,r,o),u=Ee(t);e.write(`const ${u} = Object.freeze(${l});`),c=u;break}case"success":HR(e,t,r,o),c="true";break;case"default":case"prefault":c=R4(e,t,r,o);break;case"nonoptional":c=I4(e,t,r,o);break;case"tuple":c=P4(e,t,r,o);break;case"union":c=j4(e,t,r,o);break;case"intersection":c=C4(e,t,r,o);break;case"record":c=A4(e,t,r,o);break;case"map":c=N4(e,t,r,o);break;case"set":c=M4(e,t,r,o);break;case"file":c=D4(e,o);break;case"template_literal":c=q4(e,t,r,o);break;case"lazy":c=U4(e,t,r,o);break;case"pipe":c=L4(e,t,r,o);break;case"custom":c=F4(e,t,r,o);break;case"transform":c=H4(e,t,r,o);break;case"catch":c=Z4(e,t,r,o);break;default:throw new He(`schema type ${s}`)}return c===null?null:XD(e,t,r,c)}function l4(e,t,r,o,n=!0){e.write(`if (typeof ${o} !== "string") return INVALID;`);let i=r._zod.def;return i.format===void 0?o:KR(e,t,i,o,n)}function u4(e,t,r){e.write(`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return INVALID;`);let o=t._zod.def;return o.check==="number_format"&&o.format&&GR(e,{format:o.format},r),r}function m4(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function d4(e,t,r){e.write(`if (typeof ${r} !== "bigint") return INVALID;`);let o=t._zod.def;if(o.format)switch(o.format){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break}return r}function f4(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function p4(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function h4(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function g4(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function y4(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function b4(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function w4(e,t,r,o,n=!0){let i=r._zod.def;e.write(`if (typeof ${o} !== "object" || ${o} === null || Array.isArray(${o})) return INVALID;`);let s=i.shape,a=Object.keys(s),c=Object.getOwnPropertySymbols(s),l=c.length?[...a,...c]:a,u=y=>typeof y=="symbol"?Ae(t,y):ln(y),m=y=>typeof y=="symbol"?`[${u(y)}]`:ln(y),d=s;if(a.includes("__proto__"))throw new He('object shape key "__proto__"');let f=new Map;for(let y of l){let w=d[y],v=u(y),S=Ee(t);if(e.write(`const ${S} = ${o}[${v}];`),w._zod.optin!==void 0){let _=Ee(t);e.write(`let ${_} = (() => {`),e.indented($=>{let x=Xt($,t,w,S);$.write(`return ${x};`)}),e.write("})();"),w._zod.optout==="optional"?(e.write(`if (${_} === INVALID) {`),e.indented($=>{$.write(`if (${v} in ${o}) return INVALID;`),$.write(`${_} = undefined;`)}),e.write("}")):e.write(`if (${_} === INVALID) return INVALID;`),f.set(y,_)}else{x4(w)&&e.write(`if (!(${v} in ${o})) return INVALID;`);let _=Xt(e,t,w,S,n);_!==null&&f.set(y,_)}}let p=i.catchall,h="none";if(p){let y=p._zod.def.type;if(y==="never"){let w=a.map(v=>`k !== ${ln(v)}`).join(" && ")||"true";e.write(`for (const k in ${o}) {`),e.indented(v=>{v.write(`if (${w}) return INVALID;`)}),e.write("}")}else(y==="unknown"||y==="any")&&!p._zod.def.checks?.length?h="passthrough":h="schema"}let g=Ee(t),b=l.some(y=>ZR(d[y])||_$(d[y]));if(!n){if(h==="schema"){let y=a.length>0?Ae(t,new Set(a)):null;e.write(`for (const k in ${o}) {`),e.indented(w=>{w.write('if (k === "__proto__") continue;'),y&&w.write(`if (${y}.has(k)) continue;`);let v=Ee(t);w.write(`const ${v} = ${o}[k];`),Xt(w,t,p,v,!1)}),e.write("}")}return null}if(b){e.write(`const ${g} = {};`);for(let y of l){let w=u(y),v=f.get(y);_$(d[y])?e.write(`if (${w} in ${o}) ${g}[${w}] = ${v};`):ZR(d[y])?e.write(`if (${v} !== undefined || ${w} in ${o}) ${g}[${w}] = ${v};`):e.write(`${g}[${w}] = ${v};`)}}else{let y=l.map(w=>`${m(w)}: ${f.get(w)}`).join(", ");e.write(`const ${g} = { ${y} };`)}if(h!=="none"){let y=a.length>0?Ae(t,new Set(a)):null;e.write(`for (const k in ${o}) {`),e.indented(w=>{if(w.write('if (k === "__proto__") continue;'),y&&w.write(`if (${y}.has(k)) continue;`),h==="passthrough")w.write(`${g}[k] = ${o}[k];`);else{let v=Ee(t);w.write(`const ${v} = ${o}[k];`);let S=Xt(w,t,p,v);w.write(`${g}[k] = ${S};`)}}),e.write("}")}return g}function v4(e,t,r,o,n=!0){let i=r._zod.def;if($4(r))return gt(e,t,i.innerType,o,n);if(i.innerType._zod.optin==="defaulted"){let a=Ee(t),c=Ee(t);return e.write(`let ${a};`),e.write(`if (${o} === undefined) {`),e.indented(l=>{l.write(`const ${c} = (() => {`),l.indented(u=>{let m=gt(u,t,i.innerType,o);u.write(`return ${m};`)}),l.write("})();"),l.write(`if (${c} !== INVALID) ${a} = ${c};`)}),e.write("} else {"),e.indented(l=>{let u=gt(l,t,i.innerType,o);l.write(`${a} = ${u};`)}),e.write("}"),a}let s=n?Ee(t):null;return s&&e.write(`let ${s};`),e.write(`if (${o} !== undefined) {`),e.indented(a=>{let c=gt(a,t,i.innerType,o,n);s&&c!==null&&a.write(`${s} = ${c};`)}),e.write("}"),s}function $4(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function x4(e){return e._zod.optin===void 0&&Ji(e)}function Ji(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Ji(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Ji(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Ji):!0;case"intersection":return!t.left||!t.right?!0:Ji(t.left)&&Ji(t.right);case"pipe":return t.in?Ji(t.in):!0;default:return!0}}function _$(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function ZR(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&xa(e)}function xa(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?xa(t.innerType):!0;case"union":return t.options?t.options.some(xa):!0;case"intersection":return!t.left||!t.right||xa(t.left)||xa(t.right);case"pipe":return t.out?xa(t.out):!0;default:return!0}}function _4(e,t,r,o,n=!0){let i=r._zod.def,s=n?Ee(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${o} !== null) {`),e.indented(a=>{let c=gt(a,t,i.innerType,o,n);s&&c!==null&&a.write(`${s} = ${c};`)}),e.write("}"),s}function z$(e,t,r){for(let[o,n]of da(t._zod.def.checks))e.write(`if (${r} > ${Uo(o,n._zod.def.check)}) return INVALID;`)}function S4(e,t,r,o,n=!0){let i=r._zod.def;e.write(`if (!Array.isArray(${o})) return INVALID;`),z$(e,r,`${o}.length`);let s=n?Ee(t):null,a=Ee(t),c=Ee(t);return s&&e.write(`const ${s} = new Array(${o}.length);`),e.write(`for (let ${a} = 0; ${a} < ${o}.length; ${a}++) {`),e.indented(l=>{l.write(`const ${c} = ${o}[${a}];`);let u=Xt(l,t,i.element,c,n);s&&u!==null&&l.write(`${s}[${a}] = ${u};`)}),e.write("}"),s}function k4(e,t,r,o){let i=r._zod.def.values;if(i.length!==1){let a=Ae(t,new Set(i));return e.write(`if (!${a}.has(${o})) return INVALID;`),o}let s=i[0];if(typeof s=="number"&&Number.isNaN(s)){let a=Ae(t,new Set(i));return e.write(`if (!${a}.has(${o})) return INVALID;`),o}if(typeof s=="string")e.write(`if (${o} !== ${ln(s)}) return INVALID;`);else if(typeof s=="number"||typeof s=="boolean")e.write(`if (${o} !== ${s}) return INVALID;`);else if(s===null)e.write(`if (${o} !== null) return INVALID;`);else if(s===void 0)e.write(`if (${o} !== undefined) return INVALID;`);else if(typeof s=="bigint")e.write(`if (${o} !== ${s}n) return INVALID;`);else throw new He(`literal type ${typeof s}`);return o}function z4(e,t,r,o){let n=r._zod.values;if(!n)throw new He("enum schema without enumerated values");let i=Ae(t,n);return e.write(`if (!${i}.has(${o})) return INVALID;`),o}function HR(e,t,r,o){let n=r._zod.def;return gt(e,t,n.innerType,o)}function R4(e,t,r,o){let n=r._zod.def,s=Object.getOwnPropertyDescriptor(r._zod.def,"defaultValue")?()=>r._zod.def.defaultValue:void 0;if(r._zod.def.type==="prefault"){if(!s)return gt(e,t,n.innerType,o);let c=Ae(t,s),l=Ee(t);return e.write(`let ${l} = ${o};`),e.write(`if (${o} === undefined) ${l} = ${c}();`),gt(e,t,n.innerType,l)}let a=Ee(t);if(s){let c=Ae(t,s),l=Ae(t,bl);e.write(`let ${a};`),e.write(`if (${o} === undefined) {`),e.indented(u=>{u.write(`${a} = ${l}(${c}());`)}),e.write("} else {"),e.indented(u=>{let m=gt(u,t,n.innerType,o);u.write(`${a} = ${m} === undefined ? ${l}(${c}()) : ${m};`)}),e.write("}")}else e.write(`let ${a};`),e.write(`if (${o} !== undefined) {`),e.indented(c=>{let l=gt(c,t,n.innerType,o);c.write(`${a} = ${l};`)}),e.write("}");return a}function I4(e,t,r,o){let n=r._zod.def,i=gt(e,t,n.innerType,o),s=Ee(t);return e.write(`const ${s} = ${i};`),e.write(`if (${s} === undefined) return INVALID;`),s}function P4(e,t,r,o){let n=r._zod.def,i=n.items,s=n.rest;e.write(`if (!Array.isArray(${o})) return INVALID;`);let a=BR(i,"optin"),c=BR(i,"optout");s?e.write(`if (${o}.length < ${a}) return INVALID;`):e.write(`if (${o}.length < ${a} || ${o}.length > ${i.length}) return INVALID;`);let l=Ee(t);e.write(`const ${l} = [];`);for(let u=0;u<i.length;u++){let m=i[u];if(u>=c)e.write(`if (${l}.length === ${u}) {`),e.indented(d=>{d.write(`if (${u} < ${o}.length) {`),d.indented(f=>{let p=Ee(t);f.write(`const ${p} = ${o}[${u}];`);let h=Xt(f,t,m,p);f.write(`${l}[${u}] = ${h};`)}),d.write("} else {"),d.indented(f=>{if(_$(m)){f.write(`${l}.length = ${u};`);return}let p=Ee(t),h=Ee(t);f.write(`const ${p} = undefined;`),f.write(`const ${h} = (() => {`),f.indented(g=>{let b=Xt(g,t,m,p);g.write(`return ${b};`)}),f.write("})();"),f.write(`if (${h} === INVALID || ${h} === undefined) ${l}.length = ${u};`),f.write(`else ${l}[${u}] = ${h};`)}),d.write("}")}),e.write("}");else{let d=Ee(t);e.write(`const ${d} = ${o}[${u}];`);let f=Xt(e,t,m,d);e.write(`${l}[${u}] = ${f};`)}}if(s){let u=Ee(t),m=Ee(t);e.write(`for (let ${u} = ${i.length}; ${u} < ${o}.length; ${u}++) {`),e.indented(d=>{d.write(`const ${m} = ${o}[${u}];`);let f=Xt(d,t,s,m);d.write(`${l}[${u}] = ${f};`)}),e.write("}")}return l}function BR(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function j4(e,t,r,o){let n=r._zod.def,i=n.options;if(n.discriminator)return E4(e,t,n,o);if(n.inclusive===!1)throw new He("exclusive unions (z.xor)");if(i.length===0)return e.write("return INVALID;"),o;if(i.length===1)return gt(e,t,i[0],o);if(i.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){let c=new Set(i.flatMap(u=>u._zod.def.values)),l=Ae(t,c);return e.write(`if (!${l}.has(${o})) return INVALID;`),o}let a=Ee(t);e.write(`let ${a};`);for(let c=0;c<i.length;c++){let l=i[c];c===0?e.write(`${a} = (() => {`):e.write(`if (${a} === INVALID) ${a} = (() => {`),e.indented(u=>{let m=gt(u,t,l,o);u.write(`return ${m};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function E4(e,t,r,o){if(r.unionFallback)throw new He("discriminated union with unionFallback");if(r.options.length===0)return e.write("return INVALID;"),o;let n=Ee(t),i=Ee(t);e.write(`const ${n} = ${o}?.[${ln(r.discriminator)}];`),e.write(`let ${i};`);let s=!0,a=new Set;for(let c of r.options){let l=c._zod.propValues?.[r.discriminator];if(!l||l.size===0)throw new He("discriminated union option without static discriminator values");for(let d of l){if(a.has(d))throw new He(`duplicate discriminator value ${String(d)}`);a.add(d)}let u=Array.from(l,d=>T4(t,n,d)),m=s?"if":"else if";e.write(`${m} (${u.join(" || ")}) {`),e.indented(d=>{let f=gt(d,t,c,o);d.write(`${i} = ${f};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),i}function T4(e,t,r){if(typeof r=="string")return`${t} === ${ln(r)}`;if(typeof r=="number")return Number.isNaN(r)?`Number.isNaN(${t})`:`${t} === ${r}`;if(typeof r=="boolean")return`${t} === ${r}`;if(r===null)return`${t} === null`;if(r===void 0)return`${t} === undefined`;if(typeof r=="bigint")return`${t} === ${r}n`;if(typeof r=="symbol"){let o=Ae(e,r);return`${t} === ${o}`}throw new He(`literal discriminator value ${String(r)}`)}function C4(e,t,r,o){let n=r._zod.def;t.definite=!1;let i=Xt(e,t,n.left,o),s=Xt(e,t,n.right,o),a=Ae(t,wa),c=Ee(t);return e.write(`const ${c} = ${a}(${i}, ${s});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function A4(e,t,r,o){let n=r._zod.def,i=Ae(t,Wn);e.write(`if (!${i}(${o})) return INVALID;`);let s=Ee(t),a=Ee(t),c=Ee(t);e.write(`const ${s} = {};`);let l=n,u=l.partial?void 0:n.keyType._zod.values;if(u){let f=[];for(let h of u){if(!(typeof h=="string"||typeof h=="number"||typeof h=="symbol"))throw new He(`record key value ${String(h)}`);let g=typeof h=="number"?h.toString():h;if(g==="__proto__")throw new He('record key "__proto__"');f.push(g);let b=Ae(t,h),y=gt(e,t,n.keyType,b),w=Ee(t);e.write(`const ${w} = ${o}[${O4(t,g)}];`);let v=Xt(e,t,n.valueType,w);e.write(`${s}[${y}] = ${v};`)}let p=Ae(t,new Set(f));return e.write(`for (const ${a} in ${o}) {`),e.indented(h=>{h.write(`if (${p}.has(${a})) continue;`),l.mode==="loose"?h.write(`if (${a} !== "__proto__") ${s}[${a}] = ${o}[${a}];`):h.write("return INVALID;")}),e.write("}"),s}let m=n.keyType._zod.def;if(!(m.type==="string"&&m.format===void 0&&!m.coerce&&(m.checks?.length??0)===0)){let f=n.mode==="loose",p=Tf(n.keyType);p.definite===!1&&(t.definite=!1);let h=Ae(t,p),g=Ae(t,ro),b=Ee(t);return WR(e,t,o,a,y=>{y.write(`let ${b} = ${h}(${a});`),y.write(`if (${b} === INVALID && typeof ${a} === "string" && ${g}.test(${a})) ${b} = ${h}(Number(${a}));`),f?y.write(`if (${b} === INVALID) { ${s}[${a}] = ${o}[${a}]; continue; }`):y.write(`if (${b} === INVALID) return INVALID;`),y.write(`if (${b} === "__proto__") continue;`);let w=Ee(t);y.write(`const ${w} = ${o}[${a}];`);let v=Xt(y,t,n.valueType,w);y.write(`${s}[${b}] = ${v};`)}),s}return WR(e,t,o,a,f=>{f.write(`const ${c} = ${o}[${a}];`);let p=Xt(f,t,n.valueType,c);f.write(`${s}[${a}] = ${p};`)},"return INVALID;"),s}function WR(e,t,r,o,n,i){let s=Ae(t,Object.prototype.propertyIsEnumerable),a=Ee(t),c=Ee(t),l=Ee(t);e.write(`const ${a} = Object.getOwnPropertySymbols(${r});`),e.write(`const ${c} = Object.getOwnPropertyNames(${r});`),e.write(`for (let ${l} = 0; ${l} < ${c}.length; ${l}++) {`),e.indented(u=>{u.write(`const ${o} = ${c}[${l}];`),u.write(`if (${o} === "__proto__" || !${s}.call(${r}, ${o})) continue;`),n(u)}),e.write("}"),e.write(`for (let ${l} = 0; ${l} < ${a}.length; ${l}++) {`),e.indented(u=>{u.write(`const ${o} = ${a}[${l}];`),u.write(`if (!${s}.call(${r}, ${o})) continue;`),i?u.write(i):n(u)}),e.write("}")}function O4(e,t){return typeof t=="string"?ln(t):Ae(e,t)}function N4(e,t,r,o){let n=r._zod.def;e.write(`if (!(${o} instanceof Map)) return INVALID;`),z$(e,r,`${o}.size`);let i=Ee(t),s=Ee(t),a=Ee(t);return e.write(`const ${i} = new Map();`),e.write(`for (const [${s}, ${a}] of ${o}) {`),e.indented(c=>{let l=gt(c,t,n.keyType,s),u=gt(c,t,n.valueType,a);c.write(`${i}.set(${l}, ${u});`)}),e.write("}"),i}function M4(e,t,r,o){let n=r._zod.def;e.write(`if (!(${o} instanceof Set)) return INVALID;`),z$(e,r,`${o}.size`);let i=Ee(t),s=Ee(t);return e.write(`const ${i} = new Set();`),e.write(`for (const ${s} of ${o}) {`),e.indented(a=>{let c=gt(a,t,n.valueType,s);a.write(`${i}.add(${c});`)}),e.write("}"),i}function D4(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function q4(e,t,r,o){e.write(`if (typeof ${o} !== "string") return INVALID;`);let n=r._zod.pattern;if(n){let i=Ae(t,n);e.write(`${i}.lastIndex = 0;`),e.write(`if (!${i}.test(${o})) return INVALID;`)}return o}function U4(e,t,r,o){let n=r._zod.def,i=Gi(t,n.getter),s=Ae(t,{parser:null});e.write(`if (!${s}.parser) {`),e.indented(c=>{c.write(`const inner = ${i}();`),c.write(`${s}.parser = function(input) {`),c.indented(l=>{l.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),l.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");let a=Ee(t);return e.write(`const ${a} = ${s}.parser(${o});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function L4(e,t,r,o){let n=r._zod.def,i=gt(e,t,n.in,o);if(n.transform){if(Ki(n.transform))throw new fr("z.compile: async transforms in pipes are not supported");let s=n.transform,c=Gi(t,u=>{let m={value:u,issues:[],addIssue:k$},d=s(u,m);return d instanceof Promise?mn:m.issues.length===0?d:mn}),l=Ee(t);return e.write(`const ${l} = ${c}(${i});`),e.write(`if (${l} === INVALID) return INVALID;`),gt(e,t,n.out,l)}else return gt(e,t,n.out,i)}function Ki(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function F4(e,t,r,o){let n=r._zod.def;if(n.fn){if(Ki(n.fn))throw new fr("z.compile: async custom predicates are not supported");let i=Gi(t,n.fn),s=Ae(t,x$),a=Ee(t);e.write(`const ${a} = ${i}(${o});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new He("custom schema without a predicate function");return o}function V4(e,t,r){let o=e._zod.run({value:r,issues:[]},{});if(o&&typeof o.then=="function")return mn;let n=o;return n.issues.length===0?n.value:t()}function Z4(e,t,r,o){let n=r._zod.def;if(!n.catchValue[Nd])throw new He("catch with a callback (only a constant catch value compiles)",!1);let i=Ee(t);e.write(`let ${i} = (() => {`),e.indented(l=>{let u=Xt(l,t,n.innerType,o);l.write(`return ${u};`)}),e.write("})();");let s=Ae(t,n.innerType),a=Gi(t,n.catchValue),c=Ae(t,V4);return e.write(`if (${i} === INVALID) {`),e.indented(l=>{l.write(`${i} = ${c}(${s}, ${a}, ${o});`),l.write(`if (${i} === INVALID) return INVALID;`)}),e.write("}"),i}function H4(e,t,r,o){let n=r._zod.def;if(n.transform){if(Ki(n.transform))throw new fr("z.compile: async transforms are not supported");let i=n.transform,a=Gi(t,l=>{let u={value:l,issues:[],addIssue:k$},m=i(l,u);return m instanceof Promise?mn:u.issues.length===0?m:mn}),c=Ee(t);return e.write(`const ${c} = ${a}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return o}function Cf(e){return e.checks&&(e.checks=[...e.checks]),e}function R$(e,t){return new e(Cf({type:"string",...he(t)}))}function I$(e,t){return new e(Cf({type:"string",coerce:!0,...he(t)}))}function Af(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...he(t)})}function Of(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...he(t)})}function Nf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...he(t)})}function Mf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...he(t)})}function Df(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...he(t)})}function qf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...he(t)})}function Gl(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...he(t)})}function Uf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...he(t)})}function Lf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...he(t)})}function Ff(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...he(t)})}function Vf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...he(t)})}function Zf(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...he(t)})}function Hf(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...he(t)})}function Bf(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...he(t)})}function Wf(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...he(t)})}function Jf(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...he(t)})}function P$(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...he(t)})}function Gf(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...he(t)})}function Kf(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...he(t)})}function Yf(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...he(t)})}function Xf(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...he(t)})}function Qf(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...he(t)})}function j$(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...he(t)})}function E$(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...he(t)})}function ep(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...he(t)})}var T$={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Kl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...he(t)})}function Yl(e,t){return new e({type:"string",format:"date",check:"string_format",...he(t)})}function Xl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...he(t)})}function Ql(e,t){return new e({type:"string",format:"duration",check:"string_format",...he(t)})}function C$(e,t){return new e(Cf({type:"number",checks:[],...he(t)}))}function A$(e,t){return new e(Cf({type:"number",coerce:!0,checks:[],...he(t)}))}function O$(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...he(t)})}function N$(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...he(t)})}function M$(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...he(t)})}function D$(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...he(t)})}function q$(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...he(t)})}function U$(e,t){return new e({type:"boolean",...he(t)})}function L$(e,t){return new e({type:"boolean",coerce:!0,...he(t)})}function F$(e,t){return new e({type:"bigint",...he(t)})}function V$(e,t){return new e({type:"bigint",coerce:!0,...he(t)})}function Z$(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...he(t)})}function H$(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...he(t)})}function B$(e,t){return new e({type:"symbol",...he(t)})}function W$(e,t){return new e({type:"undefined",...he(t)})}function J$(e,t){return new e({type:"null",...he(t)})}function G$(e){return new e({type:"any"})}function K$(e){return new e({type:"unknown"})}function Y$(e,t){return new e({type:"never",...he(t)})}function X$(e,t){return new e({type:"void",...he(t)})}function Q$(e,t){return new e({type:"date",...he(t)})}function e0(e,t){return new e({type:"date",coerce:!0,...he(t)})}function t0(e,t){return new e({type:"nan",...he(t)})}function Er(e,t){return new Xd({check:"less_than",...he(t),value:e,inclusive:!1})}function Nn(e,t){return new Xd({check:"less_than",...he(t),value:e,inclusive:!0})}function Tr(e,t){return new Qd({check:"greater_than",...he(t),value:e,inclusive:!1})}function Mn(e,t){return new Qd({check:"greater_than",...he(t),value:e,inclusive:!0})}function tp(e){return Tr(0,e)}function np(e){return Er(0,e)}function rp(e){return Nn(0,e)}function op(e){return Mn(0,e)}function Lo(e,t){return new Mw({check:"multiple_of",...he(t),value:e})}function Fo(e,t){return new Uw({check:"max_size",...he(t),maximum:e})}function Cr(e,t){return new Lw({check:"min_size",...he(t),minimum:e})}function Yi(e,t){return new Fw({check:"size_equals",...he(t),size:e})}function Xi(e,t){return new Vw({check:"max_length",...he(t),maximum:e})}function oo(e,t){return new Zw({check:"min_length",...he(t),minimum:e})}function Qi(e,t){return new Hw({check:"length_equals",...he(t),length:e})}function _a(e,t){return new Bw({check:"string_format",format:"regex",...he(t),pattern:e})}function Sa(e){return new Ww({check:"string_format",format:"lowercase",...he(e)})}function ka(e){return new Jw({check:"string_format",format:"uppercase",...he(e)})}function za(e,t){return new Gw({check:"string_format",format:"includes",...he(t),includes:e})}function Ra(e,t){return new Kw({check:"string_format",format:"starts_with",...he(t),prefix:e})}function Ia(e,t){return new Yw({check:"string_format",format:"ends_with",...he(t),suffix:e})}function ip(e,t,r){return new Xw({check:"property",property:e,schema:t,...he(r)})}function Pa(e,t){return new Qw({check:"properties",shape:e,...he(t)})}function ja(e,t){return new ev({check:"mime_type",mime:e,...he(t)})}function pr(e){return new tv({check:"overwrite",tx:e})}function Ea(e){return pr(t=>t.normalize(e))}function Ta(){return pr(e=>e.trim())}function Ca(){return pr(e=>e.toLowerCase())}function Aa(){return pr(e=>e.toUpperCase())}function Oa(){return pr(e=>Ub(e))}function n0(e,t,r){return new e({type:"array",element:t,...he(r)})}function B4(e,t,r){return new e({type:"union",options:t,...he(r)})}function W4(e,t,r){return new e({type:"union",options:t,inclusive:!1,...he(r)})}function J4(e,t,r,o){return new e({type:"union",options:r,discriminator:t,...he(o)})}function G4(e,t,r){return new e({type:"intersection",left:t,right:r})}function K4(e,t,r,o){let n=r instanceof Ne,i=n?o:r,s=n?r:null;return new e({type:"tuple",items:t,rest:s,...he(i)})}function Y4(e,t,r,o){return new e({type:"record",keyType:t,valueType:r,...he(o)})}function X4(e,t,r,o){return new e({type:"map",keyType:t,valueType:r,...he(o)})}function Q4(e,t,r){return new e({type:"set",valueType:t,...he(r)})}function eq(e,t,r){let o=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:o,...he(r)})}function tq(e,t,r){return new e({type:"enum",entries:t,...he(r)})}function nq(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...he(r)})}function r0(e,t){return new e({type:"file",...he(t)})}function rq(e,t){return new e({type:"transform",transform:t})}function oq(e,t){return new e({type:"optional",innerType:t})}function iq(e,t){return new e({type:"nullable",innerType:t})}function sq(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():bl(r)}})}function aq(e,t,r){return new e({type:"nonoptional",innerType:t,...he(r)})}function cq(e,t){return new e({type:"success",innerType:t})}function lq(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:Bb(r)})}function uq(e,t,r){return new e({type:"pipe",in:t,out:r})}function mq(e,t){return new e({type:"readonly",innerType:t})}function dq(e,t,r){return new e({type:"template_literal",parts:t,...he(r)})}function fq(e,t){return new e({type:"lazy",getter:t})}function pq(e,t){return new e({type:"promise",innerType:t})}function o0(e,t,r){let o=he(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function i0(e,t,r){return new e({type:"custom",check:"custom",fn:t,...he(r)})}function s0(e,t){let r=YR(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(fa(n,o.value,r._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=o.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(fa(i))}},e(o.value,o)),t);return r}function YR(e,t){let r=new lt({check:"custom",...he(t)});return r._zod.check=e,r}function a0(e){let t=new lt({check:"describe"});return t._zod.onattach=[r=>{let o=Zt.get(r)??{};Zt.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function c0(e){let t=new lt({check:"meta"});return t._zod.onattach=[r=>{let o=Zt.get(r)??{};Zt.add(r,{...o,...e})}],t._zod.check=()=>{},t}function l0(e,t){let r=he(t),o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(o=o.map(f=>typeof f=="string"?f.toLowerCase():f),n=n.map(f=>typeof f=="string"?f.toLowerCase():f));let i=new Set(o),s=new Set(n),a=e.Codec??Fl,c=e.Boolean??Ul,l=e.String??Wi,u=new l({type:"string",error:r.error}),m=new c({type:"boolean",error:r.error}),d=new a({type:"pipe",in:u,out:m,transform:((f,p)=>{let h=f;return r.case!=="sensitive"&&(h=h.toLowerCase()),i.has(h)?!0:s.has(h)?!1:(p.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:p.value,inst:d,continue:!1}),{})}),reverseTransform:((f,p)=>f===!0?o[0]||"true":n[0]||"false"),error:r.error});return d._zod.bag.truthy=o,d._zod.bag.falsy=n,d._zod.bag.case=r.case??"insensitive",d}function es(e,t,r,o={}){let n=he(o),i={check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:a=>r.test(a),...n};return r instanceof RegExp&&(i.pattern=r),new e(i)}function eu(e,...t){for(let r of t)for(let o of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,o)&&Vt(e,o,r[o]);return e}function Vo(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Zt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function jt(e,t,r,o,n){let i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:o.path,message:n}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(n);return Object.assign(r,i),!0}function rt(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{let d=s.schema,f=t.processors[n.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);f(e,t,d,u)}let m=e._zod.parent;m&&(s.ref||(s.ref=m),rt(m,t,u),t.seen.get(m).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&eu(s.schema,c),t.io==="input"&&dn(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((o=s.schema).default??(o.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function XR(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Zo(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=o.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,s[0])}}let n=s=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let m=e.external.registry.get(s[0])?.id,d=e.external.uri??(p=>p);if(m)return{ref:d(m)};let f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${XR(f)}`}}let c="#",l=`${c}/${a}/`;if(s[1]===r&&!s[1].schema.id)return{ref:c};let u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+XR(u)}},i=s=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:l}=n(s);a.def={...a.schema},l&&(a.defId=l);let u=a.schema;for(let m in u)delete u[m];u.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
63
+
64
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}a.count>1&&e.reused==="ref"&&i(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function tI(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!="object")return;tI(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let i=o.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!="string")return;r.includes(s)||r.push(s)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var nI=new Set(["type","properties","required","additionalProperties"]),QR=["oneOf","anyOf"];function eI(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function u0(e){let t=[];for(let i of e){if(typeof i!="object"||i.type!=="object")return null;for(let s in i)if(!nI.has(s))return null;t.push(i)}let r={},o=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(r,s))continue;let a=[];for(let l of t){let u=l.properties?.[s]??eI(l);u!=null&&(a.some(m=>JSON.stringify(m)===JSON.stringify(u))||a.push(u))}let c=a.length===1?a[0]:u0(a)??{allOf:a};Vt(r,s,c)}for(let s of i.required??[])o.add(s)}let n={type:"object",properties:r};if(o.size&&(n.required=[...o]),t.every(i=>i.additionalProperties===!1))n.additionalProperties=!1;else{let i=[];for(let s of t){let a=eI(s);a&&!i.some(c=>JSON.stringify(c)===JSON.stringify(a))&&i.push(a)}i.length===1?n.additionalProperties=i[0]:i.length>1&&(n.additionalProperties={allOf:i})}return n}function hq(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of nI)if(n in e)return;let r=t.filter(n=>QR.some(i=>Array.isArray(n[i]))),o=null;if(!r.length)o=u0(t);else{let n=r[0],i=QR.find(c=>Array.isArray(n[c]));if(Object.keys(n).length!==1)return;let s=t.filter(c=>c!==n),a=n[i].map(c=>u0([...s,c]));if(a.some(c=>!c))return;o={[i]:a}}o&&(delete e.allOf,eu(e,o))}function Ho(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=a=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},m=c.ref;if(c.ref=null,m){o(m);let f=e.seen.get(m),p=f.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(p)):eu(l,p),eu(l,u),a._zod.parent===m)for(let g in l)g==="$ref"||g==="allOf"||g in u||delete l[g];if(p.$ref&&f.def)for(let g in l)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(l[g])===JSON.stringify(f.def[g])&&delete l[g]}let d=a._zod.parent;if(d&&d!==m){o(d);let f=e.seen.get(d);if(f?.schema.$ref&&(l.$ref=f.schema.$ref,f.def))for(let p in l)p==="$ref"||p==="allOf"||p in f.def&&JSON.stringify(l[p])===JSON.stringify(f.def[p])&&delete l[p]}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())o(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())tI(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let m=a.get(u);m?m.push(l):a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])hq(l)}}let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}eu(n,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;i!==void 0&&n.id===i&&delete n.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Vt(s,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?n.$defs=s:n.definitions=s);try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Na(t,"input",e.processors),output:Na(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function dn(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return dn(o.element,r);if(o.type==="set")return dn(o.valueType,r);if(o.type==="lazy")return dn(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return dn(o.innerType,r);if(o.type==="intersection")return dn(o.left,r)||dn(o.right,r);if(o.type==="record"||o.type==="map")return dn(o.keyType,r)||dn(o.valueType,r);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:dn(o.in,r)||dn(o.out,r);if(o.type==="object"){for(let n in o.shape)if(dn(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(dn(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(dn(n,r))return!0;return!!(o.rest&&dn(o.rest,r))}return!1}var m0=(e,t={})=>r=>{let o=Vo({...r,processors:t});return rt(e,o),Zo(o,e),Ho(o,e)},Na=(e,t,r={})=>o=>{let{libraryOptions:n,target:i}=o??{},s=Vo({...n??{},target:i,io:t,processors:r});return rt(e,s),Zo(s,e),Ho(s,e)};var Ma=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Da=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},rI=(e,t)=>{Ma(e,"minimum",t),Da(e,"maximum",t)},aI=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},cI=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},lI=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},uI=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},oI=(e,t)=>Ma(e,"minimum",t.minimum),iI=(e,t)=>Da(e,"maximum",t.maximum),sI=e=>(t,r)=>{uI(t,r.format);let[o,n]=e[r.format];Ma(t,"minimum",o),Da(t,"maximum",n)},gq={greater_than:(e,t)=>Ma(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Da(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>aI(e,t.value),number_format:sI(vl),bigint_format:sI($l),min_length:oI,max_length:iI,length_equals:(e,t)=>rI(e,t.length),min_size:oI,max_size:iI,size_equals:(e,t)=>rI(e,t.size),string_format:(e,t)=>{uI(e,t.format),t.pattern&&cI(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>lI(e,t.mime)};function Et(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of o)gq[i._zod.def.check]?.(t,i._zod.def);let n=e._zod.bag;n.minimum!==void 0&&Ma(t,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&Ma(t,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&Da(t,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&Da(t,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&aI(t,n.multipleOf),n.format!==void 0&&(t.format??(t.format=n.format),n.format.includes("int")&&(t.isInt=!0)),n.mime&&lI(t,n.mime);for(let i of n.patterns??[])cI(t,i);return t}var yq={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},bq=new Map([[uf,yw],[ql,bw]]),mI=e=>bq.get(e)??e,p0=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Et(e);if(typeof i=="number"&&(n.minLength=i),typeof s=="number"&&(n.maxLength=s),a&&(n.format=yq[a]??a,n.format===""&&delete n.format,(a==="time"||u)&&delete n.format),l&&(n.contentEncoding=l),c&&c.size>0){let m=[...c].map(mI);m.length===1?n.pattern=m[0].source:m.length>1&&(n.allOf=[...m.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},h0=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Et(e);n.type=u?"integer":"number";let m=typeof l=="number"&&l>=(i??Number.NEGATIVE_INFINITY),d=typeof c=="number"&&c<=(s??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(m?f?(n.minimum=l,n.exclusiveMinimum=!0):n.exclusiveMinimum=l:typeof i=="number"&&(n.minimum=i),d?f?(n.maximum=c,n.exclusiveMaximum=!0):n.exclusiveMaximum=c:typeof s=="number"&&(n.maximum=s),a){let p=new Set;for(let b of a)Number.isFinite(b)&&b!==0?p.add(Math.abs(b)):jt(e,t,n,o,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);let[h,...g]=p;h!==void 0&&(n.multipleOf=h),g.length&&(n.allOf=[...n.allOf??[],...g.map(b=>({multipleOf:b}))])}},g0=(e,t,r,o)=>{r.type="boolean"},y0=(e,t,r,o)=>{jt(e,t,r,o,"BigInt cannot be represented in JSON Schema")},b0=(e,t,r,o)=>{jt(e,t,r,o,"Symbols cannot be represented in JSON Schema")},w0=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},v0=(e,t,r,o)=>{jt(e,t,r,o,"Undefined cannot be represented in JSON Schema")},$0=(e,t,r,o)=>{jt(e,t,r,o,"Void cannot be represented in JSON Schema")},x0=(e,t,r,o)=>{r.not={}},_0=(e,t,r,o)=>{},S0=(e,t,r,o)=>{},k0=(e,t,r,o)=>{jt(e,t,r,o,"Date cannot be represented in JSON Schema")},z0=(e,t,r,o)=>{let n=e._zod.def,i=ca(n.entries);if(i.length===0){r.not={};return}i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),r.enum=i},R0=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let i=[];for(let s of n.values)if(s===void 0){if(jt(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(jt(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){let s=i[0];r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[s]:r.const=s}else i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),i.every(s=>typeof s=="boolean")&&(r.type="boolean"),i.every(s=>s===null)&&(r.type="null"),r.enum=i},I0=(e,t,r,o)=>{jt(e,t,r,o,"NaN cannot be represented in JSON Schema")},P0=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},j0=(e,t,r,o)=>{let n=r;n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=Et(e);i!==void 0&&(n.minLength=i),s!==void 0&&(n.maxLength=s),a&&(a.length===0?n.not={}:a.length===1?n.contentMediaType=a[0]:n.anyOf=a.map(c=>({contentMediaType:c})))},E0=(e,t,r,o)=>{r.type="boolean"},T0=(e,t,r,o)=>{jt(e,t,r,o,"Custom types cannot be represented in JSON Schema")},C0=(e,t,r,o)=>{jt(e,t,r,o,"Function types cannot be represented in JSON Schema")},A0=(e,t,r,o)=>{jt(e,t,r,o,"Transforms cannot be represented in JSON Schema")},O0=(e,t,r,o)=>{jt(e,t,r,o,"Map cannot be represented in JSON Schema")},N0=(e,t,r,o)=>{jt(e,t,r,o,"Set cannot be represented in JSON Schema")},M0=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:a}=Et(e);typeof s=="number"&&(n.minItems=s),typeof a=="number"&&(n.maxItems=a),n.type="array",n.items=rt(i.element,t,{...o,path:[...o.path,"items"]})};function tu(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?tu(t.out):t.type==="catch"?tu(t.innerType):e._zod.optin}var D0=(e,t,r,o)=>{let n=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&jt(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let l in s)Vt(n.properties,l,rt(s[l],t,{...o,path:[...o.path,"properties",l]}));let c=[];for(let l of Object.keys(s)){let u=i.shape[l];(t.io==="input"?tu(u)===void 0:u._zod.optout===void 0)&&c.push(l)}c.length>0&&(n.required=c),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=rt(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},ap=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,c)=>rt(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=s:r.anyOf=s},q0=(e,t,r,o)=>{let n=e._zod.def,i=rt(n.left,t,{...o,path:[...o.path,"allOf",0]}),s=rt(n.right,t,{...o,path:[...o.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c,t.intersections.push(c)},U0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((h,g)=>rt(h,t,{...o,path:[...o.path,s,g]})),l=i.rest?rt(i.rest,t,{...o,path:[...o.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,u=i.items.length;for(;u>0;){let h=i.items[u-1];if(!(t.io==="input"?tu(h)!==void 0:h._zod.optout==="optional"))break;u--}let m=i.items.length,d=!i.rest;t.target==="draft-2020-12"?(n.prefixItems=c,d?n.items=!1:l&&(n.items=l),u>0&&(n.minItems=u),d&&(n.maxItems=m)):t.target==="openapi-3.0"?(n.items={anyOf:c},l&&n.items.anyOf.push(l),u>0&&(n.minItems=u),d&&(n.maxItems=m)):(n.items=c,d?n.additionalItems=!1:l&&(n.additionalItems=l),u>0&&(n.minItems=u),d&&(n.maxItems=m));let{minimum:f,maximum:p}=Et(e);typeof f=="number"&&(n.minItems=f),typeof p=="number"&&(n.maxItems=p)};function d0(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let p=e.get(t)?.def;if(!p)return t;let h=d0(e,p,r);return h===p?t:h}for(let p of["anyOf","oneOf"]){let h=t[p];if(!Array.isArray(h))continue;let g=h.map(b=>d0(e,b,r));g.some((b,y)=>b!==h[y])&&(t={...t,[p]:g})}let o=Array.isArray(t.type)?t.type:[t.type],n=!o.includes("string")&&o.some(p=>p==="number"||p==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!i?.some(p=>typeof p=="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:m,id:d,...f}=t;return f.enum?f.enum=f.enum.map(p=>typeof p=="number"?String(p):p):typeof f.const=="number"&&(f.const=String(f.const)),n&&(f.type="string",i||(f.pattern=(o.includes("number")?ro:Tl).source)),f}var f0=new WeakMap;function wq(e){let t=new Map;for(let o of e.seen.values())o.def&&!t.has(o.schema)&&t.set(o.schema,o);let r=new Map;for(let o of f0.get(e)??[]){let n=e.seen.get(o),i=(n?.def??n?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=d0(t,i,new Set);s!==i&&r.set(i,s)}if(r.size)for(let o of e.seen.values())for(let n of[o.schema,o.def]){let i=n&&r.get(n.propertyNames);i&&(n.propertyNames=i)}}var L0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,a=Et(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let u=rt(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let m of a)Vt(n.patternProperties,mI(m).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=rt(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});let u=f0.get(t);u||(u=[],f0.set(t,u),t.deferred.push(()=>wq(t))),u.push(e)}n.additionalProperties=rt(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let c=s._zod.values,l=t.io==="input"&&tu(i.valueType)!==void 0;if(c&&!i.partial&&!l){let u=[...c].filter(m=>typeof m=="string"||typeof m=="number");u.length>0&&(n.required=u.map(String))}},F0=(e,t,r,o)=>{let n=e._zod.def,i=rt(n.innerType,t,o),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},V0=(e,t,r,o)=>{let n=e._zod.def;rt(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Z0=Symbol();function dI(e,t,r,o,n){let i=!1,s=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(i=!0,null));return i?(jt(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),Z0):JSON.parse(s)}var H0=(e,t,r,o)=>{let n=e._zod.def;rt(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s=dI(n.defaultValue,e,t,r,o);s!==Z0&&(r.default=s)},B0=(e,t,r,o)=>{let n=e._zod.def;rt(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io!=="input")return;let s=dI(n.defaultValue,e,t,r,o);s!==Z0&&(r._prefault=s)},W0=(e,t,r,o)=>{let n=e._zod.def;rt(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{jt(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},J0=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;rt(s,t,o);let a=t.seen.get(e);a.ref=s},G0=(e,t,r,o)=>{let n=e._zod.def;rt(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},K0=(e,t,r,o)=>{let n=e._zod.def;rt(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},cp=(e,t,r,o)=>{let n=e._zod.def;rt(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Y0=(e,t,r,o)=>{let n=e._zod.innerType;rt(n,t,o);let i=t.seen.get(e);i.ref=n},sp={string:p0,number:h0,boolean:g0,bigint:y0,symbol:b0,null:w0,undefined:v0,void:$0,never:x0,any:_0,unknown:S0,date:k0,enum:z0,literal:R0,nan:I0,template_literal:P0,file:j0,success:E0,custom:T0,function:C0,transform:A0,map:O0,set:N0,array:M0,object:D0,union:ap,intersection:q0,tuple:U0,record:L0,nullable:F0,nonoptional:V0,default:H0,prefault:B0,catch:W0,pipe:J0,readonly:G0,promise:K0,optional:cp,lazy:Y0};function ts(e,t){if("_idmap"in e){let o=e,n=Vo({...t,processors:sp}),i={};for(let c of o._idmap.entries()){let[l,u]=c;rt(u,n)}let s={},a={registry:o,uri:t?.uri,defs:i};n.external=a;for(let c of o._idmap.entries()){let[l,u]=c;Zo(n,u),Vt(s,l,Ho(n,u))}if(Object.keys(i).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let r=Vo({...t,processors:sp});return rt(e,r),Zo(r,e),Ho(r,e)}var lp=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Vo({processors:sp,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return rt(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,Zo(this.ctx,t);let o=Ho(this.ctx,t),{"~standard":n,...i}=o;return i}};var fI={};var Ba={};eo(Ba,{ZodAny:()=>hx,ZodArray:()=>wx,ZodBase64:()=>Pp,ZodBase64URL:()=>jp,ZodBigInt:()=>Ha,ZodBigIntFormat:()=>Cp,ZodBoolean:()=>Za,ZodCIDRv4:()=>Rp,ZodCIDRv6:()=>Ip,ZodCUID:()=>vp,ZodCUID2:()=>$p,ZodCatch:()=>Dx,ZodCodec:()=>uu,ZodCreditCard:()=>ux,ZodCustom:()=>mu,ZodCustomStringFormat:()=>rs,ZodDate:()=>iu,ZodDefault:()=>Tx,ZodDiscriminatedUnion:()=>$x,ZodE164:()=>Ep,ZodEmail:()=>hp,ZodEmoji:()=>bp,ZodEnum:()=>Ua,ZodExactOptional:()=>Mp,ZodFile:()=>Ix,ZodFunction:()=>Wx,ZodGUID:()=>yp,ZodIBAN:()=>mx,ZodIPv4:()=>kp,ZodIPv6:()=>zp,ZodISODate:()=>Wo,ZodISODateTime:()=>Bo,ZodISODuration:()=>Go,ZodISOTime:()=>Jo,ZodInstanceOf:()=>Kx,ZodIntersection:()=>xx,ZodJWT:()=>Tp,ZodKSUID:()=>Sp,ZodLazy:()=>Hx,ZodLiteral:()=>Rx,ZodMAC:()=>lx,ZodMap:()=>kx,ZodNaN:()=>Ux,ZodNanoID:()=>wp,ZodNever:()=>yx,ZodNonOptional:()=>Dp,ZodNull:()=>px,ZodNullable:()=>Ex,ZodNumber:()=>Va,ZodNumberFormat:()=>os,ZodObject:()=>su,ZodOptional:()=>cu,ZodPipe:()=>lu,ZodPrefault:()=>Ax,ZodPreprocess:()=>Lx,ZodPromise:()=>Bx,ZodReadonly:()=>Fx,ZodRecord:()=>qa,ZodSet:()=>zx,ZodString:()=>La,ZodStringFormat:()=>st,ZodSuccess:()=>Mx,ZodSymbol:()=>dx,ZodTemplateLiteral:()=>Zx,ZodTransform:()=>Px,ZodTuple:()=>_x,ZodType:()=>Fe,ZodULID:()=>xp,ZodURL:()=>ou,ZodUUID:()=>Ar,ZodUndefined:()=>fx,ZodUnion:()=>au,ZodUnknown:()=>gx,ZodVoid:()=>bx,ZodXID:()=>_p,ZodXor:()=>vx,_ZodString:()=>pp,_default:()=>Cx,_function:()=>bP,any:()=>Ap,array:()=>te,base64:()=>AI,base64url:()=>OI,bigint:()=>GI,boolean:()=>$e,catch:()=>qx,check:()=>wP,cidrv4:()=>TI,cidrv6:()=>CI,codec:()=>pP,creditCard:()=>MI,cuid:()=>SI,cuid2:()=>kI,currencyCode:()=>VI,custom:()=>vP,date:()=>tP,describe:()=>$P,discriminatedUnion:()=>Ko,e164:()=>NI,email:()=>gp,emoji:()=>xI,enum:()=>Ce,exactOptional:()=>jx,file:()=>uP,float32:()=>HI,float64:()=>BI,function:()=>bP,guid:()=>gI,hash:()=>ZI,hex:()=>FI,hostname:()=>LI,httpUrl:()=>$I,iban:()=>DI,instanceof:()=>_P,int:()=>dp,int32:()=>WI,int64:()=>KI,intersection:()=>hr,invertCodec:()=>hP,ipv4:()=>PI,ipv6:()=>EI,json:()=>kP,jwt:()=>qI,keyof:()=>nP,ksuid:()=>II,lazy:()=>Yo,literal:()=>ne,looseObject:()=>je,looseRecord:()=>sP,mac:()=>jI,map:()=>aP,meta:()=>xP,nan:()=>fP,nanoid:()=>_I,nativeEnum:()=>lP,never:()=>Op,nonoptional:()=>Nx,null:()=>Or,nullable:()=>ru,nullish:()=>mP,number:()=>me,object:()=>J,optional:()=>ze,partialRecord:()=>iP,pipe:()=>fp,prefault:()=>Ox,preprocess:()=>so,promise:()=>yP,readonly:()=>Vx,record:()=>ve,refine:()=>Jx,set:()=>cP,strictObject:()=>rP,string:()=>j,stringFormat:()=>UI,stringbool:()=>SP,success:()=>dP,superRefine:()=>Gx,symbol:()=>XI,templateLiteral:()=>gP,transform:()=>Np,tuple:()=>Sx,uint32:()=>JI,uint64:()=>YI,ulid:()=>zI,undefined:()=>QI,union:()=>xe,unknown:()=>Re,url:()=>Fa,uuid:()=>yI,uuidv4:()=>bI,uuidv6:()=>wI,uuidv7:()=>vI,void:()=>eP,xid:()=>RI,xor:()=>oP});var up={};eo(up,{endsWith:()=>Ia,gt:()=>Tr,gte:()=>Mn,includes:()=>za,length:()=>Qi,lowercase:()=>Sa,lt:()=>Er,lte:()=>Nn,maxLength:()=>Xi,maxSize:()=>Fo,mime:()=>ja,minLength:()=>oo,minSize:()=>Cr,multipleOf:()=>Lo,negative:()=>np,nonnegative:()=>op,nonpositive:()=>rp,normalize:()=>Ea,overwrite:()=>pr,positive:()=>tp,properties:()=>Pa,property:()=>ip,regex:()=>_a,size:()=>Yi,slugify:()=>Oa,startsWith:()=>Ra,toLowerCase:()=>Ca,toUpperCase:()=>Aa,trim:()=>Ta,uppercase:()=>ka});var pI=new WeakSet([Object.prototype,Error.prototype]);function mp(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var hI=(e,t)=>{Yb.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);pI.has(r)||(pI.add(r),mp(r,"format",o=>n=>Il(o,n)),mp(r,"flatten",o=>n=>Rl(o,n)),mp(r,"addIssue",o=>n=>{o.issues.push(n),o.message=JSON.stringify(o.issues,la,2)}),mp(r,"addIssues",o=>n=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,la,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},$q=G("ZodError",hI),kn=G("ZodError",hI,void 0,{Parent:Error});var X0=pa(kn),Q0=ha(kn),nu=ga(kn),ex=ya(kn),tx=Ud(kn),nx=Ld(kn),rx=Fd(kn),ox=Vd(kn),ix=Zd(kn),sx=Hd(kn),ax=Bd(kn),cx=Wd(kn);function _q(){Nt.localeError||wt(zf())}function ns(){Nt.memoizer||wt({memoizer:Bl()})}var Fe=G("ZodType",(e,t)=>(_q(),Ne.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(oe.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return tt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Jx(e,t))},superRefine(e,t){return this.check(Gx(e,t))},overwrite(e){return this.check(pr(e))},optional(){return ze(this)},exactOptional(){return jx(this)},nullable(){return ru(this)},nullish(){return ze(ru(this))},nonoptional(e){return Nx(this,e)},array(){return te(this)},or(e){return xe([this,e])},and(e){return hr(this,e)},transform(e){return fp(this,Np(e))},default(e){return Cx(this,e)},prefault(e){return Ox(this,e)},catch(e){return qx(this,e)},pipe(e){return fp(this,e)},readonly(){return Vx(this)},describe(e){let t=this.clone();return Zt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Zt.get(this);let t=this.clone();return Zt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return oe.hide(this,"~standard",{...of(this),jsonSchema:{input:Na(this,"input"),output:Na(this,"output")}})},set"~standard"(e){oe.own(this,"~standard",e)},parse:function e(t,r){return X0(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Q0(this,t,r,{callee:e})},safeParse(e,t){return nu(this,e,t)},async safeParseAsync(e,t){return ex(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){oe.own(this,"spa",e)},validate(e,t){return Pl(this,e,t)},validateAsync(e,t){return jl(this,e,t)},encode:function e(t,r){return tx(this,t,r,{callee:e})},decode:function e(t,r){return nx(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await rx(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await ox(this,t,r,{callee:e})},safeEncode(e,t){return ix(this,e,t)},safeDecode(e,t){return sx(this,e,t)},async safeEncodeAsync(e,t){return ax(this,e,t)},async safeDecodeAsync(e,t){return cx(this,e,t)},toJSONSchema(e){return m0(this,{})(e)},get description(){return Zt.get(this)?.description},get _def(){return this._zod.def}}),pp=G("_ZodString",(e,t)=>{Wi.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>p0(e,r,o,n)},oe.derived({format:e=>Et(e).format??null,minLength:e=>Et(e).minimum??null,maxLength:e=>Et(e).maximum??null},{regex(...e){return this.check(_a(...e))},includes(...e){return this.check(za(...e))},startsWith(...e){return this.check(Ra(...e))},endsWith(...e){return this.check(Ia(...e))},min(...e){return this.check(oo(...e))},max(...e){return this.check(Xi(...e))},length(...e){return this.check(Qi(...e))},nonempty(...e){return this.check(oo(1,...e))},lowercase(e){return this.check(Sa(e))},uppercase(e){return this.check(ka(e))},trim(){return this.check(Ta())},normalize(...e){return this.check(Ea(...e))},toLowerCase(){return this.check(Ca())},toUpperCase(){return this.check(Aa())},slugify(){return this.check(Oa())}})),La=G("ZodString",(e,t)=>{Wi.init(e,t),pp.init(e,t)},{email(e){return this.check(Af(hp,e))},url(e){return this.check(Gl(ou,e))},jwt(e){return this.check(ep(Tp,e))},emoji(e){return this.check(Uf(bp,e))},guid(e){return this.check(Of(yp,e))},uuid(e){return this.check(Nf(Ar,e))},uuidv4(e){return this.check(Mf(Ar,e))},uuidv6(e){return this.check(Df(Ar,e))},uuidv7(e){return this.check(qf(Ar,e))},nanoid(e){return this.check(Lf(wp,e))},cuid(e){return this.check(Ff(vp,e))},cuid2(e){return this.check(Vf($p,e))},ulid(e){return this.check(Zf(xp,e))},base64(e){return this.check(Yf(Pp,e))},base64url(e){return this.check(Xf(jp,e))},xid(e){return this.check(Hf(_p,e))},ksuid(e){return this.check(Bf(Sp,e))},ipv4(e){return this.check(Wf(kp,e))},ipv6(e){return this.check(Jf(zp,e))},cidrv4(e){return this.check(Gf(Rp,e))},cidrv6(e){return this.check(Kf(Ip,e))},e164(e){return this.check(Qf(Ep,e))},datetime(e){return this.check(Kl(Bo,e))},date(e){return this.check(Yl(Wo,e))},time(e){return this.check(Xl(Jo,e))},duration(e){return this.check(Ql(Go,e))}});function j(e){return R$(La,e)}var st=G("ZodStringFormat",(e,t)=>{nt.init(e,t),pp.init(e,t)}),Bo=G("ZodISODateTime",(e,t)=>{yv.init(e,t),st.init(e,t)}),Wo=G("ZodISODate",(e,t)=>{bv.init(e,t),st.init(e,t)}),Jo=G("ZodISOTime",(e,t)=>{wv.init(e,t),st.init(e,t)}),Go=G("ZodISODuration",(e,t)=>{vv.init(e,t),st.init(e,t)}),hp=G("ZodEmail",(e,t)=>{sv.init(e,t),st.init(e,t)});function gp(e){return Af(hp,e)}var yp=G("ZodGUID",(e,t)=>{ov.init(e,t),st.init(e,t)});function gI(e){return Of(yp,e)}var Ar=G("ZodUUID",(e,t)=>{iv.init(e,t),st.init(e,t)});function yI(e){return Nf(Ar,e)}function bI(e){return Mf(Ar,e)}function wI(e){return Df(Ar,e)}function vI(e){return qf(Ar,e)}var ou=G("ZodURL",(e,t)=>{lv.init(e,t),st.init(e,t)});function Fa(e){return Gl(ou,e)}function $I(e){return Gl(ou,{protocol:El,hostname:vw,...oe.normalizeParams(e)})}var bp=G("ZodEmoji",(e,t)=>{uv.init(e,t),st.init(e,t)});function xI(e){return Uf(bp,e)}var wp=G("ZodNanoID",(e,t)=>{mv.init(e,t),st.init(e,t)});function _I(e){return Lf(wp,e)}var vp=G("ZodCUID",(e,t)=>{dv.init(e,t),st.init(e,t)});function SI(e){return Ff(vp,e)}var $p=G("ZodCUID2",(e,t)=>{fv.init(e,t),st.init(e,t)});function kI(e){return Vf($p,e)}var xp=G("ZodULID",(e,t)=>{pv.init(e,t),st.init(e,t)});function zI(e){return Zf(xp,e)}var _p=G("ZodXID",(e,t)=>{hv.init(e,t),st.init(e,t)});function RI(e){return Hf(_p,e)}var Sp=G("ZodKSUID",(e,t)=>{gv.init(e,t),st.init(e,t)});function II(e){return Bf(Sp,e)}var kp=G("ZodIPv4",(e,t)=>{$v.init(e,t),st.init(e,t)});function PI(e){return Wf(kp,e)}var lx=G("ZodMAC",(e,t)=>{_v.init(e,t),st.init(e,t)});function jI(e){return P$(lx,e)}var zp=G("ZodIPv6",(e,t)=>{xv.init(e,t),st.init(e,t)});function EI(e){return Jf(zp,e)}var Rp=G("ZodCIDRv4",(e,t)=>{Sv.init(e,t),st.init(e,t)});function TI(e){return Gf(Rp,e)}var Ip=G("ZodCIDRv6",(e,t)=>{kv.init(e,t),st.init(e,t)});function CI(e){return Kf(Ip,e)}var Pp=G("ZodBase64",(e,t)=>{zv.init(e,t),st.init(e,t)});function AI(e){return Yf(Pp,e)}var jp=G("ZodBase64URL",(e,t)=>{Rv.init(e,t),st.init(e,t)});function OI(e){return Xf(jp,e)}var Ep=G("ZodE164",(e,t)=>{Iv.init(e,t),st.init(e,t)});function NI(e){return Qf(Ep,e)}var ux=G("ZodCreditCard",(e,t)=>{Pv.init(e,t),st.init(e,t)});function MI(e){return j$(ux,e)}var mx=G("ZodIBAN",(e,t)=>{jv.init(e,t),st.init(e,t)});function DI(e){return E$(mx,e)}var Tp=G("ZodJWT",(e,t)=>{Ev.init(e,t),st.init(e,t)});function qI(e){return ep(Tp,e)}var rs=G("ZodCustomStringFormat",(e,t)=>{Tv.init(e,t),st.init(e,t)});function UI(e,t,r={}){return es(rs,e,t,r)}function LI(e){return es(rs,"hostname",ww,e)}function FI(e){return es(rs,"hex",Aw,e)}function VI(e){return es(rs,"currency_code",xw,e)}function ZI(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Gn[o];if(!n)throw new Error(`Unrecognized hash format: ${o}`);return es(rs,o,n,t)}var Va=G("ZodNumber",(e,t)=>{hf.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>h0(e,r,o,n),e.isFinite=!0},oe.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Et(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Et(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Et(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Et(e).format??null},{gt(e,t){return this.check(Tr(e,t))},gte(e,t){return this.check(Mn(e,t))},min(e,t){return this.check(Mn(e,t))},lt(e,t){return this.check(Er(e,t))},lte(e,t){return this.check(Nn(e,t))},max(e,t){return this.check(Nn(e,t))},int(e){return this.check(dp(e))},safe(e){return this.check(dp(e))},positive(e){return this.check(Tr(0,e))},nonnegative(e){return this.check(Mn(0,e))},negative(e){return this.check(Er(0,e))},nonpositive(e){return this.check(Nn(0,e))},multipleOf(e,t){return this.check(Lo(e,t))},step(e,t){return this.check(Lo(e,t))},finite(){return this}}));function me(e){return C$(Va,e)}var os=G("ZodNumberFormat",(e,t)=>{Cv.init(e,t),Va.init(e,t)});function dp(e){return O$(os,e)}function HI(e){return N$(os,e)}function BI(e){return M$(os,e)}function WI(e){return D$(os,e)}function JI(e){return q$(os,e)}var Za=G("ZodBoolean",(e,t)=>{Ul.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>g0(e,r,o,n)});function $e(e){return U$(Za,e)}var Ha=G("ZodBigInt",(e,t)=>{gf.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>y0(e,r,o,n)},oe.derived({minValue:e=>Et(e).minimum??null,maxValue:e=>Et(e).maximum??null,format:e=>Et(e).format??null},{gte(e,t){return this.check(Mn(e,t))},min(e,t){return this.check(Mn(e,t))},gt(e,t){return this.check(Tr(e,t))},lt(e,t){return this.check(Er(e,t))},lte(e,t){return this.check(Nn(e,t))},max(e,t){return this.check(Nn(e,t))},positive(e){return this.check(Tr(BigInt(0),e))},negative(e){return this.check(Er(BigInt(0),e))},nonpositive(e){return this.check(Nn(BigInt(0),e))},nonnegative(e){return this.check(Mn(BigInt(0),e))},multipleOf(e,t){return this.check(Lo(e,t))}}));function GI(e){return F$(Ha,e)}var Cp=G("ZodBigIntFormat",(e,t)=>{Av.init(e,t),Ha.init(e,t)});function KI(e){return Z$(Cp,e)}function YI(e){return H$(Cp,e)}var dx=G("ZodSymbol",(e,t)=>{Ov.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>b0(e,r,o,n)});function XI(e){return B$(dx,e)}var fx=G("ZodUndefined",(e,t)=>{Nv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>v0(e,r,o,n)});function QI(e){return W$(fx,e)}var px=G("ZodNull",(e,t)=>{Mv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>w0(e,r,o,n)});function Or(e){return J$(px,e)}var hx=G("ZodAny",(e,t)=>{Dv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>_0(e,r,o,n)});function Ap(){return G$(hx)}var gx=G("ZodUnknown",(e,t)=>{qv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>S0(e,r,o,n)});function Re(){return K$(gx)}var yx=G("ZodNever",(e,t)=>{Uv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>x0(e,r,o,n)});function Op(e){return Y$(yx,e)}var bx=G("ZodVoid",(e,t)=>{Lv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>$0(e,r,o,n)});function eP(e){return X$(bx,e)}var iu=G("ZodDate",(e,t)=>{Fv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>k0(e,r,o,n),e.min=(r,o)=>e.check(Mn(r,o)),e.max=(r,o)=>e.check(Nn(r,o))},oe.derived({minDate:e=>{let{minimum:t}=Et(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=Et(e);return t?new Date(t):null}},{}));function tP(e){return Q$(iu,e)}var wx=G("ZodArray",(e,t)=>{ns(),Zv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>M0(e,r,o,n),e.element=t.element},{min(e,t){return this.check(oo(e,t))},nonempty(e){return this.check(oo(1,e))},max(e,t){return this.check(Xi(e,t))},length(e,t){return this.check(Qi(e,t))},unwrap(){return this.element}});function te(e,t){return n0(wx,e,t)}function nP(e){let t=e._zod.def.shape;return Ce(Object.keys(t))}var su=G("ZodObject",(e,t)=>{ns(),Hv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>D0(e,r,o,n),oe.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Ce(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(oe.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(oe.mergeDefs(this._zod.def,{catchall:Re()}))},loose(){return this.clone(oe.mergeDefs(this._zod.def,{catchall:Re()}))},strict(){return this.clone(oe.mergeDefs(this._zod.def,{catchall:Op()}))},strip(){return this.clone(oe.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return oe.extend(this,e)},safeExtend(e){return oe.safeExtend(this,e)},merge(e){return oe.merge(this,e)},pick(e){return oe.pick(this,e)},omit(e){return oe.omit(this,e)},partial(...e){return oe.partial(cu,this,e[0])},exactPartial(...e){return oe.partial(Mp,this,e[0],"exactPartial")},required(...e){return oe.required(Dp,this,e[0])}});function J(e,t){let r={type:"object",shape:e??{},...oe.normalizeParams(t)};return new su(r)}function rP(e,t){return new su({type:"object",shape:e,catchall:Op(),...oe.normalizeParams(t)})}function je(e,t){return new su({type:"object",shape:e,catchall:Re(),...oe.normalizeParams(t)})}var au=G("ZodUnion",(e,t)=>{Ll.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ap(e,r,o,n),e.options=t.options});function xe(e,t){return new au({type:"union",options:e,...oe.normalizeParams(t)})}var vx=G("ZodXor",(e,t)=>{au.init(e,t),Bv.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ap(e,r,o,n),e.options=t.options});function oP(e,t){return new vx({type:"union",options:e,inclusive:!1,...oe.normalizeParams(t)})}var $x=G("ZodDiscriminatedUnion",(e,t)=>{au.init(e,t),Jv.init(e,t)});function Ko(e,t,r){return new $x({type:"union",options:t,discriminator:e,...oe.normalizeParams(r)})}var xx=G("ZodIntersection",(e,t)=>{Gv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>q0(e,r,o,n)});function hr(e,t){return new xx({type:"intersection",left:e,right:t})}var _x=G("ZodTuple",(e,t)=>{ns(),yf.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>U0(e,r,o,n)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new cu({type:"optional",innerType:t}))})}});function Sx(e,t,r){let o=t instanceof Ne,n=o?r:t,i=o?t:null;return new _x({type:"tuple",items:e,rest:i,...oe.normalizeParams(n)})}var qa=G("ZodRecord",(e,t)=>{ns(),Kv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>L0(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function ve(e,t,r){return!t||!t._zod?new qa({type:"record",keyType:j(),valueType:e,...oe.normalizeParams(t)}):new qa({type:"record",keyType:e,valueType:t,...oe.normalizeParams(r)})}function iP(e,t,r){return new qa({type:"record",keyType:e,valueType:t,...oe.normalizeParams(r),partial:!0})}function sP(e,t,r){return new qa({type:"record",keyType:e,valueType:t,mode:"loose",...oe.normalizeParams(r)})}var kx=G("ZodMap",(e,t)=>{ns(),Yv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>O0(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Cr(...r)),e.nonempty=r=>e.check(Cr(1,r)),e.max=(...r)=>e.check(Fo(...r)),e.size=(...r)=>e.check(Yi(...r))});function aP(e,t,r){return new kx({type:"map",keyType:e,valueType:t,...oe.normalizeParams(r)})}var zx=G("ZodSet",(e,t)=>{ns(),Xv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>N0(e,r,o,n),e.min=(...r)=>e.check(Cr(...r)),e.nonempty=r=>e.check(Cr(1,r)),e.max=(...r)=>e.check(Fo(...r)),e.size=(...r)=>e.check(Yi(...r))});function cP(e,t){return new zx({type:"set",valueType:e,...oe.normalizeParams(t)})}var Ua=G("ZodEnum",(e,t)=>{Qv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(o,n,i)=>z0(e,o,n,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let s of o)if(r.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Ua({...t,checks:[],...oe.normalizeParams(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let s of o)if(r.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Ua({...t,checks:[],...oe.normalizeParams(n),entries:i})}});function Ce(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new Ua({type:"enum",entries:r,...oe.normalizeParams(t)})}function lP(e,t){return new Ua({type:"enum",entries:e,...oe.normalizeParams(t)})}var Rx=G("ZodLiteral",(e,t)=>{e$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>R0(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ne(e,t){return new Rx({type:"literal",values:Array.isArray(e)?e:[e],...oe.normalizeParams(t)})}var Ix=G("ZodFile",(e,t)=>{t$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>j0(e,r,o,n),e.min=(r,o)=>e.check(Cr(r,o)),e.max=(r,o)=>e.check(Fo(r,o)),e.mime=(r,o)=>e.check(ja(Array.isArray(r)?r:[r],o))});function uP(e){return r0(Ix,e)}var Px=G("ZodTransform",(e,t)=>{ns(),n$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>A0(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new qo(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(oe.issue(i,r.value,t));else{let s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=r.value),s.inst??(s.inst=e),r.issues.push(oe.issue(s))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function Np(e){return new Px({type:"transform",transform:e})}var cu=G("ZodOptional",(e,t)=>{bf.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>cp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ze(e){return new cu({type:"optional",innerType:e})}var Mp=G("ZodExactOptional",(e,t)=>{r$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>cp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function jx(e){return new Mp({type:"optional",innerType:e})}var Ex=G("ZodNullable",(e,t)=>{o$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>F0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ru(e){return new Ex({type:"nullable",innerType:e})}function mP(e){return ze(ru(e))}var Tx=G("ZodDefault",(e,t)=>{i$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>H0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Cx(e,t){return new Tx({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():oe.shallowClone(t)}})}var Ax=G("ZodPrefault",(e,t)=>{s$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>B0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Ox(e,t){return new Ax({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():oe.shallowClone(t)}})}var Dp=G("ZodNonOptional",(e,t)=>{a$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>V0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Nx(e,t){return new Dp({type:"nonoptional",innerType:e,...oe.normalizeParams(t)})}var Mx=G("ZodSuccess",(e,t)=>{c$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>E0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function dP(e){return new Mx({type:"success",innerType:e})}var Dx=G("ZodCatch",(e,t)=>{l$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>W0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qx(e,t){return new Dx({type:"catch",innerType:e,catchValue:typeof t=="function"?t:oe.constantCatch(t)})}var Ux=G("ZodNaN",(e,t)=>{u$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>I0(e,r,o,n)});function fP(e){return t0(Ux,e)}var lu=G("ZodPipe",(e,t)=>{wf.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>J0(e,r,o,n),e.in=t.in,e.out=t.out});function fp(e,t){return new lu({type:"pipe",in:e,out:t})}var uu=G("ZodCodec",(e,t)=>{lu.init(e,t),Fl.init(e,t)});function pP(e,t,r){return new uu({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function hP(e){let t=e._zod.def;return new uu({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var Lx=G("ZodPreprocess",(e,t)=>{lu.init(e,t),m$.init(e,t)}),Fx=G("ZodReadonly",(e,t)=>{d$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>G0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Vx(e){return new Fx({type:"readonly",innerType:e})}var Zx=G("ZodTemplateLiteral",(e,t)=>{f$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>P0(e,r,o,n)});function gP(e,t){return new Zx({type:"template_literal",parts:e,...oe.normalizeParams(t)})}var Hx=G("ZodLazy",(e,t)=>{Vl.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Y0(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});function Yo(e){return new Hx({type:"lazy",getter:e})}var Bx=G("ZodPromise",(e,t)=>{h$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>K0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function yP(e){return new Bx({type:"promise",innerType:e})}var Wx=G("ZodFunction",(e,t)=>{p$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>C0(e,r,o,n)});function bP(e){return new Wx({type:"function",input:Array.isArray(e?.input)?Sx(e?.input):e?.input??te(Re()),output:e?.output??Re()})}var mu=G("ZodCustom",(e,t)=>{g$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>T0(e,r,o,n)});function wP(e){let t=new lt({check:"custom"});return t._zod.check=e,t}function vP(e,t){return o0(mu,e??(()=>!0),t)}function Jx(e,t={}){return i0(mu,e,t)}function Gx(e,t){return s0(e,t)}var $P=a0,xP=c0,Kx=G("ZodInstanceOf",(e,t)=>{mu.init(e,t)},{properties(e,t){return this.check(Pa(e,t))}});function _P(e,t={}){let r=new Kx({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...oe.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=o=>{o.value instanceof e||o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}var SP=(...e)=>l0({Codec:uu,Boolean:Za,String:La},...e);function kP(e){let t=Yo(()=>xe([j(e),me(),$e(),Or(),te(t),ve(j(),t)]));return t}function so(e,t){return new Lx({type:"pipe",in:Np(e),out:t})}var Xx={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Sq(e){wt({customError:e})}function kq(){return wt().customError}var Yx;Yx||(Yx={});var Kn={};eo(Kn,{ZodISODate:()=>Wo,ZodISODateTime:()=>Bo,ZodISODuration:()=>Go,ZodISOTime:()=>Jo,date:()=>Rq,datetime:()=>zq,duration:()=>Pq,time:()=>Iq});function zq(e){return Kl(Bo,e)}function Rq(e){return Yl(Wo,e)}function Iq(e){return Xl(Jo,e)}function Pq(e){return Ql(Go,e)}var _e={...Ba,...up,iso:Kn},jq=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function Eq(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function zP(e,t){return e.map((r,o)=>o<t?r:r.optional())}function Tq(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Cq(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1]===void 0?void 0:Tq(r[1]);if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function Aq(e,t){return _e.transform(o=>o).check(o=>{let n=o.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let i=Object.getOwnPropertyNames(n);if(t.minProperties!==void 0&&i.length<t.minProperties&&o.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:n,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&o.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:n,inst:e,continue:!0}),t.keySchema)for(let s of i){let a=t.keySchema.safeParse(s);a.success||o.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:s,path:[s],continue:!0})}}).pipe(e)}function Qx(e,t){if(e===null)return"z";let r=typeof e;if(r!=="object"){if(r==="number"&&Number.isNaN(e))return null;let o=String(e);return`${r[0]}${o.length}:${o}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let i=[];for(let s of e){let a=Qx(s,t);if(a===null)return null;i.push(a)}return`a${i.length}:[${i.join(",")}]`}let o=Object.keys(e).sort(),n=[];for(let i of o){let s=Qx(e[i],t);if(s===null)return null;n.push(`${i.length}:${i}=${s}`)}return`o${n.length}:{${n.join(",")}}`}finally{t.delete(e)}}var Oq=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),Nq=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function du(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(du):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,r])=>Oq.has(t)?du(r):!Nq.has(t)||typeof r!="object"||r===null?!1:Object.values(r).some(du))}function RP(e){return e===1?"element":"elements"}function Mq(e,t){return _e.transform(o=>o).check(o=>{let n=o.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let i=new Map;for(let s=0;s<n.length;s++){let a=Qx(n[s],new Set);if(a===null)continue;let c=i.get(a);if(c===void 0){i.set(a,s);continue}o.issues.push({code:"custom",message:`Array items must be unique: element at index ${s} duplicates the one at index ${c}`,input:n,path:[s],continue:!0})}}if(t.containsSchema){let i=t.minContains??1,s=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,a=0;for(let c of n)if(t.containsSchema.safeParse(c).success&&++a>=s)break;a<i&&o.issues.push({code:"custom",message:`Array must contain at least ${i} matching ${RP(i)}; found ${a}`,input:n,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&o.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${RP(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function IP(e,t){if(e!==!1)return e===void 0||e===!0?_e.any():fn(e,t)}var Dq=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function PP(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return _e.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return _e.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=Cq(n,t),s=fn(i,t);return t.refs.set(n,s),t.processing.delete(n),s}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return _e.null();if(n.length===0)return _e.never();if(n.length===1)return _e.literal(n[0]);if(n.every(s=>typeof s=="string"))return _e.enum(n);let i=n.map(s=>_e.literal(s));return i.length<2?i[0]:_e.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return _e.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(i=>{let s={...e,type:i};return PP(s,t)});return n.length===0?_e.never():n.length===1?n[0]:_e.union(n)}if(!r)return _e.any();let o;switch(r){case"string":{let n=_e.string();if(e.format){let i=e.format;i==="email"?n=n.check(_e.email()):i==="uri"||i==="uri-reference"?n=n.check(_e.url()):i==="uuid"||i==="guid"?n=n.check(_e.uuid()):i==="date-time"?n=n.check(_e.iso.datetime({offset:!0})):i==="date"?n=n.check(_e.iso.date()):i==="time"?n=n.check(_e.regex(Dq)):i==="duration"?n=n.check(_e.iso.duration()):i==="hostname"?n=n.check(_e.hostname()):i==="ipv4"?n=n.check(_e.ipv4()):i==="ipv6"?n=n.check(_e.ipv6()):i==="mac"?n=n.check(_e.mac()):i==="cidr"?n=n.check(_e.cidrv4()):i==="cidr-v6"?n=n.check(_e.cidrv6()):i==="base64"?n=n.check(_e.base64()):i==="base64url"?n=n.check(_e.base64url()):i==="e164"?n=n.check(_e.e164()):i==="credit_card"?n=n.check(_e.creditCard()):i==="iban"?n=n.check(_e.iban()):i==="jwt"?n=n.check(_e.jwt()):i==="emoji"?n=n.check(_e.emoji()):i==="nanoid"?n=n.check(_e.nanoid()):i==="cuid"?n=n.check(_e.cuid()):i==="cuid2"?n=n.check(_e.cuid2()):i==="ulid"?n=n.check(_e.ulid()):i==="xid"?n=n.check(_e.xid()):i==="ksuid"&&(n=n.check(_e.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),o=n;break}case"number":case"integer":{let n=r==="integer"?_e.number().int():_e.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),o=n;break}case"boolean":{o=_e.boolean();break}case"null":{o=_e.null();break}case"object":{let n={},i=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?fn(e.additionalProperties,t):void 0;for(let[m,d]of Object.entries(i)){let f=fn(d,t);Vt(n,m,s.has(m)?f:f.optional())}if(e.patternProperties){let m=e.patternProperties,d=Object.keys(m),f=[];for(let h of d){let g=fn(m[h],t),b=_e.string().regex(new RegExp(h));f.push(_e.looseRecord(b,g))}let p=[];if(Object.keys(n).length>0&&p.push(_e.object(n).passthrough()),p.push(...f),p.length===0)o=_e.object({}).passthrough();else if(p.length===1)o=p[0];else{let h=_e.intersection(p[0],p[1]);for(let g=2;g<p.length;g++)h=_e.intersection(h,p[g]);o=h}if(e.additionalProperties===!1){let h=Object.keys(n),g=d.map(y=>new RegExp(y)),b=o;o=o.check(y=>{if(!Wn(y.value))return;let w=[];for(let v of Object.keys(y.value))h.includes(v)||g.some(S=>S.test(v))||w.push(v);w.length&&y.issues.push({code:"unrecognized_keys",keys:w,input:y.value,inst:b})})}}else{let m=_e.object(n);e.additionalProperties===!1?o=m.strict():a?o=m.catchall(a):o=m.passthrough()}let c=e.propertyNames!==void 0&&e.propertyNames!==!0,l=typeof e.minProperties=="number"?e.minProperties:void 0,u=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||l!==void 0||u!==void 0){let m;if(c){let d=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;m=fn(d,t)}o=Aq(o,{keySchema:m,minProperties:l,maxProperties:u})}break}case"array":{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let s=typeof e.minItems=="number"?e.minItems:0,a=n.map(m=>fn(m,t)),c=zP(a,s),l=Array.isArray(i)?void 0:IP(i,t),u=_e.tuple(c);o=l?u.rest(l):u,typeof e.minItems=="number"&&(o=o.check(_e.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(_e.maxLength(e.maxItems)))}else if(Array.isArray(i)){let s=typeof e.minItems=="number"?e.minItems:0,a=i.map(m=>fn(m,t)),c=zP(a,s),l=IP(e.additionalItems,t),u=_e.tuple(c);o=l?u.rest(l):u,typeof e.minItems=="number"&&(o=o.check(_e.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(_e.maxLength(e.maxItems)))}else if(i!==void 0){let s=fn(i,t),a=_e.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),o=a}else o=_e.array(_e.any());(e.uniqueItems===!0||e.contains!==void 0)&&(o=Mq(o,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?fn(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return o}function fn(e,t){if(typeof e=="boolean")return e?_e.any():_e.never();let r=PP(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(l=>fn(l,t)),c=_e.union(a);r=o?_e.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(l=>fn(l,t)),c=_e.xor(a);r=o?_e.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:_e.any();else{let a=o?r:fn(e.allOf[0],t),c=o?0:1;for(let l=c;l<e.allOf.length;l++)a=_e.intersection(a,fn(e.allOf[l],t));r=a}e.nullable===!0&&t.version==="openapi-3.0"&&(r=_e.nullable(r)),e.readOnly===!0&&(r=_e.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of i)a in e&&(n[a]=e[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in e&&(n[a]=e[a]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!du(e.propertyNames)&&(n.propertyNames=e.propertyNames);for(let a of["minProperties","maxProperties"])e[a]!==void 0&&(n[a]=e[a])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!du(e.contains)&&(n.contains=e.contains);for(let a of["uniqueItems","minContains","maxContains"])e[a]!==void 0&&(n[a]=e[a])}for(let a of Object.keys(e))jq.has(a)||Vt(n,a,e[a]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function jP(e,t){if(typeof e=="boolean")return e?_e.any():_e.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=Eq(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Zt};return fn(r,i)}var EP=Symbol("z.visit/resolving");function fu(e,t){let r=typeof t=="function"?t:(s,a)=>{let c=t[s._zod.def.type];return c?c(s,a):s},o=new Map;function n(s){let a=o.get(s);if(a===EP)return new Vl({type:"lazy",getter:()=>o.get(s)});if(a!==void 0)return a;o.set(s,EP);let c=i(s),l=r(c,c!==s);return o.set(s,l),l}function i(s){let a=s._zod.def,c=a.type;switch(c){case"object":{let l=a.shape,u=Object.keys(l),m=!1,d={};for(let p of u){let h=n(l[p]);h!==l[p]&&(m=!0),d[p]=h}let f=a.catchall;return a.catchall&&(f=n(a.catchall),f!==a.catchall&&(m=!0)),m?tt(s,{...a,shape:d,catchall:f}):s}case"array":{let l=n(a.element);return l===a.element?s:tt(s,{...a,element:l})}case"tuple":{let l=a.items,u=!1,m=[];for(let f of l){let p=n(f);p!==f&&(u=!0),m.push(p)}let d=a.rest;return a.rest&&(d=n(a.rest),d!==a.rest&&(u=!0)),u?tt(s,{...a,items:m,rest:d}):s}case"record":case"map":{let l=n(a.keyType),u=n(a.valueType);return l===a.keyType&&u===a.valueType?s:tt(s,{...a,keyType:l,valueType:u})}case"set":{let l=n(a.valueType);return l===a.valueType?s:tt(s,{...a,valueType:l})}case"union":{let l=a.options,u=!1,m=[];for(let d of l){let f=n(d);f!==d&&(u=!0),m.push(f)}return u?tt(s,{...a,options:m}):s}case"intersection":{let l=n(a.left),u=n(a.right);return l===a.left&&u===a.right?s:tt(s,{...a,left:l,right:u})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let l=n(a.innerType);return l===a.innerType?s:tt(s,{...a,innerType:l})}case"pipe":{let l=n(a.in),u=n(a.out);return l===a.in&&u===a.out?s:tt(s,{...a,in:l,out:u})}case"function":{let l=n(a.input),u=n(a.output);return l===a.input&&u===a.output?s:tt(s,{...a,input:l,output:u})}case"lazy":{let l=a.getter,{_cachedInner:u,...m}=a;return tt(s,{...m,getter:()=>n(l())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return s;default:return s}}return n(e)}function TP(e){return fu(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:xe(r.options)}})}function qq(e,t){if(!t?.length)return e;let r=e._zod.def;return tt(e,dr(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function CP(e){return qq(e.out,e.checks)}function Uq(e){return e.in._zod.traits.has("$ZodTransform")?CP(e):e.in}function AP(e){return fu(e,{pipe:t=>Uq(t._zod.def),default:(t,r)=>r?ze(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function OP(e){return fu(e,{pipe:t=>CP(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var pu={};eo(pu,{bigint:()=>Zq,boolean:()=>Vq,date:()=>Hq,number:()=>Fq,string:()=>Lq});function Lq(e){return I$(La,e)}function Fq(e){return A$(Va,e)}function Vq(e){return L$(Za,e)}function Zq(e){return V$(Ha,e)}function Hq(e){return e0(iu,e)}var ss="2025-11-25",qp="2025-03-26",hu=[ss,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Up="io.modelcontextprotocol/related-task",Yn="io.modelcontextprotocol/protocolVersion",as="io.modelcontextprotocol/clientInfo",gr="io.modelcontextprotocol/serverInfo",Nr="io.modelcontextprotocol/clientCapabilities",Qo="io.modelcontextprotocol/subscriptionId",ei="io.modelcontextprotocol/logLevel";var cs="2.0";var Xo=Yo(()=>xe([j(),me(),$e(),Or(),ve(j(),Xo),te(Xo)])),vt=ve(j(),Xo),e_=te(Xo),gu=xe([j(),me().int()]),yu=j(),Lp=J({ttl:me().optional()}),Fp=J({taskId:j()}),bu=je({progressToken:gu.optional(),[Up]:Fp.optional()}),Mt=J({_meta:bu.optional()}),ls=Mt.extend({task:Lp.optional()}),$t=J({method:j(),params:Mt.loose().optional()}),Qt=J({_meta:bu.optional()}),en=J({method:j(),params:Qt.loose().optional()}),wu=je({get[gr](){return Ga.optional().catch(void 0)}}),xt=je({_meta:wu.optional()}),ti=xe([j(),me().int()]),vu=J({jsonrpc:ne(cs),id:ti,...$t.shape}).strict(),$u=J({jsonrpc:ne(cs),...en.shape}).strict(),Wa=J({jsonrpc:ne(cs),id:ti,result:xt}).strict(),Ja=J({jsonrpc:ne(cs),id:ti.optional(),error:J({code:me().int(),message:j(),data:Re().optional()})}).strict(),us=xe([vu,$u,Wa,Ja]),t_=xe([Wa,Ja]),xu=xt.strict(),Vp=Qt.extend({requestId:ti.optional(),reason:j().optional()}),_u=en.extend({method:ne("notifications/cancelled"),params:Vp}),Zp=J({src:j(),mimeType:j().optional(),sizes:te(j()).optional(),theme:Ce(["light","dark"]).optional()}),ni=J({icons:te(Zp).optional()}),ao=J({name:j(),title:j().optional()}),Ga=ao.extend({...ao.shape,...ni.shape,version:j(),websiteUrl:j().optional(),description:j().optional()}),Bq=hr(J({applyDefaults:$e().optional()}),vt),Wq=so(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,hr(J({form:Bq.optional(),url:vt.optional()}),vt.optional())),Hp=je({list:vt.optional(),cancel:vt.optional(),requests:je({sampling:je({createMessage:vt.optional()}).optional(),elicitation:je({create:vt.optional()}).optional()}).optional()}),Bp=je({list:vt.optional(),cancel:vt.optional(),requests:je({tools:je({call:vt.optional()}).optional()}).optional()}),Wp=J({experimental:ve(j(),vt).optional(),sampling:J({context:vt.optional(),tools:vt.optional()}).optional(),elicitation:Wq.optional(),roots:J({listChanged:$e().optional()}).optional(),tasks:Hp.optional(),extensions:ve(j(),vt).optional()}),Jp=Mt.extend({protocolVersion:j(),capabilities:Wp,clientInfo:Ga}),Su=$t.extend({method:ne("initialize"),params:Jp}),ku=J({experimental:ve(j(),vt).optional(),logging:vt.optional(),completions:vt.optional(),prompts:J({listChanged:$e().optional()}).optional(),resources:J({subscribe:$e().optional(),listChanged:$e().optional()}).optional(),tools:J({listChanged:$e().optional()}).optional(),tasks:Bp.optional(),extensions:ve(j(),vt).optional()}),Gp=xt.extend({protocolVersion:j(),capabilities:ku,serverInfo:Ga,instructions:j().optional()}),Kp=en.extend({method:ne("notifications/initialized"),params:Qt.optional()}),Yp=$t.extend({method:ne("server/discover"),params:Mt.optional()}),Xp=xt.extend({supportedVersions:te(j()),capabilities:ku,instructions:j().optional()}),zu=$t.extend({method:ne("ping"),params:Mt.optional()}),Qp=J({progress:me(),total:ze(me()),message:ze(j())}),eh=J({...Qt.shape,...Qp.shape,progressToken:gu}),Ru=en.extend({method:ne("notifications/progress"),params:eh}),th=Mt.extend({cursor:yu.optional()}),ri=$t.extend({params:th.optional()}),oi=xt.extend({nextCursor:yu.optional()}),Iu=J({uri:j(),mimeType:ze(j()),_meta:ve(j(),Re()).optional()}),Pu=Iu.extend({text:j()}),n_=j().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ju=Iu.extend({blob:n_}),ii=Ce(["user","assistant"]),co=J({audience:te(ii).optional(),priority:me().min(0).max(1).optional(),lastModified:Kn.datetime({offset:!0}).optional()}),Eu=J({...ao.shape,...ni.shape,uri:j(),description:ze(j()),mimeType:ze(j()),size:ze(me()),annotations:co.optional(),_meta:ze(je({}))}),nh=J({...ao.shape,...ni.shape,uriTemplate:j(),description:ze(j()),mimeType:ze(j()),annotations:co.optional(),_meta:ze(je({}))}),rh=ri.extend({method:ne("resources/list")}),oh=oi.extend({resources:te(Eu)}),ih=ri.extend({method:ne("resources/templates/list")}),sh=oi.extend({resourceTemplates:te(nh)}),Ka=Mt.extend({uri:j()}),ah=Ka,ch=$t.extend({method:ne("resources/read"),params:ah}),lh=xt.extend({contents:te(xe([Pu,ju]))}),uh=en.extend({method:ne("notifications/resources/list_changed"),params:Qt.optional()}),mh=Ka,dh=$t.extend({method:ne("resources/subscribe"),params:mh}),fh=Ka,ph=$t.extend({method:ne("resources/unsubscribe"),params:fh}),Tu=J({toolsListChanged:$e().optional(),promptsListChanged:$e().optional(),resourcesListChanged:$e().optional(),resourceSubscriptions:te(j()).optional()}),hh=Mt.extend({notifications:Tu}),gh=$t.extend({method:ne("subscriptions/listen"),params:hh}),yh=Qt.extend({notifications:Tu}),bh=en.extend({method:ne("notifications/subscriptions/acknowledged"),params:yh}),wh=wu.extend({[Qo]:ti}),vh=xt.extend({_meta:wh}),$h=Qt.extend({uri:j()}),xh=en.extend({method:ne("notifications/resources/updated"),params:$h}),_h=J({name:j(),description:ze(j()),required:ze($e())}),Sh=J({...ao.shape,...ni.shape,description:ze(j()),arguments:ze(te(_h)),_meta:ze(je({}))}),kh=ri.extend({method:ne("prompts/list")}),zh=oi.extend({prompts:te(Sh)}),Rh=Mt.extend({name:j(),arguments:ve(j(),j()).optional()}),Ih=$t.extend({method:ne("prompts/get"),params:Rh}),Ya=J({type:ne("text"),text:j(),annotations:co.optional(),_meta:ve(j(),Re()).optional()}),Xa=J({type:ne("image"),data:n_,mimeType:j(),annotations:co.optional(),_meta:ve(j(),Re()).optional()}),Qa=J({type:ne("audio"),data:n_,mimeType:j(),annotations:co.optional(),_meta:ve(j(),Re()).optional()}),Ph=J({type:ne("tool_use"),name:j(),id:j(),input:ve(j(),Re()),_meta:ve(j(),Re()).optional()}),jh=J({type:ne("resource"),resource:xe([Pu,ju]),annotations:co.optional(),_meta:ve(j(),Re()).optional()}),Eh=Eu.extend({type:ne("resource_link")}),ec=xe([Ya,Xa,Qa,Eh,jh]),Th=J({role:ii,content:ec}),Ch=xt.extend({description:j().optional(),messages:te(Th)}),Ah=en.extend({method:ne("notifications/prompts/list_changed"),params:Qt.optional()}),Oh=J({title:j().optional(),readOnlyHint:$e().optional(),destructiveHint:$e().optional(),idempotentHint:$e().optional(),openWorldHint:$e().optional()}),Nh=J({taskSupport:Ce(["required","optional","forbidden"]).optional()}),Cu=J({...ao.shape,...ni.shape,description:j().optional(),inputSchema:J({type:ne("object"),properties:ve(j(),Xo).optional(),required:te(j()).optional()}).catchall(Re()),outputSchema:je({$schema:j().optional()}).optional(),annotations:Oh.optional(),execution:Nh.optional(),_meta:ve(j(),Re()).optional()}),Mh=ri.extend({method:ne("tools/list")}),Dh=oi.extend({tools:te(Cu)}),Au=xt.extend({content:te(ec).default([]),structuredContent:Re().optional(),isError:$e().optional()}),r_=Au.or(xt.extend({toolResult:Re()})),qh=ls.extend({name:j(),arguments:ve(j(),Re()).optional()}),Uh=$t.extend({method:ne("tools/call"),params:qh}),Lh=en.extend({method:ne("notifications/tools/list_changed"),params:Qt.optional()}),o_=J({autoRefresh:$e().default(!0),debounceMs:me().int().nonnegative().default(300)}),si=Ce(["debug","info","notice","warning","error","critical","alert","emergency"]),Fh=Mt.extend({level:si}),Vh=$t.extend({method:ne("logging/setLevel"),params:Fh}),Zh=Qt.extend({level:si,logger:j().optional(),data:Re()}),Hh=en.extend({method:ne("notifications/message"),params:Zh}),Bh=J({name:j().optional()}),Wh=J({hints:te(Bh).optional(),costPriority:me().min(0).max(1).optional(),speedPriority:me().min(0).max(1).optional(),intelligencePriority:me().min(0).max(1).optional()}),Jh=J({mode:Ce(["auto","required","none"]).optional()}),Gh=J({type:ne("tool_result"),toolUseId:j().describe("The unique identifier for the corresponding tool call."),content:te(ec),structuredContent:Re().optional(),isError:$e().optional(),_meta:ve(j(),Re()).optional()}),Kh=Ko("type",[Ya,Xa,Qa]),is=Ko("type",[Ya,Xa,Qa,Ph,Gh]),Yh=J({role:ii,content:xe([is,te(is)]),_meta:ve(j(),Re()).optional()}),Xh=ls.extend({messages:te(Yh),modelPreferences:Wh.optional(),systemPrompt:j().optional(),includeContext:Ce(["none","thisServer","allServers"]).optional(),temperature:me().optional(),maxTokens:me().int(),stopSequences:te(j()).optional(),metadata:vt.optional(),tools:te(Cu).optional(),toolChoice:Jh.optional()}),Qh=$t.extend({method:ne("sampling/createMessage"),params:Xh}),eg=xt.extend({model:j(),stopReason:ze(Ce(["endTurn","stopSequence","maxTokens"]).or(j())),role:ii,content:Kh}),tg=xt.extend({model:j(),stopReason:ze(Ce(["endTurn","stopSequence","maxTokens","toolUse"]).or(j())),role:ii,content:xe([is,te(is)])}),Ou=J({type:ne("boolean"),title:j().optional(),description:j().optional(),default:$e().optional()}),tc=J({type:ne("string"),title:j().optional(),description:j().optional(),minLength:me().optional(),maxLength:me().optional(),format:Ce(["email","uri","date","date-time"]).optional(),default:j().optional()}),nc=J({type:Ce(["number","integer"]),title:j().optional(),description:j().optional(),minimum:me().optional(),maximum:me().optional(),default:me().optional()}),Nu=J({type:ne("string"),title:j().optional(),description:j().optional(),enum:te(j()),default:j().optional()}),Mu=J({type:ne("string"),title:j().optional(),description:j().optional(),oneOf:te(J({const:j(),title:j()})),default:j().optional()}),Du=J({type:ne("string"),title:j().optional(),description:j().optional(),enum:te(j()),enumNames:te(j()).optional(),default:j().optional()}),ng=xe([Nu,Mu]),qu=J({type:ne("array"),title:j().optional(),description:j().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({type:ne("string"),enum:te(j())}),default:te(j()).optional()}),Uu=J({type:ne("array"),title:j().optional(),description:j().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({anyOf:te(J({const:j(),title:j()}))}),default:te(j()).optional()}),rg=xe([qu,Uu]),og=xe([Du,ng,rg]),Lu=xe([og,Ou,tc,nc]),rc=ls.extend({mode:ne("form").optional(),message:j(),requestedSchema:J({type:ne("object"),properties:ve(j(),Lu),required:te(j()).optional()}).catchall(Re())}),ig=ls.extend({mode:ne("url"),message:j(),elicitationId:j(),url:j().url()}),sg=xe([rc,ig]),ag=$t.extend({method:ne("elicitation/create"),params:sg}),cg=Qt.extend({elicitationId:j()}),lg=en.extend({method:ne("notifications/elicitation/complete"),params:cg}),ug=xt.extend({action:Ce(["accept","decline","cancel"]),content:so(e=>e===null?void 0:e,ve(j(),xe([j(),me(),$e(),te(j())])).optional())}),mg=J({type:ne("ref/resource"),uri:j()}),dg=J({type:ne("ref/prompt"),name:j()}),fg=Mt.extend({ref:xe([dg,mg]),argument:J({name:j(),value:j()}),context:J({arguments:ve(j(),j()).optional()}).optional()}),pg=$t.extend({method:ne("completion/complete"),params:fg}),hg=xt.extend({completion:je({values:te(j()).max(100),total:ze(me().int()),hasMore:ze($e())})}),gg=J({uri:j().startsWith("file://"),name:j().optional(),_meta:ve(j(),Re()).optional()}),yg=$t.extend({method:ne("roots/list"),params:Mt.optional()}),bg=xt.extend({roots:te(gg)}),wg=en.extend({method:ne("notifications/roots/list_changed"),params:Qt.optional()}),i_=je({ttl:me().optional(),pollInterval:me().optional()}),vg=Ce(["working","input_required","completed","failed","cancelled"]),ai=J({taskId:j(),status:vg,ttl:xe([me(),Or()]),createdAt:j(),lastUpdatedAt:j(),pollInterval:ze(me()),statusMessage:ze(j())}),s_=xt.extend({task:ai}),$g=Qt.merge(ai),a_=en.extend({method:ne("notifications/tasks/status"),params:$g}),c_=$t.extend({method:ne("tasks/get"),params:Mt.extend({taskId:j()})}),l_=xt.merge(ai),u_=$t.extend({method:ne("tasks/result"),params:Mt.extend({taskId:j()})}),m_=xt.loose(),d_=ri.extend({method:ne("tasks/list")}),f_=oi.extend({tasks:te(ai)}),p_=$t.extend({method:ne("tasks/cancel"),params:Mt.extend({taskId:j()})}),h_=xt.merge(ai),g_=xe([zu,Su,Yp,pg,Vh,Ih,kh,rh,ih,ch,dh,ph,gh,Uh,Mh]),y_=xe([_u,Ru,Kp,wg]),b_=xe([xu,eg,tg,ug,bg]),w_=xe([zu,Qh,ag,yg]),v_=xe([_u,Ru,Hh,xh,uh,Lh,Ah,bh,lg]),$_=xe([xu,Gp,Xp,hg,Ch,zh,oh,sh,lh,Au,Dh,vh]);var Dt=Fa().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Xx.custom,message:"URL must be parseable",fatal:!0}),zl}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),__=je({resource:j().url(),authorization_servers:te(Dt).optional(),jwks_uri:j().url().optional(),scopes_supported:te(j()).optional(),bearer_methods_supported:te(j()).optional(),resource_signing_alg_values_supported:te(j()).optional(),resource_name:j().optional(),resource_documentation:j().optional(),resource_policy_uri:j().url().optional(),resource_tos_uri:j().url().optional(),tls_client_certificate_bound_access_tokens:$e().optional(),authorization_details_types_supported:te(j()).optional(),dpop_signing_alg_values_supported:te(j()).optional(),dpop_bound_access_tokens_required:$e().optional()}),xg=je({issuer:j(),authorization_endpoint:Dt,token_endpoint:Dt,registration_endpoint:Dt.optional(),scopes_supported:te(j()).optional(),response_types_supported:te(j()),response_modes_supported:te(j()).optional(),grant_types_supported:te(j()).optional(),token_endpoint_auth_methods_supported:te(j()).optional(),token_endpoint_auth_signing_alg_values_supported:te(j()).optional(),service_documentation:Dt.optional(),revocation_endpoint:Dt.optional(),revocation_endpoint_auth_methods_supported:te(j()).optional(),revocation_endpoint_auth_signing_alg_values_supported:te(j()).optional(),introspection_endpoint:j().optional(),introspection_endpoint_auth_methods_supported:te(j()).optional(),introspection_endpoint_auth_signing_alg_values_supported:te(j()).optional(),code_challenge_methods_supported:te(j()).optional(),client_id_metadata_document_supported:$e().optional(),authorization_response_iss_parameter_supported:$e().optional().catch(void 0),dpop_signing_alg_values_supported:te(j()).optional()}),_g=je({issuer:j(),authorization_endpoint:Dt,token_endpoint:Dt,userinfo_endpoint:Dt.optional(),jwks_uri:Dt,registration_endpoint:Dt.optional(),scopes_supported:te(j()).optional(),response_types_supported:te(j()),response_modes_supported:te(j()).optional(),grant_types_supported:te(j()).optional(),acr_values_supported:te(j()).optional(),subject_types_supported:te(j()),id_token_signing_alg_values_supported:te(j()),id_token_encryption_alg_values_supported:te(j()).optional(),id_token_encryption_enc_values_supported:te(j()).optional(),userinfo_signing_alg_values_supported:te(j()).optional(),userinfo_encryption_alg_values_supported:te(j()).optional(),userinfo_encryption_enc_values_supported:te(j()).optional(),request_object_signing_alg_values_supported:te(j()).optional(),request_object_encryption_alg_values_supported:te(j()).optional(),request_object_encryption_enc_values_supported:te(j()).optional(),token_endpoint_auth_methods_supported:te(j()).optional(),token_endpoint_auth_signing_alg_values_supported:te(j()).optional(),display_values_supported:te(j()).optional(),claim_types_supported:te(j()).optional(),claims_supported:te(j()).optional(),service_documentation:j().optional(),claims_locales_supported:te(j()).optional(),ui_locales_supported:te(j()).optional(),claims_parameter_supported:$e().optional(),request_parameter_supported:$e().optional(),request_uri_parameter_supported:$e().optional(),require_request_uri_registration:$e().optional(),op_policy_uri:Dt.optional(),op_tos_uri:Dt.optional(),client_id_metadata_document_supported:$e().optional(),authorization_response_iss_parameter_supported:$e().optional().catch(void 0)}),S_=J({..._g.shape,...xg.pick({code_challenge_methods_supported:!0}).shape}),k_=J({access_token:j(),id_token:j().optional(),token_type:j(),expires_in:pu.number().optional(),scope:j().optional(),refresh_token:j().optional(),issuer:j().optional().catch(void 0)}).strip(),z_=J({issued_token_type:ne("urn:ietf:params:oauth:token-type:id-jag"),access_token:j(),token_type:j().optional(),expires_in:me().optional(),scope:j().optional()}).strip(),R_=J({error:j(),error_description:j().optional(),error_uri:j().optional()}),x_=Dt.optional().or(ne("").transform(()=>{})),Sg=J({redirect_uris:te(Dt),token_endpoint_auth_method:j().optional(),grant_types:te(j()).optional(),response_types:te(j()).optional(),application_type:j().optional(),client_name:j().optional(),client_uri:Dt.optional(),logo_uri:x_,scope:j().optional(),contacts:te(j()).optional(),tos_uri:x_,policy_uri:j().optional(),jwks_uri:Dt.optional(),jwks:Ap().optional(),software_id:j().optional(),software_version:j().optional(),software_statement:j().optional()}).strip(),kg=J({client_id:j(),client_secret:j().optional(),client_id_issued_at:me().optional(),client_secret_expires_at:me().optional(),issuer:j().optional().catch(void 0)}).strip(),I_=Sg.merge(kg),P_=J({error:j(),error_description:j().optional()}).strip(),j_=J({token:j(),token_type_hint:j().optional()}).strip();var O_=Symbol.for("mcp.sdk.errorBrands");function q_(e,t){let r=new Set,o=t;for(;typeof o=="function";){let n=o.mcpBrand;Object.prototype.hasOwnProperty.call(o,"mcpBrand")&&typeof n=="string"&&r.add(n),o=Object.getPrototypeOf(o)}r.size!==0&&Object.defineProperty(e,O_,{value:r,enumerable:!1,configurable:!0})}function ac(e,t){try{if(typeof t=="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand=="string"&&Object.prototype.hasOwnProperty.call(t,O_)){let r=t[O_];if(r&&typeof r.has=="function"&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var fs=(function(e){return e.InvalidRequest="invalid_request",e.InvalidClient="invalid_client",e.InvalidGrant="invalid_grant",e.UnauthorizedClient="unauthorized_client",e.UnsupportedGrantType="unsupported_grant_type",e.InvalidScope="invalid_scope",e.AccessDenied="access_denied",e.ServerError="server_error",e.TemporarilyUnavailable="temporarily_unavailable",e.UnsupportedResponseType="unsupported_response_type",e.UnsupportedTokenType="unsupported_token_type",e.InvalidToken="invalid_token",e.MethodNotAllowed="method_not_allowed",e.TooManyRequests="too_many_requests",e.InvalidClientMetadata="invalid_client_metadata",e.InvalidRedirectUri="invalid_redirect_uri",e.InsufficientScope="insufficient_scope",e.InvalidTarget="invalid_target",e.InvalidDpopProof="invalid_dpop_proof",e.UseDpopNonce="use_dpop_nonce",e})({}),Ju=class sj extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return ac(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ac(this,t)}constructor(t,r,o){super(r),this.code=t,this.errorUri=o,this.name="OAuthError",q_(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}static fromResponse(t){return new sj(t.error,t.error_description??t.error,t.error_uri)}},Ue=(function(e){return e.NotConnected="NOT_CONNECTED",e.AlreadyConnected="ALREADY_CONNECTED",e.NotInitialized="NOT_INITIALIZED",e.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",e.RequestTimeout="REQUEST_TIMEOUT",e.ConnectionClosed="CONNECTION_CLOSED",e.SendFailed="SEND_FAILED",e.InvalidResult="INVALID_RESULT",e.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",e.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",e.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",e.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",e.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",e.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",e.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",e.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",e.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",e.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",e.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",e})({}),Oe=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return ac(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ac(this,e)}constructor(e,t,r,o){super(t,o),this.code=e,this.data=r,this.name="SdkError",q_(this,new.target)}},Jq=class extends Oe{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,r,o){super(e,t,r,o),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};var HP={};function aj(e){return Object.hasOwn(HP,e)?HP[e]:void 0}function BP(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Gq(e,t,r){return e==="elicitation"&&t==="form"&&r.form===void 0&&r.url===void 0}function cj(e){switch(e.method){case"elicitation/create":return e.params?.mode==="url"?{elicitation:{url:{}}}:{elicitation:{form:{}}};case"sampling/createMessage":{let t=e.params;return t!==void 0&&(t.tools!==void 0||t.toolChoice!==void 0)?{sampling:{tools:{}}}:{sampling:{}}}case"roots/list":return{roots:{}};default:return}}function Gu(e,t){let r={};for(let[o,n]of Object.entries(e)){if(n===void 0)continue;let i=t===void 0?void 0:t[o];if(i===void 0){r[o]=n;continue}if(BP(n)&&BP(i)){let s={};for(let[a,c]of Object.entries(n))c!==void 0&&i[a]===void 0&&!Gq(o,a,i)&&(s[a]=c);Object.keys(s).length>0&&(r[o]=s)}}return Object.keys(r).length>0?r:void 0}var lj="2026-07-28",zn=[lj];function uo(e){return e>=lj}function uj(e){return e.filter(t=>!uo(t))}function Eg(e){return e.filter(t=>uo(t))}function mj(e){let t=e.structuredContent;return t===void 0||!(typeof t!="object"||t===null||Array.isArray(t))||(e.content?.some(r=>r.type==="text")??!1)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var dj=["task","inputRequests","requestState"];function U_(e){return e===null||typeof e!="object"||Array.isArray(e)||e.content!==void 0||dj.some(t=>t in e)?e:{...e,content:[]}}function Kq(){let e=Yo(()=>xe([j(),me(),$e(),Or(),ve(j(),e),te(e)])),t=ve(j(),e),r=xe([j(),me().int()]),o=j(),n=J({ttl:me().optional()}),i=J({taskId:j()}),s=je({progressToken:r.optional(),"io.modelcontextprotocol/related-task":i.optional()}),a=J({_meta:s.optional()}),c=a.extend({task:n.optional()}),l=J({method:j(),params:a.loose().optional()}),u=J({_meta:s.optional()}),m=J({method:j(),params:u.loose().optional()}),d=je({_meta:s.optional()}),f=xe([j(),me().int()]),p=d.strict(),h=u.extend({requestId:f.optional(),reason:j().optional()}),g=m.extend({method:ne("notifications/cancelled"),params:h}),b=J({src:j(),mimeType:j().optional(),sizes:te(j()).optional(),theme:Ce(["light","dark"]).optional()}),y=J({icons:te(b).optional()}),w=J({name:j(),title:j().optional()}),v=w.extend({...w.shape,...y.shape,version:j(),websiteUrl:j().optional(),description:j().optional()}),S=hr(J({applyDefaults:$e().optional()}),t),_=so(Yt=>Yt&&typeof Yt=="object"&&!Array.isArray(Yt)&&Object.keys(Yt).length===0?{form:{}}:Yt,hr(J({form:S.optional(),url:t.optional()}),t.optional())),$=je({list:t.optional(),cancel:t.optional(),requests:je({sampling:je({createMessage:t.optional()}).optional(),elicitation:je({create:t.optional()}).optional()}).optional()}),x=je({list:t.optional(),cancel:t.optional(),requests:je({tools:je({call:t.optional()}).optional()}).optional()}),k=J({experimental:ve(j(),t).optional(),sampling:J({context:t.optional(),tools:t.optional()}).optional(),elicitation:_.optional(),roots:J({listChanged:$e().optional()}).optional(),tasks:$.optional(),extensions:ve(j(),t).optional()}),P=a.extend({protocolVersion:j(),capabilities:k,clientInfo:v}),I=l.extend({method:ne("initialize"),params:P}),E=J({experimental:ve(j(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:J({listChanged:$e().optional()}).optional(),resources:J({subscribe:$e().optional(),listChanged:$e().optional()}).optional(),tools:J({listChanged:$e().optional()}).optional(),tasks:x.optional(),extensions:ve(j(),t).optional()}),N=d.extend({protocolVersion:j(),capabilities:E,serverInfo:v,instructions:j().optional()}),T=m.extend({method:ne("notifications/initialized"),params:u.optional()}),q=l.extend({method:ne("ping"),params:a.optional()}),Z=J({progress:me(),total:ze(me()),message:ze(j())}),D=J({...u.shape,...Z.shape,progressToken:r}),V=m.extend({method:ne("notifications/progress"),params:D}),F=a.extend({cursor:o.optional()}),M=l.extend({params:F.optional()}),L=d.extend({nextCursor:o.optional()}),A=J({uri:j(),mimeType:ze(j()),_meta:ve(j(),Re()).optional()}),z=A.extend({text:j()}),R=j().refine(Yt=>{try{return atob(Yt),!0}catch{return!1}},{message:"Invalid Base64 string"}),C=A.extend({blob:R}),U=Ce(["user","assistant"]),W=J({audience:te(U).optional(),priority:me().min(0).max(1).optional(),lastModified:Kn.datetime({offset:!0}).optional()}),X=J({...w.shape,...y.shape,uri:j(),description:ze(j()),mimeType:ze(j()),size:ze(me()),annotations:W.optional(),_meta:ze(je({}))}),Y=J({...w.shape,...y.shape,uriTemplate:j(),description:ze(j()),mimeType:ze(j()),annotations:W.optional(),_meta:ze(je({}))}),fe=M.extend({method:ne("resources/list")}),ye=L.extend({resources:te(X)}),H=M.extend({method:ne("resources/templates/list")}),Q=L.extend({resourceTemplates:te(Y)}),re=a.extend({uri:j()}),de=re,ae=l.extend({method:ne("resources/read"),params:de}),pe=d.extend({contents:te(xe([z,C]))}),Ie=m.extend({method:ne("notifications/resources/list_changed"),params:u.optional()}),Je=re,Ze=l.extend({method:ne("resources/subscribe"),params:Je}),Ye=re,Xe=l.extend({method:ne("resources/unsubscribe"),params:Ye}),Pt=u.extend({uri:j()}),bt=m.extend({method:ne("notifications/resources/updated"),params:Pt}),wn=J({name:j(),description:ze(j()),required:ze($e())}),Gt=J({...w.shape,...y.shape,description:ze(j()),arguments:ze(te(wn)),_meta:ze(je({}))}),Cn=M.extend({method:ne("prompts/list")}),Vn=L.extend({prompts:te(Gt)}),Zn=a.extend({name:j(),arguments:ve(j(),j()).optional()}),ur=l.extend({method:ne("prompts/get"),params:Zn}),Hn=J({type:ne("text"),text:j(),annotations:W.optional(),_meta:ve(j(),Re()).optional()}),Ai=J({type:ne("image"),data:R,mimeType:j(),annotations:W.optional(),_meta:ve(j(),Re()).optional()}),Oi=J({type:ne("audio"),data:R,mimeType:j(),annotations:W.optional(),_meta:ve(j(),Re()).optional()}),Fc=J({type:ne("tool_use"),name:j(),id:j(),input:ve(j(),Re()),_meta:ve(j(),Re()).optional()}),Ao=J({type:ne("resource"),resource:xe([z,C]),annotations:W.optional(),_meta:ve(j(),Re()).optional()}),Vc=X.extend({type:ne("resource_link")}),Bn=xe([Hn,Ai,Oi,Vc,Ao]),Ks=J({role:U,content:Bn}),Ys=d.extend({description:j().optional(),messages:te(Ks)}),Ni=m.extend({method:ne("notifications/prompts/list_changed"),params:u.optional()}),Zc=J({title:j().optional(),readOnlyHint:$e().optional(),destructiveHint:$e().optional(),idempotentHint:$e().optional(),openWorldHint:$e().optional()}),Xs=J({taskSupport:Ce(["required","optional","forbidden"]).optional()}),Mi=J({...w.shape,...y.shape,description:j().optional(),inputSchema:J({type:ne("object"),properties:ve(j(),e).optional(),required:te(j()).optional()}).catchall(Re()),outputSchema:J({type:ne("object"),properties:ve(j(),e).optional(),required:te(j()).optional()}).catchall(Re()).optional(),annotations:Zc.optional(),execution:Xs.optional(),_meta:ve(j(),Re()).optional()}),Qs=M.extend({method:ne("tools/list")}),ea=L.extend({tools:te(Mi)}),ta=d.extend({content:te(Bn),structuredContent:ve(j(),Re()).optional(),isError:$e().optional()}),Kt=c.extend({name:j(),arguments:ve(j(),Re()).optional()}),Hc=l.extend({method:ne("tools/call"),params:Kt}),hd=m.extend({method:ne("notifications/tools/list_changed"),params:u.optional()}),na=Ce(["debug","info","notice","warning","error","critical","alert","emergency"]),Bc=a.extend({level:na}),Wc=l.extend({method:ne("logging/setLevel"),params:Bc}),Jc=u.extend({level:na,logger:j().optional(),data:Re()}),Gc=m.extend({method:ne("notifications/message"),params:Jc}),Kc=J({name:j().optional()}),Yc=J({hints:te(Kc).optional(),costPriority:me().min(0).max(1).optional(),speedPriority:me().min(0).max(1).optional(),intelligencePriority:me().min(0).max(1).optional()}),Xc=J({mode:Ce(["auto","required","none"]).optional()}),gd=J({type:ne("tool_result"),toolUseId:j().describe("The unique identifier for the corresponding tool call."),content:te(Bn),structuredContent:J({}).loose().optional(),isError:$e().optional(),_meta:ve(j(),Re()).optional()}),Qc=Ko("type",[Hn,Ai,Oi]),Oo=Ko("type",[Hn,Ai,Oi,Fc,gd]),el=J({role:U,content:xe([Oo,te(Oo)]),_meta:ve(j(),Re()).optional()}),tl=c.extend({messages:te(el),modelPreferences:Yc.optional(),systemPrompt:j().optional(),includeContext:Ce(["none","thisServer","allServers"]).optional(),temperature:me().optional(),maxTokens:me().int(),stopSequences:te(j()).optional(),metadata:t.optional(),tools:te(Mi).optional(),toolChoice:Xc.optional()}),nl=l.extend({method:ne("sampling/createMessage"),params:tl}),rl=d.extend({model:j(),stopReason:ze(Ce(["endTurn","stopSequence","maxTokens"]).or(j())),role:U,content:Qc}),ol=d.extend({model:j(),stopReason:ze(Ce(["endTurn","stopSequence","maxTokens","toolUse"]).or(j())),role:U,content:xe([Oo,te(Oo)])}),il=J({type:ne("boolean"),title:j().optional(),description:j().optional(),default:$e().optional()}),sl=J({type:ne("string"),title:j().optional(),description:j().optional(),minLength:me().optional(),maxLength:me().optional(),format:Ce(["email","uri","date","date-time"]).optional(),default:j().optional()}),al=J({type:Ce(["number","integer"]),title:j().optional(),description:j().optional(),minimum:me().optional(),maximum:me().optional(),default:me().optional()}),cl=J({type:ne("string"),title:j().optional(),description:j().optional(),enum:te(j()),default:j().optional()}),ll=J({type:ne("string"),title:j().optional(),description:j().optional(),oneOf:te(J({const:j(),title:j()})),default:j().optional()}),ul=J({type:ne("string"),title:j().optional(),description:j().optional(),enum:te(j()),enumNames:te(j()).optional(),default:j().optional()}),ml=xe([cl,ll]),Di=J({type:ne("array"),title:j().optional(),description:j().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({type:ne("string"),enum:te(j())}),default:te(j()).optional()}),qi=J({type:ne("array"),title:j().optional(),description:j().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({anyOf:te(J({const:j(),title:j()}))}),default:te(j()).optional()}),yd=xe([Di,qi]),bd=xe([ul,ml,yd]),An=xe([bd,il,sl,al]),On=c.extend({mode:ne("form").optional(),message:j(),requestedSchema:J({type:ne("object"),properties:ve(j(),An),required:te(j()).optional()}).catchall(Re())}),dl=c.extend({mode:ne("url"),message:j(),elicitationId:j(),url:j().url()}),mr=xe([On,dl]),wd=l.extend({method:ne("elicitation/create"),params:mr}),vd=u.extend({elicitationId:j()}),$d=m.extend({method:ne("notifications/elicitation/complete"),params:vd}),xd=d.extend({action:Ce(["accept","decline","cancel"]),content:so(Yt=>Yt===null?void 0:Yt,ve(j(),xe([j(),me(),$e(),te(j())])).optional())}),_d=J({type:ne("ref/resource"),uri:j()}),Sd=J({type:ne("ref/prompt"),name:j()}),kd=a.extend({ref:xe([Sd,_d]),argument:J({name:j(),value:j()}),context:J({arguments:ve(j(),j()).optional()}).optional()}),fl=l.extend({method:ne("completion/complete"),params:kd}),zd=d.extend({completion:je({values:te(j()).max(100),total:ze(me().int()),hasMore:ze($e())})}),Rd=J({uri:j().startsWith("file://"),name:j().optional(),_meta:ve(j(),Re()).optional()}),ra=l.extend({method:ne("roots/list"),params:a.optional()}),pl=d.extend({roots:te(Rd)}),Id=m.extend({method:ne("notifications/roots/list_changed"),params:u.optional()}),Pd=je({ttl:me().optional(),pollInterval:me().optional()}),hl=Ce(["working","input_required","completed","failed","cancelled"]),No=J({taskId:j(),status:hl,ttl:xe([me(),Or()]),createdAt:j(),lastUpdatedAt:j(),pollInterval:ze(me()),statusMessage:ze(j())}),vn=d.extend({task:No}),jd=u.merge(No),Ui=m.extend({method:ne("notifications/tasks/status"),params:jd}),oa=l.extend({method:ne("tasks/get"),params:a.extend({taskId:j()})}),ia=d.merge(No),sa=l.extend({method:ne("tasks/result"),params:a.extend({taskId:j()})}),Ob=d.loose(),cn=M.extend({method:ne("tasks/list")}),St=L.extend({tasks:te(No)}),Li=l.extend({method:ne("tasks/cancel"),params:a.extend({taskId:j()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:o,TaskMetadataSchema:n,RelatedTaskMetadataSchema:i,RequestMetaSchema:s,BaseRequestParamsSchema:a,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:u,NotificationSchema:m,ResultSchema:d,RequestIdSchema:f,EmptyResultSchema:p,CancelledNotificationParamsSchema:h,CancelledNotificationSchema:g,IconSchema:b,IconsSchema:y,BaseMetadataSchema:w,ImplementationSchema:v,ClientTasksCapabilitySchema:$,ServerTasksCapabilitySchema:x,ClientCapabilitiesSchema:k,InitializeRequestParamsSchema:P,InitializeRequestSchema:I,ServerCapabilitiesSchema:E,InitializeResultSchema:N,InitializedNotificationSchema:T,PingRequestSchema:q,ProgressSchema:Z,ProgressNotificationParamsSchema:D,ProgressNotificationSchema:V,PaginatedRequestParamsSchema:F,PaginatedRequestSchema:M,PaginatedResultSchema:L,ResourceContentsSchema:A,TextResourceContentsSchema:z,BlobResourceContentsSchema:C,RoleSchema:U,AnnotationsSchema:W,ResourceSchema:X,ResourceTemplateSchema:Y,ListResourcesRequestSchema:fe,ListResourcesResultSchema:ye,ListResourceTemplatesRequestSchema:H,ListResourceTemplatesResultSchema:Q,ResourceRequestParamsSchema:re,ReadResourceRequestParamsSchema:de,ReadResourceRequestSchema:ae,ReadResourceResultSchema:pe,ResourceListChangedNotificationSchema:Ie,SubscribeRequestParamsSchema:Je,SubscribeRequestSchema:Ze,UnsubscribeRequestParamsSchema:Ye,UnsubscribeRequestSchema:Xe,ResourceUpdatedNotificationParamsSchema:Pt,ResourceUpdatedNotificationSchema:bt,PromptArgumentSchema:wn,PromptSchema:Gt,ListPromptsRequestSchema:Cn,ListPromptsResultSchema:Vn,GetPromptRequestParamsSchema:Zn,GetPromptRequestSchema:ur,TextContentSchema:Hn,ImageContentSchema:Ai,AudioContentSchema:Oi,ToolUseContentSchema:Fc,EmbeddedResourceSchema:Ao,ResourceLinkSchema:Vc,ContentBlockSchema:Bn,PromptMessageSchema:Ks,GetPromptResultSchema:Ys,PromptListChangedNotificationSchema:Ni,ToolAnnotationsSchema:Zc,ToolExecutionSchema:Xs,ToolSchema:Mi,ListToolsRequestSchema:Qs,ListToolsResultSchema:ea,CallToolResultSchema:ta,CallToolRequestParamsSchema:Kt,CallToolRequestSchema:Hc,ToolListChangedNotificationSchema:hd,LoggingLevelSchema:na,SetLevelRequestParamsSchema:Bc,SetLevelRequestSchema:Wc,LoggingMessageNotificationParamsSchema:Jc,LoggingMessageNotificationSchema:Gc,ModelHintSchema:Kc,ModelPreferencesSchema:Yc,ToolChoiceSchema:Xc,ToolResultContentSchema:gd,SamplingContentSchema:Qc,SamplingMessageContentBlockSchema:Oo,SamplingMessageSchema:el,CreateMessageRequestParamsSchema:tl,CreateMessageRequestSchema:nl,CreateMessageResultSchema:rl,CreateMessageResultWithToolsSchema:ol,BooleanSchemaSchema:il,StringSchemaSchema:sl,NumberSchemaSchema:al,UntitledSingleSelectEnumSchemaSchema:cl,TitledSingleSelectEnumSchemaSchema:ll,LegacyTitledEnumSchemaSchema:ul,SingleSelectEnumSchemaSchema:ml,UntitledMultiSelectEnumSchemaSchema:Di,TitledMultiSelectEnumSchemaSchema:qi,MultiSelectEnumSchemaSchema:yd,EnumSchemaSchema:bd,PrimitiveSchemaDefinitionSchema:An,ElicitRequestFormParamsSchema:On,ElicitRequestURLParamsSchema:dl,ElicitRequestParamsSchema:mr,ElicitRequestSchema:wd,ElicitationCompleteNotificationParamsSchema:vd,ElicitationCompleteNotificationSchema:$d,ElicitResultSchema:xd,ResourceTemplateReferenceSchema:_d,PromptReferenceSchema:Sd,CompleteRequestParamsSchema:kd,CompleteRequestSchema:fl,CompleteResultSchema:zd,RootSchema:Rd,ListRootsRequestSchema:ra,ListRootsResultSchema:pl,RootsListChangedNotificationSchema:Id,TaskCreationParamsSchema:Pd,TaskStatusSchema:hl,TaskSchema:No,CreateTaskResultSchema:vn,TaskStatusNotificationParamsSchema:jd,TaskStatusNotificationSchema:Ui,GetTaskRequestSchema:oa,GetTaskResultSchema:ia,GetTaskPayloadRequestSchema:sa,GetTaskPayloadResultSchema:Ob,ListTasksRequestSchema:cn,ListTasksResultSchema:St,CancelTaskRequestSchema:Li,CancelTaskResultSchema:d.merge(No),ClientRequestSchema:xe([q,I,fl,Wc,ur,Cn,fe,H,ae,Ze,Xe,Hc,Qs,oa,sa,cn,Li]),ClientNotificationSchema:xe([g,V,T,Id,Ui]),ClientResultSchema:xe([p,rl,ol,xd,pl,ia,St,vn]),ServerRequestSchema:xe([q,nl,wd,ra,oa,sa,cn,Li]),ServerNotificationSchema:xe([g,V,Gc,bt,Ie,hd,Ni,Ui,$d]),ServerResultSchema:xe([p,N,zd,Ys,Vn,ye,Q,pe,ta,ea,ia,St,vn]),CallToolResultWireSchema:Re().superRefine((Yt,BN)=>{if(!(typeof Yt!="object"||Yt===null||Array.isArray(Yt)||Yt.content!==void 0)){for(let L1 of dj)if(L1 in Yt){BN.addIssue({code:"custom",message:`content is required when the body carries '${L1}' \u2014 another result family cannot default into an empty tools/call success`});return}}}).transform(U_).pipe(ta)}}var Yq;function fj(){return Yq??=Kq()}function pj(e){return e.type!=="object"}var Xq=new Set(["const","enum","default","examples"]),Qq=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function WP(e){return e!==void 0&&!(typeof e=="string"&&e.startsWith("#"))}function e6(e){let t=typeof e.$schema=="string"?e.$schema:void 0;if(WP(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let r=Z1(e.$schema)&&e.$recursiveAnchor!==!0,o=(n,i)=>{if(Array.isArray(n))return n.map(c=>o(c,!1));if(n===null||typeof n!="object"||!i&&WP(n.$id))return n;let s={},a=!1;for(let[c,l]of Object.entries(n))i?s[c]=o(l,!1):(c==="$ref"||c==="$dynamicRef")&&typeof l=="string"?s[c]=l==="#"?"#/properties/result":l.startsWith("#/")?`#/properties/result${l.slice(1)}`:l:c==="$recursiveRef"&&l==="#"&&r?a=!0:Xq.has(c)?s[c]=l:Qq.has(c)?s[c]=o(l,!0):s[c]=o(l,!1);return a&&("$ref"in s?s.allOf=[...Array.isArray(s.allOf)?s.allOf:[],{$ref:"#/properties/result"}]:s.$ref="#/properties/result"),s};return{...t!==void 0&&{$schema:t},type:"object",properties:{result:o(e,!1)},required:["result"]}}var hj={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},gj={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},t6={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},zg;function L_(){if(zg)return zg;let e=fj();return zg={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},zg}function yj(e){return Object.prototype.hasOwnProperty.call(hj,e)}function bj(e){return Object.prototype.hasOwnProperty.call(gj,e)}function n6(e){return Object.prototype.hasOwnProperty.call(t6,e)}function r6(e){return n6(e)?L_().resultSchemas[e]:void 0}function o6(e){return yj(e)?L_().requestSchemas[e]:void 0}function i6(e){return bj(e)?L_().notificationSchemas[e]:void 0}var BG=Object.keys(hj),WG=Object.keys(gj);function N_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Rg(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}var JP={ok:!1,reason:"not-in-era"};function GP(e){return N_(e)&&N_(e.outputSchema)&&pj(e.outputSchema)}var F_={era:"2025-11-25",hasRequestMethod:yj,hasNotificationMethod:bj,validateRequest:(e,t)=>Rg(o6(e),t),validateResult:(e,t)=>Rg(r6(e),t),validateNotification:(e,t)=>Rg(i6(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>JP,validateInputResponse:()=>JP,samplingResultVariant:((e,t)=>{let r=fj();return Rg(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)}),outboundEnvelope:e=>{},validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let r=mj(e),o=r.structuredContent;if(o===void 0)return r;let n=typeof o!="object"||o===null||Array.isArray(o),i=t!==void 0&&pj(t);return!n&&!i?r:{...r,structuredContent:{result:o}}},decodeResult(e,t){if(N_(t)&&"resultType"in t){let r={...t};return delete r.resultType,{kind:"complete",result:r}}return{kind:"complete",result:t}},encodeResult(e,t){if(e!=="tools/list")return t;let r=t.tools;return!Array.isArray(r)||!r.some(o=>GP(o))?t:{...t,tools:r.map(o=>GP(o)?{...o,outputSchema:e6(o.outputSchema)}:o)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>{}};function s6(){let e=Yo(()=>xe([j(),me(),$e(),Or(),ve(j(),e),te(e)])),t=ve(j(),e),r=xe([j(),me().int()]),o=j(),n=xe([j(),me().int()]),i=Ce(["user","assistant"]),s=Ce(["debug","info","notice","warning","error","critical","alert","emergency"]),a=j().refine(St=>{try{return atob(St),!0}catch{return!1}},{message:"Invalid Base64 string"}),c=J({ttl:me().optional()}),l=J({taskId:j()}),u=je({progressToken:r.optional(),"io.modelcontextprotocol/related-task":l.optional()}),m=J({_meta:u.optional()}),d=m.extend({task:c.optional()}),f=J({_meta:u.optional()}),p=J({method:j(),params:f.loose().optional()}),h=J({src:j(),mimeType:j().optional(),sizes:te(j()).optional(),theme:Ce(["light","dark"]).optional()}),g=J({icons:te(h).optional()}),b=J({name:j(),title:j().optional()}),y=b.extend({...b.shape,...g.shape,version:j(),websiteUrl:j().optional(),description:j().optional()}),w=hr(J({applyDefaults:$e().optional()}),t),v=so(St=>St&&typeof St=="object"&&!Array.isArray(St)&&Object.keys(St).length===0?{form:{}}:St,hr(J({form:w.optional(),url:t.optional()}),t.optional())),S=je({list:t.optional(),cancel:t.optional(),requests:je({sampling:je({createMessage:t.optional()}).optional(),elicitation:je({create:t.optional()}).optional()}).optional()}),_=je({list:t.optional(),cancel:t.optional(),requests:je({tools:je({call:t.optional()}).optional()}).optional()}),$=J({experimental:ve(j(),t).optional(),sampling:J({context:t.optional(),tools:t.optional()}).optional(),elicitation:v.optional(),roots:J({listChanged:$e().optional()}).optional(),tasks:S.optional(),extensions:ve(j(),t).optional()}),x=J({experimental:ve(j(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:J({listChanged:$e().optional()}).optional(),resources:J({subscribe:$e().optional(),listChanged:$e().optional()}).optional(),tools:J({listChanged:$e().optional()}).optional(),tasks:_.optional(),extensions:ve(j(),t).optional()}),k=J({progress:me(),total:ze(me()),message:ze(j())}),P=J({...f.shape,...k.shape,progressToken:r}),I=p.extend({method:ne("notifications/progress"),params:P}),E=f.extend({level:s,logger:j().optional(),data:Re()}),N=p.extend({method:ne("notifications/message"),params:E}),T=J({uri:j(),mimeType:ze(j()),_meta:ve(j(),Re()).optional()}),q=T.extend({text:j()}),Z=T.extend({blob:a}),D=J({audience:te(i).optional(),priority:me().min(0).max(1).optional(),lastModified:Kn.datetime({offset:!0}).optional()}),V=J({...b.shape,...g.shape,uri:j(),description:ze(j()),mimeType:ze(j()),size:ze(me()),annotations:D.optional(),_meta:ze(je({}))}),F=J({...b.shape,...g.shape,uriTemplate:j(),description:ze(j()),mimeType:ze(j()),annotations:D.optional(),_meta:ze(je({}))}),M=p.extend({method:ne("notifications/resources/list_changed"),params:f.optional()}),L=f.extend({uri:j()}),A=p.extend({method:ne("notifications/resources/updated"),params:L}),z=J({name:j(),description:ze(j()),required:ze($e())}),R=J({...b.shape,...g.shape,description:ze(j()),arguments:ze(te(z)),_meta:ze(je({}))}),C=p.extend({method:ne("notifications/prompts/list_changed"),params:f.optional()}),U=J({type:ne("text"),text:j(),annotations:D.optional(),_meta:ve(j(),Re()).optional()}),W=J({type:ne("image"),data:a,mimeType:j(),annotations:D.optional(),_meta:ve(j(),Re()).optional()}),X=J({type:ne("audio"),data:a,mimeType:j(),annotations:D.optional(),_meta:ve(j(),Re()).optional()}),Y=J({type:ne("tool_use"),name:j(),id:j(),input:ve(j(),Re()),_meta:ve(j(),Re()).optional()}),fe=J({type:ne("resource"),resource:xe([q,Z]),annotations:D.optional(),_meta:ve(j(),Re()).optional()}),ye=V.extend({type:ne("resource_link")}),H=xe([U,W,X,ye,fe]),Q=J({role:i,content:H}),re=J({title:j().optional(),readOnlyHint:$e().optional(),destructiveHint:$e().optional(),idempotentHint:$e().optional(),openWorldHint:$e().optional()}),de=p.extend({method:ne("notifications/tools/list_changed"),params:f.optional()}),ae=J({name:j().optional()}),pe=J({hints:te(ae).optional(),costPriority:me().min(0).max(1).optional(),speedPriority:me().min(0).max(1).optional(),intelligencePriority:me().min(0).max(1).optional()}),Ie=J({mode:Ce(["auto","required","none"]).optional()}),Je=J({type:ne("boolean"),title:j().optional(),description:j().optional(),default:$e().optional()}),Ze=J({type:ne("string"),title:j().optional(),description:j().optional(),minLength:me().optional(),maxLength:me().optional(),format:Ce(["email","uri","date","date-time"]).optional(),default:j().optional()}),Ye=J({type:Ce(["number","integer"]),title:j().optional(),description:j().optional(),minimum:me().optional(),maximum:me().optional(),default:me().optional()}),Xe=J({type:ne("string"),title:j().optional(),description:j().optional(),enum:te(j()),default:j().optional()}),Pt=J({type:ne("string"),title:j().optional(),description:j().optional(),oneOf:te(J({const:j(),title:j()})),default:j().optional()}),bt=J({type:ne("string"),title:j().optional(),description:j().optional(),enum:te(j()),enumNames:te(j()).optional(),default:j().optional()}),wn=xe([Xe,Pt]),Gt=J({type:ne("array"),title:j().optional(),description:j().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({type:ne("string"),enum:te(j())}),default:te(j()).optional()}),Cn=J({type:ne("array"),title:j().optional(),description:j().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({anyOf:te(J({const:j(),title:j()}))}),default:te(j()).optional()}),Vn=xe([Gt,Cn]),Zn=xe([bt,wn,Vn]),ur=xe([Zn,Je,Ze,Ye]),Hn=d.extend({mode:ne("form").optional(),message:j(),requestedSchema:J({type:ne("object"),properties:ve(j(),ur),required:te(j()).optional()}).catchall(Re())}),Ai=J({type:ne("ref/resource"),uri:j()}),Oi=J({type:ne("ref/prompt"),name:j()}),Fc=J({uri:j().startsWith("file://"),name:j().optional(),_meta:ve(j(),Re()).optional()}),Ao=$.shape,Vc=J({experimental:Ao.experimental,sampling:Ao.sampling,elicitation:Ao.elicitation,roots:Ao.roots,extensions:Ao.extensions}),Bn=x.shape,Ks=J({experimental:Bn.experimental,logging:Bn.logging,completions:Bn.completions,prompts:Bn.prompts,resources:Bn.resources,tools:Bn.tools,extensions:Bn.extensions}),Ys=je({progressToken:r.optional(),[Yn]:j(),[as]:y.optional(),[Nr]:Vc,[ei]:s.optional()}),Ni=J({...b.shape,...g.shape,description:j().optional(),inputSchema:je({$schema:j().optional(),type:ne("object")}),outputSchema:je({$schema:j().optional()}).optional(),annotations:re.optional(),_meta:ve(j(),Re()).optional()}),Zc=J({type:ne("tool_result"),toolUseId:j(),content:te(H),structuredContent:Re().optional(),isError:$e().optional(),_meta:ve(j(),Re()).optional()}),Xs=xe([U,W,X,Y,Zc]),Mi=J({role:i,content:xe([Xs,te(Xs)]),_meta:ve(j(),Re()).optional()}),Qs=j(),ea=je({[gr]:y.optional().catch(void 0)}),ta=ea.optional();function Kt(St){return je({_meta:ta,resultType:Qs.default("complete"),...St})}let Hc=Kt({}),hd=Kt({nextCursor:o.optional()}),na=Kt({content:te(H),structuredContent:Re().optional(),isError:$e().optional()}),Bc=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),tools:te(Ni),nextCursor:o.optional()}),Wc=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),prompts:te(R),nextCursor:o.optional()}),Jc=Kt({description:j().optional(),messages:te(Q)}),Gc=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),resources:te(V),nextCursor:o.optional()}),Kc=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),resourceTemplates:te(F),nextCursor:o.optional()}),Yc=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),contents:te(xe([q,Z]))}),Xc=Kt({completion:J({values:te(j()).max(100),total:me().int().optional(),hasMore:$e().optional()}).loose()}),gd=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"])}),Qc=Kt({ttlMs:me().int().min(0).catch(0),cacheScope:Ce(["public","private"]).catch("private"),supportedVersions:te(j()),capabilities:Ks,instructions:j().optional()}),Oo=J({messages:te(Mi),modelPreferences:pe.optional(),systemPrompt:j().optional(),includeContext:Ce(["none","thisServer","allServers"]).optional(),temperature:me().optional(),maxTokens:me().int(),stopSequences:te(j()).optional(),metadata:t.optional(),tools:te(Ni).optional(),toolChoice:Ie.optional()}),el=J({method:ne("sampling/createMessage"),params:Oo}),tl=J({method:ne("roots/list"),params:J({_meta:ve(j(),Re()).optional()}).optional()}),nl=J({...Mi.shape,model:j(),stopReason:j().optional()}),rl=J({roots:te(Fc)}),ol=J({action:Ce(["accept","decline","cancel"]),content:ve(j(),xe([j(),me(),$e(),te(j())])).optional()}),il=J({mode:ne("url"),message:j(),url:j().url()}),sl=xe([Hn,il]),al=J({method:ne("elicitation/create"),params:sl}),cl=xe([el,tl,al]),ll=xe([nl,rl,ol]),ul=ve(j(),cl),ml=ve(j(),ll),Di=Kt({inputRequests:ul.optional(),requestState:j().optional()}),qi={inputResponses:ml.optional(),requestState:j().optional()},yd=J({_meta:Ys,...qi}),bd=je({progressToken:r.optional()});function An(St,Li){return J({method:ne(St),params:J({_meta:Ys,...Li})})}function On(St,Li){return J({method:ne(St),params:J({_meta:bd.optional(),...Li}).optional()})}let dl={name:j(),arguments:ve(j(),Re()).optional(),...qi},mr={cursor:o.optional()},wd=An("tools/call",dl),vd=An("tools/list",mr),$d=An("prompts/list",mr),xd=An("prompts/get",{name:j(),arguments:ve(j(),j()).optional(),...qi}),_d=An("resources/list",mr),Sd=An("resources/templates/list",mr),kd=An("resources/read",{uri:j(),...qi}),fl={ref:xe([Oi,Ai]),argument:J({name:j(),value:j()}),context:J({arguments:ve(j(),j()).optional()}).optional()},zd=An("completion/complete",fl),Rd=An("server/discover",{}),ra=J({toolsListChanged:$e().optional(),promptsListChanged:$e().optional(),resourcesListChanged:$e().optional(),resourceSubscriptions:te(j()).optional()}),pl={notifications:ra},Id=An("subscriptions/listen",pl),Pd=ea.extend({"io.modelcontextprotocol/subscriptionId":n}),hl=je({_meta:Pd,resultType:Qs.default("complete")}),No={"tools/call":On("tools/call",dl),"tools/list":On("tools/list",mr),"prompts/get":On("prompts/get",{name:j(),arguments:ve(j(),j()).optional()}),"prompts/list":On("prompts/list",mr),"resources/list":On("resources/list",mr),"resources/templates/list":On("resources/templates/list",mr),"resources/read":On("resources/read",{uri:j()}),"completion/complete":On("completion/complete",fl),"server/discover":On("server/discover",{}),"subscriptions/listen":On("subscriptions/listen",pl)};function vn(St){return je({_meta:ta,...St})}let jd={"tools/call":vn({content:te(H),structuredContent:Re().optional(),isError:$e().optional()}),"tools/list":vn({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),tools:te(Ni),nextCursor:o.optional()}),"prompts/get":vn({description:j().optional(),messages:te(Q)}),"prompts/list":vn({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),prompts:te(R),nextCursor:o.optional()}),"resources/list":vn({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),resources:te(V),nextCursor:o.optional()}),"resources/templates/list":vn({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),resourceTemplates:te(F),nextCursor:o.optional()}),"resources/read":vn({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),contents:te(xe([q,Z]))}),"completion/complete":vn({completion:J({values:te(j()).max(100),total:me().int().optional(),hasMore:$e().optional()}).loose()}),"server/discover":vn({ttlMs:me().int().min(0).catch(0),cacheScope:Ce(["public","private"]).catch("private"),supportedVersions:te(j()),capabilities:Ks,instructions:j().optional()}),"subscriptions/listen":vn({})},Ui=je({"io.modelcontextprotocol/subscriptionId":n.optional()}),oa=J({method:ne("notifications/subscriptions/acknowledged"),params:J({_meta:Ui.optional(),notifications:ra})}),ia=J({_meta:Ui.optional(),requestId:n,reason:j().optional()}),sa=J({method:ne("notifications/cancelled"),params:ia}),Ob={"notifications/cancelled":sa,"notifications/progress":I,"notifications/message":N,"notifications/resources/updated":A,"notifications/resources/list_changed":M,"notifications/tools/list_changed":de,"notifications/prompts/list_changed":C,"notifications/subscriptions/acknowledged":oa},cn=St=>J({jsonrpc:ne("2.0"),id:xe([j(),me().int()]),result:St}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:r,CursorSchema:o,RequestIdSchema:n,RoleSchema:i,LoggingLevelSchema:s,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:u,BaseRequestParamsSchema:m,TaskAugmentedRequestParamsSchema:d,NotificationsParamsSchema:f,NotificationSchema:p,IconSchema:h,IconsSchema:g,BaseMetadataSchema:b,ImplementationSchema:y,ClientTasksCapabilitySchema:S,ServerTasksCapabilitySchema:_,ClientCapabilitiesSchema:$,ServerCapabilitiesSchema:x,ProgressSchema:k,ProgressNotificationParamsSchema:P,ProgressNotificationSchema:I,LoggingMessageNotificationParamsSchema:E,LoggingMessageNotificationSchema:N,ResourceContentsSchema:T,TextResourceContentsSchema:q,BlobResourceContentsSchema:Z,AnnotationsSchema:D,ResourceSchema:V,ResourceTemplateSchema:F,ResourceListChangedNotificationSchema:M,ResourceUpdatedNotificationParamsSchema:L,ResourceUpdatedNotificationSchema:A,PromptArgumentSchema:z,PromptSchema:R,PromptListChangedNotificationSchema:C,TextContentSchema:U,ImageContentSchema:W,AudioContentSchema:X,ToolUseContentSchema:Y,EmbeddedResourceSchema:fe,ResourceLinkSchema:ye,ContentBlockSchema:H,PromptMessageSchema:Q,ToolAnnotationsSchema:re,ToolListChangedNotificationSchema:de,ModelHintSchema:ae,ModelPreferencesSchema:pe,ToolChoiceSchema:Ie,BooleanSchemaSchema:Je,StringSchemaSchema:Ze,NumberSchemaSchema:Ye,UntitledSingleSelectEnumSchemaSchema:Xe,TitledSingleSelectEnumSchemaSchema:Pt,LegacyTitledEnumSchemaSchema:bt,SingleSelectEnumSchemaSchema:wn,UntitledMultiSelectEnumSchemaSchema:Gt,TitledMultiSelectEnumSchemaSchema:Cn,MultiSelectEnumSchemaSchema:Vn,EnumSchemaSchema:Zn,PrimitiveSchemaDefinitionSchema:ur,ElicitRequestFormParamsSchema:Hn,ResourceTemplateReferenceSchema:Ai,PromptReferenceSchema:Oi,RootSchema:Fc,ClientCapabilities2026Schema:Vc,ServerCapabilities2026Schema:Ks,RequestMetaEnvelopeSchema:Ys,ToolSchema:Ni,ToolResultContentSchema:Zc,SamplingMessageContentBlockSchema:Xs,SamplingMessageSchema:Mi,ResultTypeSchema:Qs,ResultMetaSchema:ea,ResultSchema:Hc,PaginatedResultSchema:hd,CallToolResultSchema:na,ListToolsResultSchema:Bc,ListPromptsResultSchema:Wc,GetPromptResultSchema:Jc,ListResourcesResultSchema:Gc,ListResourceTemplatesResultSchema:Kc,ReadResourceResultSchema:Yc,CompleteResultSchema:Xc,CacheableResultSchema:gd,DiscoverResultSchema:Qc,CreateMessageRequestParamsSchema:Oo,CreateMessageRequestSchema:el,ListRootsRequestSchema:tl,CreateMessageResultSchema:nl,ListRootsResultSchema:rl,ElicitResultSchema:ol,ElicitRequestURLParamsSchema:il,ElicitRequestParamsSchema:sl,ElicitRequestSchema:al,InputRequestSchema:cl,InputResponseSchema:ll,InputRequestsSchema:ul,InputResponsesSchema:ml,InputRequiredResultSchema:Di,InputResponseRequestParamsSchema:yd,CallToolRequestSchema:wd,ListToolsRequestSchema:vd,ListPromptsRequestSchema:$d,GetPromptRequestSchema:xd,ListResourcesRequestSchema:_d,ListResourceTemplatesRequestSchema:Sd,ReadResourceRequestSchema:kd,CompleteRequestSchema:zd,DiscoverRequestSchema:Rd,SubscriptionFilterSchema:ra,SubscriptionsListenRequestSchema:Id,SubscriptionsListenResultMetaSchema:Pd,SubscriptionsListenResultSchema:hl,dispatchRequestSchemas:No,dispatchResultSchemas:jd,NotificationMetaSchema:Ui,SubscriptionsAcknowledgedNotificationSchema:oa,CancelledNotificationParamsSchema:ia,CancelledNotificationSchema:sa,notificationSchemas2026:Ob,JSONRPCResultResponseSchema:cn(Hc),CallToolResultResponseSchema:cn(xe([na,Di])),ListToolsResultResponseSchema:cn(Bc),ListPromptsResultResponseSchema:cn(Wc),GetPromptResultResponseSchema:cn(xe([Jc,Di])),ListResourcesResultResponseSchema:cn(Gc),ListResourceTemplatesResultResponseSchema:cn(Kc),ReadResourceResultResponseSchema:cn(xe([Yc,Di])),CompleteResultResponseSchema:cn(Xc),DiscoverResultResponseSchema:cn(Qc),SubscriptionsListenResultResponseSchema:cn(hl)}}var a6;function ci(){return a6??=s6()}var c6=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function l6(e){return c6.includes(e)}var ic=Symbol("modelcontextprotocol.resultCacheHintFallback");function Tg(e,t){if(t===void 0)return e;let r=e[ic];if(r===void 0)return{...e,[ic]:t};let o={},n=r.ttlMs??t.ttlMs;n!==void 0&&(o.ttlMs=n);let i=r.cacheScope??t.cacheScope;return i!==void 0&&(o.cacheScope=i),{...e,[ic]:o}}function u6(e){return e[ic]}function V_(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function Z_(e){return e==="public"||e==="private"}function H_(e,t){if(e.ttlMs!==void 0&&!V_(e.ttlMs))throw new RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(e.cacheScope!==void 0&&!Z_(e.cacheScope))throw new RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}var ge=(function(e){return e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.ResourceNotFound=-32002]="ResourceNotFound",e[e.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",e[e.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired",e})({}),ke=class wj extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return ac(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ac(this,t)}constructor(t,r,o){super(r),this.code=t,this.data=o,this.name="ProtocolError",q_(this,new.target)}static fromError(t,r,o){if(t===ge.UrlElicitationRequired&&o){let n=o;if(n.elicitations)return new vj(n.elicitations,r)}if(t===ge.UnsupportedProtocolVersion&&o){let n=o;if(Array.isArray(n.supported)&&typeof n.requested=="string")return new ps({supported:n.supported,requested:n.requested},r)}if(t===ge.InvalidParams||t===ge.ResourceNotFound){let n=o;if(typeof n?.uri=="string"&&(t===ge.ResourceNotFound||Object.keys(n).length===1))return new Cg(n.uri,r)}if(t===ge.MissingRequiredClientCapability&&o){let n=o;if(n.requiredCapabilities!==null&&typeof n.requiredCapabilities=="object"&&!Array.isArray(n.requiredCapabilities))return new Ku({requiredCapabilities:n.requiredCapabilities},r)}return new wj(t,r,o)}},Cg=class extends ke{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(ge.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},vj=class extends ke{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(ge.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},ps=class extends ke{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(ge.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Ku=class extends ke{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(ge.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},m6=0,d6="private",f6=["tools/call","prompts/get","resources/read"];function p6(e,t){let r=t.resultType;if(r===void 0)return{...t,resultType:"complete"};if(r==="complete"||f6.includes(e))return t;throw new ke(ge.InternalError,`Handler for ${e} returned resultType '${String(r)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function h6(e,t){let r=u6(t);if(t.resultType!=="complete"||!l6(e))return r===void 0?t:v6(t);let o=t,n=V_(o.ttlMs)?o.ttlMs:b6(r),i=Z_(o.cacheScope)?o.cacheScope:w6(r),s={...o,ttlMs:n,cacheScope:i};return delete s[ic],s}function g6(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function y6(e,t){if(t===void 0)return e;let r=e._meta;return r===void 0?{...e,_meta:{[gr]:t}}:!g6(r)||r[gr]!==void 0?e:{...e,_meta:{...r,[gr]:t}}}function b6(e){return e!==void 0&&V_(e.ttlMs)?e.ttlMs:m6}function w6(e){return e!==void 0&&Z_(e.cacheScope)?e.cacheScope:d6}function v6(e){let t={...e};return delete t[ic],t}var $6=["elicitation/create","sampling/createMessage","roots/list"],Ig;function $j(){if(Ig)return Ig;let e=ci();return Ig={request:{"elicitation/create":J({method:ne("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":J({method:ne("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":J({method:ne("roots/list"),params:je({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Ig}function xj(e){return $6.includes(e)}function E_(e){return xj(e)?$j().request[e]:void 0}function x6(e){return xj(e)?$j().response[e]:void 0}var B_={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},_j={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function Sj(e){return Object.prototype.hasOwnProperty.call(B_,e)}function kj(e){return Object.prototype.hasOwnProperty.call(_j,e)}function _6(e){return Object.prototype.hasOwnProperty.call(B_,e)}function S6(e){return Sj(e)?ci().dispatchRequestSchemas[e]:void 0}function k6(e){return _6(e)?ci().dispatchResultSchemas[e]:void 0}function z6(e){return kj(e)?ci().notificationSchemas2026[e]:void 0}var JG=Object.keys(B_),GG=Object.keys(_j);function Zu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Fu(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let r=e.safeParse(t);return r.success?{ok:!0,value:r.data}:{ok:!1,reason:"invalid",message:String(r.error)}}var R6={ok:!1,reason:"not-in-era"},I6=[Yn,Nr];function P6(e,t){let r=t,o=!1,n=()=>(o||(r={...r},o=!0),r),i=t.tools;e==="tools/list"&&Array.isArray(i)&&i.some(a=>Zu(a)&&"execution"in a)&&(n().tools=i.map(a=>{if(!Zu(a)||!("execution"in a))return a;let c={...a};return delete c.execution,c}));let s=t.capabilities;if(Zu(s)&&"tasks"in s){let a={...s};delete a.tasks,n().capabilities=a}return r}var W_={era:"2026-07-28",hasRequestMethod:Sj,hasNotificationMethod:kj,hasInputRequestMethod:e=>E_(e)!==void 0,validateRequest:(e,t)=>Fu(S6(e),t),validateResult:(e,t)=>Fu(k6(e),t),validateNotification:(e,t)=>Fu(z6(e),t),validateInputRequest:(e,t)=>Fu(E_(e),t),validateInputResponse:(e,t)=>Fu(x6(e),t),samplingResultVariant:()=>R6,outboundEnvelope(e){return{[Yn]:e.protocolVersion,[as]:e.clientInfo,[Nr]:e.clientCapabilities,...e.logLevel!==void 0&&{[ei]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let o of I6)o in e||t.push({key:o,problem:"missing"});let r=ci().RequestMetaEnvelopeSchema.safeParse(e);if(!r.success)for(let o of r.error.issues){let n=o.path.map(String),i=n.length>0?n.join("."):"_meta";n.length===1&&t.some(s=>s.key===i&&s.problem==="missing")||t.push({key:i,problem:o.message})}return t},projectCallToolResult:e=>mj(e),inputRequestSchema:E_,decodeResult(e,t){if(!Zu(t))return{kind:"invalid",error:new Oe(Ue.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let r=t.resultType;if(r===void 0)return{kind:"invalid",error:new Oe(Ue.InvalidResult,`Invalid result for ${e}: missing required resultType \u2014 servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if(typeof r!="string")return{kind:"invalid",error:new Oe(Ue.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:r})};if(r==="input_required"){let s=t.inputRequests,a=Zu(s)?s:{},c=t.requestState,l=t._meta===void 0?void 0:ci().ResultMetaSchema.safeParse(t._meta),u=l?.success?l.data:void 0;return Object.keys(a).length===0&&typeof c!="string"?{kind:"invalid",error:new Oe(Ue.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:a,...typeof c=="string"&&{requestState:c},...u!==void 0&&{_meta:u}}}if(r!=="complete")return{kind:"invalid",error:new Oe(Ue.UnsupportedResultType,`Unsupported result type '${r}' for ${e}`,{resultType:r,method:e})};let o=j6(),n=Object.hasOwn(o,e)?o[e]:void 0;if(n!==void 0){let s=n.safeParse(t);if(!s.success)return{kind:"invalid",error:new Oe(Ue.InvalidResult,`Invalid result for ${e}: ${s.error}`,{method:e})}}let i={...t};return delete i.resultType,{kind:"complete",result:i}},encodeResult(e,t,r){return y6(h6(e,p6(e,P6(e,t))),r)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=ci().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(r=>r.message).join("; ")}`}},Pg;function j6(){if(Pg)return Pg;let e=ci();return Pg={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},Pg}var Yu="2026-07-28";function lo(e){return e!==void 0&&uo(e)?W_:F_}function KP(e){return e.revision!==void 0?lo(e.revision).era:e.era==="modern"?W_.era:F_.era}function T_(e){return zj.some(t=>t.hasRequestMethod(e))}function C_(e){return zj.some(t=>t.hasNotificationMethod(e))}function YP(e){return e==="tasks/get"||e==="tasks/cancel"}var zj=[F_,W_];function XP(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function br(e){if(!XP(e))return;let t=e._meta;return XP(t)?t:void 0}function hs(e){let t=br(e);return t!==void 0&&Yn in t}function lc(e){let t=br(e)?.[Yn];return typeof t=="string"?t:void 0}function ds(e){return lo(Yu).validateEnvelopeMeta(e)}var E6=F1({AnnotationsSchema:()=>co,AudioContentSchema:()=>Qa,BaseMetadataSchema:()=>ao,BaseRequestParamsSchema:()=>Mt,BlobResourceContentsSchema:()=>ju,BooleanSchemaSchema:()=>Ou,CallToolRequestParamsSchema:()=>qh,CallToolRequestSchema:()=>Uh,CallToolResultSchema:()=>Au,CancelTaskRequestSchema:()=>p_,CancelTaskResultSchema:()=>h_,CancelledNotificationParamsSchema:()=>Vp,CancelledNotificationSchema:()=>_u,ClientCapabilitiesSchema:()=>Wp,ClientNotificationSchema:()=>y_,ClientRequestSchema:()=>g_,ClientResultSchema:()=>b_,ClientTasksCapabilitySchema:()=>Hp,CompatibilityCallToolResultSchema:()=>r_,CompleteRequestParamsSchema:()=>fg,CompleteRequestSchema:()=>pg,CompleteResultSchema:()=>hg,ContentBlockSchema:()=>ec,CreateMessageRequestParamsSchema:()=>Xh,CreateMessageRequestSchema:()=>Qh,CreateMessageResultSchema:()=>eg,CreateMessageResultWithToolsSchema:()=>tg,CreateTaskResultSchema:()=>s_,CursorSchema:()=>yu,DiscoverRequestSchema:()=>Yp,DiscoverResultSchema:()=>Xp,ElicitRequestFormParamsSchema:()=>rc,ElicitRequestParamsSchema:()=>sg,ElicitRequestSchema:()=>ag,ElicitRequestURLParamsSchema:()=>ig,ElicitResultSchema:()=>ug,ElicitationCompleteNotificationParamsSchema:()=>cg,ElicitationCompleteNotificationSchema:()=>lg,EmbeddedResourceSchema:()=>jh,EmptyResultSchema:()=>xu,EnumSchemaSchema:()=>og,GetPromptRequestParamsSchema:()=>Rh,GetPromptRequestSchema:()=>Ih,GetPromptResultSchema:()=>Ch,GetTaskPayloadRequestSchema:()=>u_,GetTaskPayloadResultSchema:()=>m_,GetTaskRequestSchema:()=>c_,GetTaskResultSchema:()=>l_,IconSchema:()=>Zp,IconsSchema:()=>ni,ImageContentSchema:()=>Xa,ImplementationSchema:()=>Ga,InitializeRequestParamsSchema:()=>Jp,InitializeRequestSchema:()=>Su,InitializeResultSchema:()=>Gp,InitializedNotificationSchema:()=>Kp,JSONArraySchema:()=>e_,JSONObjectSchema:()=>vt,JSONRPCErrorResponseSchema:()=>Ja,JSONRPCMessageSchema:()=>us,JSONRPCNotificationSchema:()=>$u,JSONRPCRequestSchema:()=>vu,JSONRPCResponseSchema:()=>t_,JSONRPCResultResponseSchema:()=>Wa,JSONValueSchema:()=>Xo,LegacyTitledEnumSchemaSchema:()=>Du,ListChangedOptionsBaseSchema:()=>o_,ListPromptsRequestSchema:()=>kh,ListPromptsResultSchema:()=>zh,ListResourceTemplatesRequestSchema:()=>ih,ListResourceTemplatesResultSchema:()=>sh,ListResourcesRequestSchema:()=>rh,ListResourcesResultSchema:()=>oh,ListRootsRequestSchema:()=>yg,ListRootsResultSchema:()=>bg,ListTasksRequestSchema:()=>d_,ListTasksResultSchema:()=>f_,ListToolsRequestSchema:()=>Mh,ListToolsResultSchema:()=>Dh,LoggingLevelSchema:()=>si,LoggingMessageNotificationParamsSchema:()=>Zh,LoggingMessageNotificationSchema:()=>Hh,ModelHintSchema:()=>Bh,ModelPreferencesSchema:()=>Wh,MultiSelectEnumSchemaSchema:()=>rg,NotificationSchema:()=>en,NotificationsParamsSchema:()=>Qt,NumberSchemaSchema:()=>nc,PaginatedRequestParamsSchema:()=>th,PaginatedRequestSchema:()=>ri,PaginatedResultSchema:()=>oi,PingRequestSchema:()=>zu,PrimitiveSchemaDefinitionSchema:()=>Lu,ProgressNotificationParamsSchema:()=>eh,ProgressNotificationSchema:()=>Ru,ProgressSchema:()=>Qp,ProgressTokenSchema:()=>gu,PromptArgumentSchema:()=>_h,PromptListChangedNotificationSchema:()=>Ah,PromptMessageSchema:()=>Th,PromptReferenceSchema:()=>dg,PromptSchema:()=>Sh,ReadResourceRequestParamsSchema:()=>ah,ReadResourceRequestSchema:()=>ch,ReadResourceResultSchema:()=>lh,RelatedTaskMetadataSchema:()=>Fp,RequestIdSchema:()=>ti,RequestMetaSchema:()=>bu,RequestSchema:()=>$t,ResourceContentsSchema:()=>Iu,ResourceLinkSchema:()=>Eh,ResourceListChangedNotificationSchema:()=>uh,ResourceRequestParamsSchema:()=>Ka,ResourceSchema:()=>Eu,ResourceTemplateReferenceSchema:()=>mg,ResourceTemplateSchema:()=>nh,ResourceUpdatedNotificationParamsSchema:()=>$h,ResourceUpdatedNotificationSchema:()=>xh,ResultMetaObjectSchema:()=>wu,ResultSchema:()=>xt,RoleSchema:()=>ii,RootSchema:()=>gg,RootsListChangedNotificationSchema:()=>wg,SamplingContentSchema:()=>Kh,SamplingMessageContentBlockSchema:()=>is,SamplingMessageSchema:()=>Yh,ServerCapabilitiesSchema:()=>ku,ServerNotificationSchema:()=>v_,ServerRequestSchema:()=>w_,ServerResultSchema:()=>$_,ServerTasksCapabilitySchema:()=>Bp,SetLevelRequestParamsSchema:()=>Fh,SetLevelRequestSchema:()=>Vh,SingleSelectEnumSchemaSchema:()=>ng,StringSchemaSchema:()=>tc,SubscribeRequestParamsSchema:()=>mh,SubscribeRequestSchema:()=>dh,SubscriptionFilterSchema:()=>Tu,SubscriptionsAcknowledgedNotificationParamsSchema:()=>yh,SubscriptionsAcknowledgedNotificationSchema:()=>bh,SubscriptionsListenRequestParamsSchema:()=>hh,SubscriptionsListenRequestSchema:()=>gh,SubscriptionsListenResultMetaSchema:()=>wh,SubscriptionsListenResultSchema:()=>vh,TaskAugmentedRequestParamsSchema:()=>ls,TaskCreationParamsSchema:()=>i_,TaskMetadataSchema:()=>Lp,TaskSchema:()=>ai,TaskStatusNotificationParamsSchema:()=>$g,TaskStatusNotificationSchema:()=>a_,TaskStatusSchema:()=>vg,TextContentSchema:()=>Ya,TextResourceContentsSchema:()=>Pu,TitledMultiSelectEnumSchemaSchema:()=>Uu,TitledSingleSelectEnumSchemaSchema:()=>Mu,ToolAnnotationsSchema:()=>Oh,ToolChoiceSchema:()=>Jh,ToolExecutionSchema:()=>Nh,ToolListChangedNotificationSchema:()=>Lh,ToolResultContentSchema:()=>Gh,ToolSchema:()=>Cu,ToolUseContentSchema:()=>Ph,UnsubscribeRequestParamsSchema:()=>fh,UnsubscribeRequestSchema:()=>ph,UntitledMultiSelectEnumSchemaSchema:()=>qu,UntitledSingleSelectEnumSchemaSchema:()=>Nu});var kt=e=>vu.safeParse(e).success,Mr=e=>$u.safeParse(e).success,Qn=e=>Wa.safeParse(e).success,er=e=>Ja.safeParse(e).success;var mo=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var J_=e=>Su.safeParse(e).success;function G_(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function K_(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var T6="Mcp-Param-",QP="x-mcp-header",C6=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,A6=new Set(["string","integer","boolean"]);function Ag(e){let t=[],r=new Map,o,n=(s,a,c)=>{if(s===null||typeof s!="object")return;let l=s;if(QP in l){if(!c||a.length===0)return`${oc(a)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let m=l[QP];if(typeof m!="string"||m.length===0)return`${oc(a)}: x-mcp-header MUST be a non-empty string`;if(!C6.test(m))return`${oc(a)}: x-mcp-header '${m}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let d=typeof l.type=="string"?l.type:void 0;if(d===void 0||!A6.has(d)){let h=`${oc(a)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${d??"<none>"}`;if(d!=="number")return h;o??=h}let f=m.toLowerCase(),p=r.get(f);if(p!==void 0)return`x-mcp-header '${m}' is not case-insensitively unique (also declared as '${p}')`;r.set(f,m),t.push({path:a,headerName:m,type:d})}let u=l.properties;if(u!==null&&typeof u=="object")for(let[m,d]of Object.entries(u)){let f=n(d,[...a,m],c);if(f!==void 0)return f}for(let m of O6){let d=l[m];if(d===void 0)continue;let f=Array.isArray(d)?d:d!==null&&typeof d=="object"&&N6.has(m)?Object.values(d):[d];for(let p of f){let h=n(p,[...a,`<${m}>`],!1);if(h!==void 0)return h}}},i=n(e,[],!0);return i!==void 0?{valid:!1,reason:o??i}:o===void 0?{valid:!0,declarations:t}:{valid:!1,reason:o,declarations:t}}var O6=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],N6=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function oc(e){return e.length===0?"<root>":e.join(".")}var M6="=?base64?",D6="?=",q6=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,U6=/^-?\d+(\.\d+)?$/;function L6(e){if(typeof e=="string")return e;if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number")return!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)?void 0:String(e)}function F6(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.codePointAt(o);return new TextDecoder("utf-8",{fatal:!0}).decode(r)}function Rj(e){if(!(e.startsWith(M6)&&e.endsWith(D6)))return e;let t=e.slice(9,e.length-2);if(q6.test(t))try{return F6(t)}catch{return}}function V6(e,t){let r=e;for(let o of t){if(r===null||typeof r!="object")return;r=r[o]}return r}function Ij(e,t,r){for(let o of e){let n=`${T6}${o.headerName}`,i=r.get(n),s=V6(t,o.path);if(s==null)continue;let a=L6(s);if(a===void 0)continue;if(i===null)return A_("param-header-missing",n,`the body carries ${oc(o.path)}=${JSON.stringify(s)} but the ${n} header is absent`);let c=Rj(i);if(c===void 0)return A_("param-header-invalid-encoding",n,`the ${n} header carries an invalid Base64 sentinel value`);if(!((o.type==="integer"||o.type==="number")&&U6.test(c)&&typeof s=="number"?Number(c)===s:c===a))return A_("param-header-mismatch",n,`the ${n} header decodes to ${JSON.stringify(c)} but the body carries ${oc(o.path)}=${JSON.stringify(s)}`)}}function A_(e,t,r){return{kind:"reject",rung:"param-header-validation",cell:e,httpStatus:400,code:sc,message:`Bad Request: the request headers and body disagree: ${r}`,data:{mismatch:{header:t,body:r}},settled:!0}}var sc=-32020,KG=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32e3],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[ge.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[sc,ge.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[ge.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope \u2014 and a missing envelope on a request whose protocol-version header names a modern revision \u2014 is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[ge.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision\u2019s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[ge.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[sc],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half \u2014 including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[ge.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced \u2014 pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[sc],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool\u2019s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],Y_={[ge.ParseError]:400,[ge.InvalidRequest]:400,[ge.MethodNotFound]:404,[ge.UnsupportedProtocolVersion]:400,[ge.MissingRequiredClientCapability]:400,[sc]:400};function Pj(e,t){return t==="in-band"?e===ge.MissingRequiredClientCapability?400:200:Y_[e]??400}function Xn(e,t,r,o,n){return{kind:"reject",rung:e,cell:t,httpStatus:r,code:o.code,message:o.message,...o.data!==void 0&&{data:o.data},settled:n}}function yr(e,t,r,o="era-classification"){return Xn(o,e,400,new ke(sc,`Bad Request: the request headers and body disagree: ${r}`,{mismatch:{header:t,body:r}}),!0)}var ej={"tools/call":"name","prompts/get":"name","resources/read":"uri","tasks/get":"taskId","tasks/update":"taskId","tasks/cancel":"taskId"};function Z6(e,t){let r=Object.hasOwn(ej,e)?ej[e]:void 0;if(r===void 0)return;let o=Bu(t)?t[r]:void 0;return{field:r,value:typeof o=="string"?o:void 0}}function jg(e){let t=0;for(;t<e.length;){let o=e.codePointAt(t);if(o!==9&&o!==32)break;t+=1}let r=e.length;for(;r>t;){let o=e.codePointAt(r-1);if(o!==9&&o!==32)break;r-=1}return t===0&&r===e.length?e:e.slice(t,r)}function jj(e,t){if(t.messageKind!=="request")return;let r=t.message.method;if(e.protocolVersionHeader===void 0){let c=t.classification.revision;return yr("version-header-missing","(missing)",c===void 0?"the body carries a modern per-request envelope but the required MCP-Protocol-Version header is absent":`the body envelope names protocol version ${c} but the required MCP-Protocol-Version header is absent`,"standard-header-validation")}if(e.mcpMethodHeader===void 0)return yr("method-header-missing","(missing)",`the body names method ${r} but the required Mcp-Method header is absent`,"standard-header-validation");let o=Z6(r,t.message.params);if(o===void 0)return;let{field:n,value:i}=o;if(e.mcpNameHeader===void 0)return i===void 0?void 0:yr("name-header-missing","(missing)",`the body carries params.${n}="${i}" but the required Mcp-Name header is absent`,"standard-header-validation");let s=jg(e.mcpNameHeader),a=Rj(s);if(a===void 0)return yr("name-header-invalid-encoding",s,"the Mcp-Name header carries an invalid Base64 sentinel value","standard-header-validation");if(i!==void 0&&a!==i)return yr("name-header-mismatch",s,`the body carries params.${n}="${i}" but the Mcp-Name header names "${a}"`,"standard-header-validation")}function Bu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ej(e){return e===void 0?{era:"modern"}:{era:uo(e)?"modern":"legacy",revision:e}}function Og(e){if(!hs(e))return!1;let t=lc(e);if(t===void 0||!uo(t))return!1;let r=br(e);return r!==void 0&&ds(r).length===0}function H6(e){if(e.length===0)return Xn("jsonrpc-shape","empty-batch",400,new ke(ge.InvalidRequest,"Bad Request: empty JSON-RPC batch"),!0);for(let t of e){if(hs(Bu(t)?t.params:void 0))return Xn("jsonrpc-shape","batch-with-modern-element",400,new ke(ge.InvalidRequest,"Bad Request: JSON-RPC batches may not contain requests for protocol revision 2026-07-28 or later"),!0);if(!(kt(t)||Mr(t)||Qn(t)||er(t)))return Xn("jsonrpc-shape","batch-with-invalid-element",400,new ke(ge.InvalidRequest,"Bad Request: JSON-RPC batch contains an invalid message"),!0)}return{kind:"legacy",reason:"batch"}}function B6(e,t){let r=t.params,o=t.method,n=e.protocolVersionHeader,i=n!==void 0&&uo(n);if(o==="initialize"&&!Og(r)){if(i)return yr("initialize-with-modern-header",n,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let s=Bu(r)&&typeof r.protocolVersion=="string"?r.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...s!==void 0&&{requestedVersion:s}}}if(hs(r)){let s=br(r),a=(s===void 0?[]:ds(s))[0];if(a!==void 0)return Xn("envelope","envelope-invalid",400,new ke(ge.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${a.key}: ${a.problem}`,{envelope:a}),!0);let c=lc(r);return n!==void 0&&c!==void 0&&n!==c?yr("header-body-version-mismatch",n,`the body envelope names protocol version ${c} but the MCP-Protocol-Version header names ${n}`):e.mcpMethodHeader!==void 0&&e.mcpMethodHeader!==o?yr("method-header-mismatch",e.mcpMethodHeader,`the body names method ${o} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"request",message:t,classification:Ej(c)}}if(i){let s=br(r),a=ds(s??{}).filter(l=>l.problem==="missing").map(l=>l.key),c=s===void 0?["_meta"]:a.length>0?a:[Yn];return Xn("envelope","modern-header-without-claim",400,new ke(ge.InvalidParams,`Invalid params: the MCP-Protocol-Version header names protocol revision ${n}, but the request is missing the required per-request envelope key(s): ${c.join(", ")}`,{envelope:{missing:c}}),!0)}return{kind:"legacy",reason:"no-claim",...n!==void 0&&{requestedVersion:n}}}function W6(e,t){let r=t.params,o=t.method,n=e.protocolVersionHeader,i=n!==void 0&&uo(n);if(hs(r)){let s=lc(r);if(s===void 0){let c=br(r),l=(c===void 0?[]:ds(c)).find(u=>u.key===Yn)??{key:Yn,problem:"expected a protocol version string"};return Xn("envelope","notification-envelope-invalid",400,new ke(ge.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${l.key}: ${l.problem}`,{envelope:l}),!0)}if(n!==void 0&&n!==s)return yr("notification-header-body-version-mismatch",n,`the notification envelope names protocol version ${s} but the MCP-Protocol-Version header names ${n}`);let a=Ej(s);return a.era==="modern"&&e.mcpMethodHeader!==void 0&&e.mcpMethodHeader!==o?yr("notification-method-header-mismatch",e.mcpMethodHeader,`the notification body names method ${o} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:t,classification:a}}return i?e.mcpMethodHeader!==void 0&&e.mcpMethodHeader!==o?yr("notification-method-header-mismatch",e.mcpMethodHeader,`the notification body names method ${o} but the Mcp-Method header names ${e.mcpMethodHeader}`):{kind:"modern",messageKind:"notification",message:t,classification:{era:"modern",revision:n}}:{kind:"legacy",reason:"notification",...n!==void 0&&{requestedVersion:n}}}function Tj(e){if(e={...e,...e.protocolVersionHeader!==void 0&&{protocolVersionHeader:jg(e.protocolVersionHeader)},...e.mcpMethodHeader!==void 0&&{mcpMethodHeader:jg(e.mcpMethodHeader)},...e.mcpNameHeader!==void 0&&{mcpNameHeader:jg(e.mcpNameHeader)}},e.httpMethod.toUpperCase()!=="POST")return{kind:"legacy",reason:"http-method"};let t=e.body;return Array.isArray(t)?H6(t):Qn(t)||er(t)?{kind:"legacy",reason:"response"}:Bu(t)&&kt(t)?B6(e,t):Bu(t)&&Mr(t)?W6(e,t):Xn("jsonrpc-shape","invalid-json-rpc-body",400,new ke(ge.InvalidRequest,"Bad Request: the request body is not a valid JSON-RPC message"),!0)}function Ng(e,t){switch(e.reason){case"http-method":return Xn("http-method","modern-only-method-not-allowed",405,new ke(-32e3,"Method not allowed."),!0);case"batch":return Xn("jsonrpc-shape","modern-only-batch-not-supported",400,new ke(ge.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return Xn("jsonrpc-shape","modern-only-response-post",400,new ke(ge.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let r=e.requestedVersion;return Xn("era-classification","modern-only-missing-envelope",400,r===void 0?new ke(ge.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new ps({supported:[...t],requested:r}),!0)}}}function Mg(e,t){return nu(e,t)}function Vu(e){return new Set(e.flatMap(t=>Object.keys(t.shape)))}function cc(e){if(e==null)return!1;let t=typeof e;return t!=="object"&&t!=="function"||!("~standard"in e)?!1:typeof e["~standard"]?.validate=="function"}var tj=!1,M_="draft-2020-12";function gs(e,t="input"){let r=e["~standard"],o;if(r.jsonSchema)o=r.jsonSchema[t]({target:M_});else if(r.vendor==="zod"){if(!("_zod"in e))throw new Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");tj||(tj=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),o=ts(e,{target:M_,io:t})}else throw new Error(`Schema library "${r.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output")return o.type!==void 0?o:Cj(o)?{type:"object",...o}:o;if(o.type!==void 0&&o.type!=="object")throw new Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(o.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...o}}var J6=/^#\/(\$defs|definitions)\/([^/~%]+)$/;function Cj(e,t=e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;let r=typeof e.$ref=="string"&&J6.exec(e.$ref);if(r&&t[r[1]]?.[r[2]]?.type==="object")return!0;for(let o of["oneOf","anyOf","allOf"]){let n=e[o];if(Array.isArray(n)&&n.length>0)return n.every(i=>i!==null&&typeof i=="object"&&(i.type==="object"||Cj(i,"$id"in i?{}:t)))}return!1}function G6(e){return e.path?.length?`${e.path.map(t=>String(typeof t=="object"?t.key:t)).join(".")}: ${e.message}`:e.message}async function ms(e,t){let r=await e["~standard"].validate(t);return r.issues&&r.issues.length>0?{success:!1,error:r.issues.map(o=>G6(o)).join(", ")}:{success:!0,data:r.value}}function K6(e){let t=ts(e,{target:M_,io:"input"});return typeof t.pattern=="string"?t.pattern:void 0}var Y6=/\\\.\\d\{(\d+)\}/;function X6(e){let t=Y6.exec(e),r=[void 0,-1,0];return t&&r.push(Number(t[1])),[!1,!0].flatMap(o=>[!1,!0].flatMap(n=>r.map(i=>Kn.datetime({local:o,offset:n,precision:i}))))}function Q6(e,t){let r;switch(e){case"email":r=[gp()];break;case"uri":r=[Fa()];break;case"date":r=[Kn.date()];break;case"date-time":r=X6(t);break}return new Set(r.map(o=>K6(o)).filter(o=>o!==void 0))}function eU(e,t,r){return r!=="zod"?!0:Q6(e,t).has(t)}function Aj(e){let t=gs(e,"input"),r=t.properties||{},o=t.required||[];return Object.entries(r).map(([n,i])=>({name:n,description:i?.description,required:o.includes(n)}))}function Wu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function tU(e){try{return gs(e,"input")}catch(t){let r=t instanceof Error?t.message:String(t);throw new ke(ge.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${r}`)}}var nU=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function X_(e){return nU.has(e)||e.startsWith("x-")}var rU=new Set(["$schema",...Object.keys(rc.shape.requestedSchema.shape)]),nj={string:Vu([tc,Nu,Mu,Du]),number:Vu([nc]),integer:Vu([nc]),boolean:Vu([Ou]),array:Vu([qu,Uu])},oU=new Set(tc.shape.format.unwrap().options);function iU(e,t,r,o){if(!Wu(e))return e;let n=typeof e.type=="string"&&Object.hasOwn(nj,e.type)?nj[e.type]:void 0;if(n===void 0)return e;let i={};for(let[s,a]of Object.entries(e))n.has(s)||X_(s)?i[s]=a:s==="pattern"&&e.type==="string"&&typeof e.format=="string"?oU.has(e.format)?(typeof a!="string"||!eU(e.format,a,r))&&o.push(`${t}.${s}`):i[s]=a:o.push(`${t}.${s}`);return i}function sU(e,t){let r={},o=[];for(let[n,i]of Object.entries(e))n==="properties"&&Wu(i)?r[n]=Object.fromEntries(Object.entries(i).map(([s,a])=>[s,iU(a,`properties.${s}`,t,o)])):rU.has(n)?r[n]=i:X_(n)||o.push(n);if(o.length>0)throw new ke(ge.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${o.join(", ")}`);return r}function aU(e,t){if(!Wu(e.properties))return t;let r=Object.entries(e.properties).filter(([,o])=>!Mg(Lu,o).success).map(([o])=>`properties.${o}`);return r.length>0?r.join(", "):t}function D_(e,t,r=""){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((o,n)=>D_(o,t[n],`${r}[${n}]`)):!Wu(e)||!Wu(t)?[]:Object.entries(e).flatMap(([o,n])=>{let i=r?`${r}.${o}`:o;return Object.prototype.hasOwnProperty.call(t,o)?D_(n,t[o],i):X_(o)?[]:[i]})}function cU(e){if(!cc(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,r=sU(tU(e.requestedSchema),t),o=Mg(rc.shape.requestedSchema,r);if(!o.success)throw new ke(ge.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${aU(r,o.error.message)}`);let n=D_(r,o.data);if(n.length>0)throw new ke(ge.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${n.join(", ")}`);let i=(o.data.required??[]).filter(s=>!Object.prototype.hasOwnProperty.call(o.data.properties,s));if(i.length>0)throw new ke(ge.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:o.data}}function lU(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,r=typeof e.requestState=="string";if(!t&&!r)throw new TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}var uU=Object.assign(lU,{elicit(e){try{return{method:"elicitation/create",params:cU(e)}}catch(t){throw t instanceof ke?new TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var Oj=250;function Nj(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function Mj(e,t){return new Promise((r,o)=>{if(t?.aborted){o(t.reason instanceof Oe?t.reason:new Oe(Ue.RequestTimeout,String(t.reason)));return}let n=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e),i=()=>{clearTimeout(n),o(t?.reason instanceof Oe?t.reason:new Oe(Ue.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",i,{once:!0})})}function Dj(e){let t=new AbortController,r=()=>t.abort(e?.reason);return e?.addEventListener("abort",r,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:o=>t.abort(o),dispose:()=>e?.removeEventListener("abort",r)}}var mU=["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"],dU={IdJagTokenExchangeResponseSchema:z_,OAuthClientInformationFullSchema:I_,OAuthClientInformationSchema:kg,OAuthClientMetadataSchema:Sg,OAuthClientRegistrationErrorSchema:P_,OAuthErrorResponseSchema:R_,OAuthMetadataSchema:xg,OAuthProtectedResourceMetadataSchema:__,OAuthTokenRevocationRequestSchema:j_,OAuthTokensSchema:k_,OpenIdProviderDiscoveryMetadataSchema:S_,OpenIdProviderMetadataSchema:_g},qj={},Uj={};function Lj(e,t){let r=e.slice(0,-6);qj[r]=t,Uj[r]=o=>t.safeParse(o).success}for(let e of mU)Lj(e,E6[e]);for(let[e,t]of Object.entries(dU))Lj(e,t);var fU=Object.freeze(qj),pU=Object.freeze(Uj);function hU(e){switch(e){case"initialize":case"notifications/initialized":return lo(void 0);case"server/discover":return lo(Yu);default:return}}var Fj=6e4,gU=[Yn,as,Nr,ei],yU=["inputResponses","requestState"];function rj(e,t){let r=e.params;if(!Hu(r))return{message:e,lifted:{}};let o=r._meta,n=Hu(o)?gU.filter(c=>c in o):[],i=t==="request"?yU.filter(c=>c in r):[];if(n.length===0&&i.length===0)return{message:e,lifted:{}};let s={},a={...r};if(n.length>0&&Hu(o)){let c={},l={...o};for(let u of n)c[u]=o[u],delete l[u];s.envelope=c,Object.keys(l).length>0?a._meta=l:delete a._meta}for(let c of i)c==="inputResponses"&&(s.inputResponses=a[c]),c==="requestState"&&(s.requestState=a[c]),delete a[c];return{message:{...e,params:a},lifted:s}}function oj(e,t){let r=e.validateResult(t,void 0);if(!(!r.ok&&r.reason==="not-in-era"))return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(o){let n=e.validateResult(t,o);return n.ok?{value:n.value}:{issues:[{message:n.reason==="invalid"?n.message:`not-in-era: ${t}`}]}}}}}function Xu(e){return()=>e}var bU=Xu(void 0);function Q_(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:Xu(t)}}}var Vj;function Dg(e,t){Vj(e,t)}var eS=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{Vj=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??hu,this.setNotificationHandler("notifications/cancelled",t=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",t=>{this._onprogress(t)}),this.setRequestHandler("ping",t=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let r=e.params??{};return{...e,params:{...r,_meta:{...t,...r._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new Oe(Ue.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,r,o,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:n,onTimeout:o})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new Oe(Ue.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let r=this.transport?.onerror;this._transport.onerror=n=>{r?.(n),this._onerror(n)};let o=this._transport?.onmessage;this._transport.onmessage=(n,i)=>{o?.(n,i),Qn(n)||er(n)?this._onresponse(n):kt(n)?this._onrequest(n,i):Mr(n)?this._onnotification(n,i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(n)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let o of this._timeoutInfo.values())clearTimeout(o.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let r=new Oe(Ue.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let o of e.values())o(r);for(let o of t.values())o.abort(r)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:r}=rj(e,"notification"),o=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let s=KP(t.classification);if(s!==o.era){this._onerror(new Error(`Era mismatch on inbound notification '${r.method}': classified as ${s} but this instance serves ${o.era}`));return}}if(C_(r.method)&&!o.hasNotificationMethod(r.method))return;let n=this._notificationHandlers.get(r.method),i=this.fallbackNotificationHandler;n===void 0&&i===void 0||Promise.resolve().then(()=>n===void 0?i(r):n(r,o)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){let{message:r,lifted:o}=rj(e,"request"),n=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(new Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let i=this._transport,s=(h,g,b)=>{let y={jsonrpc:"2.0",id:r.id,error:{code:h,message:g,...b!==void 0&&{data:b}}};i?.send(y).catch(w=>this._onerror(new Error(`Failed to send an error response: ${w}`)))};if(t?.classification!==void 0){let h=KP(t.classification);if(h!==n.era){this._onerror(new Error(`Era mismatch on inbound request '${r.method}': classified as ${h} but this instance serves ${n.era}`));let g=t.classification.revision??h;s(ge.UnsupportedProtocolVersion,`Unsupported protocol version: ${g}`,{supported:this._supportedProtocolVersions,requested:g});return}}if(T_(r.method)&&!n.hasRequestMethod(r.method)&&!(YP(r.method)&&this._customSchemaRequestMethods.has(r.method))){s(ge.MethodNotFound,"Method not found");return}let a=this._requestHandlers.get(r.method)??this.fallbackRequestHandler;if(a===void 0){s(ge.MethodNotFound,"Method not found");return}let c=n.checkInboundEnvelope(o);if(c!==void 0){s(ge.InvalidParams,c);return}let l=(h,g)=>this._notificationViaCodec(this._resolveOutboundCodec(h.method),h,{...g,relatedRequestId:r.id}),u=(h,g,b)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(h.method),h,g,{...b,relatedRequestId:r.id}),m=new AbortController;this._requestHandlerAbortControllers.set(r.id,m);let d=o.inputResponses===void 0?void 0:wU(o.inputResponses),f={sessionId:i?.sessionId,mcpReq:{id:r.id,method:r.method,_meta:r.params?._meta,...o.envelope!==void 0&&{envelope:o.envelope},...d!==void 0&&{inputResponses:d.accepted},...d!==void 0&&d.droppedKeys.length>0&&{droppedInputResponseKeys:d.droppedKeys},requestState:o.requestState===void 0?bU:Xu(o.requestState),signal:m.signal,send:((h,g,b)=>{let y=this._resolveOutboundCodec(h.method);if(this._assertOutboundRequestInEra(y,h.method),cc(g))return u(h,g,b);let w=oj(y,h.method);if(w===void 0)throw new TypeError(`'${h.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(h,w,g)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},p=this.buildContext(f,t);Promise.resolve().then(()=>a(r,p)).then(async h=>{if(m.signal.aborted)return;let g;try{g=n.encodeResult(r.method,h,this._outboundServerInfo())}catch(y){this._onerror(new Error(`Failed to encode result for ${r.method}: ${y}`)),s(ge.InternalError,"Internal error");return}let b={result:g,jsonrpc:"2.0",id:r.id};await i?.send(b)},async h=>{if(m.signal.aborted)return;let g=Number.isSafeInteger(h.code)?h.code:ge.InternalError,b={jsonrpc:"2.0",id:r.id,error:{code:n.encodeErrorCode(g),message:h.message??"Internal error",...h.data!==void 0&&{data:h.data}}};await i?.send(b)}).catch(h=>this._onerror(new Error(`Failed to send response: ${h}`))).finally(()=>{this._requestHandlerAbortControllers.get(r.id)===m&&this._requestHandlerAbortControllers.delete(r.id)})}_onprogress(e){let{progressToken:t,...r}=e.params,o=Number(t),n=this._progressHandlers.get(o);if(!n){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),s=this._timeoutInfo.get(o);if(s&&i&&s.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(a){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(a);return}n(r)}_onresponse(e){let t=Number(e.id),r=this._responseHandlers.get(t);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Qn(e)?r(e):r(ke.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,r){let o=this._resolveOutboundCodec(e.method);if(cc(t))return YP(e.method)||this._assertOutboundRequestInEra(o,e.method),this._requestWithSchemaViaCodec(o,e,t,r);this._assertOutboundRequestInEra(o,e.method);let n=oj(o,e.method);if(n===void 0)throw new TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(o,e,n,t)}_negotiatedWireCodec(){return lo(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=hU(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(T_(t)&&!e.hasRequestMethod(t))throw new Oe(Ue.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,r){let o=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(o,e.method),this._requestWithSchemaViaCodec(o,e,t,r)}_requestWithSchemaViaCodec(e,t,r,o){let{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s,headers:a}=o??{},c=Date.now(),l,u;return new Promise((m,d)=>{let f=_=>{d(_)};if(!this._transport){f(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(_){f(_);return}if(o?.signal?.aborted){let _=o.signal.reason;throw _ instanceof Oe?_:new Oe(Ue.RequestTimeout,String(_))}let p=e.era===Yu&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:"2.0",id:h};o?.onprogress&&(this._progressHandlers.set(h,o.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let b=this._envelopeOutbound(g),y=!1,w=_=>{y||(this._progressHandlers.delete(h),p===void 0?t.method!=="initialize"&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(_)}}),{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`))):p.abort(),d(_ instanceof Oe?_:new Oe(Ue.RequestTimeout,String(_))))};this._responseHandlers.set(h,_=>{if(o?.signal?.aborted)return;if(y=!0,_ instanceof Error)return d(_);let $;try{$=e.decodeResult(t.method,_.result)}catch(k){return d(k instanceof Error?k:new Error(String(k)))}if($.kind==="invalid")return d($.error);if($.kind==="input_required"){if(o?.allowInputRequired===!0)return m(vU($));let k={codec:e,request:t,resultSchema:r,options:o,flowStartedAt:c,retry:(P,I)=>this._requestWithSchemaViaCodec(e,P===void 0?{method:t.method}:{method:t.method,params:P},r,I)};return m(this._resolveNonCompleteResult($,k))}let x=$.result;ms(r,x).then(k=>{k.success?m(k.data):d(new Oe(Ue.InvalidResult,`Invalid result for ${t.method}: ${k.error}`))},d)}),l=()=>w(o?.signal?.reason),o?.signal?.addEventListener("abort",l,{once:!0});let v=o?.timeout??Fj,S=()=>w(new Oe(Ue.RequestTimeout,"Request timed out",{timeout:v}));this._setupTimeout(h,v,o?.maxTotalTimeout,S,o?.resetTimeoutOnProgress??!1),this._transport.send(b,{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s,headers:a,requestSignal:p?.signal}).catch(_=>{this._progressHandlers.delete(h),d(_)})}).finally(()=>{l&&o?.signal?.removeEventListener("abort",l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,r){if(!this._transport)throw new Oe(Ue.NotConnected,"Not connected");if(C_(t.method)&&!e.hasNotificationMethod(t.method))throw new Oe(Ue.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let o=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&r?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(o,r).catch(n=>this._onerror(n))});return}await this._transport.send(o,r)}setRequestHandler(e,t,r){this.assertRequestHandlerCapability(e);let o;if(typeof t=="function"){if(!T_(e))throw new TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);o=(n,i)=>{let s=this._negotiatedWireCodec(),a=s.validateRequest(e,n);if(!a.ok&&a.reason==="not-in-era"&&(a=s.validateInputRequest(e,n)),!a.ok)throw a.reason==="not-in-era"?new ke(ge.InternalError,`No wire schema for ${e} in the resolved era`):new Error(a.message);return Promise.resolve(t(a.value,i))}}else if(r)o=async(n,i)=>{let s=await ms(t.params,{...n.params});if(!s.success)throw new ke(ge.InvalidParams,`Invalid params for ${e}: ${s.error}`);return r(s.data,i)};else throw new TypeError("setRequestHandler: handler is required");typeof t=="function"?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,o))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,r){if(typeof t=="function"){if(!C_(e))throw new TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(o,n)=>{let i=n.validateNotification(e,o);if(!i.ok)throw i.reason==="not-in-era"?new ke(ge.InternalError,`No wire schema for ${e} in the resolved era`):new Error(i.message);return Promise.resolve(t(i.value))});return}if(!r)throw new TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async o=>{let n=await ms(t.params,{...o.params});if(!n.success)throw new ke(ge.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await r(n.data,o)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Hu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function tS(e,t){let r={...e};for(let o in t){let n=o,i=t[n];if(i===void 0)continue;let s=r[n];r[n]=Hu(s)&&Hu(i)?{...s,...i}:i}return r}function ij(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function wU(e){let t={},r=[];if(!ij(e))return{accepted:t,droppedKeys:r};for(let[o,n]of Object.entries(e)){if(!ij(n)||"method"in n||"result"in n){r.push(o);continue}t[o]=n}return{accepted:t,droppedKeys:r}}function vU(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var $U=ue((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,r=/\\([\u000b\u0020-\u00ff])/g,o=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=n;function n(a){if(!a)throw new TypeError("argument string is required");var c=typeof a=="object"?i(a):a;if(typeof c!="string")throw new TypeError("argument string is required to be a string");var l=c.indexOf(";"),u=l!==-1?c.slice(0,l).trim():c.trim();if(!o.test(u))throw new TypeError("invalid media type");var m=new s(u.toLowerCase());if(l!==-1){var d,f,p;for(t.lastIndex=l;f=t.exec(c);){if(f.index!==l)throw new TypeError("invalid parameter format");l+=f[0].length,d=f[1].toLowerCase(),p=f[2],p.charCodeAt(0)===34&&(p=p.slice(1,-1),p.indexOf("\\")!==-1&&(p=p.replace(r,"$1"))),m.parameters[d]=p}if(l!==c.length)throw new TypeError("invalid parameter format")}return m}function i(a){var c;if(typeof a.getHeader=="function"?c=a.getHeader("content-type"):typeof a.headers=="object"&&(c=a.headers&&a.headers["content-type"]),typeof c!="string")throw new TypeError("content-type header is missing from object");return c}function s(a){this.parameters=Object.create(null),this.type=a}})),xU=Td($U(),1);function nS(e){if(e)try{return xU.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function rS(e){return e==="application/json"?!0:nS(e)==="application/json"}var Zj=10*1024*1024,oS=class{_buffer;_maxBufferSize;constructor(e){this._maxBufferSize=e?.maxBufferSize??Zj}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){for(;this._buffer;){let e=this._buffer.indexOf(`
65
+ `);if(e===-1)return null;let t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");this._buffer=this._buffer.subarray(e+1);try{return Hj(t)}catch(r){if(r instanceof SyntaxError)continue;throw r}}return null}clear(){this._buffer=void 0}};function Hj(e){return us.parse(JSON.parse(e))}function iS(e){return JSON.stringify(e)+`
66
+ `}var _U=/^[A-Za-z0-9._-]{1,128}$/;function SU(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!_U.test(e)){let r=[...e].filter(o=>!/[A-Za-z0-9._-]/.test(o)).filter((o,n,i)=>i.indexOf(o)===n);return t.push(`Tool name contains invalid characters: ${r.map(o=>`"${o}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function kU(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function sS(e){let t=SU(e);return kU(e,t.warnings),t.isValid}function zU(e){return typeof e=="object"&&e!==null&&"_zod"in e}function RU(e){return typeof e=="object"&&e!==null&&!("_zod"in e)&&"_def"in e&&typeof e._def?.typeName=="string"}function IU(e){if(typeof e!="object"||e===null||cc(e))return!1;let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null?!1:Object.values(e).every(r=>zU(r))}function qg(e){if(e!==void 0){if(IU(e))return J(e);if(typeof e=="object"&&e!==null&&!cc(e)&&Object.values(e).some(t=>RU(t)))throw new TypeError("Raw-shape inputSchema/outputSchema/argsSchema fields must be Zod v4 schemas. Got a Zod v3 field schema. Import from `zod/v4` (or upgrade your zod import), or wrap with `z.object({...})` yourself.");if(!cc(e))throw new TypeError("inputSchema/outputSchema/argsSchema must be a Standard Schema (e.g. z.object({...})) or a raw Zod shape ({ field: z.string() }).");return e}}var Lg=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var r=class extends t{constructor(b){if(super(),!e.IDENTIFIER.test(b))throw new Error("CodeGen: name must be a valid identifier");this.str=b}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=r;var o=class extends t{constructor(b){super(),this._items=typeof b=="string"?[b]:b}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let b=this._items[0];return b===""||b==='""'}get str(){var b;return(b=this._str)!==null&&b!==void 0?b:this._str=this._items.reduce((y,w)=>`${y}${w}`,"")}get names(){var b;return(b=this._names)!==null&&b!==void 0?b:this._names=this._items.reduce((y,w)=>(w instanceof r&&(y[w.str]=(y[w.str]||0)+1),y),{})}};e._Code=o,e.nil=new o("");function n(b,...y){let w=[b[0]],v=0;for(;v<y.length;)a(w,y[v]),w.push(b[++v]);return new o(w)}e._=n;let i=new o("+");function s(b,...y){let w=[f(b[0])],v=0;for(;v<y.length;)w.push(i),a(w,y[v]),w.push(i,f(b[++v]));return c(w),new o(w)}e.str=s;function a(b,y){y instanceof o?b.push(...y._items):y instanceof r?b.push(y):b.push(m(y))}e.addCodeArg=a;function c(b){let y=1;for(;y<b.length-1;){if(b[y]===i){let w=l(b[y-1],b[y+1]);if(w!==void 0){b.splice(y-1,3,w);continue}b[y++]="+"}y++}}function l(b,y){if(y==='""')return b;if(b==='""')return y;if(typeof b=="string")return y instanceof r||b[b.length-1]!=='"'?void 0:typeof y!="string"?`${b.slice(0,-1)}${y}"`:y[0]==='"'?b.slice(0,-1)+y.slice(1):void 0;if(typeof y=="string"&&y[0]==='"'&&!(b instanceof r))return`"${b}${y.slice(1)}`}function u(b,y){return y.emptyStr()?b:b.emptyStr()?y:s`${b}${y}`}e.strConcat=u;function m(b){return typeof b=="number"||typeof b=="boolean"||b===null?b:f(Array.isArray(b)?b.join(","):b)}function d(b){return new o(f(b))}e.stringify=d;function f(b){return JSON.stringify(b).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.safeStringify=f;function p(b){return typeof b=="string"&&e.IDENTIFIER.test(b)?new o(`.${b}`):n`[${b}]`}e.getProperty=p;function h(b){if(typeof b=="string"&&e.IDENTIFIER.test(b))return new o(`${b}`);throw new Error(`CodeGen: invalid export name: ${b}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(b){return new o(b.toString())}e.regexpCode=g})),Bj=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Lg();var r=class extends Error{constructor(c){super(`CodeGen: "code" for ${c} not defined`),this.value=c.value}},o;(function(c){c[c.Started=0]="Started",c[c.Completed=1]="Completed"})(o||(e.UsedValueState=o={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};var n=class{constructor({prefixes:c,parent:l}={}){this._names={},this._prefixes=c,this._parent=l}toName(c){return c instanceof t.Name?c:this.name(c)}name(c){return new t.Name(this._newName(c))}_newName(c){let l=this._names[c]||this._nameGroup(c);return`${c}${l.index++}`}_nameGroup(c){var l,u;if(!((u=(l=this._parent)===null||l===void 0?void 0:l._prefixes)===null||u===void 0)&&u.has(c)||this._prefixes&&!this._prefixes.has(c))throw new Error(`CodeGen: prefix "${c}" is not allowed in this scope`);return this._names[c]={prefix:c,index:0}}};e.Scope=n;var i=class extends t.Name{constructor(c,l){super(l),this.prefix=c}setValue(c,{property:l,itemIndex:u}){this.value=c,this.scopePath=(0,t._)`.${new t.Name(l)}[${u}]`}};e.ValueScopeName=i;let s=(0,t._)`\n`;var a=class extends n{constructor(c){super(c),this._values={},this._scope=c.scope,this.opts={...c,_n:c.lines?s:t.nil}}get(){return this._scope}name(c){return new i(c,this._newName(c))}value(c,l){var u;if(l.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let m=this.toName(c),{prefix:d}=m,f=(u=l.key)!==null&&u!==void 0?u:l.ref,p=this._values[d];if(p){let b=p.get(f);if(b)return b}else p=this._values[d]=new Map;p.set(f,m);let h=this._scope[d]||(this._scope[d]=[]),g=h.length;return h[g]=l.ref,m.setValue(l,{property:d,itemIndex:g}),m}getValue(c,l){let u=this._values[c];if(u)return u.get(l)}scopeRefs(c,l=this._values){return this._reduceValues(l,u=>{if(u.scopePath===void 0)throw new Error(`CodeGen: name "${u}" has no value`);return(0,t._)`${c}${u.scopePath}`})}scopeCode(c=this._values,l,u){return this._reduceValues(c,m=>{if(m.value===void 0)throw new Error(`CodeGen: name "${m}" has no value`);return m.value.code},l,u)}_reduceValues(c,l,u={},m){let d=t.nil;for(let f in c){let p=c[f];if(!p)continue;let h=u[f]=u[f]||new Map;p.forEach(g=>{if(h.has(g))return;h.set(g,o.Started);let b=l(g);if(b){let y=this.opts.es5?e.varKinds.var:e.varKinds.const;d=(0,t._)`${d}${y} ${g} = ${b};${this.opts._n}`}else if(b=m?.(g))d=(0,t._)`${d}${b}${this.opts._n}`;else throw new r(g);h.set(g,o.Completed)})}return d}};e.ValueScope=a})),qe=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=Lg(),r=Bj();var o=Lg();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return o._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return o.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return o.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return o.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return o.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return o.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return o.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return o.Name}});var n=Bj();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return n.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return n.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return n.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return n.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};var i=class{optimizeNodes(){return this}optimizeNames(z,R){return this}},s=class extends i{constructor(z,R,C){super(),this.varKind=z,this.name=R,this.rhs=C}render({es5:z,_n:R}){let C=z?r.varKinds.var:this.varKind,U=this.rhs===void 0?"":` = ${this.rhs}`;return`${C} ${this.name}${U};`+R}optimizeNames(z,R){if(z[this.name.str])return this.rhs&&(this.rhs=T(this.rhs,z,R)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},a=class extends i{constructor(z,R,C){super(),this.lhs=z,this.rhs=R,this.sideEffects=C}render({_n:z}){return`${this.lhs} = ${this.rhs};`+z}optimizeNames(z,R){if(!(this.lhs instanceof t.Name&&!z[this.lhs.str]&&!this.sideEffects))return this.rhs=T(this.rhs,z,R),this}get names(){return N(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends a{constructor(z,R,C,U){super(z,C,U),this.op=R}render({_n:z}){return`${this.lhs} ${this.op}= ${this.rhs};`+z}},l=class extends i{constructor(z){super(),this.label=z,this.names={}}render({_n:z}){return`${this.label}:`+z}},u=class extends i{constructor(z){super(),this.label=z,this.names={}}render({_n:z}){return`break${this.label?` ${this.label}`:""};`+z}},m=class extends i{constructor(z){super(),this.error=z}render({_n:z}){return`throw ${this.error};`+z}get names(){return this.error.names}},d=class extends i{constructor(z){super(),this.code=z}render({_n:z}){return`${this.code};`+z}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(z,R){return this.code=T(this.code,z,R),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},f=class extends i{constructor(z=[]){super(),this.nodes=z}render(z){return this.nodes.reduce((R,C)=>R+C.render(z),"")}optimizeNodes(){let{nodes:z}=this,R=z.length;for(;R--;){let C=z[R].optimizeNodes();Array.isArray(C)?z.splice(R,1,...C):C?z[R]=C:z.splice(R,1)}return z.length>0?this:void 0}optimizeNames(z,R){let{nodes:C}=this,U=C.length;for(;U--;){let W=C[U];W.optimizeNames(z,R)||(q(z,W.names),C.splice(U,1))}return C.length>0?this:void 0}get names(){return this.nodes.reduce((z,R)=>E(z,R.names),{})}},p=class extends f{render(z){return"{"+z._n+super.render(z)+"}"+z._n}},h=class extends f{},g=class extends p{};g.kind="else";var b=class Ug extends p{constructor(R,C){super(C),this.condition=R}render(R){let C=`if(${this.condition})`+super.render(R);return this.else&&(C+="else "+this.else.render(R)),C}optimizeNodes(){super.optimizeNodes();let R=this.condition;if(R===!0)return this.nodes;let C=this.else;if(C){let U=C.optimizeNodes();C=this.else=Array.isArray(U)?new g(U):U}if(C)return R===!1?C instanceof Ug?C:C.nodes:this.nodes.length?this:new Ug(Z(R),C instanceof Ug?[C]:C.nodes);if(!(R===!1||!this.nodes.length))return this}optimizeNames(R,C){var U;if(this.else=(U=this.else)===null||U===void 0?void 0:U.optimizeNames(R,C),!!(super.optimizeNames(R,C)||this.else))return this.condition=T(this.condition,R,C),this}get names(){let R=super.names;return N(R,this.condition),this.else&&E(R,this.else.names),R}};b.kind="if";var y=class extends p{};y.kind="for";var w=class extends y{constructor(z){super(),this.iteration=z}render(z){return`for(${this.iteration})`+super.render(z)}optimizeNames(z,R){if(super.optimizeNames(z,R))return this.iteration=T(this.iteration,z,R),this}get names(){return E(super.names,this.iteration.names)}},v=class extends y{constructor(z,R,C,U){super(),this.varKind=z,this.name=R,this.from=C,this.to=U}render(z){let R=z.es5?r.varKinds.var:this.varKind,{name:C,from:U,to:W}=this;return`for(${R} ${C}=${U}; ${C}<${W}; ${C}++)`+super.render(z)}get names(){return N(N(super.names,this.from),this.to)}},S=class extends y{constructor(z,R,C,U){super(),this.loop=z,this.varKind=R,this.name=C,this.iterable=U}render(z){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(z)}optimizeNames(z,R){if(super.optimizeNames(z,R))return this.iterable=T(this.iterable,z,R),this}get names(){return E(super.names,this.iterable.names)}},_=class extends p{constructor(z,R,C){super(),this.name=z,this.args=R,this.async=C}render(z){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(z)}};_.kind="func";var $=class extends f{render(z){return"return "+super.render(z)}};$.kind="return";var x=class extends p{render(z){let R="try"+super.render(z);return this.catch&&(R+=this.catch.render(z)),this.finally&&(R+=this.finally.render(z)),R}optimizeNodes(){var z,R;return super.optimizeNodes(),(z=this.catch)===null||z===void 0||z.optimizeNodes(),(R=this.finally)===null||R===void 0||R.optimizeNodes(),this}optimizeNames(z,R){var C,U;return super.optimizeNames(z,R),(C=this.catch)===null||C===void 0||C.optimizeNames(z,R),(U=this.finally)===null||U===void 0||U.optimizeNames(z,R),this}get names(){let z=super.names;return this.catch&&E(z,this.catch.names),this.finally&&E(z,this.finally.names),z}},k=class extends p{constructor(z){super(),this.error=z}render(z){return`catch(${this.error})`+super.render(z)}};k.kind="catch";var P=class extends p{render(z){return"finally"+super.render(z)}};P.kind="finally";var I=class{constructor(z,R={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...R,_n:R.lines?`
67
+ `:""},this._extScope=z,this._scope=new r.Scope({parent:z}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(z){return this._scope.name(z)}scopeName(z){return this._extScope.name(z)}scopeValue(z,R){let C=this._extScope.value(z,R);return(this._values[C.prefix]||(this._values[C.prefix]=new Set)).add(C),C}getScopeValue(z,R){return this._extScope.getValue(z,R)}scopeRefs(z){return this._extScope.scopeRefs(z,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(z,R,C,U){let W=this._scope.toName(R);return C!==void 0&&U&&(this._constants[W.str]=C),this._leafNode(new s(z,W,C)),W}const(z,R,C){return this._def(r.varKinds.const,z,R,C)}let(z,R,C){return this._def(r.varKinds.let,z,R,C)}var(z,R,C){return this._def(r.varKinds.var,z,R,C)}assign(z,R,C){return this._leafNode(new a(z,R,C))}add(z,R){return this._leafNode(new c(z,e.operators.ADD,R))}code(z){return typeof z=="function"?z():z!==t.nil&&this._leafNode(new d(z)),this}object(...z){let R=["{"];for(let[C,U]of z)R.length>1&&R.push(","),R.push(C),(C!==U||this.opts.es5)&&(R.push(":"),(0,t.addCodeArg)(R,U));return R.push("}"),new t._Code(R)}if(z,R,C){if(this._blockNode(new b(z)),R&&C)this.code(R).else().code(C).endIf();else if(R)this.code(R).endIf();else if(C)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(z){return this._elseNode(new b(z))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(b,g)}_for(z,R){return this._blockNode(z),R&&this.code(R).endFor(),this}for(z,R){return this._for(new w(z),R)}forRange(z,R,C,U,W=this.opts.es5?r.varKinds.var:r.varKinds.let){let X=this._scope.toName(z);return this._for(new v(W,X,R,C),()=>U(X))}forOf(z,R,C,U=r.varKinds.const){let W=this._scope.toName(z);if(this.opts.es5){let X=R instanceof t.Name?R:this.var("_arr",R);return this.forRange("_i",0,(0,t._)`${X}.length`,Y=>{this.var(W,(0,t._)`${X}[${Y}]`),C(W)})}return this._for(new S("of",U,W,R),()=>C(W))}forIn(z,R,C,U=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(z,(0,t._)`Object.keys(${R})`,C);let W=this._scope.toName(z);return this._for(new S("in",U,W,R),()=>C(W))}endFor(){return this._endBlockNode(y)}label(z){return this._leafNode(new l(z))}break(z){return this._leafNode(new u(z))}return(z){let R=new $;if(this._blockNode(R),this.code(z),R.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode($)}try(z,R,C){if(!R&&!C)throw new Error('CodeGen: "try" without "catch" and "finally"');let U=new x;if(this._blockNode(U),this.code(z),R){let W=this.name("e");this._currNode=U.catch=new k(W),R(W)}return C&&(this._currNode=U.finally=new P,this.code(C)),this._endBlockNode(k,P)}throw(z){return this._leafNode(new m(z))}block(z,R){return this._blockStarts.push(this._nodes.length),z&&this.code(z).endBlock(R),this}endBlock(z){let R=this._blockStarts.pop();if(R===void 0)throw new Error("CodeGen: not in self-balancing block");let C=this._nodes.length-R;if(C<0||z!==void 0&&C!==z)throw new Error(`CodeGen: wrong number of nodes: ${C} vs ${z} expected`);return this._nodes.length=R,this}func(z,R=t.nil,C,U){return this._blockNode(new _(z,R,C)),U&&this.code(U).endFunc(),this}endFunc(){return this._endBlockNode(_)}optimize(z=1){for(;z-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(z){return this._currNode.nodes.push(z),this}_blockNode(z){this._currNode.nodes.push(z),this._nodes.push(z)}_endBlockNode(z,R){let C=this._currNode;if(C instanceof z||R&&C instanceof R)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${R?`${z.kind}/${R.kind}`:z.kind}"`)}_elseNode(z){let R=this._currNode;if(!(R instanceof b))throw new Error('CodeGen: "else" without "if"');return this._currNode=R.else=z,this}get _root(){return this._nodes[0]}get _currNode(){let z=this._nodes;return z[z.length-1]}set _currNode(z){let R=this._nodes;R[R.length-1]=z}};e.CodeGen=I;function E(z,R){for(let C in R)z[C]=(z[C]||0)+(R[C]||0);return z}function N(z,R){return R instanceof t._CodeOrName?E(z,R.names):z}function T(z,R,C){if(z instanceof t.Name)return U(z);if(!W(z))return z;return new t._Code(z._items.reduce((X,Y)=>(Y instanceof t.Name&&(Y=U(Y)),Y instanceof t._Code?X.push(...Y._items):X.push(Y),X),[]));function U(X){let Y=C[X.str];return Y===void 0||R[X.str]!==1?X:(delete R[X.str],Y)}function W(X){return X instanceof t._Code&&X._items.some(Y=>Y instanceof t.Name&&R[Y.str]===1&&C[Y.str]!==void 0)}}function q(z,R){for(let C in R)z[C]=(z[C]||0)-(R[C]||0)}function Z(z){return typeof z=="boolean"||typeof z=="number"||z===null?!z:(0,t._)`!${A(z)}`}e.not=Z;let D=L(e.operators.AND);function V(...z){return z.reduce(D)}e.and=V;let F=L(e.operators.OR);function M(...z){return z.reduce(F)}e.or=M;function L(z){return(R,C)=>R===t.nil?C:C===t.nil?R:(0,t._)`${A(R)} ${z} ${A(C)}`}function A(z){return z instanceof t.Name?z:(0,t._)`(${z})`}})),We=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=qe(),r=Lg();function o(_){let $={};for(let x of _)$[x]=!0;return $}e.toHash=o;function n(_,$){return typeof $=="boolean"?$:Object.keys($).length===0?!0:(i(_,$),!s($,_.self.RULES.all))}e.alwaysValidSchema=n;function i(_,$=_.schema){let{opts:x,self:k}=_;if(!x.strictSchema||typeof $=="boolean")return;let P=k.RULES.keywords;for(let I in $)P[I]||S(_,`unknown keyword: "${I}"`)}e.checkUnknownRules=i;function s(_,$){if(typeof _=="boolean")return!_;for(let x in _)if($[x])return!0;return!1}e.schemaHasRules=s;function a(_,$){if(typeof _=="boolean")return!_;for(let x in _)if(x!=="$ref"&&$.all[x])return!0;return!1}e.schemaHasRulesButRef=a;function c({topSchemaRef:_,schemaPath:$},x,k,P){if(!P){if(typeof x=="number"||typeof x=="boolean")return x;if(typeof x=="string")return(0,t._)`${x}`}return(0,t._)`${_}${$}${(0,t.getProperty)(k)}`}e.schemaRefOrVal=c;function l(_){return d(decodeURIComponent(_))}e.unescapeFragment=l;function u(_){return encodeURIComponent(m(_))}e.escapeFragment=u;function m(_){return typeof _=="number"?`${_}`:_.replace(/~/g,"~0").replace(/\//g,"~1")}e.escapeJsonPointer=m;function d(_){return _.replace(/~1/g,"/").replace(/~0/g,"~")}e.unescapeJsonPointer=d;function f(_,$){if(Array.isArray(_))for(let x of _)$(x);else $(_)}e.eachItem=f;function p({mergeNames:_,mergeToName:$,mergeValues:x,resultToName:k}){return(P,I,E,N)=>{let T=E===void 0?I:E instanceof t.Name?(I instanceof t.Name?_(P,I,E):$(P,I,E),E):I instanceof t.Name?($(P,E,I),I):x(I,E);return N===t.Name&&!(T instanceof t.Name)?k(P,T):T}}e.mergeEvaluated={props:p({mergeNames:(_,$,x)=>_.if((0,t._)`${x} !== true && ${$} !== undefined`,()=>{_.if((0,t._)`${$} === true`,()=>_.assign(x,!0),()=>_.assign(x,(0,t._)`${x} || {}`).code((0,t._)`Object.assign(${x}, ${$})`))}),mergeToName:(_,$,x)=>_.if((0,t._)`${x} !== true`,()=>{$===!0?_.assign(x,!0):(_.assign(x,(0,t._)`${x} || {}`),g(_,x,$))}),mergeValues:(_,$)=>_===!0?!0:{..._,...$},resultToName:h}),items:p({mergeNames:(_,$,x)=>_.if((0,t._)`${x} !== true && ${$} !== undefined`,()=>_.assign(x,(0,t._)`${$} === true ? true : ${x} > ${$} ? ${x} : ${$}`)),mergeToName:(_,$,x)=>_.if((0,t._)`${x} !== true`,()=>_.assign(x,$===!0?!0:(0,t._)`${x} > ${$} ? ${x} : ${$}`)),mergeValues:(_,$)=>_===!0?!0:Math.max(_,$),resultToName:(_,$)=>_.var("items",$)})};function h(_,$){if($===!0)return _.var("props",!0);let x=_.var("props",(0,t._)`{}`);return $!==void 0&&g(_,x,$),x}e.evaluatedPropsToName=h;function g(_,$,x){Object.keys(x).forEach(k=>_.assign((0,t._)`${$}${(0,t.getProperty)(k)}`,!0))}e.setEvaluated=g;let b={};function y(_,$){return _.scopeValue("func",{ref:$,code:b[$.code]||(b[$.code]=new r._Code($.code))})}e.useFunc=y;var w;(function(_){_[_.Num=0]="Num",_[_.Str=1]="Str"})(w||(e.Type=w={}));function v(_,$,x){if(_ instanceof t.Name){let k=$===w.Num;return x?k?(0,t._)`"[" + ${_} + "]"`:(0,t._)`"['" + ${_} + "']"`:k?(0,t._)`"/" + ${_}`:(0,t._)`"/" + ${_}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return x?(0,t.getProperty)(_).toString():"/"+m(_)}e.getErrorPath=v;function S(_,$,x=_.opts.strictSchema){if(x){if($=`strict mode: ${$}`,x===!0)throw new Error($);_.self.logger.warn($)}}e.checkStrictMode=S})),wr=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r={data:new t.Name("data"),valCxt:new t.Name("valCxt"),instancePath:new t.Name("instancePath"),parentData:new t.Name("parentData"),parentDataProperty:new t.Name("parentDataProperty"),rootData:new t.Name("rootData"),dynamicAnchors:new t.Name("dynamicAnchors"),vErrors:new t.Name("vErrors"),errors:new t.Name("errors"),this:new t.Name("this"),self:new t.Name("self"),scope:new t.Name("scope"),json:new t.Name("json"),jsonPos:new t.Name("jsonPos"),jsonLen:new t.Name("jsonLen"),jsonPart:new t.Name("jsonPart")};e.default=r})),Vg=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=qe(),r=We(),o=wr();e.keywordError={message:({keyword:g})=>(0,t.str)`must pass "${g}" keyword validation`},e.keyword$DataError={message:({keyword:g,schemaType:b})=>b?(0,t.str)`"${g}" keyword must be ${b} ($data)`:(0,t.str)`"${g}" keyword is invalid ($data)`};function n(g,b=e.keywordError,y,w){let{it:v}=g,{gen:S,compositeRule:_,allErrors:$}=v,x=m(g,b,y);w??(_||$)?c(S,x):l(v,(0,t._)`[${x}]`)}e.reportError=n;function i(g,b=e.keywordError,y){let{it:w}=g,{gen:v,compositeRule:S,allErrors:_}=w;c(v,m(g,b,y)),S||_||l(w,o.default.vErrors)}e.reportExtraError=i;function s(g,b){g.assign(o.default.errors,b),g.if((0,t._)`${o.default.vErrors} !== null`,()=>g.if(b,()=>g.assign((0,t._)`${o.default.vErrors}.length`,b),()=>g.assign(o.default.vErrors,null)))}e.resetErrorsCount=s;function a({gen:g,keyword:b,schemaValue:y,data:w,errsCount:v,it:S}){if(v===void 0)throw new Error("ajv implementation error");let _=g.name("err");g.forRange("i",v,o.default.errors,$=>{g.const(_,(0,t._)`${o.default.vErrors}[${$}]`),g.if((0,t._)`${_}.instancePath === undefined`,()=>g.assign((0,t._)`${_}.instancePath`,(0,t.strConcat)(o.default.instancePath,S.errorPath))),g.assign((0,t._)`${_}.schemaPath`,(0,t.str)`${S.errSchemaPath}/${b}`),S.opts.verbose&&(g.assign((0,t._)`${_}.schema`,y),g.assign((0,t._)`${_}.data`,w))})}e.extendErrors=a;function c(g,b){let y=g.const("err",b);g.if((0,t._)`${o.default.vErrors} === null`,()=>g.assign(o.default.vErrors,(0,t._)`[${y}]`),(0,t._)`${o.default.vErrors}.push(${y})`),g.code((0,t._)`${o.default.errors}++`)}function l(g,b){let{gen:y,validateName:w,schemaEnv:v}=g;v.$async?y.throw((0,t._)`new ${g.ValidationError}(${b})`):(y.assign((0,t._)`${w}.errors`,b),y.return(!1))}let u={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function m(g,b,y){let{createErrors:w}=g.it;return w===!1?(0,t._)`{}`:d(g,b,y)}function d(g,b,y={}){let{gen:w,it:v}=g,S=[f(v,y),p(g,y)];return h(g,b,S),w.object(...S)}function f({errorPath:g},{instancePath:b}){let y=b?(0,t.str)`${g}${(0,r.getErrorPath)(b,r.Type.Str)}`:g;return[o.default.instancePath,(0,t.strConcat)(o.default.instancePath,y)]}function p({keyword:g,it:{errSchemaPath:b}},{schemaPath:y,parentSchema:w}){let v=w?b:(0,t.str)`${b}/${g}`;return y&&(v=(0,t.str)`${v}${(0,r.getErrorPath)(y,r.Type.Str)}`),[u.schemaPath,v]}function h(g,{params:b,message:y},w){let{keyword:v,data:S,schemaValue:_,it:$}=g,{opts:x,propertyName:k,topSchemaRef:P,schemaPath:I}=$;w.push([u.keyword,v],[u.params,typeof b=="function"?b(g):b||(0,t._)`{}`]),x.messages&&w.push([u.message,typeof y=="function"?y(g):y]),x.verbose&&w.push([u.schema,_],[u.parentSchema,(0,t._)`${P}${I}`],[o.default.data,S]),k&&w.push([u.propertyName,k])}})),PU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Vg(),r=qe(),o=wr(),n={message:"boolean schema is false"};function i(c){let{gen:l,schema:u,validateName:m}=c;u===!1?a(c,!1):typeof u=="object"&&u.$async===!0?l.return(o.default.data):(l.assign((0,r._)`${m}.errors`,null),l.return(!0))}e.topBoolOrEmptySchema=i;function s(c,l){let{gen:u,schema:m}=c;m===!1?(u.var(l,!1),a(c)):u.var(l,!0)}e.boolOrEmptySchema=s;function a(c,l){let{gen:u,data:m}=c,d={gen:u,keyword:"false schema",data:m,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:c};(0,t.reportError)(d,n,void 0,l)}})),Wj=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set(["string","number","integer","boolean","null","object","array"]);function r(n){return typeof n=="string"&&t.has(n)}e.isJSONType=r;function o(){let n={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...n,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},n.number,n.string,n.array,n.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=o})),Jj=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:n,self:i},s){let a=i.RULES.types[s];return a&&a!==!0&&r(n,a)}e.schemaHasRulesForType=t;function r(n,i){return i.rules.some(s=>o(n,s))}e.shouldUseGroup=r;function o(n,i){var s;return n[i.keyword]!==void 0||((s=i.definition.implements)===null||s===void 0?void 0:s.some(a=>n[a]!==void 0))}e.shouldUseRule=o})),Fg=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=Wj(),r=Jj(),o=Vg(),n=qe(),i=We();var s;(function(w){w[w.Correct=0]="Correct",w[w.Wrong=1]="Wrong"})(s||(e.DataType=s={}));function a(w){let v=c(w.type);if(v.includes("null")){if(w.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!v.length&&w.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');w.nullable===!0&&v.push("null")}return v}e.getSchemaTypes=a;function c(w){let v=Array.isArray(w)?w:w?[w]:[];if(v.every(t.isJSONType))return v;throw new Error("type must be JSONType or JSONType[]: "+v.join(","))}e.getJSONTypes=c;function l(w,v){let{gen:S,data:_,opts:$}=w,x=m(v,$.coerceTypes),k=v.length>0&&!(x.length===0&&v.length===1&&(0,r.schemaHasRulesForType)(w,v[0]));if(k){let P=h(v,_,$.strictNumbers,s.Wrong);S.if(P,()=>{x.length?d(w,v,x):b(w)})}return k}e.coerceAndCheckDataType=l;let u=new Set(["string","number","integer","boolean","null"]);function m(w,v){return v?w.filter(S=>u.has(S)||v==="array"&&S==="array"):[]}function d(w,v,S){let{gen:_,data:$,opts:x}=w,k=_.let("dataType",(0,n._)`typeof ${$}`),P=_.let("coerced",(0,n._)`undefined`);x.coerceTypes==="array"&&_.if((0,n._)`${k} == 'object' && Array.isArray(${$}) && ${$}.length == 1`,()=>_.assign($,(0,n._)`${$}[0]`).assign(k,(0,n._)`typeof ${$}`).if(h(v,$,x.strictNumbers),()=>_.assign(P,$))),_.if((0,n._)`${P} !== undefined`);for(let E of S)(u.has(E)||E==="array"&&x.coerceTypes==="array")&&I(E);_.else(),b(w),_.endIf(),_.if((0,n._)`${P} !== undefined`,()=>{_.assign($,P),f(w,P)});function I(E){switch(E){case"string":_.elseIf((0,n._)`${k} == "number" || ${k} == "boolean"`).assign(P,(0,n._)`"" + ${$}`).elseIf((0,n._)`${$} === null`).assign(P,(0,n._)`""`);return;case"number":_.elseIf((0,n._)`${k} == "boolean" || ${$} === null
68
+ || (${k} == "string" && ${$} && ${$} == +${$})`).assign(P,(0,n._)`+${$}`);return;case"integer":_.elseIf((0,n._)`${k} === "boolean" || ${$} === null
69
+ || (${k} === "string" && ${$} && ${$} == +${$} && !(${$} % 1))`).assign(P,(0,n._)`+${$}`);return;case"boolean":_.elseIf((0,n._)`${$} === "false" || ${$} === 0 || ${$} === null`).assign(P,!1).elseIf((0,n._)`${$} === "true" || ${$} === 1`).assign(P,!0);return;case"null":_.elseIf((0,n._)`${$} === "" || ${$} === 0 || ${$} === false`),_.assign(P,null);return;case"array":_.elseIf((0,n._)`${k} === "string" || ${k} === "number"
70
+ || ${k} === "boolean" || ${$} === null`).assign(P,(0,n._)`[${$}]`)}}}function f({gen:w,parentData:v,parentDataProperty:S},_){w.if((0,n._)`${v} !== undefined`,()=>w.assign((0,n._)`${v}[${S}]`,_))}function p(w,v,S,_=s.Correct){let $=_===s.Correct?n.operators.EQ:n.operators.NEQ,x;switch(w){case"null":return(0,n._)`${v} ${$} null`;case"array":x=(0,n._)`Array.isArray(${v})`;break;case"object":x=(0,n._)`${v} && typeof ${v} == "object" && !Array.isArray(${v})`;break;case"integer":x=k((0,n._)`!(${v} % 1) && !isNaN(${v})`);break;case"number":x=k();break;default:return(0,n._)`typeof ${v} ${$} ${w}`}return _===s.Correct?x:(0,n.not)(x);function k(P=n.nil){return(0,n.and)((0,n._)`typeof ${v} == "number"`,P,S?(0,n._)`isFinite(${v})`:n.nil)}}e.checkDataType=p;function h(w,v,S,_){if(w.length===1)return p(w[0],v,S,_);let $,x=(0,i.toHash)(w);if(x.array&&x.object){let k=(0,n._)`typeof ${v} != "object"`;$=x.null?k:(0,n._)`!${v} || ${k}`,delete x.null,delete x.array,delete x.object}else $=n.nil;x.number&&delete x.integer;for(let k in x)$=(0,n.and)($,p(k,v,S,_));return $}e.checkDataTypes=h;let g={message:({schema:w})=>`must be ${w}`,params:({schema:w,schemaValue:v})=>typeof w=="string"?(0,n._)`{type: ${w}}`:(0,n._)`{type: ${v}}`};function b(w){let v=y(w);(0,o.reportError)(v,g)}e.reportTypeError=b;function y(w){let{gen:v,data:S,schema:_}=w,$=(0,i.schemaRefOrVal)(w,_,"type");return{gen:v,keyword:"type",data:S,schema:_.type,schemaCode:$,schemaValue:$,parentSchema:_,params:{},it:w}}})),jU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;let t=qe(),r=We();function o(i,s){let{properties:a,items:c}=i.schema;if(s==="object"&&a)for(let l in a)n(i,l,a[l].default);else s==="array"&&Array.isArray(c)&&c.forEach((l,u)=>n(i,u,l.default))}e.assignDefaults=o;function n(i,s,a){let{gen:c,compositeRule:l,data:u,opts:m}=i;if(a===void 0)return;let d=(0,t._)`${u}${(0,t.getProperty)(s)}`;if(l){(0,r.checkStrictMode)(i,`default is ignored for: ${d}`);return}let f=(0,t._)`${d} === undefined`;m.useDefaults==="empty"&&(f=(0,t._)`${f} || ${d} === null || ${d} === ""`),c.if(f,(0,t._)`${d} = ${(0,t.stringify)(a)}`)}})),vr=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=qe(),r=We(),o=wr(),n=We();function i(w,v){let{gen:S,data:_,it:$}=w;S.if(m(S,_,v,$.opts.ownProperties),()=>{w.setParams({missingProperty:(0,t._)`${v}`},!0),w.error()})}e.checkReportMissingProp=i;function s({gen:w,data:v,it:{opts:S}},_,$){return(0,t.or)(..._.map(x=>(0,t.and)(m(w,v,x,S.ownProperties),(0,t._)`${$} = ${x}`)))}e.checkMissingProp=s;function a(w,v){w.setParams({missingProperty:v},!0),w.error()}e.reportMissingProp=a;function c(w){return w.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(w,v,S){return(0,t._)`${c(w)}.call(${v}, ${S})`}e.isOwnProperty=l;function u(w,v,S,_){let $=(0,t._)`${v}${(0,t.getProperty)(S)} !== undefined`;return _?(0,t._)`${$} && ${l(w,v,S)}`:$}e.propertyInData=u;function m(w,v,S,_){let $=(0,t._)`${v}${(0,t.getProperty)(S)} === undefined`;return _?(0,t.or)($,(0,t.not)(l(w,v,S))):$}e.noPropertyInData=m;function d(w){return w?Object.keys(w).filter(v=>v!=="__proto__"):[]}e.allSchemaProperties=d;function f(w,v){return d(v).filter(S=>!(0,r.alwaysValidSchema)(w,v[S]))}e.schemaProperties=f;function p({schemaCode:w,data:v,it:{gen:S,topSchemaRef:_,schemaPath:$,errorPath:x},it:k},P,I,E){let N=E?(0,t._)`${w}, ${v}, ${_}${$}`:v,T=[[o.default.instancePath,(0,t.strConcat)(o.default.instancePath,x)],[o.default.parentData,k.parentData],[o.default.parentDataProperty,k.parentDataProperty],[o.default.rootData,o.default.rootData]];k.opts.dynamicRef&&T.push([o.default.dynamicAnchors,o.default.dynamicAnchors]);let q=(0,t._)`${N}, ${S.object(...T)}`;return I!==t.nil?(0,t._)`${P}.call(${I}, ${q})`:(0,t._)`${P}(${q})`}e.callValidateCode=p;let h=(0,t._)`new RegExp`;function g({gen:w,it:{opts:v}},S){let _=v.unicodeRegExp?"u":"",{regExp:$}=v.code,x=$(S,_);return w.scopeValue("pattern",{key:x.toString(),ref:x,code:(0,t._)`${$.code==="new RegExp"?h:(0,n.useFunc)(w,$)}(${S}, ${_})`})}e.usePattern=g;function b(w){let{gen:v,data:S,keyword:_,it:$}=w,x=v.name("valid");if($.allErrors){let P=v.let("valid",!0);return k(()=>v.assign(P,!1)),P}return v.var(x,!0),k(()=>v.break()),x;function k(P){let I=v.const("len",(0,t._)`${S}.length`);v.forRange("i",0,I,E=>{w.subschema({keyword:_,dataProp:E,dataPropType:r.Type.Num},x),v.if((0,t.not)(x),P)})}}e.validateArray=b;function y(w){let{gen:v,schema:S,keyword:_,it:$}=w;if(!Array.isArray(S))throw new Error("ajv implementation error");if(S.some(P=>(0,r.alwaysValidSchema)($,P))&&!$.opts.unevaluated)return;let x=v.let("valid",!1),k=v.name("_valid");v.block(()=>S.forEach((P,I)=>{let E=w.subschema({keyword:_,schemaProp:I,compositeRule:!0},k);v.assign(x,(0,t._)`${x} || ${k}`),w.mergeValidEvaluated(E,k)||v.if((0,t.not)(x))})),w.result(x,()=>w.reset(),()=>w.error(!0))}e.validateUnion=y})),EU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=qe(),r=wr(),o=vr(),n=Vg();function i(f,p){let{gen:h,keyword:g,schema:b,parentSchema:y,it:w}=f,v=p.macro.call(w.self,b,y,w),S=u(h,g,v);w.opts.validateSchema!==!1&&w.self.validateSchema(v,!0);let _=h.name("valid");f.subschema({schema:v,schemaPath:t.nil,errSchemaPath:`${w.errSchemaPath}/${g}`,topSchemaRef:S,compositeRule:!0},_),f.pass(_,()=>f.error(!0))}e.macroKeywordCode=i;function s(f,p){var h;let{gen:g,keyword:b,schema:y,parentSchema:w,$data:v,it:S}=f;l(S,p);let _=u(g,b,!v&&p.compile?p.compile.call(S.self,y,w,S):p.validate),$=g.let("valid");f.block$data($,x),f.ok((h=p.valid)!==null&&h!==void 0?h:$);function x(){if(p.errors===!1)I(),p.modifying&&a(f),E(()=>f.error());else{let N=p.async?k():P();p.modifying&&a(f),E(()=>c(f,N))}}function k(){let N=g.let("ruleErrs",null);return g.try(()=>I((0,t._)`await `),T=>g.assign($,!1).if((0,t._)`${T} instanceof ${S.ValidationError}`,()=>g.assign(N,(0,t._)`${T}.errors`),()=>g.throw(T))),N}function P(){let N=(0,t._)`${_}.errors`;return g.assign(N,null),I(t.nil),N}function I(N=p.async?(0,t._)`await `:t.nil){let T=S.opts.passContext?r.default.this:r.default.self,q=!("compile"in p&&!v||p.schema===!1);g.assign($,(0,t._)`${N}${(0,o.callValidateCode)(f,_,T,q)}`,p.modifying)}function E(N){var T;g.if((0,t.not)((T=p.valid)!==null&&T!==void 0?T:$),N)}}e.funcKeywordCode=s;function a(f){let{gen:p,data:h,it:g}=f;p.if(g.parentData,()=>p.assign(h,(0,t._)`${g.parentData}[${g.parentDataProperty}]`))}function c(f,p){let{gen:h}=f;h.if((0,t._)`Array.isArray(${p})`,()=>{h.assign(r.default.vErrors,(0,t._)`${r.default.vErrors} === null ? ${p} : ${r.default.vErrors}.concat(${p})`).assign(r.default.errors,(0,t._)`${r.default.vErrors}.length`),(0,n.extendErrors)(f)},()=>f.error())}function l({schemaEnv:f},p){if(p.async&&!f.$async)throw new Error("async keyword in sync schema")}function u(f,p,h){if(h===void 0)throw new Error(`keyword "${p}" failed to compile`);return f.scopeValue("keyword",typeof h=="function"?{ref:h}:{ref:h,code:(0,t.stringify)(h)})}function m(f,p,h=!1){return!p.length||p.some(g=>g==="array"?Array.isArray(f):g==="object"?f&&typeof f=="object"&&!Array.isArray(f):typeof f==g||h&&typeof f>"u")}e.validSchemaType=m;function d({schema:f,opts:p,self:h,errSchemaPath:g},b,y){if(Array.isArray(b.keyword)?!b.keyword.includes(y):b.keyword!==y)throw new Error("ajv implementation error");let w=b.dependencies;if(w?.some(v=>!Object.prototype.hasOwnProperty.call(f,v)))throw new Error(`parent schema must have dependencies of ${y}: ${w.join(",")}`);if(b.validateSchema&&!b.validateSchema(f[y])){let v=`keyword "${y}" value is invalid at path "${g}": `+h.errorsText(b.validateSchema.errors);if(p.validateSchema==="log")h.logger.error(v);else throw new Error(v)}}e.validateKeywordUsage=d})),TU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=qe(),r=We();function o(s,{keyword:a,schemaProp:c,schema:l,schemaPath:u,errSchemaPath:m,topSchemaRef:d}){if(a!==void 0&&l!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(a!==void 0){let f=s.schema[a];return c===void 0?{schema:f,schemaPath:(0,t._)`${s.schemaPath}${(0,t.getProperty)(a)}`,errSchemaPath:`${s.errSchemaPath}/${a}`}:{schema:f[c],schemaPath:(0,t._)`${s.schemaPath}${(0,t.getProperty)(a)}${(0,t.getProperty)(c)}`,errSchemaPath:`${s.errSchemaPath}/${a}/${(0,r.escapeFragment)(c)}`}}if(l!==void 0){if(u===void 0||m===void 0||d===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:l,schemaPath:u,topSchemaRef:d,errSchemaPath:m}}throw new Error('either "keyword" or "schema" must be passed')}e.getSubschema=o;function n(s,a,{dataProp:c,dataPropType:l,data:u,dataTypes:m,propertyName:d}){if(u!==void 0&&c!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:f}=a;if(c!==void 0){let{errorPath:h,dataPathArr:g,opts:b}=a;p(f.let("data",(0,t._)`${a.data}${(0,t.getProperty)(c)}`,!0)),s.errorPath=(0,t.str)`${h}${(0,r.getErrorPath)(c,l,b.jsPropertySyntax)}`,s.parentDataProperty=(0,t._)`${c}`,s.dataPathArr=[...g,s.parentDataProperty]}u!==void 0&&(p(u instanceof t.Name?u:f.let("data",u,!0)),d!==void 0&&(s.propertyName=d)),m&&(s.dataTypes=m);function p(h){s.data=h,s.dataLevel=a.dataLevel+1,s.dataTypes=[],a.definedProperties=new Set,s.parentData=a.data,s.dataNames=[...a.dataNames,h]}}e.extendSubschemaData=n;function i(s,{jtdDiscriminator:a,jtdMetadata:c,compositeRule:l,createErrors:u,allErrors:m}){l!==void 0&&(s.compositeRule=l),u!==void 0&&(s.createErrors=u),m!==void 0&&(s.allErrors=m),s.jtdDiscriminator=a,s.jtdMetadata=c}e.extendSubschemaMode=i})),Gj=ue(((e,t)=>{t.exports=function r(o,n){if(o===n)return!0;if(o&&n&&typeof o=="object"&&typeof n=="object"){if(o.constructor!==n.constructor)return!1;var i,s,a;if(Array.isArray(o)){if(i=o.length,i!=n.length)return!1;for(s=i;s--!==0;)if(!r(o[s],n[s]))return!1;return!0}if(o.constructor===RegExp)return o.source===n.source&&o.flags===n.flags;if(o.valueOf!==Object.prototype.valueOf)return o.valueOf()===n.valueOf();if(o.toString!==Object.prototype.toString)return o.toString()===n.toString();if(a=Object.keys(o),i=a.length,i!==Object.keys(n).length)return!1;for(s=i;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[s]))return!1;for(s=i;s--!==0;){var c=a[s];if(!r(o[c],n[c]))return!1}return!0}return o!==o&&n!==n}})),CU=ue(((e,t)=>{var r=t.exports=function(i,s,a){typeof s=="function"&&(a=s,s={}),a=s.cb||a;var c=typeof a=="function"?a:a.pre||function(){},l=a.post||function(){};o(s,c,l,i,"",i)};r.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},r.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},r.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},r.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function o(i,s,a,c,l,u,m,d,f,p){if(c&&typeof c=="object"&&!Array.isArray(c)){s(c,l,u,m,d,f,p);for(var h in c){var g=c[h];if(Array.isArray(g)){if(h in r.arrayKeywords)for(var b=0;b<g.length;b++)o(i,s,a,g[b],l+"/"+h+"/"+b,u,l,h,c,b)}else if(h in r.propsKeywords){if(g&&typeof g=="object")for(var y in g)o(i,s,a,g[y],l+"/"+h+"/"+n(y),u,l,h,c,y)}else(h in r.keywords||i.allKeys&&!(h in r.skipKeywords))&&o(i,s,a,g,l+"/"+h,u,l,h,c)}a(c,l,u,m,d,f,p)}}function n(i){return i.replace(/~/g,"~0").replace(/\//g,"~1")}})),Zg=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=We(),r=Gj(),o=CU(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function i(g,b=!0){return typeof g=="boolean"?!0:b===!0?!a(g):b?c(g)<=b:!1}e.inlineRef=i;let s=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function a(g){for(let b in g){if(s.has(b))return!0;let y=g[b];if(Array.isArray(y)&&y.some(a)||typeof y=="object"&&a(y))return!0}return!1}function c(g){let b=0;for(let y in g){if(y==="$ref")return 1/0;if(b++,!n.has(y)&&(typeof g[y]=="object"&&(0,t.eachItem)(g[y],w=>b+=c(w)),b===1/0))return 1/0}return b}function l(g,b="",y){return y!==!1&&(b=d(b)),u(g,g.parse(b))}e.getFullPath=l;function u(g,b){return g.serialize(b).split("#")[0]+"#"}e._getFullPath=u;let m=/#\/?$/;function d(g){return g?g.replace(m,""):""}e.normalizeId=d;function f(g,b,y){return y=d(y),g.resolve(b,y)}e.resolveUrl=f;let p=/^[a-z_][-a-z0-9._]*$/i;function h(g,b){if(typeof g=="boolean")return{};let{schemaId:y,uriResolver:w}=this.opts,v=d(g[y]||b),S={"":v},_=l(w,v,!1),$={},x=new Set;return o(g,{allKeys:!0},(I,E,N,T)=>{if(T===void 0)return;let q=_+E,Z=S[T];typeof I[y]=="string"&&(Z=D.call(this,I[y])),V.call(this,I.$anchor),V.call(this,I.$dynamicAnchor),S[E]=Z;function D(F){let M=this.opts.uriResolver.resolve;if(F=d(Z?M(Z,F):F),x.has(F))throw P(F);x.add(F);let L=this.refs[F];return typeof L=="string"&&(L=this.refs[L]),typeof L=="object"?k(I,L.schema,F):F!==d(q)&&(F[0]==="#"?(k(I,$[F],F),$[F]=I):this.refs[F]=q),F}function V(F){if(typeof F=="string"){if(!p.test(F))throw new Error(`invalid anchor "${F}"`);D.call(this,`#${F}`)}}}),$;function k(I,E,N){if(E!==void 0&&!r(I,E))throw P(N)}function P(I){return new Error(`reference "${I}" resolves to more than one schema`)}}e.getSchemaRefs=h})),uc=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=PU(),r=Fg(),o=Jj(),n=Fg(),i=jU(),s=EU(),a=TU(),c=qe(),l=wr(),u=Zg(),m=We(),d=Vg();function f(H){if(_(H)&&(x(H),S(H))){b(H);return}p(H,()=>(0,t.topBoolOrEmptySchema)(H))}e.validateFunctionCode=f;function p({gen:H,validateName:Q,schema:re,schemaEnv:de,opts:ae},pe){ae.code.es5?H.func(Q,(0,c._)`${l.default.data}, ${l.default.valCxt}`,de.$async,()=>{H.code((0,c._)`"use strict"; ${w(re,ae)}`),g(H,ae),H.code(pe)}):H.func(Q,(0,c._)`${l.default.data}, ${h(ae)}`,de.$async,()=>H.code(w(re,ae)).code(pe))}function h(H){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${H.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(H,Q){H.if(l.default.valCxt,()=>{H.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),H.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),H.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),H.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),Q.dynamicRef&&H.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{H.var(l.default.instancePath,(0,c._)`""`),H.var(l.default.parentData,(0,c._)`undefined`),H.var(l.default.parentDataProperty,(0,c._)`undefined`),H.var(l.default.rootData,l.default.data),Q.dynamicRef&&H.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function b(H){let{schema:Q,opts:re,gen:de}=H;p(H,()=>{re.$comment&&Q.$comment&&T(H),I(H),de.let(l.default.vErrors,null),de.let(l.default.errors,0),re.unevaluated&&y(H),k(H),q(H)})}function y(H){let{gen:Q,validateName:re}=H;H.evaluated=Q.const("evaluated",(0,c._)`${re}.evaluated`),Q.if((0,c._)`${H.evaluated}.dynamicProps`,()=>Q.assign((0,c._)`${H.evaluated}.props`,(0,c._)`undefined`)),Q.if((0,c._)`${H.evaluated}.dynamicItems`,()=>Q.assign((0,c._)`${H.evaluated}.items`,(0,c._)`undefined`))}function w(H,Q){let re=typeof H=="object"&&H[Q.schemaId];return re&&(Q.code.source||Q.code.process)?(0,c._)`/*# sourceURL=${re} */`:c.nil}function v(H,Q){if(_(H)&&(x(H),S(H))){$(H,Q);return}(0,t.boolOrEmptySchema)(H,Q)}function S({schema:H,self:Q}){if(typeof H=="boolean")return!H;for(let re in H)if(Q.RULES.all[re])return!0;return!1}function _(H){return typeof H.schema!="boolean"}function $(H,Q){let{schema:re,gen:de,opts:ae}=H;ae.$comment&&re.$comment&&T(H),E(H),N(H);let pe=de.const("_errs",l.default.errors);k(H,pe),de.var(Q,(0,c._)`${pe} === ${l.default.errors}`)}function x(H){(0,m.checkUnknownRules)(H),P(H)}function k(H,Q){if(H.opts.jtd)return D(H,[],!1,Q);let re=(0,r.getSchemaTypes)(H.schema);D(H,re,!(0,r.coerceAndCheckDataType)(H,re),Q)}function P(H){let{schema:Q,errSchemaPath:re,opts:de,self:ae}=H;Q.$ref&&de.ignoreKeywordsWithRef&&(0,m.schemaHasRulesButRef)(Q,ae.RULES)&&ae.logger.warn(`$ref: keywords ignored in schema at path "${re}"`)}function I(H){let{schema:Q,opts:re}=H;Q.default!==void 0&&re.useDefaults&&re.strictSchema&&(0,m.checkStrictMode)(H,"default is ignored in the schema root")}function E(H){let Q=H.schema[H.opts.schemaId];Q&&(H.baseId=(0,u.resolveUrl)(H.opts.uriResolver,H.baseId,Q))}function N(H){if(H.schema.$async&&!H.schemaEnv.$async)throw new Error("async schema in sync schema")}function T({gen:H,schemaEnv:Q,schema:re,errSchemaPath:de,opts:ae}){let pe=re.$comment;if(ae.$comment===!0)H.code((0,c._)`${l.default.self}.logger.log(${pe})`);else if(typeof ae.$comment=="function"){let Ie=(0,c.str)`${de}/$comment`,Je=H.scopeValue("root",{ref:Q.root});H.code((0,c._)`${l.default.self}.opts.$comment(${pe}, ${Ie}, ${Je}.schema)`)}}function q(H){let{gen:Q,schemaEnv:re,validateName:de,ValidationError:ae,opts:pe}=H;re.$async?Q.if((0,c._)`${l.default.errors} === 0`,()=>Q.return(l.default.data),()=>Q.throw((0,c._)`new ${ae}(${l.default.vErrors})`)):(Q.assign((0,c._)`${de}.errors`,l.default.vErrors),pe.unevaluated&&Z(H),Q.return((0,c._)`${l.default.errors} === 0`))}function Z({gen:H,evaluated:Q,props:re,items:de}){re instanceof c.Name&&H.assign((0,c._)`${Q}.props`,re),de instanceof c.Name&&H.assign((0,c._)`${Q}.items`,de)}function D(H,Q,re,de){let{gen:ae,schema:pe,data:Ie,allErrors:Je,opts:Ze,self:Ye}=H,{RULES:Xe}=Ye;if(pe.$ref&&(Ze.ignoreKeywordsWithRef||!(0,m.schemaHasRulesButRef)(pe,Xe))){ae.block(()=>X(H,"$ref",Xe.all.$ref.definition));return}Ze.jtd||F(H,Q),ae.block(()=>{for(let bt of Xe.rules)Pt(bt);Pt(Xe.post)});function Pt(bt){(0,o.shouldUseGroup)(pe,bt)&&(bt.type?(ae.if((0,n.checkDataType)(bt.type,Ie,Ze.strictNumbers)),V(H,bt),Q.length===1&&Q[0]===bt.type&&re&&(ae.else(),(0,n.reportTypeError)(H)),ae.endIf()):V(H,bt),Je||ae.if((0,c._)`${l.default.errors} === ${de||0}`))}}function V(H,Q){let{gen:re,schema:de,opts:{useDefaults:ae}}=H;ae&&(0,i.assignDefaults)(H,Q.type),re.block(()=>{for(let pe of Q.rules)(0,o.shouldUseRule)(de,pe)&&X(H,pe.keyword,pe.definition,Q.type)})}function F(H,Q){H.schemaEnv.meta||!H.opts.strictTypes||(M(H,Q),H.opts.allowUnionTypes||L(H,Q),A(H,H.dataTypes))}function M(H,Q){if(Q.length){if(!H.dataTypes.length){H.dataTypes=Q;return}Q.forEach(re=>{R(H.dataTypes,re)||U(H,`type "${re}" not allowed by context "${H.dataTypes.join(",")}"`)}),C(H,Q)}}function L(H,Q){Q.length>1&&!(Q.length===2&&Q.includes("null"))&&U(H,"use allowUnionTypes to allow union type keyword")}function A(H,Q){let re=H.self.RULES.all;for(let de in re){let ae=re[de];if(typeof ae=="object"&&(0,o.shouldUseRule)(H.schema,ae)){let{type:pe}=ae.definition;pe.length&&!pe.some(Ie=>z(Q,Ie))&&U(H,`missing type "${pe.join(",")}" for keyword "${de}"`)}}}function z(H,Q){return H.includes(Q)||Q==="number"&&H.includes("integer")}function R(H,Q){return H.includes(Q)||Q==="integer"&&H.includes("number")}function C(H,Q){let re=[];for(let de of H.dataTypes)R(Q,de)?re.push(de):Q.includes("integer")&&de==="number"&&re.push("integer");H.dataTypes=re}function U(H,Q){let re=H.schemaEnv.baseId+H.errSchemaPath;Q+=` at "${re}" (strictTypes)`,(0,m.checkStrictMode)(H,Q,H.opts.strictTypes)}var W=class{constructor(H,Q,re){if((0,s.validateKeywordUsage)(H,Q,re),this.gen=H.gen,this.allErrors=H.allErrors,this.keyword=re,this.data=H.data,this.schema=H.schema[re],this.$data=Q.$data&&H.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,m.schemaRefOrVal)(H,this.schema,re,this.$data),this.schemaType=Q.schemaType,this.parentSchema=H.schema,this.params={},this.it=H,this.def=Q,this.$data)this.schemaCode=H.gen.const("vSchema",ye(this.$data,H));else if(this.schemaCode=this.schemaValue,!(0,s.validSchemaType)(this.schema,Q.schemaType,Q.allowUndefined))throw new Error(`${re} value must be ${JSON.stringify(Q.schemaType)}`);("code"in Q?Q.trackErrors:Q.errors!==!1)&&(this.errsCount=H.gen.const("_errs",l.default.errors))}result(H,Q,re){this.failResult((0,c.not)(H),Q,re)}failResult(H,Q,re){this.gen.if(H),re?re():this.error(),Q?(this.gen.else(),Q(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(H,Q){this.failResult((0,c.not)(H),void 0,Q)}fail(H){if(H===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(H),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(H){if(!this.$data)return this.fail(H);let{schemaCode:Q}=this;this.fail((0,c._)`${Q} !== undefined && (${(0,c.or)(this.invalid$data(),H)})`)}error(H,Q,re){if(Q){this.setParams(Q),this._error(H,re),this.setParams({});return}this._error(H,re)}_error(H,Q){(H?d.reportExtraError:d.reportError)(this,this.def.error,Q)}$dataError(){(0,d.reportError)(this,this.def.$dataError||d.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,d.resetErrorsCount)(this.gen,this.errsCount)}ok(H){this.allErrors||this.gen.if(H)}setParams(H,Q){Q?Object.assign(this.params,H):this.params=H}block$data(H,Q,re=c.nil){this.gen.block(()=>{this.check$data(H,re),Q()})}check$data(H=c.nil,Q=c.nil){if(!this.$data)return;let{gen:re,schemaCode:de,schemaType:ae,def:pe}=this;re.if((0,c.or)((0,c._)`${de} === undefined`,Q)),H!==c.nil&&re.assign(H,!0),(ae.length||pe.validateSchema)&&(re.elseIf(this.invalid$data()),this.$dataError(),H!==c.nil&&re.assign(H,!1)),re.else()}invalid$data(){let{gen:H,schemaCode:Q,schemaType:re,def:de,it:ae}=this;return(0,c.or)(pe(),Ie());function pe(){if(re.length){if(!(Q instanceof c.Name))throw new Error("ajv implementation error");let Je=Array.isArray(re)?re:[re];return(0,c._)`${(0,n.checkDataTypes)(Je,Q,ae.opts.strictNumbers,n.DataType.Wrong)}`}return c.nil}function Ie(){if(de.validateSchema){let Je=H.scopeValue("validate$data",{ref:de.validateSchema});return(0,c._)`!${Je}(${Q})`}return c.nil}}subschema(H,Q){let re=(0,a.getSubschema)(this.it,H);(0,a.extendSubschemaData)(re,this.it,H),(0,a.extendSubschemaMode)(re,H);let de={...this.it,...re,items:void 0,props:void 0};return v(de,Q),de}mergeEvaluated(H,Q){let{it:re,gen:de}=this;re.opts.unevaluated&&(re.props!==!0&&H.props!==void 0&&(re.props=m.mergeEvaluated.props(de,H.props,re.props,Q)),re.items!==!0&&H.items!==void 0&&(re.items=m.mergeEvaluated.items(de,H.items,re.items,Q)))}mergeValidEvaluated(H,Q){let{it:re,gen:de}=this;if(re.opts.unevaluated&&(re.props!==!0||re.items!==!0))return de.if(Q,()=>this.mergeEvaluated(H,c.Name)),!0}};e.KeywordCxt=W;function X(H,Q,re,de){let ae=new W(H,re,Q);"code"in re?re.code(ae,de):ae.$data&&re.validate?(0,s.funcKeywordCode)(ae,re):"macro"in re?(0,s.macroKeywordCode)(ae,re):(re.compile||re.validate)&&(0,s.funcKeywordCode)(ae,re)}let Y=/^\/(?:[^~]|~0|~1)*$/,fe=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ye(H,{dataLevel:Q,dataNames:re,dataPathArr:de}){let ae,pe;if(H==="")return l.default.rootData;if(H[0]==="/"){if(!Y.test(H))throw new Error(`Invalid JSON-pointer: ${H}`);ae=H,pe=l.default.rootData}else{let Ye=fe.exec(H);if(!Ye)throw new Error(`Invalid JSON-pointer: ${H}`);let Xe=+Ye[1];if(ae=Ye[2],ae==="#"){if(Xe>=Q)throw new Error(Ze("property/index",Xe));return de[Q-Xe]}if(Xe>Q)throw new Error(Ze("data",Xe));if(pe=re[Q-Xe],!ae)return pe}let Ie=pe,Je=ae.split("/");for(let Ye of Je)Ye&&(pe=(0,c._)`${pe}${(0,c.getProperty)((0,m.unescapeJsonPointer)(Ye))}`,Ie=(0,c._)`${Ie} && ${pe}`);return Ie;function Ze(Ye,Xe){return`Cannot access ${Ye} ${Xe} levels up, current level is ${Q}`}}e.getData=ye})),Qu=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}};e.default=t})),mc=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Zg();var r=class extends Error{constructor(o,n,i,s){super(s||`can't resolve reference ${i} from id ${n}`),this.missingRef=(0,t.resolveUrl)(o,n,i),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(o,this.missingRef))}};e.default=r})),Hg=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=qe(),r=Qu(),o=wr(),n=Zg(),i=We(),s=uc();var a=class{constructor(b){var y;this.refs={},this.dynamicAnchors={};let w;typeof b.schema=="object"&&(w=b.schema),this.schema=b.schema,this.schemaId=b.schemaId,this.root=b.root||this,this.baseId=(y=b.baseId)!==null&&y!==void 0?y:(0,n.normalizeId)(w?.[b.schemaId||"$id"]),this.schemaPath=b.schemaPath,this.localRefs=b.localRefs,this.meta=b.meta,this.$async=w?.$async,this.refs={}}};e.SchemaEnv=a;function c(b){let y=m.call(this,b);if(y)return y;let w=(0,n.getFullPath)(this.opts.uriResolver,b.root.baseId),{es5:v,lines:S}=this.opts.code,{ownProperties:_}=this.opts,$=new t.CodeGen(this.scope,{es5:v,lines:S,ownProperties:_}),x;b.$async&&(x=$.scopeValue("Error",{ref:r.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let k=$.scopeName("validate");b.validateName=k;let P={gen:$,allErrors:this.opts.allErrors,data:o.default.data,parentData:o.default.parentData,parentDataProperty:o.default.parentDataProperty,dataNames:[o.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:$.scopeValue("schema",this.opts.code.source===!0?{ref:b.schema,code:(0,t.stringify)(b.schema)}:{ref:b.schema}),validateName:k,ValidationError:x,schema:b.schema,schemaEnv:b,rootId:w,baseId:b.baseId||w,schemaPath:t.nil,errSchemaPath:b.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,t._)`""`,opts:this.opts,self:this},I;try{this._compilations.add(b),(0,s.validateFunctionCode)(P),$.optimize(this.opts.code.optimize);let E=$.toString();I=`${$.scopeRefs(o.default.scope)}return ${E}`,this.opts.code.process&&(I=this.opts.code.process(I,b));let N=new Function(`${o.default.self}`,`${o.default.scope}`,I)(this,this.scope.get());if(this.scope.value(k,{ref:N}),N.errors=null,N.schema=b.schema,N.schemaEnv=b,b.$async&&(N.$async=!0),this.opts.code.source===!0&&(N.source={validateName:k,validateCode:E,scopeValues:$._values}),this.opts.unevaluated){let{props:T,items:q}=P;N.evaluated={props:T instanceof t.Name?void 0:T,items:q instanceof t.Name?void 0:q,dynamicProps:T instanceof t.Name,dynamicItems:q instanceof t.Name},N.source&&(N.source.evaluated=(0,t.stringify)(N.evaluated))}return b.validate=N,b}catch(E){throw delete b.validate,delete b.validateName,I&&this.logger.error("Error compiling schema, function code:",I),E}finally{this._compilations.delete(b)}}e.compileSchema=c;function l(b,y,w){var v;w=(0,n.resolveUrl)(this.opts.uriResolver,y,w);let S=b.refs[w];if(S)return S;let _=f.call(this,b,w);if(_===void 0){let $=(v=b.localRefs)===null||v===void 0?void 0:v[w],{schemaId:x}=this.opts;$&&(_=new a({schema:$,schemaId:x,root:b,baseId:y}))}if(_!==void 0)return b.refs[w]=u.call(this,_)}e.resolveRef=l;function u(b){return(0,n.inlineRef)(b.schema,this.opts.inlineRefs)?b.schema:b.validate?b:c.call(this,b)}function m(b){for(let y of this._compilations)if(d(y,b))return y}e.getCompilingSchema=m;function d(b,y){return b.schema===y.schema&&b.root===y.root&&b.baseId===y.baseId}function f(b,y){let w;for(;typeof(w=this.refs[y])=="string";)y=w;return w||this.schemas[y]||p.call(this,b,y)}function p(b,y){let w=this.opts.uriResolver.parse(y),v=(0,n._getFullPath)(this.opts.uriResolver,w),S=(0,n.getFullPath)(this.opts.uriResolver,b.baseId,void 0);if(Object.keys(b.schema).length>0&&v===S)return g.call(this,w,b);let _=(0,n.normalizeId)(v),$=this.refs[_]||this.schemas[_];if(typeof $=="string"){let x=p.call(this,b,$);return typeof x?.schema!="object"?void 0:g.call(this,w,x)}if(typeof $?.schema=="object"){if($.validate||c.call(this,$),_===(0,n.normalizeId)(y)){let{schema:x}=$,{schemaId:k}=this.opts,P=x[k];return P&&(S=(0,n.resolveUrl)(this.opts.uriResolver,S,P)),new a({schema:x,schemaId:k,root:b,baseId:S})}return g.call(this,w,$)}}e.resolveSchema=p;let h=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function g(b,{baseId:y,schema:w,root:v}){var S;if(((S=b.fragment)===null||S===void 0?void 0:S[0])!=="/")return;for(let x of b.fragment.slice(1).split("/")){if(typeof w=="boolean")return;let k=w[(0,i.unescapeFragment)(x)];if(k===void 0)return;w=k;let P=typeof w=="object"&&w[this.opts.schemaId];!h.has(x)&&P&&(y=(0,n.resolveUrl)(this.opts.uriResolver,y,P))}let _;if(typeof w!="boolean"&&w.$ref&&!(0,i.schemaHasRulesButRef)(w,this.RULES)){let x=(0,n.resolveUrl)(this.opts.uriResolver,y,w.$ref);_=p.call(this,v,x)}let{schemaId:$}=this.opts;if(_=_||new a({schema:w,schemaId:$,root:v,baseId:y}),_.schema!==_.root.schema)return _}})),AU=ue(((e,t)=>{t.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}})),Kj=ue(((e,t)=>{let r=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),o=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),n=RegExp.prototype.test.bind(/^\d*$/u),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),s=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),a=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),c=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),l=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),u=new Array(256);{let A="0123456789ABCDEF";for(let z=0;z<256;z++)u[z]="%"+A[z>>4]+A[z&15]}function m(A){return A<2048?u[192|A>>6]+u[128|A&63]:A<65536?u[224|A>>12]+u[128|A>>6&63]+u[128|A&63]:u[240|A>>18]+u[128|A>>12&63]+u[128|A>>6&63]+u[128|A&63]}function d(A){let z="",R=0,C=0;for(C=0;C<A.length;C++)if(R=A[C].charCodeAt(0),R!==48){if(!(R>=48&&R<=57||R>=65&&R<=70||R>=97&&R<=102))return"";z+=A[C];break}for(C+=1;C<A.length;C++){if(R=A[C].charCodeAt(0),!(R>=48&&R<=57||R>=65&&R<=70||R>=97&&R<=102))return"";z+=A[C]}return z}let f=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),p=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),h=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),g=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function b(A){if(A.length===0)return!1;for(let z=0;z<A.length;z++)if(!h(A[z])){if(A[z]==="%"&&z+2<A.length&&i(A.slice(z+1,z+3))){z+=2;continue}return!1}return!0}function y(A){let z=-1,R=0,C=-1,U=0;for(let Y=0;Y<A.length;Y++)A[Y]==="0"?(C===-1&&(C=Y),U++,U>R&&(R=U,z=C)):(C=-1,U=0);if(R<2)return A.join(":");let W=A.slice(0,z).join(":"),X=A.slice(z+R).join(":");return W+"::"+X}function w(A){let z=A.indexOf("::");if(z!==-1&&A.indexOf("::",z+1)!==-1)return;let R=z===-1?A.split(":"):A.slice(0,z).split(":"),C=z===-1?[]:A.slice(z+2).split(":");z!==-1&&(R.length===1&&R[0]===""&&(R.length=0),C.length===1&&C[0]===""&&(C.length=0));let U=R.concat(C),W=0;for(let Y=0;Y<U.length;Y++){let fe=U[Y];if(fe==="")return;if(fe.indexOf(".")!==-1){if(Y!==U.length-1||z!==-1&&C.length===0||!o(fe))return;W+=2;continue}if(!f(fe))return;U[Y]=parseInt(fe,16).toString(16),W++}if(z===-1)return W!==8?void 0:y(U);if(W>=8)return;let X=U.slice(0,R.length);for(let Y=W;Y<8;Y++)X.push("0");for(let Y=R.length;Y<U.length;Y++)X.push(U[Y]);return y(X)}function v(A){let z=A[0]==="["&&A[A.length-1]==="]";if((A[0]==="["||A[A.length-1]==="]")&&!z)return{host:A,isIPV6:!1,error:!0};let R=z?A.slice(1,-1):A;if(z&&p(R))return R=R.toLowerCase(),{host:`[${R}]`,escapedHost:R,isIPV6:!1,isIPVFuture:!0};if(S(R,":")<2)return{host:A,isIPV6:!1,error:z};let C="",U=R.indexOf("%");if(U!==-1){let X=R.slice(U,U+3).toLowerCase()==="%25"?3:1;if(C=R.slice(U+X),!b(C))return{host:A,isIPV6:!1,error:!0};R=R.slice(0,U)}let W=w(R);return W===void 0?{host:A,isIPV6:!1,error:!0}:{host:W+(C?"%"+C:""),escapedHost:W+(C?"%25"+C:""),isIPV6:!0}}function S(A,z){let R=0;for(let C=0;C<A.length;C++)A[C]===z&&R++;return R}function _(A){let z=A,R=[],C=-1,U=0;for(;U=z.length;){if(U===1){if(z===".")break;if(z==="/"){R.push("/");break}else{R.push(z);break}}else if(U===2){if(z[0]==="."){if(z[1]===".")break;if(z[1]==="/"){z=z.slice(2);continue}}else if(z[0]==="/"&&(z[1]==="."||z[1]==="/")){R.push("/");break}}else if(U===3&&z==="/.."){R.length!==0&&R.pop(),R.push("/");break}if(z[0]==="."){if(z[1]==="."){if(z[2]==="/"){z=z.slice(3);continue}}else if(z[1]==="/"){z=z.slice(2);continue}}else if(z[0]==="/"&&z[1]==="."){if(z[2]==="/"){z=z.slice(2);continue}else if(z[2]==="."&&z[3]==="/"){z=z.slice(3),R.length!==0&&R.pop();continue}}if((C=z.indexOf("/",1))===-1){R.push(z);break}else R.push(z.slice(0,C)),z=z.slice(C)}return R.join("")}let $={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},x=/[@/?#:]/g,k=/[@/?#]/g;function P(A,z){let R=z?k:x;return R.lastIndex=0,A.replace(R,C=>$[C])}function I(A,z=!1){if(A.indexOf("%")===-1)return A;let R="";for(let C=0;C<A.length;C++){if(A[C]==="%"&&C+2<A.length){let U=A.slice(C+1,C+3);if(i(U)){let W=U.toUpperCase(),X=String.fromCharCode(parseInt(W,16));z&&s(X)?R+=X:R+="%"+W,C+=2;continue}}R+=A[C]}return R}function E(A){let z="";for(let R=0;R<A.length;R++){let C=A[R];if(C==="%"&&R+2<A.length){let U=A.slice(R+1,R+3);if(i(U)){let W=U.toUpperCase(),X=String.fromCharCode(parseInt(W,16));X!=="."&&s(X)?z+=X:z+="%"+W,R+=2;continue}}if(a(C))z+=C;else{let U=A.charCodeAt(R);if(U<128)z+=V(U)?C:u[U];else if(U<55296||U>57343)z+=m(U);else if(U<=56319&&R+1<A.length){let W=A.charCodeAt(R+1);W>=56320&&W<=57343?(z+=m(65536+(U-55296<<10)+(W-56320)),R++):z+=m(65533)}else z+=m(65533)}}return z}function N(A,z=!1){let R="",C=z&&A[0]!=="/";for(let U=0;U<A.length;U++){let W=A[U];if(W==="%"&&U+2<A.length){let X=A.slice(U+1,U+3);if(i(X)){R+="%"+X.toUpperCase(),U+=2;continue}}if(W==="/"&&(C=!1),a(W)&&(W!==":"||!C))R+=W;else{let X=A.charCodeAt(U);if(X<128)R+=u[X];else if(X<55296||X>57343)R+=m(X);else if(X<=56319&&U+1<A.length){let Y=A.charCodeAt(U+1);Y>=56320&&Y<=57343?(R+=m(65536+(X-55296<<10)+(Y-56320)),U++):R+=m(65533)}else R+=m(65533)}}return R}function T(A,z){let R="";for(let C=0;C<A.length;C++){let U=A[C];if(U==="%"&&C+2<A.length){let W=A.slice(C+1,C+3);if(i(W)){R+="%"+W.toUpperCase(),C+=2;continue}}if(z(U))R+=U;else{let W=A.charCodeAt(C);if(W<128)R+=u[W];else if(W<55296||W>57343)R+=m(W);else if(W<=56319&&C+1<A.length){let X=A.charCodeAt(C+1);X>=56320&&X<=57343?(R+=m(65536+(W-55296<<10)+(X-56320)),C++):R+=m(65533)}else R+=m(65533)}}return R}function q(A){return T(A,l)}function Z(A){return T(A,c)}function D(A){return T(A,c)}function V(A){return A>=48&&A<=57||A>=65&&A<=90||A>=97&&A<=122||A===42||A===43||A===45||A===46||A===47||A===64||A===95}function F(A){let z="";for(let R=0;R<A.length;R++){let C=A[R];if(C==="%"&&R+2<A.length){let U=A.slice(R+1,R+3);if(i(U)){let W=U.toUpperCase(),X=String.fromCharCode(parseInt(W,16));s(X)?z+=X:z+="%"+W,R+=2;continue}}if(c(C))z+=C;else{let U=A.charCodeAt(R);if(U<128)z+=V(U)?C:u[U];else if(U<55296||U>57343)z+=m(U);else if(U<=56319&&R+1<A.length){let W=A.charCodeAt(R+1);W>=56320&&W<=57343?(z+=m(65536+(U-55296<<10)+(W-56320)),R++):z+=m(65533)}else z+=m(65533)}}return z}function M(A){let z="";for(let R=0;R<A.length;R++){if(A[R]==="%"&&R+2<A.length){let C=A.slice(R+1,R+3);if(i(C)){z+="%"+C.toUpperCase(),R+=2;continue}}z+=escape(A[R])}return z}function L(A){let z=[];if(A.userinfo!==void 0&&(z.push(q(A.userinfo)),z.push("@")),A.host!==void 0){let R=A.host;if(!o(R)){let C=v(R);C.isIPV6!==!0&&C.isIPVFuture!==!0&&(R=I(R,!0),C=v(R)),C.isIPV6===!0||C.isIPVFuture===!0?R=`[${C.escapedHost}]`:R=P(R,!1)}z.push(R)}if(typeof A.port=="number"||typeof A.port=="string"){let R=String(A.port);if(!n(R))throw new TypeError("URI port is malformed.");z.push(":"),z.push(R)}return z.length?z.join(""):void 0}t.exports={nonSimpleDomain:g,recomposeAuthority:L,reescapeHostDelimiters:P,normalizePercentEncoding:I,normalizePathEncoding:E,serializePathEncoding:N,normalizeQueryFragmentEncoding:F,encodeUserinfo:q,encodeQuery:Z,encodeFragment:D,escapePreservingEscapes:M,removeDotSegments:_,isIPv4:o,isUUID:r,normalizeIPv6:v,stringArrayToHexStripped:d}})),OU=ue(((e,t)=>{let{isUUID:r}=Kj(),o=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,n=["http","https","ws","wss","urn","urn:uuid"];function i($){return n.indexOf($)!==-1}function s($){return $.secure===!0?!0:$.secure===!1?!1:$.scheme?$.scheme.length===3&&($.scheme[0]==="w"||$.scheme[0]==="W")&&($.scheme[1]==="s"||$.scheme[1]==="S")&&($.scheme[2]==="s"||$.scheme[2]==="S"):!1}function a($){return $.host||($.error=$.error||"HTTP URIs must have a host."),$}function c($){let x=String($.scheme).toLowerCase()==="https";return($.port===(x?443:80)||$.port==="")&&($.port=void 0),$.path||($.path="/"),$}function l($){return $.secure=s($),$.resourceName=($.path||"/")+($.query?"?"+$.query:""),$.path=void 0,$.query=void 0,$}function u($){if(($.port===(s($)?443:80)||$.port==="")&&($.port=void 0),typeof $.secure=="boolean"&&($.scheme=$.secure?"wss":"ws",$.secure=void 0),$.resourceName){let x=$.resourceName.indexOf("?"),k=x===-1?$.resourceName:$.resourceName.slice(0,x);$.path=k&&k!=="/"?k:void 0,$.query=x===-1?void 0:$.resourceName.slice(x+1),$.resourceName=void 0}return $.fragment=void 0,$}function m($,x){if(!$.path)return $.error="URN can not be parsed",$;let k=$.path.match(o);if(k&&k[0]===$.path){let P=x.scheme||$.scheme||"urn";$.nid=k[1].toLowerCase(),$.nss=k[2];let I=_(`${P}:${x.nid||$.nid}`);$.path=void 0,I&&($=I.parse($,x))}else $.error=$.error||"URN can not be parsed.";return $}function d($,x){if($.nid===void 0)throw new Error("URN without nid cannot be serialized");let k=x.scheme||$.scheme||"urn",P=$.nid.toLowerCase(),I=_(`${k}:${x.nid||P}`);I&&($=I.serialize($,x));let E=$,N=$.nss;return E.path=`${P||x.nid}:${N}`,x.skipEscape=!0,E}function f($,x){let k=$;return k.uuid=k.nss,k.nss=void 0,!x.tolerant&&(!k.uuid||!r(k.uuid))&&(k.error=k.error||"UUID is not valid."),k}function p($){let x=$;return x.nss=($.uuid||"").toLowerCase(),x}let h={scheme:"http",domainHost:!0,parse:a,serialize:c},g={scheme:"https",domainHost:h.domainHost,parse:a,serialize:c},b={scheme:"ws",domainHost:!0,parse:l,serialize:u},y={scheme:"wss",domainHost:b.domainHost,parse:b.parse,serialize:b.serialize},S={http:h,https:g,ws:b,wss:y,urn:{scheme:"urn",parse:m,serialize:d,skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:f,serialize:p,skipNormalize:!0}};Object.setPrototypeOf(S,null);function _($){return $&&(S[$]||S[$.toLowerCase()])||void 0}t.exports={wsIsSecure:s,SCHEMES:S,isValidSchemeName:i,getSchemeHandler:_}})),NU=ue(((e,t)=>{let{normalizeIPv6:r,removeDotSegments:o,recomposeAuthority:n,normalizePercentEncoding:i,normalizePathEncoding:s,serializePathEncoding:a,normalizeQueryFragmentEncoding:c,encodeQuery:l,encodeFragment:u,reescapeHostDelimiters:m,isIPv4:d,nonSimpleDomain:f}=Kj(),{SCHEMES:p,getSchemeHandler:h}=OU(),g=/^[A-Za-z][A-Za-z0-9+.-]*$/u,b="URI scheme is malformed.";function y(A){let z=unescape(String(A));if(!g.test(z))throw new TypeError(b);return z}function w(A,z){return typeof A=="string"?A=V(A,z):typeof A=="object"&&(A=D($(A,z),z)),A}function v(A,z,R){let C=R?Object.assign({scheme:"null"},R):{scheme:"null"},{parsed:U,malformedAuthorityOrPort:W,malformedPercentEncoding:X,malformedSchemeSpecific:Y,malformedHost:fe,malformedScheme:ye}=Z(A,C),{parsed:H,malformedAuthorityOrPort:Q,malformedPercentEncoding:re,malformedSchemeSpecific:de,malformedHost:ae,malformedScheme:pe}=Z(z,C);if(W||Q||X||re||Y||de||fe||ae||ye||pe)throw new Error(U.error||H.error||"URI is malformed.");let Ie=S(U,H,C,!0),Je=h(R&&R.scheme||Ie.scheme),Ze=Ie.host,Ye=Ze!==void 0&&Ze!==""&&(d(Ze)||r(Ze).isIPV6);q(Ie,R||{},Je,Ye);let Xe=Ze&&Ze.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(Ze);if(Ie.error&&!Xe)throw new Error(Ie.error);return C.skipEscape=!0,$(Ie,C)}function S(A,z,R,C){let U={};return C||(A=D($(A,R),R),z=D($(z,R),R)),R=R||{},!R.tolerant&&z.scheme?(U.scheme=z.scheme,U.userinfo=z.userinfo,U.host=z.host,U.port=z.port,U.path=o(z.path||""),U.query=z.query):(z.userinfo!==void 0||z.host!==void 0||z.port!==void 0?(U.userinfo=z.userinfo,U.host=z.host,U.port=z.port,U.path=o(z.path||""),U.query=z.query):(z.path?(z.path[0]==="/"?U.path=o(z.path):((A.userinfo!==void 0||A.host!==void 0||A.port!==void 0)&&!A.path?U.path="/"+z.path:A.path?U.path=A.path.slice(0,A.path.lastIndexOf("/")+1)+z.path:U.path=z.path,U.path=o(U.path)),U.query=z.query):(U.path=A.path,z.query!==void 0?U.query=z.query:U.query=A.query),U.userinfo=A.userinfo,U.host=A.host,U.port=A.port),U.scheme=A.scheme),U.fragment=z.fragment,U}function _(A,z,R){let C=M(A,R),U=M(z,R);return C!==void 0&&U!==void 0&&C===U}function $(A,z){let R={host:A.host,scheme:A.scheme,userinfo:A.userinfo,port:A.port,path:A.path,query:A.query,nid:A.nid,nss:A.nss,uuid:A.uuid,fragment:A.fragment,reference:A.reference,resourceName:A.resourceName,secure:A.secure,error:""},C=Object.assign({},z),U=[];R.scheme&&(R.scheme=y(R.scheme));let W=h(C.scheme||R.scheme);W&&W.serialize&&W.serialize(R,C);let X=R.userinfo!==void 0||R.host!==void 0||R.port!==void 0,Y=!C.skipEscape&&R.scheme===void 0&&!X;R.path!==void 0&&(C.skipEscape?R.path=i(R.path):R.path=a(R.path,Y)),C.reference!=="suffix"&&R.scheme&&(R.scheme=y(R.scheme),U.push(R.scheme,":"));let fe=n(R);if(fe!==void 0&&(C.reference!=="suffix"&&U.push("//"),U.push(fe),R.path&&R.path[0]!=="/"&&U.push("/")),R.path!==void 0){let ye=R.path;!C.absolutePath&&(!W||!W.absolutePath)&&(ye=o(ye)),Y&&(ye=a(ye,!0)),fe===void 0&&ye[0]==="/"&&ye[1]==="/"&&(ye="/%2F"+ye.slice(2)),U.push(ye)}return R.query!==void 0&&U.push("?",l(R.query)),R.fragment!==void 0&&U.push("#",u(R.fragment)),U.join("")}let x=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,k=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,P=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function I(A,z){if(z[2]!==void 0&&A.path&&A.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof A.port=="number"&&(A.port<0||A.port>65535))return"URI port is malformed."}function E(A){if(A===void 0)return!1;let z=A.indexOf("%");for(;z!==-1;){if(z+2>=A.length||!/^[\da-f]{2}$/iu.test(A.slice(z+1,z+3)))return!0;z=A.indexOf("%",z+3)}return!1}function N(A){return A[0]==="["&&A[A.length-1]==="]"}function T(A){let z=A[4];return E(A[3])||z!==void 0&&!N(z)&&E(z)||E(A[6])||E(A[7])||E(A[8])}function q(A,z,R,C){if(!z.unicodeSupport&&(!R||!R.unicodeSupport)&&A.host&&!N(A.host)&&(z.domainHost||R&&R.domainHost)&&C===!1&&f(A.host))try{A.host=new URL("http://"+A.host).hostname}catch(U){return A.error=A.error||"Host's domain name can not be converted to ASCII: "+U,!0}return!1}function Z(A,z){let R=Object.assign({},z),C={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},U=!1,W=!1,X=!1,Y=!1,fe=!1,ye=!1,H=!1;R.reference==="suffix"&&(R.scheme?A=R.scheme+":"+A:A="//"+A);let Q=A.match(k);Q!==null&&Q[1].indexOf("\\")!==-1&&(C.error="URI authority must not contain a literal backslash.",U=!0);let re=A.match(P);if(re!==null){let ae=re[1],pe=ae.replace(/[\t\n\r]/g,"");pe.length>=2&&(pe.slice(0,2)!=="//"?(C.error=C.error||"URI authority must not contain a literal backslash.",U=!0):ae.length!==pe.length&&(C.error=C.error||"URI authority introducer must not contain whitespace.",U=!0))}let de=A.match(x);if(de){if(C.scheme=de[1],C.userinfo=de[3],C.host=de[4],C.port=parseInt(de[5],10),C.path=de[6]||"",C.query=de[7],C.fragment=de[8],C.scheme!==void 0){let Ie=unescape(C.scheme);g.test(Ie)?C.scheme=Ie.toLowerCase():(C.error=C.error||b,ye=!0)}W=T(de),W&&(C.error=C.error||"URI contains malformed percent-encoding."),isNaN(C.port)&&(C.port=de[5]);let ae=I(C,de);if(ae!==void 0&&(C.error=C.error||ae,U=!0),C.host)if(d(C.host)===!1){let Ie=N(C.host),Je=C.host.indexOf("[")!==-1||C.host.indexOf("]")!==-1,Ze=r(C.host);H=Ze.isIPV6||Ze.isIPVFuture===!0,fe=Je&&(!Ie||Ze.error===!0),C.host=H?Ze.host:Ze.host.toLowerCase(),fe&&(C.error=C.error||"URI host is malformed.",U=!0)}else H=!0;C.scheme===void 0&&C.userinfo===void 0&&C.host===void 0&&C.port===void 0&&C.query===void 0&&!C.path?C.reference="same-document":C.scheme===void 0?C.reference="relative":C.fragment===void 0?C.reference="absolute":C.reference="uri",R.reference&&R.reference!=="suffix"&&R.reference!==C.reference&&(C.error=C.error||"URI is not a "+R.reference+" reference.");let pe=h(R.scheme||C.scheme);if(fe||(Y=q(C,R,pe,H)),A.indexOf("%")!==-1&&C.host!==void 0&&!fe){let Ie=H?C.host:i(C.host,!0);H||(Ie=i(Ie.toLowerCase())),C.host=m(Ie,H)}(!pe||pe&&!pe.skipNormalize)&&(C.path&&(C.path=s(C.path)),C.query&&(C.query=c(C.query)),C.fragment&&(C.fragment=c(C.fragment))),pe&&pe.parse&&(pe.parse(C,R),pe===p.urn&&C.nid===void 0&&(X=!0))}else C.error=C.error||"URI can not be parsed.";return{parsed:C,malformedAuthorityOrPort:U,malformedPercentEncoding:W,malformedSchemeSpecific:X,malformedHost:Y,malformedScheme:ye}}function D(A,z){return Z(A,z).parsed}function V(A,z){return F(A,z).normalized}function F(A,z){let{parsed:R,malformedAuthorityOrPort:C,malformedPercentEncoding:U,malformedSchemeSpecific:W,malformedHost:X,malformedScheme:Y}=Z(A,z);return{normalized:C||U||W||X||Y?A:$(R,z),malformedAuthorityOrPort:C,malformedPercentEncoding:U,malformedSchemeSpecific:W,malformedHost:X,malformedScheme:Y}}function M(A,z){if(typeof A!="string"&&typeof A!="object")return;let R;try{R=typeof A=="string"?A:$(A,z)}catch{return}let{normalized:C,malformedAuthorityOrPort:U,malformedPercentEncoding:W,malformedSchemeSpecific:X,malformedHost:Y,malformedScheme:fe}=F(R,z);return U||W||X||Y||fe?void 0:C}let L={SCHEMES:p,normalize:w,resolve:v,resolveComponent:S,equal:_,serialize:$,parse:D};t.exports=L,t.exports.default=L,t.exports.fastUri=L})),MU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=NU();t.code='require("ajv/dist/runtime/uri").default',e.default=t})),cS=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=uc();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=qe();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});let o=Qu(),n=mc(),i=Wj(),s=Hg(),a=qe(),c=Zg(),l=Fg(),u=We(),m=AU(),d=MU(),f=(M,L)=>new RegExp(M,L);f.code="new RegExp";let p=["removeAdditional","useDefaults","coerceTypes"],h=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),g={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},b={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},y=200;function w(M){var L,A,z,R,C,U,W,X,Y,fe,ye,H,Q,re,de,ae,pe,Ie,Je,Ze,Ye,Xe,Pt,bt,wn;let Gt=M.strict,Cn=(L=M.code)===null||L===void 0?void 0:L.optimize,Vn=Cn===!0||Cn===void 0?1:Cn||0,Zn=(z=(A=M.code)===null||A===void 0?void 0:A.regExp)!==null&&z!==void 0?z:f,ur=(R=M.uriResolver)!==null&&R!==void 0?R:d.default;return{strictSchema:(U=(C=M.strictSchema)!==null&&C!==void 0?C:Gt)!==null&&U!==void 0?U:!0,strictNumbers:(X=(W=M.strictNumbers)!==null&&W!==void 0?W:Gt)!==null&&X!==void 0?X:!0,strictTypes:(fe=(Y=M.strictTypes)!==null&&Y!==void 0?Y:Gt)!==null&&fe!==void 0?fe:"log",strictTuples:(H=(ye=M.strictTuples)!==null&&ye!==void 0?ye:Gt)!==null&&H!==void 0?H:"log",strictRequired:(re=(Q=M.strictRequired)!==null&&Q!==void 0?Q:Gt)!==null&&re!==void 0?re:!1,code:M.code?{...M.code,optimize:Vn,regExp:Zn}:{optimize:Vn,regExp:Zn},loopRequired:(de=M.loopRequired)!==null&&de!==void 0?de:y,loopEnum:(ae=M.loopEnum)!==null&&ae!==void 0?ae:y,meta:(pe=M.meta)!==null&&pe!==void 0?pe:!0,messages:(Ie=M.messages)!==null&&Ie!==void 0?Ie:!0,inlineRefs:(Je=M.inlineRefs)!==null&&Je!==void 0?Je:!0,schemaId:(Ze=M.schemaId)!==null&&Ze!==void 0?Ze:"$id",addUsedSchema:(Ye=M.addUsedSchema)!==null&&Ye!==void 0?Ye:!0,validateSchema:(Xe=M.validateSchema)!==null&&Xe!==void 0?Xe:!0,validateFormats:(Pt=M.validateFormats)!==null&&Pt!==void 0?Pt:!0,unicodeRegExp:(bt=M.unicodeRegExp)!==null&&bt!==void 0?bt:!0,int32range:(wn=M.int32range)!==null&&wn!==void 0?wn:!0,uriResolver:ur}}var v=class{constructor(M={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,M=this.opts={...M,...w(M)};let{es5:L,lines:A}=this.opts.code;this.scope=new a.ValueScope({scope:{},prefixes:h,es5:L,lines:A}),this.logger=E(M.logger);let z=M.validateFormats;M.validateFormats=!1,this.RULES=(0,i.getRules)(),S.call(this,g,M,"NOT SUPPORTED"),S.call(this,b,M,"DEPRECATED","warn"),this._metaOpts=P.call(this),M.formats&&x.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),M.keywords&&k.call(this,M.keywords),typeof M.meta=="object"&&this.addMetaSchema(M.meta),$.call(this),M.validateFormats=z}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:M,meta:L,schemaId:A}=this.opts,z=m;A==="id"&&(z={...m},z.id=z.$id,delete z.$id),L&&M&&this.addMetaSchema(z,z[A],!1)}defaultMeta(){let{meta:M,schemaId:L}=this.opts;return this.opts.defaultMeta=typeof M=="object"?M[L]||M:void 0}validate(M,L){let A;if(typeof M=="string"){if(A=this.getSchema(M),!A)throw new Error(`no schema with key or ref "${M}"`)}else A=this.compile(M);let z=A(L);return"$async"in A||(this.errors=A.errors),z}compile(M,L){let A=this._addSchema(M,L);return A.validate||this._compileSchemaEnv(A)}compileAsync(M,L){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:A}=this.opts;return z.call(this,M,L);async function z(Y,fe){await R.call(this,Y.$schema);let ye=this._addSchema(Y,fe);return ye.validate||C.call(this,ye)}async function R(Y){Y&&!this.getSchema(Y)&&await z.call(this,{$ref:Y},!0)}async function C(Y){try{return this._compileSchemaEnv(Y)}catch(fe){if(!(fe instanceof n.default))throw fe;return U.call(this,fe),await W.call(this,fe.missingSchema),C.call(this,Y)}}function U({missingSchema:Y,missingRef:fe}){if(this.refs[Y])throw new Error(`AnySchema ${Y} is loaded but ${fe} cannot be resolved`)}async function W(Y){let fe=await X.call(this,Y);this.refs[Y]||await R.call(this,fe.$schema),this.refs[Y]||this.addSchema(fe,Y,L)}async function X(Y){let fe=this._loading[Y];if(fe)return fe;try{return await(this._loading[Y]=A(Y))}finally{delete this._loading[Y]}}}addSchema(M,L,A,z=this.opts.validateSchema){if(Array.isArray(M)){for(let C of M)this.addSchema(C,void 0,A,z);return this}let R;if(typeof M=="object"){let{schemaId:C}=this.opts;if(R=M[C],R!==void 0&&typeof R!="string")throw new Error(`schema ${C} must be string`)}return L=(0,c.normalizeId)(L||R),this._checkUnique(L),this.schemas[L]=this._addSchema(M,A,L,z,!0),this}addMetaSchema(M,L,A=this.opts.validateSchema){return this.addSchema(M,L,!0,A),this}validateSchema(M,L){if(typeof M=="boolean")return!0;let A;if(A=M.$schema,A!==void 0&&typeof A!="string")throw new Error("$schema must be a string");if(A=A||this.opts.defaultMeta||this.defaultMeta(),!A)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let z=this.validate(A,M);if(!z&&L){let R="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(R);else throw new Error(R)}return z}getSchema(M){let L;for(;typeof(L=_.call(this,M))=="string";)M=L;if(L===void 0){let{schemaId:A}=this.opts,z=new s.SchemaEnv({schema:{},schemaId:A});if(L=s.resolveSchema.call(this,z,M),!L)return;this.refs[M]=L}return L.validate||this._compileSchemaEnv(L)}removeSchema(M){if(M instanceof RegExp)return this._removeAllSchemas(this.schemas,M),this._removeAllSchemas(this.refs,M),this;switch(typeof M){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let L=_.call(this,M);return typeof L=="object"&&this._cache.delete(L.schema),delete this.schemas[M],delete this.refs[M],this}case"object":{let L=M;this._cache.delete(L);let A=M[this.opts.schemaId];return A&&(A=(0,c.normalizeId)(A),delete this.schemas[A],delete this.refs[A]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(M){for(let L of M)this.addKeyword(L);return this}addKeyword(M,L){let A;if(typeof M=="string")A=M,typeof L=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),L.keyword=A);else if(typeof M=="object"&&L===void 0){if(L=M,A=L.keyword,Array.isArray(A)&&!A.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(T.call(this,A,L),!L)return(0,u.eachItem)(A,R=>q.call(this,R)),this;D.call(this,L);let z={...L,type:(0,l.getJSONTypes)(L.type),schemaType:(0,l.getJSONTypes)(L.schemaType)};return(0,u.eachItem)(A,z.type.length===0?R=>q.call(this,R,z):R=>z.type.forEach(C=>q.call(this,R,z,C))),this}getKeyword(M){let L=this.RULES.all[M];return typeof L=="object"?L.definition:!!L}removeKeyword(M){let{RULES:L}=this;delete L.keywords[M],delete L.all[M];for(let A of L.rules){let z=A.rules.findIndex(R=>R.keyword===M);z>=0&&A.rules.splice(z,1)}return this}addFormat(M,L){return typeof L=="string"&&(L=new RegExp(L)),this.formats[M]=L,this}errorsText(M=this.errors,{separator:L=", ",dataVar:A="data"}={}){return!M||M.length===0?"No errors":M.map(z=>`${A}${z.instancePath} ${z.message}`).reduce((z,R)=>z+L+R)}$dataMetaSchema(M,L){let A=this.RULES.all;M=JSON.parse(JSON.stringify(M));for(let z of L){let R=z.split("/").slice(1),C=M;for(let U of R)C=C[U];for(let U in A){let W=A[U];if(typeof W!="object")continue;let{$data:X}=W.definition,Y=C[U];X&&Y&&(C[U]=F(Y))}}return M}_removeAllSchemas(M,L){for(let A in M){let z=M[A];(!L||L.test(A))&&(typeof z=="string"?delete M[A]:z&&!z.meta&&(this._cache.delete(z.schema),delete M[A]))}}_addSchema(M,L,A,z=this.opts.validateSchema,R=this.opts.addUsedSchema){let C,{schemaId:U}=this.opts;if(typeof M=="object")C=M[U];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof M!="boolean")throw new Error("schema must be object or boolean")}let W=this._cache.get(M);if(W!==void 0)return W;A=(0,c.normalizeId)(C||A);let X=c.getSchemaRefs.call(this,M,A);return W=new s.SchemaEnv({schema:M,schemaId:U,meta:L,baseId:A,localRefs:X}),this._cache.set(W.schema,W),R&&!A.startsWith("#")&&(A&&this._checkUnique(A),this.refs[A]=W),z&&this.validateSchema(M,!0),W}_checkUnique(M){if(this.schemas[M]||this.refs[M])throw new Error(`schema with key or id "${M}" already exists`)}_compileSchemaEnv(M){if(M.meta?this._compileMetaSchema(M):s.compileSchema.call(this,M),!M.validate)throw new Error("ajv implementation error");return M.validate}_compileMetaSchema(M){let L=this.opts;this.opts=this._metaOpts;try{s.compileSchema.call(this,M)}finally{this.opts=L}}};v.ValidationError=o.default,v.MissingRefError=n.default,e.default=v;function S(M,L,A,z="error"){for(let R in M){let C=R;C in L&&this.logger[z](`${A}: option ${R}. ${M[C]}`)}}function _(M){return M=(0,c.normalizeId)(M),this.schemas[M]||this.refs[M]}function $(){let M=this.opts.schemas;if(M)if(Array.isArray(M))this.addSchema(M);else for(let L in M)this.addSchema(M[L],L)}function x(){for(let M in this.opts.formats){let L=this.opts.formats[M];L&&this.addFormat(M,L)}}function k(M){if(Array.isArray(M)){this.addVocabulary(M);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let L in M){let A=M[L];A.keyword||(A.keyword=L),this.addKeyword(A)}}function P(){let M={...this.opts};for(let L of p)delete M[L];return M}let I={log(){},warn(){},error(){}};function E(M){if(M===!1)return I;if(M===void 0)return console;if(M.log&&M.warn&&M.error)return M;throw new Error("logger must implement log, warn and error methods")}let N=/^[a-z_$][a-z0-9_$:-]*$/i;function T(M,L){let{RULES:A}=this;if((0,u.eachItem)(M,z=>{if(A.keywords[z])throw new Error(`Keyword ${z} is already defined`);if(!N.test(z))throw new Error(`Keyword ${z} has invalid name`)}),!!L&&L.$data&&!("code"in L||"validate"in L))throw new Error('$data keyword must have "code" or "validate" function')}function q(M,L,A){var z;let R=L?.post;if(A&&R)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:C}=this,U=R?C.post:C.rules.find(({type:X})=>X===A);if(U||(U={type:A,rules:[]},C.rules.push(U)),C.keywords[M]=!0,!L)return;let W={keyword:M,definition:{...L,type:(0,l.getJSONTypes)(L.type),schemaType:(0,l.getJSONTypes)(L.schemaType)}};L.before?Z.call(this,U,W,L.before):U.rules.push(W),C.all[M]=W,(z=L.implements)===null||z===void 0||z.forEach(X=>this.addKeyword(X))}function Z(M,L,A){let z=M.rules.findIndex(R=>R.keyword===A);z>=0?M.rules.splice(z,0,L):(M.rules.push(L),this.logger.warn(`rule ${A} is not defined`))}function D(M){let{metaSchema:L}=M;L!==void 0&&(M.$data&&this.opts.$data&&(L=F(L)),M.validateSchema=this.compile(L,!0))}let V={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function F(M){return{anyOf:[M,V]}}})),DU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};e.default=t})),lS=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;let t=mc(),r=vr(),o=qe(),n=wr(),i=Hg(),s=We(),a={keyword:"$ref",schemaType:"string",code(u){let{gen:m,schema:d,it:f}=u,{baseId:p,schemaEnv:h,validateName:g,opts:b,self:y}=f,{root:w}=h;if((d==="#"||d==="#/")&&p===w.baseId)return S();let v=i.resolveRef.call(y,w,p,d);if(v===void 0)throw new t.default(f.opts.uriResolver,p,d);if(v instanceof i.SchemaEnv)return _(v);return $(v);function S(){if(h===w)return l(u,g,h,h.$async);let x=m.scopeValue("root",{ref:w});return l(u,(0,o._)`${x}.validate`,w,w.$async)}function _(x){l(u,c(u,x),x,x.$async)}function $(x){let k=m.scopeValue("schema",b.code.source===!0?{ref:x,code:(0,o.stringify)(x)}:{ref:x}),P=m.name("valid"),I=u.subschema({schema:x,dataTypes:[],schemaPath:o.nil,topSchemaRef:k,errSchemaPath:d},P);u.mergeEvaluated(I),u.ok(P)}}};function c(u,m){let{gen:d}=u;return m.validate?d.scopeValue("validate",{ref:m.validate}):(0,o._)`${d.scopeValue("wrapper",{ref:m})}.validate`}e.getValidate=c;function l(u,m,d,f){let{gen:p,it:h}=u,{allErrors:g,schemaEnv:b,opts:y}=h,w=y.passContext?n.default.this:o.nil;f?v():S();function v(){if(!b.$async)throw new Error("async schema referenced by sync schema");let x=p.let("valid");p.try(()=>{p.code((0,o._)`await ${(0,r.callValidateCode)(u,m,w)}`),$(m),g||p.assign(x,!0)},k=>{p.if((0,o._)`!(${k} instanceof ${h.ValidationError})`,()=>p.throw(k)),_(k),g||p.assign(x,!1)}),u.ok(x)}function S(){u.result((0,r.callValidateCode)(u,m,w),()=>$(m),()=>_(m))}function _(x){let k=(0,o._)`${x}.errors`;p.assign(n.default.vErrors,(0,o._)`${n.default.vErrors} === null ? ${k} : ${n.default.vErrors}.concat(${k})`),p.assign(n.default.errors,(0,o._)`${n.default.vErrors}.length`)}function $(x){var k;if(!h.opts.unevaluated)return;let P=(k=d?.validate)===null||k===void 0?void 0:k.evaluated;if(h.props!==!0)if(P&&!P.dynamicProps)P.props!==void 0&&(h.props=s.mergeEvaluated.props(p,P.props,h.props));else{let I=p.var("props",(0,o._)`${x}.evaluated.props`);h.props=s.mergeEvaluated.props(p,I,h.props,o.Name)}if(h.items!==!0)if(P&&!P.dynamicItems)P.items!==void 0&&(h.items=s.mergeEvaluated.items(p,P.items,h.items));else{let I=p.var("items",(0,o._)`${x}.evaluated.items`);h.items=s.mergeEvaluated.items(p,I,h.items,o.Name)}}}e.callRef=l,e.default=a})),Yj=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=DU(),r=lS(),o=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",t.default,r.default];e.default=o})),qU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=t.operators,o={maximum:{okStr:"<=",ok:r.LTE,fail:r.GT},minimum:{okStr:">=",ok:r.GTE,fail:r.LT},exclusiveMaximum:{okStr:"<",ok:r.LT,fail:r.GTE},exclusiveMinimum:{okStr:">",ok:r.GT,fail:r.LTE}},n={keyword:Object.keys(o),type:"number",schemaType:"number",$data:!0,error:{message:({keyword:i,schemaCode:s})=>(0,t.str)`must be ${o[i].okStr} ${s}`,params:({keyword:i,schemaCode:s})=>(0,t._)`{comparison: ${o[i].okStr}, limit: ${s}}`},code(i){let{keyword:s,data:a,schemaCode:c}=i;i.fail$data((0,t._)`${a} ${o[s].fail} ${c} || isNaN(${a})`)}};e.default=n})),UU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:o})=>(0,t.str)`must be multiple of ${o}`,params:({schemaCode:o})=>(0,t._)`{multipleOf: ${o}}`},code(o){let{gen:n,data:i,schemaCode:s,it:a}=o,c=a.opts.multipleOfPrecision,l=n.let("res"),u=c?(0,t._)`Math.abs(Math.round(${l}) - ${l}) > 1e-${c}`:(0,t._)`${l} !== parseInt(${l})`;o.fail$data((0,t._)`(${s} === 0 || (${l} = ${i}/${s}, ${u}))`)}};e.default=r})),LU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(r){let o=r.length,n=0,i=0,s;for(;i<o;)n++,s=r.charCodeAt(i++),s>=55296&&s<=56319&&i<o&&(s=r.charCodeAt(i),(s&64512)===56320&&i++);return n}e.default=t,t.code='require("ajv/dist/runtime/ucs2length").default'})),FU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=We(),o=LU(),n={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:i,schemaCode:s}){let a=i==="maxLength"?"more":"fewer";return(0,t.str)`must NOT have ${a} than ${s} characters`},params:({schemaCode:i})=>(0,t._)`{limit: ${i}}`},code(i){let{keyword:s,data:a,schemaCode:c,it:l}=i,u=s==="maxLength"?t.operators.GT:t.operators.LT,m=l.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,r.useFunc)(i.gen,o.default)}(${a})`;i.fail$data((0,t._)`${m} ${u} ${c}`)}};e.default=n})),VU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vr(),r=We(),o=qe(),n={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:i})=>(0,o.str)`must match pattern "${i}"`,params:({schemaCode:i})=>(0,o._)`{pattern: ${i}}`},code(i){let{gen:s,data:a,$data:c,schema:l,schemaCode:u,it:m}=i,d=m.opts.unicodeRegExp?"u":"";if(c){let{regExp:f}=m.opts.code,p=f.code==="new RegExp"?(0,o._)`new RegExp`:(0,r.useFunc)(s,f),h=s.let("valid");s.try(()=>s.assign(h,(0,o._)`${p}(${u}, ${d}).test(${a})`),()=>s.assign(h,!1)),i.fail$data((0,o._)`!${h}`)}else{let f=(0,t.usePattern)(i,l);i.fail$data((0,o._)`!${f}.test(${a})`)}}};e.default=n})),ZU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:o,schemaCode:n}){let i=o==="maxProperties"?"more":"fewer";return(0,t.str)`must NOT have ${i} than ${n} properties`},params:({schemaCode:o})=>(0,t._)`{limit: ${o}}`},code(o){let{keyword:n,data:i,schemaCode:s}=o,a=n==="maxProperties"?t.operators.GT:t.operators.LT;o.fail$data((0,t._)`Object.keys(${i}).length ${a} ${s}`)}};e.default=r})),HU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vr(),r=qe(),o=We(),n={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:i}})=>(0,r.str)`must have required property '${i}'`,params:({params:{missingProperty:i}})=>(0,r._)`{missingProperty: ${i}}`},code(i){let{gen:s,schema:a,schemaCode:c,data:l,$data:u,it:m}=i,{opts:d}=m;if(!u&&a.length===0)return;let f=a.length>=d.loopRequired;if(m.allErrors?p():h(),d.strictRequired){let y=i.parentSchema.properties,{definedProperties:w}=i.it;for(let v of a)if(y?.[v]===void 0&&!w.has(v)){let S=`required property "${v}" is not defined at "${m.schemaEnv.baseId+m.errSchemaPath}" (strictRequired)`;(0,o.checkStrictMode)(m,S,m.opts.strictRequired)}}function p(){if(f||u)i.block$data(r.nil,g);else for(let y of a)(0,t.checkReportMissingProp)(i,y)}function h(){let y=s.let("missing");if(f||u){let w=s.let("valid",!0);i.block$data(w,()=>b(y,w)),i.ok(w)}else s.if((0,t.checkMissingProp)(i,a,y)),(0,t.reportMissingProp)(i,y),s.else()}function g(){s.forOf("prop",c,y=>{i.setParams({missingProperty:y}),s.if((0,t.noPropertyInData)(s,l,y,d.ownProperties),()=>i.error())})}function b(y,w){i.setParams({missingProperty:y}),s.forOf(y,c,()=>{s.assign(w,(0,t.propertyInData)(s,l,y,d.ownProperties)),s.if((0,r.not)(w),()=>{i.error(),s.break()})},r.nil)}}};e.default=n})),BU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:o,schemaCode:n}){let i=o==="maxItems"?"more":"fewer";return(0,t.str)`must NOT have ${i} than ${n} items`},params:({schemaCode:o})=>(0,t._)`{limit: ${o}}`},code(o){let{keyword:n,data:i,schemaCode:s}=o,a=n==="maxItems"?t.operators.GT:t.operators.LT;o.fail$data((0,t._)`${i}.length ${a} ${s}`)}};e.default=r})),uS=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Gj();t.code='require("ajv/dist/runtime/equal").default',e.default=t})),WU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Fg(),r=qe(),o=We(),n=uS(),i={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:s,j:a}})=>(0,r.str)`must NOT have duplicate items (items ## ${a} and ${s} are identical)`,params:({params:{i:s,j:a}})=>(0,r._)`{i: ${s}, j: ${a}}`},code(s){let{gen:a,data:c,$data:l,schema:u,parentSchema:m,schemaCode:d,it:f}=s;if(!l&&!u)return;let p=a.let("valid"),h=m.items?(0,t.getSchemaTypes)(m.items):[];s.block$data(p,g,(0,r._)`${d} === false`),s.ok(p);function g(){let v=a.let("i",(0,r._)`${c}.length`),S=a.let("j");s.setParams({i:v,j:S}),a.assign(p,!0),a.if((0,r._)`${v} > 1`,()=>(b()?y:w)(v,S))}function b(){return h.length>0&&!h.some(v=>v==="object"||v==="array")}function y(v,S){let _=a.name("item"),$=(0,t.checkDataTypes)(h,_,f.opts.strictNumbers,t.DataType.Wrong),x=a.const("indices",(0,r._)`{}`);a.for((0,r._)`;${v}--;`,()=>{a.let(_,(0,r._)`${c}[${v}]`),a.if($,(0,r._)`continue`),h.length>1&&a.if((0,r._)`typeof ${_} == "string"`,(0,r._)`${_} += "_"`),a.if((0,r._)`typeof ${x}[${_}] == "number"`,()=>{a.assign(S,(0,r._)`${x}[${_}]`),s.error(),a.assign(p,!1).break()}).code((0,r._)`${x}[${_}] = ${v}`)})}function w(v,S){let _=(0,o.useFunc)(a,n.default),$=a.name("outer");a.label($).for((0,r._)`;${v}--;`,()=>a.for((0,r._)`${S} = ${v}; ${S}--;`,()=>a.if((0,r._)`${_}(${c}[${v}], ${c}[${S}])`,()=>{s.error(),a.assign(p,!1).break($)})))}}};e.default=i})),JU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=We(),o=uS(),n={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:i})=>(0,t._)`{allowedValue: ${i}}`},code(i){let{gen:s,data:a,$data:c,schemaCode:l,schema:u}=i;c||u&&typeof u=="object"?i.fail$data((0,t._)`!${(0,r.useFunc)(s,o.default)}(${a}, ${l})`):i.fail((0,t._)`${u} !== ${a}`)}};e.default=n})),GU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=We(),o=uS(),n={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:i})=>(0,t._)`{allowedValues: ${i}}`},code(i){let{gen:s,data:a,$data:c,schema:l,schemaCode:u,it:m}=i;if(!c&&l.length===0)throw new Error("enum must have non-empty array");let d=l.length>=m.opts.loopEnum,f,p=()=>f??(f=(0,r.useFunc)(s,o.default)),h;if(d||c)h=s.let("valid"),i.block$data(h,g);else{if(!Array.isArray(l))throw new Error("ajv implementation error");let y=s.const("vSchema",u);h=(0,t.or)(...l.map((w,v)=>b(y,v)))}i.pass(h);function g(){s.assign(h,!1),s.forOf("v",u,y=>s.if((0,t._)`${p()}(${a}, ${y})`,()=>s.assign(h,!0).break()))}function b(y,w){let v=l[w];return typeof v=="object"&&v!==null?(0,t._)`${p()}(${a}, ${y}[${w}])`:(0,t._)`${a} === ${v}`}}};e.default=n})),Xj=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qU(),r=UU(),o=FU(),n=VU(),i=ZU(),s=HU(),a=BU(),c=WU(),l=JU(),u=GU(),m=[t.default,r.default,o.default,n.default,i.default,s.default,a.default,c.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},l.default,u.default];e.default=m})),Qj=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;let t=qe(),r=We(),o={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:i}})=>(0,t.str)`must NOT have more than ${i} items`,params:({params:{len:i}})=>(0,t._)`{limit: ${i}}`},code(i){let{parentSchema:s,it:a}=i,{items:c}=s;if(!Array.isArray(c)){(0,r.checkStrictMode)(a,'"additionalItems" is ignored when "items" is not an array of schemas');return}n(i,c)}};function n(i,s){let{gen:a,schema:c,data:l,keyword:u,it:m}=i;m.items=!0;let d=a.const("len",(0,t._)`${l}.length`);if(c===!1)i.setParams({len:s.length}),i.pass((0,t._)`${d} <= ${s.length}`);else if(typeof c=="object"&&!(0,r.alwaysValidSchema)(m,c)){let p=a.var("valid",(0,t._)`${d} <= ${s.length}`);a.if((0,t.not)(p),()=>f(p)),i.ok(p)}function f(p){a.forRange("i",s.length,d,h=>{i.subschema({keyword:u,dataProp:h,dataPropType:r.Type.Num},p),m.allErrors||a.if((0,t.not)(p),()=>a.break())})}}e.validateAdditionalItems=n,e.default=o})),eE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;let t=qe(),r=We(),o=vr(),n={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(s){let{schema:a,it:c}=s;if(Array.isArray(a))return i(s,"additionalItems",a);c.items=!0,!(0,r.alwaysValidSchema)(c,a)&&s.ok((0,o.validateArray)(s))}};function i(s,a,c=s.schema){let{gen:l,parentSchema:u,data:m,keyword:d,it:f}=s;g(u),f.opts.unevaluated&&c.length&&f.items!==!0&&(f.items=r.mergeEvaluated.items(l,c.length,f.items));let p=l.name("valid"),h=l.const("len",(0,t._)`${m}.length`);c.forEach((b,y)=>{(0,r.alwaysValidSchema)(f,b)||(l.if((0,t._)`${h} > ${y}`,()=>s.subschema({keyword:d,schemaProp:y,dataProp:y},p)),s.ok(p))});function g(b){let{opts:y,errSchemaPath:w}=f,v=c.length,S=v===b.minItems&&(v===b.maxItems||b[a]===!1);if(y.strictTuples&&!S){let _=`"${d}" is ${v}-tuple, but minItems or maxItems/${a} are not specified or different at path "${w}"`;(0,r.checkStrictMode)(f,_,y.strictTuples)}}}e.validateTuple=i,e.default=n})),KU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=eE(),r={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:o=>(0,t.validateTuple)(o,"items")};e.default=r})),YU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=We(),o=vr(),n=Qj(),i={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:s}})=>(0,t.str)`must NOT have more than ${s} items`,params:({params:{len:s}})=>(0,t._)`{limit: ${s}}`},code(s){let{schema:a,parentSchema:c,it:l}=s,{prefixItems:u}=c;l.items=!0,!(0,r.alwaysValidSchema)(l,a)&&(u?(0,n.validateAdditionalItems)(s,u):s.ok((0,o.validateArray)(s)))}};e.default=i})),XU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=We(),o={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:n,max:i}})=>i===void 0?(0,t.str)`must contain at least ${n} valid item(s)`:(0,t.str)`must contain at least ${n} and no more than ${i} valid item(s)`,params:({params:{min:n,max:i}})=>i===void 0?(0,t._)`{minContains: ${n}}`:(0,t._)`{minContains: ${n}, maxContains: ${i}}`},code(n){let{gen:i,schema:s,parentSchema:a,data:c,it:l}=n,u,m,{minContains:d,maxContains:f}=a;l.opts.next?(u=d===void 0?1:d,m=f):u=1;let p=i.const("len",(0,t._)`${c}.length`);if(n.setParams({min:u,max:m}),m===void 0&&u===0){(0,r.checkStrictMode)(l,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(m!==void 0&&u>m){(0,r.checkStrictMode)(l,'"minContains" > "maxContains" is always invalid'),n.fail();return}if((0,r.alwaysValidSchema)(l,s)){let w=(0,t._)`${p} >= ${u}`;m!==void 0&&(w=(0,t._)`${w} && ${p} <= ${m}`),n.pass(w);return}l.items=!0;let h=i.name("valid");m===void 0&&u===1?b(h,()=>i.if(h,()=>i.break())):u===0?(i.let(h,!0),m!==void 0&&i.if((0,t._)`${c}.length > 0`,g)):(i.let(h,!1),g()),n.result(h,()=>n.reset());function g(){let w=i.name("_valid"),v=i.let("count",0);b(w,()=>i.if(w,()=>y(v)))}function b(w,v){i.forRange("i",0,p,S=>{n.subschema({keyword:"contains",dataProp:S,dataPropType:r.Type.Num,compositeRule:!0},w),v()})}function y(w){i.code((0,t._)`${w}++`),m===void 0?i.if((0,t._)`${w} >= ${u}`,()=>i.assign(h,!0).break()):(i.if((0,t._)`${w} > ${m}`,()=>i.assign(h,!1).break()),u===1?i.assign(h,!0):i.if((0,t._)`${w} >= ${u}`,()=>i.assign(h,!0)))}}};e.default=o})),mS=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=qe(),r=We(),o=vr();e.error={message:({params:{property:c,depsCount:l,deps:u}})=>{let m=l===1?"property":"properties";return(0,t.str)`must have ${m} ${u} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:u,missingProperty:m}})=>(0,t._)`{property: ${c},
71
+ missingProperty: ${m},
72
+ depsCount: ${l},
73
+ deps: ${u}}`};let n={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){let[l,u]=i(c);s(c,l),a(c,u)}};function i({schema:c}){let l={},u={};for(let m in c){if(m==="__proto__")continue;let d=Array.isArray(c[m])?l:u;d[m]=c[m]}return[l,u]}function s(c,l=c.schema){let{gen:u,data:m,it:d}=c;if(Object.keys(l).length===0)return;let f=u.let("missing");for(let p in l){let h=l[p];if(h.length===0)continue;let g=(0,o.propertyInData)(u,m,p,d.opts.ownProperties);c.setParams({property:p,depsCount:h.length,deps:h.join(", ")}),d.allErrors?u.if(g,()=>{for(let b of h)(0,o.checkReportMissingProp)(c,b)}):(u.if((0,t._)`${g} && (${(0,o.checkMissingProp)(c,h,f)})`),(0,o.reportMissingProp)(c,f),u.else())}}e.validatePropertyDeps=s;function a(c,l=c.schema){let{gen:u,data:m,keyword:d,it:f}=c,p=u.name("valid");for(let h in l)(0,r.alwaysValidSchema)(f,l[h])||(u.if((0,o.propertyInData)(u,m,h,f.opts.ownProperties),()=>{let g=c.subschema({keyword:d,schemaProp:h},p);c.mergeValidEvaluated(g,p)},()=>u.var(p,!0)),c.ok(p))}e.validateSchemaDeps=a,e.default=n})),QU=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=We(),o={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:n})=>(0,t._)`{propertyName: ${n.propertyName}}`},code(n){let{gen:i,schema:s,data:a,it:c}=n;if((0,r.alwaysValidSchema)(c,s))return;let l=i.name("valid");i.forIn("key",a,u=>{n.setParams({propertyName:u}),n.subschema({keyword:"propertyNames",data:u,dataTypes:["string"],propertyName:u,compositeRule:!0},l),i.if((0,t.not)(l),()=>{n.error(!0),c.allErrors||i.break()})}),n.ok(l)}};e.default=o})),tE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vr(),r=qe(),o=wr(),n=We(),i={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:s})=>(0,r._)`{additionalProperty: ${s.additionalProperty}}`},code(s){let{gen:a,schema:c,parentSchema:l,data:u,errsCount:m,it:d}=s;if(!m)throw new Error("ajv implementation error");let{allErrors:f,opts:p}=d;if(d.props=!0,p.removeAdditional!=="all"&&(0,n.alwaysValidSchema)(d,c))return;let h=(0,t.allSchemaProperties)(l.properties),g=(0,t.allSchemaProperties)(l.patternProperties);b(),s.ok((0,r._)`${m} === ${o.default.errors}`);function b(){a.forIn("key",u,_=>{!h.length&&!g.length?v(_):a.if(y(_),()=>v(_))})}function y(_){let $;if(h.length>8){let x=(0,n.schemaRefOrVal)(d,l.properties,"properties");$=(0,t.isOwnProperty)(a,x,_)}else h.length?$=(0,r.or)(...h.map(x=>(0,r._)`${_} === ${x}`)):$=r.nil;return g.length&&($=(0,r.or)($,...g.map(x=>(0,r._)`${(0,t.usePattern)(s,x)}.test(${_})`))),(0,r.not)($)}function w(_){a.code((0,r._)`delete ${u}[${_}]`)}function v(_){if(p.removeAdditional==="all"||p.removeAdditional&&c===!1){w(_);return}if(c===!1){s.setParams({additionalProperty:_}),s.error(),f||a.break();return}if(typeof c=="object"&&!(0,n.alwaysValidSchema)(d,c)){let $=a.name("valid");p.removeAdditional==="failing"?(S(_,$,!1),a.if((0,r.not)($),()=>{s.reset(),w(_)})):(S(_,$),f||a.if((0,r.not)($),()=>a.break()))}}function S(_,$,x){let k={keyword:"additionalProperties",dataProp:_,dataPropType:n.Type.Str};x===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),s.subschema(k,$)}}};e.default=i})),eL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=uc(),r=vr(),o=We(),n=tE(),i={keyword:"properties",type:"object",schemaType:"object",code(s){let{gen:a,schema:c,parentSchema:l,data:u,it:m}=s;m.opts.removeAdditional==="all"&&l.additionalProperties===void 0&&n.default.code(new t.KeywordCxt(m,n.default,"additionalProperties"));let d=(0,r.allSchemaProperties)(c);for(let b of d)m.definedProperties.add(b);m.opts.unevaluated&&d.length&&m.props!==!0&&(m.props=o.mergeEvaluated.props(a,(0,o.toHash)(d),m.props));let f=d.filter(b=>!(0,o.alwaysValidSchema)(m,c[b]));if(f.length===0)return;let p=a.name("valid");for(let b of f)h(b)?g(b):(a.if((0,r.propertyInData)(a,u,b,m.opts.ownProperties)),g(b),m.allErrors||a.else().var(p,!0),a.endIf()),s.it.definedProperties.add(b),s.ok(p);function h(b){return m.opts.useDefaults&&!m.compositeRule&&c[b].default!==void 0}function g(b){s.subschema({keyword:"properties",schemaProp:b,dataProp:b},p)}}};e.default=i})),tL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vr(),r=qe(),o=We(),n=We(),i={keyword:"patternProperties",type:"object",schemaType:"object",code(s){let{gen:a,schema:c,data:l,parentSchema:u,it:m}=s,{opts:d}=m,f=(0,t.allSchemaProperties)(c),p=f.filter(S=>(0,o.alwaysValidSchema)(m,c[S]));if(f.length===0||p.length===f.length&&(!m.opts.unevaluated||m.props===!0))return;let h=d.strictSchema&&!d.allowMatchingProperties&&u.properties,g=a.name("valid");m.props!==!0&&!(m.props instanceof r.Name)&&(m.props=(0,n.evaluatedPropsToName)(a,m.props));let{props:b}=m;y();function y(){for(let S of f)h&&w(S),m.allErrors?v(S):(a.var(g,!0),v(S),a.if(g))}function w(S){for(let _ in h)new RegExp(S).test(_)&&(0,o.checkStrictMode)(m,`property ${_} matches pattern ${S} (use allowMatchingProperties)`)}function v(S){a.forIn("key",l,_=>{a.if((0,r._)`${(0,t.usePattern)(s,S)}.test(${_})`,()=>{let $=p.includes(S);$||s.subschema({keyword:"patternProperties",schemaProp:S,dataProp:_,dataPropType:n.Type.Str},g),m.opts.unevaluated&&b!==!0?a.assign((0,r._)`${b}[${_}]`,!0):!$&&!m.allErrors&&a.if((0,r.not)(g),()=>a.break())})})}}};e.default=i})),nL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=We(),r={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(o){let{gen:n,schema:i,it:s}=o;if((0,t.alwaysValidSchema)(s,i)){o.fail();return}let a=n.name("valid");o.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},a),o.failResult(a,()=>o.reset(),()=>o.error())},error:{message:"must NOT be valid"}};e.default=r})),rL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:vr().validateUnion,error:{message:"must match a schema in anyOf"}};e.default=t})),oL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=We(),o={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:n})=>(0,t._)`{passingSchemas: ${n.passing}}`},code(n){let{gen:i,schema:s,parentSchema:a,it:c}=n;if(!Array.isArray(s))throw new Error("ajv implementation error");if(c.opts.discriminator&&a.discriminator)return;let l=s,u=i.let("valid",!1),m=i.let("passing",null),d=i.name("_valid");n.setParams({passing:m}),i.block(f),n.result(u,()=>n.reset(),()=>n.error(!0));function f(){l.forEach((p,h)=>{let g;(0,r.alwaysValidSchema)(c,p)?i.var(d,!0):g=n.subschema({keyword:"oneOf",schemaProp:h,compositeRule:!0},d),h>0&&i.if((0,t._)`${d} && ${u}`).assign(u,!1).assign(m,(0,t._)`[${m}, ${h}]`).else(),i.if(d,()=>{i.assign(u,!0),i.assign(m,h),g&&n.mergeEvaluated(g,t.Name)})})}}};e.default=o})),iL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=We(),r={keyword:"allOf",schemaType:"array",code(o){let{gen:n,schema:i,it:s}=o;if(!Array.isArray(i))throw new Error("ajv implementation error");let a=n.name("valid");i.forEach((c,l)=>{if((0,t.alwaysValidSchema)(s,c))return;let u=o.subschema({keyword:"allOf",schemaProp:l},a);o.ok(a),o.mergeEvaluated(u)})}};e.default=r})),sL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=We(),o={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:i})=>(0,t.str)`must match "${i.ifClause}" schema`,params:({params:i})=>(0,t._)`{failingKeyword: ${i.ifClause}}`},code(i){let{gen:s,parentSchema:a,it:c}=i;a.then===void 0&&a.else===void 0&&(0,r.checkStrictMode)(c,'"if" without "then" and "else" is ignored');let l=n(c,"then"),u=n(c,"else");if(!l&&!u)return;let m=s.let("valid",!0),d=s.name("_valid");if(f(),i.reset(),l&&u){let h=s.let("ifClause");i.setParams({ifClause:h}),s.if(d,p("then",h),p("else",h))}else l?s.if(d,p("then")):s.if((0,t.not)(d),p("else"));i.pass(m,()=>i.error(!0));function f(){let h=i.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},d);i.mergeEvaluated(h)}function p(h,g){return()=>{let b=i.subschema({keyword:h},d);s.assign(m,d),i.mergeValidEvaluated(b,m),g?s.assign(g,(0,t._)`${h}`):i.setParams({ifClause:h})}}}};function n(i,s){let a=i.schema[s];return a!==void 0&&!(0,r.alwaysValidSchema)(i,a)}e.default=o})),aL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=We(),r={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:o,parentSchema:n,it:i}){n.if===void 0&&(0,t.checkStrictMode)(i,`"${o}" without "if" is ignored`)}};e.default=r})),nE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Qj(),r=KU(),o=eE(),n=YU(),i=XU(),s=mS(),a=QU(),c=tE(),l=eL(),u=tL(),m=nL(),d=rL(),f=oL(),p=iL(),h=sL(),g=aL();function b(y=!1){let w=[m.default,d.default,f.default,p.default,h.default,g.default,a.default,c.default,s.default,l.default,u.default];return y?w.push(r.default,n.default):w.push(t.default,o.default),w.push(i.default),w}e.default=b})),cL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:o})=>(0,t.str)`must match format "${o}"`,params:({schemaCode:o})=>(0,t._)`{format: ${o}}`},code(o,n){let{gen:i,data:s,$data:a,schema:c,schemaCode:l,it:u}=o,{opts:m,errSchemaPath:d,schemaEnv:f,self:p}=u;if(!m.validateFormats)return;a?h():g();function h(){let b=i.scopeValue("formats",{ref:p.formats,code:m.code.formats}),y=i.const("fDef",(0,t._)`${b}[${l}]`),w=i.let("fType"),v=i.let("format");i.if((0,t._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>i.assign(w,(0,t._)`${y}.type || "string"`).assign(v,(0,t._)`${y}.validate`),()=>i.assign(w,(0,t._)`"string"`).assign(v,y)),o.fail$data((0,t.or)(S(),_()));function S(){return m.strictSchema===!1?t.nil:(0,t._)`${l} && !${v}`}function _(){let $=f.$async?(0,t._)`(${y}.async ? await ${v}(${s}) : ${v}(${s}))`:(0,t._)`${v}(${s})`,x=(0,t._)`(typeof ${v} == "function" ? ${$} : ${v}.test(${s}))`;return(0,t._)`${v} && ${v} !== true && ${w} === ${n} && !${x}`}}function g(){let b=p.formats[c];if(!b){S();return}if(b===!0)return;let[y,w,v]=_(b);y===n&&o.pass($());function S(){if(m.strictSchema===!1){p.logger.warn(x());return}throw new Error(x());function x(){return`unknown format "${c}" ignored in schema at path "${d}"`}}function _(x){let k=x instanceof RegExp?(0,t.regexpCode)(x):m.code.formats?(0,t._)`${m.code.formats}${(0,t.getProperty)(c)}`:void 0,P=i.scopeValue("formats",{key:c,ref:x,code:k});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,t._)`${P}.validate`]:["string",x,P]}function $(){if(typeof b=="object"&&!(b instanceof RegExp)&&b.async){if(!f.$async)throw new Error("async format in sync schema");return(0,t._)`await ${v}(${s})`}return typeof w=="function"?(0,t._)`${v}(${s})`:(0,t._)`${v}.test(${s})`}}}};e.default=r})),rE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=[cL().default];e.default=t})),oE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],e.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]})),iE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Yj(),r=Xj(),o=nE(),n=rE(),i=oE(),s=[t.default,r.default,(0,o.default)(),n.default,i.metadataVocabulary,i.contentVocabulary];e.default=s})),lL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(r){r.Tag="tag",r.Mapping="mapping"})(t||(e.DiscrError=t={}))})),dS=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=lL(),o=Hg(),n=mc(),i=We(),s={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:a,tagName:c}})=>a===r.DiscrError.Tag?`tag "${c}" must be string`:`value of tag "${c}" must be in oneOf`,params:({params:{discrError:a,tag:c,tagName:l}})=>(0,t._)`{error: ${a}, tag: ${l}, tagValue: ${c}}`},code(a){let{gen:c,data:l,schema:u,parentSchema:m,it:d}=a,{oneOf:f}=m;if(!d.opts.discriminator)throw new Error("discriminator: requires discriminator option");let p=u.propertyName;if(typeof p!="string")throw new Error("discriminator: requires propertyName");if(u.mapping)throw new Error("discriminator: mapping is not supported");if(!f)throw new Error("discriminator: requires oneOf keyword");let h=c.let("valid",!1),g=c.const("tag",(0,t._)`${l}${(0,t.getProperty)(p)}`);c.if((0,t._)`typeof ${g} == "string"`,()=>b(),()=>a.error(!1,{discrError:r.DiscrError.Tag,tag:g,tagName:p})),a.ok(h);function b(){let v=w();c.if(!1);for(let S in v)c.elseIf((0,t._)`${g} === ${S}`),c.assign(h,y(v[S]));c.else(),a.error(!1,{discrError:r.DiscrError.Mapping,tag:g,tagName:p}),c.endIf()}function y(v){let S=c.name("valid"),_=a.subschema({keyword:"oneOf",schemaProp:v},S);return a.mergeEvaluated(_,t.Name),S}function w(){var v;let S={},_=x(m),$=!0;for(let I=0;I<f.length;I++){let E=f[I];if(E?.$ref&&!(0,i.schemaHasRulesButRef)(E,d.self.RULES)){let T=E.$ref;if(E=o.resolveRef.call(d.self,d.schemaEnv.root,d.baseId,T),E instanceof o.SchemaEnv&&(E=E.schema),E===void 0)throw new n.default(d.opts.uriResolver,d.baseId,T)}let N=(v=E?.properties)===null||v===void 0?void 0:v[p];if(typeof N!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${p}"`);$=$&&(_||x(E)),k(N,I)}if(!$)throw new Error(`discriminator: "${p}" must be required`);return S;function x({required:I}){return Array.isArray(I)&&I.includes(p)}function k(I,E){if(I.const)P(I.const,E);else if(I.enum)for(let N of I.enum)P(N,E);else throw new Error(`discriminator: "properties/${p}" must have "const" or "enum"`)}function P(I,E){if(typeof I!="string"||I in S)throw new Error(`discriminator: "${p}" values must be unique strings`);S[I]=E}}}};e.default=s})),uL=ue(((e,t)=>{t.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}})),sE=ue(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let r=cS(),o=iE(),n=dS(),i=uL(),s=["/properties"],a="http://json-schema.org/draft-07/schema";var c=class extends r.default{_addVocabularies(){super._addVocabularies(),o.default.forEach(f=>this.addVocabulary(f)),this.opts.discriminator&&this.addKeyword(n.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let f=this.opts.$data?this.$dataMetaSchema(i,s):i;this.addMetaSchema(f,a,!1),this.refs["http://json-schema.org/schema"]=a}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var l=uc();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=qe();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var m=Qu();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return m.default}});var d=mc();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})),aE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicAnchor=void 0;let t=qe(),r=wr(),o=Hg(),n=lS(),i={keyword:"$dynamicAnchor",schemaType:"string",code:c=>s(c,c.schema)};function s(c,l){let{gen:u,it:m}=c;m.schemaEnv.root.dynamicAnchors[l]=!0;let d=(0,t._)`${r.default.dynamicAnchors}${(0,t.getProperty)(l)}`,f=m.errSchemaPath==="#"?m.validateName:a(c);u.if((0,t._)`!${d}`,()=>u.assign(d,f))}e.dynamicAnchor=s;function a(c){let{schemaEnv:l,schema:u,self:m}=c.it,{root:d,baseId:f,localRefs:p,meta:h}=l.root,{schemaId:g}=m.opts,b=new o.SchemaEnv({schema:u,schemaId:g,root:d,baseId:f,localRefs:p,meta:h});return o.compileSchema.call(m,b),(0,n.getValidate)(c,b)}e.default=i})),cE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicRef=void 0;let t=qe(),r=wr(),o=lS(),n={keyword:"$dynamicRef",schemaType:"string",code:s=>i(s,s.schema)};function i(s,a){let{gen:c,keyword:l,it:u}=s;if(a[0]!=="#")throw new Error(`"${l}" only supports hash fragment reference`);let m=a.slice(1);if(u.allErrors)d();else{let p=c.let("valid",!1);d(p),s.ok(p)}function d(p){if(u.schemaEnv.root.dynamicAnchors[m]){let h=c.let("_v",(0,t._)`${r.default.dynamicAnchors}${(0,t.getProperty)(m)}`);c.if(h,f(h,p),f(u.validateName,p))}else f(u.validateName,p)()}function f(p,h){return h?()=>c.block(()=>{(0,o.callRef)(s,p),c.let(h,!0)}):()=>(0,o.callRef)(s,p)}}e.dynamicRef=i,e.default=n})),mL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=aE(),r=We(),o={keyword:"$recursiveAnchor",schemaType:"boolean",code(n){n.schema?(0,t.dynamicAnchor)(n,""):(0,r.checkStrictMode)(n.it,"$recursiveAnchor: false is ignored")}};e.default=o})),dL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=cE(),r={keyword:"$recursiveRef",schemaType:"string",code:o=>(0,t.dynamicRef)(o,o.schema)};e.default=r})),lE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=aE(),r=cE(),o=mL(),n=dL(),i=[t.default,r.default,o.default,n.default];e.default=i})),fL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=mS(),r={keyword:"dependentRequired",type:"object",schemaType:"object",error:t.error,code:o=>(0,t.validatePropertyDeps)(o)};e.default=r})),pL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=mS(),r={keyword:"dependentSchemas",type:"object",schemaType:"object",code:o=>(0,t.validateSchemaDeps)(o)};e.default=r})),hL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=We(),r={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:o,parentSchema:n,it:i}){n.contains===void 0&&(0,t.checkStrictMode)(i,`"${o}" without "contains" is ignored`)}};e.default=r})),uE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=fL(),r=pL(),o=hL(),n=[t.default,r.default,o.default];e.default=n})),gL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=We(),o=wr(),n={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:{message:"must NOT have unevaluated properties",params:({params:i})=>(0,t._)`{unevaluatedProperty: ${i.unevaluatedProperty}}`},code(i){let{gen:s,schema:a,data:c,errsCount:l,it:u}=i;if(!l)throw new Error("ajv implementation error");let{allErrors:m,props:d}=u;d instanceof t.Name?s.if((0,t._)`${d} !== true`,()=>s.forIn("key",c,g=>s.if(p(d,g),()=>f(g)))):d!==!0&&s.forIn("key",c,g=>d===void 0?f(g):s.if(h(d,g),()=>f(g))),u.props=!0,i.ok((0,t._)`${l} === ${o.default.errors}`);function f(g){if(a===!1){i.setParams({unevaluatedProperty:g}),i.error(),m||s.break();return}if(!(0,r.alwaysValidSchema)(u,a)){let b=s.name("valid");i.subschema({keyword:"unevaluatedProperties",dataProp:g,dataPropType:r.Type.Str},b),m||s.if((0,t.not)(b),()=>s.break())}}function p(g,b){return(0,t._)`!${g} || !${g}[${b}]`}function h(g,b){let y=[];for(let w in g)g[w]===!0&&y.push((0,t._)`${b} !== ${w}`);return(0,t.and)(...y)}}};e.default=n})),yL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=We(),o={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:{message:({params:{len:n}})=>(0,t.str)`must NOT have more than ${n} items`,params:({params:{len:n}})=>(0,t._)`{limit: ${n}}`},code(n){let{gen:i,schema:s,data:a,it:c}=n,l=c.items||0;if(l===!0)return;let u=i.const("len",(0,t._)`${a}.length`);if(s===!1)n.setParams({len:l}),n.fail((0,t._)`${u} > ${l}`);else if(typeof s=="object"&&!(0,r.alwaysValidSchema)(c,s)){let d=i.var("valid",(0,t._)`${u} <= ${l}`);i.if((0,t.not)(d),()=>m(d,l)),n.ok(d)}c.items=!0;function m(d,f){i.forRange("i",f,u,p=>{n.subschema({keyword:"unevaluatedItems",dataProp:p,dataPropType:r.Type.Num},d),c.allErrors||i.if((0,t.not)(d),()=>i.break())})}}};e.default=o})),mE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=gL(),r=yL(),o=[t.default,r.default];e.default=o})),bL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/schema",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format"},{$ref:"meta/content"}],type:["object","boolean"],properties:{definitions:{$comment:"While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},dependencies:{$comment:'"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"',type:"object",additionalProperties:{anyOf:[{$recursiveRef:"#"},{$ref:"meta/validation#/$defs/stringArray"}]}}}}})),wL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/applicator":!0},$recursiveAnchor:!0,title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{additionalItems:{$recursiveRef:"#"},unevaluatedItems:{$recursiveRef:"#"},items:{anyOf:[{$recursiveRef:"#"},{$ref:"#/$defs/schemaArray"}]},contains:{$recursiveRef:"#"},additionalProperties:{$recursiveRef:"#"},unevaluatedProperties:{$recursiveRef:"#"},properties:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$recursiveRef:"#"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$recursiveRef:"#"}},propertyNames:{$recursiveRef:"#"},if:{$recursiveRef:"#"},then:{$recursiveRef:"#"},else:{$recursiveRef:"#"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$recursiveRef:"#"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$recursiveRef:"#"}}}}})),vL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/content",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentMediaType:{type:"string"},contentEncoding:{type:"string"},contentSchema:{$recursiveRef:"#"}}}})),$L=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/core",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0},$recursiveAnchor:!0,title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{type:"string",format:"uri"},$anchor:{type:"string",pattern:"^[A-Za-z][-A-Za-z0-9.:_]*$"},$ref:{type:"string",format:"uri-reference"},$recursiveRef:{type:"string",format:"uri-reference"},$recursiveAnchor:{type:"boolean",default:!1},$vocabulary:{type:"object",propertyNames:{type:"string",format:"uri"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}}}}})),xL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/format",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/format":!0},$recursiveAnchor:!0,title:"Format vocabulary meta-schema",type:["object","boolean"],properties:{format:{type:"string"}}}})),_L=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},$recursiveAnchor:!0,title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}})),SL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/validation",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/validation":!0},$recursiveAnchor:!0,title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}},const:!0,enum:{type:"array",items:!0},type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}})),kL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=bL(),r=wL(),o=vL(),n=$L(),i=xL(),s=_L(),a=SL(),c=["/properties"];function l(u){return[t,r,o,n,m(this,i),s,m(this,a)].forEach(d=>this.addMetaSchema(d,void 0,!1)),this;function m(d,f){return u?d.$dataMetaSchema(f,c):f}}e.default=l})),zL=ue(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv2019=void 0;let r=cS(),o=iE(),n=lE(),i=uE(),s=mE(),a=dS(),c=kL(),l="https://json-schema.org/draft/2019-09/schema";var u=class extends r.default{constructor(h={}){super({...h,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(n.default),o.default.forEach(h=>this.addVocabulary(h)),this.addVocabulary(i.default),this.addVocabulary(s.default),this.opts.discriminator&&this.addKeyword(a.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:h,meta:g}=this.opts;g&&(c.default.call(this,h),this.refs["http://json-schema.org/schema"]=l)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}};e.Ajv2019=u,t.exports=e=u,t.exports.Ajv2019=u,Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var m=uc();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return m.KeywordCxt}});var d=qe();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var f=Qu();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var p=mc();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})})),RL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Yj(),r=Xj(),o=nE(),n=lE(),i=uE(),s=mE(),a=rE(),c=oE(),l=[n.default,t.default,r.default,(0,o.default)(!0),a.default,c.metadataVocabulary,c.contentVocabulary,i.default,s.default];e.default=l})),IL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}}}})),PL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}}})),jL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}}})),EL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}}})),TL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}}})),CL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}}})),AL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}})),OL=ue(((e,t)=>{t.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}})),NL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=IL(),r=PL(),o=jL(),n=EL(),i=TL(),s=CL(),a=AL(),c=OL(),l=["/properties"];function u(m){return[t,r,o,n,i,d(this,s),a,d(this,c)].forEach(f=>this.addMetaSchema(f,void 0,!1)),this;function d(f,p){return m?f.$dataMetaSchema(p,l):p}}e.default=u})),ML=ue(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv2020=void 0;let r=cS(),o=RL(),n=dS(),i=NL(),s="https://json-schema.org/draft/2020-12/schema";var a=class extends r.default{constructor(d={}){super({...d,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),o.default.forEach(d=>this.addVocabulary(d)),this.opts.discriminator&&this.addKeyword(n.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:d,meta:f}=this.opts;f&&(i.default.call(this,d),this.refs["http://json-schema.org/schema"]=s)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv2020=a,t.exports=e=a,t.exports.Ajv2020=a,Object.defineProperty(e,"__esModule",{value:!0}),e.default=a;var c=uc();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var l=qe();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return l._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return l.CodeGen}});var u=Qu();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var m=mc();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})),DL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(I,E){return{validate:I,compare:E}}e.fullFormats={date:t(i,s),time:t(c(!0),l),"date-time":t(d(!0),f),"iso-time":t(c(),u),"iso-date-time":t(d(),p),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:b,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:P,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:w,int32:{type:"number",validate:_},int64:{type:"number",validate:$},float:{type:"number",validate:x},double:{type:"number",validate:x},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,s),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,p),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function r(I){return I%4===0&&(I%100!==0||I%400===0)}let o=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,n=[0,31,28,31,30,31,30,31,31,30,31,30,31];function i(I){let E=o.exec(I);if(!E)return!1;let N=+E[1],T=+E[2],q=+E[3];return T>=1&&T<=12&&q>=1&&q<=(T===2&&r(N)?29:n[T])}function s(I,E){if(I&&E)return I>E?1:I<E?-1:0}let a=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(I){return function(N){let T=a.exec(N);if(!T)return!1;let q=+T[1],Z=+T[2],D=+T[3],V=T[4],F=T[5]==="-"?-1:1,M=+(T[6]||0),L=+(T[7]||0);if(M>23||L>59||I&&!V)return!1;if(q<=23&&Z<=59&&D<60)return!0;let A=Z-L*F,z=q-M*F-(A<0?1:0);return(z===23||z===-1)&&(A===59||A===-1)&&D<61}}function l(I,E){if(!(I&&E))return;let N=new Date("2020-01-01T"+I).valueOf(),T=new Date("2020-01-01T"+E).valueOf();if(N&&T)return N-T}function u(I,E){if(!(I&&E))return;let N=a.exec(I),T=a.exec(E);if(N&&T)return I=N[1]+N[2]+N[3],E=T[1]+T[2]+T[3],I>E?1:I<E?-1:0}let m=/t|\s/i;function d(I){let E=c(I);return function(T){let q=T.split(m);return q.length===2&&i(q[0])&&E(q[1])}}function f(I,E){if(!(I&&E))return;let N=new Date(I).valueOf(),T=new Date(E).valueOf();if(N&&T)return N-T}function p(I,E){if(!(I&&E))return;let[N,T]=I.split(m),[q,Z]=E.split(m),D=s(N,q);if(D!==void 0)return D||l(T,Z)}let h=/\/|:/,g=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function b(I){return h.test(I)&&g.test(I)}let y=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function w(I){return y.lastIndex=0,y.test(I)}let v=-(2**31),S=2**31-1;function _(I){return Number.isInteger(I)&&I<=S&&I>=v}function $(I){return Number.isInteger(I)}function x(){return!0}let k=/[^\\]\\Z/;function P(I){if(k.test(I))return!1;try{return new RegExp(I),!0}catch{return!1}}})),qL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;let t=sE(),r=qe(),o=r.operators,n={formatMaximum:{okStr:"<=",ok:o.LTE,fail:o.GT},formatMinimum:{okStr:">=",ok:o.GTE,fail:o.LT},formatExclusiveMaximum:{okStr:"<",ok:o.LT,fail:o.GTE},formatExclusiveMinimum:{okStr:">",ok:o.GT,fail:o.LTE}},i={message:({keyword:a,schemaCode:c})=>(0,r.str)`should be ${n[a].okStr} ${c}`,params:({keyword:a,schemaCode:c})=>(0,r._)`{comparison: ${n[a].okStr}, limit: ${c}}`};e.formatLimitDefinition={keyword:Object.keys(n),type:"string",schemaType:"string",$data:!0,error:i,code(a){let{gen:c,data:l,schemaCode:u,keyword:m,it:d}=a,{opts:f,self:p}=d;if(!f.validateFormats)return;let h=new t.KeywordCxt(d,p.RULES.all.format.definition,"format");h.$data?g():b();function g(){let w=c.scopeValue("formats",{ref:p.formats,code:f.code.formats}),v=c.const("fmt",(0,r._)`${w}[${h.schemaCode}]`);a.fail$data((0,r.or)((0,r._)`typeof ${v} != "object"`,(0,r._)`${v} instanceof RegExp`,(0,r._)`typeof ${v}.compare != "function"`,y(v)))}function b(){let w=h.schema,v=p.formats[w];if(!v||v===!0)return;if(typeof v!="object"||v instanceof RegExp||typeof v.compare!="function")throw new Error(`"${m}": format "${w}" does not define "compare" function`);let S=c.scopeValue("formats",{key:w,ref:v,code:f.code.formats?(0,r._)`${f.code.formats}${(0,r.getProperty)(w)}`:void 0});a.fail$data(y(S))}function y(w){return(0,r._)`${w}.compare(${l}, ${u}) ${n[m].fail} 0`}},dependencies:["format"]};let s=a=>(a.addKeyword(e.formatLimitDefinition),a);e.default=s})),UL=ue(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});let r=DL(),o=qL(),n=qe(),i=new n.Name("fullFormats"),s=new n.Name("fastFormats"),a=(l,u={keywords:!0})=>{if(Array.isArray(u))return c(l,u,r.fullFormats,i),l;let[m,d]=u.mode==="fast"?[r.fastFormats,s]:[r.fullFormats,i];return c(l,u.formats||r.formatNames,m,d),u.keywords&&(0,o.default)(l),l};a.get=(l,u="full")=>{let m=(u==="fast"?r.fastFormats:r.fullFormats)[l];if(!m)throw new Error(`Unknown format "${l}"`);return m};function c(l,u,m,d){var f,p;(f=(p=l.opts.code).formats)!==null&&f!==void 0||(p.formats=(0,n._)`require("ajv-formats/dist/formats").${d}`);for(let h of u)l.addFormat(h,m[h])}t.exports=e=a,Object.defineProperty(e,"__esModule",{value:!0}),e.default=a})),dE=sE(),LL=zL(),FL=ML(),VL=Td(UL(),1),ZL=VL.default;function aS(e){let t=new e({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return ZL(t),t}var Bg=class{_ajv;_ajvDraft7;_ajv2019;_userAjv;constructor(e){this._userAjv=e!==void 0,this._ajv=e}get ajv(){return this._ajv??=aS(FL.Ajv2020)}_engineFor(e){if(this._userAjv)return this.ajv;let t=H1(e,"pass a pre-configured Ajv instance to AjvJsonSchemaValidator(ajv) to validate other dialects.");return t==="2020-12"?this.ajv:t==="2019-09"?this._ajv2019??=aS(LL.Ajv2019):this._ajvDraft7??=aS(dE.Ajv)}getValidator(e){let t=this._engineFor(e),r="$id"in e&&typeof e.$id=="string"?t.getSchema(e.$id)??t.compile(e):t.compile(e);return o=>r(o)?{valid:!0,data:o,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:t.errorsText(r.errors)}}},cK=dE.Ajv;import fS from"node:process";var $E=Symbol.for("mcp.completable");function hS(e){return!!e&&typeof e=="object"&&$E in e}function BL(e){return e[$E]?.complete}var dc=15e3,WL=2**31-1;function tm(e,t){if(!Number.isFinite(e)||e<1)return;let r=setInterval(t,Math.min(e,WL));return r.unref?.(),r}var xE,gS=class{static{xE=e=>e._classification}onclose;onerror;onmessage;_classification;_responseMode;_started=!1;_used=!1;_closed=!1;_terminalDelivered=!1;_dispatchWindowOpen=!1;_requestId;_deferredResponse;_sse;_abortCleanup;_keepAliveMs;constructor(e){this._classification=e.classification,this._responseMode=e.responseMode??"auto",this._keepAliveMs=e.keepAliveMs??dc}async start(){if(this._started)throw new Error("PerRequestHTTPServerTransport is already started");this._started=!0}async handleMessage(e,t){if(this._used)throw new Error("PerRequestHTTPServerTransport serves exactly one exchange; construct a new transport per request");if(!this._started||this.onmessage===void 0)throw new Error("PerRequestHTTPServerTransport is not connected: connect a server to this transport before handling a message");if(this._closed)throw new Error("PerRequestHTTPServerTransport is closed");this._used=!0;let r=t?.request?.signal;if(r?.aborted)throw await this.close(),new Oe(Ue.ConnectionClosed,"The request was aborted before it could be handled");let o={classification:this._classification,...t?.request!==void 0&&{request:t.request},...t?.authInfo!==void 0&&{authInfo:t.authInfo}};if(kt(e)){this._requestId=e.id;let n,i,s=new Promise((a,c)=>{n=a,i=c});if(this._deferredResponse={promise:s,resolve:n,reject:i,settled:!1},r!==void 0){let a=()=>{this.close()};r.addEventListener("abort",a,{once:!0}),this._abortCleanup=()=>r.removeEventListener("abort",a)}this._dispatchWindowOpen=!0;try{this.onmessage(e,o)}finally{this._dispatchWindowOpen=!1}return this._responseMode==="sse"&&!this._closed&&!this._deferredResponse.settled&&this.upgradeToSse(),s}return this.onmessage(e,o),new Response(null,{status:202})}async send(e,t){if(this._closed)return;let r=Qn(e)||er(e),o=r?e.id:t?.relatedRequestId;if(this._requestId===void 0||o===void 0||o!==this._requestId){r&&this.onerror?.(new Error(`Received a response for an unknown request id: ${String(e.id)}`));return}if(r){if(this._terminalDelivered)return;this._terminalDelivered=!0;let n=er(e)?e.error.code:void 0,i=n!==void 0&&(this._dispatchWindowOpen||n===ge.MissingRequiredClientCapability)?Y_[n]:void 0;if(i!==void 0&&this._sse===void 0){this.settleResponse(Response.json(e,{status:i,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>{this.close()});return}if(this._sse!==void 0||this._responseMode==="sse"){this._sse===void 0&&this.upgradeToSse(),this.writeMessageFrame(e),this.finalizeStream();return}this.settleResponse(Response.json(e,{status:200,headers:{"Content-Type":"application/json"}})),queueMicrotask(()=>{this.close()});return}this._responseMode!=="json"&&(this._sse===void 0&&this.upgradeToSse(),this.writeMessageFrame(e))}writeCommentFrame(e){if(this._closed||this._sse===void 0||this._sse.closed)return;let t=e.split(`
74
+ `).map(r=>`: ${r}`).join(`
75
+ `);this.writeFrame(`${t}
76
+
77
+ `)}async close(){if(!this._closed){if(this._closed=!0,this._abortCleanup?.(),this._abortCleanup=void 0,this._sse?.keepAliveTimer!==void 0&&clearInterval(this._sse.keepAliveTimer),this._sse!==void 0&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}this._deferredResponse!==void 0&&!this._deferredResponse.settled&&(this._deferredResponse.settled=!0,this._deferredResponse.reject(new Oe(Ue.ConnectionClosed,"Connection closed before a response was produced"))),this.onclose?.()}}settleResponse(e){this._deferredResponse===void 0||this._deferredResponse.settled||(this._deferredResponse.settled=!0,this._deferredResponse.resolve(e))}upgradeToSse(){let e,t=new ReadableStream({start:r=>{e=r},cancel:()=>{this.close()}});this._sse={controller:e,encoder:new TextEncoder,closed:!1},this._sse.keepAliveTimer=tm(this._keepAliveMs,()=>this.writeCommentFrame("keepalive")),this.settleResponse(new Response(t,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}}))}finalizeStream(){if(this._sse?.keepAliveTimer!==void 0&&clearInterval(this._sse.keepAliveTimer),this._sse!==void 0&&!this._sse.closed){this._sse.closed=!0;try{this._sse.controller.close()}catch{}}queueMicrotask(()=>{this.close()})}writeMessageFrame(e){this.writeFrame(`event: message
78
+ data: ${JSON.stringify(e)}
79
+
80
+ `)}writeFrame(e){if(!(this._sse===void 0||this._sse.closed))try{this._sse.controller.enqueue(this._sse.encoder.encode(e))}catch(t){this.onerror?.(new Error(`Failed to write to the response stream: ${t}`))}}};function JL(e){return e instanceof gS?xE(e):void 0}function Wg(e){return e.replaceAll(/[\\"]/g,String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g," ")}function fE(e,t,r,o){let n=`Bearer error="${Wg(e)}", error_description="${Wg(t)}"`;return r.length>0&&(n+=`, scope="${Wg(r.join(" "))}"`),o&&(n+=`, resource_metadata="${Wg(o)}"`),n}function _E(e,t){let{requiredScopes:r=[],resourceMetadataUrl:o}=t??{};if(!(e instanceof Ju)){let n=new Ju(fs.ServerError,"Internal Server Error");return Response.json(n.toResponseObject(),{status:500})}switch(e.code){case fs.InvalidToken:{let n=fE(e.code,e.message,r,o);return Response.json(e.toResponseObject(),{status:401,headers:{"WWW-Authenticate":n}})}case fs.InsufficientScope:{let n=fE(e.code,e.message,r,o);return Response.json(e.toResponseObject(),{status:403,headers:{"WWW-Authenticate":n}})}case fs.ServerError:return Response.json(e.toResponseObject(),{status:500});default:return Response.json(e.toResponseObject(),{status:400})}}function SE(e){let t=new URL(e);return t.pathname=GL(e),t.hash="",t.href}function GL(e){let t=KL(e.pathname);return`/.well-known/oauth-protected-resource${t==="/"?"":t}`}function KL(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function YL(e){return typeof e=="object"&&e!==null&&"setScopeChallengeResolver"in e&&typeof e.setScopeChallengeResolver=="function"}function XL(e,t){if(typeof e!="string"||!/^[\u0021\u0023-\u005B\u005D-\u007E]+$/.test(e))throw new TypeError(`${t} must satisfy the OAuth scope-token grammar`)}function QL(e){if(e===null||typeof e!="object"||!Array.isArray(e.scopes)||e.scopes.length===0)throw new TypeError("scope challenge must contain at least one scope");for(let[t,r]of e.scopes.entries())XL(r,`scope challenge scopes[${t}]`);if(e.errorDescription!==void 0&&typeof e.errorDescription!="string")throw new TypeError("scope challenge errorDescription must be a string");if(e.errorDescription!==void 0&&!/^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/.test(e.errorDescription))throw new TypeError("scope challenge errorDescription must satisfy the RFC 6750 error-description grammar");return e}async function yS(e,t,r){for(let o of e){let n=await r({request:o,...t!==void 0&&{authInfo:t}});if(n!==void 0)return QL(n)}}function bS(e){if(e?.resourceMetadataUrl!==void 0)return e.resourceMetadataUrl;if(e?.resource?.protocol==="https:"||e?.resource?.protocol==="http:")return SE(e.resource)}function wS(e,t){return _E(new Ju(fs.InsufficientScope,e.errorDescription??"Insufficient scope"),{requiredScopes:[...e.scopes],resourceMetadataUrl:t})}var e3=8,t3=6e5;function n3(e){if(e?.maxRounds!==void 0&&(!Number.isInteger(e.maxRounds)||e.maxRounds<1))throw new RangeError(`inputRequired.maxRounds must be a positive integer (got ${e.maxRounds})`);if(e?.roundTimeoutMs!==void 0&&(!Number.isFinite(e.roundTimeoutMs)||e.roundTimeoutMs<=0))throw new RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${e.roundTimeoutMs})`);return{maxRounds:e?.maxRounds??e3,roundTimeoutMs:e?.roundTimeoutMs??t3,legacyShim:e?.legacyShim??!0}}function kE(e,t,r){if(r===null||typeof r!="object"||typeof r.method!="string")throw new ke(ge.InternalError,`Handler for ${e} returned an invalid input request '${t}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);let o=r,n=cj(o);if(n===void 0)throw new ke(ge.InternalError,`Handler for ${e} returned an input request '${t}' of kind '${o.method}', which is not an embedded request the 2026-07-28 revision defines`);return{embedded:o,required:n}}function r3(){let e=globalThis.crypto;if(e?.randomUUID!==void 0)return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let r=[...t].map(o=>o.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}function pS(e,t){if(e==="tools/call")return{content:[{type:"text",text:t}],isError:!0};throw new ke(ge.InternalError,t)}var o3=class{constructor(e){this._host=e}async fulfill(e,t,r,o,n){let{maxRounds:i,roundTimeoutMs:s}=this._host,a=o.mcpReq.signal,c=n,l=0;for(;;){if(l+=1,l>i)return pS(e,Nj(e,i));let u=c.inputRequests,m=u!=null&&Object.keys(u).length>0,d=typeof c.requestState=="string"?c.requestState:void 0;if(!m&&d===void 0)throw new ke(ge.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);let f;if(m){let g=this._host.resolvedClientCapabilities(o),b=[];for(let[w,v]of Object.entries(u)){let{embedded:S,required:_}=kE(e,w,v);if(S.method!=="roots/list"&&S.params===void 0)throw new ke(ge.InternalError,`Handler for ${e} returned an input request '${w}' of kind '${S.method}' without params`);if(Gu(_,g)!==void 0)return pS(e,`Cannot request input '${w}' (${S.method}): the client on this 2025-era connection did not declare the required capability${g===void 0?" (no client capabilities are available on this connection \u2014 per-request legacy serving cannot receive server-to-client requests)":""}`);b.push([w,S])}let y=Dj(a);try{let w={relatedRequestId:o.mcpReq.id,timeout:s,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:y.signal},v=await Promise.all(b.map(async([S,_])=>{try{return[S,await this._dispatchLeg(_,w)]}catch($){throw y.abort($),$}}));f=Object.fromEntries(v)}catch(w){if(a.aborted)throw w;return pS(e,`Fulfilling input required by '${e}' failed: ${w instanceof Error?w.message:String(w)}`)}finally{y.dispose()}}else await Mj(Oj,a);let p={...o,mcpReq:{...o.mcpReq,inputResponses:f,droppedInputResponseKeys:void 0,requestState:Xu(d)}};if(d!==void 0){let g=await this._host.verifyRequestState(d,p,e);g!==void 0&&(p=Q_(p,g))}let h=await t(r,p);if(!mo(h))return h;c=h}}async _dispatchLeg(e,t){switch(e.method){case"elicitation/create":{let r=e.params;return r.mode==="url"&&r.elicitationId===void 0&&(r={...r,elicitationId:r3()}),await this._host.sendElicitation(r,t)}case"sampling/createMessage":return await this._host.sendSampling(e.params,t);case"roots/list":return await this._host.listRoots(e.params,t)}}},i3=new Set(["tools/call","prompts/get","resources/read"]),zE,RE,IE;function PE(e,t){zE(e,t)}function Jg(e,t){RE(e,t)}function Gg(e){return IE(e)}var jE=class extends eS{_clientCapabilities;_clientVersion;static{zE=(e,t)=>{t.clientCapabilities!==void 0&&(e._clientCapabilities=t.clientCapabilities),t.clientInfo!==void 0&&(e._clientVersion=t.clientInfo)},RE=(e,t)=>{let r=t.filter(o=>!e._supportedProtocolVersions.includes(o));r.length>0&&(e._supportedProtocolVersions=[...e._supportedProtocolVersions,...r]),e.setRequestHandler("server/discover",()=>e._ondiscover())},IE=e=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_boundFromTransport=!1;_legacyInputRequiredShim(){return this._legacyShim??=new o3({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:e=>this._inputRequestCapabilityView(e),verifyRequestState:(e,t,r)=>this._verifyRequestState(e,t,r),sendElicitation:(e,t)=>this._sendElicitationLeg(e,t,{validateAcceptedContent:!1}),sendSampling:(e,t)=>this.createMessage(e,t),listRoots:(e,t)=>this.listRoots(e,t)})}oninitialized;constructor(e,t){if(super(t),this._serverInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new Bg,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=n3(t?.inputRequired),t?.cacheHints!==void 0){for(let[r,o]of Object.entries(t.cacheHints))o!==void 0&&H_(o,`cacheHints['${r}']`);this._cacheHints=t.cacheHints}this.setRequestHandler("initialize",r=>this._oninitialize(r)),this.setNotificationHandler("notifications/initialized",()=>this.oninitialized?.()),Eg(this._supportedProtocolVersions).length>0&&this.setRequestHandler("server/discover",()=>this._ondiscover()),this._capabilities.logging&&this._registerLoggingHandler()}async connect(e){if(this.transport!==void 0)throw new Oe(Ue.AlreadyConnected,"Use a separate Server instance per connection: this instance is already connected to a transport. To connect it to a new transport, call close() first.");this._boundFromTransport&&(this._boundFromTransport=!1,this._negotiatedProtocolVersion=void 0);let t=JL(e)?.revision;t!==void 0&&!this._servedModernEra()&&zn.includes(t)&&Eg(this._supportedProtocolVersions).includes(t)&&(this._negotiatedProtocolVersion=t,this._boundFromTransport=!0),await super.connect(e)}_registerLoggingHandler(){this.setRequestHandler("logging/setLevel",async(e,t)=>{let r=t.sessionId||t.http?.req?.headers.get("mcp-session-id")||void 0,{level:o}=e.params,n=Mg(si,o);return n.success&&this._loggingLevels.set(r,n.data),{}})}buildContext(e,t){let r=e.http||t?.request||t?.closeSSEStream||t?.closeStandaloneSSEStream;return{...e,mcpReq:{...e.mcpReq,log:(o,n,i)=>{if(!this._capabilities.logging)return Promise.resolve();let s;if(this._servedModernEra()){if(s=e.mcpReq.envelope?.[ei],s===void 0)return Promise.resolve()}else s=this._loggingLevels.get(e.sessionId)??this._loggingLevels.get(void 0);return s!==void 0&&this.LOG_LEVEL_SEVERITY.get(o)<this.LOG_LEVEL_SEVERITY.get(s)?Promise.resolve():e.mcpReq.notify({method:"notifications/message",params:{level:o,data:n,logger:i}})},elicitInput:(o,n)=>this.elicitInput(o,n),requestSampling:(o,n)=>this.createMessage(o,n)},http:r?{...e.http,req:t?.request,closeSSE:t?.closeSSEStream,closeStandaloneSSE:t?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(si.options.map((e,t)=>[e,t]));isMessageIgnored=(e,t)=>{let r=this._loggingLevels.get(t);return r?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(r):!1};registerCapabilities(e){if(this.transport)throw new Oe(Ue.AlreadyConnected,"Cannot register capabilities after connecting to transport");let t=!!this._capabilities.logging;this._capabilities=tS(this._capabilities,e),!t&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(e,t){if(e!=="tools/call"){let r=this._cacheHints?.[e],o=i3.has(e);return r===void 0&&!o?async(n,i)=>{let s=await t(n,i);if(mo(s))throw new ke(ge.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return s}:async(n,i)=>{let s=o?await this._invokeInputRequiredCapableHandler(e,t,n,i):await t(n,i);if(mo(s)){if(!o)throw new ke(ge.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return s}return r===void 0?s:Tg(s,r)}}return async(r,o)=>{let n=lo(this._negotiatedProtocolVersion),i=n.validateRequest("tools/call",r);if(!i.ok)throw new ke(i.reason==="not-in-era"?ge.InternalError:ge.InvalidParams,i.reason==="not-in-era"?"No wire schema for tools/call in the resolved era":`Invalid tools/call request: ${i.message}`);let s=await this._invokeInputRequiredCapableHandler("tools/call",t,r,o);if(mo(s))return s;let a=U_(s),c=n.validateResult("tools/call",a);if(!c.ok)throw new ke(c.reason==="not-in-era"?ge.InternalError:ge.InvalidParams,c.reason==="not-in-era"?"No wire schema for tools/call in the resolved era":`Invalid tools/call result: ${c.message}`);return c.value}}_servedModernEra(){return this._negotiatedProtocolVersion!==void 0&&uo(this._negotiatedProtocolVersion)}async _invokeInputRequiredCapableHandler(e,t,r,o){let n=this._servedModernEra(),i=o.mcpReq.requestState();if(i!==void 0&&typeof i!="string")throw new ke(ge.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"});let s=o;if(typeof i=="string"){let m=await this._verifyRequestState(i,o,e);m!==void 0&&(s=Q_(o,m))}let a;try{a=await t(r,s)}catch(m){throw m instanceof ke&&m.code===ge.UrlElicitationRequired&&n?new ke(ge.InternalError,`URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { \u2026: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`):m}if(!mo(a))return a;if(!n){if(!this._inputRequiredServing.legacyShim)throw new ke(ge.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??ss}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(e,t,r,s,a)}let c=a.inputRequests,l=c!=null&&Object.keys(c).length>0,u=typeof a.requestState=="string";if(!l&&!u)throw new ke(ge.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(l){let m=this._inputRequestCapabilityView(o);for(let[d,f]of Object.entries(c)){let{embedded:p,required:h}=kE(e,d,f),g=Gu(h,m);if(g!==void 0)throw new Ku({requiredCapabilities:g},`Cannot request input '${d}' (${p.method}): the request's client capabilities do not declare the required capability`)}}return a}async _verifyRequestState(e,t,r){if(this._requestStateVerify!==void 0)try{return await this._requestStateVerify(e,t)}catch(o){throw this.onerror?.(new Error(`requestState verification rejected ${r}: ${o instanceof Error?o.message:String(o)}`)),new ke(ge.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[Nr]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new Oe(Ue.MethodNotSupportedByProtocolVersion,`Server-to-client requests are not available on protocol revision ${this._negotiatedProtocolVersion}: '${e}' cannot be sent while serving a request on that revision. Return inputRequired({ ... }) from the handler instead \u2014 the client fulfils the embedded requests and retries the original request (multi round-trip requests).`,{method:e,era:"2026-07-28"})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Oe(Ue.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Oe(Ue.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Oe(Ue.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Oe(Ue.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Oe(Ue.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Oe(Ue.CapabilityNotSupported,`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Oe(Ue.CapabilityNotSupported,`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Oe(Ue.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Oe(Ue.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Oe(Ue.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Oe(Ue.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Oe(Ue.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Oe(Ue.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case"ping":case"initialize":break}}async _oninitialize(e){let t=e.params.protocolVersion;this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo;let r=uj(this._supportedProtocolVersions),o=r.includes(t)?t:r[0]??ss;return this._negotiatedProtocolVersion=o,this.transport?.setProtocolVersion?.(o),{protocolVersion:o,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:Eg(this._supportedProtocolVersions),capabilities:s3(this.getCapabilities()),...this._instructions&&{instructions:this._instructions}}}_outboundServerInfo(){return this._serverInfo}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}projectCallToolResult(e,t){return this._wireCodec().projectCallToolResult(e,t)}getCapabilities(){return this._capabilities}async ping(){return this._assertPushApiInServedEra("ping"),this.request({method:"ping"})}async createMessage(e,t){if(this._assertPushApiInServedEra("sampling/createMessage"),(e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Oe(Ue.CapabilityNotSupported,"Client does not support sampling tools capability.");if(e.messages.length>0){let i=e.messages.at(-1),s=Array.isArray(i.content)?i.content:[i.content],a=s.some(m=>m.type==="tool_result"),c=e.messages.length>1?e.messages.at(-2):void 0,l=c?Array.isArray(c.content)?c.content:[c.content]:[],u=l.some(m=>m.type==="tool_use");if(a){if(s.some(m=>m.type!=="tool_result"))throw new ke(ge.InvalidParams,"The last message must contain only tool_result content if any is present");if(!u)throw new ke(ge.InvalidParams,"tool_result blocks are not matching any tool_use from the previous message")}if(u){let m=new Set(l.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(s.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(m.size!==d.size||![...m].every(f=>d.has(f)))throw new ke(ge.InvalidParams,"ids of tool_result blocks and tool_use blocks from previous message do not match")}}let r=!!(e.tools||e.toolChoice),o=await this.request({method:"sampling/createMessage",params:e},t),n=this._wireCodec().samplingResultVariant(r,o);if(!n.ok)throw new Oe(Ue.InvalidResult,`Invalid sampling/createMessage result: ${n.reason==="invalid"?n.message:n.reason}`);return n.value}async elicitInput(e,t){switch(this._assertPushApiInServedEra("elicitation/create"),e.mode??"form"){case"url":if(!this._clientCapabilities?.elicitation?.url)throw new Oe(Ue.CapabilityNotSupported,"Client does not support url elicitation.");break;case"form":if(!this._clientCapabilities?.elicitation?.form)throw new Oe(Ue.CapabilityNotSupported,"Client does not support form elicitation.");break}return this._sendElicitationLeg(e,t)}async _sendElicitationLeg(e,t,r){let o=e.mode??"form",n=r?.validateAcceptedContent??!0;switch(o){case"url":{let i=e;return this.request({method:"elicitation/create",params:i},t)}case"form":{let i=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:i},t);if(n&&s.action==="accept"&&s.content&&i.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(i.requestedSchema)(s.content);if(!a.valid)throw new ke(ge.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(a){throw a instanceof ke?a:new ke(ge.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return s}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new Oe(Ue.CapabilityNotSupported,"Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this._assertPushApiInServedEra("roots/list"),this.request({method:"roots/list",params:e},t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};function s3(e){return{...e}}function a3(e,t){let r=0,o=[e];for(;o.length>0;){let n=o.pop();if(!(n===null||typeof n!="object"))if(Array.isArray(n))for(let i of n){if(++r>t)return r;i!==null&&typeof i=="object"&&o.push(i)}else for(let i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;if(++r>t)return r;let s=n[i];s!==null&&typeof s=="object"&&o.push(s)}}return r}function c3(e){if(!(e===void 0||e===1/0)){if(typeof e!="number"||Number.isNaN(e)||e<1)throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(e)}`);return e}}var li=class{server;_maxToolInputElements;_registeredResources={};_registeredResourceTemplates={};_registeredTools={};_registeredPrompts={};_toolInputSchemaJson={};toolInputSchemaJson(e){let t=this._registeredTools[e];if(!(t===void 0||!t.enabled)){if(Object.hasOwn(this._toolInputSchemaJson,e))return this._toolInputSchemaJson[e];if(t.inputSchema===void 0)return hE;try{let r=gs(t.inputSchema,"input");return this._toolInputSchemaJson[e]=r,r}catch{return}}}constructor(e,t){this.server=new jE(e,t),this._maxToolInputElements=c3(t?.maxToolInputElements),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return YL(e)&&e.setScopeChallengeResolver(t=>this.resolveScopeChallenge(t)),await this.server.connect(e)}async close(){await this.server.close()}resolveScopeChallenge=e=>{switch(e.request.method){case"tools/call":{let t=e.request.params?.name;if(typeof t!="string")return;let r=this._registeredTools[t];return r===void 0||!r.enabled?void 0:r.scopeChallenge?.(e)}case"resources/read":{let t=e.request.params?.uri;if(typeof t!="string")return;let r;try{r=new URL(t)}catch{return}let o=this._registeredResources[r.toString()];if(o!==void 0)return o.enabled?o.scopeChallenge?.(e):void 0;for(let n of Object.values(this._registeredResourceTemplates))if(n.resourceTemplate.uriTemplate.match(r.toString()))return n.enabled?n.scopeChallenge?.(e):void 0;return}case"prompts/get":{let t=e.request.params?.name;if(typeof t!="string")return;let r=this._registeredPrompts[t];return r===void 0||!r.enabled?void 0:r.scopeChallenge?.(e)}default:return}};_toolHandlersInitialized=!1;setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler("tools/list"),this.server.assertCanSetRequestHandler("tools/call"),this.server.registerCapabilities({tools:{listChanged:this.server.getCapabilities().tools?.listChanged??!0}}),this.server.setRequestHandler("tools/list",()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{let r={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?l3(e,t.inputSchema):hE,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(r.outputSchema=gs(t.outputSchema,"output")),r})})),this.server.setRequestHandler("tools/call",async(e,t)=>{let r=this._registeredTools[e.params.name];if(!r)throw new ke(ge.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new ke(ge.InvalidParams,`Tool ${e.params.name} disabled`);try{let o=await this.validateToolInput(r,e.params.arguments,e.params.name),n=await this.executeToolHandler(r,o,t);return await this.validateToolOutput(r,n,e.params.name),mo(n)?n:this.server.projectCallToolResult(n,r.outputSchemaJson)}catch(o){if(o instanceof ke&&o.code===ge.UrlElicitationRequired)throw o;return this.createToolError(o instanceof Error?o.message:String(o))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,t,r){if(this._maxToolInputElements!==void 0&&a3(t,this._maxToolInputElements)>this._maxToolInputElements)throw new ke(ge.InvalidParams,`Invalid arguments for tool ${r}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!e.inputSchema)return;let o=await ms(e.inputSchema,t??{});if(!o.success)throw new ke(ge.InvalidParams,`Input validation error: Invalid arguments for tool ${r}: ${o.error}`);return o.data}async validateToolOutput(e,t,r){if(!e.outputSchema||mo(t)||t.isError)return;if(t.structuredContent===void 0)throw new ke(ge.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);let o=await ms(e.outputSchema,t.structuredContent);if(!o.success)throw new ke(ge.InvalidParams,`Output validation error: Invalid structured content for tool ${r}: ${o.error}`)}async executeToolHandler(e,t,r){return e.executor(t,r)}_completionHandlerInitialized=!1;setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler("completion/complete"),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler("completion/complete",async e=>{switch(e.params.ref.type){case"ref/prompt":return G_(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return K_(e),this.handleResourceCompletion(e,e.params.ref);default:throw new ke(ge.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){let r=this._registeredPrompts[t.name];if(!r)throw new ke(ge.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new ke(ge.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return em;let o=vE(wE(r.argsSchema)?.[e.params.argument.name]);if(!hS(o))return em;let n=BL(o);return n?bE(await n(e.params.argument.value,e.params.context)):em}async handleResourceCompletion(e,t){let r=Object.values(this._registeredResourceTemplates).find(n=>n.resourceTemplate.uriTemplate.toString()===t.uri);if(!r){if(this._registeredResources[t.uri])return em;throw new ke(ge.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=r.resourceTemplate.completeCallback(e.params.argument.name);return o?bE(await o(e.params.argument.value,e.params.context)):em}_resourceHandlersInitialized=!1;setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler("resources/list"),this.server.assertCanSetRequestHandler("resources/templates/list"),this.server.assertCanSetRequestHandler("resources/read"),this.server.registerCapabilities({resources:{listChanged:this.server.getCapabilities().resources?.listChanged??!0}}),this.server.setRequestHandler("resources/list",async(e,t)=>{let r=Object.entries(this._registeredResources).filter(([n,i])=>i.enabled).map(([n,i])=>({uri:n,name:i.name,...i.metadata})),o=[];for(let n of Object.values(this._registeredResourceTemplates)){if(!n.resourceTemplate.listCallback)continue;let i=await n.resourceTemplate.listCallback(t);for(let s of i.resources)o.push({...n.metadata,...s})}return{resources:[...r,...o]}}),this.server.setRequestHandler("resources/templates/list",async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler("resources/read",async(e,t)=>{let r;try{r=new URL(e.params.uri)}catch{throw new ke(ge.InvalidParams,`Resource URI ${e.params.uri} is invalid`,{uri:e.params.uri,reason:"invalid_uri"})}let o=this._registeredResources[r.toString()];if(o){if(!o.enabled)throw new ke(ge.InvalidParams,`Resource ${r} disabled`);return Tg(await o.readCallback(r,t),o.cacheHint)}for(let n of Object.values(this._registeredResourceTemplates)){let i=n.resourceTemplate.uriTemplate.match(r.toString());if(i){if(!n.enabled)throw new ke(ge.InvalidParams,`Resource template ${n.resourceTemplate.uriTemplate} disabled`);return Tg(await n.readCallback(r,i,t),n.cacheHint)}}throw new Cg(e.params.uri)}),this._resourceHandlersInitialized=!0)}_promptHandlersInitialized=!1;setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler("prompts/list"),this.server.assertCanSetRequestHandler("prompts/get"),this.server.registerCapabilities({prompts:{listChanged:this.server.getCapabilities().prompts?.listChanged??!0}}),this.server.setRequestHandler("prompts/list",()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?Aj(t.argsSchema):void 0,icons:t.icons,_meta:t._meta}))})),this.server.setRequestHandler("prompts/get",async(e,t)=>{let r=this._registeredPrompts[e.params.name];if(!r)throw new ke(ge.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new ke(ge.InvalidParams,`Prompt ${e.params.name} disabled`);return r.handler(e.params.arguments,t)}),this._promptHandlersInitialized=!0)}registerResource(e,t,r,o){let{cacheHint:n,scopeChallenge:i,...s}=r,a=s;if(n!==void 0&&H_(n,`resource ${e}`),typeof t=="string"){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);let c=this._createRegisteredResource(e,r.title,t,a,i,o);return n!==void 0&&(c.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),c}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let c=this._createRegisteredResourceTemplate(e,r.title,t,a,i,o);return n!==void 0&&(c.cacheHint=n),this.setResourceRequestHandlers(),this.sendResourceListChanged(),c}}_createRegisteredResource(e,t,r,o,n,i){let s={name:e,title:t,metadata:o,readCallback:i,scopeChallenge:n,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:a=>{a.uri!==void 0&&a.uri!==r&&(delete this._registeredResources[r],a.uri&&(this._registeredResources[a.uri]=s)),a.name!==void 0&&(s.name=a.name),a.metadata!==void 0&&(s.metadata=a.metadata),a.title!==void 0&&(s.title=a.title,s.metadata={...s.metadata,title:a.title}),a.callback!==void 0&&(s.readCallback=a.callback),a.scopeChallenge!==void 0&&(s.scopeChallenge=a.scopeChallenge===null?void 0:a.scopeChallenge),a.enabled!==void 0&&(s.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[r]=s,s}_createRegisteredResourceTemplate(e,t,r,o,n,i){let s={resourceTemplate:r,title:t,metadata:o,readCallback:i,scopeChallenge:n,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:c=>{c.name!==void 0&&c.name!==e&&(delete this._registeredResourceTemplates[e],c.name&&(this._registeredResourceTemplates[c.name]=s)),c.template!==void 0&&(s.resourceTemplate=c.template),c.metadata!==void 0&&(s.metadata=c.metadata),c.title!==void 0&&(s.title=c.title,s.metadata={...s.metadata,title:c.title}),c.callback!==void 0&&(s.readCallback=c.callback),c.scopeChallenge!==void 0&&(s.scopeChallenge=c.scopeChallenge===null?void 0:c.scopeChallenge),c.enabled!==void 0&&(s.enabled=c.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=s;let a=r.uriTemplate.variableNames;return Array.isArray(a)&&a.some(c=>!!r.completeCallback(c))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(e,t,r,o,n,i,s,a){let c=o,l=n,u={title:t,description:r,argsSchema:o,icons:i,scopeChallenge:s,_meta:a,handler:yE(e,o,n),enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:m=>{m.name!==void 0&&m.name!==e&&(delete this._registeredPrompts[e],m.name&&(this._registeredPrompts[m.name]=u)),m.title!==void 0&&(u.title=m.title),m.description!==void 0&&(u.description=m.description),m.icons!==void 0&&(u.icons=m.icons),m.scopeChallenge!==void 0&&(u.scopeChallenge=m.scopeChallenge===null?void 0:m.scopeChallenge),m._meta!==void 0&&(u._meta=m._meta);let d=!1;m.argsSchema!==void 0&&(u.argsSchema=m.argsSchema,c=m.argsSchema,d=!0),m.callback!==void 0&&(l=m.callback,d=!0),d&&(u.handler=yE(e,c,l)),m.enabled!==void 0&&(u.enabled=m.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=u,o){let m=wE(o);m&&Object.values(m).some(d=>hS(vE(d)))&&this.setCompletionRequestHandler()}return u}_createRegisteredTool(e,t,r,o,n,i,s,a,c,l,u){sS(e);let m=u,d,f={title:t,description:r,inputSchema:o,outputSchema:n,get outputSchemaJson(){return d??=gE(f.outputSchema)},set outputSchemaJson(p){d=p},annotations:i,icons:s,execution:a,scopeChallenge:c,_meta:l,handler:u,executor:pE(o,u),enabled:!0,disable:()=>f.update({enabled:!1}),enable:()=>f.update({enabled:!0}),remove:()=>f.update({name:null}),update:p=>{p.name!==void 0&&p.name!==e&&(typeof p.name=="string"&&sS(p.name),delete this._registeredTools[e],delete this._toolInputSchemaJson[e],p.name&&(delete this._toolInputSchemaJson[p.name],this._registeredTools[p.name]=f,e=p.name)),p.title!==void 0&&(f.title=p.title),p.description!==void 0&&(f.description=p.description);let h=!1;p.paramsSchema!==void 0&&(f.inputSchema=p.paramsSchema,delete this._toolInputSchemaJson[e],h=!0),p.callback!==void 0&&(f.handler=p.callback,m=p.callback,h=!0),h&&(f.executor=pE(f.inputSchema,m)),p.outputSchema!==void 0&&(f.outputSchema=p.outputSchema,f.outputSchemaJson=gE(p.outputSchema)),p.annotations!==void 0&&(f.annotations=p.annotations),p.icons!==void 0&&(f.icons=p.icons),p.scopeChallenge!==void 0&&(f.scopeChallenge=p.scopeChallenge===null?void 0:p.scopeChallenge),p._meta!==void 0&&(f._meta=p._meta),p.enabled!==void 0&&(f.enabled=p.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=f,this.setToolRequestHandlers(),this.sendToolListChanged(),f}registerTool(e,t,r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:o,description:n,inputSchema:i,outputSchema:s,annotations:a,icons:c,scopeChallenge:l,_meta:u}=t;return this._createRegisteredTool(e,o,n,qg(i),qg(s),a,c,void 0,l,u,r)}registerPrompt(e,t,r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:o,description:n,argsSchema:i,icons:s,scopeChallenge:a,_meta:c}=t,l=this._createRegisteredPrompt(e,o,n,qg(i),r,s,a,c);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),l}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};function pE(e,t){if(e){let o=t;return async(n,i)=>o(n,i)}let r=t;return async(o,n)=>r(n)}var hE={type:"object",properties:{}};function l3(e,t){let r=gs(t,"input"),o=Ag(r);return o.valid||console.warn(`[mcp-sdk] tool '${e}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${o.reason}`),r}function gE(e){if(e!==void 0)try{return gs(e,"output")}catch{return}}function yE(e,t,r){if(t){let o=r;return async(n,i)=>{let s=await ms(t,n??{});if(!s.success)throw new ke(ge.InvalidParams,`Invalid arguments for prompt ${e}: ${s.error}`);return o(s.data,i)}}else{let o=r;return async(n,i)=>o(i)}}function bE(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}var em={completion:{values:[],hasMore:!1}};function wE(e){let t=e;if(t.shape&&typeof t.shape=="object")return t.shape}function u3(e){return e?.type==="optional"}function vE(e){return u3(e)?e.def?.innerType??e:e}var TE=class{_listeners=new Set;constructor(e){this.onerror=e}publish(e){for(let t of this._listeners)try{t(e)}catch(r){this.onerror?.(r instanceof Error?r:new Error(String(r)))}}subscribe(e){this._listeners.add(e);let t=!0;return()=>{t&&(t=!1,this._listeners.delete(e))}}get listenerCount(){return this._listeners.size}};function CE(e){return{toolsChanged:()=>e.publish({kind:"tools_list_changed"}),promptsChanged:()=>e.publish({kind:"prompts_list_changed"}),resourcesChanged:()=>e.publish({kind:"resources_list_changed"}),resourceUpdated:t=>e.publish({kind:"resource_updated",uri:t})}}function AE(e,t){switch(t.kind){case"tools_list_changed":return e.toolsListChanged===!0;case"prompts_list_changed":return e.promptsListChanged===!0;case"resources_list_changed":return e.resourcesListChanged===!0;case"resource_updated":return e.resourceSubscriptions!==void 0&&e.resourceSubscriptions.includes(t.uri)}}function OE(e,t){let r={},o=n=>t===void 0||n===!0;return e.toolsListChanged===!0&&o(t?.tools?.listChanged)&&(r.toolsListChanged=!0),e.promptsListChanged===!0&&o(t?.prompts?.listChanged)&&(r.promptsListChanged=!0),e.resourcesListChanged===!0&&o(t?.resources?.listChanged)&&(r.resourcesListChanged=!0),e.resourceSubscriptions!==void 0&&e.resourceSubscriptions.length>0&&o(t?.resources?.subscribe)&&(r.resourceSubscriptions=[...e.resourceSubscriptions]),r}function m3(e){switch(e.kind){case"tools_list_changed":return{method:"notifications/tools/list_changed",...e.params!==void 0&&{params:e.params}};case"prompts_list_changed":return{method:"notifications/prompts/list_changed",...e.params!==void 0&&{params:e.params}};case"resources_list_changed":return{method:"notifications/resources/list_changed",...e.params!==void 0&&{params:e.params}};case"resource_updated":return{method:"notifications/resources/updated",params:{...e.params,uri:e.uri}}}}var fc=1024;function EE(e,t,r){return Response.json({jsonrpc:"2.0",error:{code:t,message:r},id:e},{status:200})}function Kg(e,t){return{method:e.method,params:{...e.params,_meta:{...e.params?._meta,[Qo]:t}}}}function NE(e){let t=lo(Yu).validateRequest("subscriptions/listen",e);return t.ok?t.value.params?.notifications:void 0}function ME(e){let{bus:t,onerror:r}=e,o=e.maxSubscriptions??fc,n=e.keepAliveMs??dc,i=new Set;function s(a,c,l,u){if(i.size>=o)return r?.(new Error(`subscriptions/listen refused: subscription limit reached (${o})`)),EE(a.id,-32603,"Subscription limit reached");let m=NE(a);if(m===void 0)return EE(a.id,-32602,"Invalid params: 'notifications' is required and must be a valid SubscriptionFilter");let d=OE(m,l),f=a.id,p=new TextEncoder,h,g=!1,b,y,w,v=x=>{if(!g)try{h.enqueue(p.encode(x))}catch(k){r?.(k instanceof Error?k:new Error(String(k)))}},S=(x,k)=>{v(`event: message
81
+ data: ${JSON.stringify({jsonrpc:"2.0",method:x,params:k})}
82
+
83
+ `)},_=x=>{if(!g){x&&v(`event: message
84
+ data: ${JSON.stringify({jsonrpc:"2.0",id:f,result:{resultType:"complete",_meta:{[Qo]:f,[gr]:u}}})}
85
+
86
+ `),g=!0;try{b?.()}catch(k){r?.(k instanceof Error?k:new Error(String(k)))}y!==void 0&&clearInterval(y),w?.(),i.delete(_);try{h.close()}catch{}}},$=new ReadableStream({start(x){h=x;let k=Kg({method:"notifications/subscriptions/acknowledged",params:{notifications:d}},f);if(S(k.method,k.params),Object.keys(d).length===0){_(!0);return}b=t.subscribe(P=>{if(g||!AE(d,P))return;let I=Kg(m3(P),f);S(I.method,I.params)}),y=tm(n,()=>v(`: keepalive
87
+
88
+ `)),i.add(_)},cancel(){_(!1)}});if(c!==void 0)if(c.aborted)_(!1);else{let x=()=>_(!1);c.addEventListener("abort",x,{once:!0}),w=()=>c.removeEventListener("abort",x)}return new Response($,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}})}return{serve:s,closeAll(){for(let a of i)a(!0)},get openCount(){return i.size}}}var d3=new Set(["notifications/tools/list_changed","notifications/prompts/list_changed","notifications/resources/list_changed","notifications/resources/updated"]),DE=class{_subs=new Map;_serverCapabilities;_serverInfo;constructor(e=fc,t,r){this._maxSubscriptions=e,this._serverCapabilities=t,this._serverInfo=r}setServerCapabilities(e,t){this._serverCapabilities=e,t!==void 0&&(this._serverInfo=t)}has(e){return this._subs.has(e)}serve(e){if(this._serverCapabilities===void 0)throw new Error("StdioListenRouter.serve() called before setServerCapabilities(); refusing to honor a filter without capabilities");if(this._subs.size>=this._maxSubscriptions)return{jsonrpc:"2.0",id:e.id,error:{code:-32603,message:"Subscription limit reached"}};let t=NE(e);if(t===void 0)return{jsonrpc:"2.0",id:e.id,error:{code:-32602,message:"Invalid params: 'notifications' is required and must be a valid SubscriptionFilter"}};let r=OE(t,this._serverCapabilities);return this._subs.set(e.id,r),Kg({method:"notifications/subscriptions/acknowledged",params:{notifications:r}},e.id)}cancel(e){return this._subs.delete(e)}routeOutbound(e){if(!d3.has(e.method))return"passthrough";let t=e.params?.uri,r=typeof t=="string"?t:void 0,o=f3(e.method,r),n=[];for(let[i,s]of this._subs)AE(s,o)&&n.push(Kg({method:e.method,params:e.params??{}},i));return n}teardownAll(){let e=[];for(let t of this._subs.keys())e.push({jsonrpc:"2.0",id:t,result:{resultType:"complete",_meta:{[Qo]:t,...this._serverInfo!==void 0&&{[gr]:this._serverInfo}}}});return this._subs.clear(),e}};function f3(e,t){switch(e){case"notifications/tools/list_changed":return{kind:"tools_list_changed"};case"notifications/prompts/list_changed":return{kind:"prompts_list_changed"};case"notifications/resources/list_changed":return{kind:"resources_list_changed"};default:return{kind:"resource_updated",uri:t??""}}}var qE=Symbol("swallowsErrorsAfterClose"),p3=class{_readBuffer;_started=!1;_closed=!1;constructor(e=fS.stdin,t=fS.stdout,r){this._stdin=e,this._stdout=t,this._readBuffer=new oS({maxBufferSize:r?.maxBufferSize})}onclose;onerror;onmessage;_ondata=e=>{try{this._readBuffer.append(e),this.processReadBuffer()}catch(t){this.onerror?.(t),this.close().catch(()=>{})}};_onerror=e=>{this.onerror?.(e)};_onstdouterror=e=>{this._closed||(this.onerror?.(e),this.close().catch(()=>{}))};_onstdinclose=()=>{this.close().catch(()=>{})};async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0;for(let e of this._stdout.listeners("error"))e[qE]&&this._stdout.off("error",e);(this._stdin.readableEnded||this._stdin.destroyed)&&setImmediate(this._onstdinclose),this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror),this._stdin.on("end",this._onstdinclose),this._stdin.on("close",this._onstdinclose),this._stdout.on("error",this._onstdouterror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._closed||(this._closed=!0,this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.off("end",this._onstdinclose),this._stdin.off("close",this._onstdinclose),this._onstdouterror[qE]=!0,this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.())}send(e){return this._closed?Promise.reject(new Error("StdioServerTransport is closed")):new Promise((t,r)=>{let o=iS(e),n=!1,i=a=>{n||(n=!0,this._stdout.off("error",i),this._stdout.off("drain",s),r(a))},s=()=>{n||(n=!0,this._stdout.off("error",i),this._stdout.off("drain",s),t())};if(this._stdout.once("error",i),this._stdout.write(o)){if(n)return;n=!0,this._stdout.off("error",i),t()}else n||this._stdout.once("drain",s)})}},UE=3e3,h3=class{onclose;onerror;onmessage;_closed=!1;_pendingRequests=new Set;_drainWaiters=[];constructor(e,t,r){this._wire=e,this._onInstanceClose=t,this._outboundIntercept=r}async start(){}async send(e,t){if(Qn(e)||er(e)){let{id:r}=e;r!==void 0&&this._settle(r)}if(!this._closed&&this._outboundIntercept?.(e)!=="handled")return this._wire.send(e,t)}setProtocolVersion=e=>{this._wire.setProtocolVersion?.(e)};deliver(e,t){if(!this._closed){if(kt(e))this._pendingRequests.add(e.id);else if(Mr(e)&&e.method==="notifications/cancelled"){let r=e.params?.requestId;r!==void 0&&this._settle(r)}this.onmessage?.(e,t)}}async whenRequestsAnswered(e){return this._closed||this._pendingRequests.size===0?!0:await new Promise(t=>{let r=()=>{clearTimeout(o),t(!0)},o=setTimeout(()=>{this._drainWaiters=this._drainWaiters.filter(n=>n!==r),t(!1)},e);this._drainWaiters.push(r)})}async close(){if(!this._closed){this._closed=!0,this._pendingRequests.clear(),this._releaseDrainWaiters();try{this._onInstanceClose()}finally{this.onclose?.()}}}_settle(e){this._pendingRequests.delete(e),this._pendingRequests.size===0&&this._releaseDrainWaiters()}_releaseDrainWaiters(){let e=this._drainWaiters;this._drainWaiters=[];for(let t of e)t()}};function g3(e){let t=e.params;if(e.method==="initialize"&&!Og(t)){let i=t!==null&&typeof t=="object"&&typeof t.protocolVersion=="string"?t.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...i!==void 0&&{requestedVersion:i}}}if(!hs(t))return{kind:"legacy",reason:"no-claim"};let r=br(t),o=(r===void 0?[]:ds(r))[0];if(o!==void 0)return{kind:"invalid-envelope",issue:o};let n=lc(t);return n===void 0||!zn.includes(n)?{kind:"unsupported-revision",requested:n??"unknown"}:{kind:"modern",revision:n,classification:{era:"modern",revision:n}}}function LE(e,t={}){let r=t.legacy??"serve",o=t.transport??new p3,n={phase:"opening"},i,s=!1,a=()=>s||n.phase==="closed",c=x=>{try{t.onerror?.(x)}catch{}},l=(x,k,P,I)=>o.send({jsonrpc:"2.0",id:x,error:{code:k,message:P,...I!==void 0&&{data:I}}}).catch(E=>c($r(E))),u=new DE(t.maxSubscriptions??fc),m=x=>{if(!Mr(x))return;let k=u.routeOutbound(x);if(k!=="passthrough"){for(let P of k)o.send({jsonrpc:"2.0",...P}).catch(I=>c($r(I)));return"handled"}},d=async x=>{if(kt(x)&&x.method==="subscriptions/listen"){let k=br(x.params),P=hs(x.params)?(k===void 0?[]:ds(k))[0]:{key:"_meta",problem:"the per-request envelope is required on protocol revision 2026-07-28"},I=lc(x.params),E;if(P!==void 0)E={jsonrpc:"2.0",id:x.id,error:{code:-32602,message:`Invalid _meta envelope: ${P.key}: ${P.problem}`}};else if(I===void 0||!zn.includes(I)){let N=new ps({supported:[...zn],requested:I??"unknown"});E={jsonrpc:"2.0",id:x.id,error:{code:N.code,message:N.message,data:N.data}}}else E=u.serve(x);return await o.send("error"in E?E:{jsonrpc:"2.0",method:E.method,params:E.params}).catch(N=>c($r(N))),!0}if(Mr(x)&&x.method==="notifications/cancelled"){let k=x.params?.requestId;if(k!==void 0&&u.cancel(k))return!0}return!1},f=(x,k,P)=>{let I=Ng({kind:"legacy",reason:k,...P!==void 0&&{requestedVersion:P}},zn);return I===void 0?Promise.resolve():(c(new Error(`Rejected 2025-era request on a modern-only stdio connection (${I.cell}): ${I.message}`)),l(x.id,I.code,I.message,I.data))},p=x=>{s||x===i||_()},h=async(x,k)=>{let P=await e({era:x}),I=P instanceof li?P.server:P;x==="modern"&&(Dg(I,k),Jg(I,zn),u.setServerCapabilities(I.getCapabilities(),Gg(I)));let E=new h3(o,()=>p(E),x==="modern"?m:void 0);return await P.connect(E),{product:P,channel:E}},g=x=>x.product.close().catch(k=>c($r(k))),b=async x=>{i=x.channel;try{await x.channel.whenRequestsAnswered(UE)||c(new Error(`Discarded the probe instance with requests still unanswered after ${UE}ms; continuing with the fallback`)),await x.product.close()}catch(k){c($r(k))}finally{i=void 0}},y=async x=>{if(n.phase==="closed")return;if(n.phase==="pinned"){if(n.era==="modern"&&kt(x)&&x.method==="initialize"&&!Og(x.params)){await f(x,"initialize",x.params!==null&&typeof x.params=="object"&&typeof x.params.protocolVersion=="string"?x.params.protocolVersion:void 0);return}if(n.era==="modern"&&await d(x)||a())return;n.instance.channel.deliver(x);return}if(!kt(x)&&!Mr(x)){c(new Error("Discarded a JSON-RPC response received before the connection negotiated an era"));return}let k=g3(x);switch(k.kind){case"invalid-envelope":{let P=`Invalid _meta envelope for protocol revision 2026-07-28: ${k.issue.key}: ${k.issue.problem}`;kt(x)?await l(x.id,ge.InvalidParams,P,{envelope:k.issue}):c(new Error(`Discarded a notification with a malformed envelope: ${P}`));return}case"unsupported-revision":if(kt(x)){let P=new ps({supported:[...zn],requested:k.requested});c(P),await l(x.id,P.code,P.message,P.data)}else c(new Error(`Discarded a notification claiming unsupported protocol revision ${k.requested}`));return;case"modern":if(kt(x)&&x.method==="server/discover"){if(n.phase==="probe"){n.instance.channel.deliver(x,{classification:k.classification});return}let P=await h("modern",k.revision);if(a()){await g(P);return}n={phase:"probe",instance:P},P.channel.deliver(x,{classification:k.classification});return}if(n.phase==="probe"){if(Mr(x)){n.instance.channel.deliver(x,{classification:k.classification});return}n={phase:"pinned",era:"modern",instance:n.instance}}else{let P=await h("modern",k.revision);if(a()){await g(P);return}n={phase:"pinned",era:"modern",instance:P}}if(await d(x)||a())return;n.instance.channel.deliver(x,{classification:k.classification});return;case"legacy":{if(r==="reject"){kt(x)&&await f(x,k.reason,k.requestedVersion);return}if(n.phase==="probe"){if(await b(n.instance),a())return;n={phase:"opening"}}let P=await h("legacy");if(a()){await g(P);return}n={phase:"pinned",era:"legacy",instance:P},n.instance.channel.deliver(x);return}}},w=[],v=!1,S=async()=>{if(!v){v=!0;try{for(;w.length>0;){let x=w.shift();try{await y(x)}catch(k){kt(x)&&await l(x.id,ge.InternalError,"Internal server error"),c($r(k))}}}finally{v=!1}}},_=async()=>{if(s||n.phase==="closed")return;s=!0;let x=n;n={phase:"closed"};for(let k of u.teardownAll())await o.send(k).catch(P=>c($r(P)));(x.phase==="probe"||x.phase==="pinned")&&await x.instance.product.close().catch(k=>c($r(k))),await o.close().catch(k=>c($r(k)))};o.onmessage=x=>{w.push(x),S()},o.onerror=x=>{c(x),(n.phase==="probe"||n.phase==="pinned")&&n.instance.channel.onerror?.(x)},o.onclose=()=>{if(s||n.phase==="closed")return;s=!0;let x=n;n={phase:"closed"},(x.phase==="probe"||x.phase==="pinned")&&x.instance.product.close().catch(k=>c($r(k)))};let $=o.start().catch(x=>{throw c($r(x)),x});return $.catch(()=>{}),{close:async()=>{await $.catch(()=>{}),await _()}}}function $r(e){return e instanceof Error?e:new Error(String(e))}import{timingSafeEqual as xZ}from"node:crypto";import{existsSync as _b,readFileSync as $b,statSync as _Z}from"node:fs";import{createServer as SZ}from"node:http";import{extname as kZ,join as Mc,normalize as zZ,sep as RZ}from"node:path";import{fileURLToPath as uN}from"node:url";async function y3(e,t,r){let o=new gS({classification:r.classification,...r.responseMode!==void 0&&{responseMode:r.responseMode},...r.keepAliveMs!==void 0&&{keepAliveMs:r.keepAliveMs}});return await e.connect(o),o.handleMessage(t,{...r.request!==void 0&&{request:r.request},...r.authInfo!==void 0&&{authInfo:r.authInfo}})}var $S=4*1024*1024,vS=100;function VE(e){return`Payload Too Large: Request body must not exceed ${e} bytes`}function ZE(e){if(e===void 0)return $S;if(typeof e!="number"||!Number.isFinite(e)||e<=0)throw new RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(e)}`);return e}async function HE(e,t=$S){if(Number(e.headers.get("content-length"))>t)return{tooLarge:!0};if(e.body===null)return{tooLarge:!1,text:""};let r=e.body.getReader(),o=new TextDecoder,n=0,i="";try{for(;;){let{done:s,value:a}=await r.read();if(s)break;if(n+=a.byteLength,n>t)return{tooLarge:!0};i+=o.decode(a,{stream:!0})}}finally{r.releaseLock()}return{tooLarge:!1,text:i+o.decode()}}var b3=class{sessionIdGenerator;_started=!1;_hasHandledRequest=!1;_closed=!1;_streamMapping=new Map;_requestToStreamMapping=new Map;_requestResponseMap=new Map;_initialized=!1;_enableJsonResponse=!1;_standaloneSseStreamId="_GET_stream";_eventStore;_onsessioninitialized;_onsessionclosed;_allowedHosts;_allowedOrigins;_enableDnsRebindingProtection;_retryInterval;_supportedProtocolVersions;_keepAliveMs;_maxRequestBodySize;_scopeChallengeResolver;sessionId;onclose;onerror;onmessage;constructor(e={}){this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval,this._supportedProtocolVersions=e.supportedProtocolVersions??hu,this._keepAliveMs=e.keepAliveMs??dc,this._maxRequestBodySize=ZE(e.maxRequestBodySize)}startKeepAlive(e,t){if(this._closed)return;let r=tm(this._keepAliveMs,()=>{try{e.enqueue(t.encode(`: keepalive
89
+
90
+ `))}catch{r!==void 0&&clearInterval(r)}});return r}setScopeChallengeResolver(e){this._scopeChallengeResolver=e}async start(){if(this._started)throw new Error("Transport already started");this._started=!0}setSupportedProtocolVersions(e){this._supportedProtocolVersions=e}createJsonErrorResponse(e,t,r,o){let n={code:t,message:r};return o?.data!==void 0&&(n.data=o.data),Response.json({jsonrpc:"2.0",error:n,id:null},{status:e,headers:{"Content-Type":"application/json",...o?.headers}})}async _checkScopeChallenge(e,t){if(!this._scopeChallengeResolver)return;let r=await yS(e.filter(o=>kt(o)),t,this._scopeChallengeResolver);return r===void 0?void 0:wS(r,bS(t))}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let t=e.headers.get("host");if(!t||!this._allowedHosts.includes(t)){let r=`Invalid Host header: ${t}`;return this.onerror?.(new Error(r)),this.createJsonErrorResponse(403,-32e3,r)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let t=e.headers.get("origin");if(t&&!this._allowedOrigins.includes(t)){let r=`Invalid Origin header: ${t}`;return this.onerror?.(new Error(r)),this.createJsonErrorResponse(403,-32e3,r)}}}}async handleRequest(e,t){if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");if(!this.sessionIdGenerator&&this._hasHandledRequest)throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let r=this.validateRequestHeaders(e);if(r)return r;switch(e.method){case"POST":return this.handlePostRequest(e,t);case"GET":return this.handleGetRequest(e);case"DELETE":return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}supportsEmptySSEData(e){return this._supportedProtocolVersions.includes(e)&&e>="2025-11-25"}async writePrimingEvent(e,t,r,o){if(!this._eventStore||!this.supportsEmptySSEData(o))return;let n=await this._eventStore.storeEvent(r,{}),i=`id: ${n}
91
+ data:
92
+
93
+ `;this._retryInterval!==void 0&&(i=`id: ${n}
94
+ retry: ${this._retryInterval}
95
+ data:
96
+
97
+ `),e.enqueue(t.encode(i))}async handleGetRequest(e){if(!e.headers.get("accept")?.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept text/event-stream");let t=this.validateSession(e);if(t)return t;let r=this.validateProtocolVersion(e);if(r)return r;if(this._eventStore){let c=e.headers.get("last-event-id");if(c)return this.replayEvents(c)}if(this._streamMapping.get(this._standaloneSseStreamId)!==void 0)return this.onerror?.(new Error("Conflict: Only one SSE stream is allowed per session")),this.createJsonErrorResponse(409,-32e3,"Conflict: Only one SSE stream is allowed per session");let o=new TextEncoder,n,i,s=new ReadableStream({start:c=>{n=c},cancel:()=>{i!==void 0&&clearInterval(i),this._streamMapping.get(this._standaloneSseStreamId)?.controller===n&&this._streamMapping.delete(this._standaloneSseStreamId)}}),a={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};return this.sessionId!==void 0&&(a["mcp-session-id"]=this.sessionId),this._streamMapping.set(this._standaloneSseStreamId,{controller:n,encoder:o,cleanup:()=>{i!==void 0&&clearInterval(i),this._streamMapping.delete(this._standaloneSseStreamId);try{n.close()}catch{}}}),i=this.startKeepAlive(n,o),new Response(s,{headers:a})}async replayEvents(e){if(!this._eventStore)return this.onerror?.(new Error("Event store not configured")),this.createJsonErrorResponse(400,-32e3,"Event store not configured");try{let t;if(this._eventStore.getStreamIdForEventId){if(t=await this._eventStore.getStreamIdForEventId(e),!t)return this.onerror?.(new Error("Invalid event ID format")),this.createJsonErrorResponse(400,-32e3,"Invalid event ID format");if(this._streamMapping.get(t)!==void 0)return this.onerror?.(new Error("Conflict: Stream already has an active connection")),this.createJsonErrorResponse(409,-32e3,"Conflict: Stream already has an active connection")}let r={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};this.sessionId!==void 0&&(r["mcp-session-id"]=this.sessionId);let o=new TextEncoder,n,i,s=!1,a,c=new ReadableStream({start:u=>{n=u},cancel:()=>{s=!0,i!==void 0&&clearInterval(i),a!==void 0&&this._streamMapping.get(a)?.controller===n&&this._streamMapping.delete(a)}}),l=new Set;if(a=await this._eventStore.replayEventsAfter(e,{send:async(u,m)=>{if(l.add(u),!this.writeSSEEvent(n,o,m,u))try{n.close()}catch{}}}),this._closed||s){try{n.close()}catch{}return this.createJsonErrorResponse(404,-32001,"Session not found")}if(this._streamMapping.get(a)?.cleanup(),this._streamMapping.set(a,{controller:n,encoder:o,replayedEventIds:l,cleanup:()=>{i!==void 0&&clearInterval(i),this._streamMapping.delete(a);try{n.close()}catch{}}}),a!==this._standaloneSseStreamId&&![...this._requestToStreamMapping.values()].includes(a)){this._streamMapping.delete(a);try{n.close()}catch{}}return this._streamMapping.get(a)?.controller===n&&(i=this.startKeepAlive(n,o)),new Response(c,{headers:r})}catch(t){return this.onerror?.(t),this.createJsonErrorResponse(500,-32e3,"Error replaying events")}}writeSSEEvent(e,t,r,o){try{let n=`event: message
98
+ `;return o&&(n+=`id: ${o}
99
+ `),n+=`data: ${JSON.stringify(r)}
100
+
101
+ `,e.enqueue(t.encode(n)),!0}catch(n){return this.onerror?.(n),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),Response.json({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null},{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,t){try{let r=e.headers.get("accept");if(!r?.includes("application/json")||!r.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");if(!rS(e.headers.get("content-type")))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let o=e,n;if(t?.parsedBody===void 0)try{let g=await HE(e,this._maxRequestBodySize);if(g.tooLarge){let b=VE(this._maxRequestBodySize);return this.onerror?.(new Error(b)),this.createJsonErrorResponse(413,-32e3,b)}n=JSON.parse(g.text)}catch(g){return this.onerror?.(g),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}else n=t.parsedBody;if(Array.isArray(n)&&n.length>vS)return this.onerror?.(new Error(`Invalid Request: Batch must not exceed ${vS} messages`)),this.createJsonErrorResponse(400,-32600,`Invalid Request: Batch must not exceed ${vS} messages`);let i;try{i=Array.isArray(n)?n.map(g=>us.parse(g)):[us.parse(n)]}catch(g){return this.onerror?.(g),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let s=i.some(g=>J_(g));if(s){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(i.length>1)return this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!s){let g=this.validateSession(e);if(g)return g;let b=this.validateProtocolVersion(e);if(b)return b}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let a;try{a=await this._checkScopeChallenge(i,t?.authInfo)}catch(g){return this.onerror?.(g),this.createJsonErrorResponse(500,-32603,"Internal server error")}if(a)return a;if(!i.some(g=>kt(g))){for(let g of i)this.onmessage?.(g,{authInfo:t?.authInfo,request:o});return new Response(null,{status:202})}let c=crypto.randomUUID(),l=i.find(g=>J_(g)),u=l?l.params.protocolVersion:e.headers.get("mcp-protocol-version")??qp;if(this._enableJsonResponse)return new Promise(g=>{this._streamMapping.set(c,{resolveJson:g,cleanup:()=>{this._streamMapping.delete(c)}});for(let b of i)kt(b)&&this._requestToStreamMapping.set(b.id,c);for(let b of i)this.onmessage?.(b,{authInfo:t?.authInfo,request:o})});let m=new TextEncoder,d,f,p=new ReadableStream({start:g=>{d=g},cancel:()=>{f!==void 0&&clearInterval(f),this._streamMapping.get(c)?.controller===d&&this._streamMapping.delete(c)}}),h={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};this.sessionId!==void 0&&(h["mcp-session-id"]=this.sessionId);for(let g of i)kt(g)&&(this._streamMapping.set(c,{controller:d,encoder:m,cleanup:()=>{f!==void 0&&clearInterval(f),this._streamMapping.delete(c);try{d.close()}catch{}}}),this._requestToStreamMapping.set(g.id,c));await this.writePrimingEvent(d,m,c,u);for(let g of i){let b,y;kt(g)&&this._eventStore&&this.supportsEmptySSEData(u)&&(b=()=>{this.closeSSEStream(g.id)},y=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(g,{authInfo:t?.authInfo,request:o,closeSSEStream:b,closeStandaloneSSEStream:y})}return this._streamMapping.get(c)?.controller===d&&(f=this.startKeepAlive(d,m)),new Response(p,{status:200,headers:h})}catch(r){return this.onerror?.(r),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(r)})}}async handleDeleteRequest(e){let t=this.validateSession(e);if(t)return t;let r=this.validateProtocolVersion(e);if(r)return r;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(e){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(new Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let t=e.headers.get("mcp-session-id");if(!t)return this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required");if(t!==this.sessionId)return this.onerror?.(new Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(e){let t=e.headers.get("mcp-protocol-version");if(t!==null&&!this._supportedProtocolVersions.includes(t)){let r=`Bad Request: Unsupported protocol version: ${t} (supported versions: ${this._supportedProtocolVersions.join(", ")})`;return this.onerror?.(new Error(r)),this.createJsonErrorResponse(400,-32e3,r)}}async close(){if(!this._closed){this._closed=!0;for(let{cleanup:e}of this._streamMapping.values())e();this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}}closeSSEStream(e){let t=this._requestToStreamMapping.get(e);if(!t)return;let r=this._streamMapping.get(t);r&&r.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,t){let r=t?.relatedRequestId;if((Qn(e)||er(e))&&(r=e.id),r===void 0){if(Qn(e)||er(e))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let i;this._eventStore&&(i=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let s=this._streamMapping.get(this._standaloneSseStreamId);if(s===void 0)return;s.controller&&s.encoder&&(i===void 0||!s.replayedEventIds?.has(i))&&this.writeSSEEvent(s.controller,s.encoder,e,i);return}let o=this._requestToStreamMapping.get(r);if(!o)throw new Error(`No connection established for request ID: ${String(r)}`);let n=this._streamMapping.get(o);if(!this._enableJsonResponse){let i;this._eventStore&&(i=await this._eventStore.storeEvent(o,e),n=this._streamMapping.get(o)),n?.controller&&n?.encoder&&(i===void 0||!n.replayedEventIds?.has(i))&&this.writeSSEEvent(n.controller,n.encoder,e,i)}if(Qn(e)||er(e)){this._requestResponseMap.set(r,e);let i=[...this._requestToStreamMapping.entries()].filter(([s,a])=>a===o).map(([s])=>s);if(i.every(s=>this._requestResponseMap.has(s))){if(!n){if(this._enableJsonResponse)throw new Error(`No connection established for request ID: ${String(r)}`);if(!this._eventStore){this.onerror?.(new Error(`Response for request ID ${String(r)} is undeliverable: per-request stream is disconnected and no eventStore is configured`));for(let s of i)this._requestResponseMap.delete(s),this._requestToStreamMapping.delete(s);return}for(let s of i)this._requestResponseMap.delete(s),this._requestToStreamMapping.delete(s);return}if(this._enableJsonResponse&&n.resolveJson){let s={"Content-Type":"application/json"};this.sessionId!==void 0&&(s["mcp-session-id"]=this.sessionId);let a=i.map(c=>this._requestResponseMap.get(c));a.length===1?n.resolveJson(Response.json(a[0],{status:200,headers:s})):n.resolveJson(Response.json(a,{status:200,headers:s})),n.cleanup()}else n.cleanup();for(let s of i)this._requestResponseMap.delete(s),this._requestToStreamMapping.delete(s)}}}};function ui(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let{method:t,id:r}=e;return typeof t!="string"?null:typeof r=="string"||typeof r=="number"?r:null}function fo(e,t,r,o,n=null){return Response.json({jsonrpc:"2.0",error:{code:t,message:r,...o!==void 0&&{data:o}},id:n},{status:e,...e===405&&{headers:{Allow:"POST"}}})}function Yg(e,t=null){return fo(e.httpStatus,e.code,e.message,e.data,t)}function nm(e){return e instanceof Error?e:new Error(String(e))}function rm(e=null){return fo(500,-32603,"Internal server error",void 0,e)}function FE(e){if(e.transport!==void 0)throw new Error("The factory returned an instance that is still serving another request. Return a new instance for each request.")}function w3(e,t,r,o){return async(n,i)=>{if(n.method.toUpperCase()!=="POST")return fo(405,-32e3,"Method not allowed.");try{let s=await e({era:"legacy",...i?.authInfo!==void 0&&{authInfo:i.authInfo},requestInfo:n}),a=new b3({sessionIdGenerator:void 0,...r!==void 0&&{keepAliveMs:r},...o!==void 0&&{maxRequestBodySize:o}});await s.connect(a);let c=()=>{a.close().catch(()=>{}),s.close().catch(()=>{})};n.signal?.addEventListener("abort",c,{once:!0});let l=await a.handleRequest(n,{...i?.authInfo!==void 0&&{authInfo:i.authInfo},...i?.parsedBody!==void 0&&{parsedBody:i.parsedBody}});if(l.body===null||nS(l.headers.get("content-type"))!=="text/event-stream")return c(),l;let u=l.body.getReader(),m=!1,d=()=>{m||(m=!0,c())},f=new ReadableStream({pull:async p=>{try{let{done:h,value:g}=await u.read();if(h){d(),p.close();return}g!==void 0&&p.enqueue(g)}catch(h){d(),p.error(h)}},cancel:p=>(d(),u.cancel(p).catch(()=>{}))});return new Response(f,{status:l.status,statusText:l.statusText,headers:l.headers})}catch(s){try{t?.(nm(s))}catch{}return rm(ui(i?.parsedBody))}}}function BE(e){return{protocolVersionHeader:e.headers.get("mcp-protocol-version")??void 0,mcpMethodHeader:e.headers.get("mcp-method")??void 0,mcpNameHeader:e.headers.get("mcp-name")??void 0}}async function v3(e,t,r=!0,o=$S){let n=e.method.toUpperCase(),i,s=t,a=e,c=!1;if(n==="POST"){if(s===void 0){r&&(a=e.clone());let l;try{let u=await HE(e,o);if(u.tooLarge)return{step:"body-too-large"};l=u.text}catch{return{step:"unreadable-body"}}try{i=l.length===0?void 0:JSON.parse(l)}catch{c=!0}!c&&i!==void 0&&(s=i)}else i=s;if(c||i===void 0)return{step:"no-json-body",forwardRequest:a}}return{step:"classified",outcome:Tj({httpMethod:n,...BE(e),...i!==void 0&&{body:i}}),body:i,parsedBody:s,forwardRequest:a}}function xS(e,t={}){let{legacy:r,onerror:o,responseMode:n}=t,i=ZE(t.maxRequestBodySize);if(typeof r=="function")throw new TypeError("The 'legacy' option only accepts 'stateless' or 'reject', not a handler function. To serve 2025-era traffic with your own handler, route in user land with the exported isLegacyRequest(request) predicate in front of a strict (legacy: 'reject') handler.");let s=new Set,a=!1,c=b=>{try{o?.(b)}catch{}},l=t.bus??new TE(c),u=CE(l),m=ME({bus:l,maxSubscriptions:t.maxSubscriptions??fc,keepAliveMs:t.keepAliveMs??dc,onerror:c});n==="json"&&console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let d=r==="reject"?void 0:w3(e,c,t.keepAliveMs,i);async function f(b,y,w){let v=b.classification.revision;if(v===void 0||!zn.includes(v)){let E=new ps({supported:[...zn],requested:v??"unknown"});return c(E),fo(400,E.code,E.message,E.data,ui(b.message))}let S=jj({httpMethod:y.method,...BE(y)},b);if(S!==void 0)return c(new Error(`Rejected inbound request (${S.cell}): ${S.message}`)),Yg(S,ui(b.message));let _=b.messageKind==="request"?br(b.message.params):void 0,$=_?.[Nr];if(b.messageKind==="request"){let E=aj(b.message.method);if(E!==void 0){let N=Gu(E,$);if(N!==void 0){let T=new Ku({requiredCapabilities:N});return c(T),fo(Pj(T.code,"ladder"),T.code,T.message,T.data,b.message.id)}}}let x=await e({era:"modern",...w!==void 0&&{authInfo:w},requestInfo:y}),k=x instanceof li?x.server:x;if(FE(k),b.messageKind==="request"&&b.message.method==="subscriptions/listen"){let E=k.getCapabilities(),N=Gg(k);return x.close().catch(c),m.serve(b.message,y.signal,E,N)}if(b.messageKind==="request"&&b.message.method==="tools/call"&&x instanceof li){let E=b.message.params,N=typeof E?.name=="string"?E.name:void 0,T=N===void 0?void 0:x.toolInputSchemaJson(N);if(T!==void 0){let q=Ag(T);if(q.declarations!==void 0&&q.declarations.length>0){let Z=Ij(q.declarations,E?.arguments,y.headers);if(Z!==void 0)return x.close().catch(c),c(new Error(`Rejected inbound request (${Z.cell}): ${Z.message}`)),Yg(Z,b.message.id)}}}if(b.messageKind==="request"&&x instanceof li)try{let E=await yS([b.message],w,N=>x.resolveScopeChallenge(N));if(E!==void 0)return x.close().catch(c),wS(E,bS(w))}catch(E){return x.close().catch(c),c(nm(E)),rm(b.message.id)}FE(k),Dg(k,v),Jg(k,zn),_!==void 0&&PE(k,{clientInfo:_[as],clientCapabilities:$});let P=k.onclose;s.add(k);let I=()=>{s.delete(k),k.onclose===I&&(k.onclose=P),P?.()};k.onclose=I;try{let E=await y3(x,b.message,{classification:b.classification,request:y,...w!==void 0&&{authInfo:w},...n!==void 0&&{responseMode:n},...t.keepAliveMs!==void 0&&{keepAliveMs:t.keepAliveMs}});return b.messageKind==="notification"&&queueMicrotask(()=>{k.close().catch(()=>{})}),E}catch(E){return E instanceof Oe&&E.code===Ue.ConnectionClosed?new Response(null,{status:499}):(await k.close().catch(()=>{}),s.delete(k),c(nm(E)),rm(ui(b.message)))}}async function p(b,y,w,v){if(d!==void 0)return d(y,{...w!==void 0&&{authInfo:w},...v!==void 0&&{parsedBody:v}});let S=Ng(b,zn);return S===void 0?new Response(null,{status:202}):(c(new Error(`Rejected 2025-era request on a modern-only endpoint (${S.cell}): ${S.message}`)),Yg(S,ui(v)))}async function h(b,y){let w=y?.authInfo;if(b.method.toUpperCase()==="POST"&&!rS(b.headers.get("content-type")))return c(new Error("Unsupported Media Type: Content-Type must be application/json")),fo(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let v=await v3(b,y?.parsedBody,!0,i);if(v.step==="unreadable-body")return fo(400,-32700,"Parse error: the request body could not be read");if(v.step==="body-too-large")return fo(413,-32e3,VE(i));if(v.step==="no-json-body")return d!==void 0?d(v.forwardRequest,{...w!==void 0&&{authInfo:w}}):fo(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:S,body:_,parsedBody:$,forwardRequest:x}=v;try{switch(S.kind){case"reject":return c(new Error(`Rejected inbound request (${S.cell}): ${S.message}`)),Yg(S,ui(_));case"modern":return await f(S,b,w);case"legacy":return await p(S,x,w,$)}}catch(k){return c(nm(k)),rm(ui(_))}}return{fetch:async(b,y)=>{if(a)throw new Error("This MCP handler has been closed");try{return await h(b,y)}catch(w){return c(nm(w)),rm(ui(y?.parsedBody))}},notify:u,bus:l,close:async()=>{a=!0,m.closeAll();let b=[...s].map(y=>y.close().catch(()=>{}));s.clear(),await Promise.all(b)}}}var ys=["tile","sprite","sheet","icon","family","overlay","object","map","font"],_S=["tone","full","channel"],WE=["cycle","pingpong","wave","sparkle"];function pc(e){return e.iconMode??(e.palette.entries.some(t=>t.role)?"tone":"full")}function JE(e){return{...e,chars:[...e.chars],advances:{...e.advances}}}function $3(e){return{...e,at:[e.at[0],e.at[1]],anchor:[e.anchor[0],e.anchor[1]],flags:[...e.flags]}}function GE(e){return{tile:e.tile,entries:e.entries.map(t=>({...t,anchor:[t.anchor[0],t.anchor[1]]}))}}function Dr(e,t={}){return{name:e,hidden:!1,locked:!1,reference:!1,...t}}function KE(e){let t=new Uint16Array(e.width*e.height).fill(e.bg),r=e.family?[Dr("ground"),Dr("band")]:e.map?[Dr("floor",{map:{kind:"tiles"}})]:[Dr("main")],o=e.family?[[t],[new Uint16Array(e.width*e.height).fill(65535)]]:[[t]];return{kind:e.kind,name:e.name,width:e.width,height:e.height,cellW:e.cellW,cellH:e.cellH,wrap:e.wrap,palette:e.palette,paletteLocked:!1,layers:r,frameCount:1,cels:o,ctx:{},home:{layer:e.family?1:0,frame:0},notes:[],stamps:{},macros:{},ticks:[10],tags:[],views:[],pivot:null,ground:null,family:e.family?YE(e.family):null,overlay:e.overlay?XE(e.overlay):null,footprint:null,variantOf:null,densityOf:null,map:e.map?GE(e.map):null,marks:[],iconMode:null,font:e.font?JE(e.font):null}}function YE(e){return{...e,geometry:{...e.geometry,bands:e.geometry.bands.map(t=>({...t}))},detached:[...e.detached],terrain:e.terrain.slice()}}function XE(e){return{...e,anchor:e.anchor?[e.anchor[0],e.anchor[1]]:null,spread:[e.spread[0],e.spread[1]]}}function x3(e){return e.map(t=>{let r=new Map;return t.map(o=>{let n=r.get(o);return n||r.set(o,n=o.slice()),n})})}function QE(e){let t=[];return e.cels.forEach((r,o)=>r.forEach((n,i)=>{let s=r.indexOf(n);s!==i&&t.push([o,i,s])})),t}function eT(e){return e.ticks.some(t=>t!==10)||e.tags.length>0||e.views.length>0||e.pivot!==null||e.ground!==null||QE(e).length>0}function _3(e){return{...e,sel:e.sel?e.sel.slice():null,mirror:e.mirror?{...e.mirror}:null,brush:e.brush?{...e.brush}:null}}function qr(e){return{...e,layers:e.layers.map(t=>({...t})),cels:x3(e.cels),ticks:[...e.ticks],tags:e.tags.map(t=>({...t})),views:e.views.map(t=>({...t})),pivot:e.pivot?[e.pivot[0],e.pivot[1]]:null,ctx:Object.fromEntries(Object.entries(e.ctx).map(([t,r])=>[t,_3(r)])),home:{...e.home},family:e.family?YE(e.family):null,overlay:e.overlay?XE(e.overlay):null,footprint:e.footprint?$3(e.footprint):null,map:e.map?GE(e.map):null,notes:e.notes.map(t=>({...t})),marks:e.marks.map(t=>({...t})),font:e.font?JE(e.font):null,stamps:Object.fromEntries(Object.entries(e.stamps).map(([t,r])=>[t,{...r,px:r.px.slice()}])),macros:Object.fromEntries(Object.entries(e.macros).map(([t,r])=>[t,{params:[...r.params],body:r.body}]))}}function Me(e,t){return e.ctx[t]??{layer:e.home.layer,frame:e.home.frame,sel:null,mirror:null,brush:null}}function Tt(e,t,r){let o={...Me(e,t),...r};o.layer===e.home.layer&&o.frame===e.home.frame&&!o.sel&&!o.mirror&&!o.brush?delete e.ctx[t]:e.ctx[t]=o}function xr(e,t,r){let o=Object.keys(e.ctx).map(n=>[n,Me(e,n)]);e.home={layer:t(e.home.layer),frame:r(e.home.frame)};for(let[n,i]of o)e.ctx[n]={...i,layer:t(i.layer),frame:r(i.frame)};for(let[n]of o)Tt(e,n,{})}function S3(e){return e.layers.flatMap((t,r)=>t.hidden||t.reference?[]:[r])}function be(e,t=0){return nT(e,t,S3(e))}function tT(e,t=0){let r=e.layers.flatMap((o,n)=>o.reference&&!o.hidden?[n]:[]);return r.length?nT(e,t,r):null}function nT(e,t,r){let o=new Uint16Array(e.width*e.height).fill(65535);for(let n of r){let i=e.cels[n][t];for(let s=0;s<o.length;s++)i[s]!==65535&&(o[s]=i[s])}return o}function Qg(e){let t=[];for(let r of e){let o=r.codePointAt(0);o<128?t.push(o):o<2048?t.push(192|o>>6,128|o&63):o<65536?t.push(224|o>>12,128|o>>6&63,128|o&63):t.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|o&63)}return Uint8Array.from(t)}function SS(e){let t="";for(let r=0;r<e.length;){let o=e[r],n;o<128?(n=o,r+=1):o<224?(n=(o&31)<<6|e[r+1]&63,r+=2):o<240?(n=(o&15)<<12|(e[r+1]&63)<<6|e[r+2]&63,r+=3):(n=(o&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63,r+=4),t+=String.fromCodePoint(n)}return t}var Xg=e=>Object.keys(e).sort();function Rn(e){let t=Xg(e.ctx),r=Xg(e.stamps),o=Xg(e.macros),n=JSON.stringify({kind:e.kind,name:e.name,width:e.width,height:e.height,cellW:e.cellW,cellH:e.cellH,wrap:e.wrap,palette:{name:e.palette.name,entries:e.palette.entries.map(d=>d.role?[d.key,d.name,d.hex,d.role]:[d.key,d.name,d.hex]),ramps:Xg(e.palette.ramps).map(d=>[d,e.palette.ramps[d]]),locked:e.paletteLocked},layers:e.layers.map(d=>d.map?[d.name,d.hidden,d.locked,d.reference,k3(d.map)]:[d.name,d.hidden,d.locked,d.reference]),frameCount:e.frameCount,home:[e.home.layer,e.home.frame],notes:e.notes.map(d=>[d.id,d.x,d.y,d.w,d.h,d.text]),ctx:t.map(d=>{let f=e.ctx[d],p=f.brush?f.brush.shape==="stamp"?["stamp",f.brush.stamp]:[f.brush.shape,f.brush.size]:null;return[d,f.layer,f.frame,!!f.sel,f.mirror?[f.mirror.x2,f.mirror.y2]:null,p]}),stamps:r.map(d=>[d,e.stamps[d].w,e.stamps[d].h]),macros:o.map(d=>[d,e.macros[d].params,e.macros[d].body]),...eT(e)?{anim:{ticks:e.ticks,tags:e.tags.map(d=>[d.name,d.from,d.to,d.loop]),views:e.views.map(d=>[d.name,d.from,d.to,d.mirror]),pivot:e.pivot,ground:e.ground,links:QE(e)}}:{},...e.family?{family:{scheme:e.family.scheme,tile:e.family.tile,inset:e.family.geometry.inset,radius:e.family.geometry.radius,...e.family.geometry.fillet!==void 0?{fillet:e.family.geometry.fillet}:{},...e.family.geometry.jitter?{jitter:[e.family.geometry.jitter.px,e.family.geometry.jitter.seed]}:{},...e.family.bandOf?{bandOf:e.family.bandOf}:{},bands:e.family.geometry.bands.map(d=>[d.w,d.fill]),detached:e.family.detached,map:[e.family.mapCols,e.family.mapRows],terrain:Array.from(e.family.terrain).join(""),...e.family.def?{def:e.family.def}:{}}}:{},...e.overlay?{overlay:{mode:e.overlay.mode,on:e.overlay.on,anchor:e.overlay.anchor,spread:e.overlay.spread,every:e.overlay.every,rest:e.overlay.rest,seed:e.overlay.seed}}:{},...e.footprint?{footprint:[e.footprint.cols,e.footprint.rows,e.footprint.at,e.footprint.anchor,e.footprint.flags]}:{},...e.variantOf?{variantOf:e.variantOf}:{},...e.densityOf?{densityOf:[e.densityOf.of,e.densityOf.d]}:{},...e.map?{map:{tile:e.map.tile,entries:e.map.entries.map(d=>d.exact?[d.name,d.variant,d.cols,d.rows,d.anchor,1]:[d.name,d.variant,d.cols,d.rows,d.anchor])}}:{},...e.marks.length?{marks:e.marks.map(d=>[d.name,d.seq,d.by,d.text,d.art])}:{},...e.iconMode?{iconMode:e.iconMode}:{},...e.font?{font:[e.font.chars.join(","),e.font.cols,e.font.baseline,e.font.line,e.font.spacing,Object.keys(e.font.advances).map(Number).sort((d,f)=>d-f).map(d=>[d,e.font.advances[d]])]}:{},...e.layers.some(d=>d.underlay)?{underlays:e.layers.flatMap((d,f)=>d.underlay?[[f,d.underlay.blob,d.underlay.iw,d.underlay.ih,d.underlay.x,d.underlay.y,d.underlay.w,d.underlay.h,d.underlay.layout]]:[])}:{}}),i=Qg(`PCLAWDOC 2
102
+ `+n+`
103
+ `),s=e.width*e.height,a=t.flatMap(d=>e.ctx[d].sel?[e.ctx[d].sel]:[]),c=r.reduce((d,f)=>d+e.stamps[f].px.length,0),l=new Uint8Array(i.length+e.layers.length*e.frameCount*s*2+a.length*s+c*2);l.set(i,0);let u=i.length,m=d=>{for(let f=0;f<d.length;f++)l[u++]=d[f]&255,l[u++]=d[f]>>8};for(let d of e.cels)for(let f of d)m(f);for(let d of a)l.set(d,u),u+=s;for(let d of r)m(e.stamps[d].px);return l}function ey(e){let t=`PCLAWDOC 2
104
+ `;for(let m=0;m<t.length;m++)if(e[m]!==t.charCodeAt(m))throw new Error("not a PCLAWDOC 2 document");let r=t.length;for(;r<e.length&&e[r]!==10;)r++;let o=JSON.parse(SS(e.subarray(t.length,r))),n=r+1,i=o.width*o.height,s=m=>{let d=new Uint16Array(m);for(let f=0;f<m;f++)d[f]=e[n]|e[n+1]<<8,n+=2;return d},a=o.layers.map(()=>Array.from({length:o.frameCount},()=>s(i)));for(let[m,d,f]of o.anim?.links??[])a[m][d]=a[m][f];let c={};for(let[m,d,f,p,h,g]of o.ctx)c[m]={layer:d,frame:f,sel:null,mirror:h?{x2:h[0],y2:h[1]}:null,brush:g?g[0]==="stamp"?{shape:"stamp",stamp:String(g[1])}:{shape:g[0],size:Number(g[1])}:null},p&&(c[m].sel=e.slice(n,n+i)),p&&(n+=i);let l={};for(let[m,d,f]of o.stamps)l[m]={w:d,h:f,px:s(d*f)};let u=o.layers.map(([m,d,f,p,h])=>h?{name:m,hidden:d,locked:f,reference:p,map:z3(h)}:{name:m,hidden:d,locked:f,reference:p});for(let[m,d,f,p,h,g,b,y,w]of o.underlays??[])u[m].underlay={blob:d,iw:f,ih:p,x:h,y:g,w:b,h:y,layout:w};return{kind:o.kind,name:o.name,width:o.width,height:o.height,cellW:o.cellW,cellH:o.cellH,wrap:o.wrap,palette:{name:o.palette.name,entries:o.palette.entries.map(([m,d,f,p])=>p?{key:m,name:d,hex:f,role:p}:{key:m,name:d,hex:f}),ramps:Object.fromEntries(o.palette.ramps)},paletteLocked:o.palette.locked,layers:u,frameCount:o.frameCount,cels:a,ctx:c,home:{layer:o.home[0],frame:o.home[1]},notes:o.notes.map(([m,d,f,p,h,g])=>({id:m,x:d,y:f,w:p,h,text:g})),stamps:l,macros:Object.fromEntries(o.macros.map(([m,d,f])=>[m,{params:d,body:f}])),ticks:o.anim?.ticks??Array.from({length:o.frameCount},()=>10),tags:(o.anim?.tags??[]).map(([m,d,f,p])=>({name:m,from:d,to:f,loop:p})),views:(o.anim?.views??[]).map(([m,d,f,p])=>({name:m,from:d,to:f,mirror:p})),pivot:o.anim?.pivot??null,ground:o.anim?.ground??null,family:o.family?{scheme:o.family.scheme,tile:o.family.tile,geometry:{inset:o.family.inset,radius:o.family.radius,bands:o.family.bands.map(([m,d])=>({w:m,fill:d})),...o.family.fillet!==void 0?{fillet:o.family.fillet}:{},...o.family.jitter?{jitter:{px:o.family.jitter[0],seed:o.family.jitter[1]}}:{}},detached:o.family.detached,mapCols:o.family.map[0],mapRows:o.family.map[1],terrain:Uint8Array.from([...o.family.terrain].map(Number)),...o.family.def?{def:o.family.def}:{},...o.family.bandOf?{bandOf:o.family.bandOf}:{}}:null,overlay:o.overlay??null,footprint:o.footprint?{cols:o.footprint[0],rows:o.footprint[1],at:o.footprint[2],anchor:o.footprint[3],flags:o.footprint[4]}:null,variantOf:o.variantOf??null,densityOf:o.densityOf?{of:o.densityOf[0],d:o.densityOf[1]}:null,map:o.map?{tile:o.map.tile,entries:o.map.entries.map(([m,d,f,p,h,g])=>({name:m,variant:d,cols:f,rows:p,anchor:h,...g?{exact:!0}:{}}))}:null,marks:(o.marks??[]).map(([m,d,f,p,h])=>({name:m,seq:d,by:f,text:p,art:h})),iconMode:o.iconMode??null,font:o.font?{chars:o.font[0]?o.font[0].split(",").map(Number):[],cols:o.font[1],baseline:o.font[2],line:o.font[3],spacing:o.font[4],advances:Object.fromEntries(o.font[5])}:null}}function k3(e){switch(e.kind){case"terrain":return["terrain",e.family,e.outside?"outside":"",...e.walkable?["walkable"]:[],...e.border?[`border=${e.border}`]:[],...e.mix?[`mix=${e.mix.map(t=>`${t.name}:${t.weight}`).join(",")}`,`seed=${e.seed??1}`]:[]];case"overlay":return["overlay",e.overlay,e.on];case"objects":return e.shadow?["objects",`shadow=${e.shadow.c}`,`dir=${e.shadow.dir}`]:["objects"];default:return[e.kind]}}function z3(e){if(e[0]==="terrain"){let t=e.slice(3),r=i=>t.find(s=>s.startsWith(`${i}=`))?.slice(i.length+1),o=r("border"),n=r("mix");return{kind:"terrain",family:e[1],outside:e[2]==="outside",...t.includes("walkable")?{walkable:!0}:{},...o==="terrain"||o==="not"?{border:o}:{},...n?{mix:n.split(",").map(i=>{let[s,a]=i.split(":");return{name:s,weight:Number(a)}}),seed:Number(r("seed")??1)}:{}}}return e[0]==="overlay"?{kind:"overlay",overlay:e[1],on:e[2]}:e[0]==="objects"&&e[1]?.startsWith("shadow=")?{kind:"objects",shadow:{c:e[1].slice(7),dir:(e[2]??"dir=se").slice(4)}}:{kind:e[0]}}function rT(e){let t=Object.keys(e.ctx);if(eT(e)||e.marks.length||e.iconMode||e.font||e.family||e.overlay||e.footprint||e.variantOf||e.densityOf||e.map||e.paletteLocked||e.home.layer||e.home.frame||e.frameCount!==1||e.layers.length!==1||Object.keys(e.stamps).length||Object.keys(e.macros).length)return null;let r=e.layers[0];if(r.hidden||r.locked||r.reference||t.length>1||t.some(u=>e.ctx[u].mirror||e.ctx[u].brush||e.ctx[u].layer||e.ctx[u].frame))return null;let o=t.length?e.ctx[t[0]].sel:null,n=JSON.stringify({kind:e.kind,name:e.name,width:e.width,height:e.height,cellW:e.cellW,cellH:e.cellH,wrap:e.wrap,palette:{name:e.palette.name,entries:e.palette.entries.map(u=>[u.key,u.name,u.hex])},layers:e.layers.map(u=>u.name),frameCount:e.frameCount,active:[0,0],...e.notes.length?{notes:e.notes.map(u=>[u.id,u.x,u.y,u.w,u.h,u.text])}:{},...o?{sel:!0}:{}}),i=Qg(`PCLAWDOC 1
105
+ `+n+`
106
+ `),s=e.width*e.height,a=new Uint8Array(i.length+s*2+(o?s:0));a.set(i,0);let c=i.length,l=e.cels[0][0];for(let u=0;u<s;u++)a[c++]=l[u]&255,a[c++]=l[u]>>8;return o&&a.set(o,c),a}function hc(e){let t=2166136261,r=1523705862,o=n=>{t=Math.imul(t^n&65535,16777619)>>>0,r=Math.imul(r^n*31+7&65535,1540483477)>>>0,r=(r^r>>>15)>>>0};for(let n of[e.width,e.height,e.frameCount,...e.ticks])o(n);for(let n=0;n<e.frameCount;n++)for(let i of be(e,n))o(i);if(e.map){for(let n of JSON.stringify([e.map.entries,e.layers.map(i=>i.map??null)]))o(n.charCodeAt(0));for(let n of e.cels)for(let i of n)for(let s of i)o(s)}return t.toString(16).padStart(8,"0")+r.toString(16).padStart(8,"0")}var Ht=["black","white","light","dark","darkest"];function om(e){return Ht.includes(e)}var oT=256,kS=new Set(["."," ","|"]),mi=/^[A-Za-z][A-Za-z0-9_-]*$/,R3=/^#?([0-9a-fA-F]{6})$/,ot=class extends Error{};function it(e){let t=parseInt(e.slice(1),16);return[t>>16&255,t>>8&255,t&255]}function I3(e,t,r){return"#"+[e,t,r].map(o=>o.toString(16).padStart(2,"0")).join("")}function di(e){let t=R3.exec(e.trim());return t?"#"+t[1].toLowerCase():null}function bs(e){if(!e.name||!mi.test(e.name))throw new ot(`palette name '${e.name}' must match ${mi}`);if(e.entries.length===0)throw new ot(`palette '${e.name}' has no entries`);if(e.entries.length>oT)throw new ot(`palette '${e.name}' has ${e.entries.length} entries; the limit is ${oT}`);let t=new Set,r=new Set;for(let o of e.entries){if([...o.key].length!==1)throw new ot(`entry '${o.name}': key '${o.key}' must be one character`);if(kS.has(o.key)||/\s/.test(o.key))throw new ot(`entry '${o.name}': key '${o.key}' is reserved`);if(t.has(o.key))throw new ot(`duplicate key '${o.key}'`);if(!mi.test(o.name))throw new ot(`entry name '${o.name}' must match ${mi}`);if(o.name==="none")throw new ot("'none' is reserved (it means transparent)");if(r.has(o.name))throw new ot(`duplicate entry name '${o.name}'`);if(!/^#[0-9a-f]{6}$/.test(o.hex))throw new ot(`entry '${o.name}': colour '${o.hex}' must be #rrggbb`);if(o.role!==void 0&&!om(o.role))throw new ot(`entry '${o.name}': role '${o.role}' must be one of ${Ht.join(", ")}`);t.add(o.key),r.add(o.name)}for(let[o,n]of Object.entries(e.ramps)){if(!mi.test(o))throw new ot(`ramp name '${o}' must match ${mi}`);if(n.length===0)throw new ot(`ramp '${o}' is empty`);for(let i of n)if(!r.has(i))throw new ot(`ramp '${o}' names unknown entry '${i}'`)}return e}function ws(e){let t=[],r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-/:;<=>?@[\\]^_`{}~";for(let o of r)t.length<e&&t.push(o);for(let o=192;t.length<e;o++)o!==215&&o!==247&&t.push(String.fromCodePoint(o));return t}function P3(e,t,r){let o=e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"");(!o||o==="untitled"||o==="none")&&(o=t),/^[a-z]/.test(o)||(o="c"+o);let n=o;for(let i=2;r.has(n);i++)n=`${o}_${i}`;return r.add(n),n}function zS(e,t){let r=ws(t.length),o=new Set,n=t.map((i,s)=>({key:r[s],name:P3(i.name??"",`c${s}`,o),hex:i.hex}));return bs({name:e,entries:n,ramps:{}})}function j3(e,t){let r;try{r=JSON.parse(e)}catch(a){throw new ot(`palette JSON does not parse: ${a.message}`)}if(typeof r!="object"||r===null)throw new ot("palette JSON must be an object");let o=r,n=typeof o.name=="string"&&mi.test(o.name)?o.name:t??"palette";if(Array.isArray(o.colors))return zS(n,o.colors.map((a,c)=>{let l=typeof a=="string"?di(a):null;if(!l)throw new ot(`colors[${c}]: '${String(a)}' is not a hex colour`);return{hex:l}}));if(!Array.isArray(o.entries))throw new ot("palette JSON needs an 'entries' array (or Lospec 'colors')");let i=o.entries.map((a,c)=>{let l=a;if(l.role!==void 0&&(typeof l.role!="string"||!om(l.role)))throw new ot(`entries[${c}]: role must be one of ${Ht.join(", ")}`);let u=l.role,m=typeof l.hex=="string"?di(l.hex):u?gc[u]:null;if(!m)throw new ot(`entries[${c}]: missing or bad 'hex'`);if(typeof l.key!="string"||typeof l.name!="string")throw new ot(`entries[${c}]: needs 'key' and 'name' strings`);return u?{key:l.key,name:l.name,hex:m,role:u}:{key:l.key,name:l.name,hex:m}}),s={};if(o.ramps!==void 0){if(typeof o.ramps!="object"||o.ramps===null||Array.isArray(o.ramps))throw new ot("'ramps' must be an object");for(let[a,c]of Object.entries(o.ramps)){if(!Array.isArray(c)||!c.every(l=>typeof l=="string"))throw new ot(`ramp '${a}' must be a list of entry names`);s[a]=c}}return bs({name:n,entries:i,ramps:s})}function E3(e,t){let r=[];return e.split(/\r?\n/).forEach((o,n)=>{let i=o.trim();if(!i||i.startsWith(";")||i.startsWith("//"))return;let s=di(i);if(!s)throw new ot(`line ${n+1}: '${i}' is not a hex colour`);r.push({hex:s})}),zS(t,r)}function T3(e,t){let r=e.split(/\r?\n/);if(!r[0]||r[0].trim()!=="GIMP Palette")throw new ot("line 1: a .gpl file starts with 'GIMP Palette'");let o=t,n=[];for(let i=1;i<r.length;i++){let s=r[i].trim();if(!s||s.startsWith("#"))continue;let a=/^(Name|Columns):\s*(.*)$/.exec(s);if(a){if(a[1]==="Name"){let d=a[2].trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");d&&mi.test(d)&&(o=d)}continue}let c=/^(\d+)\s+(\d+)\s+(\d+)\s*(.*)$/.exec(s);if(!c)throw new ot(`line ${i+1}: expected 'R G B name', got '${s}'`);let[l,u,m]=[c[1],c[2],c[3]].map(Number);if(l>255||u>255||m>255)throw new ot(`line ${i+1}: channel above 255`);n.push({hex:I3(l,u,m),name:c[4]??""})}return zS(o,n)}function RS(e,t){let r=e.replace(/^.*[\\/]/,""),o=r.replace(/\.[^.]*$/,"").toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"palette",n=/^[a-z]/.test(o)?o:"p"+o,i=r.slice(r.lastIndexOf(".")+1).toLowerCase();if(i==="json")return j3(t,n);if(i==="hex")return E3(t,n);if(i==="gpl")return T3(t,n);throw new ot(`unknown palette format '.${i}' (use .json, .hex or .gpl)`)}function po(e){let t=e.entries.map(o=>" "+JSON.stringify({key:o.key,name:o.name,hex:o.hex,...o.role?{role:o.role}:{}})).join(`,
107
+ `),r=Object.entries(e.ramps).map(([o,n])=>` ${JSON.stringify(o)}: ${JSON.stringify(n)}`).join(`,
108
+ `);return`{
109
+ "name": ${JSON.stringify(e.name)},
110
+ "entries": [
111
+ ${t}
112
+ ],
113
+ "ramps": {${r?`
114
+ `+r+`
115
+ `:""}}
116
+ }
117
+ `}var gc={black:"#000000",white:"#ffffff",light:"#cccccc",dark:"#6e6e6e",darkest:"#282828"};function ty(e){return[...e.entries.map(t=>`${t.key} ${t.name} ${t.hex}${t.role?` role=${t.role}`:""}`),...Object.entries(e.ramps).map(([t,r])=>`ramp ${t} ${r.join(" ")}`)]}function iT(e,t){let r=[],o={};for(let n=0;n<t.length;n++){let i=t[n];if(i.trim()==="")continue;let s=i.split(" ").filter(m=>m!=="");if(s[0]==="ramp"){if(s.length<3)return{row:n,col:0,message:"palette row: 'ramp <name> <entry> ...' needs a name and entries"};if(o[s[1]])return{row:n,col:5,message:`palette row: ramp '${s[1]}' given twice`};o[s[1]]=s.slice(2);continue}let a=[...i][0],c=i.slice(a.length).split(" ").filter(m=>m!=="");if(i[a.length]!==" "||c.length<2||c.length>3)return{row:n,col:0,message:"palette row: expected '<key> <name> #rrggbb [role=<role>]' or 'ramp <name> <entries...>'"};let l=di(c[1]);if(!l||!c[1].startsWith("#"))return{row:n,col:i.indexOf(c[1]),message:`palette row: '${c[1]}' is not a colour like #a4552e`};let u;if(c[2]!==void 0){let m=/^role=(.*)$/.exec(c[2]);if(!m||!om(m[1]))return{row:n,col:i.indexOf(c[2]),message:`palette row: '${c[2]}' should be role=${Ht.join("|")}`};u=m[1]}r.push(u?{key:a,name:c[0],hex:l,role:u}:{key:a,name:c[0],hex:l})}try{return{palette:bs({name:e,entries:r,ramps:o})}}catch(n){return{row:0,col:0,message:n.message}}}var O=class extends Error{line;col;constructor(t,r,o){super(o),this.line=t,this.col=r}},C3=/^-?\d+$/,A3=/^(-?\d+),(-?\d+)$/,O3=/^(\d+)x(\d+)$/,N3=/^@cell\((\d+),(\d+)\)$/,M3=/^@cell\(([a-z][a-z0-9_]*)\)$/,D3=/^([A-Za-z_][A-Za-z0-9_-]*)=/,q3=/^[a-z][a-z0-9_-]*$/,U3=1<<20;function L3(e,t,r,o){let n,i=(s,a)=>{let c=Number(s);if(Math.abs(c)>U3)throw new O(t,a,`number ${s} is out of range`);return c};if(n=D3.exec(e)){let s=n[1],a=r+s.length+1;return o!==null?{t:"kv",key:s,value:o,quoted:!0,vcol:a,line:t,col:r}:{t:"kv",key:s,value:e.slice(s.length+1),quoted:!1,vcol:a,line:t,col:r}}if(o!==null){if(e.startsWith('"'))return{t:"string",v:o,line:t,col:r};throw new O(t,r,`unexpected quote in '${e}'`)}return C3.test(e)?{t:"int",v:i(e,r),line:t,col:r}:(n=A3.exec(e))?{t:"point",x:i(n[1],r),y:i(n[2],r),line:t,col:r}:(n=O3.exec(e))?{t:"size",w:i(n[1],r),h:i(n[2],r),line:t,col:r}:(n=N3.exec(e))?{t:"cell",cx:i(n[1],r),cy:i(n[2],r),line:t,col:r}:(n=M3.exec(e))?{t:"cell",cx:-1,cy:-1,name:n[1],line:t,col:r}:{t:"word",v:e,line:t,col:r}}function F3(e){let t=e.filter(o=>o.text.trim()!=="");if(t.length>0&&t.every(o=>o.text.trimStart().startsWith("|")))return e.map(o=>{if(o.text.trim()==="")return{...o,text:""};let n=o.text.indexOf("|")+1,i=o.text.slice(n),s=i.lastIndexOf("|");return s>=0&&i.slice(s+1).trim()===""&&(i=i.slice(0,s)),{text:i,line:o.line,col:o.col+n}});let r=1/0;for(let o of t)r=Math.min(r,o.text.length-o.text.trimStart().length);return Number.isFinite(r)||(r=0),e.map(o=>o.text.trim()===""?{...o,text:""}:{text:o.text.slice(r),line:o.line,col:o.col+r})}function pn(e){let t=e.split(/\r?\n/),r=[],o=[],n=[],i=()=>{if(n.length===0)return;let s=n[0];s.t!=="word"||!q3.test(s.v)?o.push({line:s.line,col:s.col,message:"expected a command name"}):r.push({name:s.v,line:s.line,col:s.col,args:n.slice(1)}),n=[]};for(let s=0;s<t.length;s++){let a=t[s],c=s+1,l=0,u=!1;for(;l<a.length;){let m=a[l];if(m===" "||m===" "){l++;continue}if(m==="#")break;if(m===";"){i(),l++;continue}let d=l,f=null;try{if(m==="{"){let h=V3(t,s,l);n.push({t:"body",text:h.text,bodyLine:c,bodyCol:l+2,line:c,col:l+1}),s=h.endLine,a=t[s],c=s+1,l=h.endCol+1;continue}for(;l<a.length&&a[l]!==" "&&a[l]!==" "&&a[l]!==";";)if(a[l]==='"'){if(f!==null)throw new O(c,l+1,"a token may hold only one quoted string");let h=l+1,g="";for(;h<a.length&&a[h]!=='"';)a[h]==="\\"&&h+1<a.length?(g+=a[h+1],h+=2):(g+=a[h],h++);if(h>=a.length)throw new O(c,l+1,"unterminated string");f=g,l=h+1}else l++;let p=a.slice(d,l);if(p==="<<"){let h=a.slice(l).trim();if(h!==""&&!h.startsWith("#"))throw new O(c,l+2,"'<<' must end the line; the block starts on the next line");let g=[],b=s+1;for(;b<t.length&&t[b].trim()!==">>";)g.push({text:t[b],line:b+1,col:1}),b++;if(b>=t.length)throw new O(c,d+1,"block opened here is never closed with '>>'");n.push({t:"block",rows:F3(g),line:c,col:d+1}),s=b,l=a.length;break}n.push(L3(p,c,d+1,f))}catch(p){if(!(p instanceof O))throw p;o.push({line:p.line,col:p.col,message:p.message}),n=[],u=!0,(p.message.startsWith("block opened")||p.message.startsWith("'{' opened"))&&(s=t.length);break}}u||i()}return i(),{commands:r,errors:o}}function V3(e,t,r){let o=0,n="";for(let i=t;i<e.length;i++){let s=e[i],a=i===t?r:0;if(i>t&&/<<\s*(#.*)?$/.test(e[i-1])){let c=i;for(;c<e.length&&e[c].trim()!==">>";)n+=e[c]+`
118
+ `,c++;if(c>=e.length)break;i=c,n+=e[c]+`
119
+ `;continue}for(;a<s.length;a++){let c=s[a];if(c==='"'){let l=a+1;for(;l<s.length&&s[l]!=='"';)l+=s[l]==="\\"?2:1;n+=s.slice(a,l+1),a=l;continue}if(c==="#"&&(a===0||s[a-1]===" "||s[a-1]===" "))break;if(!(c==="{"&&(o++,o===1))){if(c==="}"&&(o--,o===0))return{text:n,endLine:i,endCol:a};n+=c}}n+=`
120
+ `}throw new O(t+1,r+1,"'{' opened here is never closed with '}'")}function tn(e){return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}var Ur=["S","N","E","W","SE","SW","NE","NW"];function im(e){return{E:"W",W:"E",SE:"SW",SW:"SE",NE:"NW",NW:"NE"}[e]??null}function sm(e,t,r,o,n){e.cels.forEach((s,a)=>s.splice(t,0,...Array.from({length:r},(c,l)=>o(a,l)))),e.ticks.splice(t,0,...n),e.frameCount+=r;let i=s=>{t<=s.from?(s.from+=r,s.to+=r):t<=s.to&&(s.to+=r)};e.tags.forEach(i),e.views.forEach(i),xr(e,s=>s,s=>s>=t?s+r:s)}function PS(e,t){for(let o of e.cels)o.splice(t,1);e.ticks.splice(t,1),e.frameCount--;let r=o=>o.filter(n=>(t<n.from?(n.from--,n.to--):t<=n.to&&n.to--,n.to>=n.from));e.tags=r(e.tags),e.views=r(e.views),xr(e,o=>o,o=>o>t?o-1:Math.min(o,e.frameCount-1))}function jS(e,t){return r=>r===e?t:e<r&&r<=t?r-1:t<=r&&r<e?r+1:r}function sT(e,t,r){for(let i of e.cels){let[s]=i.splice(t,1);i.splice(r,0,s)}let[o]=e.ticks.splice(t,1);e.ticks.splice(r,0,o);let n=jS(t,r);for(let i of[...e.tags,...e.views]){let s=Array.from({length:i.to-i.from+1},(a,c)=>n(i.from+c));i.from=Math.min(...s),i.to=Math.max(...s)}xr(e,i=>i,n)}function Z3(e,t,r){let o=new Uint16Array(e.length);for(let n=0;n<r;n++)for(let i=0;i<t;i++)o[n*t+i]=e[n*t+t-1-i];return o}function fi(e,t){return e.views.find(r=>r.from<=t&&t<=r.to)??null}function aT(e){for(let t of e.views){if(!t.mirror)continue;let r=e.views.find(n=>n.name===t.mirror&&!n.mirror);if(!r){t.mirror=null;continue}let o=r.to-r.from+1;for(;t.to-t.from+1<o;)sm(e,t.to+1,1,()=>new Uint16Array(e.width*e.height).fill(65535),[10]),t.to++;for(;t.to-t.from+1>o;)PS(e,t.to);for(let n=0;n<o;n++)e.ticks[t.from+n]=e.ticks[r.from+n],e.cels.forEach(i=>{i[t.from+n]=Z3(i[r.from+n],e.width,e.height)})}}function tr(e){let t=i=>Array.from({length:i.to-i.from+1},(s,a)=>i.from+a),r=(i,s)=>s.from<=i.from&&i.to<=s.to,o=[],n=[...e.views].sort((i,s)=>Ur.indexOf(i.name)-Ur.indexOf(s.name));for(let i of n)e.tags.some(s=>r(s,i))||o.push({name:i.name,frames:t(i),loop:"cycle",view:i.name,mirror:!!i.mirror});for(let i of e.tags){let s=e.views.find(a=>r(i,a))??null;o.push({name:i.name,frames:t(i),loop:i.loop,view:s?.name??null,mirror:!!s?.mirror})}return o.length||o.push({name:"all",frames:t({from:0,to:e.frameCount-1}),loop:"cycle",view:null,mirror:!1}),o}function Lr(e){return e.loop!=="pingpong"||e.frames.length<3?e.frames:[...e.frames,...e.frames.slice(1,-1).reverse()]}function nr(e,t){return Lr(t).reduce((r,o)=>r+e.ticks[o],0)}function Fr(e,t,r){let o=Lr(t),n=nr(e,t),i=n>0?(r%n+n)%n:0;for(let s of o){if(i<e.ticks[s])return s;i-=e.ticks[s]}return o[0]}function ut(e,t,r=0){let o=new Uint8Array(e*t*4);if(r)for(let n=0;n<e*t;n++)yc(o,n*4,r);return{width:e,height:t,data:o}}function yc(e,t,r){e[t]=r>>>24&255,e[t+1]=r>>>16&255,e[t+2]=r>>>8&255,e[t+3]=r&255}var H3=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let r=t;for(let o=0;o<8;o++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r>>>0}return e})();function B3(e,t=0,r=e.length){let o=4294967295;for(let n=t;n<r;n++)o=H3[(o^e[n])&255]^o>>>8;return(o^4294967295)>>>0}function W3(e){let t=1,r=0;for(let o=0;o<e.length;o++)t=(t+e[o])%65521,r=(r+t)%65521;return(r<<16|t)>>>0}var TS=class{buf=[];acc=0;n=0;bits(t,r){for(let o=0;o<r;o++)this.acc|=(t>>>o&1)<<this.n,++this.n===8&&(this.buf.push(this.acc),this.acc=0,this.n=0)}code(t,r){for(let o=r-1;o>=0;o--)this.bits(t>>>o&1,1)}finish(){return this.n&&this.buf.push(this.acc),Uint8Array.from(this.buf)}},cT=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],J3=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],lT=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],G3=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];function ES(e,t){t<144?e.code(48+t,8):t<256?e.code(400+t-144,9):t<280?e.code(t-256,7):e.code(192+t-280,8)}function uT(e,t){let r=e.length-1;for(;e[r]>t;)r--;return r}function K3(e){let t=new TS;t.bits(1,1),t.bits(1,2);let r=32768,o=64,n=new Int32Array(32768).fill(-1),i=new Int32Array(e.length),s=l=>(e[l]<<10^e[l+1]<<5^e[l+2])&32767,a=l=>{if(l+2>=e.length)return;let u=s(l);i[l]=n[u],n[u]=l},c=0;for(;c<e.length;){let l=0,u=0;if(c+2<e.length){let m=n[s(c)],d=0,f=Math.min(258,e.length-c);for(;m>=0&&c-m<=r&&d++<o;){let p=0;for(;p<f&&e[m+p]===e[c+p];)p++;if(p>l&&(l=p,u=c-m,p===f))break;m=i[m]}}if(l>=3){let m=uT(cT,l);ES(t,257+m),t.bits(l-cT[m],J3[m]);let d=uT(lT,u);t.code(d,5),t.bits(u-lT[d],G3[d]);for(let f=0;f<l;f++)a(c+f);c+=l}else ES(t,e[c]),a(c),c++}return ES(t,256),t.finish()}function CS(e){let t=K3(e),r=new Uint8Array(t.length+6);return r[0]=120,r[1]=1,r.set(t,2),yc(r,t.length+2,W3(e)),r}function am(e,t){let r=new Uint8Array(12+t.length);yc(r,0,t.length);for(let o=0;o<4;o++)r[4+o]=e.charCodeAt(o);return r.set(t,8),yc(r,8+t.length,B3(r,4,8+t.length)),r}function Y3(e){let t=new Uint8Array(e.reduce((o,n)=>o+n.length,0)),r=0;for(let o of e)t.set(o,r),r+=o.length;return t}function X3(e,t,r){let o=e+t-r,n=Math.abs(o-e),i=Math.abs(o-t),s=Math.abs(o-r);return n<=i&&n<=s?e:i<=s?t:r}function Le(e){let{width:t,height:r,data:o}=e,n=t*r,i=new Map,s=[];for(let m=0;m<n&&s.length<=256;m++){let d=(o[m*4]<<24|o[m*4+1]<<16|o[m*4+2]<<8|o[m*4+3])>>>0;i.has(d)||(i.set(d,s.length),s.push(d))}let a=s.length<=256,c=new Uint8Array(13);yc(c,0,t),yc(c,4,r),c[8]=8,c[9]=a?3:6;let l=[Uint8Array.from([137,80,78,71,13,10,26,10]),am("IHDR",c)],u;if(a){let m=new Uint8Array(s.length*3),d=new Uint8Array(s.length);s.forEach((p,h)=>{m[h*3]=p>>>24,m[h*3+1]=p>>>16&255,m[h*3+2]=p>>>8&255,d[h]=p&255}),l.push(am("PLTE",m));let f=-1;d.forEach((p,h)=>{p!==255&&(f=h)}),f>=0&&l.push(am("tRNS",d.slice(0,f+1))),u=new Uint8Array(r*(t+1));for(let p=0;p<r;p++){u[p*(t+1)]=0;for(let h=0;h<t;h++){let g=(p*t+h)*4,b=(o[g]<<24|o[g+1]<<16|o[g+2]<<8|o[g+3])>>>0;u[p*(t+1)+1+h]=i.get(b)}}}else{let m=t*4;u=new Uint8Array(r*(m+1));let d=[0,1,2,3,4].map(()=>new Uint8Array(m));for(let f=0;f<r;f++){let p=f*m;for(let b=0;b<m;b++){let y=o[p+b],w=b>=4?o[p+b-4]:0,v=f>0?o[p-m+b]:0,S=b>=4&&f>0?o[p-m+b-4]:0;d[0][b]=y,d[1][b]=y-w&255,d[2][b]=y-v&255,d[3][b]=y-(w+v>>1)&255,d[4][b]=y-X3(w,v,S)&255}let h=0,g=1/0;d.forEach((b,y)=>{let w=0;for(let v=0;v<m;v++)w+=b[v]<128?b[v]:256-b[v];w<g&&(g=w,h=y)}),u[f*(m+1)]=h,u.set(d[h],f*(m+1)+1)}}return l.push(am("IDAT",CS(u)),am("IEND",new Uint8Array(0))),Y3(l)}var AS="#ff0000";function go(e){let t=String.fromCodePoint(e);return/^[A-Za-z0-9]$/.test(t)?t:`U+${e.toString(16).toUpperCase().padStart(4,"0")}`}function mT(e){let t=[];for(let r=0;r<e.length;){let o=r;for(;o+1<e.length&&e[o+1]===e[o]+1;)o++;t.push(o>r?`${e[r]}-${e[o]}`:String(e[r])),r=o+1}return t.join(",")}function cm(e,t){if(t){let n=[...e].map(i=>i.codePointAt(0));return n.length?n:"chars= is empty"}let r=n=>{if(/^\d+$/.test(n))return Number(n);let i=/^U\+([0-9A-Fa-f]{1,6})$/.exec(n);return i?parseInt(i[1],16):null},o=[];for(let n of e.split(",")){let i=/^([^-]+)-([^-]+)$/.exec(n),s=r(i?i[1]:n),a=i?r(i[2]):s;if(s===null||a===null||a<s||a>1114111)return`chars=: '${n}' is not a code point or a range a-b (decimal or U+hex)`;for(let c=s;c<=a;c++)o.push(c)}return new Set(o).size!==o.length?"chars=: a code point is listed twice":o.length>4096?"chars=: at most 4096 glyphs":o}function ny(e,t){let r=e.font.cols;return[t%r*e.cellW,Math.floor(t/r)*e.cellH]}function ry(e,t,r=0,o){let n=o??be(e,r),[i,s]=ny(e,t),a=new Uint16Array(e.cellW*e.cellH);for(let c=0;c<e.cellH;c++)for(let l=0;l<e.cellW;l++)a[c*e.cellW+l]=n[(s+c)*e.width+i+l];return a}function dT(e,t,r){let o=t,n=r,i=-1,s=-1;for(let a=0;a<r;a++)for(let c=0;c<t;c++)e[a*t+c]!==65535&&(c<o&&(o=c),c>i&&(i=c),a<n&&(n=a),a>s&&(s=a));return i<0?null:[o,n,i,s]}function Q3(e,t,r){let o=e.font,n=o.chars[t];if(o.advances[n]!==void 0)return o.advances[n];let i=dT(ry(e,t,0,r),e.cellW,e.cellH);return i?i[2]+1:Math.ceil(e.cellW/2)}function oy(e){let t=be(e,0);return e.font.chars.map((r,o)=>({cp:r,cell:ny(e,o),advance:Q3(e,o,t),box:dT(ry(e,o,0,t),e.cellW,e.cellH)}))}var ho=class extends Error{};function iy(e,t,r=AS){if(!e.font)throw new ho(`'${e.name}' is not a font`);let o=it(r),n=t.map(it),i=oy(e),s=be(e,0),a=1+i.reduce((d,f)=>d+f.advance+1,0),c=e.cellH,l=ut(a,c),u=d=>{for(let f=0;f<c;f++)l.data.set([o[0],o[1],o[2],255],(f*a+d)*4)};u(0);let m=1;return i.forEach((d,f)=>{let p=ry(e,f,0,s);for(let h=0;h<c;h++)for(let g=0;g<Math.min(d.advance,e.cellW);g++){let b=p[h*e.cellW+g];if(b===65535)continue;let y=n[b];if(y[0]===o[0]&&y[1]===o[1]&&y[2]===o[2])throw new ho(`${e.name}: glyph ${go(d.cp)} uses the separator colour ${r} at ${d.cell[0]+g},${d.cell[1]+h}`);l.data.set([y[0],y[1],y[2],255],(h*a+m+g)*4)}m+=d.advance,u(m),m++}),{img:l,chars:e.font.chars.map(d=>String.fromCodePoint(d)).join("")}}function sy(e,t,r,o=256){if(!e.font)throw new ho(`'${e.name}' is not a font`);let n=e.font,i=t.map(it),s=oy(e),a=be(e,0),c=[],l=0,u=0,m=0,d=0;for(let y of s){if(!y.box){c.push(null);continue}let w=y.box[2]-y.box[0]+1,v=y.box[3]-y.box[1]+1;l>0&&l+w>o&&(l=0,u+=m+1,m=0),c.push([l,u]),l+=w+1,m=Math.max(m,v),d=Math.max(d,l-1)}let f=u+m,p=Math.max(1,d),h=Math.max(1,f),g=ut(p,h),b=[`info face="${e.name}" size=${e.cellH} bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=1 padding=0,0,0,0 spacing=1,1 outline=0`,`common lineHeight=${n.line} base=${n.baseline+1} scaleW=${p} scaleH=${h} pages=1 packed=0 alphaChnl=0 redChnl=0 greenChnl=0 blueChnl=0`,`page id=0 file="${r}"`,`chars count=${s.length}`];return s.forEach((y,w)=>{let v=c[w];if(!v||!y.box){b.push(`char id=${y.cp} x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=${y.advance+n.spacing} page=0 chnl=15`);return}let[S,_,$,x]=y.box,k=ry(e,w,0,a);for(let P=_;P<=x;P++)for(let I=S;I<=$;I++){let E=k[P*e.cellW+I];if(E===65535)continue;let N=i[E];g.data.set([N[0],N[1],N[2],255],((v[1]+P-_)*p+v[0]+I-S)*4)}b.push(`char id=${y.cp} x=${v[0]} y=${v[1]} width=${$-S+1} height=${x-_+1} xoffset=${S} yoffset=${_} xadvance=${y.advance+n.spacing} page=0 chnl=15`)}),b.push("kernings count=0"),{fnt:b.join(`
121
+ `)+`
122
+ `,img:g}}function OS(e,t,r){let o=(1-Math.abs(2*r-1))*t,n=(e%360+360)%360/60,i=o*(1-Math.abs(n%2-1)),[s,a,c]=n<1?[o,i,0]:n<2?[i,o,0]:n<3?[0,o,i]:n<4?[0,i,o]:n<5?[i,0,o]:[o,0,i],l=r-o/2;return"#"+[s,a,c].map(u=>Math.round((u+l)*255).toString(16).padStart(2,"0")).join("")}function lm(e,t,r,o,n){return{name:e,colours:{black:"#000000",white:"#ffffff",light:OS(t,n,.6),dark:OS(r,n,.5),darkest:OS(o,n,.4)}}}var fT=[{name:"grey",colours:{...gc}},lm("moss",95,115,140,.45),lm("ember",38,18,352,.65),lm("tide",185,205,228,.5),lm("dusk",290,265,240,.35),lm("sand",48,32,18,.5)];function pT(e,t){let r={...gc};for(let[o,n]of Object.entries(t)){if(!Ht.includes(o))throw new Error(`theme '${e}': unknown role '${o}' (roles: ${Ht.join(", ")})`);let i=typeof n=="string"?di(n):null;if(!i)throw new Error(`theme '${e}': ${o} must be a colour like #a4552e`);r[o]=i}return{name:e,colours:r}}function NS(e,t){return!t||!e.entries.some(r=>r.role)?e:{...e,entries:e.entries.map(r=>r.role?{...r,hex:t.colours[r.role]}:r)}}function hT(e){return e.entries.some(t=>t.role)}var gT={name:"blob47",description:"8 neighbours with the corner rule (a diagonal counts only when both sides next to it are the same terrain): 47 variants",neighbours:"8",cornerRule:!0,columns:8,pieces:["o","nesw","ew","ns","nesw_ne_se_sw_nw"],variants:[{name:"o",key:0,quads:["outer","outer","outer","outer"]},{name:"n",key:1,quads:["vert","vert","outer","outer"]},{name:"e",key:4,quads:["outer","horiz","outer","horiz"]},{name:"ne",key:5,quads:["vert","inner","outer","horiz"]},{name:"ne_ne",key:7,quads:["vert","in","outer","horiz"]},{name:"s",key:16,quads:["outer","outer","vert","vert"]},{name:"ns",key:17,quads:["vert","vert","vert","vert"]},{name:"es",key:20,quads:["outer","horiz","vert","inner"]},{name:"nes",key:21,quads:["vert","inner","vert","inner"]},{name:"nes_ne",key:23,quads:["vert","in","vert","inner"]},{name:"es_se",key:28,quads:["outer","horiz","vert","in"]},{name:"nes_se",key:29,quads:["vert","inner","vert","in"]},{name:"nes_ne_se",key:31,quads:["vert","in","vert","in"]},{name:"w",key:64,quads:["horiz","outer","horiz","outer"]},{name:"nw",key:65,quads:["inner","vert","horiz","outer"]},{name:"ew",key:68,quads:["horiz","horiz","horiz","horiz"]},{name:"new",key:69,quads:["inner","inner","horiz","horiz"]},{name:"new_ne",key:71,quads:["inner","in","horiz","horiz"]},{name:"sw",key:80,quads:["horiz","outer","inner","vert"]},{name:"nsw",key:81,quads:["inner","vert","inner","vert"]},{name:"esw",key:84,quads:["horiz","horiz","inner","inner"]},{name:"nesw",key:85,quads:["inner","inner","inner","inner"]},{name:"nesw_ne",key:87,quads:["inner","in","inner","inner"]},{name:"esw_se",key:92,quads:["horiz","horiz","inner","in"]},{name:"nesw_se",key:93,quads:["inner","inner","inner","in"]},{name:"nesw_ne_se",key:95,quads:["inner","in","inner","in"]},{name:"sw_sw",key:112,quads:["horiz","outer","in","vert"]},{name:"nsw_sw",key:113,quads:["inner","vert","in","vert"]},{name:"esw_sw",key:116,quads:["horiz","horiz","in","inner"]},{name:"nesw_sw",key:117,quads:["inner","inner","in","inner"]},{name:"nesw_ne_sw",key:119,quads:["inner","in","in","inner"]},{name:"esw_se_sw",key:124,quads:["horiz","horiz","in","in"]},{name:"nesw_se_sw",key:125,quads:["inner","inner","in","in"]},{name:"nesw_ne_se_sw",key:127,quads:["inner","in","in","in"]},{name:"nw_nw",key:193,quads:["in","vert","horiz","outer"]},{name:"new_nw",key:197,quads:["in","inner","horiz","horiz"]},{name:"new_ne_nw",key:199,quads:["in","in","horiz","horiz"]},{name:"nsw_nw",key:209,quads:["in","vert","inner","vert"]},{name:"nesw_nw",key:213,quads:["in","inner","inner","inner"]},{name:"nesw_ne_nw",key:215,quads:["in","in","inner","inner"]},{name:"nesw_se_nw",key:221,quads:["in","inner","inner","in"]},{name:"nesw_ne_se_nw",key:223,quads:["in","in","inner","in"]},{name:"nsw_sw_nw",key:241,quads:["in","vert","in","vert"]},{name:"nesw_sw_nw",key:245,quads:["in","inner","in","inner"]},{name:"nesw_ne_sw_nw",key:247,quads:["in","in","in","inner"]},{name:"nesw_se_sw_nw",key:253,quads:["in","inner","in","in"]},{name:"nesw_ne_se_sw_nw",key:255,quads:["in","in","in","in"]}]};var yT={name:"blob47-round",description:"blob47 with rounder inner corners: edges bend into each inner corner and the cell outside it rounds it off (161 variants + 15 fillets; family band fillet=<px>)",neighbours:"8",cornerRule:"either",fillets:!0,columns:8,pieces:["o","nesw","ew","ns","nesw_ne_se_sw_nw","ns_ne_se_sw_nw","ew_ne_se_sw_nw","f_ne_se_sw_nw"],variants:[{name:"o",key:0,quads:["outer","outer","outer","outer"]},{name:"n",key:1,quads:["vert","vert","outer","outer"]},{name:"n_ne",key:3,quads:["vert","vround","outer","outer"]},{name:"e",key:4,quads:["outer","horiz","outer","horiz"]},{name:"ne",key:5,quads:["vert","inner","outer","horiz"]},{name:"e_ne",key:6,quads:["outer","hround","outer","horiz"]},{name:"ne_ne",key:7,quads:["vert","in","outer","horiz"]},{name:"e_se",key:12,quads:["outer","horiz","outer","hround"]},{name:"ne_se",key:13,quads:["vert","inner","outer","hround"]},{name:"e_ne_se",key:14,quads:["outer","hround","outer","hround"]},{name:"ne_ne_se",key:15,quads:["vert","in","outer","hround"]},{name:"s",key:16,quads:["outer","outer","vert","vert"]},{name:"ns",key:17,quads:["vert","vert","vert","vert"]},{name:"ns_ne",key:19,quads:["vert","vround","vert","vert"]},{name:"es",key:20,quads:["outer","horiz","vert","inner"]},{name:"nes",key:21,quads:["vert","inner","vert","inner"]},{name:"es_ne",key:22,quads:["outer","hround","vert","inner"]},{name:"nes_ne",key:23,quads:["vert","in","vert","inner"]},{name:"s_se",key:24,quads:["outer","outer","vert","vround"]},{name:"ns_se",key:25,quads:["vert","vert","vert","vround"]},{name:"ns_ne_se",key:27,quads:["vert","vround","vert","vround"]},{name:"es_se",key:28,quads:["outer","horiz","vert","in"]},{name:"nes_se",key:29,quads:["vert","inner","vert","in"]},{name:"es_ne_se",key:30,quads:["outer","hround","vert","in"]},{name:"nes_ne_se",key:31,quads:["vert","in","vert","in"]},{name:"s_sw",key:48,quads:["outer","outer","vround","vert"]},{name:"ns_sw",key:49,quads:["vert","vert","vround","vert"]},{name:"ns_ne_sw",key:51,quads:["vert","vround","vround","vert"]},{name:"es_sw",key:52,quads:["outer","horiz","vround","inner"]},{name:"nes_sw",key:53,quads:["vert","inner","vround","inner"]},{name:"es_ne_sw",key:54,quads:["outer","hround","vround","inner"]},{name:"nes_ne_sw",key:55,quads:["vert","in","vround","inner"]},{name:"s_se_sw",key:56,quads:["outer","outer","vround","vround"]},{name:"ns_se_sw",key:57,quads:["vert","vert","vround","vround"]},{name:"ns_ne_se_sw",key:59,quads:["vert","vround","vround","vround"]},{name:"es_se_sw",key:60,quads:["outer","horiz","vround","in"]},{name:"nes_se_sw",key:61,quads:["vert","inner","vround","in"]},{name:"es_ne_se_sw",key:62,quads:["outer","hround","vround","in"]},{name:"nes_ne_se_sw",key:63,quads:["vert","in","vround","in"]},{name:"w",key:64,quads:["horiz","outer","horiz","outer"]},{name:"nw",key:65,quads:["inner","vert","horiz","outer"]},{name:"nw_ne",key:67,quads:["inner","vround","horiz","outer"]},{name:"ew",key:68,quads:["horiz","horiz","horiz","horiz"]},{name:"new",key:69,quads:["inner","inner","horiz","horiz"]},{name:"ew_ne",key:70,quads:["horiz","hround","horiz","horiz"]},{name:"new_ne",key:71,quads:["inner","in","horiz","horiz"]},{name:"ew_se",key:76,quads:["horiz","horiz","horiz","hround"]},{name:"new_se",key:77,quads:["inner","inner","horiz","hround"]},{name:"ew_ne_se",key:78,quads:["horiz","hround","horiz","hround"]},{name:"new_ne_se",key:79,quads:["inner","in","horiz","hround"]},{name:"sw",key:80,quads:["horiz","outer","inner","vert"]},{name:"nsw",key:81,quads:["inner","vert","inner","vert"]},{name:"nsw_ne",key:83,quads:["inner","vround","inner","vert"]},{name:"esw",key:84,quads:["horiz","horiz","inner","inner"]},{name:"nesw",key:85,quads:["inner","inner","inner","inner"]},{name:"esw_ne",key:86,quads:["horiz","hround","inner","inner"]},{name:"nesw_ne",key:87,quads:["inner","in","inner","inner"]},{name:"sw_se",key:88,quads:["horiz","outer","inner","vround"]},{name:"nsw_se",key:89,quads:["inner","vert","inner","vround"]},{name:"nsw_ne_se",key:91,quads:["inner","vround","inner","vround"]},{name:"esw_se",key:92,quads:["horiz","horiz","inner","in"]},{name:"nesw_se",key:93,quads:["inner","inner","inner","in"]},{name:"esw_ne_se",key:94,quads:["horiz","hround","inner","in"]},{name:"nesw_ne_se",key:95,quads:["inner","in","inner","in"]},{name:"w_sw",key:96,quads:["horiz","outer","hround","outer"]},{name:"nw_sw",key:97,quads:["inner","vert","hround","outer"]},{name:"nw_ne_sw",key:99,quads:["inner","vround","hround","outer"]},{name:"ew_sw",key:100,quads:["horiz","horiz","hround","horiz"]},{name:"new_sw",key:101,quads:["inner","inner","hround","horiz"]},{name:"ew_ne_sw",key:102,quads:["horiz","hround","hround","horiz"]},{name:"new_ne_sw",key:103,quads:["inner","in","hround","horiz"]},{name:"ew_se_sw",key:108,quads:["horiz","horiz","hround","hround"]},{name:"new_se_sw",key:109,quads:["inner","inner","hround","hround"]},{name:"ew_ne_se_sw",key:110,quads:["horiz","hround","hround","hround"]},{name:"new_ne_se_sw",key:111,quads:["inner","in","hround","hround"]},{name:"sw_sw",key:112,quads:["horiz","outer","in","vert"]},{name:"nsw_sw",key:113,quads:["inner","vert","in","vert"]},{name:"nsw_ne_sw",key:115,quads:["inner","vround","in","vert"]},{name:"esw_sw",key:116,quads:["horiz","horiz","in","inner"]},{name:"nesw_sw",key:117,quads:["inner","inner","in","inner"]},{name:"esw_ne_sw",key:118,quads:["horiz","hround","in","inner"]},{name:"nesw_ne_sw",key:119,quads:["inner","in","in","inner"]},{name:"sw_se_sw",key:120,quads:["horiz","outer","in","vround"]},{name:"nsw_se_sw",key:121,quads:["inner","vert","in","vround"]},{name:"nsw_ne_se_sw",key:123,quads:["inner","vround","in","vround"]},{name:"esw_se_sw",key:124,quads:["horiz","horiz","in","in"]},{name:"nesw_se_sw",key:125,quads:["inner","inner","in","in"]},{name:"esw_ne_se_sw",key:126,quads:["horiz","hround","in","in"]},{name:"nesw_ne_se_sw",key:127,quads:["inner","in","in","in"]},{name:"n_nw",key:129,quads:["vround","vert","outer","outer"]},{name:"n_ne_nw",key:131,quads:["vround","vround","outer","outer"]},{name:"ne_nw",key:133,quads:["vround","inner","outer","horiz"]},{name:"ne_ne_nw",key:135,quads:["vround","in","outer","horiz"]},{name:"ne_se_nw",key:141,quads:["vround","inner","outer","hround"]},{name:"ne_ne_se_nw",key:143,quads:["vround","in","outer","hround"]},{name:"ns_nw",key:145,quads:["vround","vert","vert","vert"]},{name:"ns_ne_nw",key:147,quads:["vround","vround","vert","vert"]},{name:"nes_nw",key:149,quads:["vround","inner","vert","inner"]},{name:"nes_ne_nw",key:151,quads:["vround","in","vert","inner"]},{name:"ns_se_nw",key:153,quads:["vround","vert","vert","vround"]},{name:"ns_ne_se_nw",key:155,quads:["vround","vround","vert","vround"]},{name:"nes_se_nw",key:157,quads:["vround","inner","vert","in"]},{name:"nes_ne_se_nw",key:159,quads:["vround","in","vert","in"]},{name:"ns_sw_nw",key:177,quads:["vround","vert","vround","vert"]},{name:"ns_ne_sw_nw",key:179,quads:["vround","vround","vround","vert"]},{name:"nes_sw_nw",key:181,quads:["vround","inner","vround","inner"]},{name:"nes_ne_sw_nw",key:183,quads:["vround","in","vround","inner"]},{name:"ns_se_sw_nw",key:185,quads:["vround","vert","vround","vround"]},{name:"ns_ne_se_sw_nw",key:187,quads:["vround","vround","vround","vround"]},{name:"nes_se_sw_nw",key:189,quads:["vround","inner","vround","in"]},{name:"nes_ne_se_sw_nw",key:191,quads:["vround","in","vround","in"]},{name:"w_nw",key:192,quads:["hround","outer","horiz","outer"]},{name:"nw_nw",key:193,quads:["in","vert","horiz","outer"]},{name:"nw_ne_nw",key:195,quads:["in","vround","horiz","outer"]},{name:"ew_nw",key:196,quads:["hround","horiz","horiz","horiz"]},{name:"new_nw",key:197,quads:["in","inner","horiz","horiz"]},{name:"ew_ne_nw",key:198,quads:["hround","hround","horiz","horiz"]},{name:"new_ne_nw",key:199,quads:["in","in","horiz","horiz"]},{name:"ew_se_nw",key:204,quads:["hround","horiz","horiz","hround"]},{name:"new_se_nw",key:205,quads:["in","inner","horiz","hround"]},{name:"ew_ne_se_nw",key:206,quads:["hround","hround","horiz","hround"]},{name:"new_ne_se_nw",key:207,quads:["in","in","horiz","hround"]},{name:"sw_nw",key:208,quads:["hround","outer","inner","vert"]},{name:"nsw_nw",key:209,quads:["in","vert","inner","vert"]},{name:"nsw_ne_nw",key:211,quads:["in","vround","inner","vert"]},{name:"esw_nw",key:212,quads:["hround","horiz","inner","inner"]},{name:"nesw_nw",key:213,quads:["in","inner","inner","inner"]},{name:"esw_ne_nw",key:214,quads:["hround","hround","inner","inner"]},{name:"nesw_ne_nw",key:215,quads:["in","in","inner","inner"]},{name:"sw_se_nw",key:216,quads:["hround","outer","inner","vround"]},{name:"nsw_se_nw",key:217,quads:["in","vert","inner","vround"]},{name:"nsw_ne_se_nw",key:219,quads:["in","vround","inner","vround"]},{name:"esw_se_nw",key:220,quads:["hround","horiz","inner","in"]},{name:"nesw_se_nw",key:221,quads:["in","inner","inner","in"]},{name:"esw_ne_se_nw",key:222,quads:["hround","hround","inner","in"]},{name:"nesw_ne_se_nw",key:223,quads:["in","in","inner","in"]},{name:"w_sw_nw",key:224,quads:["hround","outer","hround","outer"]},{name:"nw_sw_nw",key:225,quads:["in","vert","hround","outer"]},{name:"nw_ne_sw_nw",key:227,quads:["in","vround","hround","outer"]},{name:"ew_sw_nw",key:228,quads:["hround","horiz","hround","horiz"]},{name:"new_sw_nw",key:229,quads:["in","inner","hround","horiz"]},{name:"ew_ne_sw_nw",key:230,quads:["hround","hround","hround","horiz"]},{name:"new_ne_sw_nw",key:231,quads:["in","in","hround","horiz"]},{name:"ew_se_sw_nw",key:236,quads:["hround","horiz","hround","hround"]},{name:"new_se_sw_nw",key:237,quads:["in","inner","hround","hround"]},{name:"ew_ne_se_sw_nw",key:238,quads:["hround","hround","hround","hround"]},{name:"new_ne_se_sw_nw",key:239,quads:["in","in","hround","hround"]},{name:"sw_sw_nw",key:240,quads:["hround","outer","in","vert"]},{name:"nsw_sw_nw",key:241,quads:["in","vert","in","vert"]},{name:"nsw_ne_sw_nw",key:243,quads:["in","vround","in","vert"]},{name:"esw_sw_nw",key:244,quads:["hround","horiz","in","inner"]},{name:"nesw_sw_nw",key:245,quads:["in","inner","in","inner"]},{name:"esw_ne_sw_nw",key:246,quads:["hround","hround","in","inner"]},{name:"nesw_ne_sw_nw",key:247,quads:["in","in","in","inner"]},{name:"sw_se_sw_nw",key:248,quads:["hround","outer","in","vround"]},{name:"nsw_se_sw_nw",key:249,quads:["in","vert","in","vround"]},{name:"nsw_ne_se_sw_nw",key:251,quads:["in","vround","in","vround"]},{name:"esw_se_sw_nw",key:252,quads:["hround","horiz","in","in"]},{name:"nesw_se_sw_nw",key:253,quads:["in","inner","in","in"]},{name:"esw_ne_se_sw_nw",key:254,quads:["hround","hround","in","in"]},{name:"nesw_ne_se_sw_nw",key:255,quads:["in","in","in","in"]},{name:"f_ne",key:2,quads:["out","fillet","out","out"],on:"fillet"},{name:"f_se",key:8,quads:["out","out","out","fillet"],on:"fillet"},{name:"f_ne_se",key:10,quads:["out","fillet","out","fillet"],on:"fillet"},{name:"f_sw",key:32,quads:["out","out","fillet","out"],on:"fillet"},{name:"f_ne_sw",key:34,quads:["out","fillet","fillet","out"],on:"fillet"},{name:"f_se_sw",key:40,quads:["out","out","fillet","fillet"],on:"fillet"},{name:"f_ne_se_sw",key:42,quads:["out","fillet","fillet","fillet"],on:"fillet"},{name:"f_nw",key:128,quads:["fillet","out","out","out"],on:"fillet"},{name:"f_ne_nw",key:130,quads:["fillet","fillet","out","out"],on:"fillet"},{name:"f_se_nw",key:136,quads:["fillet","out","out","fillet"],on:"fillet"},{name:"f_ne_se_nw",key:138,quads:["fillet","fillet","out","fillet"],on:"fillet"},{name:"f_sw_nw",key:160,quads:["fillet","out","fillet","out"],on:"fillet"},{name:"f_ne_sw_nw",key:162,quads:["fillet","fillet","fillet","out"],on:"fillet"},{name:"f_se_sw_nw",key:168,quads:["fillet","out","fillet","fillet"],on:"fillet"},{name:"f_ne_se_sw_nw",key:170,quads:["fillet","fillet","fillet","fillet"],on:"fillet"}]};var bT={name:"bridge8",description:"a deck joined along one axis (east-west wins when both): single, the two ends and the middle of each axis: 8 variants. A tile with no bridge beside it is the east-west single; the north-south single is placed by name",neighbours:"axis",inset:[1,4],kinds:{endh:"horiz",endv:"vert"},columns:4,pieces:["h","h_ew","v","v_ns"],variants:[{name:"h",key:0,quads:["endh","endh","endh","endh"]},{name:"h_e",key:4,quads:["endh","horiz","endh","horiz"]},{name:"h_ew",key:68,quads:["horiz","horiz","horiz","horiz"]},{name:"h_w",key:64,quads:["horiz","endh","horiz","endh"]},{name:"v",key:null,quads:["endv","endv","endv","endv"]},{name:"v_s",key:16,quads:["endv","endv","vert","vert"]},{name:"v_ns",key:17,quads:["vert","vert","vert","vert"]},{name:"v_n",key:1,quads:["vert","vert","endv","endv"]}]};var wT={name:"face",description:"blob47 and a cliff's faces in the cells around it: south faces below the terrain (ends, joins, inner corners), side faces beside its east and west edges, corners where they meet, and alternate looks of the long middles: 47 + 28 variants",neighbours:"8",cornerRule:!0,columns:8,pieces:["o","nesw","ew","ns","nesw_ne_se_sw_nw","face_o","face_ew","face_ie_iw","side_e","side_e_ns","side_w","side_w_ns","corner_ew"],faces:!0,sides:!0,kinds:{faceend:"out",facemid:"out",faceinner:"out",sidetop:"out",sidemid:"out",sidebot:"out",cornere:"out",cornerw:"out"},variants:[{name:"o",key:0,quads:["outer","outer","outer","outer"]},{name:"n",key:1,quads:["vert","vert","outer","outer"]},{name:"e",key:4,quads:["outer","horiz","outer","horiz"]},{name:"ne",key:5,quads:["vert","inner","outer","horiz"]},{name:"ne_ne",key:7,quads:["vert","in","outer","horiz"]},{name:"s",key:16,quads:["outer","outer","vert","vert"]},{name:"ns",key:17,quads:["vert","vert","vert","vert"]},{name:"es",key:20,quads:["outer","horiz","vert","inner"]},{name:"nes",key:21,quads:["vert","inner","vert","inner"]},{name:"nes_ne",key:23,quads:["vert","in","vert","inner"]},{name:"es_se",key:28,quads:["outer","horiz","vert","in"]},{name:"nes_se",key:29,quads:["vert","inner","vert","in"]},{name:"nes_ne_se",key:31,quads:["vert","in","vert","in"]},{name:"w",key:64,quads:["horiz","outer","horiz","outer"]},{name:"nw",key:65,quads:["inner","vert","horiz","outer"]},{name:"ew",key:68,quads:["horiz","horiz","horiz","horiz"]},{name:"new",key:69,quads:["inner","inner","horiz","horiz"]},{name:"new_ne",key:71,quads:["inner","in","horiz","horiz"]},{name:"sw",key:80,quads:["horiz","outer","inner","vert"]},{name:"nsw",key:81,quads:["inner","vert","inner","vert"]},{name:"esw",key:84,quads:["horiz","horiz","inner","inner"]},{name:"nesw",key:85,quads:["inner","inner","inner","inner"]},{name:"nesw_ne",key:87,quads:["inner","in","inner","inner"]},{name:"esw_se",key:92,quads:["horiz","horiz","inner","in"]},{name:"nesw_se",key:93,quads:["inner","inner","inner","in"]},{name:"nesw_ne_se",key:95,quads:["inner","in","inner","in"]},{name:"sw_sw",key:112,quads:["horiz","outer","in","vert"]},{name:"nsw_sw",key:113,quads:["inner","vert","in","vert"]},{name:"esw_sw",key:116,quads:["horiz","horiz","in","inner"]},{name:"nesw_sw",key:117,quads:["inner","inner","in","inner"]},{name:"nesw_ne_sw",key:119,quads:["inner","in","in","inner"]},{name:"esw_se_sw",key:124,quads:["horiz","horiz","in","in"]},{name:"nesw_se_sw",key:125,quads:["inner","inner","in","in"]},{name:"nesw_ne_se_sw",key:127,quads:["inner","in","in","in"]},{name:"nw_nw",key:193,quads:["in","vert","horiz","outer"]},{name:"new_nw",key:197,quads:["in","inner","horiz","horiz"]},{name:"new_ne_nw",key:199,quads:["in","in","horiz","horiz"]},{name:"nsw_nw",key:209,quads:["in","vert","inner","vert"]},{name:"nesw_nw",key:213,quads:["in","inner","inner","inner"]},{name:"nesw_ne_nw",key:215,quads:["in","in","inner","inner"]},{name:"nesw_se_nw",key:221,quads:["in","inner","inner","in"]},{name:"nesw_ne_se_nw",key:223,quads:["in","in","inner","in"]},{name:"nsw_sw_nw",key:241,quads:["in","vert","in","vert"]},{name:"nesw_sw_nw",key:245,quads:["in","inner","in","inner"]},{name:"nesw_ne_sw_nw",key:247,quads:["in","in","in","inner"]},{name:"nesw_se_sw_nw",key:253,quads:["in","inner","in","in"]},{name:"nesw_ne_se_sw_nw",key:255,quads:["in","in","in","in"]},{name:"face_o",key:0,quads:["faceend","faceend","faceend","faceend"],on:"face"},{name:"face_e",key:4,quads:["faceend","facemid","faceend","facemid"],on:"face"},{name:"face_ew",key:68,quads:["facemid","facemid","facemid","facemid"],on:"face"},{name:"face_w",key:64,quads:["facemid","faceend","facemid","faceend"],on:"face"},{name:"face_ie",key:8,quads:["faceend","faceinner","faceend","faceinner"],on:"face"},{name:"face_iw",key:32,quads:["faceinner","faceend","faceinner","faceend"],on:"face"},{name:"face_e_iw",key:36,quads:["faceinner","facemid","faceinner","facemid"],on:"face"},{name:"face_ie_iw",key:40,quads:["faceinner","faceinner","faceinner","faceinner"],on:"face"},{name:"face_ie_w",key:72,quads:["facemid","faceinner","facemid","faceinner"],on:"face"},{name:"side_e",key:64,quads:["sidetop@nw","out","sidebot@sw","out"],on:"side"},{name:"side_e_n",key:65,quads:["sidemid@nw","out","sidebot@sw","out"],on:"side"},{name:"side_e_s",key:80,quads:["sidetop@nw","out","sidemid@sw","out"],on:"side"},{name:"side_e_ns",key:81,quads:["sidemid@nw","out","sidemid@sw","out"],on:"side"},{name:"side_w",key:4,quads:["out","sidetop@ne","out","sidebot@se"],on:"side"},{name:"side_w_n",key:5,quads:["out","sidemid@ne","out","sidebot@se"],on:"side"},{name:"side_w_s",key:20,quads:["out","sidetop@ne","out","sidemid@se"],on:"side"},{name:"side_w_ns",key:21,quads:["out","sidemid@ne","out","sidemid@se"],on:"side"},{name:"side_ew",key:68,quads:["sidetop@nw","sidetop@ne","sidebot@sw","sidebot@se"],on:"side"},{name:"side_ew_n",key:69,quads:["sidemid@nw","sidemid@ne","sidebot@sw","sidebot@se"],on:"side"},{name:"side_ew_s",key:84,quads:["sidetop@nw","sidetop@ne","sidemid@sw","sidemid@se"],on:"side"},{name:"side_ew_ns",key:85,quads:["sidemid@nw","sidemid@ne","sidemid@sw","sidemid@se"],on:"side"},{name:"corner_e",key:128,quads:["cornere","out","out","out"],on:"corner"},{name:"corner_w",key:2,quads:["out","cornerw","out","out"],on:"corner"},{name:"corner_ew",key:130,quads:["cornere","cornerw","out","out"],on:"corner"},{name:"face_ew_b",key:null,quads:["facemid","facemid","facemid","facemid"],on:"face",alt:"face_ew"},{name:"face_ew_c",key:null,quads:["facemid","facemid","facemid","facemid"],on:"face",alt:"face_ew"},{name:"side_e_ns_b",key:null,quads:["sidemid@nw","out","sidemid@sw","out"],on:"side",alt:"side_e_ns"},{name:"side_w_ns_b",key:null,quads:["out","sidemid@ne","out","sidemid@se"],on:"side",alt:"side_w_ns"}]};var vT={name:"lane",description:"a path that fills where it is wide (a diagonal counts when both sides next to it are the lane) and turns diagonally (a lone diagonal draws a strip to that corner, and the cells beside it the strip's edge): 82 variants + 15",neighbours:"8",cornerRule:"diagonal",inset:[1,4],columns:8,pieces:["o","nesw","ew","ns","nesw_ne_se_sw_nw","o_ne","o_se","d_ne_se_sw_nw","o_sw","o_nw","n_se","s_ne","n_sw","w_se"],variants:[{name:"o",key:0,quads:["outer","outer","outer","outer"]},{name:"n",key:1,quads:["vert","vert","outer","outer"]},{name:"o_ne",key:2,quads:["diagside","diag","diagcap","diagside"]},{name:"e",key:4,quads:["outer","horiz","outer","horiz"]},{name:"ne",key:5,quads:["vert","inner","outer","horiz"]},{name:"ne_ne",key:7,quads:["vert","in","outer","horiz"]},{name:"o_se",key:8,quads:["diagcap","diagside","diagside","diag"]},{name:"n_se",key:9,quads:["vert","vert","outerdiag","diag"]},{name:"o_ne_se",key:10,quads:["diagside","diag","diagside","diag"]},{name:"s",key:16,quads:["outer","outer","vert","vert"]},{name:"ns",key:17,quads:["vert","vert","vert","vert"]},{name:"s_ne",key:18,quads:["outerdiag","diag","vert","vert"]},{name:"es",key:20,quads:["outer","horiz","vert","inner"]},{name:"nes",key:21,quads:["vert","inner","vert","inner"]},{name:"nes_ne",key:23,quads:["vert","in","vert","inner"]},{name:"es_se",key:28,quads:["outer","horiz","vert","in"]},{name:"nes_se",key:29,quads:["vert","inner","vert","in"]},{name:"nes_ne_se",key:31,quads:["vert","in","vert","in"]},{name:"o_sw",key:32,quads:["diagside","diagcap","diag","diagside"]},{name:"n_sw",key:33,quads:["vert","vert","diag","outerdiag"]},{name:"o_ne_sw",key:34,quads:["diagside","diag","diag","diagside"]},{name:"e_sw",key:36,quads:["outerdiag","horiz","diag","horiz"]},{name:"ne_sw",key:37,quads:["vert","inner","diag","horiz"]},{name:"ne_ne_sw",key:39,quads:["vert","in","diag","horiz"]},{name:"o_se_sw",key:40,quads:["diagside","diagside","diag","diag"]},{name:"n_se_sw",key:41,quads:["vert","vert","diag","diag"]},{name:"o_ne_se_sw",key:42,quads:["diagside","diag","diag","diag"]},{name:"w",key:64,quads:["horiz","outer","horiz","outer"]},{name:"nw",key:65,quads:["inner","vert","horiz","outer"]},{name:"w_ne",key:66,quads:["horiz","diag","horiz","outerdiag"]},{name:"ew",key:68,quads:["horiz","horiz","horiz","horiz"]},{name:"new",key:69,quads:["inner","inner","horiz","horiz"]},{name:"new_ne",key:71,quads:["inner","in","horiz","horiz"]},{name:"w_se",key:72,quads:["horiz","outerdiag","horiz","diag"]},{name:"nw_se",key:73,quads:["inner","vert","horiz","diag"]},{name:"w_ne_se",key:74,quads:["horiz","diag","horiz","diag"]},{name:"sw",key:80,quads:["horiz","outer","inner","vert"]},{name:"nsw",key:81,quads:["inner","vert","inner","vert"]},{name:"sw_ne",key:82,quads:["horiz","diag","inner","vert"]},{name:"esw",key:84,quads:["horiz","horiz","inner","inner"]},{name:"nesw",key:85,quads:["inner","inner","inner","inner"]},{name:"nesw_ne",key:87,quads:["inner","in","inner","inner"]},{name:"esw_se",key:92,quads:["horiz","horiz","inner","in"]},{name:"nesw_se",key:93,quads:["inner","inner","inner","in"]},{name:"nesw_ne_se",key:95,quads:["inner","in","inner","in"]},{name:"sw_sw",key:112,quads:["horiz","outer","in","vert"]},{name:"nsw_sw",key:113,quads:["inner","vert","in","vert"]},{name:"sw_ne_sw",key:114,quads:["horiz","diag","in","vert"]},{name:"esw_sw",key:116,quads:["horiz","horiz","in","inner"]},{name:"nesw_sw",key:117,quads:["inner","inner","in","inner"]},{name:"nesw_ne_sw",key:119,quads:["inner","in","in","inner"]},{name:"esw_se_sw",key:124,quads:["horiz","horiz","in","in"]},{name:"nesw_se_sw",key:125,quads:["inner","inner","in","in"]},{name:"nesw_ne_se_sw",key:127,quads:["inner","in","in","in"]},{name:"o_nw",key:128,quads:["diag","diagside","diagside","diagcap"]},{name:"o_ne_nw",key:130,quads:["diag","diag","diagside","diagside"]},{name:"e_nw",key:132,quads:["diag","horiz","outerdiag","horiz"]},{name:"o_se_nw",key:136,quads:["diag","diagside","diagside","diag"]},{name:"o_ne_se_nw",key:138,quads:["diag","diag","diagside","diag"]},{name:"s_nw",key:144,quads:["diag","outerdiag","vert","vert"]},{name:"s_ne_nw",key:146,quads:["diag","diag","vert","vert"]},{name:"es_nw",key:148,quads:["diag","horiz","vert","inner"]},{name:"es_se_nw",key:156,quads:["diag","horiz","vert","in"]},{name:"o_sw_nw",key:160,quads:["diag","diagside","diag","diagside"]},{name:"o_ne_sw_nw",key:162,quads:["diag","diag","diag","diagside"]},{name:"e_sw_nw",key:164,quads:["diag","horiz","diag","horiz"]},{name:"o_se_sw_nw",key:168,quads:["diag","diagside","diag","diag"]},{name:"o_ne_se_sw_nw",key:170,quads:["diag","diag","diag","diag"]},{name:"nw_nw",key:193,quads:["in","vert","horiz","outer"]},{name:"new_nw",key:197,quads:["in","inner","horiz","horiz"]},{name:"new_ne_nw",key:199,quads:["in","in","horiz","horiz"]},{name:"nw_se_nw",key:201,quads:["in","vert","horiz","diag"]},{name:"nsw_nw",key:209,quads:["in","vert","inner","vert"]},{name:"nesw_nw",key:213,quads:["in","inner","inner","inner"]},{name:"nesw_ne_nw",key:215,quads:["in","in","inner","inner"]},{name:"nesw_se_nw",key:221,quads:["in","inner","inner","in"]},{name:"nesw_ne_se_nw",key:223,quads:["in","in","inner","in"]},{name:"nsw_sw_nw",key:241,quads:["in","vert","in","vert"]},{name:"nesw_sw_nw",key:245,quads:["in","inner","in","inner"]},{name:"nesw_ne_sw_nw",key:247,quads:["in","in","in","inner"]},{name:"nesw_se_sw_nw",key:253,quads:["in","inner","in","in"]},{name:"nesw_ne_se_sw_nw",key:255,quads:["in","in","in","in"]},{name:"d_ne",key:2,quads:["out","diagfill","out","out"],on:"fillet"},{name:"d_se",key:8,quads:["out","out","out","diagfill"],on:"fillet"},{name:"d_ne_se",key:10,quads:["out","diagfill","out","diagfill"],on:"fillet"},{name:"d_sw",key:32,quads:["out","out","diagfill","out"],on:"fillet"},{name:"d_ne_sw",key:34,quads:["out","diagfill","diagfill","out"],on:"fillet"},{name:"d_se_sw",key:40,quads:["out","out","diagfill","diagfill"],on:"fillet"},{name:"d_ne_se_sw",key:42,quads:["out","diagfill","diagfill","diagfill"],on:"fillet"},{name:"d_nw",key:128,quads:["diagfill","out","out","out"],on:"fillet"},{name:"d_ne_nw",key:130,quads:["diagfill","diagfill","out","out"],on:"fillet"},{name:"d_se_nw",key:136,quads:["diagfill","out","out","diagfill"],on:"fillet"},{name:"d_ne_se_nw",key:138,quads:["diagfill","diagfill","out","diagfill"],on:"fillet"},{name:"d_sw_nw",key:160,quads:["diagfill","out","diagfill","out"],on:"fillet"},{name:"d_ne_sw_nw",key:162,quads:["diagfill","diagfill","diagfill","out"],on:"fillet"},{name:"d_se_sw_nw",key:168,quads:["diagfill","out","diagfill","diagfill"],on:"fillet"},{name:"d_ne_se_sw_nw",key:170,quads:["diagfill","diagfill","diagfill","diagfill"],on:"fillet"}]};var $T={name:"path",description:"4 neighbours: a strip through the middle of the tile toward each joined side (roads, rivers, fences): 16 variants",neighbours:"4",inset:[1,4],columns:8,pieces:["o","nesw","ew","ns"],variants:[{name:"o",key:0,quads:["outer","outer","outer","outer"]},{name:"n",key:1,quads:["vert","vert","outer","outer"]},{name:"e",key:4,quads:["outer","horiz","outer","horiz"]},{name:"ne",key:5,quads:["vert","inner","outer","horiz"]},{name:"s",key:16,quads:["outer","outer","vert","vert"]},{name:"ns",key:17,quads:["vert","vert","vert","vert"]},{name:"es",key:20,quads:["outer","horiz","vert","inner"]},{name:"nes",key:21,quads:["vert","inner","vert","inner"]},{name:"w",key:64,quads:["horiz","outer","horiz","outer"]},{name:"nw",key:65,quads:["inner","vert","horiz","outer"]},{name:"ew",key:68,quads:["horiz","horiz","horiz","horiz"]},{name:"new",key:69,quads:["inner","inner","horiz","horiz"]},{name:"sw",key:80,quads:["horiz","outer","inner","vert"]},{name:"nsw",key:81,quads:["inner","vert","inner","vert"]},{name:"esw",key:84,quads:["horiz","horiz","inner","inner"]},{name:"nesw",key:85,quads:["inner","inner","inner","inner"]}]};var xT={name:"single",description:"one tile whatever its neighbours (plain ground, props): 1 variant",neighbours:"none",columns:1,pieces:["o"],variants:[{name:"o",key:0,quads:["in","in","in","in"]}]};var _T={name:"wang16-corner",description:"corner Wang tiles: each of the four corners is in or out, and the edge runs through the middle of the tile: 16 variants",neighbours:"corners",columns:8,pieces:["ne_se_sw_nw","ne_se_sw","ne_se_nw","ne_sw_nw","se_sw_nw","ne_sw","se_nw"],variants:[{name:"o",key:0,quads:["out","out","out","out"]},{name:"ne",key:2,quads:["out","outer@sw","out","out"]},{name:"se",key:8,quads:["out","out","out","outer@nw"]},{name:"ne_se",key:10,quads:["out","vert@sw","out","vert@nw"]},{name:"sw",key:32,quads:["out","out","outer@ne","out"]},{name:"ne_sw",key:34,quads:["out","outer@sw","outer@ne","out"]},{name:"se_sw",key:40,quads:["out","out","horiz@ne","horiz@nw"]},{name:"ne_se_sw",key:42,quads:["out","vert@sw","horiz@ne","inner@nw"]},{name:"nw",key:128,quads:["outer@se","out","out","out"]},{name:"ne_nw",key:130,quads:["horiz@se","horiz@sw","out","out"]},{name:"se_nw",key:136,quads:["outer@se","out","out","outer@nw"]},{name:"ne_se_nw",key:138,quads:["horiz@se","inner@sw","out","vert@nw"]},{name:"sw_nw",key:160,quads:["vert@se","out","vert@ne","out"]},{name:"ne_sw_nw",key:162,quads:["inner@se","horiz@sw","vert@ne","out"]},{name:"se_sw_nw",key:168,quads:["vert@se","out","inner@ne","horiz@nw"]},{name:"ne_se_sw_nw",key:170,quads:["in@se","in@sw","in@ne","in@nw"]}]};var ay=(1n<<64n)-1n,c5=6364136223846793005n,dt=class{state=0n;inc=1n;constructor(t,r=54){this.inc=(BigInt(r)<<1n|1n)&ay,this.state=0n,this.nextU32(),this.state=this.state+(BigInt(t)&ay)&ay,this.nextU32()}nextU32(){let t=this.state;this.state=t*c5+this.inc&ay;let r=Number((t>>18n^t)>>27n&0xffffffffn),o=Number(t>>59n);return(r>>>o|r<<(32-o&31))>>>0}nextInt(t){if(!Number.isInteger(t)||t<=0||t>4294967296)throw new RangeError(`nextInt: bad bound ${t}`);let r=(4294967296-t)%t;for(;;){let o=this.nextU32();if(o>=r)return o%t}}range(t,r){return t+this.nextInt(r-t+1)}};function cy(e){return e.nextU32()%2147483647+1}function ly(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619)>>>0;return t>>>0}var pt={N:1,NE:2,E:4,SE:8,S:16,SW:32,W:64,NW:128},l5=[[1,0,-1],[2,1,-1],[4,1,0],[8,1,1],[16,0,1],[32,-1,1],[64,-1,0],[128,-1,-1]],ST=["in","out","outer","inner","horiz","vert","vround","hround","fillet","diag","diagcap","diagside","outerdiag","diagfill"],u5=["diag","diagcap","diagside","outerdiag","diagfill"],PT=["nw","ne","sw","se"],pi=e=>e==="face"||e==="side"||e==="corner",_r=class extends Error{};function m5(e,t,r){let[o,n]=t.split("@"),i=ST.includes(o)?o:e.kinds?.[o];if(!i||!ST.includes(i))throw new _r(`scheme ${e.name}: unknown quadrant kind '${o}'`);let s=n===void 0?r:PT.indexOf(n);if(s<0)throw new _r(`scheme ${e.name}: '${t}' faces no corner (nw, ne, sw, se)`);return{kind:o,base:i,face:s}}function vs(e){let t=new Map,r=new Map,o=new Map,n=new Map,i=new Map,s=new Map;e.variants.forEach((m,d)=>{if(!/^[a-z][a-z0-9_]*$/.test(m.name))throw new _r(`scheme ${e.name}: '${m.name}' is not a usable variant name`);if(t.has(m.name))throw new _r(`scheme ${e.name}: variant '${m.name}' twice`);if(m.quads.length!==4)throw new _r(`scheme ${e.name}: variant '${m.name}' needs 4 quads`);if(t.set(m.name,d),m.key===null)return;let f=m.on==="face"?o:m.on==="side"?n:m.on==="corner"?i:m.on==="fillet"?s:r;if(f.has(m.key))throw new _r(`scheme ${e.name}: key ${m.key} is both ${e.variants[f.get(m.key)].name} and ${m.name}`);f.set(m.key,d)});let a=e.variants.map(m=>m.quads.map((d,f)=>m5(e,d,f))),c=e.pieces.map(m=>{let d=t.get(m);if(d===void 0)throw new _r(`scheme ${e.name}: piece '${m}' is not a variant`);return d}),l=e.variants.map((m,d)=>c.includes(d)?null:a[d].map((f,p)=>{for(let h of c){let g=a[h].findIndex(b=>b.kind===f.kind&&b.face===f.face);if(g>=0)return[h,g]}if(f.base==="out")return[-1,p];throw new _r(`scheme ${e.name}: no piece has the ${f.kind}@${PT[f.face]} quadrant variant '${m.name}' needs`)})),u=new Map;return e.variants.forEach((m,d)=>{if(!m.alt)return;let f=t.get(m.alt);if(f===void 0)throw new _r(`scheme ${e.name}: '${m.name}' is a look of '${m.alt}', which it does not have`);u.set(f,[...u.get(f)??[f],d])}),{...e,quadSpecs:a,sources:l,byName:t,byKey:r,faceByKey:o,sideByKey:n,cornerByKey:i,filletByKey:s,alts:u}}var yo=new Map([gT,yT,_T,$T,bT,xT,wT,vT].map(e=>[e.name,vs(e)]));function uy(e){return yo.get(e)}function kT(e,t){let{N:r,NE:o,E:n,SE:i,S:s,SW:a,W:c,NW:l}=pt;switch(e.neighbours){case"none":return 0;case"corners":return t&(o|i|a|l);case"4":return t&(r|n|s|c);case"axis":return t&(n|c)?t&(n|c):t&(r|s);case"8":{let u=t&(r|n|s|c);if(!e.cornerRule)return t&255;if(e.cornerRule==="diagonal"){for(let[m,d,f]of[[o,r,n],[i,s,n],[a,s,c],[l,r,c]])t&m&&!!(t&d)==!!(t&f)&&(u|=m);return u}if(e.cornerRule==="either"){for(let[m,d,f]of[[o,r,n],[i,s,n],[a,s,c],[l,r,c]])t&m&&t&(d|f)&&(u|=m);return u}return t&r&&t&n&&t&o&&(u|=o),t&s&&t&n&&t&i&&(u|=i),t&s&&t&c&&t&a&&(u|=a),t&r&&t&c&&t&l&&(u|=l),u}}}function zT(e,t,r){if(e.neighbours==="corners"||t)return e.byKey.get(kT(e,r))??null;if(e.fillets){let{N:m,NE:d,E:f,SE:p,S:h,SW:g,W:b,NW:y}=pt,w=((r&(m|f|d))===(m|f|d)?d:0)|((r&(h|f|p))===(h|f|p)?p:0)|((r&(h|b|g))===(h|b|g)?g:0)|((r&(m|b|y))===(m|b|y)?y:0);return w?e.filletByKey.get(w)??null:null}if(e.cornerRule==="diagonal"){let{N:m,NE:d,E:f,SE:p,S:h,SW:g,W:b,NW:y}=pt,w=((r&(m|f))===(m|f)&&!(r&d)?d:0)|((r&(h|f))===(h|f)&&!(r&p)?p:0)|((r&(h|b))===(h|b)&&!(r&g)?g:0)|((r&(m|b))===(m|b)&&!(r&y)?y:0);return w?e.filletByKey.get(w)??null:null}if(!e.faces)return null;let{N:o,NE:n,E:i,SE:s,S:a,SW:c,W:l,NW:u}=pt;if(r&o){let m=(r&i?s:r&n?i:0)|(r&l?c:r&u?l:0);return e.faceByKey.get(m)??e.faceByKey.get(m&(i|l))??null}if(!e.sides)return null;if(r&(i|l)){let m=r&(i|l)|(r&l&&r&u||r&i&&r&n?o:0)|(r&a?0:a);return e.sideByKey.get(m)??null}return e.cornerByKey.get(r&(n|u))??null}function d5(...e){let t=625341585;for(let r of e)t=Math.imul(t^(r|0),2654435761)>>>0,t=(t^t>>>15)>>>0,t=Math.imul(t,2246822519)>>>0,t=(t^t>>>13)>>>0;return t}function f5(e,t,r,o){if(t===null)return null;let n=e.alts.get(t);return n?n[d5(r,o,64206)%n.length]:t}function bo(e){return e.variants.flatMap((t,r)=>t.key===null?[]:[r])}var p5=(e,t)=>e.neighbours==="corners"?t.cols+1:t.cols;function hi(e,t,r="not",o=!0){let n=p5(e,t),i=t.cells.length/n,s=(c,l)=>c>=0&&l>=0&&c<n&&l<i?t.cells[l*n+c]===1:r!=="same"?r==="terrain":t.cells[Math.min(i-1,Math.max(0,l))*n+Math.min(n-1,Math.max(0,c))]===1,a=[];for(let c=0;c<t.rows;c++)for(let l=0;l<t.cols;l++){if(e.neighbours==="corners"){let d=(s(l+1,c)?pt.NE:0)|(s(l+1,c+1)?pt.SE:0)|(s(l,c+1)?pt.SW:0)|(s(l,c)?pt.NW:0);a.push(zT(e,!0,d));continue}let u=0;for(let[d,f,p]of l5)s(l+f,c+p)&&(u|=d);let m=zT(e,s(l,c),u);a.push(o?f5(e,m,l,c):m)}return a}var RT=e=>e.bands.reduce((t,r)=>t+r.w,0);function h5(e,t,r,o,n,i){let s=e/2,a=t&1?s:0,c=t&2?s:0,l=r&1?a+s-1-o:o-a,u=r&2?c+s-1-n:n-c;return[2*(l-i)+1,2*(u-i)+1]}var hn=e=>e*e;function MS(e,t,r,o,n){return jT(e,t,r,o,n)}function jT(e,t,r,o,n){switch(e){case"in":return!1;case"out":return!0;case"horiz":case"hround":return r<o;case"vert":case"vround":return t<o;case"fillet":case"diag":case"diagcap":case"diagside":case"outerdiag":case"diagfill":return!0;case"outer":return t>=n||r>=n?Math.min(t,r)<o:n-o<0||hn(n-t)+hn(n-r)>hn(n-o);case"inner":return t>0&&r>0?o>0&&hn(t)+hn(r)<hn(o):t>0?t<o:r>0?r<o:!0}}function g5(e,t,r,o,n,i){let s=Math.floor((n*99+35)/70)-o;if(s<=0)return!0;let a=Math.abs(t-r)>=s,c=Math.abs(t+r-2*i)>=s;switch(e){case"diag":return a;case"diagfill":return t+r>=s;case"diagcap":return a||c;default:return c}}function IT(e,t,r,o,n){let i=hn(o+n);switch(e){case"inner":return hn(t+n)+hn(r+n)<i;case"vround":return r<=n?hn(t+n)+hn(r-n)<i:t<o;case"hround":return t<=n?hn(t-n)+hn(r+n)<i:r<o;case"fillet":return t<=n&&r<=n?hn(t-n)+hn(r-n)<i:!0;default:return MS(e,t,r,o,0)}}function y5(e,t,r,o,n,i,s=0,a=0){let[c,l]=h5(t,r,e.face,o,n,i.inset),u=c-s,m=l-a;if(u5.includes(e.base)){let h=2*(RT(i)+i.radius),g=y=>g5(e.base,u+2*i.inset,m+2*i.inset,y,t-2*i.inset,t)&&(e.base!=="outerdiag"||jT("outer",u,m,y,h));if(g(0))return-1;let b=0;for(let y=0;y<i.bands.length;y++)if(b+=2*i.bands[y].w,g(b))return y;return i.bands.length}let d=2*(i.fillet??0);if((d>0||e.base==="vround"||e.base==="hround"||e.base==="fillet")&&e.base!=="outer"&&e.base!=="in"&&e.base!=="out"&&e.base!=="vert"&&e.base!=="horiz"){if(IT(e.base,u,m,0,d))return-1;let h=0;for(let g=0;g<i.bands.length;g++)if(h+=2*i.bands[g].w,IT(e.base,u,m,h,d))return g;return i.bands.length}let f=2*(RT(i)+i.radius);if(MS(e.base,u,m,0,f))return-1;let p=0;for(let h=0;h<i.bands.length;h++)if(p+=2*i.bands[h].w,MS(e.base,u,m,p,f))return h;return i.bands.length}var b5=(e,t,r)=>(r>=e/2?2:0)|(t>=e/2?1:0);function ET(e,t,r,o){let n=new Int8Array(r*r),i=o.jitter&&o.jitter.px>0?w5(r,o.jitter.px,o.jitter.seed):null;for(let s=0;s<r;s++)for(let a=0;a<r;a++){let c=b5(r,a,s);n[s*r+a]=y5(e.quadSpecs[t][c],r,c,a,s,o,i?i.u[s]:0,i?i.v[a]:0)}return n}function w5(e,t,r){let o=Math.max(2,Math.floor(e/5)),n=new dt(r,11),i=()=>{let a=Array.from({length:o},()=>n.nextInt(4*t+1)-2*t),c=new Int32Array(e);for(let l=0;l<e;l++){let u=(2*l+1)*o,m=2*e,d=Math.floor(u/m),f=u-d*m;c[l]=Math.round((a[d%o]*(m-f)+a[(d+1)%o]*f)/m)}return c},s=i();return{u:i(),v:s}}function TT(e,t){return e.inset?Math.floor(t*e.inset[0]/e.inset[1]):0}function v5(e){let t=s=>{let a=s/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4},[r,o,n]=it(e),i=.2126*t(r)+.7152*t(o)+.0722*t(n);return i>216/24389?116*Math.cbrt(i)-16:24389/27*i}function $5(e){return e.views.length?[...new Set(e.views.filter(t=>!t.mirror).map(t=>t.from))]:[0]}function um(e,t){if(e.width!==t.width||e.height!==t.height||e.frameCount!==t.frameCount)return!1;let r=new Map,o=new Map,n=!1;for(let i=0;i<e.frameCount;i++){let s=be(e,i),a=be(t,i);for(let c=0;c<s.length;c++){let l=s[c],u=a[c];if(l===65535!=(u===65535))return!1;if(l!==65535){if((r.get(l)??u)!==u||(o.get(u)??l)!==l)return!1;r.set(l,u),o.set(u,l)}}}for(let[i,s]of r)(e.palette.entries[i].hex.toLowerCase()!==t.palette.entries[s].hex.toLowerCase()||e.palette.entries[i].role!==t.palette.entries[s].role)&&(n=!0);return n&&r.size>0}function x5(e,t,r){let o=[],n=0,i=0,s=0,a=t,c=r,l=-1,u=-1,m=new Int32Array(t*r),d=new Int32Array(t*r);for(let h=0;h<r;h++)for(let g=0;g<t;){if(e[h*t+g]===65535){g++;continue}let b=g;for(;b<t&&e[h*t+b]!==65535;)b++;for(let y=g;y<b;y++)m[h*t+y]=b-g;g=b}for(let h=0;h<t;h++)for(let g=0;g<r;){if(e[g*t+h]===65535){g++;continue}let b=g;for(;b<r&&e[b*t+h]!==65535;)b++;for(let y=g;y<b;y++)d[y*t+h]=b-g;g=b}for(let h=0;h<r;h++)for(let g=0;g<t;g++){let b=h*t+g;e[b]!==65535&&(o.push(Math.min(m[b],d[b])),n++,i+=g,s+=h,a=Math.min(a,g),c=Math.min(c,h),l=Math.max(l,g),u=Math.max(u,h))}if(!n)return{stroke:null,fill:null,centre:null};let f=i/n,p=s/n;return{stroke:AT(o),fill:(l-a+1)*(u-c+1)/(t*r),centre:{x:f,y:p,off:Math.hypot(f-(t-1)/2,p-(r-1)/2)}}}function CT(e,t){let r=e.palette,o=r.entries.map(T=>v5(T.hex)),n=new Set(r.entries.flatMap((T,q)=>t.includes(T.name)?[q]:[]));if(!n.size&&!e.wrap){let T=-1;for(let q of be(e,0))q!==65535&&(T<0||o[q]<o[T])&&(T=q);T>=0&&n.add(T)}let i=e.width,s=e.height,a=0,c=0,l=0,u=0,m=0,d=0,f=0,p=0,h=0,g=i,b=s,y=-1,w=-1,v=new Map,S=new Map,_=new Map,$=new Map;for(let[T,q]of Object.entries(r.ramps))for(let Z of q){let D=r.entries.findIndex(V=>V.name===Z);D>=0&&!$.has(D)&&!n.has(D)&&$.set(D,T)}let x=$5(e);for(let T of x){let q=be(e,T),Z=(V,F)=>e.wrap?q[(F+s)%s*i+(V+i)%i]:V<0||F<0||V>=i||F>=s?65535:q[F*i+V];for(let V=0;V<s;V++)for(let F=0;F<i;F++){let M=q[V*i+F];if(M===65535)continue;a++,c+=o[M],T===x[0]&&(g=Math.min(g,F),b=Math.min(b,V),y=Math.max(y,F),w=Math.max(w,V));let L=$.get(M);if(L&&((v.get(L)??v.set(L,new Set).get(L)).add(M),_.set(L,(_.get(L)??0)+1),S.set(M,(S.get(M)??0)+1)),!e.wrap&&[[1,0],[-1,0],[0,1],[0,-1]].some(([A,z])=>Z(F+A,V+z)===65535)&&(l++,n.has(M)&&u++),L)for(let[A,z]of[[1,0],[0,1]]){let R=Z(F+A,V+z);if(R===65535||R===M||$.get(R)!==L)continue;let C=o[R]-o[M];m+=A*C,d+=z*C,f+=Math.abs(C)}}let D=new Uint8Array(i*s);for(let V=0;V<q.length;V++){let F=q[V];if(F===65535||n.has(F)||D[V])continue;let M=0,L=[V];for(D[V]=1;L.length;){let A=L.pop();M++;let z=A%i,R=Math.floor(A/i);for(let[C,U]of[[1,0],[-1,0],[0,1],[0,-1]]){let W=z+C,X=R+U;if(e.wrap)W=(W+i)%i,X=(X+s)%s;else if(W<0||X<0||W>=i||X>=s)continue;let Y=X*i+W;!D[Y]&&q[Y]===F&&(D[Y]=1,L.push(Y))}}p++,h+=M}}if(!a)return{box:null,lightness:null,outline:null,light:null,cluster:null,steps:null,material:null,stroke:null,fill:null,centre:null};let k=Math.hypot(m,d),P=f>0?k/f:0,I=Math.max(3,Math.floor(a/100)),E=[...v.values()].map(T=>[...T].filter(q=>(S.get(q)??0)>=I).length).filter(T=>T>0),N=[..._].sort((T,q)=>q[1]-T[1]||(T[0]<q[0]?-1:1))[0]?.[0]??null;return{box:y>=0?{x:g,y:b,w:y-g+1,h:w-b+1}:null,lightness:c/a,outline:e.wrap?null:l?u/l:null,light:e.wrap||P<.1?null:{x:m/k,y:d/k,strength:P},cluster:p?h/p/Math.sqrt(a/x.length):null,steps:E.length?E.reduce((T,q)=>T+q,0)/E.length:null,material:N,...x5(be(e,x[0]),i,s)}}var In={n:[0,-1],ne:[1,-1],e:[1,0],se:[1,1],s:[0,1],sw:[-1,1],w:[-1,0],nw:[-1,-1]};function _5(e){let t=[...e].sort((o,n)=>o-n),r=o=>{let n=o*(t.length-1),i=Math.floor(n);return i+1<t.length?t[i]+(t[i+1]-t[i])*(n-i):t[i]};return[r(.25),r(.75)]}function AT(e){let t=[...e].sort((r,o)=>r-o);return t.length%2?t[(t.length-1)/2]:(t[t.length/2-1]+t[t.length/2])/2}var wo=e=>Math.round(e*10)/10,DS=e=>Math.round(e*100)/100;function qS(e,t,r){let o=t.filter(u=>um(u.doc,e)||um(e,u.doc)).map(u=>u.name),n=t.filter(u=>u.doc!==e&&!o.includes(u.name)),i=CT(e,r.ink),s=n.map(u=>({name:u.name,m:CT(u.doc,r.ink)})),a=[];if(r.height!==void 0&&i.box){let u=i.box.h-r.height;a.push({name:"height",value:i.box.h,limit:`${r.height} \xB1 ${r.heightTol}`,pass:Math.abs(u)<=r.heightTol,detail:`the drawn shape is ${i.box.h} px tall (rows ${i.box.y}..${i.box.y+i.box.h-1}); the manifest plans ${r.height}`})}let c=(u,m,d,f,p,h=!1,g=!1,b=!1)=>{let y=d(i),w=s.filter(_=>!g||_.m.material!==null&&_.m.material===i.material).map(_=>d(_.m)).filter(_=>_!==null);if(y===null||w.length<2)return;let v=AT([...w,y]);if(b){let[_,$]=_5([...w,y]),x=y<_?_-y:y>$?y-$:0,k=_===$?p(_):`${p(_)}..${p($)}`;a.push({name:m,value:y,limit:`\xB1 ${p(f)} of the set's ${k}`,pass:x<=f,detail:`${p(y)} against the set's middle half ${k} (with ${w.length} others)`});return}let S=h?v>0?Math.max(y/v,v/y):1:Math.abs(y-v);a.push({name:m,value:y,limit:h?`\xD7 ${f} of the set's ${p(v)}`:`\xB1 ${p(f)} of the set's ${p(v)}`,pass:S<=f,detail:`${p(y)} against the set's median ${p(v)} (with ${w.length} others${g?` mostly in ${i.material}`:""})`})};if(c("lightness","lightness",u=>u.lightness,r.maxL,u=>String(wo(u)),!1,!0),c("outline","outline share",u=>u.outline,r.maxOutline,u=>String(DS(u))),c("cluster","cluster size",u=>u.cluster,r.maxCluster,u=>String(DS(u)),!0),c("steps","ramp steps",u=>u.steps,r.maxSteps,u=>String(wo(u)),!1,!1,!0),r.icon&&(c("stroke","stroke weight",u=>u.stroke,r.icon.maxStroke,u=>String(wo(u))),c("fill","box fill",u=>u.fill,r.icon.maxFill,u=>String(DS(u))),i.centre)){let u=i.centre;a.push({name:"optical centre",value:wo(u.off),limit:`\u2264 ${r.icon.maxCentre} px from the canvas centre`,pass:u.off<=r.icon.maxCentre,detail:`the drawn pixels' centre is at ${wo(u.x)},${wo(u.y)}, ${wo(u.off)} px from the canvas centre ${wo((e.width-1)/2)},${wo((e.height-1)/2)}`})}let l=r.light&&In[r.light]?In[r.light]:(()=>{let u=s.flatMap(f=>f.m.light?[f.m.light]:[]);if(u.length<2)return null;let m=u.reduce((f,p)=>f+p.x,0),d=u.reduce((f,p)=>f+p.y,0);return Math.hypot(m,d)>0?[m,d]:null})();if(l&&!e.wrap){let u=Math.hypot(l[0],l[1]);if(i.light){let m=(i.light.x*l[0]+i.light.y*l[1])/u,d=Math.acos(Math.max(-1,Math.min(1,m)))*180/Math.PI,f=Object.entries(In).sort((p,h)=>{let g=(p[1][0]*i.light.x+p[1][1]*i.light.y)/Math.hypot(...p[1]);return(h[1][0]*i.light.x+h[1][1]*i.light.y)/Math.hypot(...h[1])-g})[0][0];a.push({name:"light",value:Math.round(d),limit:`\u2264 ${r.maxAngle}\xB0 from ${r.light??"the set's"}`,pass:d<=r.maxAngle,detail:`lit from the ${f} (${Math.round(d)}\xB0 from ${r.light?`the style guide's ${r.light}`:"the set's light"})`})}else a.push({name:"light",value:null,limit:"",pass:null,detail:"no clear lit side (flat shading)"})}return{parts:a,recolours:o,peers:n.map(u=>u.name),box:i.box}}var OT=(e,t)=>(e%t+t)%t;function Rt(e,t,r){return e.wrap?OT(r,e.height)*e.width+OT(t,e.width):t<0||r<0||t>=e.width||r>=e.height?-1:r*e.width+t}function dy(e,t){let r=Math.abs(t[0]-e[0])>=Math.abs(t[1]-e[1]),o=p=>r?[p[0],p[1]]:[p[1],p[0]],[n,i]=[o(e),o(t)],s=i[0]<n[0]||i[0]===n[0]&&i[1]<n[1],[a,c]=s?[i,n]:[n,i],l=c[0]-a[0]+1,u=Math.abs(c[1]-a[1])+1,m=c[1]<a[1]?-1:1,d=p=>{let h=2*p*l+u,g=2*u,b=Math.floor(h/g);return h%g===0&&2*p<=u&&(b-=1),b},f=[];for(let p=0;p<u;p++)for(let h=d(p);h<d(p+1);h++){let g=a[0]+h,b=a[1]+m*p;f.push(r?[g,b]:[b,g])}return s&&f.reverse(),f}function LS(e,t){let r=[],o=new Set;for(let n=0;n<e.length;n++){if(n===0){r.push(e[0]);continue}let i=dy(e[n-1],e[n]);for(let s=1;s<i.length;s++)r.push(i[s]);if(n<e.length-1){let[s,a,c]=[e[n-1],e[n],e[n+1]],l=s[0]===a[0]||s[1]===a[1],u=a[0]===c[0]||a[1]===c[1];l&&u&&o.add(r.length-1)}}return t?NT(r,o):mm(r)}function bc(e,t){let r=e.length?[e[0]]:[];for(let n=1;n<e.length;n++){let i=dy(e[n-1],e[n]);for(let s=1;s<i.length;s++)r.push(i[s])}let o=mm(r);return t?NT(o,new Set):o}function NT(e,t){if(e.length<3)return mm(e);let r=[e[0]];for(let o=1;o<e.length-1;o++){let n=r[r.length-1],i=e[o],s=e[o+1];Math.abs(n[0]-s[0])===1&&Math.abs(n[1]-s[1])===1&&(n[0]===i[0]||n[1]===i[1])&&(s[0]===i[0]||s[1]===i[1])&&!t.has(o)||r.push(i)}return r.push(e[e.length-1]),mm(r)}function mm(e){return e.filter((t,r)=>r===0||t[0]!==e[r-1][0]||t[1]!==e[r-1][1])}function my(e,t){let r=Math.floor(e/t);return r*t>e?r--:(r+1)*t<=e&&r++,r}function MT(e,t){let r=e.length-1,o=0;for(let a=1;a<e.length;a++)o+=Math.max(Math.abs(e[a][0]-e[a-1][0]),Math.abs(e[a][1]-e[a-1][1]));let n=Math.max(2,Math.min(r===3?1024:8192,2*o)),i=n**r,s=[];for(let a=0;a<=n;a++){let c=n-a,l=r===3?[c*c*c,3*c*c*a,3*c*a*a,a*a*a]:[c*c,2*c*a,a*a],u=0,m=0;for(let d=0;d<=r;d++)u+=l[d]*e[d][0],m+=l[d]*e[d][1];s.push([my(2*u+i,2*i),my(2*m+i,2*i)])}return bc(mm(s),t)}function fy(e,t,r){let o=LS([...e,e[0]],r);if(!t)return US(o);let n=[...o],i=e.map(a=>a[1]),s=e.length;for(let a=Math.min(...i);a<=Math.max(...i);a++){let c=[];for(let l=0;l<s;l++){let[u,m]=e[l],[d,f]=e[(l+1)%s];if(m===f||a<Math.min(m,f)||a>=Math.max(m,f))continue;let p=u*(f-m)+(a-m)*(d-u),h=f-m;c.push(h>0?[p,h]:[-p,-h])}c.sort((l,u)=>l[0]*u[1]-u[0]*l[1]);for(let l=0;l+1<c.length;l+=2){let[u,m]=c[l],[d,f]=c[l+1];for(let p=-my(-u,m);p<=my(d,f);p++)n.push([p,a])}}return US(n)}function vo(e,t,r,o,n){let i=[];for(let s=0;s<o;s++)for(let a=0;a<r;a++)(n||s===0||s===o-1||a===0||a===r-1)&&i.push([e+a,t+s]);return i}function gi(e,t,r,o,n){let i=new Map,s=[],a=(h,g)=>{s.push([h,g]);let b=i.get(g);b?(b[0]=Math.min(b[0],h),b[1]=Math.max(b[1],h)):i.set(g,[h,h])},c=Math.abs(r-e),l=Math.abs(o-t),u=l&1,m=4*(1-c)*l*l,d=4*(u+1)*c*c,f=m+d+u*c*c;e>r&&(e=r,r+=c),t>o&&(t=o),t+=l+1>>1,o=t-u,c*=8*c,u=8*l*l;do{a(r,t),a(e,t),a(e,o),a(r,o);let h=2*f;h<=d&&(t++,o--,d+=c,f+=d),(h>=m||2*f>d)&&(e++,r--,m+=u,f+=m)}while(e<=r);for(;t-o<=l;)a(e-1,t),a(r+1,t++),a(e-1,o),a(r+1,o--);if(!n)return US(s);let p=[];for(let[h,[g,b]]of[...i.entries()].sort((y,w)=>y[0]-w[0]))for(let y=g;y<=b;y++)p.push([y,h]);return p}function US(e){let t=new Set;return e.filter(([r,o])=>t.has(`${r},${o}`)?!1:(t.add(`${r},${o}`),!0))}function py(e,t,r,o,n,i){let s=Rt(e,t,r),a=e.mask;if(s<0||a&&!a[s])return;let c=e.pixels[s];if(c===o)return;if(n){for(let m=0;m<e.pixels.length;m++)e.pixels[m]===c&&(!a||a[m])&&(e.pixels[m]=o);return}let l=i===4?[[1,0],[-1,0],[0,1],[0,-1]]:[[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1]],u=[s];for(e.pixels[s]=o;u.length;){let m=u.pop(),d=m%e.width,f=(m-d)/e.width;for(let[p,h]of l){let g=Rt(e,d+p,f+h);g>=0&&e.pixels[g]===c&&(!a||a[g])&&(e.pixels[g]=o,u.push(g))}}}var wc=Object.keys(In);function hy(e){let t=e&&In[e]?In[e]:In.nw;return Object.entries(In).find(([,r])=>r[0]===-t[0]&&r[1]===-t[1])[0]}function gy(e,t,r,o){let n=-1,i=-1;for(let p=0;p<r;p++)for(let h=0;h<t;h++)e[p*t+h]!==65535&&(n<0&&(n=p),i=p);if(i<0)return null;let s=Math.max(1,Math.floor((i-n+1)/3)),a=t,c=-1;for(let p=i-s+1;p<=i;p++)for(let h=0;h<t;h++)e[p*t+h]!==65535&&(a=Math.min(a,h),c=Math.max(c,h));let l=c-a+3,u=Math.max(2,Math.floor((l+1)/3)),m=Math.max(1,Math.floor(l/6)),[d,f]=In[o]??[1,1];return{x:a-1+d*m,y:i-(u>>1)+f*m,w:l,h:u}}var yy=e=>gi(e.x,e.y,e.x+e.w-1,e.y+e.h-1,!0);function DT(e,t){let r=e.map((i,s)=>s),o=new Set;for(let{palette:i,map:s}of t)for(let a of Object.values(i.ramps)){let c=a.map(l=>i.entries.findIndex(u=>u.name===l));for(let l=1;l<c.length;l++){let u=s[c[l]],m=s[c[l-1]];u===void 0||m===void 0||o.has(u)||(r[u]=m,o.add(u))}}let n=e.map(i=>Vr(i.hex));return e.forEach((i,s)=>{if(o.has(s))return;let a=-1;for(let c=0;c<e.length;c++)n[s]-n[c]>=6&&(a<0||n[c]>n[a])&&(a=c);a>=0&&(r[s]=a)}),r}function qn(e){let t=new Map(e.map(o=>[o.name,o.doc])),r=new Map;for(let o of[...e].sort((n,i)=>n.name<i.name?-1:n.name>i.name?1:0)){let n=o.doc.variantOf;n&&r.set(n,[...r.get(n)??[],o.doc])}return{get:o=>t.get(o),family:o=>{let n=t.get(o);return n?[n,...(r.get(o)??[]).filter(i=>S5(n,i))]:[]}}}function S5(e,t){return e.width!==t.width||e.height!==t.height?!1:e.family||t.family?!!e.family&&!!t.family&&e.family.scheme===t.family.scheme&&e.family.tile===t.family.tile:!0}var Br=e=>[Math.max(1,Math.floor(e.width/e.cellW)),Math.max(1,Math.floor(e.height/e.cellH))];function Dn(e){if(e.footprint)return e.footprint;let[t,r]=Br(e);return{cols:t,rows:r,at:[0,0],anchor:[0,r-1],flags:Array.from({length:r},()=>".".repeat(t))}}function dm(e,t,r){let o=e.flags[r]?.[t]??".";return{block:o==="b"||o==="x",roof:o==="r"||o==="x"}}var fm=(e,t,r)=>t>=e.at[0]&&r>=e.at[1]&&t<e.at[0]+e.cols&&r<e.at[1]+e.rows;function Zr(e,t,r){return{x:t-e.anchor[0],y:r-e.anchor[1],w:e.cols,h:e.rows}}function Hr(e,t=["tiles","objects"]){let r=[];return e.layers.forEach((o,n)=>{if(!o.map||!t.includes(o.map.kind))return;let i=e.cels[n][0];for(let s=0;s<i.length;s++)i[s]!==65535&&r.push({layer:n,entry:i[s],x:s%e.width,y:Math.floor(s/e.width)})}),r}function vc(e,t){let r=e.layers[t]?.map?.kind,o=Hr(e).filter(i=>r==="objects"?e.layers[i.layer].map.kind==="objects":i.layer===t),n=new Int32Array(e.width*e.height).fill(-1);return o.forEach((i,s)=>{let a=Zr(e.map.entries[i.entry],i.x,i.y);for(let c=a.y;c<a.y+a.h;c++)for(let l=a.x;l<a.x+a.w;l++)l>=0&&c>=0&&l<e.width&&c<e.height&&(n[c*e.width+l]=s)}),{grid:n,placed:o}}function k5(e,t,r){let o=e.cels[t][0],n=e.width,i=e.height,s=(l,u)=>o[Math.min(u,i-1)*n+Math.min(l,n-1)]===1?1:0;if(r.neighbours!=="corners")return{cols:n,rows:i,cells:Uint8Array.from(o,l=>l===1?1:0)};let a=e.layers[t].map?.kind==="terrain"?e.layers[t].map.border:void 0,c=new Uint8Array((n+1)*(i+1));for(let l=0;l<=i;l++)for(let u=0;u<=n;u++){let m=u===0||l===0||u===n||l===i;c[l*(n+1)+u]=m&&a?a==="terrain"?1:0:s(u,l)}return{cols:n,rows:i,cells:c}}function z5(e,t,r,o){let n=new Map,i=(a,c)=>{let l=c.reduce((m,d)=>m+d.weight,0),u=a%l;for(let m of c){if(u<m.weight)return m.name;u-=m.weight}return c[0].name},s=(a,c,l)=>{if(a<0||c<0||a>=r||c>=o||l(c*r+a))return null;let u=c*r+a,m=n.get(u);if(m!==void 0)return m;let d=i($s(a,c,t,7170424),e),f=s(a-1,c,l),p=s(a,c-1,l);return d===f&&d===p&&(e.length>2||d===s(a-1,c-1,l))&&e.length>1&&(d=i($s(a,c,t,7170425),e.filter(g=>g.name!==d))),n.set(u,d),d};return(a,c,l)=>s(a,c,l)}var FS=class{entries;maps=new Map;constructor(t){this.entries=t.map(r=>({name:r.name,hex:r.hex}))}of(t){let r=this.maps.get(t);return r||(r=t.palette.entries.map(o=>{let n=this.entries.findIndex(i=>i.name===o.name&&i.hex===o.hex);return n<0&&(n=this.entries.findIndex(i=>i.hex===o.hex)),n<0&&(this.entries.push({name:o.name,hex:o.hex}),n=this.entries.length-1),n}),this.maps.set(t,r),r)}},by=(e,t)=>!e.variants[t].on&&e.variants[t].quads.every(r=>r==="in"||r.startsWith("in@"));function qT(e,t){if(e.frameCount<2)return 0;let r=tr(e)[0];return Lr(r).length?Fr(e,r,t):0}function Bt(e,t,r={}){let o=e.map,n=o.tile,i=e.width,s=e.height,a=i*n,c=s*n,l=r.tick??0,u=new FS(e.palette.entries),m=new Uint16Array(a*c).fill(65535),d=Array.from({length:i*s},()=>null),f=Array.from({length:i*s},()=>null),p=[],h=new Map,g=new Set,b=q=>{g.add(q);let Z=qT(q,l),D=h.get(q);D||h.set(q,D=new Map);let V=D.get(Z);if(!V){let F=u.of(q);V=be(q,Z).map(M=>M===65535?M:F[M]),D.set(Z,V)}return V},y=(q,Z,D,V,F,M,L,A)=>{for(let z=0;z<M;z++){let R=A+z;if(!(R<0||R>=c))for(let C=0;C<F;C++){let U=L+C;if(U<0||U>=a)continue;let W=q[(V+z)*Z+D+C];W!==65535&&(m[R*a+U]=W)}}},w=new Map,v=q=>{let Z=qT(q,l),D=w.get(q);D||w.set(q,D=new Map);let V=D.get(Z);if(!V){let F=u.of(q);V=new Uint16Array(q.width*q.height).fill(65535),q.layers.forEach((M,L)=>{if(M.hidden||M.reference||M.underlay||M.name===xs)return;let A=q.cels[L][Z];for(let z=0;z<A.length;z++)A[z]!==65535&&(V[z]=F[A[z]])}),D.set(Z,V)}return V},S=new Set,_=q=>{let Z=t.family(q);return!Z.length&&!S.has(q)&&(S.add(q),p.push(`no asset '${q}'`)),Z},$=new Map,x=(q,Z,D,V)=>{if(q.length<2)return q[0];let F=$.get(V);F||$.set(V,F=new Int16Array(i*s).fill(-1));let M=$s(Z,D,V,90),L=M%q.length,A=Z>0?F[D*i+Z-1]:-1,z=D>0?F[(D-1)*i+Z]:-1;return L===A&&L===z&&(L=(L+1+(M>>>16)%(q.length-1))%q.length),Z>=0&&D>=0&&Z<i&&D<s&&(F[D*i+Z]=L),q[L]},k=[];e.layers.forEach((q,Z)=>{let D=q.map;if(!D||q.hidden||D.kind==="objects"||r.groundOnly&&D.kind==="overlay")return;let V=e.cels[Z][0];if(D.kind==="terrain"){let z=_(D.family).filter(W=>W.family);if(!z.length){t.get(D.family)&&p.push(`layer ${q.name}: '${D.family}' is not a family`);return}let R=Qe(z[0].family),C=hi(R,k5(e,Z,R),D.border??"same"),U=D.mix?z5(D.mix,D.seed??1,i,s):null;C.forEach((W,X)=>{let Y=X%i,fe=Math.floor(X/i);if(W===null&&!D.outside)return;if(U&&W!==null&&by(R,W)){let de=U(Y,fe,pe=>pe<0||C[pe]===null||!by(R,C[pe])),ae=t.get(de);if(!ae){p.push(`layer ${q.name}: mix= names '${de}', which is not drawn`);return}if(ae.width!==n||ae.height!==n){p.push(`layer ${q.name}: mix= tile '${de}' is ${ae.width}x${ae.height}, not ${n}x${n}`);return}y(b(ae),ae.width,0,0,n,n,Y*n,fe*n),d[X]={asset:de,variant:R.variants[W].name,edge:!1,...D.outside?{base:!0}:{},...D.walkable?{walkable:!0}:{}},f[X]=W;return}let ye=x(z,Y,fe,Z),H=mt(ye.family),[Q,re]=W===null?H.outside:H.cells[W];if(W!==null&&pi(R.variants[W].on)&&!D.outside)y(v(ye),ye.width,Q*n,re*n,n,n,Y*n,fe*n);else if(W!==null&&R.variants[W].on&&!D.outside){let de=xo(R,n,ye.family.geometry)[W],ae=b(ye);for(let pe=0;pe<n;pe++)for(let Ie=0;Ie<n;Ie++){if(ZS(ye.family.geometry,de[pe*n+Ie]))continue;let Je=ae[(re*n+pe)*ye.width+Q*n+Ie];Je!==65535&&(m[(fe*n+pe)*a+Y*n+Ie]=Je)}}else y(b(ye),ye.width,Q*n,re*n,n,n,Y*n,fe*n);d[X]={asset:ye.name,variant:W===null?"outside":R.variants[W].name,edge:W!==null&&!by(R,W),...D.outside?{base:!0}:{},...D.walkable?{walkable:!0}:{}},f[X]=W});return}if(D.kind==="tiles"){for(let z=0;z<V.length;z++){let R=V[z];if(R===65535)continue;let C=o.entries[R],U=z%i,W=Math.floor(z/i),X=C.exact&&t.get(C.name)?[t.get(C.name)]:_(C.name);if(!X.length)continue;let Y=Zr(C,U,W);if(C.variant){let H=x(X,U,W,Z),Q=H.family?Qe(H.family).byName.get(C.variant):void 0;if(Q===void 0){p.push(`${C.name} has no variant '${C.variant}'`);continue}let[re,de]=mt(H.family).cells[Q];y(b(H),H.width,re*n,de*n,n,n,Y.x*n,Y.y*n),Y.x>=0&&Y.y>=0&&Y.x<i&&Y.y<s&&(d[Y.y*i+Y.x]={asset:H.name,variant:C.variant,edge:!by(Qe(H.family),Q)});continue}let fe=x(X,U,W,Z),ye=Dn(fe);y(b(fe),fe.width,0,0,fe.width,fe.height,(Y.x-ye.at[0])*n,(Y.y-ye.at[1])*n);for(let H=Y.y;H<Y.y+Y.h;H++)for(let Q=Y.x;Q<Y.x+Y.w;Q++)Q>=0&&H>=0&&Q<i&&H<s&&(d[H*i+Q]={asset:fe.name,variant:null,edge:!1})}return}let F=t.get(D.overlay);if(!F?.overlay){p.push(`layer ${q.name}: no overlay '${D.overlay}'`);return}let M=R5(e,D),L=u.of(F),A=new Map;for(let z=0;z<M.length;z++){if(!M[z])continue;let R=z%i,C=Math.floor(z/i),U=HS(F,R,C,l);if(U===null)continue;let W=A.get(U)??A.set(U,be(F,U)).get(U);BS(F,U,R,C,n,(X,Y,fe)=>{X>=0&&Y>=0&&X<a&&Y<c&&(m[Y*a+X]=L[fe])},W)}});let P=m.slice();if(!r.groundOnly){for(let q of Hr(e,["objects"])){if(e.layers[q.layer].hidden)continue;let Z=o.entries[q.entry],D=_(Z.name),V=D.length?x(D,q.x,q.y,q.layer):null,F=V?Dn(V):{cols:Z.cols,rows:Z.rows,at:[0,0],anchor:Z.anchor,flags:[]},M=Zr(Z,q.x,q.y);k.push({...q,doc:V,name:Z.name,fp:F,px:(M.x-F.at[0])*n,py:(M.y-F.at[1])*n,base:M.y+M.h-1}),V&&V.cellW!==n&&p.push(`${Z.name}: its cells are ${V.cellW} px, the map's ${n}`)}k.sort((q,Z)=>q.base-Z.base||q.layer-Z.layer||q.x-Z.x||q.y-Z.y)}let I=k.filter(q=>q.doc&&e.layers[q.layer].map.shadow);if(I.length){let q=DT(u.entries,[...g].map(Z=>({palette:Z.palette,map:u.of(Z)})));for(let Z of I){let D=e.layers[Z.layer].map.shadow,V=gy(b(Z.doc),Z.doc.width,Z.doc.height,D.dir);if(!V)continue;let F=D.c==="darker"?-1:u.entries.findIndex(M=>M.name===D.c);if(D.c!=="darker"&&F<0){p.push(`layer ${e.layers[Z.layer].name}: no colour '${D.c}' for shadows`);continue}for(let[M,L]of yy(V)){let A=Z.px+M,z=Z.py+L;if(A<0||z<0||A>=a||z>=c)continue;let R=m[z*a+A];R!==65535&&(m[z*a+A]=F<0?q[R]:F)}}}let E=new Int32Array(a*c).fill(-1),N=new Int32Array(a*c).fill(-1),T=(q,Z)=>{let D=k[q];if(!D.doc)return;let V=b(D.doc),[F,M]=Br(D.doc);for(let L=0;L<M;L++)for(let A=0;A<F;A++)if(!(Z&&!dm(D.fp,A,L).roof))for(let z=0;z<D.doc.cellH;z++)for(let R=0;R<D.doc.cellW;R++){let C=A*D.doc.cellW+R,U=L*D.doc.cellH+z,W=V[U*D.doc.width+C];if(W===65535)continue;let X=D.px+C,Y=D.py+U;X<0||Y<0||X>=a||Y>=c||(m[Y*a+X]=W,(Z?N:E)[Y*a+X]=q)}};return k.forEach((q,Z)=>T(Z,!1)),k.forEach((q,Z)=>T(Z,!0)),{px:m,w:a,h:c,t:n,variants:f,cols:i,rows:s,palette:u.entries,ground:P,top:d,objects:k,roofOwner:N,artOwner:E,problems:p}}function R5(e,t){let r=e.width*e.height;if(t.on==="all")return new Uint8Array(r).fill(1);let[o,n]=t.on.split(":"),i=e.layers.findIndex(c=>c.name===o),s=n==="out";if(i<0)return new Uint8Array(r);let a=e.cels[i][0];return Uint8Array.from(a,c=>c!==65535!==s?1:0)}var I5=e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)];function yi(e,t={}){let r=t.scale??1,o=t.region??{x:0,y:0,w:e.cols,h:e.rows},n=e.t,i=o.w*n*r,s=o.h*n*r,a=new Uint8Array(i*s*4),c=e.palette.map(f=>I5(t.hex?t.hex(f.name,f.hex):f.hex));for(let f=0;f<o.h*n;f++)for(let p=0;p<o.w*n;p++){let h=o.x*n+p,g=o.y*n+f,b=h>=0&&g>=0&&h<e.w&&g<e.h?e.px[g*e.w+h]:65535,y=b===65535?(h>>2)+(g>>2)&1?[204,204,204]:[238,238,238]:c[b];for(let w=0;w<r;w++)for(let v=0;v<r;v++){let S=((f*r+w)*i+p*r+v)*4;a[S]=y[0],a[S+1]=y[1],a[S+2]=y[2],a[S+3]=255}}let l=(f,p,h,g=1)=>{if(f<0||p<0||f>=i||p>=s)return;let b=(p*i+f)*4;a[b]=Math.round(a[b]*(1-g)+h[0]*g),a[b+1]=Math.round(a[b+1]*(1-g)+h[1]*g),a[b+2]=Math.round(a[b+2]*(1-g)+h[2]*g)};if(t.grid){for(let f=0;f<=o.h;f++)for(let p=0;p<i;p++)l(p,Math.min(s-1,f*n*r),[0,0,0],.18);for(let f=0;f<=o.w;f++)for(let p=0;p<s;p++)l(Math.min(i-1,f*n*r),p,[0,0,0],.18)}let u=new Set((t.marks??[]).map(([f,p])=>`${f},${p}`)),m=(f,p)=>u.has(`${f},${p}`),d=Math.max(1,r);for(let[f,p]of t.marks??[]){let h=(f-o.x)*n*r,g=(p-o.y)*n*r,b=n*r;for(let y=0;y<b;y++)for(let w=0;w<d;w++)m(f,p-1)||l(h+y,g+w,[255,0,200]),m(f,p+1)||l(h+y,g+b-1-w,[255,0,200]),m(f-1,p)||l(h+w,g+y,[255,0,200]),m(f+1,p)||l(h+b-1-w,g+y,[255,0,200]);for(let y=0;y<b;y+=2)for(let w=(y>>1)%2;w<b;w+=2)l(h+w,g+y,[255,0,200],.3)}return{width:i,height:s,data:a}}function P5(e,t,r){let o=(c,l)=>l?o(l,c%l):c,n=1,i=c=>{c>1&&(n=Math.min(r,n/o(n,c)*c))},s=new Set,a=[];for(let c of e.layers){let l=c.map;if(!(!l||c.hidden)&&(l.kind==="terrain"&&a.push(...t.family(l.family)),l.kind==="overlay")){let u=t.get(l.overlay);u&&a.push(u)}}for(let c of Hr(e))a.push(...t.family(e.map.entries[c.entry].name));for(let c of a)s.has(c)||(s.add(c),c.overlay?i(j5(c)):c.frameCount>1&&i(VS(c)));return n}var VS=e=>{let t=tr(e)[0];return Math.max(1,nr(e,t))},j5=e=>e.overlay.mode==="sparkle"?VS(e)+e.overlay.rest:VS(e);function UT(e,t,r={}){let o=r.tickRate??60,n=P5(e,t,o*(r.seconds??4));if(n<=1)return[];let i=l=>Math.round(l*100/o),s=[],a=null,c=0;for(let l=0;l<=n;l+=l===n?1:Math.min(3,n-l)){let u=l<n?Bt(e,t,{tick:l}):null;if(!(u&&a&&u.px.every((m,d)=>m===a[d]))){if(a&&s.length&&(s[s.length-1].delay=Math.max(1,i(l)-i(c))),!u)break;s.push({img:yi(u,{...r,tick:l}),delay:1}),a=u.px,c=l}}return s.length>1?s:[]}function wy(e,t,r,o,n){let i=Math.min(e.cols,Math.ceil(o/e.t)),s=Math.min(e.rows,Math.ceil(n/e.t)),a=Math.max(0,Math.min(e.cols-i,t-Math.floor(i/2))),c=Math.max(0,Math.min(e.rows-s,r-Math.floor(s/2)));return{x:a,y:c,w:i,h:s,px:[o,n]}}function LT(e,t,r=Bt(e,t)){let o=e.map,n=a=>String(Number(a.toFixed(2))),i=_s({px:r.ground,w:r.w,h:r.h,t:r.t,variants:r.variants},{palette:{entries:r.palette}}),s=[`${e.name}: a map of ${e.width}x${e.height} cells of ${o.tile} px (${r.w}x${r.h} px); seam over the ground ${n(i.score)} (about 1 or less reads as no seam)`];return e.layers.forEach((a,c)=>{let l=a.map;if(!l)return;let u=e.cels[c][0],m=a.hidden?" (hidden)":"";if(l.kind==="terrain"){let d=u.reduce((p,h)=>p+(h===1?1:0),0),f=t.family(l.family);s.push(`layer ${a.name}: terrain of ${l.family}${f.length>1?` (+ variants ${f.slice(1).map(p=>p.name).join(", ")})`:""}, ${d} cells${l.outside?"; its outside ground fills the rest":""}${l.walkable?" (walkable: objects may stand on it)":""}${l.border?`; past the map's edge: ${l.border==="terrain"?"terrain":"not terrain"}`:""}${l.mix?`; inside: mix=${l.mix.map(p=>`${p.name}:${p.weight}`).join(",")} seed=${l.seed}`:""}${m}`)}else if(l.kind==="overlay")s.push(`layer ${a.name}: overlay ${l.overlay} on ${l.on}${m}`);else{let d=Hr(e,[l.kind]).filter(p=>p.layer===c),f=d.slice(0,40).map(p=>{let h=o.entries[p.entry];return`${h.name}${h.variant?`.${h.variant}`:""} ${p.x},${p.y}`});s.push(`layer ${a.name}: ${l.kind}, ${d.length} placed${d.length?`: ${f.join("; ")}${d.length>40?"; \u2026":""}`:""}${m}`)}}),r.problems.length&&s.push(`problems: ${r.problems.join("; ")}`),s.join(`
123
+ `)}function FT(e,t){let r=e.width,o=e.height,n=Array.from({length:r*o},()=>"."),i=[],s=new Set([".","+"]),a=(f,p)=>{let g=[...f.replace(/[^a-z]/gi,""),..."abcdefghijklmnopqrstuvwxyz"].map(b=>p?b.toUpperCase():b.toLowerCase()).find(b=>!s.has(b))??"?";return s.add(g),g},c=new Map,l=Hr(e);e.layers.forEach((f,p)=>{if(!f.hidden){if(f.map?.kind==="terrain"){let h=a(f.name,!1);i.push(`${h} ${f.name}`);let g=e.cels[p][0];for(let b=0;b<g.length;b++)g[b]===1&&(n[b]=h);return}for(let h of l){if(h.layer!==p)continue;let g=e.map.entries[h.entry],b=`${g.name}${g.variant?`.${g.variant}`:""}`;c.has(b)||c.set(b,a(g.name,!0));let y=Zr(g,h.x,h.y);for(let w=y.y;w<y.y+y.h;w++)for(let v=y.x;v<y.x+y.w;v++)v>=0&&w>=0&&v<r&&w<o&&(n[w*r+v]="+");h.x>=0&&h.y>=0&&h.x<r&&h.y<o&&(n[h.y*r+h.x]=c.get(b))}}});let u=" "+Array.from({length:r},(f,p)=>p%10===0?String(Math.floor(p/10)%10):" ").join(""),m=" "+Array.from({length:r},(f,p)=>String(p%10)).join(""),d=Array.from({length:o},(f,p)=>`${String(p).padStart(3)} ${n.slice(p*r,p*r+r).join("")}`);return[`cells (${[...i,...[...c].map(([f,p])=>`${p} ${f}`),"+ under an object, . nothing"].join(", ")}):`,u,m,...d].join(`
124
+ `)}function VT(e,t){let r=e.width,o=e.height,n=Array.from({length:r*o},()=>"."),i=new Set([".","+"]),s=new Map,a=(f,p,h)=>{let g=s.get(f);if(g)return g;let y=[...p.replace(/[^a-z]/gi,""),..."abcdefghijklmnopqrstuvwxyz"].map(w=>h?w.toUpperCase():w.toLowerCase()).find(w=>!i.has(w))??"?";return i.add(y),s.set(f,y),y};for(let f=0;f<r*o;f++){let p=t.top[f];p&&(n[f]=p.variant==="outside"?a(`${p.asset} outside`,p.asset,!1):a(p.asset,p.asset,!1))}let c=new Map;for(let f of Hr(e)){if(e.layers[f.layer].map?.kind!=="objects"||e.layers[f.layer].hidden)continue;let p=e.map.entries[f.entry];c.set(p.name,a(`object ${p.name}`,p.name,!0));let h=Zr(p,f.x,f.y);for(let g=h.y;g<h.y+h.h;g++)for(let b=h.x;b<h.x+h.w;b++)b>=0&&g>=0&&b<r&&g<o&&(n[g*r+b]="+");f.x>=0&&f.y>=0&&f.x<r&&f.y<o&&(n[f.y*r+f.x]=c.get(p.name))}let l=[...s].map(([f,p])=>`${p} ${f.startsWith("object ")?f.slice(7):f.endsWith(" outside")?`${f.slice(0,-8)}'s outside ground`:f}`),u=" "+Array.from({length:r},(f,p)=>p%10===0?String(Math.floor(p/10)%10):" ").join(""),m=" "+Array.from({length:r},(f,p)=>String(p%10)).join(""),d=Array.from({length:o},(f,p)=>`${String(p).padStart(3)} ${n.slice(p*r,p*r+r).join("")}`);return[`cells (columns across, rows down; ${[...l,"+ under an object, . nothing"].join(", ")}):`,u,m,...d].join(`
125
+ `)}var E5={seam:1,edgeRun:4,motif:10,window:4,lattice:.3,latticeContrast:18};function T5(e){let t=new Int32Array(e.cols*e.rows),r=new Map;for(let o=0;o<e.rows;o++)for(let n=0;n<e.cols;n++){let i=2166136261,s=19088743;for(let l=0;l<e.t;l++)for(let u=0;u<e.t;u++){let m=e.ground[(o*e.t+l)*e.w+n*e.t+u];i=Math.imul(i^m,16777619)>>>0,s=Math.imul(s+m+1,2654435761)>>>0}let a=`${i}:${s}`,c=r.get(a);c===void 0&&r.set(a,c=r.size),t[o*e.cols+n]=c}return t}function C5(e,t,r){let o=new Map;for(let i=0;i<e.t;i++)for(let s=0;s<e.t;s++){let a=e.ground[(r*e.t+i)*e.w+t*e.t+s];o.set(a,(o.get(a)??0)+1)}return Math.max(...o.values())>=e.t*e.t*.97}function ZT(e,t,r={},o=Bt(e,t)){let n={...E5,...r},i=D=>String(Number(D.toFixed(2))),s=[],a=o.cols,c=o.rows,l=_s({px:o.ground,w:o.w,h:o.h,t:o.t,variants:o.variants},{palette:{entries:o.palette}});s.push({id:"seam",score:l.score,limit:n.seam,pass:l.score<=n.seam,shown:i(l.score),limitText:`\u2264 ${n.seam}`,groups:[],detail:`the tile grid over the whole ground: jump x ${i(l.jx)} y ${i(l.jy)}, line x ${i(l.lx)} y ${i(l.ly)}`});let u=T5(o),m=new Uint8Array(a*c);for(let D=0;D<c;D++)for(let V=0;V<a;V++)m[D*a+V]=C5(o,V,D)?1:0;let d=[],f=(D,V)=>!!o.top[V*a+D]?.edge&&!m[V*a+D];for(let D of[!0,!1]){let V=D?c:a,F=D?a:c;for(let M=0;M<V;M++){let L=0;for(let A=1;A<=F;A++){let z=X=>D?[X,M]:[M,X],[R,C]=z(L);if(A<F&&f(...z(A))&&u[z(A)[1]*a+z(A)[0]]===u[C*a+R])continue;let W=A-L;if(f(R,C)&&W>n.edgeRun){let X=o.top[C*a+R];d.push({cells:Array.from({length:W},(Y,fe)=>z(L+fe)),name:`${X.asset}.${X.variant}`})}L=A}}}let p=d.reduce((D,V)=>Math.max(D,V.cells.length),0),h=0;for(let D=0;D<c;D++)for(let V=0;V<a;V++){if(!f(V,D))continue;let F=1;for(;V+F<a&&f(V+F,D)&&u[D*a+V+F]===u[D*a+V];)F++;for(h=Math.max(h,F),F=1;D+F<c&&f(V,D+F)&&u[(D+F)*a+V]===u[D*a+V];)F++;h=Math.max(h,F)}let g=Math.min(n.window,a,c),b=[],y=0;for(let D=0;D+g<=c;D++)for(let V=0;V+g<=a;V++){let F=new Map;for(let A=0;A<g;A++)for(let z=0;z<g;z++){let R=(D+A)*a+V+z;m[R]||!o.top[R]||F.set(u[R],(F.get(u[R])??0)+1)}let M=0,L=-1;for(let[A,z]of F)z>M&&(M=z,L=A);y=Math.max(y,M),M>n.motif&&b.push({x:V,y:D,n:M,key:L})}let w=new Uint8Array(a*c);for(let D of b)for(let V=0;V<g;V++)for(let F=0;F<g;F++){let M=(D.y+V)*a+D.x+F;u[M]===D.key&&(w[M]=1)}let v=[];for(let D=0;D<w.length;D++)w[D]&&v.push([D%a,Math.floor(D/a)]);let S=new Map;for(let[D,V]of v){let F=o.top[V*a+D],M=`${F.asset}${F.variant?`.${F.variant}`:""}`;S.set(M,(S.get(M)??0)+1)}let _=D=>{let V=D.map(M=>M[0]),F=D.map(M=>M[1]);return`${Math.min(...V)},${Math.min(...F)} ${Math.max(...V)-Math.min(...V)+1}x${Math.max(...F)-Math.min(...F)+1}`},$=h<=n.edgeRun,x=y<=n.motif,k=[...d.map(D=>({label:`${D.cells.length} ${D.name} in a row at ${_(D.cells)}`,cells:D.cells})),...v.length?[{label:`the same tile over and over (${[...S].map(([D,V])=>`${D} \xD7${V}`).join(", ")})`,cells:v}]:[]];s.push({id:"repetition",score:Math.max(h/n.edgeRun,y/n.motif),limit:1,pass:$&&x,shown:`run ${h} \xB7 ${y}/${g*g}`,limitText:`run \u2264 ${n.edgeRun}, \u2264 ${n.motif}/${g*g}`,groups:k,detail:[`longest straight run of one edge tile: ${h}${d.length?` (${d.slice(0,4).map(D=>`${D.name} \xD7${D.cells.length} at ${_(D.cells)}`).join("; ")})`:""}`,`most of one textured tile in a ${g}x${g} window: ${y} of ${g*g}${v.length?` (hot spots: ${[...S].map(([D,V])=>`${D} on ${V} cells`).join(", ")})`:""}`,...$&&x?[]:["texture variants (an asset with variant of=<base>) break the pattern: the map picks among them cell by cell"]].join("; "),parts:[{name:"edge run",value:h,limit:`\u2264 ${n.edgeRun}`,pass:$,detail:"the same edge tile in a straight line"},{name:"motif",value:y,limit:`\u2264 ${n.motif} of ${g*g}`,pass:x,detail:`one textured tile in a ${g}x${g} window`}]}),s.push(A5(o,t,m,n));let P=[],I=new Map;o.objects.forEach((D,V)=>{let F=e.map.entries[D.entry],M=Zr(F,D.x,D.y),L=[];for(let W=M.y;W<M.y+M.h;W++)for(let X=M.x;X<M.x+M.w;X++)L.push([X,W]);let A=`${D.name} at ${D.x},${D.y}`;if(!D.doc){P.push({label:`${A}: no such asset`,cells:L});return}let z=L.filter(([W,X])=>W<0||X<0||W>=a||X>=c);z.length&&P.push({label:`${A}: off the map`,cells:L.filter(W=>!z.includes(W))});let R=Dn(D.doc);(R.cols!==F.cols||R.rows!==F.rows||R.anchor[0]!==F.anchor[0]||R.anchor[1]!==F.anchor[1])&&P.push({label:`${A}: placed as ${F.cols}x${F.rows} anchor ${F.anchor.join(",")}, its footprint is now ${R.cols}x${R.rows} anchor ${R.anchor.join(",")} (place it again)`,cells:L});let C=[],U=[];for(let[W,X]of L){if(W<0||X<0||W>=a||X>=c)continue;let Y=X*a+W;I.has(Y)?C.push([W,X]):I.set(Y,V);let fe=o.top[Y];fe?!fe.walkable&&(fe.variant==="outside"||fe.edge&&fe.base)&&U.push([W,X]):U.push([W,X])}if(C.length&&P.push({label:`${A}: overlaps ${o.objects[I.get(C[0][1]*a+C[0][0])].name}`,cells:C}),U.length){let W=o.top[U[0][1]*a+U[0][0]];P.push({label:`${A}: stands on ${W?W.variant==="outside"?`${W.asset}'s outside ground`:`the edge tile ${W.asset}.${W.variant}`:"nothing"} (${U.length} of ${L.length} cells)`,cells:U})}}),s.push({id:"footprint",score:P.length,limit:0,pass:P.length===0,shown:String(P.length),limitText:"0",groups:P,detail:P.length?P.slice(0,6).map(D=>D.label).join("; "):`${o.objects.length} objects, every footprint on plain ground`});let E=[],N=o.t;o.objects.forEach((D,V)=>{if(!D.doc)return;let[F,M]=Br(D.doc),L=be(D.doc,0),A=[];for(let z=0;z<M;z++)for(let R=0;R<F;R++){if(fm(D.fp,R,z)||dm(D.fp,R,z).roof)continue;let C=!1;for(let U=0;U<D.doc.cellH&&!C;U++)for(let W=0;W<D.doc.cellW;W++)if(L[(z*D.doc.cellH+U)*D.doc.width+R*D.doc.cellW+W]!==65535){C=!0;break}C&&A.push([Math.floor(D.px/N)+R,Math.floor(D.py/N)+z])}A.length&&E.push({label:`${D.name} at ${D.x},${D.y}: art outside its footprint is not a roof (an actor walking behind would be drawn over it)`,cells:A})});let T=new Map;for(let D=0;D<o.roofOwner.length;D++){let V=o.roofOwner[D],F=o.artOwner[D];if(V<0||F<0||F===V||o.objects[F].base<=o.objects[V].base)continue;let M=`${V}>${F}`,L=T.get(M);L||T.set(M,L=new Set),L.add(Math.floor(Math.floor(D/o.w)/N)*a+Math.floor(D%o.w/N))}for(let[D,V]of T){let[F,M]=D.split(">").map(Number),L=o.objects[F],A=o.objects[M];E.push({label:`${L.name} at ${L.x},${L.y}: its roof hides ${A.name} at ${A.x},${A.y}, which stands in front of it`,cells:[...V].map(z=>[z%a,Math.floor(z/a)])})}s.push({id:"draworder",score:E.length,limit:0,pass:E.length===0,shown:String(E.length),limitText:"0",groups:E,detail:E.length?E.slice(0,6).map(D=>D.label).join("; "):"objects in order of their base row; overhangs are roofs; no roof hides what stands in front"});let q=[],Z=new Map;for(let D=0;D<c;D++)for(let V=0;V<a;V++){let F=o.top[D*a+V];if(!F||!F.variant||F.variant==="outside")continue;let M=!0;for(let L=0;L<N&&M;L++)for(let A=0;A<N;A++)if(o.ground[(D*N+L)*o.w+V*N+A]!==65535){M=!1;break}if(M){let L=`${F.asset}.${F.variant}`;Z.set(L,[...Z.get(L)??[],[V,D]])}}for(let[D,V]of Z)q.push({label:`${D} is not drawn`,cells:V});for(let D of o.problems)q.push({label:D,cells:[]});return s.push({id:"coverage",score:q.length,limit:0,pass:q.length===0,shown:String(q.length),limitText:"0",groups:q,detail:q.length?q.map(D=>D.label).join("; "):"every tile and object the map names exists and is drawn"}),s}function A5(e,t,r,o){let{t:n,cols:i,rows:s}=e,a=n*n,c=Math.max(2,Math.round(a/128)),l=Math.max(0,Math.round(n/16)-1),u=Math.ceil(n*.75),m=e.palette.map(z=>JT(z.hex)),d=z=>{let R=z;for(let C=0;C<8;C++){let U=t.get(R)?.variantOf;if(!U||!t.get(U))break;R=U}return R},f=Array.from({length:i*s},()=>null),p=Array.from({length:i*s},()=>null),h=new Int32Array(a),g=z=>z.sort((R,C)=>R-C)[z.length>>1];for(let z=0;z<s;z++)for(let R=0;R<i;R++){let C=z*i+R,U=e.top[C];if(!U||U.edge||r[C])continue;let W=[],X=[],Y=[];for(let de=0;de<n;de++)for(let ae=0;ae<n;ae++){let pe=e.ground[(z*n+de)*e.w+R*n+ae];if(h[de*n+ae]=pe===65535?-1:pe,pe!==65535){let Ie=m[pe];W.push(Ie[0]),X.push(Ie[1]),Y.push(Ie[2])}}if(W.length<a*.9)continue;let fe=[g(W),g(X),g(Y)],ye=new Uint8Array(a);for(let de=0;de<a;de++){if(h[de]<0)continue;let ae=m[h[de]];Math.hypot(ae[0]-fe[0],ae[1]-fe[1],ae[2]-fe[2])>=o.latticeContrast&&(ye[de]=1)}let H=[],Q=new Uint8Array(a);for(let de=0;de<a;de++){if(!ye[de]||Q[de])continue;let ae=[de];Q[de]=1;let pe=n,Ie=n,Je=-1,Ze=-1,Ye=0,Xe=0;for(let Pt=0;Pt<ae.length;Pt++){let bt=ae[Pt],wn=bt%n,Gt=bt/n|0;pe=Math.min(pe,wn),Je=Math.max(Je,wn),Ie=Math.min(Ie,Gt),Ze=Math.max(Ze,Gt),Ye+=wn,Xe+=Gt;for(let Cn=-1;Cn<=1;Cn++)for(let Vn=-1;Vn<=1;Vn++){let Zn=wn+Vn,ur=Gt+Cn;if(Zn<0||ur<0||Zn>=n||ur>=n)continue;let Hn=ur*n+Zn;ye[Hn]&&!Q[Hn]&&(Q[Hn]=1,ae.push(Hn))}}ae.length<c||Je-pe+1>u||Ze-Ie+1>u||H.push({at:Math.floor(Xe/ae.length)*n+Math.floor(Ye/ae.length),weight:ae.length,pts:ae})}if(f[C]=`${d(U.asset)}.${U.variant??""}`,!H.length)continue;let re=H.reduce((de,ae)=>de+ae.weight,0);for(let de of H)de.weight/=re;p[C]=H}let b=z=>{let R=new Float64Array(a);for(let C of z){let U=C.at%n,W=C.at/n|0;for(let X=-l;X<=l;X++)for(let Y=-l;Y<=l;Y++){let fe=U+Y,ye=W+X;fe>=0&&ye>=0&&fe<n&&ye<n&&(R[ye*n+fe]=Math.max(R[ye*n+fe],C.weight))}}return R},y=new Map;for(let z=0;z<f.length;z++){let R=f[z];if(!R)continue;let C=y.get(R);if(C||y.set(R,C={cells:0,shown:new Float64Array(a),count:new Int32Array(a)}),C.cells++,!p[z])continue;let U=b(p[z]);for(let W=0;W<a;W++)U[W]>0&&(C.shown[W]+=U[W],C.count[W]++)}let w=8,v=null;for(let[z,R]of y){if(R.cells<w)continue;let C=0;for(let W=1;W<a;W++)R.shown[W]>R.shown[C]&&(C=W);let U=R.shown[C]/R.cells;(!v||U>v.share)&&(v={ground:z,share:U,n:R.count[C],cells:R.cells,at:C})}let S=z=>`${Math.round(z*100)}%`,_=`\u2264 ${S(o.lattice)}`,$={id:"lattice",limit:o.lattice,limitText:_};if(!v||v.n===0){let z=[...y.values()].reduce((R,C)=>R+(C.cells>=w?1:0),0);return{...$,score:0,pass:!0,shown:"0%",groups:[],detail:z?`no mark comes back at the same spot of the cell (${z} ground${z===1?"":"s"} looked at)`:"no stretch of plain ground big enough to show a lattice"}}let x=[],k=new Map,P=new Int32Array(a),I=v.at%n,E=v.at/n|0;for(let z=0;z<f.length;z++){if(f[z]!==v.ground||!p[z])continue;let R=p[z].filter(U=>Math.abs(U.at%n-I)<=l&&Math.abs((U.at/n|0)-E)<=l);if(!R.length)continue;x.push([z%i,Math.floor(z/i)]);let C=e.top[z].asset;k.set(C,(k.get(C)??0)+1);for(let U of R)for(let W of U.pts)P[W]++}let N=n,T=n,q=-1,Z=-1,D=P.reduce((z,R)=>Math.max(z,R),0);for(let z=0;z<a;z++)if(P[z]>=D*.75){let R=z%n,C=z/n|0;N=Math.min(N,R),q=Math.max(q,R),T=Math.min(T,C),Z=Math.max(Z,C)}let[V]=v.ground.split("."),F=v.share<=o.lattice,M=`${N},${T} ${q-N+1}x${Z-T+1}`,L=Math.abs(v.share-v.n/v.cells)>.005?` (as ${S(v.share*v.cells/v.n)} of their marking, on average)`:"",A=`a mark at ${M} of the cell (${[...k].map(([z,R])=>`${z} \xD7${R}`).join(", ")}) comes back on the tile pitch`;return{...$,score:Number(v.share.toFixed(3)),pass:F,shown:S(v.share),groups:F?[]:[{label:A,cells:x}],detail:`${F?`the mark most often at one spot: at ${M} of the cell (${[...k].map(([z,R])=>`${z} \xD7${R}`).join(", ")})`:A}: ${v.n} of the ${v.cells} cells of ${V}'s ground show it at the same spot${L}`+(F?"":`; give ${V} texture variants that move or leave out the mark (variant of=${V}) and fill with a mix of them (tiles <layer> fill mix=${V}:1,<variant>:2,...; a terrain's inside: layer set <layer> mix=\u2026), or soften the mark`)}}function HT(e,t,r=0){let o=be(e,r),n=be(t,Math.min(r,t.frameCount-1)),i=(f,p)=>{let h=new Map,g=0,b=0;for(let y of f){if(y===65535)continue;let w=p.palette.entries[y].hex;h.set(w,(h.get(w)??0)+1),b+=Vr(w),g++}return{n:h,tot:Math.max(1,g),l:b/Math.max(1,g)}},s=i(o,e),a=i(n,t),c=0;for(let f of new Set([...s.n.keys(),...a.n.keys()]))c+=Math.abs((s.n.get(f)??0)/s.tot-(a.n.get(f)??0)/a.tot);let l=Math.abs(s.l-a.l),u=[],m=e.width,d=e.height;if(t.width===m&&t.height===d&&!e.family)for(let f=0;f<d;f++)for(let p=0;p<m;p++){if(p!==0&&f!==0&&p!==m-1&&f!==d-1)continue;let h=o[f*m+p],g=n[f*m+p],b=h===65535?"":e.palette.entries[h].hex,y=g===65535?"":t.palette.entries[g].hex;b!==y&&u.push([p,f])}return{l1:c,dl:l,border:u,ok:c<.3&&l<2}}function BT(e,t=0){let[r,o]=Br(e),n=Dn(e),i=be(e,t),s=[];for(let a=0;a<o;a++)for(let c=0;c<r;c++){let l=new Uint16Array(e.cellW*e.cellH),u=!0;for(let m=0;m<e.cellH;m++)for(let d=0;d<e.cellW;d++){let f=i[(a*e.cellH+m)*e.width+c*e.cellW+d];l[m*e.cellW+d]=f,f!==65535&&(u=!1)}s.push({name:`${e.name}_${c}_${a}`,cx:c,cy:a,px:l,empty:u})}return{pieces:s,stamp:{asset:e.name,cellW:e.cellW,cellH:e.cellH,cols:r,rows:o,pieces:s.map(a=>({name:a.name,dx:a.cx,dy:a.cy,...dm(n,a.cx,a.cy),footprint:fm(n,a.cx,a.cy)})),anchor:[n.at[0]+n.anchor[0],n.at[1]+n.anchor[1]],footprint:[n.cols,n.rows],at:[n.at[0],n.at[1]]}}}function WT(e,t,r,o=2){let n=Bt(t,r),i=e?.map&&e.width===t.width&&e.height===t.height?Bt(e,r):null,s=n.t,a=n.cols,c=n.rows,l=[];for(let I=0;I<c;I++)for(let E=0;E<a;E++){let N=!i;for(let T=0;T<s&&!N;T++)for(let q=0;q<s;q++){let Z=(I*s+T)*n.w+E*s+q,D=n.px[Z],V=i.px[Z],F=D===65535?"":n.palette[D].hex,M=V===65535?"":i.palette[V].hex;if(F!==M){N=!0;break}}N&&l.push([E,I])}let u=(I,E)=>{let N=I.map.entries[E.entry];return`${I.layers[E.layer].name}|${N.name}${N.variant?`.${N.variant}`:""}`},m=e?.map?Hr(e).map(I=>({k:u(e,I),p:I})):[],d=Hr(t).map(I=>({k:u(t,I),p:I})),f=m.filter(I=>!d.some(E=>E.k===I.k&&E.p.x===I.p.x&&E.p.y===I.p.y)),p=d.filter(I=>!m.some(E=>E.k===I.k&&E.p.x===I.p.x&&E.p.y===I.p.y)),h=[];for(let I of[...f]){let E=p.findIndex(T=>T.k===I.k);if(E<0)continue;let N=p[E];h.push(`moved: ${I.k.split("|")[1]} ${I.p.x},${I.p.y} \u2192 ${N.p.x},${N.p.y} (layer ${I.k.split("|")[0]})`),p.splice(E,1),f.splice(f.indexOf(I),1)}for(let I of f)h.push(`taken away: ${I.k.split("|")[1]} at ${I.p.x},${I.p.y} (layer ${I.k.split("|")[0]})`);for(let I of p)h.push(`placed: ${I.k.split("|")[1]} at ${I.p.x},${I.p.y} (layer ${I.k.split("|")[0]})`);t.layers.forEach((I,E)=>{if(I.map?.kind!=="terrain"||!e?.map)return;let N=e.layers.findIndex(V=>V.name===I.name);if(N<0){h.push(`terrain layer ${I.name} added`);return}let T=t.cels[E][0],q=e.cels[N][0],Z=0,D=0;for(let V=0;V<T.length;V++)T[V]===1&&q[V]!==1?Z++:T[V]!==1&&q[V]===1&&D++;(Z||D)&&h.push(`terrain ${I.name}: ${Z} cells painted, ${D} erased`)});let g=l.length?`${l.length} cells look different${h.length?`; ${h.join("; ")}`:""}`:`no cell looks different${h.length?`; ${h.join("; ")}`:""}`,b=l.map(I=>I[0]),y=l.map(I=>I[1]),w=l.length?{x:Math.max(0,Math.min(...b)-1),y:Math.max(0,Math.min(...y)-1),x1:Math.min(a-1,Math.max(...b)+1),y1:Math.min(c-1,Math.max(...y)+1)}:{x:0,y:0,x1:Math.min(a,8)-1,y1:Math.min(c,6)-1},v={x:w.x,y:w.y,w:w.x1-w.x+1,h:w.y1-w.y+1},S=yi(n,{scale:o,region:v,marks:l}),_=i?yi(i,{scale:o,region:v,marks:l}):null,$=8,x=S.width*2+$,k=S.height,P=new Uint8Array(x*k*4);for(let I=0;I<k;I++)for(let E=0;E<x;E++){let N=(I*x+E)*4,T=E<S.width?_:E>=S.width+$?S:null,q=E<S.width?E:E-S.width-$;if(!T){P[N]=30,P[N+1]=31,P[N+2]=36,P[N+3]=255;continue}let Z=(I*S.width+q)*4;P[N]=T.data[Z],P[N+1]=T.data[Z+1],P[N+2]=T.data[Z+2],P[N+3]=255}return{cells:l,text:g,img:{width:x,height:k,data:P}}}function vy(e){let t=e.trim(),r=/^(\d+),(\d+)(?:\s+|,)(\d+)x(\d+)$/.exec(t)??/^(\d+),(\d+),(\d+),(\d+)$/.exec(t);if(!r)return null;let[o,n,i,s]=r.slice(1).map(Number);return{x:o,y:n,w:i,h:s}}function WS(e,t){let r=Math.floor(e/t);return r*t>e?r--:(r+1)*t<=e&&r++,r}function pm(e){let t=Math.floor(Math.sqrt(e));for(;t*t>e;)t--;for(;(t+1)*(t+1)<=e;)t++;return t}function Ss(e,t=0,r=1){let o=e.value.trim(),n=null,i;if((i=/^(\d+)\/(\d+)$/.exec(o))&&Number(i[2])>0)n={num:Number(i[1]),den:Number(i[2]),text:`${Number(i[1])}/${Number(i[2])}`};else if((i=/^(\d*)(?:\.(\d{1,6}))?(%?)$/.exec(o))&&(i[1]||i[2])){let s=i[2]??"",a=Number((i[1]||"0")+s),c=10**s.length;i[3]&&(c*=100);let l=s.length+(i[3]?2:0);for(;l>0&&a%10===0;)a/=10,c/=10,l--;let u=Math.floor(a/c),m=String(a-u*c).padStart(l,"0");n={num:a,den:c,text:l?`${u}.${m}`:String(u)}}if(!n)throw new O(e.line,e.vcol,`${e.key}= must be a number like 0.25, 3/16 or 25%`);if(n.num*1<t*n.den||n.num>r*n.den)throw new O(e.line,e.vcol,`${e.key}= must be between ${t} and ${r}`);return n}function Ct(e,t,r){if(!/^-?\d+$/.test(e.value))throw new O(e.line,e.vcol,`${e.key}= must be a whole number`);let o=Number(e.value);if(o<t||o>r)throw new O(e.line,e.vcol,`${e.key}= must be ${t}..${r}`);return o}function $c(e,t,r){let o=/^(\d+)(?:\.\.(\d+))?$/.exec(e.value);if(!o)throw new O(e.line,e.vcol,`${e.key}= must be a range like 2..4`);let n=Number(o[1]),i=Number(o[2]??o[1]);if(n<t||i>r||n>i)throw new O(e.line,e.vcol,`${e.key}= must be within ${t}..${r}, smallest first`);return[n,i]}function $y(e,t){let r=e.value.split(",");if(!r.every(n=>/^\d+$/.test(n)))throw new O(e.line,e.vcol,`${e.key}= must be whole numbers like 1,6,2`);let o=r.map(Number);if(o.length!==t)throw new O(e.line,e.vcol,`${e.key}= needs ${t} weights (one per colour), not ${o.length}`);if(o.every(n=>n===0))throw new O(e.line,e.vcol,`${e.key}= needs a weight above 0`);if(o.some(n=>n>1e4))throw new O(e.line,e.vcol,`${e.key}= weights must be at most 10000`);return o}function bi(e,t){let r=e.value,o=t.ramps[r],n=a=>t.entries.findIndex(c=>c.name===a||[...a].length===1&&c.key===a);if(o)return{name:r,idx:o.map(n),text:r};let i=r.split(",");if(i.length<2){let a=Object.keys(t.ramps);throw new O(e.line,e.vcol,`unknown ramp '${r}' (palette '${t.name}' ramps: ${a.length?a.join(", "):"none"}; or list entries: ramp=a,b,c)`)}let s=[];for(let a of i){let c=n(a);if(c<0)throw new O(e.line,e.vcol,`ramp: '${a}' is not an entry of palette '${t.name}'`);s.push(c)}return{name:null,idx:s,text:s.map(a=>t.entries[a].name).join(",")}}function hm(e,t){let r=e.entries[t]?.name,o=[];for(let n of Object.values(e.ramps)){let i=n.indexOf(r??"");i>=0&&o.push({ramp:n.map(s=>e.entries.findIndex(a=>a.name===s)),at:i})}return o}var Rs=[30,31,36],GT=[120,126,136],ym=[216,219,224],Is=[204,204,204],xc=[238,238,238],KT=[255,79,216],wi=[255,0,200],O5=[[7,5,5,5,7],[2,6,2,2,7],[7,1,7,4,7],[7,1,7,1,7],[5,5,7,1,1],[7,4,7,1,7],[7,4,7,5,7],[7,1,1,1,1],[7,5,7,5,7],[7,5,7,1,7]];function ht(e,t,r,o,n=255){if(t<0||r<0||t>=e.width||r>=e.height)return;let i=(r*e.width+t)*4;e.data[i]=o[0],e.data[i+1]=o[1],e.data[i+2]=o[2],e.data[i+3]=n}function gn(e,t,r,o,n,i){for(let s=0;s<n;s++)for(let a=0;a<o;a++)ht(e,t+a,r+s,i)}function YT(e,t,r,o){if(t<0||r<0||t>=e.width||r>=e.height)return;let n=(r*e.width+t)*4,i=e.data,a=i[n]*77+i[n+1]*150+i[n+2]*29>>8>100?0:255;for(let c=0;c<3;c++)i[n+c]=i[n+c]*(256-o)+a*o>>8}function bm(e,t,r,o,n){if(t<0||r<0||t>=e.width||r>=e.height)return;let i=(r*e.width+t)*4;for(let s=0;s<3;s++)e.data[i+s]=e.data[i+s]*(256-n)+o[s]*n>>8}var N5={A:[2,5,7,5,5],B:[6,5,6,5,6],C:[3,4,4,4,3],D:[6,5,5,5,6],E:[7,4,6,4,7],F:[7,4,6,4,4],G:[3,4,5,5,3],H:[5,5,7,5,5],I:[7,2,2,2,7],J:[1,1,1,5,2],K:[5,5,6,5,5],L:[4,4,4,4,7],M:[5,7,7,5,5],N:[6,5,5,5,5],O:[2,5,5,5,2],P:[6,5,6,4,4],Q:[2,5,5,6,3],R:[6,5,6,5,5],S:[3,4,2,1,6],T:[7,2,2,2,2],U:[5,5,5,5,7],V:[5,5,5,5,2],W:[5,5,7,7,5],X:[5,5,2,5,5],Y:[5,5,2,2,2],Z:[7,1,2,4,7],"%":[5,1,2,4,5],"-":[0,0,7,0,0],".":[0,0,0,0,2],">":[4,2,1,2,4],_:[0,0,0,0,7],":":[0,2,0,2,0],"/":[1,1,2,4,4],"+":[0,2,7,2,0]};function Wr(e,t,r,o,n,i){for(let s of o){let a=O5[s.charCodeAt(0)-48]??N5[s.toUpperCase()];a&&a.forEach((c,l)=>{for(let u=0;u<3;u++)c&4>>u&&gn(e,t+u*i,r+l*i,i,i,n)}),t+=4*i}}var ks=(e,t)=>e.length*4*t-t;function eC(e,t,r,o,n,i=1){return Wr(e,t,r,o,n,i),ks(o,i)}function Jr(e,t){return NS(e.palette,t).entries.map(r=>it(r.hex))}function wm(e,t,r,o,n,i,s){for(let[a,c]of n){if(a<0||c<0||a>=i||c>=s)continue;let l=t+a*o,u=r+c*o;if(o<4){for(let p=0;p<o;p++)for(let h=0;h<o;h++)ht(e,l+h,u+p,wi);continue}let m=o+Math.max(2,o>>1),d=o>=8?4:2,f=(m>>1)+1;for(let p=-f;p<o+f;p++)for(let h=-f;h<o+f;h++){let g=2*h+1-o,b=2*p+1-o,y=g*g+b*b;y<=m*m&&y>(m-d)*(m-d)&&ht(e,l+h,u+p,wi)}}}function vi(e,t=0,r){let o=be(e,t),n=Jr(e,r),i=ut(e.width,e.height);for(let s=0;s<o.length;s++){if(o[s]===65535)continue;let a=n[o[s]];i.data.set([a[0],a[1],a[2],255],s*4)}return i}function tC(e){return Math.max(1,Math.min(16,Math.floor(192/Math.max(e.width,e.height))))}function nC(e,t){let o=e.layers.filter(s=>s.underlay&&!s.hidden).map(s=>s.underlay).map(s=>({u:s,img:t(s.blob)})).filter(s=>!!s.img);if(!o.length)return null;let n=Math.max(1,Math.min(8,Math.round(Math.max(...o.map(({u:s})=>Math.max(s.iw/s.w,s.ih/s.h)))))),i=ut(e.width*n,e.height*n);for(let{u:s,img:a}of o)for(let c=Math.max(0,s.y*n);c<Math.min(i.height,(s.y+s.h)*n);c++){let l=Math.min(a.height-1,Math.floor((c-s.y*n+.5)*a.height/(s.h*n)));for(let u=Math.max(0,s.x*n);u<Math.min(i.width,(s.x+s.w)*n);u++){let m=Math.min(a.width-1,Math.floor((u-s.x*n+.5)*a.width/(s.w*n))),d=(l*a.width+m)*4;a.data[d+3]<128||i.data.set([a.data[d],a.data[d+1],a.data[d+2],255],(c*i.width+u)*4)}}return i}function XT(e,t){return[e[0]+t[0]>>1,e[1]+t[1]>>1,e[2]+t[2]>>1]}function ky(e,t={}){let r=t.scale??tC(e),o=(t.grid??!0)&&r>=4,n=t.rulers??!0,i=r>=6?2:1,{x:s,y:a,w:c,h:l}=t.region??{x:0,y:0,w:e.width,h:e.height},u=String(Math.max(s+c,a+l)).length,m=n?5*i+9:0,d=n?2+ks("0".repeat(u),i)+3+5:0,f=c*r,p=l*r,h=ut(d+f+1,m+p+1);gn(h,0,0,h.width,h.height,Rs);let g=be(e,t.frame??0),b=tT(e,t.frame??0),y=t.underlay??null,w=Jr(e,t.theme),v=Math.max(2,r>>1),S=e.width*r,_=e.height*r;for(let x=0;x<l;x++)for(let k=0;k<c;k++){let P=s+k,I=a+x,E=g[I*e.width+P],N=b?b[I*e.width+P]:65535;for(let T=0;T<r;T++)for(let q=0;q<r;q++){let Z;if(E!==65535)Z=w[E];else if(Z=(((P*r+q)/v|0)+((I*r+T)/v|0))%2?Is:xc,N!==65535)Z=XT(w[N],Z);else if(y){let D=(Math.floor((I*r+T)*y.height/_)*y.width+Math.floor((P*r+q)*y.width/S))*4;y.data[D+3]>=128&&(Z=XT([y.data[D],y.data[D+1],y.data[D+2]],Z))}ht(h,d+k*r+q,m+x*r+T,Z)}}if(o){for(let x=0;x<=c;x++){let k=(s+x)%8===0?80:30;for(let P=0;P<p;P++)YT(h,d+x*r,m+P,k)}for(let x=0;x<=l;x++){let k=(a+x)%8===0?80:30;for(let P=0;P<f+1;P++)(P%r!==0||P===f)&&YT(h,d+P,m+x*r,k)}}if(e.cellW<e.width||e.cellH<e.height){for(let x=e.cellW;x<e.width;x+=e.cellW)if(x>s&&x<s+c)for(let k=0;k<p;k++)bm(h,d+(x-s)*r,m+k,KT,180);for(let x=e.cellH;x<e.height;x+=e.cellH)if(x>a&&x<a+l)for(let k=0;k<f;k++)bm(h,d+k,m+(x-a)*r,KT,180)}if(t.marks?.length){let x=t.marks.filter(([k,P])=>k>=s&&P>=a&&k<s+c&&P<a+l).map(([k,P])=>[k-s,P-a]);x.length&&wm(h,d,m,r,x,c,l)}if(n){for(let x=0;x<=c;x++){let k=s+x,P=k%8===0;!P&&r<4||(gn(h,d+x*r,m-(P?6:3),1,P?6:3,P?ym:GT),P&&x<c&&Wr(h,d+x*r+2,2,String(k),ym,i))}for(let x=0;x<=l;x++){let k=a+x,P=k%8===0;if(!(!P&&r<4)&&(gn(h,d-(P?6:3),m+x*r,P?6:3,1,P?ym:GT),P&&x<l)){let I=String(k);Wr(h,d-8-ks(I,i),m+x*r+2,I,ym,i)}}}return h}function zy(e,t=0,r={}){let n=e.width,i=e.height,s=r.scale??4,a=ut(8+3*n+8+3*s*n+8,8+Math.max(3*i,3*s*i)+8);gn(a,0,0,a.width,a.height,Rs);let c=be(e,t),l=Jr(e,r.theme),u=(m,d,f)=>{for(let p=0;p<3;p++)for(let h=0;h<3;h++)for(let g=0;g<i;g++)for(let b=0;b<n;b++){let y=c[g*n+b],w=(h*n+b)*f,v=(p*i+g)*f;for(let S=0;S<f;S++)for(let _=0;_<f;_++){let $=y===65535?((w+_>>2)+(v+S>>2))%2?Is:xc:l[y];ht(a,m+w+_,d+v+S,$)}}};return u(8,8,1),u(8+3*n+8,8,s),r.marks?.length&&wm(a,8+3*n+8+s*n,8+s*i,s,r.marks,n,i),a}function rC(e,t,r=0){let o=t??{x:0,y:0,w:e.width,h:e.height},n=be(e,r),i={width:e.width,height:e.height,wrap:e.wrap,pixels:n},s=o.y+o.h-1,a=o.x+o.w-1,c=Math.max(2,String(s).length),l=" ".repeat(c+2),u=[],m=h=>{let g="";for(let b=o.x;b<=a;b++)g+=h(b);return(l+g).trimEnd()},d=Math.max(2,String(a).length);for(let h=d-1;h>=1;h--){let g=10**h;u.push(m(b=>b%g===0||b===o.x?String(Math.floor(b/g)%10):" "))}u.push(m(h=>String((h%10+10)%10)));let f=new Map;for(let h=o.y;h<=s;h++){let g="";for(let b=o.x;b<=a;b++){let y=Rt(i,b,h);if(y<0){g+=" ";continue}let w=n[y];f.set(w,(f.get(w)??0)+1),g+=w===65535?".":e.palette.entries[w].key}u.push(String(h).padStart(c)+" "+g)}u.push("");let p=[...f.entries()].sort((h,g)=>h[0]-g[0]);for(let[h,g]of p)if(h===65535)u.push(` . (transparent) ${g} px`);else{let b=e.palette.entries[h];u.push(` ${b.key} ${b.name.padEnd(10)} ${b.hex} ${g} px`)}return u.join(`
126
+ `)+`
127
+ `}function vm(e,t){let r=e&&e.width===t.width&&e.height===t.height,o=[];for(let n=0;n<t.frameCount;n++){let i=be(t,n),s=r&&n<e.frameCount?be(e,n):null;for(let a=0;a<i.length;a++){let c=s?s[a]:65535;s&&c===i[a]||!s&&i[a]===65535&&r||o.push({x:a%t.width,y:Math.floor(a/t.width),from:c,to:i[a],f:n})}}return o}var xy=[255,214,10];function Ry(e,t,r,o=60){let n=(c,l)=>l===65535?"none":c?.palette.entries[l]?.name??`#${l}`;if(r.length===0)return"no pixels changed";let i=t.frameCount>1||(e?.frameCount??1)>1,s=[...new Set(r.map(c=>c.f))].map(c=>`frame ${c+1}: ${r.filter(l=>l.f===c).length}`),a=`${r.length} px changed${i?` (${s.join(", ")})`:""}`;return r.length>o?`${a} (more than ${o}: see the image)`:[a+":",...r.map(c=>` ${i?`f${c.f+1} `:""}${c.x},${c.y} ${n(e,c.from)}\u2192${n(t,c.to)}`)].join(`
128
+ `)}function oC(e,t,r={}){let o=vm(e,t),n=r.scale??tC(t),i=8,s=t.width*n,a=t.height*n,c=e?e.width*n:s,l=e?e.height*n:a,u=o.length>(r.limit??60)?3:2,m=t.frameCount>1||(e?.frameCount??1)>1,d=[...new Set(o.map(w=>w.f))].sort((w,v)=>w-v),f=m&&d.length?d:[0],p=m?ks(String(t.frameCount),2)+i:0,h=Math.max(l,a)+i,g=ut(p+i+c+i+(s+i)*(u-1),i+h*f.length);gn(g,0,0,g.width,g.height,Rs);let b=(w,v,S,_,$)=>{let x=v<w.frameCount?be(w,v):new Uint16Array(w.width*w.height).fill(65535),k=Jr(w),P=Math.max(2,n>>1);for(let I=0;I<w.height;I++)for(let E=0;E<w.width;E++){let N=x[I*w.width+E];for(let T=0;T<n;T++)for(let q=0;q<n;q++){let Z=N===65535?(((E*n+q)/P|0)+((I*n+T)/P|0))%2?Is:xc:k[N];ht(g,S+E*n+q,_+I*n+T,Z),$&&bm(g,S+E*n+q,_+I*n+T,Rs,190)}}},y=(w,v,S,_,$,x)=>{for(let k of o){if(k.f!==w||k.x>=_||k.y>=$)continue;let P=v+k.x*n,I=S+k.y*n;if(x||n<4){for(let N=0;N<n;N++)for(let T=0;T<n;T++)x?ht(g,P+T,I+N,wi):bm(g,P+T,I+N,wi,150);continue}let E=n>=8?2:1;for(let N=0;N<n;N++)for(let T=0;T<E;T++)ht(g,P+N,I+T,wi),ht(g,P+N,I+n-1-T,wi),ht(g,P+T,I+N,wi),ht(g,P+n-1-T,I+N,wi)}};return f.forEach((w,v)=>{let S=i+v*h;m&&Wr(g,i,S+2,String(w+1),ym,2);let _=p+i;e&&(b(e,w,_,S,!1),y(w,_,S,e.width,e.height,!1));let $=_+c+i;b(t,w,$,S,!1),y(w,$,S,t.width,t.height,!1);for(let x of t.notes){let k=Math.max($,$+x.x*n-1),P=Math.max(S,S+x.y*n-1),I=Math.min($+s-1,$+(x.x+x.w)*n),E=Math.min(S+a-1,S+(x.y+x.h)*n);for(let N=k;N<=I;N++)(N-k>>1)%2===0&&(ht(g,N,P,xy),ht(g,N,E,xy));for(let N=P;N<=E;N++)(N-P>>1)%2===0&&(ht(g,k,N,xy),ht(g,I,N,xy))}if(u===3){let x=$+s+i;b(t,w,x,S,!0),y(w,x,S,t.width,t.height,!0)}}),g}var M5=[88,94,102];function $m(e,t={}){let r=Math.max(1,t.scale??2),o=8,n=8,i=Math.max(1,...e.map(b=>b.doc.height)),s=n*2+e.reduce((b,y)=>b+y.doc.width,0)+o*Math.max(0,e.length-1),a=n*2+i,c=[],l=t.ground?be(t.ground,0):null,u=t.ground?Jr(t.ground,t.theme):[];for(let b=0;b<a;b++)for(let y=0;y<s;y++){let w=l?l[b%t.ground.height*t.ground.width+y%t.ground.width]:65535;c.push(w===65535?M5:u[w])}let m=n,d=[n,n+i-(e[0]?.doc.height??0)];for(let b of e){let y=be(b.doc,b.frame??0),w=Jr(b.doc,t.theme),v=n+i-b.doc.height;for(let S=0;S<b.doc.height;S++)for(let _=0;_<b.doc.width;_++){let $=y[S*b.doc.width+_];$!==65535&&(c[(v+S)*s+m+_]=w[$])}m+=b.doc.width+o}let f=8,p=r===1,h=p?0:a+f,g=ut(f+Math.max(s,s*r)+f,f+h+a*r+f);gn(g,0,0,g.width,g.height,Rs);for(let b=0;b<a;b++)for(let y=0;y<s;y++){let w=c[b*s+y];p||ht(g,f+y,f+b,w);for(let v=0;v<r;v++)for(let S=0;S<r;S++)ht(g,f+y*r+S,f+h+b*r+v,w)}return t.marks?.length&&e[0]&&wm(g,f+d[0]*r,f+h+d[1]*r,r,t.marks,e[0].doc.width,e[0].doc.height),g}function iC(e,t,r={}){let o=r.scale??Math.max(1,Math.min(4,Math.floor(96/Math.max(e.width,e.height)))),n=8,i=e.width*o,s=e.height*o,a=Math.max(4,Math.floor(i/Ht.length)),c=Math.max(1,t.length),l=ut(n+c*(i+n),n+s+4+6+n);gn(l,0,0,l.width,l.height,Rs);let u=be(e,r.frame??0),m=Math.max(2,o>>1);return t.forEach((d,f)=>{let p=n+f*(i+n),h=Jr(e,d);for(let g=0;g<e.height;g++)for(let b=0;b<e.width;b++){let y=u[g*e.width+b];for(let w=0;w<o;w++)for(let v=0;v<o;v++){let S=y===65535?(((b*o+v)/m|0)+((g*o+w)/m|0))%2?Is:xc:h[y];ht(l,p+b*o+v,n+g*o+w,S)}}Ht.forEach((g,b)=>gn(l,p+b*a,n+s+4,a,6,it(d.colours[g])))}),l}var gm=[64,220,230],D5=[255,110,70],sC=[58,60,68],QT=[216,219,224],_y=[150,156,166],aC=e=>`${Math.round(e*100)}%`;function cC(e,t,r){let o=be(e,t),n=be(e,r),i=0,s=0;for(let a=0;a<o.length;a++)(o[a]!==65535||n[a]!==65535)&&s++,o[a]!==n[a]&&i++;return s?i/s:0}var lC=(e,t)=>t.scale??Math.max(2,Math.min(8,Math.floor(96/Math.max(e.width,e.height))));function JS(e,t){let r=tr(e);if(!t.only?.length)return r;let o=r.filter(n=>t.only.includes(n.name));if(!o.length)throw new Error(`no sequence named ${t.only.join(", ")} (sequences: ${r.map(n=>n.name).join(", ")})`);return o}function q5(e,t){let r=Lr(e);if(r.length<2)return null;let o=r.indexOf(e.frames[t]);return r[(o-1+r.length)%r.length]}function Iy(e,t={}){let r=lC(e,t),o=JS(e,t),n=e.width*r,i=e.height*r,s=8,a=2,c=5*a+4,l=Math.max(...o.map(h=>Math.max(ks(h.name,a),ks(h.mirror?"MIRROR":h.loop,a),ks(`${nr(e,h)}T`,a))))+s,u=Math.max(...o.map(h=>h.frames.length)),m=c+i+c+s,d=ut(s+l+u*(n+s),s+o.length*m);gn(d,0,0,d.width,d.height,Rs);let f=Jr(e,t.theme),p=Math.max(2,r>>1);return o.forEach((h,g)=>{let b=s+g*m;Wr(d,s,b+c,h.name,QT,a),Wr(d,s,b+c*2,h.mirror?"MIRROR":h.loop,_y,a),Wr(d,s,b+c*3,`${nr(e,h)}T`,_y,a),h.frames.forEach((y,w)=>{let v=s+l+w*(n+s);Wr(d,v,b,`${y+1} ${e.ticks[y]}T`,QT,a);let S=be(e,y),_=q5(h,w),$=_!==null&&_!==y?be(e,_):null;for(let x=0;x<e.height;x++)for(let k=0;k<e.width;k++){let P=x*e.width+k,I=S[P];for(let E=0;E<r;E++)for(let N=0;N<r;N++){let T=v+k*r+N,q=b+c+x*r+E;if(I!==65535){ht(d,T,q,f[I]);continue}ht(d,T,q,(((k*r+N)/p|0)+((x*r+E)/p|0))%2?Is:xc),$&&$[P]!==65535&&bm(d,T,q,D5,110)}}if(!e.wrap&&e.ground!==null)for(let x=0;x<n;x+=2)ht(d,v+x,b+c+(e.ground+1)*r-1,gm);if(!e.wrap&&e.pivot){let[x,k]=e.pivot,P=v+x*r,I=b+c+k*r;for(let E=-1;E<=r;E++)ht(d,P+E,I-1,gm),ht(d,P+E,I+r,gm),ht(d,P-1,I+E,gm),ht(d,P+r,I+E,gm)}_!==null&&_!==y&&Wr(d,v,b+c+i+4,`${_+1}>${y+1} ${aC(cC(e,_,y))}`,_y,a)})}),d}function uC(e,t={}){let r=t.tickRate??60,o=[`${e.name}: ${e.frameCount} frame${e.frameCount===1?"":"s"} at ${r} ticks/s`+(e.pivot?`; pivot ${e.pivot[0]},${e.pivot[1]}`:"")+(e.ground!==null?`; ground ${e.ground}`:"")];for(let n of JS(e,t)){let i=nr(e,n),s=Lr(n),a=s.length<2?[]:n.loop==="pingpong"?n.frames.slice(1).map((l,u)=>[n.frames[u],l]):s.map((l,u)=>[l,s[(u+1)%s.length]]),c=n.mirror?e.views.find(l=>l.name===n.name)?.mirror:null;o.push(` ${n.name}: ${c?`mirror of ${c}, `:""}${n.loop}, frames ${n.frames.map(l=>l+1).join(",")}, ticks ${n.frames.map(l=>e.ticks[l]).join(",")} (a loop is ${i} ticks, ${Math.round(i*1e3/r)} ms)`+(a.length?`; changed ${a.map(([l,u])=>`${l+1}\u2192${u+1} ${aC(cC(e,l,u))}`).join(", ")}`:""))}return o.join(`
129
+ `)}function Py(e,t={}){let r=t.scale??(e.wrap?Math.max(1,Math.min(4,Math.floor(72/e.width))):lC(e,t)),o=t.tickRate??60,n=JS(e,t),i=e.wrap?3:1,s=e.width*r*i,a=e.height*r*i,c=8,l=Jr(e,t.theme),u=(b,y)=>y?u(y,b%y):b,m=1;for(let b of n){let y=Math.max(1,nr(e,b));m=Math.min(o*60,m/u(m,y)*y)}let d=new Set([0]);for(let b of n){let y=Lr(b),w=0;for(let v=0;w<m;v++)d.add(w),w+=Math.max(1,e.ticks[y[v%y.length]])}let f=b=>Math.round(b*100/o),p=[...d].sort((b,y)=>b-y).filter((b,y,w)=>y===0||f(b)!==f(w[y-1])),h=new Map,g=b=>h.get(b)??h.set(b,be(e,b)).get(b);return p.map((b,y)=>{let w=y+1<p.length?p[y+1]:m,v=ut(c+n.length*(s+c),c+a+c);return gn(v,0,0,v.width,v.height,sC),n.forEach((S,_)=>{let $=g(Fr(e,S,b)),x=c+_*(s+c);for(let k=0;k<e.height*i;k++)for(let P=0;P<e.width*i;P++){let I=$[k%e.height*e.width+P%e.width];I!==65535&&gn(v,x+P*r,c+k*r,r,r,l[I])}}),{img:v,delay:Math.max(1,f(w)-f(b))}})}function Sy(e,t,r){let o=e.overlay?t.ground??null:e;if(!o)throw new Error("a map of an overlay needs a ground tile or family under it");let n=[...e.overlay?[e]:[],...t.overlays??[]],i=NS(o.palette,t.theme).entries.map(l=>({name:l.name,hex:l.hex})),s=n.map(l=>hC(l,i)),a,c=null;if(o.family){let l=Qe(o.family),u=t.cols??t.terrain?.cols??zs.cols,m=t.rows??t.terrain?.rows??zs.rows;c=t.terrain??$i(l,u,m,t.seed??zs.seed),a=_o(o,c,t.frame??yC(o,r))}else{let l=o.width;a=fC(o,t.cols??Math.max(4,Math.ceil(288/l)),t.rows??Math.max(3,Math.ceil(216/o.height)),t.frame??(o.frameCount>1?Fr(o,tr(o)[0],r):0))}return pC(a,s,r,o.family?o:null),{base:o,img:a,colours:i.map(l=>it(l.hex)),overlays:s,terrain:c}}function mC(e,t){let{img:r}=e,o=ut(r.w*t,r.h*t);for(let n=0;n<r.h;n++)for(let i=0;i<r.w;i++){let s=r.px[n*r.w+i];gn(o,i*t,n*t,t,t,s===65535?((i>>2)+(n>>2))%2?Is:xc:e.colours[s])}return o}function jy(e,t={}){return mC(Sy(e,t,t.tick??0),t.scale??2)}function dC(e,t={}){let r=Sy(e,t,t.tick??0),{img:o,base:n}=r,i={...o,px:o.px.slice()};n.family&&!t.terrain&&Cy(i,n,0);let s=_s(i,n),a=l=>String(Number(l.toFixed(2))),c=[`${o.w/o.t}x${o.h/o.t} tiles of ${o.t} px${n.family&&!t.terrain?`, a random island (seed ${t.seed??zs.seed})`:""}; seam ${a(s.score)} (jump x ${a(s.jx)} y ${a(s.jy)}, line x ${a(s.lx)} y ${a(s.ly)}; about 1 or less reads as no seam)`];if(n.family){let l=Qe(n.family),u=new Map;for(let d of o.variants)d!==null&&u.set(d,(u.get(d)??0)+1);let m=[...u.keys()].sort((d,f)=>d-f);c.push(`${m.length} of ${l.variants.length} variants on the map: ${m.map(d=>`${l.variants[d].name}\xD7${u.get(d)}`).join(" ")}`)}return r.overlays.length&&c.push(`overlays: ${r.overlays.map(l=>`${l.name} (${l.overlay.mode} on ${l.overlay.on}, every ${l.overlay.every})`).join(", ")}`),c.join(`
130
+ `)}function Ey(e,t={}){let r=t.tickRate??60,o=Sy(e,t,0),n=gC(o.base,o.overlays,r*4),i=t.scale??2,s=u=>Math.round(u*100/r),a=[],c=null,l=0;for(let u=0;u<=n;u+=u===n?1:Math.min(3,n-u)){let m=u===0?o:u<n?Sy(e,t,u):null;if(!(m&&c&&m.img.px.every((f,p)=>f===c[p]))){if(c&&a.length&&(a[a.length-1].delay=Math.max(1,s(u)-s(l))),!m)break;a.push({img:mC(m,i),delay:1}),c=m.img.px,l=u}}return a}function U5(e,t,r={}){let o=e.family,n=Qe(o),i=o.tile,s=r.frame??0,a=Jr(e,r.theme),c=GS(n,t),l=_o(e,c??{cols:3,rows:3,cells:new Uint8Array(n.neighbours==="corners"?16:9)},s);if(!c){let[m,d]=mt(o).cells[t],f=be(e,s);for(let p=0;p<i;p++)for(let h=0;h<i;h++)l.px[(i+p)*l.w+i+h]=f[(d*i+p)*e.width+m*i+h]}let u=ut(l.w,l.h);for(let m=0;m<l.h;m++)for(let d=0;d<l.w;d++){let f=l.px[m*l.w+d],p=d>=i&&d<2*i&&m>=i&&m<2*i,h=f===65535?Is:a[f];ht(u,d,m,p?h:[Math.round(h[0]*.55+20),Math.round(h[1]*.55+20),Math.round(h[2]*.55+22)])}return u}function Ty(e,t={}){let r=e.family,o=Qe(r),n=r.tile,i=t.scale??1,s=t.cols??Math.min(8,o.variants.length),a=6,c=9,l=3*n*i,u=3*n*i+c,m=Math.ceil(o.variants.length/s),d=ut(a+s*(l+a),a+m*(u+a));gn(d,0,0,d.width,d.height,sC);let f=new Set(o.pieces),p=new Set(r.detached);return o.variants.forEach((h,g)=>{let b=a+g%s*(l+a),y=a+Math.floor(g/s)*(u+a);Wr(d,b,y,h.name.length>l/4?h.name.slice(0,Math.floor(l/4)):h.name,f.has(h.name)?L5:p.has(h.name)?F5:_y,1);let w=U5(e,g,t);for(let v=0;v<w.height;v++)for(let S=0;S<w.width;S++){let _=(v*w.width+S)*4;gn(d,b+S*i,y+c+v*i,i,i,[w.data[_],w.data[_+1],w.data[_+2]])}}),d}var L5=[120,220,230],F5=[240,190,90];var bC=e=>{let[t,r,o]=it(e);return 299*t+587*r+114*o};function wC(e,t){let r=new Map;for(let i of e)r.set(i,(r.get(i)??0)+1);let o=65535,n=-1;for(let[i,s]of r)if(!(s<n)){if(s===n){if(i===65535)continue;if(o!==65535){let a=bC(t.entries[i].hex),c=bC(t.entries[o].hex);if(a>c||a===c&&i>o)continue}}o=i,n=s}return o}var vC=new Map([["mode",(e,t,r)=>wC(e,r)],["nearest",(e,t)=>e[(t>>1)*t+(t>>1)]],["ink-vote",(e,t,r,o)=>{let n=o.ink??r.entries.filter(m=>/^(ink|outline|black)$/.test(m.name)).map(m=>m.name),i=new Set(n.map(m=>r.entries.findIndex(d=>d.name===m)).filter(m=>m>=0)),[s,a]=o.share??[1,4],c=new Map;for(let m of e)i.has(m)&&c.set(m,(c.get(m)??0)+1);let l=-1,u=0;for(let[m,d]of c)(d>u||d===u&&m<l)&&(l=m,u=d);return l>=0&&u*a>=s*e.length?l:wC(e,r)}]]);function YS(e,t,r,o,n,i="mode",s={}){let a=vC.get(i);if(!a)throw new Error(`unknown reducer '${i}' (reducers: ${[...vC.keys()].join(", ")})`);let c=Math.floor(t/o),l=Math.floor(r/o),u=new Uint16Array(c*l),m=new Uint16Array(o*o);for(let d=0;d<l;d++)for(let f=0;f<c;f++){for(let p=0;p<o;p++)for(let h=0;h<o;h++)m[p*o+h]=e[(d*o+p)*t+f*o+h];u[d*c+f]=a(m,o,n,s)}return u}function xm(e,t,r,o){let n=new Uint16Array(t*o*r*o);for(let i=0;i<r*o;i++)for(let s=0;s<t*o;s++)n[i*t*o+s]=e[Math.floor(i/o)*t+Math.floor(s/o)];return n}function Ay(e,t,r){let o=t.entries.map(n=>{let i=r.entries.findIndex(s=>s.name===n.name);return i<0&&(i=r.entries.findIndex(s=>s.hex===n.hex)),i<0?65535:i});return e.map(n=>n===65535?n:o[n])}function XS(e,t,r,o="mode",n={},i=0){let s=Math.min(i,t.frameCount-1),a=YS(be(t,s),t.width,t.height,r,t.palette,o,n),c=Ay(a,t.palette,e.palette),l=be(e,Math.min(i,e.frameCount-1)),u=[],m=0,d=Math.min(e.width,Math.floor(t.width/r)),f=Math.min(e.height,Math.floor(t.height/r));for(let p=0;p<f;p++)for(let h=0;h<d;h++){let g=l[p*e.width+h],b=c[p*d+h];(g!==65535||b!==65535)&&m++,g!==b&&u.push([h,p])}return{pts:u,share:m?u.length/m:0,reduced:c}}var KS=[40,42,48];function $C(e,t,r={}){let{reducer:o="ink-vote",frame:n=0,scale:i=2,...s}=r,a=[{d:1,doc:e},...t.filter(g=>g.densityOf).map(g=>({d:g.densityOf.d,doc:g}))].sort((g,b)=>g.d-b.d),c=a[a.length-1],l=a.map(g=>({img:vi(g.doc,Math.min(n,g.doc.frameCount-1)),s:c.d/g.d*i,label:`${g.d}x ${g.doc.name}`})),u=a.map(g=>`${g.d}x ${g.doc.name} ${g.doc.width}x${g.doc.height}${g.d===1?" (base)":""}`);if(c.d>1){let g=XS(e,c.doc,c.d,o,s,n),b={...e,cels:[[g.reduced]],layers:[{name:"reduced",hidden:!1,locked:!1,reference:!1}],frameCount:1};l.push({img:vi(b,0),s:c.d*i,label:`${c.d}x reduced`,marks:g.pts}),u.push(`${c.d}x reduced by ${c.d} with ${o}: ${g.pts.length} pixels differ from ${e.name} (${(g.share*100).toFixed(1)}%)${g.pts.length?` at ${g.pts.slice(0,12).map(([y,w])=>`${y},${w}`).join(" ")}${g.pts.length>12?" \u2026":""}`:""}`)}else u.push("no higher-density copies (density of=<asset> d=<n> on a copy made with scale <n>)");let m=8,d=l.reduce((g,b)=>g+b.img.width*b.s+m,m),f=Math.max(...l.map(g=>g.img.height*g.s))+2*m,p=ut(d,f);for(let g=0;g<d*f;g++)p.data.set([KS[0],KS[1],KS[2],255],g*4);let h=m;for(let g of l){for(let b=0;b<g.img.height*g.s;b++)for(let y=0;y<g.img.width*g.s;y++){let w=(Math.floor(b/g.s)*g.img.width+Math.floor(y/g.s))*4;g.img.data[w+3]&&p.data.set(g.img.data.subarray(w,w+4),((m+b)*d+h+y)*4)}g.marks?.length&&wm(p,h,m,g.s,g.marks,g.img.width,g.img.height),h+=g.img.width*g.s+m}return{img:p,text:[...u,`panels: ${l.map(g=>g.label).join(" | ")}`].join(`
131
+ `)}}var jn=["palette","orphans","jaggies","banding","outline","seam","coverage","readability","revert","repetition","lattice","anim","views","fit","variant","footprint","draworder","density","consistency","font","margin","pieces"];function My(e){return jn.includes(e)}function zC(e,t){if(!e.groups.some(n=>n.frame!==void 0))return e.flagged;let r=new Set,o=[];for(let n of e.groups)if(!(n.frame!==void 0&&n.frame!==t))for(let i of n.pts){let s=i[1]*65536+i[0];r.has(s)||(r.add(s),o.push(i))}return o}var Ny={palette:{all:{max:0}},orphans:{all:{max:1,texture:!1},tile:{max:2,texture:!0},family:{max:2,texture:!0},overlay:{off:!0},font:{off:!0}},jaggies:{all:{max:0,area:1152},tile:{max:2},family:{max:2},font:{off:!0}},banding:{all:{max:.5,minEdges:8},font:{off:!0}},outline:{all:{min:.85},font:{off:!0}},seam:{all:{max:1}},coverage:{all:{max:0},font:{off:!0}},readability:{all:{min:.8,delta:15,maxIou:.9,minSpread:25},font:{off:!0}},revert:{all:{max:.15}},repetition:{all:{max:3,contrast:3},map:{edgeRun:4,motif:10},font:{off:!0}},anim:{all:{minDiff:.08,maxDiff:.35,maxPivot:1,maxGround:0,maxArea:.15},tile:{minDiff:.03},family:{minDiff:.01},overlay:{minDiff:0,maxDiff:1}},views:{all:{min:.2}},fit:{all:{max:0},font:{off:!0}},variant:{all:{maxL1:.3,maxDl:2}},footprint:{all:{max:0}},draworder:{all:{max:0}},lattice:{all:{max:.3,contrast:18}},density:{all:{max:.25}},consistency:{all:{max:0,maxL:18,maxOutline:.3,maxAngle:90,maxCluster:3,maxSteps:1.5,heightTol:2},family:{off:!0},overlay:{off:!0},font:{off:!0},icon:{maxStroke:1,maxFill:.2,maxCentre:1.5}},font:{all:{max:0,maxLine:0}},margin:{all:{max:0,bottom:!0},object:{off:!0},tile:{off:!0},family:{off:!0},map:{off:!0},font:{off:!0},overlay:{off:!0},sheet:{off:!0}},pieces:{all:{max:0,min:4},tile:{off:!0},family:{off:!0},map:{off:!0},font:{off:!0},overlay:{off:!0},icon:{off:!0},sheet:{off:!0}}};function _m(e,t,r,o){let n=Ny[e],i={...n.all,...n[t]??{}},s=c=>{if(c&&typeof c=="object")for(let[l,u]of Object.entries(c))(typeof u=="number"||typeof u=="boolean")&&(i[l]=u)},a=r?.checks?.[e];return a&&typeof a=="object"&&(s(a),s(a[t])),o&&s(r?.assets?.[o]?.checks?.[e]),i}function $o(e){let[t,r,o]=it(e);return .299*t+.587*r+.114*o}function Vr(e){let t=s=>{let a=s/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4},[r,o,n]=it(e),i=.2126*t(r)+.7152*t(o)+.0722*t(n);return i>216/24389?116*Math.cbrt(i)-16:24389/27*i}function JT(e){let t=l=>{let u=l/255;return u<=.04045?u/12.92:((u+.055)/1.055)**2.4},[r,o,n]=it(e).map(t),i=l=>l>216/24389?Math.cbrt(l):(24389/27*l+16)/116,s=i((.4124564*r+.3575761*o+.1804375*n)/.95047),a=i(.2126729*r+.7151522*o+.072175*n),c=i((.0193339*r+.119192*o+.9503041*n)/1.08883);return[116*a-16,500*(s-a),200*(a-c)]}function V5(e,t){let r=be(e,t),{width:o,height:n,wrap:i}=e,s=(a,c)=>i?(c%n+n)%n*o+(a%o+o)%o:a<0||c<0||a>=o||c>=n?-1:c*o+a;return{doc:e,w:o,h:n,wrap:i,px:r,at:s,get:(a,c)=>{let l=s(a,c);return l<0?65535:r[l]}}}var Pn=[[1,0],[0,1],[-1,0],[0,-1]],js=[[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1],[0,-1],[1,-1]],nn=(e,t)=>[t%e.w,Math.floor(t/e.w)],Ke=(e,t=2)=>String(Number(e.toFixed(t)));function at(e,t){let r=(t.groups??[]).map(i=>{let s=new Set;return{label:i.label,pts:i.pts.filter(a=>{let c=a[1]*65536+a[0];return s.has(c)?!1:(s.add(c),!0)})}}),o=new Set,n=[];for(let i of r)for(let s of i.pts){let a=s[1]*65536+s[0];o.has(a)||(o.add(a),n.push(s))}return{id:e,score:null,shown:"\u2014",limit:"",flagged:n,groups:r,...t}}var ct=(e,t)=>at(e,{status:"skip",detail:t}),Ps=e=>e.wrap||e.kind==="family"||e.kind==="overlay";function Z5(e,t,r){let o=e.doc.palette,n=e.doc.kind==="icon"?pc(e.doc):null,i=hT(o)||n==="tone",s=g=>it(g).every(b=>b===0||b===255),a=r.style?.palettes?.length?new Set(r.style.palettes.flatMap(g=>g.entries.map(b=>b.hex))):null,c=new Map(Object.entries(r.style?.reserved??{}).filter(([,g])=>!g.includes(e.doc.name))),l=new Map,u=(g,b)=>{l.has(g)||l.set(g,[]),l.get(g).push(nn(e,b))},m=0;for(let g=0;g<e.px.length;g++){let b=e.px[g];if(b===65535)continue;m++;let y=o.entries[b];y?n==="channel"&&(y.role||!s(y.hex))?u(`${y.name} ${y.role??y.hex} is not a pure channel colour (channel icons use channels of 0 or 255)`,g):n==="full"&&y.role?u(`${y.name} is a role in a full-colour icon (drawn as is)`,g):i&&n!=="channel"&&n!=="full"&&!y.role?u(`${y.name} is a fixed colour in ${n==="tone"?"a tone icon (recoloured through roles)":"role art"}`,g):a&&!y.role&&!a.has(y.hex)?u(`${y.name} ${y.hex} is not in the style palettes`,g):c.has(y.name)&&u(`${y.name} is reserved for ${c.get(y.name).join(", ")} (style.reserved)`,g):u(`index ${b} is not a palette entry`,g)}let d=[...l].map(([g,b])=>({label:g,pts:b})),f=d.reduce((g,b)=>g+b.pts.length,0),p=Number(t.max),h=n==="channel"?"pure channel colours":i&&n!=="full"?"role entries":a?`the style palettes (${r.style.palettes.map(g=>g.name).join(", ")})`:`palette '${o.name}'`;return at("palette",{status:f<=p?"pass":"fail",score:f,shown:String(f),limit:`\u2264 ${p}`,groups:d,detail:f===0?`all ${m} px are ${/^(role entries|pure channel colours)$/.test(h)?h:`in ${h}`}`:`${f} px outside ${h}: ${d.map(g=>`${g.label} (${g.pts.length})`).join("; ")}`})}function RC(e,t,r){let o=1/0;for(let n of hm(e,t)){let i=n.ramp.indexOf(r);i>=0&&(o=Math.min(o,Math.abs(i-n.at)))}return o}function H5(e,t,r){let o=e.px[t],n=new Set([t]),i=[t];for(;i.length&&n.size<r;){let s=i.pop(),[a,c]=nn(e,s);for(let[l,u]of js){let m=e.at(a+l,c+u);m>=0&&!n.has(m)&&e.px[m]===o&&(n.add(m),i.push(m))}}return n.size}function B5(e,t){let r=[],o=[],n=0,i=0;for(let u=0;u<e.px.length;u++){let m=e.px[u];if(m===65535)continue;n++;let[d,f]=nn(e,u);if(Pn.some(([h,g])=>e.get(d+h,f+g)===m))continue;let p=H5(e,u,3);if(!(p>2)){if(t.texture){let h=new Map;for(let[b,y]of Pn){let w=e.get(d+b,f+y);w!==65535&&h.set(w,(h.get(w)??0)+1)}let g=[...h].sort((b,y)=>y[1]-b[1]||b[0]-y[0])[0]?.[0];if(g!==void 0&&RC(e.doc.palette,m,g)===1){i++;continue}}(p===1?r:o).push([d,f])}}let s=r.length+o.length,a=n?100*s/n:0,c=Number(t.max),l=[...r.length?[{label:"lone pixel (no neighbour shares its colour)",pts:r}]:[],...o.length?[{label:"near-orphan (a diagonal pair)",pts:o}]:[]];return at("orphans",{status:a<=c?"pass":"fail",score:a,shown:`${Ke(a,1)}%`,limit:`\u2264 ${c}%`,groups:l,detail:`${s} stray px in ${n} (${r.length} lone, ${o.length} near-orphans)${t.texture?`; ${i} one ramp step from their surroundings allowed as texture`:""}`})}function W5(e){let t=new Map;for(let r of e)t.set(r,(t.get(r)??0)+1);return[...t].sort((r,o)=>o[1]-r[1]||r[0]-o[0])[0][0]}function xC(e,t,r){let o=e.get(t,r);return js.filter(([n,i])=>e.get(t+n,r+i)===o).map(([n,i])=>[t+n,r+i])}var Sm=(e,t)=>e[0]===t[0]&&e[1]===t[1];function _C(e,t,r,o){let n=[],i=(u,m)=>{let d=m[0]-u[0],f=m[1]-u[1];return o&&(d>1&&(d-=t),d<-1&&(d+=t),f>1&&(f-=r),f<-1&&(f+=r)),[d,f]},s=u=>{let m=u.map(d=>d.length);for(let d=2;d<=m.length-3;d++){let f=m[d-1],p=m[d],h=m[d+1];(p>f&&p>h||p<f&&p<h)&&Math.max(f,p,h)-Math.min(f,p,h)>=2&&n.push(u[d])}},a=null,c=null,l=e.length?[[e[0]]]:[];for(let u=1;u<e.length;u++){let m=i(e[u-1],e[u]),d=m[0]===0!=(m[1]===0),f=(h,g)=>!h||!g||(h[0]!==0?h[0]===g[0]:h[1]===g[1]),p;d?p=a?Sm(a,m):f(m,c):p=c?Sm(c,m):f(a,m),p||(s(l),l=[[e[u-1]]],a=null,c=null),d?(a=m,l[l.length-1].push(e[u])):(c=m,l.push([e[u]]))}return s(l),n}function J5(e){let t=new Uint8Array(e.px.length),r=[],o=(n,i)=>e.get(n,i)!==65535;for(let n=0;n<e.px.length;n++){if(e.px[n]===65535||t[n])continue;let i=[n];for(t[n]=1;i.length;){let d=i.pop(),[f,p]=nn(e,d);for(let[h,g]of js){let b=e.at(f+h,p+g);b>=0&&!t[b]&&e.px[b]!==65535&&(t[b]=1,i.push(b))}}let s=nn(e,n),a=[[-1,0],[-1,-1],[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1]],c=(d,f)=>a.findIndex(([p,h])=>p===d&&h===f),l=[s],u=s,m=0;for(let d=0;d<4*e.px.length+8;d++){let f=1;for(;f<=8&&!o(u[0]+a[(m+f)%8][0],u[1]+a[(m+f)%8][1]);)f++;if(f>8)break;let p=a[(m+f)%8],h=a[(m+f-1)%8],g=[u[0]+p[0],u[1]+p[1]];if(Sm(u,s)&&l.length>1&&Sm(g,l[1]))break;m=c(h[0]-p[0],h[1]-p[1]),u=g,l.push(u)}l.length>1&&Sm(l[l.length-1],s)&&l.pop(),r.push(l)}return r}function G5(e,t){let r=new Int8Array(e.px.length).fill(-1);for(let i=0;i<e.px.length;i++){if(e.px[i]===65535)continue;let[s,a]=nn(e,i);r[i]=xC(e,s,a).length}let o=new Uint8Array(e.px.length),n=[];for(let i=0;i<e.px.length;i++){if(r[i]!==1||o[i])continue;let s=[],a=i;for(;;){o[a]=1;let c=nn(e,a);s.push(c);let l=xC(e,c[0],c[1]).map(([u,m])=>e.at(u,m)).filter(u=>!o[u]);if(l.length!==1||r[l[0]]!==1&&r[l[0]]!==2)break;a=l[0]}s.length>=t&&n.push(s)}return n}function ek(e,t,r,o){return t!==65535&&r!==65535&&!o.has(t)&&!o.has(r)&&RC(e.doc.palette,t,r)===1}function K5(e,t,r,o){let n=e.get(t,r),i=!1;for(let[s,a]of js){let c=e.get(t+s,r+a);if(!(c===n||o.has(c)&&!o.has(n))){if(!ek(e,n,c,o))return!1;i=!0}}return i}function Y5(e,t,r={}){if(e.doc.family)return ct("jaggies","a family is judged on its map (its textures are checked as tiles)");let o=tk(e,r.style),n=0,i=Ps(e.doc)?W5(e.px):-1,s=[];for(let S=0;S<e.px.length;S++){let _=e.px[S];if(_===65535||_===i)continue;let[$,x]=nn(e,S),k=Pn.filter(([q,Z])=>e.get($+q,x+Z)===_);if(k.length!==2)continue;let P=k.find(([,q])=>q===0),I=k.find(([q])=>q===0);if(!P||!I||e.get($+P[0]+I[0],x+I[1])===_)continue;let E=e.get($+I[0]-P[0],x+I[1])===_||e.get($+P[0],x-I[1])===_,N=e.get($+P[0],x+I[1]),T=!o.has(_)&&Pn.every(([q,Z])=>e.get($+q,x+Z)!==65535);E&&T&&(ek(e,_,N,o)||o.has(N)&&js.some(([q,Z])=>ek(e,_,e.get($+q,x+Z),o)))?n++:E&&s.push([$,x])}let a=0;{let S=$=>e.at($[0],$[1]),_=new Set(s.map(S));for(let $ of s){if(!_.has(S($)))continue;a++;let x=[$];for(_.delete(S($));x.length;){let[k,P]=x.pop();for(let[I,E]of Pn){let N=e.at(k+I,P+E);_.has(N)&&(_.delete(N),x.push(nn(e,N)))}}}}let c=new Map,l=S=>{for(let _ of S)c.set(_.map($=>e.at($[0],$[1])).sort(($,x)=>$-x).join(","),_)};for(let S of G5(e,6))if(e.get(S[0][0],S[0][1])!==i){if(S.every(([_,$])=>K5(e,_,$,o))){n++;continue}l(_C(S,e.w,e.h,e.wrap))}if(!Ps(e.doc))for(let S of J5(e))l(_C(S,e.w,e.h,!1));let u=[...c.values()].flat(),m=[],d=[];if(!Ps(e.doc)){let S=(_,$)=>e.get(_,$)!==65535;for(let _=0;_<e.h;_++)for(let $=0;$<e.w;$++){let x=Pn.filter(([k,P])=>S($+k,_+P));if(S($,_)){if(x.length!==1)continue;let[k,P]=[$+x[0][0],_+x[0][1]],I=Pn.filter(([N,T])=>S(k+N,P+T)).length,E=js.filter(([N,T])=>S($+N,_+T)).length;I>=3&&E<=3&&m.push([$,_])}else if(x.length===4)d.push([$,_]);else if(x.length===3){let k=Pn.find(([P,I])=>!S($+P,_+I));S($-2*k[0],_-2*k[1])&&d.push([$,_])}}}let f=[...s.length?[{label:"doubled L-corner",pts:s}]:[],...u.length?[{label:"irregular step run",pts:u}]:[],...m.length?[{label:"spike on the outline",pts:m}]:[],...d.length?[{label:"notch in the outline",pts:d}]:[]],p=c.size,h=a+p+m.length+d.length,g=e.doc,b=Number(t.max)>0&&(g.wrap||g.family)?Math.max(1,Math.floor(g.cellW*g.cellH/576)):1,y=g.kind==="object"?g.width*g.height:g.cellW*g.cellH,w=!g.wrap&&!g.family&&Number(t.area)>0?Math.floor(y/Number(t.area)):0,v=Number(t.max)*b+w;return at("jaggies",{status:h<=v?"pass":"fail",score:h,shown:String(h),limit:`\u2264 ${v}`,groups:f,detail:(h===0?"lines and outlines step evenly":`${a} doubled L-corners, ${p} irregular step runs, ${m.length} spikes, ${d.length} notches`)+(n?`; ${n} steps between neighbouring entries of one ramp are shading, not counted`:"")})}function X5(e){let t=new Int32Array(e.px.length).fill(0),r=[];for(let o=0;o<e.px.length;o++){if(e.px[o]===65535)continue;let[n,i]=nn(e,o);Pn.some(([s,a])=>e.get(n+s,i+a)===65535)&&(t[o]=1,r.push(o))}for(let o=0;o<r.length;o++){let n=r[o],[i,s]=nn(e,n);for(let[a,c]of Pn){let l=e.at(i+a,s+c);l>=0&&e.px[l]!==65535&&t[l]===0&&(t[l]=t[n]+1,r.push(l))}}return t}function tk(e,t){let r=e.doc.palette,o=t?.outline?.length?t.outline:["ink","outline","black"],n=new Set(r.entries.flatMap((s,a)=>o.includes(s.name)||s.role==="black"?[a]:[]));if(n.size||t?.outline?.length)return n;let i=-1;for(let s of new Set(e.px))s!==65535&&(i<0||$o(r.entries[s].hex)<$o(r.entries[i].hex))&&(i=s);return new Set(i>=0?[i]:[])}function Q5(e,t,r){let o=Object.keys(e.ramps),n=e.entries[t]?.name,i=e.entries[r]?.name;return o.findIndex(s=>e.ramps[s].includes(n)&&e.ramps[s].includes(i))}function eF(e,t,r){if(Ps(e.doc))return ct("banding","tiles have no silhouette to band along");let o=e.doc.palette,n=X5(e),i=tk(e,r.style),s=o.entries.map(y=>$o(y.hex)),a=Object.keys(o.ramps).length>0,c=Object.keys(o.ramps),l=new Map;for(let y=0;y<e.px.length;y++){let w=e.px[y];if(w===65535||i.has(w))continue;let[v,S]=nn(e,y);Pn.forEach(([_,$],x)=>{let k=e.at(v+_,S+$);if(k<0)return;let P=e.px[k];if(P===65535||P===w||i.has(P)||n[k]!==n[y]+1)return;let I=a?Q5(o,w,P):0;if(I<0)return;let E=Math.sign(s[P]-s[w]);if(!E)return;l.has(I)||l.set(I,{count:Pn.map(()=>[0,0]),edges:[]});let N=l.get(I);N.count[x][E>0?0:1]++,N.edges.push({p:[v,S],sign:E})})}let u=Number(t.minEdges),m=Number(t.max),d=["west","top","east","bottom"],f={score:0,ramp:-1,sign:0,net:[0,0,0,0],n:0},p=0;for(let[y,w]of l){if(p+=w.edges.length,w.edges.length<u)continue;let v=w.count.map(([$,x])=>$+x>=2?($-x)/($+x):0),S=Math.sign(v[0]),_=S!==0&&v.every($=>Math.sign($)===S)?Math.min(...v.map(Math.abs)):0;(_>f.score||f.ramp<0)&&(f={score:_,ramp:y,sign:S,net:v,n:w.edges.length})}let h=a&&f.ramp>=0?`ramp ${c[f.ramp]}`:"the colours";if(f.ramp<0)return at("banding",{status:"pass",score:0,shown:"0",limit:`\u2264 ${m}`,detail:`${p} ramp steps follow the outline; too few to band`});let g=f.score>m,b=g?l.get(f.ramp).edges.filter(y=>y.sign===f.sign).map(y=>y.p):[];return at("banding",{status:g?"fail":"pass",score:f.score,shown:Ke(f.score),limit:`\u2264 ${m}`,groups:g?[{label:`pillow shading in ${h}: it gets ${f.sign>0?"lighter":"darker"} inward on every side`,pts:b}]:[],detail:`${h}: ${f.n} ramp steps along the outline; inward ${f.net.map((y,w)=>`${d[w]} ${y>0?"+":""}${Ke(y)}`).join(", ")}`+(g?" (the same on every side: light one side and shade the other)":"")})}function IC(e){let t=[];for(let r=0;r<e.px.length;r++){if(e.px[r]===65535)continue;let[o,n]=nn(e,r);Pn.some(([i,s])=>e.get(o+i,n+s)===65535)&&t.push(r)}return t}function tF(e,t,r){if(Ps(e.doc))return ct("outline","tiles have no silhouette");let o=IC(e);if(!o.length)return ct("outline","nothing drawn");let n=tk(e,r.style),i=o.filter(l=>!n.has(e.px[l])),s=1-i.length/o.length,a=Number(t.min),c=[...n].filter(l=>e.px.includes(l)||n.size===1).map(l=>e.doc.palette.entries[l].name).join(", ")||"none";return at("outline",{status:s>=a?"pass":"fail",score:s,shown:Ke(s),limit:`\u2265 ${a}`,groups:i.length?[{label:`silhouette edge not in the outline colour (${c})`,pts:i.map(l=>nn(e,l))}]:[],detail:`${o.length-i.length} of ${o.length} silhouette edge px are ${c}${i.length?`; ${i.length} gaps`:""}`})}var _c=e=>e.length?e.reduce((t,r)=>t+r,0)/e.length:0,SC=e=>{let t=_c(e);return Math.sqrt(_c(e.map(r=>(r-t)*(r-t))))};function km(e,t,r,o,n){let i=[];for(let h=0;h<=r-2;h++){let g=0;for(let b=0;b<o;b++)e[b*r+h]!==e[b*r+h+1]&&g++;i.push(g/o)}let s=i.map((h,g)=>(g+1)%n===0),a=i.filter((h,g)=>s[g]),c=i.filter((h,g)=>!s[g]),l=(_c(a)-_c(c))/(SC(c)+.02),u=[];for(let h=0;h<r;h++){let g=0;for(let b=0;b<o;b++)g+=t[b*r+h];u.push(g/o)}let m=u.map((h,g)=>((g+1)%n===0||g%n===0)&&g!==0&&g!==r-1),d=u.filter((h,g)=>m[g]),f=u.filter((h,g)=>!m[g]),p=Math.abs(_c(d)-_c(f))/(SC(f)+2);return{jump:l,line:p}}function nF(e,t=0){let r=be(e,t),{width:o,height:n}=e,i=e.palette.entries.map(p=>$o(p.hex)),s=3*o,a=3*n,c=new Int32Array(s*a),l=new Float64Array(s*a),u=new Int32Array(s*a),m=new Float64Array(s*a);for(let p=0;p<a;p++)for(let h=0;h<s;h++){let g=r[p%n*o+h%o],b=g===65535?-1:g,y=g===65535?0:i[g];c[p*s+h]=b,l[p*s+h]=y,u[h*a+p]=b,m[h*a+p]=y}let d=km(c,l,s,a,o),f=km(u,m,a,s,n);return{score:Math.max(d.jump,f.jump,d.line,f.line,0),jx:d.jump,jy:f.jump,lx:d.line,ly:f.line}}function rF(e,t,r){if(e.doc.family){let c=e.doc,{cols:l,rows:u,seed:m}=zs,d=_o(c,$i(Qe(c.family),l,u,m),r.frame??0),f=Cy(d,c,r.frame??0),p=_s(d,c),h=Number(t.max);return at("seam",{status:p.score<=h?"pass":"fail",score:p.score,shown:Ke(p.score),limit:`\u2264 ${h}`,detail:`over a ${l}x${u} island (seed ${m}${f?`; its ${f} face cells as the outside under them`:""}): jump x ${Ke(p.jx)} y ${Ke(p.jy)}; line x ${Ke(p.lx)} y ${Ke(p.ly)} (view map shows it)`})}if(!e.wrap)return ct("seam","not a wrap (tile) document");let o=nF(e.doc,r.frame??0),n=Number(t.max),i=[],{w:s,h:a}=e;if(o.jx>n||o.lx>n){let c=[];for(let l=0;l<a;l++)(o.lx>n||e.get(s-1,l)!==e.get(0,l))&&c.push([0,l],[s-1,l]);i.push({label:o.lx>n?"left and right edge columns stand out (a line at the seam)":"the colour changes across the left-right seam",pts:c})}if(o.jy>n||o.ly>n){let c=[];for(let l=0;l<s;l++)(o.ly>n||e.get(l,a-1)!==e.get(l,0))&&c.push([l,0],[l,a-1]);i.push({label:o.ly>n?"top and bottom edge rows stand out (a line at the seam)":"the colour changes across the top-bottom seam",pts:c})}return at("seam",{status:o.score<=n?"pass":"fail",score:o.score,shown:Ke(o.score),limit:`\u2264 ${n}`,groups:i,detail:`jump x ${Ke(o.jx)} y ${Ke(o.jy)}; line x ${Ke(o.lx)} y ${Ke(o.ly)} (about 1 or less reads as no seam)`})}function oF(e,t){let r=e.family,o=Qe(r),n=mt(r),i=r.tile,s=[],a=[],c=[["inside",n.inside],["outside",n.outside],...o.variants.map((d,f)=>[d.name,n.cells[f]])],l=(d,f,p)=>{for(let h=0;h<i;h++)for(let g=0;g<i;g++)if(d[(p*i+h)*e.width+f*i+g]!==65535)return!1;return!0},u=Array.from({length:e.frameCount},(d,f)=>f).every(d=>l(be(e,d),n.outside[0],n.outside[1])&&!l(be(e,d),n.inside[0],n.inside[1]));for(let d=0;d<e.frameCount;d++){let f=be(e,d);for(let[p,[h,g]]of c){if(u&&(p==="outside"||o.variants[o.byName.get(p)??-1]?.on)||!l(f,h,g))continue;s.push(`${p}${e.frameCount>1?` (frame ${d+1})`:""} is empty`);let b=[];for(let y=0;y<i;y++)b.push([h*i+y,g*i],[h*i+y,g*i+i-1]);a.push({label:`${p} is empty`,pts:b,...e.frameCount>1?{frame:d}:{}})}}let m=Number(t.max);return at("coverage",{status:s.length<=m?"pass":"fail",score:s.length,shown:String(s.length),limit:`\u2264 ${m}`,groups:a,detail:s.length?s.join("; "):`${o.name}: all ${o.variants.length} variants and ${u?"the inside texture drawn (the outside left empty: the ground below shows)":"both textures drawn"}${e.frameCount>1?` on ${e.frameCount} frames`:""}${r.detached.length?` (${r.detached.length} detached)`:""}`})}function iF(e,t,r){let o=e.doc;if(o.family)return oF(o,t);let n=[],i=[],s=o.densityOf?.d??1,a=r.style?.sizes?.[o.kind]?.split("|").map(l=>l.trim()).map(l=>s===1?l:l.replace(/^(\d+)x(\d+)$/,(u,m,d)=>`${Number(m)*s}x${Number(d)*s}`)).join("|");a&&!a.split("|").includes(`${o.width}x${o.height}`)&&n.push(`size ${o.width}x${o.height} is not the style's ${a} for a ${o.kind}${s>1?` at ${s}x`:""}`),(o.width%o.cellW||o.height%o.cellH)&&n.push(`size ${o.width}x${o.height} is not a whole number of ${o.cellW}x${o.cellH} cells`);for(let l=0;l<o.frameCount;l++){let u=be(o,l);if(u.every(m=>m===65535)){n.push(`frame ${l+1} is empty`);continue}if(!(o.cellW>=o.width&&o.cellH>=o.height))for(let m=0;m+o.cellH<=o.height;m+=o.cellH)for(let d=0;d+o.cellW<=o.width;d+=o.cellW){let f=!0;for(let h=m;h<m+o.cellH&&f;h++)for(let g=d;g<d+o.cellW;g++)if(u[h*o.width+g]!==65535){f=!1;break}if(!f)continue;n.push(`cell (${d/o.cellW},${m/o.cellH})${o.frameCount>1?` of frame ${l+1}`:""} is empty`);let p=[];for(let h=0;h<o.cellW;h++)p.push([d+h,m],[d+h,m+o.cellH-1]);for(let h=1;h<o.cellH-1;h++)p.push([d,m+h],[d+o.cellW-1,m+h]);i.push({label:`empty cell (${d/o.cellW},${m/o.cellH})`,pts:p})}}let c=Number(t.max);return at("coverage",{status:n.length<=c?"pass":"fail",score:n.length,shown:String(n.length),limit:`\u2264 ${c}`,groups:i,detail:n.length?n.join("; "):`${o.frameCount} frame${o.frameCount>1?"s":""}, every cell drawn${a?`, size ${a}`:""} (autotile names come with schemes)`})}function sF(e,t,r){if(Ps(e.doc))return ct("readability","tiles are ground, not figures");let n=e.doc.palette.entries.map(y=>Vr(y.hex)),i=[];for(let y=0;y<e.px.length;y++)e.px[y]!==65535&&i.push(y);if(!i.length)return ct("readability","nothing drawn");let s=[],a=[],c=null,l=Number(t.delta),u=r.ground;if(u){let y=be(u,0),w=u.palette.entries.map(x=>Vr(x.hex)),v=(x,k)=>{let P=y[(k%u.height+u.height)%u.height*u.width+(x%u.width+u.width)%u.width];return P===65535?null:w[P]},S=[],_=0;for(let x of IC(e)){let[k,P]=nn(e,x),I=-1;for(let[E,N]of Pn){if(e.get(k+E,P+N)!==65535)continue;let T=v(k+E,P+N);T!==null&&(I=Math.max(I,Math.abs(n[e.px[x]]-T)))}I<0||(_++,I<l&&S.push([k,P]))}c=_?1-S.length/_:1;let $=Number(t.min);s.push({name:"edge contrast",value:c,limit:`\u2265 ${$}`,pass:c>=$,detail:`${_-S.length} of ${_} edge px differ from '${u.name}' by \u0394L* \u2265 ${l}`}),S.length&&a.push({label:`edge too close to the ground '${u.name}' (\u0394L* < ${l})`,pts:S})}else s.push({name:"edge contrast",value:null,limit:"",pass:null,detail:"no ground tile to judge against"});let m=(r.set??[]).filter(y=>!y.doc.wrap&&y.doc.width===e.w&&y.doc.height===e.h&&y.doc.name!==e.doc.name),d=m.filter(y=>!um(y.doc,e.doc)&&!um(e.doc,y.doc));if(d.length){let y=e.px.map(S=>S===65535?0:1),w={name:"",iou:0};for(let S of d){let _=be(S.doc,Math.min(r.frame??0,S.doc.frameCount-1)),$=0,x=0;for(let P=0;P<_.length;P++){let I=y[P],E=_[P]!==65535?1:0;I&&E&&$++,(I||E)&&x++}let k=x?$/x:0;(k>w.iou||!w.name)&&(w={name:S.name,iou:k})}let v=Number(t.maxIou);s.push({name:"distinct silhouette",value:w.iou,limit:`\u2264 ${v}`,pass:w.iou<=v,detail:`most like '${w.name}' (IoU ${Ke(w.iou)})${d.length<m.length?`; recolours not compared: ${m.filter(S=>!d.includes(S)).map(S=>S.name).join(", ")}`:""}`})}else m.length&&s.push({name:"distinct silhouette",value:null,limit:"",pass:null,detail:`only recolours to compare with (${m.map(y=>y.name).join(", ")})`});let f=i.map(y=>n[e.px[y]]).sort((y,w)=>y-w),p=y=>f[Math.min(f.length-1,Math.floor(y*f.length))],h=p(.95)-p(.05),g=Number(t.minSpread);s.push({name:"lightness spread",value:h,limit:`\u2265 ${g}`,pass:h>=g,detail:`L* ${Ke(p(.05),0)}..${Ke(p(.95),0)} inside the sprite`});let b=s.some(y=>y.pass===!1);return at("readability",{status:b?"fail":"pass",score:c,shown:c===null?b?"\u2717":"\u2713":Ke(c),limit:s[0].limit||"",groups:a,parts:s,detail:s.map(y=>`${y.name}: ${y.detail}`).join("; ")})}function aF(e,t,r){let o=r.ref;if(!o)return ct("revert","no reference asset (give ref=<asset>)");let n=be(o,Math.min(r.frame??0,o.frameCount-1)),i=[],s=0;for(let l=0;l<e.h;l++)for(let u=0;u<e.w;u++){let m=e.px[l*e.w+u],d=u<o.width&&l<o.height?n[l*o.width+u]:65535;m===65535&&d===65535||(s++,m!==65535&&d!==65535&&e.doc.palette.entries[m].hex===o.palette.entries[d].hex&&i.push([u,l]))}let a=s?i.length/s:0,c=Number(t.max);return at("revert",{status:a<=c?"pass":"fail",score:a,shown:`${Ke(100*a,0)}%`,limit:`\u2264 ${Ke(100*c,0)}%`,groups:a>c?[{label:`same colour as '${o.name}'`,pts:i}]:[],detail:`${i.length} of ${s} px are unchanged from '${o.name}'`})}function cF(e,t=0,r=Ny.repetition.all.contrast,o=Ny.repetition.all.max){let n=be(e,t),{width:i,height:s}=e,a=e.palette.entries.map(d=>Vr(d.hex)),c=Float64Array.from(n,d=>d===65535?0:a[d]),l=c.reduce((d,f)=>d+f,0)/c.length,u={score:0,axis:"rows",from:0,width:1,delta:0,spread:0,limit:o},m=-1;for(let d of["rows","columns"]){let f=d==="rows"?s:i,p=d==="rows"?i:s,h=(b,y)=>d==="rows"?c[b*i+y]:c[y*i+b],g=Math.max(1,Math.floor(f/24));for(let b=1;b<=Math.min(6*Math.max(1,Math.floor(f/24)),Math.floor(f/4))||b===1;b++){let y=new Float64Array(p);for(let w=0;w<f;w++){y.fill(0);for(let I=0;I<b;I++){let E=(w+I)%f;for(let N=0;N<p;N++)y[N]+=h(E,N)}let v=0;for(let I=0;I<p;I++)v+=y[I]/=b;v/=p;let S=0;for(let I=0;I<p;I++)S+=(y[I]-v)**2;let _=Math.sqrt(S/p),$=v-l,x=Math.abs($)*Math.sqrt(b/g),k=Math.max(o,r*_*Math.sqrt(b/g/p)),P=x/k;P>m+1e-9&&(m=P,u={score:x,axis:d,from:w,width:b,delta:$,spread:_,limit:k})}if(f<4)break}}return u}function lF(e,t,r){if(!e.wrap)return ct("repetition","not a wrap (tile) document");let o=Number(t.max),n=cF(e.doc,r.frame??0,Number(t.contrast??0),o),i=n.score>n.limit,s=n.axis==="rows"?e.h:e.w,a=n.axis==="rows"?e.w:e.h,c=[];for(let v=0;v<n.width;v++)for(let S=0;S<a;S++){let _=(n.from+v)%s;c.push(n.axis==="rows"?[S,_]:[_,S])}let l=new Map;for(let v of e.px)l.set(v,(l.get(v)??0)+1);let u=[...l].sort((v,S)=>S[1]-v[1]||v[0]-S[0])[0][0],m=v=>v===65535?0:Vr(e.doc.palette.entries[v].hex),d=c.filter(([v,S])=>{let _=e.get(v,S);return _!==u&&Math.sign(m(_)-m(u))===Math.sign(n.delta)}),f=d.length?d:c,p=(n.from+n.width-1)%s,h=n.width===1?`${n.axis==="rows"?"row":"column"} ${n.from}`:`${n.axis} ${n.from}-${p}`,g=n.delta<0?"darker":"lighter",b=n.limit>o+1e-9,y=b?`\u2264 ${Ke(n.limit,1)}`:`\u2264 ${o}`,w=b?`; limit raised from ${o} by its spread along the band (\u03C3 ${Ke(n.spread,1)}): an uneven band is a mark, not a stripe`:"";return at("repetition",{status:i?"fail":"pass",score:n.score,shown:Ke(n.score,1),limit:y,groups:i?[{label:`${h}: ${g} than the rest (\u0394L* ${Ke(Math.abs(n.delta),1)}), a stripe when tiled`,pts:f}]:[],detail:`most visible stripe: ${h}, ${g} by \u0394L* ${Ke(Math.abs(n.delta),1)} (score \u0394L*\xB7\u221Awidth ${Ke(n.score,1)}${w})`})}var It=e=>`${Ke(e*100,1)}%`;function uF(e,t){let r=e.doc;if(r.frameCount<2)return ct("anim","one frame");let o=tr(r).filter(N=>!N.mirror&&N.frames.length>=2);if(!o.length)return ct("anim","no sequence of two frames or more (mirror views follow their source)");let n=Ps(r),i=[],s=N=>i[N]??=be(r,N),a=N=>s(N).reduce((T,q)=>T+(q!==65535?1:0),0),c=(N,T)=>{let q=[];for(let Z=0;Z<r.width*r.height;Z++)T(Z)&&q.push(nn(e,Z));return q},[l,u,m,d,f]=[t.minDiff,t.maxDiff,t.maxPivot,t.maxGround,t.maxArea].map(Number),p=[],h=[],g=0,b="",y=0,w="",v=0,S="";for(let N of o){let T=N.frames,q=T.slice(1).map((L,A)=>({a:T[A],b:L,seam:!1}));N.loop==="cycle"&&T.length>=3&&q.push({a:T.at(-1),b:T[0],seam:!0});for(let{a:L,b:A,seam:z}of q){let R=s(L),C=s(A),U=0,W=0;for(let Y=0;Y<R.length;Y++)(R[Y]!==65535||C[Y]!==65535)&&W++,R[Y]!==C[Y]&&U++;let X=W?U/W:0;if(h.push({s:N.name,a:L,b:A,v:X,seam:z}),X<l||X>u){let Y=X<l?U?"too little changes (it barely moves)":"the frames are the same (a held frame: give it more ticks instead)":"too much changes (it jumps)";p.push({label:`${N.name} ${z?"loop seam ":""}${L+1}\u2192${A+1}: ${It(X)} of the pixels change; ${Y}`,pts:c(A,fe=>R[fe]!==C[fe]),frame:A})}if(!n){let Y=a(L),fe=a(A),ye=Math.max(Y,fe)?Math.abs(Y-fe)/Math.max(Y,fe):0;ye>v&&(v=ye,S=`${N.name} ${L+1}\u2192${A+1}`),ye>f&&p.push({label:`${N.name} ${L+1}\u2192${A+1}: the silhouette ${fe>Y?"grows":"shrinks"} by ${It(ye)}`,pts:c(A,H=>R[H]===65535!=(C[H]===65535)),frame:A})}}if(n)continue;let Z=T.map(L=>{let A=0,z=0;return s(L).forEach((R,C)=>{R!==65535&&(A+=C%r.width,z++)}),z?A/z:0}),D=T.map(L=>{let A=s(L);for(let z=r.height-1;z>=0;z--)for(let R=0;R<r.width;R++)if(A[z*r.width+R]!==65535)return z;return-1}),V=Z.reduce((L,A)=>L+A,0)/Z.length,F=Math.max(...Z)-Math.min(...Z);if(F>g&&(g=F,b=N.name),F>m){let L=Z.reduce((R,C,U)=>Math.abs(C-V)>Math.abs(Z[R]-V)?U:R,0),A=s(T[L]),z=s(T[L===0?1:0]);p.push({label:`${N.name} frame ${T[L]+1}: the sprite sits ${Ke(Z[L]-V,1)} px off the sequence's centre (it slides; drift ${Ke(F,1)} px)`,pts:c(T[L],R=>A[R]!==65535&&z[R]===65535),frame:T[L]})}let M=r.ground??D[0];T.forEach((L,A)=>{let z=Math.abs(D[A]-M);if(!(D[A]<0)&&(z>y&&(y=z,w=`${N.name} frame ${L+1}`),z>d)){let R=s(L);p.push({label:`${N.name} frame ${L+1}: the lowest row is ${D[A]}, the ground is ${M} (${D[A]<M?"it floats":"it sinks"})`,pts:c(L,C=>Math.floor(C/r.width)===D[A]&&R[C]!==65535),frame:L})}})}let _=h.filter(N=>!N.seam),$=Math.min(..._.map(N=>N.v)),x=Math.max(..._.map(N=>N.v)),k=h.filter(N=>N.seam),P=[{name:"frame diff",value:x,limit:`${It(l)}\u2013${It(u)}`,pass:$>=l&&x<=u,detail:`pairs change ${It($)}..${It(x)} of their pixels`}];if(k.length){let N=k.filter(q=>q.v<l||q.v>u),T=N[0]??k[0];P.push({name:"loop seam",value:T.v,limit:`${It(l)}\u2013${It(u)}`,pass:!N.length,detail:`${T.s} ${T.a+1}\u2192${T.b+1} changes ${It(T.v)}`})}n||(P.push({name:"pivot drift",value:g,limit:`\u2264 ${m} px`,pass:g<=m,detail:`${Ke(g,1)} px${b?` (${b})`:""}`}),P.push({name:"ground drift",value:y,limit:`\u2264 ${d} px`,pass:y<=d,detail:`${y} px${w?` (${w})`:""} from ${r.ground!==null?`the ground line ${r.ground}`:"the first frame's lowest row"}`}),P.push({name:"area jump",value:v,limit:`\u2264 ${It(f)}`,pass:v<=f,detail:`${It(v)}${S?` (${S})`:""}`}));let I=h.reduce((N,T)=>Math.max(l-T.v,T.v-u)>Math.max(l-N.v,N.v-u)?T:N,h[0]),E=P.some(N=>!N.pass);return at("anim",{status:E?"fail":"pass",score:I.v,shown:It(I.v),limit:`${It(l)}\u2013${It(u)}`,groups:p,parts:P,detail:`${o.map(N=>N.name).join(", ")}: `+P.map(N=>`${N.name} ${N.detail}${N.pass?"":` (limit ${N.limit})`}`).join("; ")})}function mF(e,t){let r=e.doc,o=r.views.filter(a=>!a.mirror);if(o.length<2)return ct("views","fewer than two views (a mirror view counts as its source)");let n=Number(t.min),i=[];for(let a=0;a<o.length;a++)for(let c=a+1;c<o.length;c++){let l=o[a],u=o[c];if(im(l.name)===u.name)continue;let m=be(r,l.from),d=be(r,u.from),f=0,p=0;for(let h=0;h<m.length;h++)(m[h]!==65535||d[h]!==65535)&&p++,m[h]!==d[h]&&f++;i.push({a:l.name,b:u.name,v:p?f/p:0})}if(!i.length)return ct("views","only views facing each other (they are meant to be mirror images)");let s=i.reduce((a,c)=>c.v<a.v?c:a);return at("views",{status:s.v>=n?"pass":"fail",score:s.v,shown:It(s.v),limit:`\u2265 ${It(n)}`,detail:i.map(a=>`${a.a}/${a.b} differ by ${It(a.v)}`).join(", ")+(s.v<n?`; ${s.a} and ${s.b} look too alike`:"")})}function dF(e,t){let r=e.doc,[o,n]=Br(r);if(r.family||r.overlay||r.kind==="sheet")return ct("fit",`a ${r.kind} is not placed as one piece`);if(!r.footprint&&o*n===1)return ct("fit","one cell, no footprint");if(r.width%r.cellW||r.height%r.cellH)return ct("fit",`the canvas is not whole ${r.cellW}x${r.cellH} cells`);let i=r.footprint??{cols:o,rows:n,at:[0,0],anchor:[0,n-1],flags:[]},s=[],a=(u,m)=>{let d=[];for(let f=0;f<r.cellW;f++)d.push([u*r.cellW+f,m*r.cellH],[u*r.cellW+f,m*r.cellH+r.cellH-1]);for(let f=1;f<r.cellH-1;f++)d.push([u*r.cellW,m*r.cellH+f],[u*r.cellW+r.cellW-1,m*r.cellH+f]);return d};for(let u=0;u<n;u++)for(let m=0;m<o;m++){let d=[];for(let f=0;f<r.cellH;f++)for(let p=0;p<r.cellW;p++)e.px[(u*r.cellH+f)*r.width+m*r.cellW+p]!==65535&&d.push([m*r.cellW+p,u*r.cellH+f]);fm(i,m,u)&&!d.length&&s.push({label:`footprint cell ${m},${u} is empty`,pts:a(m,u)}),!fm(i,m,u)&&d.length&&!dm(i,m,u).roof&&s.push({label:`cell ${m},${u} overhangs the footprint but is not a roof (r): actors behind would be drawn over it`,pts:d})}let c=s.length,l=Number(t.max);return at("fit",{status:c<=l?"pass":"fail",score:c,shown:String(c),limit:`\u2264 ${l}`,groups:s,detail:c?s.map(u=>u.label).join("; "):`${o}x${n} cells, footprint ${i.cols}x${i.rows} at ${i.at.join(",")} drawn${o*n>i.cols*i.rows?", overhangs are roofs":""}`})}function fF(e,t,r){let o=e.doc;if(!o.variantOf)return ct("variant","not a variant (variant of=<asset>)");let n=r.world?.get(o.variantOf);if(!n)return at("variant",{status:"fail",score:null,shown:"?",limit:"",detail:`no asset '${o.variantOf}' to be a variant of`});let i=HT(n,o,r.frame??0),s=i.l1<Number(t.maxL1)&&i.dl<Number(t.maxDl);return at("variant",{status:s?"pass":"fail",score:i.l1,shown:`${Ke(i.l1)} \xB7 \u0394L* ${Ke(i.dl,1)}`,limit:`< ${t.maxL1} \xB7 < ${t.maxDl}`,groups:i.border.length?[{label:`border pixels unlike ${o.variantOf}'s (a seam where they meet, unless the textures blend)`,pts:i.border}]:[],detail:`colour mix against ${o.variantOf}: L1 ${Ke(i.l1)}, \u0394L* ${Ke(i.dl,1)}${s?"":" (too different: on a map it reads as a patch)"}; ${i.border.length?`${i.border.length} border pixels differ`:"same border"}`})}function pF(e,t,r){let o=e.doc;if(!o.densityOf)return ct("density","not a density copy (density of=<asset> d=<n>)");let n=r.world?.get(o.densityOf.of);if(!n)return at("density",{status:"fail",score:null,shown:"?",limit:"",detail:`no asset '${o.densityOf.of}' to be a density of`});let i=o.densityOf.d;if(n.width*i!==o.width||n.height*i!==o.height)return at("density",{status:"fail",score:null,shown:"size",limit:"",detail:`${o.width}x${o.height} is not ${i} x ${o.densityOf.of}'s ${n.width}x${n.height}`});let{reducer:s="ink-vote",...a}=r.style?.density??{},c=XS(n,o,i,s,a,r.frame??0),l=Number(t.max),u=c.pts.flatMap(([m,d])=>Array.from({length:i*i},(f,p)=>[m*i+p%i,d*i+Math.floor(p/i)]));return at("density",{status:c.share<=l?"pass":"fail",score:c.share,shown:It(c.share),limit:`\u2264 ${It(l)}`,groups:c.pts.length?[{label:`blocks the ${s} reducer turns into another colour than ${o.densityOf.of} has`,pts:u}]:[],detail:`reduced by ${i} with ${s}: ${c.pts.length} of ${o.densityOf.of}'s pixels differ (${It(c.share)})`})}var QS=e=>()=>ct(e,"a map check (on map documents)");function hF(e,t,r){let o=e.doc;if(o.family||o.overlay)return ct("consistency","judged on its maps");let n=(r.peers??[]).filter(p=>p.doc!==o&&p.name!==o.name),i=Math.max(1,Math.min(o.width,o.height)/16),s=Math.max(1,o.cellH/24),a=o.kind==="icon"?{maxStroke:Number(t.maxStroke)*i,maxFill:Number(t.maxFill),maxCentre:Number(t.maxCentre)*i}:void 0;if(!n.length&&r.expect?.height===void 0&&!a)return ct("consistency","no set to compare with (plan it in the manifest)");let c=qS(o,n,{ink:r.style?.outline??["ink","outline","black"],light:r.style?.light,height:r.expect?.height,maxL:Number(t.maxL),maxOutline:Number(t.maxOutline),maxAngle:Number(t.maxAngle),maxCluster:Number(t.maxCluster),maxSteps:Number(t.maxSteps),heightTol:Math.round(Number(t.heightTol)*s),...a?{icon:a}:{}}),l=c.parts.filter(p=>p.pass===!1),u=[];if(c.box&&l.some(p=>p.name==="height")){let p=[];for(let h=c.box.x;h<c.box.x+c.box.w;h++)p.push([h,c.box.y],[h,c.box.y+c.box.h-1]);u.push({label:"the drawn shape's top and bottom rows (its height is off the plan)",pts:p})}let m=l.filter(p=>["stroke weight","box fill","optical centre"].includes(p.name));if(c.box&&m.length){let p=[],h=c.box;for(let g=h.x;g<h.x+h.w;g++)p.push([g,h.y],[g,h.y+h.h-1]);for(let g=h.y;g<h.y+h.h;g++)p.push([h.x,g],[h.x+h.w-1,g]);u.push({label:`the drawn box (${m.map(g=>g.name).join(", ")} off the icon set)`,pts:p})}let d=Number(t.max),f=c.peers.length?`against ${c.peers.length} in its set (${c.peers.slice(0,6).join(", ")}${c.peers.length>6?", \u2026":""})`:"against the plan";return at("consistency",{status:l.length<=d?"pass":"fail",score:l.length,shown:String(l.length),limit:`\u2264 ${d}`,groups:u,parts:c.parts.map(p=>({...p})),detail:`${l.length?`outliers: ${l.map(p=>`${p.name} ${p.detail}`).join("; ")}`:"no outliers"} ${f}${c.recolours.length?`; recolours of each other, not compared: ${c.recolours.join(", ")}`:""}`})}function gF(e,t){let r=e.doc;if(!r.font)return ct("font","not a glyph sheet");let o=r.font,n=oy(r),i=[],s=[],a=(_,$)=>{let x=[];for(let k=0;k<r.cellW;k++)e.get(_.cell[0]+k,_.cell[1]+$)!==65535&&x.push([_.cell[0]+k,_.cell[1]+$]);return x},c=_=>{let $=new Map;for(let x of _)$.set(x,($.get(x)??0)+1);return[...$].sort((x,k)=>k[1]-x[1]||k[0]-x[0])[0]?.[0]},l=(_,$)=>{let x=n.filter(E=>E.box&&_.includes(String.fromCodePoint(E.cp)));if(x.length<2)return null;let k=x.map(E=>o.baseline-E.box[1]+1),P=c(k),I=x.filter((E,N)=>k[N]!==P);return I.length&&(s.push(`${$} ${P}: ${I.map(E=>`${go(E.cp)} ${o.baseline-E.box[1]+1}`).join(", ")}`),i.push({label:`${$} is not ${P}`,pts:I.flatMap(E=>a(E,E.box[1]))})),P},u=l("ABCDEFGHIJKLMNOPRSTUVWXYZ","cap height"),m=l("acemnorsuvwxz","x-height"),f=n.filter(_=>_.box&&/^[A-PR-Za-fhik-ortuv-xz0-9]$/.test(String.fromCodePoint(_.cp))).filter(_=>_.box[3]!==o.baseline);f.length&&(s.push(`off the baseline (row ${o.baseline}): ${f.map(_=>`${go(_.cp)} ends on row ${_.box[3]}`).join(", ")}`),i.push({label:`not standing on the baseline (row ${o.baseline})`,pts:f.flatMap(_=>a(_,_.box[3]))}));let p=n.filter(_=>_.box&&(_.advance===0||_.box[2]>=_.advance));p.length&&(s.push(`drawn past the advance: ${p.map(_=>`${go(_.cp)} (advance ${_.advance}, ink to column ${_.box[2]})`).join(", ")}`),i.push({label:"drawn past its advance",pts:p.flatMap(_=>{let $=[];for(let x=0;x<r.cellH;x++)for(let k=Math.max(_.advance,0);k<r.cellW;k++)e.get(_.cell[0]+k,_.cell[1]+x)!==65535&&$.push([_.cell[0]+k,_.cell[1]+x]);return $})}));let h=n.filter(_=>!_.box&&!/\s/u.test(String.fromCodePoint(_.cp)));h.length&&(s.push(`not drawn: ${h.map(_=>go(_.cp)).join(" ")}`),i.push({label:"an empty glyph cell",pts:h.map(_=>[_.cell[0],_.cell[1]])}));let g=n.filter(_=>_.box),b=g.length?Math.max(...g.map(_=>_.box[3]))-Math.min(...g.map(_=>_.box[1]))+1:0;b&&o.line<b&&s.push(`the line height ${o.line} is less than the glyphs' ${b} rows (lines would overlap)`);let y=Number(t.maxLine);y>0&&o.line>y&&s.push(`the line height ${o.line} is over the limit ${y}`);let w=s.length,v=Number(t.max),S=n.length-g.length;return at("font",{status:w<=v?"pass":"fail",score:w,shown:String(w),limit:`\u2264 ${v}`,groups:i,detail:`${w?s.join("; "):"metrics agree"} (${g.length} of ${n.length} glyphs drawn${S?`, ${S} empty`:""}; cap height ${u??"\u2014"}, x-height ${m??"\u2014"}, baseline row ${o.baseline}, line ${o.line}${y>0?` of at most ${y}`:""})`})}function PC(e){if(e.kind==="object")return[{x:0,y:0,w:e.width,h:e.height}];let t=[];for(let r=0;r+e.cellH<=e.height;r+=e.cellH)for(let o=0;o+e.cellW<=e.width;o+=e.cellW)t.push({x:o,y:r,w:e.cellW,h:e.cellH});return t}function yF(e,t){let r=e.doc;if(r.wrap||r.family||r.map)return ct("margin","tiles and families join their neighbours");let o=Number(t.max)>=0&&t.bottom===!1?["top","left","right","bottom"]:["top","left","right"],n=new Map,i=(l,u,m)=>{n.has(l)||n.set(l,[]),n.get(l).push([u,m])};for(let l of PC(r)){for(let u=l.x;u<l.x+l.w;u++)e.get(u,l.y)!==65535&&i("top",u,l.y),o.includes("bottom")&&e.get(u,l.y+l.h-1)!==65535&&i("bottom",u,l.y+l.h-1);for(let u=l.y;u<l.y+l.h;u++)e.get(l.x,u)!==65535&&i("left",l.x,u),e.get(l.x+l.w-1,u)!==65535&&i("right",l.x+l.w-1,u)}let s=o.filter(l=>n.has(l)).map(l=>({label:`art on the ${l} edge of its ${r.kind==="object"?"canvas":"cell"}`,pts:n.get(l)})),a=s.reduce((l,u)=>l+u.pts.length,0),c=Number(t.max);return at("margin",{status:a<=c?"pass":"fail",score:a,shown:String(a),limit:`\u2264 ${c}`,groups:s,detail:a===0?`a clear pixel all round${o.includes("bottom")?"":" but the bottom (where it stands)"}`:`${a} px on the edge (${s.map(l=>`${l.label.replace(/^art on the | edge.*$/g,"")} ${l.pts.length}`).join(", ")}): move it in, or make the canvas bigger`})}function bF(e,t){let r=e.doc;if(r.wrap||r.family||r.map)return ct("pieces","tiles and families are texture");let o=Number(t.min),n=[],i=0;for(let a of PC(r)){let c=new Uint8Array(a.w*a.h),l=[];for(let u=0;u<a.h;u++)for(let m=0;m<a.w;m++){if(c[u*a.w+m]||e.get(a.x+m,a.y+u)===65535)continue;let d=[],f=[[m,u]];for(c[u*a.w+m]=1;f.length;){let[p,h]=f.pop();d.push([a.x+p,a.y+h]);for(let[g,b]of js){let y=p+g,w=h+b;y<0||w<0||y>=a.w||w>=a.h||c[w*a.w+y]||e.get(a.x+y,a.y+w)===65535||(c[w*a.w+y]=1,f.push([y,w]))}}l.push(d)}l.sort((u,m)=>m.length-u.length);for(let u of l.slice(1)){if(u.length<o)continue;i++;let m=u.map(f=>f[0]),d=u.map(f=>f[1]);n.push({label:`a part apart from the rest: ${u.length} px at ${Math.min(...m)},${Math.min(...d)} ${Math.max(...m)-Math.min(...m)+1}x${Math.max(...d)-Math.min(...d)+1}`,pts:u})}}let s=Number(t.max);return at("pieces",{status:i<=s?"pass":"fail",score:i,shown:String(i),limit:`\u2264 ${s}`,groups:n,detail:i===0?"one piece":`${i} part${i>1?"s":""} not touching the rest (${n.map(a=>a.label.replace(/^a part apart from the rest: /,"")).join("; ")}): join it, or turn pieces off for this asset if it is meant to float`})}var Oy={palette:Z5,orphans:B5,jaggies:Y5,banding:eF,outline:tF,seam:rF,coverage:iF,readability:sF,revert:aF,repetition:lF,anim:uF,views:mF,fit:dF,variant:fF,footprint:QS("footprint"),lattice:QS("lattice"),draworder:QS("draworder"),density:pF,consistency:hF,font:gF,margin:yF,pieces:bF},wF=new Set(["font","consistency","coverage","anim","views","footprint","draworder","lattice"]);function vF(e,t,r){let o=Hr(e,["objects"]),i=[...new Set(o.map(l=>e.map.entries[l.entry].name))].flatMap(l=>{let u=r.world.get(l);return u&&!u.family&&!u.wrap?[{name:l,doc:u}]:[]});if(i.length<3)return ct("consistency",`fewer than three kinds of object on the map (${i.length})`);let s=[],a=[];for(let l of i){let m=qS(l.doc,i.filter(d=>d!==l),{ink:r.style?.outline??["ink","outline","black"],light:r.style?.light,maxL:Number(t.maxL),maxOutline:Number(t.maxOutline),maxAngle:Number(t.maxAngle),maxCluster:Number(t.maxCluster),maxSteps:Number(t.maxSteps),heightTol:Number(t.heightTol)}).parts.filter(d=>d.pass===!1);m.length&&(a.push(`${l.name}: ${m.map(d=>`${d.name} ${d.detail}`).join("; ")}`),s.push({label:`${l.name} stands out (${m.map(d=>d.name).join(", ")})`,pts:o.filter(d=>e.map.entries[d.entry].name===l.name).map(d=>[d.x,d.y])}))}let c=Number(t.max);return at("consistency",{status:s.length<=c?"pass":"fail",score:s.length,shown:String(s.length),limit:`\u2264 ${c}`,groups:s,detail:a.length?a.join(" | "):`${i.length} kinds of object on the map, none out of step with the rest`})}function $F(e,t,r){if(!r.world)return t.map(c=>ct(c,"a map is checked with the project's assets"));let o=_m("repetition","map",r.style,e.name),n=_m("seam","map",r.style,e.name),i=_m("lattice","map",r.style,e.name),s=Bt(e,r.world),a=ZT(e,r.world,{edgeRun:Number(o.edgeRun),motif:Number(o.motif),seam:Number(n.max),lattice:Number(i.max),latticeContrast:Number(i.contrast)},s);return t.map(c=>{let l=_m(c,"map",r.style,e.name);if(l.off===!0)return ct(c,"turned off in the style guide");if(c==="consistency")return vF(e,l,r);let u=a.find(m=>m.id===c);return u?at(c,{status:u.pass?"pass":"fail",score:u.score,shown:u.shown,limit:u.limitText,detail:u.detail,groups:u.groups.map(m=>({label:m.label,pts:m.cells})),...u.parts?{parts:u.parts.map(m=>({name:m.name,value:m.value,limit:m.limit,pass:m.pass,detail:m.detail}))}:{}}):ct(c,"checked on the assets the map names, not on the map")})}function kC(e,t,r){let o=t.filter(m=>m.r.status!=="skip");if(!o.length)return t[0].r;let n=o[0].r.limit.startsWith("\u2265"),i=o.filter(m=>m.r.status==="fail"),a=(i.length?i:o).reduce((m,d)=>(d.r.score??0)*(n?-1:1)>(m.r.score??0)*(n?-1:1)?d:m),c=o.flatMap(m=>m.r.groups.map(d=>({...d,label:`frame ${m.f+1}: ${d.label}`,frame:m.f}))),l=i.length>1?` (fails on frames ${i.map(m=>m.f+1).join(", ")})`:"";return at(e,{...a.r,groups:c,detail:`frame ${a.f+1}: ${a.r.detail}${l}${r}`,frame:a.f})}function jC(e,t=jn,r={}){if(e.map)return $F(e,t,r);let o=r.frame!==void 0?[r.frame]:Array.from({length:e.frameCount},(a,c)=>c),n="";if(o.length>1&&r.budget!==void 0&&e.width*e.height*e.frameCount>r.budget){let a=Math.min(r.focus??0,e.frameCount-1);o=[a],n=` (frame ${a+1} of ${e.frameCount} only: a large canvas; \`check\` covers every frame)`}let i=new Map,s=a=>i.get(a)??i.set(a,V5(e,a)).get(a);return t.map(a=>{let c=_m(a,e.kind,r.style,e.name);if(c.off===!0)return ct(a,Ny[a][e.kind]?.off===!0?`not checked on a ${e.kind}`:"turned off in the style guide");if(wF.has(a)||o.length===1&&e.frameCount===1)return Oy[a](s(o[0]),c,r);if(o.length===1){let l=Oy[a](s(o[0]),c,{...r,frame:o[0]});return l.status==="skip"?l:kC(a,[{f:o[0],r:l}],n)}return kC(a,o.map(l=>({f:l,r:Oy[a](s(l),c,{...r,frame:l})})),n)})}function xi(e){let t=e.filter(o=>o.status!=="skip");if(!t.length)return"checks: none apply";let r=t.filter(o=>o.status==="fail").length;return`checks: ${t.map(o=>`${o.id} ${o.shown} ${o.status==="pass"?"\u2713":"\u2717"}`).join(" \xB7 ")}`+(r?` (${r} failing: \`check\` gives coordinates)`:"")}var xs="ground",Sc="band",EC=new Map;function Qe(e){if(e.def){let r=JSON.stringify(e.def),o=EC.get(r);if(o)return o;let n=vs(e.def);return EC.set(r,n),n}let t=uy(e.scheme);if(!t)throw new Error(`unknown scheme '${e.scheme}'`);return t}function nk(e,t,r){let o=e.variants.length,n=Math.max(2,e.columns,t),i=Math.ceil(o/e.columns),s=e.variants.map((a,c)=>[c%e.columns,1+Math.floor(c/e.columns)]);return{cols:n,rows:1+i+r,inside:[0,0],outside:[1,0],cells:s,mapRow:1+i}}var mt=e=>nk(Qe(e),e.mapCols,e.mapRows);function zm(e,t){let r=mt(e);if(t==="inside")return r.inside;if(t==="outside")return r.outside;let o=Qe(e).byName.get(t);return o===void 0?null:r.cells[o]}var Dy=new Map;function xo(e,t,r){let o=`${e.name}|${t}|${r.inset}|${r.radius}|${r.fillet??""}|${r.jitter?`${r.jitter.px}:${r.jitter.seed}`:""}|${r.bands.map(i=>`${i.w}:${i.fill}`).join(",")}`,n=Dy.get(o);return n||(n=e.variants.map((i,s)=>ET(e,s,t,r)),Dy.size>64&&Dy.clear(),Dy.set(o,n)),n}function ZS(e,t){return t<0||t<e.bands.length&&e.bands[t].fill==="outside"}var xF=(e,t)=>t>=0&&t<e.bands.length;function _F(e,t,r,o,n,i,s,a){for(let c=0;c<a;c++){let l=(o+c)*t+r;e.copyWithin((i+c)*t+n,l,l+s)}}function TC(e,t,r,o,n){let i=new Uint16Array(n*n).fill(65535);return e.layers.forEach((s,a)=>{if(s.hidden||s.reference)return;let c=e.cels[a][t];for(let l=0;l<n;l++)for(let u=0;u<n;u++){let m=c[(o*n+l)*e.width+r*n+u];m!==65535&&(i[l*n+u]=m)}}),i}var CC=new WeakMap;function SF(e,t,r,o){let n=CC.get(o);return n||(n=o.map(i=>Uint8Array.from(i,s=>ZS(r,s)?1:0)),CC.set(o,n)),n}function rk(e){let t=e.family;if(!t)return;let r=Qe(t),o=t.tile,n=o/2,i=e.width,s=mt(t),a=xo(r,o,t.geometry),c=e.layers.findIndex(d=>d.name===xs),l=e.layers.findIndex(d=>d.name===Sc),u=new Set(t.detached.map(d=>r.byName.get(d))),m=new Set;for(let d=0;d<e.frameCount;d++){if(c>=0&&!m.has(e.cels[c][d])){let f=e.cels[c][d];m.add(f);let p=TC(e,d,s.inside[0],s.inside[1],o),h=TC(e,d,s.outside[0],s.outside[1],o),g=SF(r,o,t.geometry,a);for(let b=0;b<r.variants.length;b++){let[y,w]=s.cells[b],v=g[b];for(let S=0;S<o;S++){let _=(w*o+S)*i+y*o;for(let $=0;$<o;$++){let x=S*o+$;f[_+$]=v[x]?h[x]:p[x]}}}}if(l>=0&&!m.has(e.cels[l][d])){let f=e.cels[l][d];m.add(f);for(let p=0;p<r.variants.length;p++){let h=r.sources[p];if(!h||u.has(p))continue;let[g,b]=s.cells[p];h.forEach(([y,w],v)=>{if(y<0){for(let $=0;$<n;$++)f.fill(65535,(b*o+(v&2?n:0)+$)*i+g*o+(v&1?n:0),(b*o+(v&2?n:0)+$)*i+g*o+(v&1?n:0)+n);return}let[S,_]=s.cells[y];_F(f,i,S*o+(w&1?n:0),_*o+(w&2?n:0),g*o+(v&1?n:0),b*o+(v&2?n:0),n,n)})}}}}function OC(e,t,r,o,n){let i=new Uint16Array(n*n);for(let s=0;s<n;s++)i.set(e.subarray((o*n+s)*t+r*n,(o*n+s)*t+r*n+n),s*n);return i}function _o(e,t,r=0){let o=e.family,n=Qe(o),i=o.tile,s=mt(o),a=be(e,r),c=hi(n,t),l=new Map,u=p=>{let h=p??-1,g=l.get(h);if(!g){let[b,y]=p===null?s.outside:s.cells[p];l.set(h,g=OC(a,e.width,b,y,i))}return g},m=t.cols*i,d=t.rows*i,f=new Uint16Array(m*d);return c.forEach((p,h)=>{let g=u(p),b=h%t.cols*i,y=Math.floor(h/t.cols)*i;for(let w=0;w<i;w++)f.set(g.subarray(w*i,w*i+i),(y+w)*m+b)}),{px:f,w:m,h:d,t:i,variants:c}}function fC(e,t,r,o=0){let n=be(e,o),i=t*e.width,s=r*e.height,a=new Uint16Array(i*s);for(let c=0;c<s;c++)for(let l=0;l<i;l++)a[c*i+l]=n[c%e.height*e.width+l%e.width];return{px:a,w:i,h:s,t:e.width,variants:Array.from({length:t*r},()=>null)}}function $s(...e){let t=2654435769;for(let r of e)t=Math.imul(t^(r|0),2246822507)>>>0,t=(t^t>>>13)>>>0,t=Math.imul(t,3266489909)>>>0,t=(t^t>>>16)>>>0;return t}function $i(e,t,r,o){let n=e.neighbours==="corners"?t+1:t,i=e.neighbours==="corners"?r+1:r,s=new dt(o,346),a=2,c=Math.floor(n/a)+2,l=Math.floor(i/a)+2,u=Array.from({length:c*l},()=>s.nextInt(256)),m=new Uint8Array(n*i);for(let d=0;d<i;d++)for(let f=0;f<n;f++){let p=Math.floor(f/a),h=Math.floor(d/a),g=f%a,b=d%a,y=u[h*c+p],w=u[h*c+p+1],v=u[(h+1)*c+p],S=u[(h+1)*c+p+1],_=Math.floor(((y*(a-g)+w*g)*(a-b)+(v*(a-g)+S*g)*b)/(a*a)),$=2*f-(n-1),x=2*d-(i-1),k=Math.floor($*$*256/((n-1)*(n-1)||1)+x*x*256/((i-1)*(i-1)||1)),P=f===0||d===0||f===n-1||d===i-1;m[d*n+f]=!P&&(_-128)*2+150-k>0?1:0}return{cols:t,rows:r,cells:m}}function Es(e,t){let r=new Array(e.variants.length).fill(0);for(let o of hi(e,t,"not",!1))o!==null&&r[o]++;return r}function GS(e,t){let r=e.variants[t];if(r.key===null)return null;if(e.neighbours==="corners"){let i=new Uint8Array(16),s=r.key;return s&128&&(i[5]=1),s&2&&(i[6]=1),s&32&&(i[9]=1),s&8&&(i[10]=1),{cols:3,rows:3,cells:i}}let o=new Uint8Array(9);if(r.on==="fillet"){let i=e.cornerRule==="diagonal";for(let[s,a]of[[2,[1,2,5]],[8,[5,8,7]],[32,[7,6,3]],[128,[3,0,1]]])if(r.key&s)for(let c of a)(!i||c!==a[1])&&(o[c]=1);return{cols:3,rows:3,cells:o}}if(r.on==="face")return o[1]=1,r.key&4&&(o[2]=1),r.key&64&&(o[0]=1),r.key&8&&(o[2]=o[5]=1),r.key&32&&(o[0]=o[3]=1),{cols:3,rows:3,cells:o};if(r.on==="side")return r.key&64&&(o[3]=1),r.key&4&&(o[5]=1),r.key&1&&(r.key&64&&(o[0]=1),r.key&4&&(o[2]=1)),r.key&16||(o[7]=1,r.key&64&&(o[6]=1),r.key&4&&(o[8]=1)),{cols:3,rows:3,cells:o};if(r.on==="corner")return r.key&128&&(o[0]=1),r.key&2&&(o[2]=1),{cols:3,rows:3,cells:o};o[4]=1;let n=[[1,1],[2,2],[4,5],[8,8],[16,7],[32,6],[64,3],[128,0]];for(let[i,s]of n)r.key&i&&(o[s]=1);return{cols:3,rows:3,cells:o}}function qy(e,t,r,o,n=1){let i=e.neighbours==="corners",s=i?t+1:t,a=i?r+1:r,c=bo(e),l=new dt(o,3086),u=h=>{for(let g=h.length-1;g>0;g--){let b=l.nextInt(g+1);[h[g],h[b]]=[h[b],h[g]]}return h},m=i?2:3,d=h=>{let g=GS(e,h).cells;return i?Uint8Array.from([g[5],g[6],g[9],g[10]]):g},f=s-m+1,p=a-m+1;for(let h=0;h<8;h++){let g={cols:t,rows:r,cells:new Uint8Array(s*a)},b=Es(e,g),y=!0,w=new Map(c.map($=>[$,d($).reduce((x,k)=>x+k,0)]));for(let $ of u([...c]).sort((x,k)=>w.get(k)-w.get(x))){let x=d($);for(;b[$]<n;){let k=u(Array.from({length:f*p},(N,T)=>T)),P=N=>{let T=N%f,q=Math.floor(N/f),Z=0;for(let D=0;D<m;D++)for(let V=0;V<m;V++)g.cells[(q+D)*s+T+V]!==x[D*m+V]&&Z++;return Z},I=new Map(k.map(N=>[N,P(N)]));k.sort((N,T)=>I.get(N)-I.get(T));let E=!1;for(let N of k){let T=N%f,q=Math.floor(N/f),Z=g.cells.slice();for(let V=0;V<m;V++)for(let F=0;F<m;F++)g.cells[(q+V)*s+T+F]=x[V*m+F];let D=Es(e,g);if(D[$]>b[$]&&c.every(V=>V===$||D[V]>=Math.min(n,b[V]))){b=D,E=!0;break}g.cells.set(Z)}if(!E){y=!1;break}}}if(y)return g;let v=$=>{let x=Es(e,$);return c.reduce((k,P)=>k+Math.min(n,x[P]),0)},S=c.length*n,_=v(g);for(let $=0;$<60&&_<S;$++){let x=0,k=-1,P=l.nextInt(g.cells.length);for(let I=0;I<g.cells.length;I++){let E=(P+I)%g.cells.length;g.cells[E]^=1;let N=v(g);g.cells[E]^=1,N-_>x&&(x=N-_,k=E)}if(k<0){let I=l.nextInt(g.cells.length);g.cells[I]^=1,_=v(g);continue}g.cells[k]^=1,_+=x}if(_>=S)return g}return null}function Cy(e,t,r=0){let o=t.family;if(!o)return 0;let n=Qe(o),i=e.t,s=e.w/i,a=e.variants.flatMap((m,d)=>m!==null&&pi(n.variants[m].on)?[d]:[]);if(!a.length)return 0;let[c,l]=mt(o).outside,u=be(t,r);for(let m of a){let d=m%s*i,f=Math.floor(m/s)*i;for(let p=0;p<i;p++)for(let h=0;h<i;h++)e.px[(f+p)*e.w+d+h]=u[(l*i+p)*t.width+c*i+h]}return a.length}function _s(e,t){let{w:r,h:o,t:n}=e,i=t.palette.entries.map(d=>$o(d.hex)),s=new Int32Array(r*o),a=new Float64Array(r*o),c=new Int32Array(r*o),l=new Float64Array(r*o);for(let d=0;d<o;d++)for(let f=0;f<r;f++){let p=e.px[d*r+f],h=p===65535?-1:p,g=p===65535?0:i[p];s[d*r+f]=h,a[d*r+f]=g,c[f*o+d]=h,l[f*o+d]=g}let u=km(s,a,r,o,n),m=km(c,l,o,r,n);return{score:Math.max(u.jump,m.jump,u.line,m.line,0),jx:u.jump,jy:m.jump,lx:u.line,ly:m.line}}var zs={cols:12,rows:10,seed:1};function AC(e,t){let r=0,o=1/0;return e.forEach((n,i)=>{let s=0;for(let a of e)if(a!==n)for(let c=0;c<n.length;c++)t(c)&&n[c]!==a[c]&&s++;s<o&&(o=s,r=i)}),r}function NC(e,t){let r=e.family,o=Qe(r),n=r.tile,i=mt(r),s={cols:r.mapCols,rows:r.mapRows,cells:r.terrain},a=hi(o,s),c=e.layers.findIndex(h=>h.name===Sc),l=e.layers.findIndex(h=>h.name===xs),u=xo(o,n,r.geometry),m=new Map,d=[],f=e.width,p=new Set(r.detached);for(let h=0;h<e.frameCount;h++){let g=be(e,h),b=y=>OC(g,f,y%r.mapCols,i.mapRow+Math.floor(y/r.mapCols),n);if(o.variants.forEach((y,w)=>{let v=a.flatMap((I,E)=>I===w?[E]:[]);if(!v.length){h===0&&y.key!==null&&d.push(y.name);return}let S=I=>!!y.on||xF(r.geometry,u[w][I]),_=v.map(b),$=AC(_,S);if(h===0&&m.set(w,{tile:v[$],of:v.length}),c<0)return;let x=e.cels[c][h],[k,P]=i.cells[w];for(let I=0;I<n;I++)for(let E=0;E<n;E++)x[(P*n+I)*f+k*n+E]=S(I*n+E)?_[$][I*n+E]:65535;o.pieces.includes(y.name)||p.add(y.name)}),t&&l>=0){let y=o.variants.findIndex($=>!$.on&&$.quads.every(x=>x==="in"||x.startsWith("in@"))),w=a.flatMap(($,x)=>$===y?[x]:[]),v=a.flatMap(($,x)=>{if($!==null)return[];if(o.neighbours==="corners")return[];let k=x%r.mapCols,P=Math.floor(x/r.mapCols);for(let I=-1;I<=1;I++)for(let E=-1;E<=1;E++){let N=k+E,T=P+I;if(N>=0&&T>=0&&N<r.mapCols&&T<r.mapRows&&r.terrain[T*r.mapCols+N])return[]}return[x]}),S=o.neighbours==="corners"?a.flatMap(($,x)=>$!==null&&o.variants[$].key===0?[x]:[]):[],_=e.cels[l][h];for(let[$,x]of[[i.inside,w],[i.outside,o.neighbours==="corners"?S:v]]){if(!x.length)continue;let k=x.map(b),P=k[AC(k,()=>!0)];for(let I=0;I<n;I++)_.set(P.subarray(I*n,I*n+n),($[1]*n+I)*f+$[0]*n)}}}return r.detached=o.variants.map(h=>h.name).filter(h=>p.has(h)),{chosen:m,missing:d}}var MC=e=>{let t=tr(e)[0];return e.overlay?.mode==="pingpong"?{...t,loop:"pingpong"}:t};function kF(e){let t=e.overlay,r=Math.max(1,nr(e,MC(e)));return t.mode==="sparkle"?r+t.rest:r}function HS(e,t,r,o){let n=e.overlay;if($s(n.seed,t,r)%n.every!==0)return null;let i=MC(e),s=Math.max(1,nr(e,i));if(n.mode==="cycle"||n.mode==="pingpong")return Fr(e,i,o);if(n.mode==="wave")return Fr(e,i,o+Math.floor((t+r)*s/8));let a=s+n.rest,c=(o+$s(n.seed,t,r,7)%a)%a;return c<s?Fr(e,i,c):null}function BS(e,t,r,o,n,i,s){let a=e.overlay,c=s??be(e,t),l=$s(a.seed,r,o,1),u=(a.anchor?a.anchor[0]:Math.floor((n-e.width)/2))+(a.spread[0]?l%(2*a.spread[0]+1)-a.spread[0]:0),m=(a.anchor?a.anchor[1]:Math.floor((n-e.height)/2))+(a.spread[1]?(l>>>8)%(2*a.spread[1]+1)-a.spread[1]:0);for(let d=0;d<e.height;d++)for(let f=0;f<e.width;f++){let p=c[d*e.width+f];p!==65535&&i(r*n+u+f,o*n+m+d,p)}}function pC(e,t,r,o){let n=o?.family?Qe(o.family):null;for(let i of t){let s=i.overlay;if(!s)continue;let a=e.w/e.t,c=new Map;e.variants.forEach((l,u)=>{let m=u%a,d=Math.floor(u/a),f=l!==null&&!n?.variants[l].on;if(s.on==="outside"&&f||s.on==="inside"&&!f)return;let p=HS(i,m,d,r);if(p===null)return;let h=c.get(p)??c.set(p,be(i,p)).get(p);BS(i,p,m,d,e.t,(g,b,y)=>{g>=0&&b>=0&&g<e.w&&b<e.h&&(e.px[b*e.w+g]=y)},h)})}}function hC(e,t){let r=e.palette.entries.map(n=>{let i=t.findIndex(s=>s.name===n.name&&s.hex===n.hex);return i<0&&(i=t.findIndex(s=>s.hex===n.hex)),i<0&&(t.push({name:n.name,hex:n.hex}),i=t.length-1),i}),o=e.cels.map(n=>n.map(i=>i.map(s=>s===65535?s:r[s])));return{...e,cels:o}}function gC(e,t,r){let o=(s,a)=>a?o(a,s%a):s,n=1,i=s=>{n=Math.min(r,n/o(n,s)*s)};e.frameCount>1&&i(Math.max(1,nr(e,tr(e)[0])));for(let s of t)s.overlay&&i(kF(s));return n}function yC(e,t){if(e.frameCount<2)return 0;let r=tr(e)[0];return Lr(r).length?Fr(e,r,t):0}function DC(){return{mode:"cycle",on:"outside",anchor:null,spread:[0,0],every:1,rest:60,seed:1}}function qt(e,t,r=!0){let o=Me(e,t);return{width:e.width,height:e.height,wrap:e.wrap,pixels:e.cels[o.layer][o.frame],mask:r?o.sel:null}}function zF(e,t){if(!t)return[[0,0]];if(t.shape==="stamp"){let n=e.stamps[t.stamp];if(!n)return[[0,0]];let i=[];for(let s=0;s<n.h;s++)for(let a=0;a<n.w;a++)n.px[s*n.w+a]!==65535&&i.push([a-(n.w>>1),s-(n.h>>1)]);return i.length?i:[[0,0]]}let r=t.size,o=[];for(let n=0;n<r;n++)for(let i=0;i<r;i++){if(t.shape==="circle"){let s=2*i-(r-1),a=2*n-(r-1);if(s*s+a*a>r*r-r+1)continue}o.push([i-(r>>1),n-(r>>1)])}return o}function Uy(e,t,r){let o=Me(e,t).mirror;if(!o)return r;let n=[...r],i=(s,a,c)=>{let l=[...s];return a&&(l[0]=o.x2-s[0]),c&&(l[1]=o.y2-s[1]),l};for(let s of r)o.x2!==null&&n.push(i(s,!0,!1)),o.y2!==null&&n.push(i(s,!1,!0)),o.x2!==null&&o.y2!==null&&n.push(i(s,!0,!0));return n}function qC(e,t,r,o,n={}){let i=qt(e,t),s=r;if(n.brush){let a=zF(e,Me(e,t).brush);(a.length!==1||a[0][0]!==0||a[0][1]!==0)&&(s=r.flatMap(([c,l])=>a.map(([u,m])=>[c+u,l+m])))}n.mirror&&(s=Uy(e,t,s));for(let[a,c]of s)UC(i,a,c,o)}function yn(e,t,r,o){let n=qt(e,t);for(let[i,s,a]of o?Uy(e,t,r):r)UC(n,i,s,a)}function UC(e,t,r,o){let n=Rt(e,t,r);n>=0&&(!e.mask||e.mask[n])&&(e.pixels[n]=o)}var Sr=2;function kc(e,t,r){return{t:"kv",key:e,value:t,quoted:!1,vcol:r.col,line:r.line,col:r.col}}var we=class{cmd;positional=[];opts=new Map;flags=[];cell=null;next=0;constructor(t,r,o=[]){this.cmd=t;for(let n of t.args)if(n.t==="kv"){if(!r.includes(n.key)){let i=r.length?` (options: ${r.join(", ")})`:"";throw new O(n.line,n.col,`${t.name} has no option '${n.key}'${i}`)}if(this.opts.has(n.key))throw new O(n.line,n.col,`option '${n.key}' given twice`);this.opts.set(n.key,n)}else if(n.t==="cell"){if(this.cell)throw new O(n.line,n.col,"@cell given twice");this.cell=n}else n.t==="word"&&o.includes(n.v)?this.flags.push(n):this.positional.push(n)}where(){let t=this.positional[this.next-1];return t?[t.line,t.col+zc(t).length+1]:[this.cmd.line,this.cmd.col+this.cmd.name.length+1]}peek(){return this.positional[this.next]}take(t,r){let o=this.positional[this.next];if(!o){let[n,i]=this.where();throw new O(n,i,`${this.cmd.name}: expected ${r}`)}if(o.t!==t)throw new O(o.line,o.col,`${this.cmd.name}: expected ${r}`);return this.next++,o}rest(){let t=this.positional.slice(this.next);return this.next=this.positional.length,t}done(){let t=this.positional[this.next];if(t)throw new O(t.line,t.col,`${this.cmd.name}: unexpected '${zc(t)}'`)}cellOrigin(t){if(!this.cell)return{dx:0,dy:0,text:""};if(this.cell.name!==void 0){let s=t.family?zm(t.family,this.cell.name):null;if(!s)throw new O(this.cell.line,this.cell.col,t.family?`@cell(${this.cell.name}): no such cell (inside, outside, or a variant of ${t.family.scheme})`:`@cell(${this.cell.name}): cells by name are a family's`);return{dx:s[0]*t.cellW,dy:s[1]*t.cellH,text:` @cell(${this.cell.name})`}}let{cx:r,cy:o}=this.cell,n=Math.floor(t.width/t.cellW),i=Math.floor(t.height/t.cellH);if(r>=n||o>=i)throw new O(this.cell.line,this.cell.col,`@cell(${r},${o}) is outside the ${n}x${i} cell grid`);return{dx:r*t.cellW,dy:o*t.cellH,text:` @cell(${r},${o})`}}flag(t,r){let o=this.flags.filter(n=>t.includes(n.v));if(o.length>1)throw new O(o[1].line,o[1].col,`choose one of ${t.join(" or ")}`);return o[0]?.v??r}choice(t,r,o){let n=this.opts.get(t);if(!n)return o;if(!r.includes(n.value))throw new O(n.line,n.vcol,`${t}= must be one of ${r.join(", ")}`);return n.value}};function zc(e){switch(e.t){case"word":return e.v;case"int":return String(e.v);case"point":return`${e.x},${e.y}`;case"size":return`${e.w}x${e.h}`;case"cell":return e.name!==void 0?`@cell(${e.name})`:`@cell(${e.cx},${e.cy})`;case"string":return tn(e.v);case"kv":return`${e.key}=${e.quoted?tn(e.value):e.value}`;case"block":return"<<";case"body":return"{"}}function De(e,t){if(!t.doc)throw new O(e.line,e.col,"there is no document yet: start with 'new'");return t.doc}function Be(e,t){let r=De(e,t);if(r.map)throw new O(e.line,e.col,`${e.name}: a map holds tiles and objects by name, not pixels (terrain, place, move, road, scatter, map gen)`);let o=r.layers[Me(r,t.by).layer];if(o.locked)throw new O(e.line,e.col,`layer '${o.name}' is locked (layer set ${o.name} locked=off to draw on it)`);let n=Me(r,t.by).frame,i=fi(r,n);if(i?.mirror){let s=r.views.find(c=>c.name===i.mirror),a=s?` (frame ${s.from+n-i.from+1})`:"";throw new O(e.line,e.col,`frame ${n+1} is in view ${i.name}, a live mirror of ${i.mirror}: draw on ${i.mirror}${a}, or view ${i.name} mirror=off`)}return r}var le=e=>({k:"fn",run:e}),So=(e,t,r=!0)=>le((o,n)=>qC(o,n,e,t,{brush:r,mirror:!0}));function zt(e,t,r,o){if(e==="none")return{index:65535,name:"none"};let n=t.entries.findIndex(i=>i.name===e);if(n<0&&[...e].length===1&&(n=t.entries.findIndex(i=>i.key===e)),n<0&&e.startsWith("#")){let i=e.toLowerCase();if(n=t.entries.findIndex(s=>s.hex===i),n<0)throw new O(r,o,`c=${e} is not in palette '${t.name}'`)}if(n<0){let i=t.entries.map(a=>a.name),s=i.length>12?i.slice(0,12).join(", ")+", ...":i.join(", ");throw new O(r,o,`unknown colour '${e}' (palette '${t.name}': ${s}, none)`)}return{index:n,name:t.entries[n].name}}function ko(e,t){let r=e.opts.get("c");if(!r)throw new O(e.cmd.line,e.cmd.col,`${e.cmd.name}: missing c=<colour>`);return zt(r.value,t.palette,r.line,r.vcol)}var ik=(e,t,r)=>t||r?e.map(([o,n])=>[o+t,n+r]):e;function RF(e){return{name:e.name,description:e.description,neighbours:e.neighbours,...e.cornerRule!==void 0?{cornerRule:e.cornerRule}:{},...e.inset?{inset:e.inset}:{},...e.kinds?{kinds:e.kinds}:{},...e.faces!==void 0?{faces:e.faces}:{},...e.sides!==void 0?{sides:e.sides}:{},...e.fillets!==void 0?{fillets:e.fillets}:{},columns:e.columns,pieces:e.pieces,variants:e.variants.map(t=>({name:t.name,key:t.key,quads:t.quads,...t.on?{on:t.on}:{},...t.alt?{alt:t.alt}:{}}))}}var IF={name:"new",summary:"new <kind> <name> <W>x<H> [palette=<name>] [wrap=on|off] [cell=<W>x<H>] [bg=<colour>|none] [<< palette rows >>] (new family <name> <T>x<T> scheme=<scheme> [map=<C>x<R>]: an autotile family of T px tiles; new map <name> <C>x<R> [tile=<T>]: a map of C x R cells of T px)",normalise(e,t){if(t.doc)throw new O(e.line,e.col,"new must be the first command of a tape (this document already exists)");let r=new we(e,["palette","wrap","cell","bg","scheme","def","map","tile","chars","cols","baseline","line","spacing"]),o=r.take("word",`a kind (${ys.join(", ")})`);if(!ys.includes(o.v))throw new O(o.line,o.col,`unknown kind '${o.v}' (kinds: ${ys.join(", ")})`);let n=o.v,i=r.take("word","a document name");if(!/^[a-z][a-z0-9_-]*$/.test(i.v))throw new O(i.line,i.col,"document names use a-z, 0-9, _ and -, starting with a letter");let s=t.defaults?.asset?.(n,i.v),a=r.peek()?.t!=="size"&&s?.size?{t:"size",w:s.size[0],h:s.size[1],line:i.line,col:i.col}:r.take("size","a size like 24x24 (or plan the asset in the manifest)"),c=r.peek()?.t==="block"?r.take("block","palette rows"):null;if(r.done(),a.w<1||a.h<1||a.w>4096||a.h>4096)throw new O(a.line,a.col,"size must be 1..4096 on each side");let l=t.lang??Sr,u=r.opts.get("palette"),m=u?.value??s?.palette??t.defaultPalette,d;if(c){if(l<2)throw new O(c.line,c.col,"a palette block needs tape language 2");if(!m||!/^[A-Za-z][A-Za-z0-9_-]*$/.test(m))throw new O(u?.line??e.line,u?.vcol??e.col,"new: a palette block needs palette=<name>");let T=iT(m,c.rows.map(q=>q.text));if("message"in T){let q=c.rows[T.row];throw new O(q?.line??c.line,(q?.col??c.col)+T.col,T.message)}d=T.palette}else{if(!m)throw new O(e.line,e.col,"new: no palette= given and the project has no default palette");let T=t.palette(m);if(!T)throw new O(u?.line??e.line,u?.vcol??e.col,`unknown palette '${m}'`);d=T}let f=r.choice("wrap",["on","off"],n==="tile"?"on":"off")==="on",p=a.w,h=a.h,g=r.opts.get("cell")??(s?.cell&&n!=="family"&&n!=="map"?kc("cell",`${s.cell[0]}x${s.cell[1]}`,e):void 0);if(g){let T=/^(\d+)x(\d+)$/.exec(g.value);if(!T||Number(T[1])<1||Number(T[2])<1)throw new O(g.line,g.vcol,"cell= must be a size like 24x24");p=Number(T[1]),h=Number(T[2])}let b=r.opts.get("bg"),y=b?zt(b.value,d,b.line,b.vcol):{index:65535,name:"none"},w=r.opts.get("scheme")??(n==="family"&&s?.scheme?kc("scheme",s.scheme,e):void 0),v=r.opts.get("map"),S,_,$,x=["chars","cols","baseline","line","spacing"].flatMap(T=>r.opts.get(T)?[r.opts.get(T)]:[]);if(n!=="font"&&x.length)throw new O(x[0].line,x[0].col,`${x[0].key}= is for new font`);let k=a.w,P=a.h,I="",E=r.opts.get("tile");if(E&&n!=="map")throw new O(E.line,E.col,"tile= is for new map");if(n==="family"){if(a.w!==a.h||a.w%2||a.w<4||a.w>256)throw new O(a.line,a.col,`a family's tiles are square, even and 4..256 px (${a.w}x${a.h})`);if(!w)throw new O(e.line,e.col,`new family: missing scheme=<scheme> (${[...yo.keys()].join(", ")})`);let T=r.opts.get("def"),q=null,Z=T||t.scheme?.(w.value)?void 0:uy(w.value);if(!Z){try{let M=T?JSON.parse(T.value):t.scheme?.(w.value)??null;q=M?RF(M):null,q&&(Z=vs(q))}catch(M){throw new O((T??w).line,(T??w).vcol,`scheme '${w.value}': ${M.message}`)}if(q&&q.name!==w.value)throw new O(w.line,w.vcol,`def= holds scheme '${q.name}', not '${w.value}'`)}if(!Z)throw new O(w.line,w.vcol,`unknown scheme '${w.value}' (schemes: ${[...yo.keys()].join(", ")}, or the project's schemes/*.json)`);if(f)throw new O(r.opts.get("wrap").line,r.opts.get("wrap").vcol,"a family sheet does not wrap (its textures are tiles that do)");if(g&&(p!==a.w||h!==a.h))throw new O(g.line,g.vcol,`a family's cells are its tiles (${a.w}x${a.h})`);let D=0,V=0;if(v){let M=/^(\d+)x(\d+)$/.exec(v.value);if(!M||Number(M[1])<3||Number(M[2])<3||Number(M[1])>64||Number(M[2])>64)throw new O(v.line,v.vcol,"map= must be a size in tiles like 12x10 (3..64 each way)");D=Number(M[1]),V=Number(M[2])}let F=nk(Z,D,V);k=F.cols*a.w,P=F.rows*a.h,p=a.w,h=a.h,S={scheme:Z.name,tile:a.w,geometry:{inset:TT(Z,a.w),radius:0,bands:[]},detached:[],mapCols:D,mapRows:V,terrain:new Uint8Array,def:q},I=` scheme=${Z.name}${q?` def=${tn(JSON.stringify(q))}`:""}${D?` map=${D}x${V}`:""}`}else if(n==="map"){if(a.w>512||a.h>512)throw new O(a.line,a.col,"a map is at most 512x512 cells");for(let q of[w,v,g,r.opts.get("wrap"),b])if(q)throw new O(q.line,q.col,`new map takes no ${q.key}= (its cells are tile= px)`);let T=t.defaults?.grid??24;if(E){if(!/^\d+$/.test(E.value)||Number(E.value)<4||Number(E.value)>256)throw new O(E.line,E.vcol,"tile= must be the cell size in pixels, 4..256");T=Number(E.value)}p=1,h=1,_={tile:T,entries:[]},I=` tile=${T}`}else for(let T of[w,v,r.opts.get("def")])if(T)throw new O(T.line,T.col,`${T.key}= is for new family`);if(n==="font"){let T=r.opts.get("chars")??(s?.chars?{...kc("chars",s.chars,e),quoted:!/^[0-9U+,\-]+$/.test(s.chars)}:void 0),q=T?cm(T.value,T.quoted):cm("32-126",!1);if(typeof q=="string")throw new O(T.line,T.vcol,q);if(f)throw new O(r.opts.get("wrap").line,r.opts.get("wrap").vcol,"a glyph sheet does not wrap");if(g&&(p!==a.w||h!==a.h))throw new O(g.line,g.vcol,`a font's cells are its glyph size (${a.w}x${a.h})`);let Z=(F,M,L,A)=>{let z=r.opts.get(F);if(!z)return A;if(!/^\d+$/.test(z.value)||Number(z.value)<M||Number(z.value)>L)throw new O(z.line,z.vcol,`${F}= must be ${M}..${L}`);return Number(z.value)},D=Z("cols",1,256,Math.min(16,q.length)),V=Math.ceil(q.length/D);if(a.w>256||a.h>256)throw new O(a.line,a.col,"a glyph cell is at most 256x256");if(D*a.w>4096||V*a.h>4096)throw new O(a.line,a.col,`${q.length} glyphs in ${D} columns make a ${D*a.w}x${V*a.h} sheet, over 4096`);$={chars:q,cols:D,baseline:Z("baseline",0,a.h-1,a.h-1),line:Z("line",1,1024,a.h+1),spacing:Z("spacing",0,64,1),advances:{}},k=D*a.w,P=V*a.h,p=a.w,h=a.h,I=` chars=${mT(q)} cols=${D} baseline=${$.baseline} line=${$.line} spacing=${$.spacing}`}let N=_?`new map ${i.v} ${a.w}x${a.h}${I} palette=${d.name}`:n==="font"?`new font ${i.v} ${a.w}x${a.h} palette=${d.name} wrap=off cell=${p}x${h} bg=${y.name}${I}`:`new ${n} ${i.v} ${a.w}x${a.h}${I} palette=${d.name} wrap=${f?"on":"off"} cell=${p}x${h} bg=${y.name}`;return{text:l>=2?`${N} <<
132
+ ${Wt(ty(d))}>>`:N,op:{k:"new",kind:n,name:i.v,width:k,height:P,cellW:p,cellH:h,wrap:f,palette:d,bg:y.index,...S?{family:S}:{},..._?{map:_}:{},...$?{font:$}:{},...n==="overlay"?{overlay:DC()}:{}}}}},PF={name:"px",summary:"px <x,y> [<x,y> ...] c=<colour>",normalise(e,t){let r=Be(e,t),o=new we(e,["c"]),n=o.cellOrigin(r),i=[];i.push(rn(o.take("point","a point x,y")));for(let a of o.rest()){if(a.t!=="point")throw new O(a.line,a.col,"px: expected a point x,y");i.push(rn(a))}let s=ko(o,r);return{text:`px${n.text} ${i.map(rr).join(" ")} c=${s.name}`,op:So(ik(i,n.dx,n.dy),s.index)}}},jF={name:"line",summary:"line <x,y> <x,y> [<x,y> ...] c=<colour> [pp=on|off]",normalise(e,t){let r=Be(e,t),o=new we(e,["c","pp"]),n=o.cellOrigin(r),i=[rn(o.take("point","a start point x,y")),rn(o.take("point","an end point x,y"))];for(let c of o.rest()){if(c.t!=="point")throw new O(c.line,c.col,"line: expected a point x,y");i.push(rn(c))}let s=ko(o,r),a=o.choice("pp",["on","off"],"on");return{text:`line${n.text} ${i.map(rr).join(" ")} c=${s.name} pp=${a}`,op:So(LS(ik(i,n.dx,n.dy),a==="on"),s.index)}}},EF={name:"rect",summary:"rect <x,y> <W>x<H> c=<colour> [outline|fill]",normalise(e,t){let r=Be(e,t),o=new we(e,["c"],["outline","fill"]),n=o.cellOrigin(r),i=o.take("point","a corner x,y"),s=o.take("size","a size WxH");if(o.done(),s.w<1||s.h<1)throw new O(s.line,s.col,"rect: size must be at least 1x1");let a=ko(o,r),c=o.flag(["outline","fill"],"outline");return{text:`rect${n.text} ${i.x},${i.y} ${s.w}x${s.h} c=${a.name} ${c}`,op:So(vo(i.x+n.dx,i.y+n.dy,s.w,s.h,c==="fill"),a.index,c==="outline")}}},TF={name:"ellipse",summary:"ellipse <cx,cy> r=<RX>x<RY>|r=<R> c=<colour> [outline|fill] or ellipse <x,y> <W>x<H> c=<colour> [outline|fill]",normalise(e,t){let r=Be(e,t),o=new we(e,["c","r"],["outline","fill"]),n=o.cellOrigin(r),i=o.take("point","a centre x,y (with r=) or a corner x,y (with a size)"),s=o.opts.get("r"),a,c;if(s){let d=/^(\d+)(?:x(\d+))?$/.exec(s.value);if(!d)throw new O(s.line,s.vcol,"r= must be a radius like 5 or 5x3");let f=Number(d[1]),p=Number(d[2]??d[1]);o.done(),a=[i.x-f,i.y-p,i.x+f,i.y+p],c=`${i.x},${i.y} r=${f}x${p}`}else{let d=o.take("size","a size WxH (or r=<radius>)");if(o.done(),d.w<1||d.h<1)throw new O(d.line,d.col,"ellipse: size must be at least 1x1");a=[i.x,i.y,i.x+d.w-1,i.y+d.h-1],c=`${i.x},${i.y} ${d.w}x${d.h}`}let l=ko(o,r),u=o.flag(["outline","fill"],"outline"),m=gi(a[0]+n.dx,a[1]+n.dy,a[2]+n.dx,a[3]+n.dy,u==="fill");return{text:`ellipse${n.text} ${c} c=${l.name} ${u}`,op:So(m,l.index,u==="outline")}}},CF={name:"fill",summary:"fill <x,y> c=<colour> [mode=contiguous|global] [conn=4|8]",normalise(e,t){let r=Be(e,t),o=new we(e,["c","mode","conn"]),n=o.cellOrigin(r),i=o.take("point","a start point x,y");o.done();let s=i.x+n.dx,a=i.y+n.dy;if(!r.wrap&&(s<0||a<0||s>=r.width||a>=r.height))throw new O(i.line,i.col,`fill: ${i.x},${i.y} is outside the ${r.width}x${r.height} canvas`);let c=ko(o,r),l=o.choice("mode",["contiguous","global"],"contiguous"),u=o.choice("conn",["4","8"],"4");return{text:`fill${n.text} ${i.x},${i.y} c=${c.name} mode=${l} conn=${u}`,op:le((m,d)=>{for(let[f,p]of Uy(m,d,[[s,a]]))py(qt(m,d),f,p,c.index,l==="global",u==="8"?8:4)})}}},AF={name:"paint",summary:"paint <x,y> << rows of palette keys ('.' leaves a pixel, ' ' clears it) >>",normalise(e,t){let r=Be(e,t),o=new we(e,[]),n=o.cellOrigin(r),i=o.take("point","a top-left corner x,y"),s=o.take("block","a block: '<<' at the end of the line, rows, then '>>'");o.done();let a=new Map(r.palette.entries.map((d,f)=>[d.key,f])),c=s.rows.map(d=>[...d.text].map((f,p)=>{if(f===".")return null;if(f===" ")return 65535;let h=a.get(f);if(h===void 0)throw new O(d.line,d.col+p,`paint: '${f}' is not a key in palette '${r.palette.name}'`);return h})),l=i.x+n.dx,u=i.y+n.dy,m=[];return c.forEach((d,f)=>d.forEach((p,h)=>{p!==null&&m.push([l+h,u+f,p])})),{text:`paint${n.text} ${i.x},${i.y} <<
133
+ ${Wt(s.rows.map(d=>d.text))}>>`,op:le((d,f)=>yn(d,f,m,!0))}}};function Wt(e){let t=e.some(r=>r.startsWith(" ")||r.endsWith(" ")||r.trim()===">>");return e.map(r=>t?` |${r}|
134
+ `:r===""?`
135
+ `:` ${r}
136
+ `).join("")}var OF={name:"undo",summary:"undo [group=<group>] [by=<author>] (default: the latest group still in effect, or that author's latest)",normalise(e,t){De(e,t);let r=new we(e,["group","by"]);r.done();let o=r.opts.get("group"),n=r.opts.get("by");if(o&&n)throw new O(n.line,n.col,"undo: give group= or by=, not both");let i=t.undoTarget(o?.value??null,n?.value??null),s=o??n;if("error"in i)throw new O(s?.line??e.line,s?.vcol??e.col,i.error);return{text:`undo group=${i.group}`,op:{k:"undo",group:i.group}}}},NF={name:"redo",summary:"redo [group=<undo group>] [by=<author>] (takes back an undo: the latest one still in effect, or that author's)",normalise(e,t){De(e,t);let r=new we(e,["group","by"]);r.done();let o=r.opts.get("group"),n=r.opts.get("by");if(o&&n)throw new O(n.line,n.col,"redo: give group= or by=, not both");let i=t.redoTarget(o?.value??null,n?.value??null),s=o??n;if("error"in i)throw new O(s?.line??e.line,s?.vcol??e.col,i.error);return{text:`redo group=${i.group}`,op:{k:"undo",group:i.group}}}},ok=["pencil","eraser"],MF={name:"stroke",summary:"stroke pencil c=<colour> [pp=on|off] <x,y> [<x,y> ...] or stroke eraser <x,y> [<x,y> ...] (one drag of a tool)",normalise(e,t){let r=Be(e,t),o=new we(e,["c","pp"]),n=o.cellOrigin(r),i=o.take("word",`a tool (${ok.join(", ")})`);if(!ok.includes(i.v))throw new O(i.line,i.col,`stroke: unknown tool '${i.v}' (tools: ${ok.join(", ")})`);let s=[],a=o.rest();if(!a.length)throw new O(i.line,i.col+i.v.length+1,"stroke: expected a point x,y");for(let m of a){if(m.t!=="point")throw new O(m.line,m.col,"stroke: expected a point x,y");s.push(rn(m))}let c=ik(s,n.dx,n.dy);if(i.v==="eraser"){for(let m of["c","pp"]){let d=o.opts.get(m);if(d)throw new O(d.line,d.col,`stroke eraser takes no ${m}=`)}return{text:`stroke${n.text} eraser ${s.map(rr).join(" ")}`,op:So(bc(c,!1),65535)}}let l=ko(o,r),u=o.choice("pp",["on","off"],"on");return{text:`stroke${n.text} pencil c=${l.name} pp=${u} ${s.map(rr).join(" ")}`,op:So(bc(c,u==="on"),l.index)}}},DF={name:"palette",summary:"palette set <entry> [hex=#rrggbb] [role=<role>|none] | palette add [<name>] hex=#rrggbb|role=<role> [key=<k>] | palette lock | palette unlock | palette save as=<name>",normalise(e,t){let r=De(e,t),o=new we(e,["hex","key","as","role"]),n=o.take("word","set, add, lock, unlock or save");if(n.v==="lock"||n.v==="unlock"){o.done();for(let w of o.opts.values())throw new O(w.line,w.col,`palette ${n.v} takes no options`);let y=n.v==="lock";return{text:`palette ${n.v}`,op:le(w=>{w.paletteLocked=y})}}if(n.v==="save"){o.done();let y=o.opts.get("as");if(!y)throw new O(e.line,e.col,"palette save: missing as=<palette name> (the project palette to write)");if(!/^[A-Za-z][A-Za-z0-9_-]*$/.test(y.value))throw new O(y.line,y.vcol,"as= must be a palette name (letters, digits, _ and -)");for(let w of["hex","key","role"]){let v=o.opts.get(w);if(v)throw new O(v.line,v.col,`palette save takes no ${w}=`)}return{text:`palette save as=${y.value}`,op:le(()=>{})}}if(n.v!=="set"&&n.v!=="add")throw new O(n.line,n.col,"palette: expected set, add, lock, unlock or save");if(r.paletteLocked)throw new O(n.line,n.col,`palette '${r.palette.name}' is locked (palette unlock to change it)`);let i=o.opts.get("as");if(i)throw new O(i.line,i.col,`palette ${n.v} takes no as=`);let s=o.opts.get("hex"),a=o.opts.get("role"),c=null;if(s&&(c=di(s.value),!c||!s.value.startsWith("#")))throw new O(s.line,s.vcol,"hex= must be a colour like #a4552e");if(a&&!om(a.value)&&!(n.v==="set"&&a.value==="none"))throw new O(a.line,a.vcol,`role= must be one of ${Ht.join(", ")}${n.v==="set"?" or none":""}`);let l=r.palette;if(n.v==="set"){if(!s&&!a)throw new O(e.line,e.col,"palette set: missing hex=#rrggbb (or role=)");let y=o.peek()?.t==="int"?($=>({...$,v:String($.v)}))(o.take("int","an entry")):o.take("word","an entry name or key");o.done();let w=o.opts.get("key");if(w)throw new O(w.line,w.col,"palette set changes a colour only; keys stay");let v=l.entries.findIndex($=>$.name===y.v||[...y.v].length===1&&$.key===y.v);if(v<0)throw new O(y.line,y.col,`palette '${l.name}' has no entry '${y.v}'`);let S=l.entries.map(($,x)=>{if(x!==v)return $;let k={key:$.key,name:$.name,hex:c??$.hex},P=a?a.value:$.role;return P&&P!=="none"?{...k,role:P}:k});return{text:`palette set ${l.entries[v].name}${c?` hex=${c}`:""}${a?` role=${a.value}`:""}`,op:le($=>{$.palette={...l,entries:S}})}}if(l.entries.length>=256)throw new O(n.line,n.col,`palette '${l.name}' is full (256 entries)`);if(!c&&!a)throw new O(e.line,e.col,"palette add: missing hex=#rrggbb (or role=)");let u=a?a.value:void 0;c??=gc[u];let m=new Set(l.entries.map(y=>y.name)),d=new Set(l.entries.map(y=>y.key)),f=o.peek()?.t==="word"?o.take("word","a name"):null;o.done();let p;if(f){if(p=f.v,!/^[A-Za-z][A-Za-z0-9_-]*$/.test(p)||p==="none")throw new O(f.line,f.col,`'${p}' is not a usable entry name`);if(m.has(p))throw new O(f.line,f.col,`palette '${l.name}' already has an entry '${p}'`)}else{let y=l.entries.length;for(;m.has(`c${y}`);)y++;p=`c${y}`}let h=o.opts.get("key"),g;if(h){if(g=h.value,[...g].length!==1||kS.has(g)||/\s/.test(g)||g==='"'||g===";")throw new O(h.line,h.vcol,'key= must be one character other than . | ; " and space');if(d.has(g))throw new O(h.line,h.vcol,`key '${g}' is taken`)}else g=ws(512).find(y=>!d.has(y)&&y!=='"'&&y!==";");let b=[...l.entries,u?{key:g,name:p,hex:c,role:u}:{key:g,name:p,hex:c}];return{text:`palette add ${p} hex=${c} key=${g}${u?` role=${u}`:""}`,op:le(y=>{y.palette={...l,entries:b}})}}},qF=/^n[1-9]\d*$/,UF={name:"note",summary:'note <x,y> [<W>x<H>] "text" (pins a note to a pixel or a region) or note done <id>',normalise(e,t){let r=De(e,t),o=new we(e,["id"]),n=o.peek();if(n?.t==="word"&&n.v==="done"){o.take("word","done");let f=o.take("word","a note id like n1");if(o.done(),!r.notes.some(p=>p.id===f.v))throw new O(f.line,f.col,`no open note '${f.v}'${r.notes.length?` (open: ${r.notes.map(p=>p.id).join(", ")})`:""}`);return{text:`note done ${f.v}`,op:le(p=>{p.notes=p.notes.filter(h=>h.id!==f.v)})}}let i=o.take("point","a point x,y (or done <id>)"),s=o.peek()?.t==="size"?o.take("size","a size WxH"):null,a=o.take("string","the note text in quotes");o.done();let c=s?.w??1,l=s?.h??1;if(c<1||l<1)throw new O(s.line,s.col,"note: size must be at least 1x1");if(i.x<0||i.y<0||i.x+c>r.width||i.y+l>r.height)throw new O(i.line,i.col,`note: ${i.x},${i.y}${s?` ${c}x${l}`:""} is outside the ${r.width}x${r.height} canvas`);let u=a.v.trim();if(!u)throw new O(a.line,a.col,"note: the text is empty");if(u.length>1e3)throw new O(a.line,a.col,"note: the text is longer than 1000 characters");let m=o.opts.get("id"),d=m?.value??t.noteId();if(!qF.test(d))throw new O(m.line,m.vcol,"id= must look like n1");if(r.notes.some(f=>f.id===d))throw new O(m?.line??e.line,m?.vcol??e.col,`note '${d}' is already open`);return{text:`note ${i.x},${i.y}${s?` ${c}x${l}`:""} ${tn(u)} id=${d}`,op:le(f=>{f.notes=[...f.notes,{id:d,x:i.x,y:i.y,w:c,h:l,text:u}]})}}},LF={name:"fork",summary:"fork <from> <to> [at=<seq>] (starts the tape of asset <to> as a copy of <from> up to command <seq>)",normalise(e,t){let r=De(e,t),o=new we(e,["at"]),n=o.take("word","the asset forked from"),i=o.take("word","the new asset's name");if(o.done(),r.name!==n.v)throw new O(n.line,n.col,`fork: this tape is '${r.name}', not '${n.v}'`);if(!/^[a-z][a-z0-9_-]*$/.test(i.v))throw new O(i.line,i.col,"document names use a-z, 0-9, _ and -, starting with a letter");if(i.v===n.v)throw new O(i.line,i.col,"fork: the new asset needs another name");let s=o.opts.get("at"),a=s?Number(s.value):t.seq-1;if(!Number.isInteger(a)||a!==t.seq-1)throw new O(s?.line??e.line,s?.vcol??e.col,`fork: at=${s?.value} must be the command just before this one (#${t.seq-1})`);return{text:`fork ${n.v} ${i.v} at=${a}`,op:{k:"fork",name:i.v}}}};function rn(e){return[e.x,e.y]}function rr(e){return`${e[0]},${e[1]}`}var Gr=new Map;function Te(e){Gr.set(e.name,e)}for(let e of[IF,PF,jF,EF,TF,CF,AF,MF,DF,UF,LF,OF,NF])Te(e);function _i(e,t){let r=Gr.get(e.name);if(!r)throw new O(e.line,e.col,`unknown command '${e.name}' (commands: ${[...Gr.keys()].join(", ")})`);return r.normalise(e,t)}function Ts(e,t,r=""){if(t.k==="new"){let o=KE(t);return rk(o),o}if(!e)throw new Error("applyOp: no document");if(t.k==="fork")e.name=t.name;else if(t.k==="fn")t.run(e,r),e.views.length&&aT(e),e.family&&rk(e);else throw new Error("applyOp: undo is applied by replay");return e}var sk=(e,t)=>t?sk(t,e%t):e;function Ly(e,t){let r=new Set(e.map(c=>c.name)),o=t.assetNames?.()??[],n=e.map(c=>[c.name,...o.filter(l=>l!==c.name&&!r.has(l)&&t.asset?.(l)?.variantOf===c.name&&t.asset?.(l)?.kind==="tile").sort()]),i=n.reduce((c,l)=>c*l.length/sk(c,l.length),1),s=[];n.forEach((c,l)=>{for(let u of c)s.some(m=>m.name===u)||s.push({name:u,weight:e[l].weight*i/c.length})});let a=s.reduce((c,l)=>sk(c,l.weight),0)||1;return s.map(c=>({name:c.name,weight:c.weight/a}))}function Fy(e){let t=[];for(let r of e.value.split(",")){let o=/^([a-z][a-z0-9_-]*)(?::(\d+))?$/.exec(r);if(!o)throw new O(e.line,e.vcol,`mix= is a list of one-cell tiles with weights: mix=<tile>:<weight>,<tile>:<weight>,... ('${r}' is not <tile> or <tile>:<weight>)`);let n=o[2]===void 0?1:Number(o[2]);if(n<1||n>1e3)throw new O(e.line,e.vcol,`mix=: ${o[1]}'s weight must be 1..1000`);if(t.some(i=>i.name===o[1]))throw new O(e.line,e.vcol,`mix=: ${o[1]} is named twice`);t.push({name:o[1],weight:n})}if(t.length>64)throw new O(e.line,e.vcol,"mix=: at most 64 tiles");return t}function LC(e,t){let r=e.opts.get("seed");if(!r)return t.newSeed();if(!/^\d+$/.test(r.value)||Number(r.value)<1||Number(r.value)>2147483647)throw new O(r.line,r.vcol,"seed= must be a whole number 1..2147483647");return Number(r.value)}var FF=/^[A-Za-z][A-Za-z0-9_-]*$/,JC=new Set(["add","set","remove","rename","move","merge"]),VF=e=>e?"on":"off";function FC(e,t){let r=e.layers.findIndex(o=>o.name===t.v);if(r<0)throw new O(t.line,t.col,`no layer '${t.v}' (layers: ${e.layers.map(o=>o.name).join(", ")})`);return r}function VC(e,t){if(!FF.test(t.v)||JC.has(t.v))throw new O(t.line,t.col,`'${t.v}' is not a usable layer name`);if(e.layers.some(r=>r.name===t.v))throw new O(t.line,t.col,`there is already a layer '${t.v}'`)}function ZC(e,t){let r=new Map(t.map((o,n)=>[o,n]));e.layers=t.map(o=>e.layers[o]),e.cels=t.map(o=>e.cels[o]),xr(e,o=>r.get(o)??0,o=>o)}function HC(e,t,r){let o=e.opts.get("above"),n=e.opts.get("below");if(o&&n)throw new O(n.line,n.col,"give above= or below=, not both");let i=o??n,s=i?.value??r,a=t.layers.findIndex(c=>c.name===s);if(a<0)throw new O(i?.line??e.cmd.line,i?.vcol??e.cmd.col,`no layer '${s}'`);return n?{at:a,text:`below=${s}`}:{at:a+1,text:`above=${s}`}}function ZF(e){let t={};for(let r of["hidden","locked","reference"])e.opts.has(r)&&(t[r]=e.choice(r,["on","off"],"off")==="on");return t}var HF={name:"layer",summary:"layer <name> | layer add <name> [above=|below=<layer>] [reference] | (maps) layer add <name> terrain=<family> [outside=on|off] [walkable=on|off] [border=same|terrain|not] [mix=<tile>:<weight>,... [variants=spread|named] [seed=]] | tiles | objects [shadow=darker|<colour>|off] [shadowdir=<dir>] | overlay=<overlay> on=<layer>|<layer>:out|all | layer set <name> [hidden=] [locked=] [reference=] [walkable=] [border=] [mix=\u2026|none] [shadow=darker|<colour>|off [shadowdir=]] | layer rename <name> <new> | layer move <name> above=|below=<layer> | layer merge <name> | layer remove <name> (border: past the map's edge a cell counts as its own (same, the default), as terrain, or not; mix: the terrain's inside cells drawn as a seeded scatter of one-cell tiles by weight)",normalise(e,t){let r=De(e,t),o=e.args[0],n=!!r.map&&o?.t==="word"&&o.v==="add",i=new we(e,["above","below","hidden","locked","reference","terrain","outside","walkable","overlay","on","border","mix","seed","variants","shadow","shadowdir"],n?["reference","tiles","objects"]:["reference"]),s=i.take("word","a layer name, or add, set, rename, move, merge or remove"),a=(u=[])=>{for(let m of i.opts.values())if(!u.includes(m.key))throw new O(m.line,m.col,`layer ${s.v} takes no ${m.key}=`);if(!u.includes("flag")&&i.flags.length)throw new O(i.flags[0].line,i.flags[0].col,`layer ${s.v}: unexpected '${i.flags[0].v}'`)};if(!JC.has(s.v)){i.done(),a();let u=FC(r,s);return{text:`layer ${s.v}`,op:le((m,d)=>Tt(m,d,{layer:u}))}}if(s.v==="add"){let u=i.take("word","a name for the new layer");if(i.done(),VC(r,u),r.map&&(u.v==="tiles"||u.v==="objects"))throw new O(u.line,u.col,`'${u.v}' says what a map layer holds; name the layer something else (layer add props objects)`);let m,d="";r.map?(m=BF(i,r,t),d=WF(m),a(["above","below","flag","terrain","outside","walkable","overlay","on","border","mix","seed","variants","shadow","shadowdir"])):a(["above","below","flag"]);let f=HC(i,r,r.layers[Me(r,t.by).layer].name),p=!r.map&&i.flags.length>0;return{text:`layer add ${u.v}${d} ${f.text}${p?" reference":""}`,op:le(h=>{let g=h.width*h.height,b=h.layers.map((y,w)=>w);h.layers.push(Dr(u.v,{reference:p,...m?{map:m}:{}})),h.cels.push(Array.from({length:h.frameCount},()=>new Uint16Array(g).fill(65535))),b.splice(f.at,0,h.layers.length-1),ZC(h,b)})}}let c=i.take("word","a layer name"),l=FC(r,c);if(s.v==="set"){if(i.done(),i.opts.get("shadow")||i.opts.get("shadowdir")){let h=i.opts.get("shadow")??i.opts.get("shadowdir");if(r.layers[l].map?.kind!=="objects")throw new O(h.line,h.col,`${h.key}= goes with an objects layer`);a(["shadow","shadowdir"]);let g=r.layers[l].map.shadow,b=GC(i,r,t,g);return{text:`layer set ${c.v} ${b?`shadow=${b.c} shadowdir=${b.dir}`:"shadow=off"}`,op:le(y=>{y.layers[l].map=b?{kind:"objects",shadow:b}:{kind:"objects"}})}}let u=i.opts.get("walkable"),m=i.opts.get("border"),d=i.opts.get("mix");if(u||m||d){let h=r.layers[l].map,g=u??m??d;if(h?.kind!=="terrain")throw new O(g.line,g.col,`${g.key}= goes with a terrain layer`);a(["walkable","border","mix","seed","variants"]);let b={},y=[];if(u){let v=i.choice("walkable",["on","off"],"off")==="on";b.walkable=v,y.push(`walkable=${v?"on":"off"}`)}if(m){let v=KC(i);b.border=v,y.push(`border=${v??"same"}`)}let w=!1;if(d)if(d.value==="none"){w=!0,y.push("mix=none");for(let v of["seed","variants"])if(i.opts.get(v))throw new O(i.opts.get(v).line,i.opts.get(v).col,`${v}= goes with a mix`)}else{let v=YC(i,t);b.mix=v.mix,b.seed=v.seed,y.push(v.text)}else for(let v of["seed","variants"])if(i.opts.get(v))throw new O(i.opts.get(v).line,i.opts.get(v).col,`${v}= goes with mix=`);return{text:`layer set ${c.v} ${y.join(" ")}`,op:le(v=>{let S={...v.layers[l].map,...b};S.walkable||delete S.walkable,S.border||delete S.border,w&&(delete S.mix,delete S.seed),v.layers[l].map=S})}}a(["hidden","locked","reference"]);let f=ZF(i);if(!Object.keys(f).length)throw new O(e.line,e.col,"layer set: give hidden=, locked= or reference= (on or off)");let p=["hidden","locked","reference"].flatMap(h=>f[h]===void 0?[]:[`${h}=${VF(f[h])}`]);return{text:`layer set ${c.v} ${p.join(" ")}`,op:le(h=>{Object.assign(h.layers[l],f)})}}if(s.v==="rename"){let u=i.take("word","the new name");return i.done(),a(),VC(r,u),{text:`layer rename ${c.v} ${u.v}`,op:le(m=>{m.layers[l].name=u.v})}}if(s.v==="move"){if(i.done(),a(["above","below"]),!i.opts.has("above")&&!i.opts.has("below"))throw new O(e.line,e.col,"layer move: give above=<layer> or below=<layer>");let u=HC(i,r,""),m=i.opts.get("above")??i.opts.get("below");if(m.value===c.v)throw new O(m.line,m.vcol,"layer move: a layer cannot move relative to itself");return{text:`layer move ${c.v} ${u.text}`,op:le(d=>{let f=d.layers.map((p,h)=>h);f.splice(u.at,0,l),f.splice(u.at<=l?l+1:l,1),ZC(d,f)})}}if(s.v==="merge"){if(i.done(),a(),r.map)throw new O(s.line,s.col,"layer merge: a map's layers hold different things; move or remove them instead");if(l===0)throw new O(c.line,c.col,`layer merge: '${c.v}' is the bottom layer; there is nothing below to merge into`);let u=r.layers[l-1];if(u.locked)throw new O(c.line,c.col,`layer merge: '${u.name}' below is locked`);return{text:`layer merge ${c.v}`,op:le(m=>{m.cels[l-1]=m.cels[l-1].map(d=>d.slice());for(let d=0;d<m.frameCount;d++){let f=m.cels[l][d],p=m.cels[l-1][d];for(let h=0;h<f.length;h++)f[h]!==65535&&(p[h]=f[h])}BC(m,l)})}}if(i.done(),a(),r.layers.length===1)throw new O(c.line,c.col,`layer remove: '${c.v}' is the only layer`);return{text:`layer remove ${c.v}`,op:le(u=>BC(u,l))}}};function GC(e,t,r,o){let n=e.opts.get("shadow"),i=r.defaults?.shadow,s=n?n.value:o?.c??i?.c;if(!s||s==="off"){if(e.opts.get("shadowdir")&&s==="off")throw new O(e.opts.get("shadowdir").line,e.opts.get("shadowdir").col,"shadowdir= goes with a shadow");return}let a=s==="darker"?s:zt(s,t.palette,n?.line??e.cmd.line,n?.vcol??e.cmd.col).name,c=e.choice("shadowdir",wc,o?.dir??(i?.dir&&wc.includes(i.dir)?i.dir:hy(r.defaults?.light)));return{c:a,dir:c}}function KC(e){let t=e.choice("border",["same","terrain","not"],"same");return t==="same"?void 0:t}function YC(e,t){let r=e.opts.get("mix");if(!r)return null;let o=e.opts.get("variants");if(o&&o.value!=="spread"&&o.value!=="named")throw new O(o.line,o.vcol,"variants= is spread (a tile's weight shared with its texture variants) or named (only the tiles the mix names)");let n=Fy(r),i=o?.value==="named"?n:Ly(n,t);for(let a of i){let c=t.asset?.(a.name);if(c&&c.kind!=="tile")throw new O(r.line,r.vcol,`mix= takes one-cell tiles; '${a.name}' is a ${c.kind}`)}let s=LC(e,t);return{mix:i,seed:s,text:`mix=${i.map(a=>`${a.name}:${a.weight}`).join(",")} variants=named seed=${s}`}}function BF(e,t,r){let o=e.opts.get("terrain"),n=e.opts.get("overlay"),i=[o?"terrain":"",n?"overlay":"",...e.flags.filter(c=>c.v==="tiles"||c.v==="objects").map(c=>c.v)].filter(Boolean);if(i.length!==1)throw new O(e.cmd.line,e.cmd.col,"layer add: a map layer holds one thing: terrain=<family>, tiles, objects or overlay=<overlay> on=<where>");let s=e.flags.find(c=>c.v==="reference");if(s)throw new O(s.line,s.col,"layer add: a map has no reference layers");let a=(c,l)=>{if(!/^[a-z][a-z0-9_-]*$/.test(c))throw new O(l.line,l.vcol,`'${c}' is not an asset name`);return c};for(let c of["shadow","shadowdir"]){let l=e.opts.get(c);if(l&&!e.flags.some(u=>u.v==="objects"))throw new O(l.line,l.col,`${c}= goes with objects`)}for(let c of["outside","walkable","on","border","mix"]){let l=e.opts.get(c);if(l&&!(c!=="on"&&o||c==="on"&&n))throw new O(l.line,l.col,`${c}= goes with ${c!=="on"?"terrain=":"overlay="}`)}for(let c of["seed","variants"])if(e.opts.get(c)&&!e.opts.get("mix"))throw new O(e.opts.get(c).line,e.opts.get(c).col,`${c}= goes with mix=`);if(o){let c=e.choice("walkable",["on","off"],"off")==="on",l=KC(e),u=YC(e,r);return{kind:"terrain",family:a(o.value,o),outside:e.choice("outside",["on","off"],"off")==="on",...c?{walkable:c}:{},...l?{border:l}:{},...u?{mix:u.mix,seed:u.seed}:{}}}if(n){let c=e.opts.get("on"),l=c?.value??"all",[u,m]=l.split(":");if(l!=="all"&&(!t.layers.some(d=>d.name===u&&d.map?.kind==="terrain")||m!==void 0&&m!=="out"))throw new O(c.line,c.vcol,`on= must be all, a terrain layer, or a terrain layer:out (terrain layers: ${t.layers.filter(d=>d.map?.kind==="terrain").map(d=>d.name).join(", ")||"none"})`);return{kind:"overlay",overlay:a(n.value,n),on:l}}if(i[0]==="objects"){let c=GC(e,t,r);return c?{kind:"objects",shadow:c}:{kind:"objects"}}return{kind:"tiles"}}function WF(e){return e.kind==="terrain"?` terrain=${e.family} outside=${e.outside?"on":"off"}${e.walkable?" walkable=on":""}${e.border?` border=${e.border}`:""}`+(e.mix?` mix=${e.mix.map(t=>`${t.name}:${t.weight}`).join(",")} variants=named seed=${e.seed}`:""):e.kind==="overlay"?` overlay=${e.overlay} on=${e.on}`:e.kind==="objects"&&e.shadow?` objects shadow=${e.shadow.c} shadowdir=${e.shadow.dir}`:` ${e.kind}`}function BC(e,t){e.layers.splice(t,1),e.cels.splice(t,1),xr(e,r=>r>t?r-1:r===t?Math.max(0,t-1):r,r=>r)}var JF=new Set(["add","remove","move","set"]);function ak(e,t,r,o,n=e.frameCount){if(!t||t.t!=="int")throw new O(t?.line??r.line,t?.col??r.col,`frame: expected ${o}`);if(t.v<1||t.v>n)throw new O(t.line,t.col,`frame ${t.v} does not exist (frames 1..${e.frameCount})`);return t.v}function ck(e,t,r=e.frameCount){if(!/^\d+$/.test(t.value)||Number(t.value)<1||Number(t.value)>r)throw new O(t.line,t.vcol,`${t.key}= must be a frame 1..${r}`);return Number(t.value)}function Rm(e,t,r){let o=()=>new O(t?.line??r.line,t?.col??r.col,`${r.name}: expected frames as <n>, <a>-<b> or all (frames 1..${e.frameCount})`);if(!t)throw o();let n,i;if(t.t==="int")n=i=t.v;else if(t.t==="word"&&t.v==="all")n=1,i=e.frameCount;else if(t.t==="word"&&/^\d+-\d+$/.test(t.v))[n,i]=t.v.split("-").map(Number);else throw o();if(n<1||i>e.frameCount||n>i)throw new O(t.line,t.col,`${r.name}: frames ${n}-${i} are not within 1..${e.frameCount}`);return{from:n,to:i,text:n===i?String(n):`${n}-${i}`}}function WC(e){if(!/^\d+$/.test(e.value)||Number(e.value)<1||Number(e.value)>65535)throw new O(e.line,e.vcol,"ticks= must be a whole number 1..65535");return Number(e.value)}function Vy(e,t,r,o){let n=fi(e,t);if(n?.mirror)throw new O(r.line,r.col,`${o}: frame ${t+1} is in view ${n.name}, a live mirror of ${n.mirror} (change ${n.mirror}, or view ${n.name} mirror=off)`)}var GF={name:"frame",summary:"frame <n> | frame add [<n>] [copy=<m>|link=<m>|empty] [ticks=<t>] | frame set <n>|<a>-<b>|all ticks=<t> | frame remove <n> | frame move <n> to=<m> (frames count from 1; ticks are game ticks)",normalise(e,t){let r=De(e,t),o=new we(e,["copy","to","link","ticks"],["empty"]),n=o.peek(),i=(m,d=[])=>{for(let f of o.opts.values())if(!d.includes(f.key))throw new O(f.line,f.col,`${m} takes no ${f.key}=`)};if(n?.t==="int"){let m=ak(r,o.take("int","a frame number"),e,"a frame number");return o.done(),i("frame <n>"),{text:`frame ${m}`,op:le((d,f)=>Tt(d,f,{frame:m-1}))}}let s=o.take("word","a frame number, or add, set, remove or move");if(!JF.has(s.v))throw new O(s.line,s.col,"frame: expected a frame number, add, set, remove or move");if(s.v==="set"){let m=Rm(r,o.rest()[0],e);if(i("frame set",["ticks"]),o.flags.length)throw new O(o.flags[0].line,o.flags[0].col,`frame set: unexpected '${o.flags[0].v}'`);let d=o.opts.get("ticks");if(!d)throw new O(e.line,e.col,"frame set: give ticks=<t>");let f=WC(d),p=h=>!fi(r,h)?.mirror;return m.from===m.to&&Vy(r,m.from-1,e,"frame set"),{text:`frame set ${m.text} ticks=${f}`,op:le(h=>{for(let g=m.from-1;g<m.to;g++)p(g)&&(h.ticks[g]=f)})}}if(s.v==="add"){let m=o.peek()?.t==="int"?ak(r,o.take("int","a position"),e,"a position",r.frameCount+1):r.frameCount+1;o.done(),i("frame add",["copy","link","ticks"]);let d=o.opts.get("copy"),f=o.opts.get("link"),p=o.flags.length>0;if([d,f,p||void 0].filter(Boolean).length>1)throw new O(e.line,e.col,"frame add: give one of copy=, link= or empty");let h=f?ck(r,f):d?ck(r,d):Me(r,t.by).frame+1;f&&Vy(r,h-1,f,"frame add link=");let g=o.opts.get("ticks"),b=g?WC(g):null,y=f?`link=${h}`:p?"empty":`copy=${h}`;return{text:`frame add ${m} ${y}${b!==null?` ticks=${b}`:""}`,op:le(w=>{let v=w.width*w.height,S=_=>p?new Uint16Array(v).fill(65535):f?w.cels[_][h-1]:w.cels[_][h-1].slice();sm(w,m-1,1,S,[b??w.ticks[h-1]])})}}let a=ak(r,o.take("int","a frame number"),e,"a frame number");if(s.v==="remove"){if(o.done(),i("frame remove"),r.frameCount===1)throw new O(e.line,e.col,"frame remove: frame 1 is the only frame");return Vy(r,a-1,e,"frame remove"),{text:`frame remove ${a}`,op:le(m=>PS(m,a-1))}}o.done(),i("frame move",["to"]);let c=o.opts.get("to");if(!c)throw new O(e.line,e.col,"frame move: missing to=<n>");let l=ck(r,c),u=jS(a-1,l-1);for(let m of r.views){let d=Array.from({length:m.to-m.from+1},(p,h)=>u(m.from+h)),f=Math.min(...d);if(Math.max(...d)-f!==d.length-1)throw new O(c.line,c.vcol,`frame move: view ${m.name} would no longer be one run of frames`)}return fi(r,a-1)?.mirror&&Vy(r,a-1,e,"frame move"),{text:`frame move ${a} to=${l}`,op:le(m=>sT(m,a-1,l-1))}}};Te(HF);Te(GF);var XC=["add","sub","and"];function lk(e,t){let r={width:e.width,height:e.height,wrap:e.wrap,pixels:new Uint16Array(0)},o=new Uint8Array(e.width*e.height);for(let[n,i]of t){let s=Rt(r,n,i);s>=0&&(o[s]=1)}return o}function KF(e,t,r){let o;if(r==="replace")o=t;else{o=new Uint8Array(t.length);for(let n=0;n<t.length;n++){let i=e?e[n]:0;o[n]=r==="add"?i|t[n]:r==="sub"?i&(t[n]^1):i&t[n]}}return o.some(n=>n)?o:null}function YF(e,t,r,o,n,i){let s={width:e.width,height:e.height,wrap:e.wrap,pixels:t},a=new Uint8Array(t.length),c=Rt(s,r,o),l=t[c];if(n){for(let d=0;d<t.length;d++)t[d]===l&&(a[d]=1);return a}let u=i===4?[[1,0],[-1,0],[0,1],[0,-1]]:[[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1]],m=[c];for(a[c]=1;m.length;){let d=m.pop(),f=d%e.width,p=(d-f)/e.width;for(let[h,g]of u){let b=Rt(s,f+h,p+g);b>=0&&!a[b]&&t[b]===l&&(a[b]=1,m.push(b))}}return a}var QC="rect, ellipse, lasso, wand, colour, layer, all, none or invert",XF={name:"select",summary:"select rect <x,y> <W>x<H> | ellipse <cx,cy> r=<RX>x<RY> | ellipse <x,y> <W>x<H> | lasso <x,y> <x,y> <x,y>... | wand <x,y> [mode=contiguous|global] [conn=4|8] | colour c=<colour> | layer [<name>] | all | none | invert [add|sub|and]",normalise(e,t){let r=De(e,t),o=new we(e,["r","mode","conn","c"],XC),n=o.cellOrigin(r),i=o.take("word",QC),s=o.flag(XC,"replace"),a=s==="replace"?"":` ${s}`,c=m=>{for(let d of o.opts.values())if(!m.includes(d.key))throw new O(d.line,d.col,`select ${i.v} takes no ${d.key}=`)},l=(m,d)=>({text:`select${n.text} ${m}${a}`,op:le((f,p)=>Tt(f,p,{sel:KF(Me(f,p).sel,d(f,p),s)}))}),u=m=>[m[0]+n.dx,m[1]+n.dy];switch(i.v){case"all":case"none":case"invert":{if(o.done(),c([]),s!=="replace")throw new O(e.line,e.col,`select ${i.v} takes no ${s}`);return i.v==="none"?{text:`select${n.text} none`,op:le((m,d)=>Tt(m,d,{sel:null}))}:i.v==="all"?{text:`select${n.text} all`,op:le((m,d)=>Tt(m,d,{sel:new Uint8Array(m.width*m.height).fill(1)}))}:{text:`select${n.text} invert`,op:le((m,d)=>{let f=Me(m,d).sel,p=new Uint8Array(m.width*m.height);for(let h=0;h<p.length;h++)p[h]=f?f[h]^1:1;Tt(m,d,{sel:p.some(h=>h)?p:null})})}}case"rect":{let m=o.take("point","a corner x,y"),d=o.take("size","a size WxH");if(o.done(),c([]),d.w<1||d.h<1)throw new O(d.line,d.col,"select: size must be at least 1x1");let f=lk(r,vo(m.x+n.dx,m.y+n.dy,d.w,d.h,!0));return l(`rect ${m.x},${m.y} ${d.w}x${d.h}`,()=>f)}case"ellipse":{let m=o.take("point","a centre x,y (with r=) or a corner x,y (with a size)"),d=o.opts.get("r");c(["r"]);let f,p;if(d){let g=/^(\d+)(?:x(\d+))?$/.exec(d.value);if(!g)throw new O(d.line,d.vcol,"r= must be a radius like 5 or 5x3");let b=Number(g[1]),y=Number(g[2]??g[1]);o.done(),f=[m.x-b,m.y-y,m.x+b,m.y+y],p=`${m.x},${m.y} r=${b}x${y}`}else{let g=o.take("size","a size WxH (or r=<radius>)");if(o.done(),g.w<1||g.h<1)throw new O(g.line,g.col,"select: size must be at least 1x1");f=[m.x,m.y,m.x+g.w-1,m.y+g.h-1],p=`${m.x},${m.y} ${g.w}x${g.h}`}let h=lk(r,gi(f[0]+n.dx,f[1]+n.dy,f[2]+n.dx,f[3]+n.dy,!0));return l(`ellipse ${p}`,()=>h)}case"lasso":{let m=[];for(let f of o.rest()){if(f.t!=="point")throw new O(f.line,f.col,"select lasso: expected a point x,y");m.push(rn(f))}if(c([]),m.length<3)throw new O(e.line,e.col,"select lasso: give at least 3 points");let d=lk(r,fy(m.map(u),!0,!1));return l(`lasso ${m.map(rr).join(" ")}`,()=>d)}case"wand":{let m=o.take("point","a point x,y");o.done(),c(["mode","conn"]);let d=o.choice("mode",["contiguous","global"],"contiguous"),f=o.choice("conn",["4","8"],"4"),p=m.x+n.dx,h=m.y+n.dy;if(!r.wrap&&(p<0||h<0||p>=r.width||h>=r.height))throw new O(m.line,m.col,`select wand: ${m.x},${m.y} is outside the canvas`);return l(`wand ${m.x},${m.y} mode=${d} conn=${f}`,(g,b)=>YF(g,qt(g,b).pixels,p,h,d==="global",f==="8"?8:4))}case"colour":case"color":{o.done(),c(["c"]);let m=o.opts.get("c");if(!m)throw new O(e.line,e.col,"select colour: missing c=<colour>");let d=zt(m.value,r.palette,m.line,m.vcol);return l(`colour c=${d.name}`,(f,p)=>{let h=qt(f,p).pixels;return Uint8Array.from(h,g=>g===d.index?1:0)})}case"layer":{let m=o.peek()?.t==="word"?o.take("word","a layer name"):null;o.done(),c([]);let d=m?r.layers.findIndex(p=>p.name===m.v):Me(r,t.by).layer;if(d<0)throw new O(m.line,m.col,`no layer '${m.v}'`);let f=r.layers[d].name;return l(`layer ${f}`,(p,h)=>{let g=p.layers.findIndex(y=>y.name===f),b=p.cels[g][Me(p,h).frame];return Uint8Array.from(b,y=>y===65535?0:1)})}default:throw new O(i.line,i.col,`select: '${i.v}' is not a selection (${QC})`)}}},QF={name:"deselect",summary:"deselect (the same as select none)",normalise(e,t){return De(e,t),new we(e,[]).done(),{text:"deselect",op:le((r,o)=>Tt(r,o,{sel:null}))}}},eV={name:"clear",summary:"clear (clears the selected pixels of your layer, or all of it, to transparent)",normalise(e,t){return Be(e,t),new we(e,[]).done(),{text:"clear",op:le((r,o)=>{let n=qt(r,o);for(let i=0;i<n.pixels.length;i++)(!n.mask||n.mask[i])&&(n.pixels[i]=65535)})}}};Te(XF);Te(QF);Te(eV);var eA=(e,t)=>(e%t+t)%t;function Zy(e,t){let r=Me(e,t).sel;if(!r)return{mask:null,x:0,y:0,w:e.width,h:e.height};let o=e.width,n=e.height,i=-1,s=-1;for(let a=0;a<r.length;a++){if(!r[a])continue;let c=a%e.width,l=(a-c)/e.width;o=Math.min(o,c),i=Math.max(i,c),n=Math.min(n,l),s=Math.max(s,l)}return{mask:r,x:o,y:n,w:i-o+1,h:s-n+1}}function mk(e,t,r){let o=qt(e,t,!1),n=Zy(e,t),i=[];for(let a=0;a<o.pixels.length;a++){if(n.mask&&!n.mask[a])continue;let c=a%e.width,l=(a-c)/e.width;i.push([...r(c,l),o.pixels[a]]),o.pixels[a]=65535}let s=n.mask?new Uint8Array(n.mask.length):null;for(let[a,c,l]of i){let u=Rt(o,a,c);u<0||(o.pixels[u]=l,s&&(s[u]=1))}n.mask&&Tt(e,t,{sel:s.some(a=>a)?s:null})}function dk(e,t,r,o){let n=e.flags.find(s=>s.v==="sel"),i=e.flags.find(s=>s.v==="wrap");if(i&&!o)throw new O(i.line,i.col,`${e.cmd.name}: unexpected 'wrap'`);if(n&&!Me(t,r).sel)throw new O(n.line,n.col,`${e.cmd.name} sel: nothing is selected`);return{sel:!!n,wrap:!!i}}var fk=e=>`${e.sel?" sel":""}${e.wrap?" wrap":""}`,tV={name:"shift",summary:"shift <dx,dy> [sel] [wrap] (moves the selected pixels, or your whole layer; wrap: around the selection's box or the canvas)",normalise(e,t){let r=Be(e,t),o=new we(e,[],["sel","wrap"]),n=o.take("point","an offset dx,dy");o.done();let i=dk(o,r,t.by,!0);return{text:`shift ${n.x},${n.y}${fk(i)}`,op:le((s,a)=>{let c=Zy(s,a);mk(s,a,i.wrap?(l,u)=>[c.x+eA(l-c.x+n.x,c.w),c.y+eA(u-c.y+n.y,c.h)]:(l,u)=>[l+n.x,u+n.y])})}}},nV={name:"flip",summary:"flip h|v [sel] (mirrors the selected pixels within their box, or your whole layer)",normalise(e,t){let r=Be(e,t),o=new we(e,[],["sel"]),n=o.take("word","h or v");if(n.v!=="h"&&n.v!=="v")throw new O(n.line,n.col,"flip: expected h (left-right) or v (top-bottom)");o.done();let i=dk(o,r,t.by,!1);return{text:`flip ${n.v}${fk(i)}`,op:le((s,a)=>{let c=Zy(s,a);mk(s,a,n.v==="h"?(l,u)=>[2*c.x+c.w-1-l,u]:(l,u)=>[l,2*c.y+c.h-1-u])})}}},rV={name:"rotate",summary:"rotate 90|180|270 [sel] (clockwise, about the middle of the selection's box or the canvas)",normalise(e,t){let r=Be(e,t),o=new we(e,[],["sel"]),n=o.take("int","90, 180 or 270");if(![90,180,270].includes(n.v))throw new O(n.line,n.col,"rotate: the angle must be 90, 180 or 270 (clockwise)");o.done();let i=dk(o,r,t.by,!1);return{text:`rotate ${n.v}${fk(i)}`,op:le((s,a)=>{let c=Zy(s,a),l=c.x+Math.floor((c.w-c.h)/2),u=c.y+Math.floor((c.h-c.w)/2);mk(s,a,(m,d)=>{let f=m-c.x,p=d-c.y;return n.v===180?[c.x+c.w-1-f,c.y+c.h-1-p]:n.v===90?[l+c.h-1-p,u+f]:[l+p,u+c.w-1-f]})})}}};function tA(e){let t=/^(-?\d+)(\.5|\.0)?$/.exec(e.value);if(!t)throw new O(e.line,e.vcol,`${e.key}= must be a pixel position like 12 or 11.5`);return 2*Number(t[1])+(t[2]===".5"?e.value.startsWith("-")?-1:1:0)}var uk=e=>e%2===0?String(e/2):`${(e-1)/2}.5`,oV={name:"mirror",summary:"mirror [x=<a>] [y=<b>] live (later strokes are mirrored) | mirror off | mirror x=<a> from=left|right or mirror y=<b> from=top|bottom (copies one side over the other once)",normalise(e,t){let r=De(e,t),o=new we(e,["x","y","from"],["live","off"]);o.done();let n=o.flags.find(g=>g.v==="off"),i=o.flags.find(g=>g.v==="live"),s=o.opts.get("x"),a=o.opts.get("y"),c=o.opts.get("from");if(n){if(i||s||a||c)throw new O(n.line,n.col,"mirror off takes nothing else");return{text:"mirror off",op:le((g,b)=>Tt(g,b,{mirror:null}))}}if(i&&c)throw new O(c.line,c.col,"mirror: give live or from=, not both");let l=s?tA(s):null,u=a?tA(a):null;if(i)return l===null&&u===null&&(l=r.width-1),{text:`mirror ${[l!==null?`x=${uk(l)}`:"",u!==null?`y=${uk(u)}`:""].filter(Boolean).join(" ")} live`,op:le((b,y)=>Tt(b,y,{mirror:{x2:l,y2:u}}))};if(Be(e,t),s&&a)throw new O(a.line,a.col,"mirror from=: give one axis, x= or y=");l===null&&u===null&&(l=r.width-1);let m=l!==null,d=c?c.value:m?"left":"top",f=m?["left","right"]:["top","bottom"];if(!f.includes(d))throw new O(c.line,c.vcol,`from= must be ${f.join(" or ")} for a ${m?"vertical (x=)":"horizontal (y=)"} axis`);let p=m?l:u,h=d===f[0];return{text:`mirror ${m?"x":"y"}=${uk(p)} from=${d}`,op:le((g,b)=>{let y=qt(g,b),w=y.pixels.slice();for(let v=0;v<w.length;v++){let S=v%g.width,_=(v-S)/g.width,$=m?S:_;if(h?2*$>=p:2*$<=p)continue;let x=Rt(y,m?p-S:S,m?_:p-_);x>=0&&(!y.mask||y.mask[x])&&(y.pixels[x]=w[v])}})}}};Te(tV);Te(nV);Te(rV);Te(oV);var iV={name:"curve",summary:"curve <x,y> <x,y> <x,y> [<x,y>] c=<colour> [pp=on|off] (quadratic with 3 points, cubic with 4; the middle points pull the curve)",normalise(e,t){let r=Be(e,t),o=new we(e,["c","pp"]),n=o.cellOrigin(r),i=[];for(let l of o.rest()){if(l.t!=="point")throw new O(l.line,l.col,"curve: expected a point x,y");i.push(rn(l))}if(i.length<3||i.length>4)throw new O(e.line,e.col,"curve: give 3 points (quadratic) or 4 (cubic): start, control point(s), end");let s=ko(o,r),a=o.choice("pp",["on","off"],"on"),c=i.map(([l,u])=>[l+n.dx,u+n.dy]);return{text:`curve${n.text} ${i.map(rr).join(" ")} c=${s.name} pp=${a}`,op:So(MT(c,a==="on"),s.index)}}},sV={name:"polygon",summary:"polygon <x,y> <x,y> <x,y> [...] c=<colour> [outline|fill] (closed; fill takes pixels whose centre is inside)",normalise(e,t){let r=Be(e,t),o=new we(e,["c"],["outline","fill"]),n=o.cellOrigin(r),i=[];for(let l of o.rest()){if(l.t!=="point")throw new O(l.line,l.col,"polygon: expected a point x,y");i.push(rn(l))}if(i.length<3)throw new O(e.line,e.col,"polygon: give at least 3 points");let s=ko(o,r),a=o.flag(["outline","fill"],"outline"),c=i.map(([l,u])=>[l+n.dx,u+n.dy]);return{text:`polygon${n.text} ${i.map(rr).join(" ")} c=${s.name} ${a}`,op:So(fy(c,a==="fill",!0),s.index,a==="outline")}}};function Hy(e){if(e===1)return[[0]];let t=Hy(e/2),r=[];for(let o=0;o<e;o++){r.push([]);for(let n=0;n<e;n++){let i=[0,2,3,1][(o>=e/2?2:0)+(n>=e/2?1:0)];r[o].push(4*t[o%(e/2)][n%(e/2)]+i)}}return r}var Wy={checker:[[0,1],[1,0]],bayer2:Hy(2),bayer4:Hy(4),bayer8:Hy(8),hlines:[[0],[1]],vlines:[[0,1]]},By=Object.keys(Wy);function pk(e,t,r,o,n){let i=Math.max(...e.flat())+1,s=e[(r%e.length+e.length)%e.length][(t%e[0].length+e[0].length)%e[0].length];return 2*o*i>(2*s+1)*n}function rA(e,t){let r=e.take("point","a corner x,y"),o=e.take("size","a size WxH");if(o.w<1||o.h<1)throw new O(o.line,o.col,`${t}: size must be at least 1x1`);return{x:r.x,y:r.y,w:o.w,h:o.h,text:`${r.x},${r.y} ${o.w}x${o.h}`}}var aV={name:"dither",summary:`dither <x,y> <W>x<H> a=<colour> b=<colour> [pattern=${By.join("|")}] [level=<0..1>] (b covers the share 'level' of the box)`,normalise(e,t){let r=Be(e,t),o=new we(e,["a","b","pattern","level"]),n=o.cellOrigin(r),i=rA(o,"dither");o.done();let s=p=>{let h=o.opts.get(p);if(!h)throw new O(e.line,e.col,`dither: missing ${p}=<colour>`);return zt(h.value,r.palette,h.line,h.vcol)},a=s("a"),c=s("b"),l=o.choice("pattern",By,"bayer4"),u=o.opts.get("level"),m=u?Ss(u):{num:1,den:2,text:"0.5"},d=Wy[l],f=vo(i.x+n.dx,i.y+n.dy,i.w,i.h,!0).map(([p,h])=>[p,h,pk(d,p,h,m.num,m.den)?c.index:a.index]);return{text:`dither${n.text} ${i.text} a=${a.name} b=${c.name} pattern=${l} level=${m.text}`,op:le((p,h)=>yn(p,h,f,!1))}}},nA=["down","up","right","left","radial"],cV={name:"gradient",summary:`gradient <x,y> <W>x<H> ramp=<ramp|a,b,c> [dir=${nA.join("|")}] [steps=<n>] [pattern=none|${By.join("|")}] (banded, or dithered between bands)`,normalise(e,t){let r=Be(e,t),o=new we(e,["ramp","dir","steps","pattern"]),n=o.cellOrigin(r),i=rA(o,"gradient");o.done();let s=o.opts.get("ramp");if(!s)throw new O(e.line,e.col,"gradient: missing ramp=<ramp> (a palette ramp, or entries a,b,c)");let a=bi(s,r.palette),c=o.choice("dir",nA,"down"),l=o.opts.get("steps"),u=l?Ct(l,2,a.idx.length):a.idx.length;if(u<2)throw new O(s.line,s.vcol,"gradient: the ramp needs at least 2 colours");let m=o.choice("pattern",["none",...By],"none"),d=Array.from({length:u},(S,_)=>a.idx[WS(2*_*(a.idx.length-1)+(u-1),2*(u-1))]),f=m==="none"?null:Wy[m],p=i.x+n.dx,h=i.y+n.dy,g=2*p+i.w-1,b=2*h+i.h-1,y=(i.w-1)**2+(i.h-1)**2,w=(S,_)=>{switch(c){case"down":return[_-h,i.h-1];case"up":return[h+i.h-1-_,i.h-1];case"right":return[S-p,i.w-1];case"left":return[p+i.w-1-S,i.w-1];default:return[pm(4*((2*S-g)**2+(2*_-b)**2)),pm(4*y)||1]}},v=vo(p,h,i.w,i.h,!0).map(([S,_])=>{let[$,x]=w(S,_);if(x<=0)return[S,_,d[0]];let k=$*(u-1),P=Math.min(u-1,WS(k,x)),I=k-P*x;if(P===u-1)return[S,_,d[P]];let E=f?pk(f,S,_,I,x):2*I>=x;return[S,_,d[E?P+1:P]]});return{text:`gradient${n.text} ${i.text} ramp=${a.text} dir=${c} steps=${u} pattern=${m}`,op:le((S,_)=>yn(S,_,v,!1))}}},lV={name:"ramp",summary:"ramp <name> = <entry> <entry> ... (defines or replaces a ramp of this document's palette, darkest first)",normalise(e,t){let r=De(e,t),o=new we(e,[]),n=o.take("word","a ramp name");if(!/^[A-Za-z][A-Za-z0-9_-]*$/.test(n.v))throw new O(n.line,n.col,`'${n.v}' is not a usable ramp name`);let i=o.take("word","'='");if(i.v!=="=")throw new O(i.line,i.col,"ramp: expected '=' after the name");let s=[];for(let a of o.rest()){let c=a.t==="word"?a.v:a.t==="int"?String(a.v):null;if(c===null)throw new O(a.line,a.col,"ramp: expected an entry name or key");if(s.push(zt(c,r.palette,a.line,a.col).name),s.at(-1)==="none")throw new O(a.line,a.col,"ramp: 'none' cannot be in a ramp")}if(s.length<2)throw new O(e.line,e.col,"ramp: give at least 2 entries, darkest first");if(r.paletteLocked)throw new O(e.line,e.col,`palette '${r.palette.name}' is locked (palette unlock to change its ramps)`);return{text:`ramp ${n.v} = ${s.join(" ")}`,op:le(a=>{a.palette={...a.palette,ramps:{...a.palette.ramps,[n.v]:s}}})}}};Te(iV);Te(sV);Te(aV);Te(cV);Te(lV);var Im=[[0,-1],[1,0],[0,1],[-1,0]],uV=[...Im,[1,-1],[1,1],[-1,1],[-1,-1]];function oA(e,t,r,o){let n=Rt(e,r,o);return n<0?65535:t[n]}var mV={name:"outline",summary:"outline c=<colour> [mode=outer|inner] [corners=on|off] [from=<layer>] (around the shapes on your layer, or on another layer)",normalise(e,t){let r=Be(e,t),o=new we(e,["c","mode","corners","from"]);o.done();let n=t.defaults?.outline?.find(d=>r.palette.entries.some(f=>f.name===d)),i=o.opts.get("c")??(n?kc("c",n,e):void 0);if(!i)throw new O(e.line,e.col,"outline: missing c=<colour> (or give the style guide an outline colour)");let s=zt(i.value,r.palette,i.line,i.vcol),a=o.choice("mode",["outer","inner"],"outer"),c=o.choice("corners",["on","off"],"off"),l=o.opts.get("from"),u=l?r.layers.findIndex(d=>d.name===l.value):-1;if(l&&u<0)throw new O(l.line,l.vcol,`no layer '${l.value}'`);if(l&&a==="inner")throw new O(l.line,l.col,"outline: from= goes with mode=outer (an inner outline is drawn on the shape itself)");let m=c==="on"?uV:Im;return{text:`outline c=${s.name} mode=${a} corners=${c}${l?` from=${l.value}`:""}`,op:le((d,f)=>{let p=qt(d,f),h=u>=0?d.cels[u][Me(d,f).frame]:p.pixels.slice(),g=p.pixels.slice();for(let b=0;b<h.length;b++){if(p.mask&&!p.mask[b])continue;let y=b%d.width,w=(b-y)/d.width,v=h[b]!==65535;if(a==="outer"?v||g[b]!==65535:!v)continue;m.some(([_,$])=>oA(p,h,y+_,w+$)!==65535==(a==="outer"))&&(p.pixels[b]=s.index)}})}}},hk={n:[0,-1],ne:[1,-1],e:[1,0],se:[1,1],s:[0,1],sw:[-1,1],w:[-1,0],nw:[-1,-1]},dV={name:"shade",summary:"shade light=n|ne|e|se|s|sw|w|nw [ramp=<ramp>|all] [edge=<n>] (each shape's lit edge a ramp step lighter, its far edge a step darker)",normalise(e,t){let r=Be(e,t),o=new we(e,["light","ramp","edge"]);o.done();let n=t.defaults?.light&&t.defaults.light in hk?t.defaults.light:void 0;if(!o.opts.has("light")&&!n)throw new O(e.line,e.col,"shade: missing light=<direction> (n, ne, e, se, s, sw, w, nw), or a light in the style guide");let i=o.choice("light",Object.keys(hk),n??"nw"),s=o.opts.get("ramp"),a=s&&s.value!=="all"?bi(s,r.palette):null,c=o.opts.get("edge"),l=c?Ct(c,1,8):1,[u,m]=hk[i];return{text:`shade light=${i} ramp=${a?a.text:"all"} edge=${l}`,op:le((d,f)=>{let p=qt(d,f),h=p.pixels.slice(),g=new Map,b=y=>{if(!g.has(y)){let w=a?a.idx.includes(y)?{ramp:a.idx,at:a.idx.indexOf(y)}:null:hm(d.palette,y)[0]??null;g.set(y,w)}return g.get(y)};for(let y=0;y<h.length;y++){let w=h[y];if(w===65535||p.mask&&!p.mask[y])continue;let v=b(w);if(!v)continue;let S=y%d.width,_=(y-S)/d.width,$=(E,N)=>{for(let T=1;T<=l;T++){let q=oA(p,h,S+E*T,_+N*T);if(q===65535||!v.ramp.includes(q))return!0}return!1},x=(E,N)=>E!==0&&$(E,0)||N!==0&&$(0,N),k=x(u,m),P=x(-u,-m);if(k===P)continue;let I=v.at+(k?1:-1);I>=0&&I<v.ramp.length&&(p.pixels[y]=v.ramp[I])}})}}},fV={name:"clean",summary:"clean orphans [size=<n>] [keep=none|texture] (pixels or clusters of up to n that share no 4-neighbour's colour take the colour around them)",normalise(e,t){let r=Be(e,t),o=new we(e,["size","keep"]),n=o.take("word","orphans");if(n.v!=="orphans")throw new O(n.line,n.col,"clean: expected orphans");o.done();let i=o.opts.get("size"),s=i?Ct(i,1,64):1,a=o.choice("keep",["none","texture"],"none");return{text:`clean orphans size=${s} keep=${a}`,op:le((c,l)=>pV(c,qt(c,l),s,a==="texture"))}}};function pV(e,t,r,o){let n=t.pixels.slice(),i=new Uint8Array(n.length);for(let s=0;s<n.length;s++){if(i[s])continue;let a=n[s],c=[s];i[s]=1;for(let f=0;f<c.length&&c.length<=r;f++){let p=c[f],h=p%e.width,g=(p-h)/e.width;for(let[b,y]of Im){let w=Rt(t,h+b,g+y);w>=0&&!i[w]&&n[w]===a&&(i[w]=1,c.push(w))}}if(c.length>r){for(let f=0;f<c.length;f++){let p=c[f],h=p%e.width,g=(p-h)/e.width;for(let[b,y]of Im){let w=Rt(t,h+b,g+y);w>=0&&!i[w]&&n[w]===a&&(i[w]=1,c.push(w))}}continue}let l=new Set(c),u=new Map;for(let f of c){let p=f%e.width,h=(f-p)/e.width;for(let[g,b]of Im){let y=Rt(t,p+g,h+b);y<0||l.has(y)||u.set(n[y],(u.get(n[y])??0)+1)}}let m=-1,d=0;for(let[f,p]of[...u.entries()].sort((h,g)=>h[0]-g[0]))p>d&&(m=f,d=p);if(!(m<0||m===a)&&!(o&&a!==65535&&m!==65535&&hm(e.palette,a).some(f=>Math.abs(f.ramp.indexOf(m)-f.at)===1&&f.ramp.includes(m))))for(let f of c)(!t.mask||t.mask[f])&&(t.pixels[f]=m)}}var hV={name:"shadow",summary:"shadow [<x,y> <W>x<H>] [c=<colour>] [dir=n|ne|e|se|s|sw|w|nw] (an ellipse on the ground under the art, away from the light; the style guide's colour and direction)",normalise(e,t){let r=Be(e,t),o=new we(e,["c","dir"]),n=o.cellOrigin(r),i=null;if(o.peek()?.t==="point"){let m=o.take("point","a corner x,y"),d=o.take("size","a size WxH");i={x:m.x+n.dx,y:m.y+n.dy,w:d.w,h:d.h}}o.done();let s=t.defaults?.shadow,a=o.choice("dir",wc,s?.dir&&wc.includes(s.dir)?s.dir:hy(t.defaults?.light)),c=o.opts.get("c")??(s?.c&&s.c!=="darker"?kc("c",s.c,e):void 0);if(!c)throw new O(e.line,e.col,`shadow: give c=<colour>${s?.c==="darker"?" (the style guide's shadow is darker, a step down the ramps of the ground under it: maps draw that; a sprite has no ground)":" (or a shadow colour in the style guide: style.shadow.c)"}`);let l=zt(c.value,r.palette,c.line,c.vcol);if(!i){let m=Me(r,t.by).frame;if(i=gy(be(r,m),r.width,r.height,a),!i)throw new O(e.line,e.col,"shadow: nothing is drawn yet to cast one (or give its box x,y WxH)")}let u=i;return{text:`shadow ${u.x},${u.y} ${u.w}x${u.h} c=${l.name} dir=${a}`,op:le((m,d)=>{let f=qt(m,d),p=be(m,Me(m,d).frame);for(let[h,g]of yy(u)){if(h<0||g<0||h>=m.width||g>=m.height)continue;let b=g*m.width+h;p[b]!==65535||f.mask&&!f.mask[b]||(f.pixels[b]=l.index)}})}}};Te(mV);Te(hV);Te(dV);Te(fV);var or=(e,t)=>(e%t+t)%t;function Cs(e,t,r){let o=e.cellOrigin(t);if(e.peek()?.t!=="point")return e.cell?{x:o.dx,y:o.dy,w:t.cellW,h:t.cellH,text:`${o.text} 0,0 ${t.cellW}x${t.cellH}`}:{x:0,y:0,w:t.width,h:t.height,text:` 0,0 ${t.width}x${t.height}`};let n=e.take("point","a corner x,y"),i=e.take("size","a size WxH");if(i.w<1||i.h<1)throw new O(i.line,i.col,`${r}: size must be at least 1x1`);return{x:n.x+o.dx,y:n.y+o.dy,w:i.w,h:i.h,text:`${o.text} ${n.x},${n.y} ${i.w}x${i.h}`}}function Rc(e,t){let r=e.opts.get("seed");return r?Ct(r,0,2147483647):t.newSeed()}function Pm(e,t){return e.choice("wrap",["on","off"],t.wrap?"on":"off")==="on"}function jm(e,t){let r=t.reduce((n,i)=>n+i,0),o=e.nextInt(r);for(let n=0;n<t.length;n++){if(o<t[n])return n;o-=t[n]}return t.length-1}function gk(e,t,r){let o=e.opts.get("ramp");if(!o)throw new O(r.line,r.col,`${r.name}: missing ramp=<ramp> (a palette ramp, or entries a,b,c)`);let n=bi(o,t.palette),i=e.opts.get("weights"),s=i?$y(i,n.idx.length):n.idx.map(()=>1);return{ramp:n,weights:s}}function yk(e,t){return(r,o)=>t?[e.x+or(r,e.w),e.y+or(o,e.h)]:r<0||o<0||r>=e.w||o>=e.h?null:[e.x+r,e.y+o]}var gV={name:"noise",summary:"noise [<x,y> <W>x<H>] ramp=<ramp> [weights=<w,w,..>] [cluster=<a>..<b>] [density=<0..1>] [base=<entry>|keep] [wrap=on|off] [seed=<n>] (clustered specks on a ramp)",normalise(e,t){let r=Be(e,t),o=new we(e,["ramp","weights","cluster","density","base","wrap","seed"]),n=Cs(o,r,"noise");o.done();let{ramp:i,weights:s}=gk(o,r,e),a=o.opts.get("cluster"),c=Math.max(1,Math.floor(r.cellW/24)),[l,u]=a?$c(a,1,64):[c,3*c],m=o.opts.get("density"),d=m?Ss(m):{num:15,den:100,text:"0.15"},f=o.opts.get("base"),p=i.idx[s.indexOf(Math.max(...s))],h=r.palette.entries[p].name;if(f&&f.value==="keep")p=null,h="keep";else if(f){let k=zt(f.value,r.palette,f.line,f.vcol);p=k.index,h=k.name}let g=Pm(o,r),b=Rc(o,t),y=i.idx.map((k,P)=>k===p?0:s[P]);if(y.every(k=>k===0))throw new O(e.line,e.col,"noise: the ramp has no colour other than the base to scatter (check weights=)");let w=[];if(p!==null)for(let k=0;k<n.h;k++)for(let P=0;P<n.w;P++)w.push([n.x+P,n.y+k,p]);let v=new dt(b,1),S=yk(n,g),_=Math.floor((d.num*n.w*n.h*2+d.den)/(2*d.den)),$=new Uint8Array(n.w*n.h),x=0;for(let k=0;x<_&&k<_*4+16;k++){let P=v.range(l,u),I=i.idx[jm(v,y)],E=[[v.nextInt(n.w),v.nextInt(n.h)]],N=(q,Z)=>`${or(q,n.w)},${or(Z,n.h)}`,T=new Set([N(...E[0])]);for(let q=0;E.length<P&&q<P*8;q++){let[Z,D]=E[v.nextInt(E.length)],[V,F]=[[1,0],[-1,0],[0,1],[0,-1]][v.nextInt(4)],M=Z+V,L=D+F;!S(M,L)||T.has(N(M,L))||(T.add(N(M,L)),E.push([M,L]))}for(let[q,Z]of E){let D=S(q,Z);if(!D)continue;w.push([D[0],D[1],I]);let V=(D[1]-n.y)*n.w+(D[0]-n.x);$[V]||($[V]=1,x++)}}return{text:`noise${n.text} ramp=${i.text} weights=${s.join(",")} cluster=${l}..${u} density=${d.text} base=${h} wrap=${g?"on":"off"} seed=${b}`,op:le((k,P)=>yn(k,P,w,!1))}}},yV={name:"scatter",summary:"scatter [<x,y> <W>x<H>] stamp=<name>[,<name>..]|c=<colour> count=<n> [minDist=<n>] [flip=on|off] [wrap=on|off] [seed=<n>] (places stamps by their middle, at least minDist apart)",normalise(e,t){let r=Be(e,t),o=new we(e,["stamp","c","count","minDist","flip","wrap","seed"]),n=Cs(o,r,"scatter");o.done();let i=o.opts.get("stamp"),s=o.opts.get("c");if(!!i==!!s)throw new O(e.line,e.col,"scatter: give stamp=<name> or c=<colour> (one of them)");let a,c;if(i){let S=i.value.split(",");c=S.map(_=>{let $=r.stamps[_];if(!$)throw new O(i.line,i.vcol,`no stamp '${_}' (stamps: ${Object.keys(r.stamps).join(", ")||"none; make one with stamp save"})`);return $}),a=`stamp=${S.join(",")}`}else{let S=zt(s.value,r.palette,s.line,s.vcol);c=[{w:1,h:1,px:Uint16Array.of(S.index)}],a=`c=${S.name}`}let l=o.opts.get("count");if(!l)throw new O(e.line,e.col,"scatter: missing count=<n>");let u=Ct(l,1,1e4),m=o.opts.get("minDist"),d=m?Ct(m,0,4096):0,f=o.choice("flip",["on","off"],"off")==="on",p=Pm(o,r),h=Rc(o,t),g=new dt(h,2),b=[],y=(S,_)=>{let $=Math.abs(S[0]-_[0]),x=Math.abs(S[1]-_[1]);return p&&($=Math.min($,n.w-$),x=Math.min(x,n.h-x)),$*$+x*x};for(let S=0;b.length<u&&S<u*30;S++){let _=[g.nextInt(n.w),g.nextInt(n.h)];b.some($=>y(_,$)<d*d)||b.push(_)}let w=yk(n,p),v=[];for(let[S,_]of b){let $=c[g.nextInt(c.length)],x=f&&g.nextInt(2)===1;for(let k=0;k<$.h;k++)for(let P=0;P<$.w;P++){let I=$.px[k*$.w+(x?$.w-1-P:P)];if(I===65535)continue;let E=w(S-($.w>>1)+P,_-($.h>>1)+k);E&&v.push([E[0],E[1],I])}}return{text:`scatter${n.text} ${a} count=${u} minDist=${d} flip=${f?"on":"off"} wrap=${p?"on":"off"} seed=${h}`,op:le((S,_)=>yn(S,_,v,!1))}}};function iA(e,t){let r=e.opts.get("gap");if(!r)return{index:null,text:"none"};if(r.value==="none")return{index:null,text:"none"};let o=zt(r.value,t.palette,r.line,r.vcol);return{index:o.index,text:o.name}}var bV={name:"voronoi",summary:"voronoi [<x,y> <W>x<H>] cells=<n> ramp=<ramp> [weights=<w,..>] [gap=<colour>|none] [relax=<n>] [wrap=on|off] [seed=<n>] (stones: cells of the nearest point, each a ramp colour, 1-px gaps)",normalise(e,t){let r=Be(e,t),o=new we(e,["cells","ramp","weights","gap","relax","wrap","seed"]),n=Cs(o,r,"voronoi");o.done();let{ramp:i,weights:s}=gk(o,r,e),a=o.opts.get("cells");if(!a)throw new O(e.line,e.col,"voronoi: missing cells=<n>");let c=Ct(a,1,Math.max(1,Math.min(4096,n.w*n.h))),l=iA(o,r),u=o.opts.get("relax"),m=u?Ct(u,0,8):1,d=Pm(o,r),f=Rc(o,t),p=new dt(f,3),h=pm(Math.floor(n.w*n.h*36/(100*c))),g=(x,k,P)=>{let I=k-x;if(!d)return I;let E=or(I,P);return E*2>P?E-P:E},b=(x,k,P)=>{let I=g(P[0],x,n.w),E=g(P[1],k,n.h);return I*I+E*E},y=[];for(let x=0;y.length<c&&x<c*50;x++){let k=[p.nextInt(n.w),p.nextInt(n.h)];x<c*40&&y.some(P=>b(k[0],k[1],P)<h*h)||y.push(k)}let w=new Int32Array(n.w*n.h),v=()=>{for(let x=0;x<n.h;x++)for(let k=0;k<n.w;k++){let P=0,I=1/0;y.forEach((E,N)=>{let T=b(k,x,E);T<I&&(I=T,P=N)}),w[x*n.w+k]=P}};v();for(let x=0;x<m;x++){let k=new Array(y.length).fill(0),P=new Array(y.length).fill(0),I=new Array(y.length).fill(0);for(let E=0;E<n.h;E++)for(let N=0;N<n.w;N++){let T=w[E*n.w+N];k[T]+=g(y[T][0],N,n.w),P[T]+=g(y[T][1],E,n.h),I[T]++}y=y.map((E,N)=>{if(!I[N])return E;let T=E[0]+Math.floor((2*k[N]+I[N])/(2*I[N])),q=E[1]+Math.floor((2*P[N]+I[N])/(2*I[N]));return d?[or(T,n.w),or(q,n.h)]:[Math.max(0,Math.min(n.w-1,T)),Math.max(0,Math.min(n.h-1,q))]}),v()}let S=y.map(()=>i.idx[jm(p,s)]),_=yk(n,d),$=[];for(let x=0;x<n.h;x++)for(let k=0;k<n.w;k++){let P=w[x*n.w+k],I=!1;if(l.index!==null)for(let[E,N]of[[1,0],[-1,0],[0,1],[0,-1]]){let T=_(k+E,x+N);if(T&&w[(T[1]-n.y)*n.w+(T[0]-n.x)]<P){I=!0;break}}$.push([n.x+k,n.y+x,I?l.index:S[P]])}return{text:`voronoi${n.text} cells=${c} ramp=${i.text} weights=${s.join(",")} gap=${l.text} relax=${m} wrap=${d?"on":"off"} seed=${f}`,op:le((x,k)=>yn(x,k,$,!1))}}},wV={name:"bricks",summary:"bricks [<x,y> <W>x<H>] size=<W>x<H> ramp=<ramp> [weights=<w,..>] [gap=<colour>|none] [offset=<n>] [seed=<n>] (courses of bricks with 1-px joints; every other course shifted)",normalise(e,t){let r=Be(e,t),o=new we(e,["size","ramp","weights","gap","offset","seed"]),n=Cs(o,r,"bricks");o.done();let i=o.opts.get("size"),s=i?/^(\d+)x(\d+)$/.exec(i.value):null;if(!i||!s||Number(s[1])<2||Number(s[2])<2)throw new O(i?.line??e.line,i?.vcol??e.col,"bricks: size= must be a brick size like 8x4 (joints included), at least 2x2");let a=Number(s[1]),c=Number(s[2]),{ramp:l,weights:u}=gk(o,r,e),m=iA(o,r),d=o.opts.get("offset"),f=d?Ct(d,0,a-1):a>>1,p=Rc(o,t),h=new dt(p,4),g=Math.ceil(n.h/c),b=Math.ceil(n.w/a)+1,y=Array.from({length:g*b},()=>l.idx[jm(h,u)]),w=[];for(let v=0;v<n.h;v++)for(let S=0;S<n.w;S++){let _=Math.floor(v/c),$=S+(_%2?f:0),x=n.w%a===0?Math.floor($/a)%(n.w/a):Math.floor($/a),k=v%c===c-1||$%a===a-1;k&&m.index===null||w.push([n.x+S,n.y+v,k?m.index:y[_*b+x]])}return{text:`bricks${n.text} size=${a}x${c} ramp=${l.text} weights=${u.join(",")} gap=${m.text} offset=${f} seed=${p}`,op:le((v,S)=>yn(v,S,w,!1))}}};Te(gV);Te(yV);Te(bV);Te(wV);function aA(e,t){let r=t.defaults?.light&&t.defaults.light in In?t.defaults.light:"nw",o=e.choice("light",Object.keys(In),r);return{name:o,dir:In[o]}}function cA(e,t,r,o){let n=e.opts.get("ramp");if(!n)throw new O(r.line,r.col,`${r.name}: missing ramp=<ramp> (a palette ramp, darkest first, or entries a,b,c)`);let i=bi(n,t.palette);if(i.idx.length<o)throw new O(n.line,n.vcol,`${r.name}: ramp= needs at least ${o} colours (darkest first), not ${i.idx.length}`);return i}function lA(e,t,r,o){let n=e.opts.get(r);if(!n)return{index:o,text:o===null?"none":t.palette.entries[o].name};if(n.value==="none")return{index:null,text:"none"};let i=zt(n.value,t.palette,n.line,n.vcol);return{index:i.index,text:i.name}}var uA=e=>Math.max(8,Math.min(e.cellW,e.cellH));function mA(e,t,r,o,n){let i=e.opts.get("gap"),s=i?Ct(i,0,16):1,a=Pm(e,t),c=Rc(e,r),l=e.opts.get("edges");if(l&&!a)throw new O(l.line,l.col,"edges= goes with wrap=on (with wrap=off nothing crosses the box's edge)");let u=l?Ct(l,0,2147483647):c;return{box:o,wrap:a,gap:s,density:n,seed:c,edges:u}}var dA=e=>`gap=${e.gap} wrap=${e.wrap?"on":"off"}${e.wrap?` edges=${e.edges}`:""} seed=${e.seed}`,Jy=class{n;len;wmax;unit;C;S1;S2;Y;mis;total=0;constructor(t,r){this.n=t,this.len=r,this.unit=Math.max(1,Math.floor(t/24)),this.wmax=Math.max(1,Math.min(6*this.unit,t>>2)),this.C=new Float64Array(t*this.wmax*r),this.S1=new Float64Array(t*this.wmax),this.S2=new Float64Array(t*this.wmax),this.Y=new Float64Array(t),this.mis=new Float64Array(t)}recolour(t,r,o,n){let i=this.n,s=n((t-1+i)%i),a=n((t+1)%i);this.mis[(t-1+i)%i]+=(s!==o?1:0)-(s!==r?1:0),this.mis[t]+=(a!==o?1:0)-(a!==r?1:0)}jump(){let{n:t,len:r}=this;if(t<4)return 0;let o=0;for(let i=0;i<t-1;i++)o+=this.mis[i]/r;o/=t-1;let n=0;for(let i=0;i<t-1;i++)n+=(this.mis[i]/r-o)**2;return(this.mis[t-1]/r-o)/(Math.sqrt(n/(t-1))+.02)}add(t,r,o,n){let{n:i,wmax:s,len:a}=this;this.total+=o,this.Y[t]+=n;for(let c=1;c<=s;c++)for(let l=0;l<c;l++){let u=(t-l+i)%i*s+c-1,m=this.C[u*a+r];this.C[u*a+r]=m+o,this.S1[u]+=o,this.S2[u]+=2*m*o+o*o}}bands(){let{n:t,wmax:r,len:o,unit:n}=this,i=this.total/(t*o),s=0,a=0;for(let c=0;c<t*r;c++){let l=c%r+1,u=this.S1[c]/(o*l),m=Math.max(0,this.S2[c]/(o*l*l)-u*u),f=Math.abs(u-i)*Math.sqrt(l/n)/Math.max(3,3*Math.sqrt(m)*Math.sqrt(l/n/o));a+=f*f,f>s&&(s=f)}return[s,a]}line(){let{n:t,len:r}=this;if(t<4)return 0;let o=0;for(let s=1;s<t-1;s++)o+=this.Y[s]/r;o/=t-2;let n=0;for(let s=1;s<t-1;s++)n+=(this.Y[s]/r-o)**2;let i=Math.sqrt(n/(t-2));return Math.abs((this.Y[0]+this.Y[t-1])/(2*r)-o)/(i+2)}};function fA(e,t,r,o,n,i){let{box:s,wrap:a,gap:c}=e,l=s.w,u=s.h,m=Math.floor((e.density.num*l*u*2+e.density.den)/(2*e.density.den)),d=(T,q)=>a?or(q,u)*l+or(T,l):T<0||q<0||T>=l||q>=u?-1:q*l+T,f=(T,q)=>T[0]+q.w>l||T[1]+q.h>u,p=(T,q,Z)=>{let D={baseL:T,baseY:q,baseC:Z,occ:new Uint8Array(l*u),lum:T.slice(),luma:q.slice(),cls:new Int32Array(l*u).fill(-2),rows:new Jy(u,l),cols:new Jy(l,u),covered:0};for(let V=0;V<u;V++)for(let F=0;F<l;F++)D.rows.add(V,F,T[V*l+F],q[V*l+F]),D.cols.add(F,V,T[V*l+F],q[V*l+F]);for(let V=0;V<l*u;V++)h(D,V,Z[V]);return D},h=(T,q,Z)=>{let D=q%l,V=Math.floor(q/l),F=T.cls[q];F!==Z&&(T.rows.recolour(V,F,Z,M=>T.cls[M*l+D]),T.cols.recolour(D,F,Z,M=>T.cls[V*l+M]),T.cls[q]=Z)},g=(T,q,Z,D)=>{for(let[V,F,M]of Z.px){let L=d(q[0]+V,q[1]+F);if(L<0)continue;let A=D?r[M]:T.baseL[L],z=D?o[M]:T.baseY[L],R=A-T.lum[L],C=z-T.luma[L];T.lum[L]=A,T.luma[L]=z;let U=L%l,W=Math.floor(L/l);T.rows.add(W,U,R,C),T.cols.add(U,W,R,C),T.occ[L]=D?1:0,T.covered+=D?1:-1,h(T,L,D?M:T.baseC[L])}},b=(T,q,Z)=>{for(let[D,V]of Z.px)for(let F=-c;F<=c;F++)for(let M=-c;M<=c;M++){let L=d(q[0]+D+M,q[1]+V+F);if(L>=0&&T.occ[L])return!1}return!0},y=T=>{let q=T.rows.bands(),Z=T.cols.bands(),D=a?Math.max(T.rows.line(),T.cols.line(),T.rows.jump(),T.cols.jump())/.8:0;return[Math.max(q[0],Z[0],D),q[1]+Z[1]+D*D]},w=(T,q,Z)=>{g(T,q,Z,!0);let D=y(T);return g(T,q,Z,!1),D},v=(T,q)=>T[0]<q[0]-1e-9||T[0]<=q[0]+1e-9&&T[1]<q[1]-1e-9,S=(T,q,Z,D=0)=>{let V=new dt(T,i+(q?0:16)+32*D),F=(R,C)=>{if(a){let U=[or(R[0],l),or(R[1],u)];return!q&&f(U,C)?null:U}return R[0]<0||R[1]<0||R[0]+C.w>l||R[1]+C.h>u?null:R},M=R=>F(a?[V.nextInt(l),V.nextInt(u)]:[V.nextInt(l-R.w+1),V.nextInt(u-R.h+1)],R),L=[];for(let R=0;Z.covered<m&&R<64+3*m;R++){let C=n(V);if(C.w>l||C.h>u)continue;let U=null,W=1/0;for(let X=0;X<8;X++){let Y=M(C);if(!Y||!b(Z,Y,C))continue;let fe=w(Z,Y,C)[1];fe<W&&(W=fe,U=Y)}U&&(g(Z,U,C,!0),L.push({at:U,s:C}))}let A=.8,z=()=>{for(let R=0;R<8;R++){let C=!1;for(let U of L){if(y(Z)[0]<=A)return;g(Z,U.at,U.s,!1);let W=U.at,X=w(Z,U.at,U.s),Y=[];for(let ye=-2;ye<=2;ye++)for(let H=-2;H<=2;H++)(H||ye)&&Y.push(F([U.at[0]+H,U.at[1]+ye],U.s));for(let ye=0;ye<8;ye++)Y.push(M(U.s));for(let ye of Y){if(!ye||!b(Z,ye,U.s))continue;let H=w(Z,ye,U.s);v(H,X)&&(X=H,W=ye)}let fe=U.s;for(let ye of U.s.alts??[]){if(ye===U.s)continue;let H=w(Z,W,ye);v(H,X)&&(X=H,fe=ye)}(W!==U.at||fe!==U.s)&&(C=!0),U.at=W,U.s=fe,g(Z,U.at,U.s,!0)}if(!C)break}};z();for(let R=0;R<8&&Z.covered<m+(m>>2)&&y(Z)[0]>A;R++){let C=n(V),U=y(Z),W=null,X=U,Y=l*u<=1024;for(let fe=0;fe<(Y?l*u:64);fe++){let ye=Y?F([fe%l,Math.floor(fe/l)],C):M(C);if(!ye||!b(Z,ye,C))continue;let H=w(Z,ye,C);v(H,X)&&(X=H,W=ye)}W&&(g(Z,W,C,!0),L.push({at:W,s:C}),z())}return{placed:L,cost:y(Z)}},_=l*u<=400?4:l*u<=1024?3:2,$=(T,q,Z)=>{let D=S(T,q,Z());for(let V=1;V<_&&D.cost[0]>.8;V++){let F=S(T,q,Z(),V);v(F.cost,D.cost)&&(D=F)}return D.placed},x;if(!a)x=$(e.seed,!0,()=>p(t.l,t.y,t.c));else{let T=t.l.reduce((D,V)=>D+V,0)/(l*u),q=t.y.reduce((D,V)=>D+V,0)/(l*u),Z=$(e.edges,!0,()=>p(new Float64Array(l*u).fill(T),new Float64Array(l*u).fill(q),new Int32Array(l*u).fill(-1))).filter(({at:D,s:V})=>f(D,V));x=[...Z,...$(e.seed,!1,()=>{let D=p(t.l,t.y,t.c);for(let{at:V,s:F}of Z)g(D,V,F,!0);return D})]}let k=[],P=new Map;for(let{at:T,s:q}of x)for(let[Z,D,V]of q.px){let F=d(T[0]+Z,T[1]+D);F>=0&&P.set(F,V)}let I=new Map;for(let T of t.c)I.set(T,(I.get(T)??0)+1);let E=[...I].sort((T,q)=>q[1]-T[1]||T[0]-q[0])[0]?.[0]??-1,N=new Set;for(let[T,q]of P){if(q===E||E<0)continue;let Z=T%l,D=Math.floor(T/l);for(let V=-1;V<=1;V++)for(let F=-1;F<=1;F++){let M=d(Z+F,D+V);M>=0&&!P.has(M)&&t.c[M]===q&&N.add(M)}}for(let T of[...N].sort((q,Z)=>q-Z))k.push([s.x+T%l,s.y+Math.floor(T/l),E]);for(let[T,q]of P)k.push([s.x+T%l,s.y+Math.floor(T/l),q]);return k}function pA(e,t,r){let o=e.palette.entries.map(l=>Vr(l.hex)),n=e.palette.entries.map(l=>$o(l.hex)),i=be(e,Me(e,t).frame),s=new Float64Array(r.w*r.h),a=new Float64Array(r.w*r.h),c=new Int32Array(r.w*r.h);for(let l=0;l<r.h;l++)for(let u=0;u<r.w;u++){let m=r.x+u,d=r.y+l,f=m<e.width&&d<e.height?i[d*e.width+m]:65535;s[l*r.w+u]=f===65535?50:o[f],a[l*r.w+u]=f===65535?128:n[f],c[l*r.w+u]=f===65535?-1:f}return{under:{l:s,y:a,c},L:o,Y:n}}function vV(e,t){let r=new Uint8Array(e*t);for(let o=0;o<t;o++)for(let n=0;n<e;n++){let i=(2*n+1-e)*t,s=(2*o+1-t)*e;i*i+s*s<=e*e*t*t&&(r[o*e+n]=1)}return r}var sA=[[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1],[0,-1],[1,-1]];function $V(e,t,r,o){let n=vV(e,t),[i,s]=r,a=(w,v)=>w>=0&&v>=0&&w<e&&v<t&&n[v*e+w]===1,c=new Array(e*t).fill(-1),l=new Array(e*t).fill(0);for(let w=0;w<t;w++)for(let v=0;v<e;v++){if(!n[w*e+v])continue;let S=0,_=0;for(let[$,x]of sA)a(v+$,w+x)||(S+=$,_+=x);l[w*e+v]=S*i+_*s,c[w*e+v]=l[w*e+v]<0?o.dark:o.body}let u=(w,v)=>a(w,v)&&c[v*e+w]===o.dark;for(let w=0;w<t;w++)for(let v=0;v<e;v++){if(!u(v,w))continue;let S=[-1,1].filter($=>u(v+$,w)),_=[-1,1].filter($=>u(v,w+$));S.length===1&&_.length===1&&!a(v+S[0],w+_[0])&&(c[w*e+v]=o.body)}let m=e>=5&&t>=4,d=(w,v)=>a(w,v)&&c[v*e+w]===o.body,f=[];for(let w=0;w<t;w++)for(let v=0;v<e;v++){let S=w*e+v;c[S]===o.body&&(m&&sA.some(([_,$])=>!a(v+_,w+$))||f.push({k:S,s:4*(i*(2*v+1-e)+s*(2*w+1-t))-Math.abs(s*(2*v+1-e))-Math.abs(i*(2*w+1-t))}))}f.sort((w,v)=>v.s-w.s||w.k-v.k);let p=[[1,0],[-1,0],[0,1],[0,-1]],h=w=>{let v=w.map(_=>c[_]);for(let _ of w)c[_]=o.lit;let S=w.length>1||w.every(_=>{let $=_%e,x=Math.floor(_/e),k=p.map(([I,E])=>a($+I,x+E)?c[(x+E)*e+$+I]:-1),P=k.filter(I=>I===o.body).length;return P>=2&&k.filter(I=>I!==o.body&&I!==o.lit).length<P});for(let _=0;S&&_<t;_++)for(let $=0;$<e;$++)if(d($,_)&&!p.some(([x,k])=>d($+x,_+k))){S=!1;break}return S||w.forEach((_,$)=>{c[_]=v[$]}),S},g=w=>{let v=w%e,S=Math.floor(w/e),[_,$]=s!==0?[i===0?1:-i,0]:[0,1];return d(v+_,S+$)?(S+$)*e+v+_:null},b=!1;for(let{k:w}of f)if(h([w])){if(b=!0,e>=8){let v=g(w);v!==null&&h([v])}break}for(let{k:w}of b?[]:f){let v=g(w);if(v!==null&&h([w,v]))break}let y=[];for(let w=0;w<t;w++)for(let v=0;v<e;v++)c[w*e+v]>=0&&y.push([v,w,c[w*e+v]]);return{w:e,h:t,px:y}}var xV=(e,t)=>Math.max(2,Math.min(e,e-1-(e>>2)+t)),_V={name:"pebbles",summary:"pebbles [<x,y> <W>x<H>] ramp=<ramp> [weights=<w,..>] [size=<a>..<b>] [density=<0..1>] [gap=<n>] [light=<dir>] [cast=<colour>|none] [wrap=on|off] [edges=<seed>] [seed=<n>] (stones: a body tone, a shadow side and a lit pixel from the light, never overlapping)",normalise(e,t){let r=Be(e,t),o=new we(e,["ramp","weights","size","density","gap","light","cast","wrap","edges","seed"]),n=Cs(o,r,"pebbles");o.done();let i=cA(o,r,e,3),s=i.idx.slice(1,-1),a=o.opts.get("weights"),c=a?$y(a,s.length):s.map(()=>1),l=uA(r),u=o.opts.get("size"),m=Math.max(3,Math.floor((l+4)/9)),[d,f]=u?$c(u,3,64):[m,Math.max(m+1,Math.floor((2*l+4)/9))],p=o.opts.get("density"),h=p?Ss(p):{num:3,den:10,text:"0.3"},g=aA(o,t),b=lA(o,r,"cast",null),y=mA(o,r,t,n,h),w=k=>{let P=k.range(d,f),I=xV(P,k.nextInt(2)),E=jm(k,c),N=q=>v($V(P,I,g.dir,{dark:i.idx[q],body:i.idx[q+1],lit:i.idx[q+2]})),T=N(E);T.alts=c.flatMap((q,Z)=>q>0?[Z===E?T:N(Z)]:[]);for(let q of T.alts)q.alts=T.alts;return T},v=k=>{if(b.index===null)return k;let P=new Set(k.px.map(([V,F])=>`${V},${F}`)),[I,E]=g.dir,T=[...k.px.map(([V,F])=>[V-I,F-E,b.index]).filter(([V,F])=>!P.has(`${V},${F}`)),...k.px],q=Math.min(...T.map(V=>V[0])),Z=Math.min(...T.map(V=>V[1])),D=T.map(([V,F,M])=>[V-q,F-Z,M]);return{w:Math.max(...D.map(V=>V[0]))+1,h:Math.max(...D.map(V=>V[1]))+1,px:D}},{under:S,L:_,Y:$}=pA(r,t.by,n),x=fA(y,S,_,$,w,7);return{text:`pebbles${n.text} ramp=${i.text} weights=${c.join(",")} size=${d}..${f} density=${h.text} light=${g.name} cast=${b.text} ${dA(y)}`,op:le((k,P)=>yn(k,P,x,!1))}}};function SV(e,t,r,o,n,i){let s=n[n.length-1],a=n[n.length-2],c=n[Math.max(0,n.length-3)],l=t>=8?2:1,u=[];for(let p=0;p<e;p++){let h=2*p-(e-1),g=Math.sign(h),b=g*Math.ceil(Math.abs(h)/2)*l,y=Math.max(3,t-Math.ceil(Math.abs(h)/2)*Math.max(1,t>>2)-(r[p]??0)),w=g===0?o[1]<0||o[0]===0?s:a:o[0]===0?a:g===Math.sign(o[0])?s:c;for(let[v,S]of dy([p,t-1],[p+b,t-y]))u.push([v,S,w])}if(i!==null)for(let p=0;p<e;p++)u.push([p,t,i]);let m=Math.min(...u.map(p=>p[0])),d=Math.min(...u.map(p=>p[1])),f=u.map(([p,h,g])=>[p-m,h-d,g]);return{w:Math.max(...f.map(p=>p[0]))+1,h:Math.max(...f.map(p=>p[1]))+1,px:f}}var kV={name:"tufts",summary:"tufts [<x,y> <W>x<H>] ramp=<ramp> [size=<a>..<b>] [blades=<a>..<b>] [density=<0..1>] [gap=<n>] [light=<dir>] [foot=<colour>|none] [wrap=on|off] [edges=<seed>] [seed=<n>] (tufts of blades lit from the light, never overlapping)",normalise(e,t){let r=Be(e,t),o=new we(e,["ramp","size","blades","density","gap","light","foot","wrap","edges","seed"]),n=Cs(o,r,"tufts");o.done();let i=cA(o,r,e,3),s=uA(r),a=o.opts.get("size"),c=Math.max(3,Math.floor((s+2)/6)),[l,u]=a?$c(a,3,64):[c,Math.max(c+1,Math.floor((s+2)/4))],m=o.opts.get("blades"),[d,f]=m?$c(m,1,9):s<20?[2,3]:s<32?[3,4]:[3,5],p=o.opts.get("density"),h=p?Ss(p):{num:2,den:10,text:"0.2"},g=aA(o,t),b=lA(o,r,"foot",i.idx[0]),y=mA(o,r,t,n,h),{under:w,L:v,Y:S}=pA(r,t.by,n),$=fA(y,w,v,S,x=>{let k=x.range(d,f),P=x.range(l,u),I=Array.from({length:k},()=>x.nextInt(2)),E=[P-1,P,P+1].filter(N=>N>=l&&N<=u).map(N=>SV(k,N,I,g.dir,i.idx,b.index));for(let N of E)N.alts=E;return E[E.length>2?1:P>l?E.length-1:0]},8);return{text:`tufts${n.text} ramp=${i.text} size=${l}..${u} blades=${d}..${f} density=${h.text} light=${g.name} foot=${b.text} ${dA(y)}`,op:le((x,k)=>yn(x,k,$,!1))}}};Te(_V);Te(kV);var zV=/^[a-z][a-z0-9_-]*$/,RV=new Set(["save","remove"]),IV={name:"stamp",summary:"stamp save <name> <x,y> <W>x<H> | stamp save <name> << rows >> | stamp <name> <x,y> [flip=none|h|v|hv] | stamp remove <name>",normalise(e,t){let r=De(e,t),o=new we(e,["flip"]),n=o.cellOrigin(r),i=o.take("word","save, remove or a stamp name");if(i.v==="save"){let d=o.take("word","a name for the stamp");if(!zV.test(d.v)||RV.has(d.v))throw new O(d.line,d.col,"stamp names use a-z, 0-9, _ and -, starting with a letter (not save or remove)");if(o.opts.has("flip"))throw new O(e.line,e.col,"stamp save takes no flip=");if(o.peek()?.t==="block"){let h=o.take("block","a block");o.done();let g=new Map(r.palette.entries.map((S,_)=>[S.key,_])),b=h.rows.map(S=>[...S.text].map((_,$)=>{if(_==="."||_===" ")return 65535;let x=g.get(_);if(x===void 0)throw new O(S.line,S.col+$,`stamp: '${_}' is not a key in palette '${r.palette.name}'`);return x})),y=Math.max(0,...b.map(S=>S.length)),w=b.length;if(y<1||w<1)throw new O(h.line,h.col,"stamp save: the block is empty");let v=new Uint16Array(y*w).fill(65535);return b.forEach((S,_)=>S.forEach(($,x)=>{v[_*y+x]=$})),{text:`stamp save ${d.v} <<
137
+ ${Wt(h.rows.map(S=>S.text))}>>`,op:le(S=>{S.stamps={...S.stamps,[d.v]:{w:y,h:w,px:v}}})}}let f=o.take("point","a corner x,y (or a block: <<)"),p=o.take("size","a size WxH");if(o.done(),p.w<1||p.h<1||p.w>256||p.h>256)throw new O(p.line,p.col,"stamp save: size must be 1x1 to 256x256");return{text:`stamp${n.text} save ${d.v} ${f.x},${f.y} ${p.w}x${p.h}`,op:le((h,g)=>{let b=qt(h,g),y=new Uint16Array(p.w*p.h).fill(65535);for(let w=0;w<p.h;w++)for(let v=0;v<p.w;v++){let S=Rt(b,f.x+n.dx+v,f.y+n.dy+w);S>=0&&(!b.mask||b.mask[S])&&(y[w*p.w+v]=b.pixels[S])}h.stamps={...h.stamps,[d.v]:{w:p.w,h:p.h,px:y}}})}}if(i.v==="remove"){let d=o.take("word","a stamp name");if(o.done(),!r.stamps[d.v])throw new O(d.line,d.col,`no stamp '${d.v}'`);return{text:`stamp remove ${d.v}`,op:le(f=>{let{[d.v]:p,...h}=f.stamps;f.stamps=h;for(let[g,b]of Object.entries(f.ctx))b.brush?.shape==="stamp"&&b.brush.stamp===d.v&&Tt(f,g,{brush:null})})}}Be(e,t);let s=r.stamps[i.v];if(!s)throw new O(i.line,i.col,`no stamp '${i.v}' (stamps: ${Object.keys(r.stamps).join(", ")||"none; make one with stamp save"})`);let a=o.take("point","where its top-left goes, x,y");o.done();let c=o.choice("flip",["none","h","v","hv"],"none"),l=a.x+n.dx,u=a.y+n.dy,m=[];for(let d=0;d<s.h;d++)for(let f=0;f<s.w;f++){let p=c.includes("h")?s.w-1-f:f,h=c.includes("v")?s.h-1-d:d,g=s.px[h*s.w+p];g!==65535&&m.push([l+f,u+d,g])}return{text:`stamp${n.text} ${i.v} ${a.x},${a.y} flip=${c}`,op:le((d,f)=>yn(d,f,m,!0))}}},PV={name:"brush",summary:"brush square <n> | brush circle <n> | brush stamp <name> | brush off (the shape px, line, curve, stroke and outlines draw with)",normalise(e,t){let r=De(e,t),o=new we(e,[]),n=o.take("word","square, circle, stamp or off");if(n.v==="off")return o.done(),{text:"brush off",op:le((a,c)=>Tt(a,c,{brush:null}))};if(n.v==="stamp"){let a=o.take("word","a stamp name");if(o.done(),!r.stamps[a.v])throw new O(a.line,a.col,`no stamp '${a.v}'`);return{text:`brush stamp ${a.v}`,op:le((c,l)=>Tt(c,l,{brush:{shape:"stamp",stamp:a.v}}))}}if(n.v!=="square"&&n.v!=="circle")throw new O(n.line,n.col,"brush: expected square, circle, stamp or off");let i=o.take("int","a size in pixels");if(o.done(),i.v<1||i.v>32)throw new O(i.line,i.col,"brush: size must be 1..32");let s=n.v;return{text:`brush ${s} ${i.v}`,op:le((a,c)=>Tt(a,c,{brush:i.v===1?null:{shape:s,size:i.v}}))}}};Te(IV);Te(PV);var jV=/^[a-z][a-z0-9_]*$/,yA=new Set(["new","fork","undo","redo","note","def"]),hA=8;function EV(e){let t=e.split(`
138
+ `).map(o=>o.replace(/\s+$/,""));for(;t.length&&t[0].trim()==="";)t.shift();for(;t.length&&t.at(-1).trim()==="";)t.pop();let r=1/0;for(let o of t)o.trim()&&(r=Math.min(r,o.length-o.trimStart().length));return t.map(o=>o.slice(Number.isFinite(r)?r:0)).join(`
139
+ `)}function TV(e){return e.includes(`
140
+ `)?`{
141
+ ${e.split(`
142
+ `).map(t=>t?` ${t}`:"").join(`
143
+ `)}
144
+ }`:`{ ${e} }`}function gA(e,t){let r=0,o=()=>{for(;e[r]===" ";)r++},n=()=>{if(o(),e[r]==="("){r++;let u=s();if(o(),e[r]!==")")throw new Error("expected ')'");return r++,u}if(e[r]==="-")return r++,-n();let c=/^(\d+|[a-z_][a-z0-9_]*)/.exec(e.slice(r));if(!c)throw new Error("expected a number or a parameter");if(r+=c[1].length,/^\d/.test(c[1]))return Number(c[1]);let l=t.get(c[1]);if(l===void 0)throw new Error(`unknown parameter '${c[1]}'`);if(!/^-?\d+$/.test(l))throw new Error(`parameter '${c[1]}' is '${l}', not a number`);return Number(l)},i=()=>{let c=n();for(;;){o();let l=e[r];if(l!=="*"&&l!=="/")return c;r++;let u=n();if(l==="/"&&u===0)throw new Error("division by zero");c=l==="*"?c*u:Math.floor(c/u)}},s=()=>{let c=i();for(;;){o();let l=e[r];if(l!=="+"&&l!=="-")return c;r++,c=l==="+"?c+i():c-i()}},a=s();if(o(),r<e.length)throw new Error(`unexpected '${e[r]}'`);return a}function bk(e,t){let r=new Map(e.params.map((o,n)=>[o,t[n]]));return e.body.replace(/\$\(([^()]*(?:\([^()]*\)[^()]*)*)\)|\$([a-z_][a-z0-9_]*)((?:[+\-*/]\d+)*)/g,(o,n,i,s)=>{if(n!==void 0)return String(gA(n,r));let a=r.get(i);if(a===void 0)throw new Error(`unknown parameter '$${i}'`);if(!s)return a;let c=gA(i,r);for(let[,l,u]of s.matchAll(/([+\-*/])(\d+)/g)){let m=Number(u);if(l==="/"&&m===0)throw new Error("division by zero");c=l==="+"?c+m:l==="-"?c-m:l==="*"?c*m:Math.floor(c/m)}return String(c)})}var CV={name:"def",summary:"def <name>(<param>,...) { <commands> } (a macro: $param in the body, $x+1 or $(x*2+y) for arithmetic)",normalise(e,t){De(e,t);let r=e.args.find(d=>d.t==="body");if(!r)throw new O(e.line,e.col,"def: expected a body in braces: def name(a,b) { ... }");let o=e.args.slice(0,e.args.indexOf(r)),n=e.args.slice(e.args.indexOf(r)+1);if(n.length)throw new O(n[0].line,n[0].col,`def: unexpected '${zc(n[0])}' after the body`);let i=o.map(zc).join(""),s=/^([a-z][a-z0-9_]*)\(([a-z0-9_,]*)\)$/.exec(i);if(!s)throw new O(o[0]?.line??e.line,o[0]?.col??e.col,"def: expected name(param,...) before the body, like tuft(x,y)");let a=s[1];if(Gr.has(a))throw new O(o[0].line,o[0].col,`def: '${a}' is a command name`);let c=s[2]?s[2].split(","):[];if(c.some(d=>!jV.test(d)))throw new O(o[0].line,o[0].col,"def: parameters are names like x, y, c");if(new Set(c).size!==c.length)throw new O(o[0].line,o[0].col,"def: a parameter is named twice");let l=EV(r.text);if(!l.trim())throw new O(r.line,r.col,"def: the body is empty");let u;try{u=bk({params:c,body:l},c.map(()=>"0"))}catch(d){throw new O(r.line,r.col,`def ${a}: ${d.message}`)}let m=pn(u);if(m.errors.length)throw new O(r.line,r.col,`def ${a}: body line ${m.errors[0].line}: ${m.errors[0].message}`);for(let d of m.commands){if(yA.has(d.name))throw new O(r.line,r.col,`def ${a}: '${d.name}' cannot be used in a macro`);if(!Gr.has(d.name))throw new O(r.line,r.col,`def ${a}: unknown command '${d.name}' in the body`)}return{text:`def ${a}(${c.join(",")}) ${TV(l)}`,op:{k:"fn",run:d=>{d.macros={...d.macros,[a]:{params:c,body:l}}}}}}},AV={name:"call",summary:"call <name> <args...> [seed=<n>] (runs a macro; a point x,y fills two parameters)",normalise(e,t){let r=De(e,t),o=new we(e,["seed"]),n=o.take("word","a macro name"),i=r.macros[n.v];if(!i){let b=Object.keys(r.macros);throw new O(n.line,n.col,`no macro '${n.v}' (${b.length?`macros: ${b.join(", ")}`:"define one with def"})`)}let s=[],a=[];for(let b of o.rest()){if(b.t==="point")s.push(String(b.x),String(b.y));else if(b.t==="int")s.push(String(b.v));else if(b.t==="word")s.push(b.v);else throw new O(b.line,b.col,"call: arguments are numbers, points x,y or words");a.push(zc(b))}if(s.length!==i.params.length)throw new O(n.line,n.col,`call ${n.v}: takes ${i.params.length} value(s) (${i.params.join(", ")}), got ${s.length}`);let c=(t.depth??0)+1;if(c>hA)throw new O(e.line,e.col,`call ${n.v}: macros call each other more than ${hA} deep`);let l=o.opts.get("seed"),u=l?Ct(l,0,2147483647):null,m=0,d;try{d=bk(i,s)}catch(b){throw new O(e.line,e.col,`call ${n.v}: ${b.message}`)}let f=pn(d);if(f.errors.length)throw new O(e.line,e.col,`call ${n.v}: body line ${f.errors[0].line}: ${f.errors[0].message}`);let p=qr(r),h=[];for(let b of f.commands){if(yA.has(b.name))throw new O(e.line,e.col,`call ${n.v}: '${b.name}' cannot be used in a macro`);let y={...t,doc:p,depth:c,newSeed:()=>(u===null&&(u=t.newSeed()),cy(new dt(u,1e3+m++))),undoTarget:()=>({error:"not in a macro"}),redoTarget:()=>({error:"not in a macro"})};try{let w=_i(b,y);p=Ts(p,w.op,t.by),h.push(w.op)}catch(w){throw w instanceof O?new O(e.line,e.col,`call ${n.v}: body line ${w.line}: ${w.message}`):w}}let g=u!==null&&(l||m>0)?` seed=${u}`:"";return{text:`call ${n.v}${a.length?" "+a.join(" "):""}${g}`,op:{k:"fn",run:(b,y)=>{for(let w of h)Ts(b,w,y)}}}}};Te(CV);Te(AV);var OV=/^[A-Za-z][A-Za-z0-9_-]*$/,NV=new Set(["add","set","remove","all"]),bA=["cycle","pingpong"];function wk(e,t){if(e.flags.length)throw new O(e.flags[0].line,e.flags[0].col,`${t}: unexpected '${e.flags[0].v}'`)}function Gy(e,t,r){for(let o of e.opts.values())if(!r.includes(o.key))throw new O(o.line,o.col,`${t} takes no ${o.key}=`)}function vA(e,t){let r=t.opts.get("frames");if(!r)return null;let o=/^\d+$/.test(r.value)?{t:"int",v:Number(r.value),line:r.line,col:r.vcol}:{t:"word",v:r.value,line:r.line,col:r.vcol};return Rm(e,o,t.cmd)}var MV={name:"tag",summary:"tag add <name> <a>-<b> [loop=cycle|pingpong] | tag set <name> [frames=<a>-<b>] [loop=cycle|pingpong] | tag remove <name> (a named run of frames: walk_s, idle)",normalise(e,t){let r=De(e,t),o=new we(e,["loop","frames"]);wk(o,"tag");let n=o.take("word","add, set or remove");if(!["add","set","remove"].includes(n.v))throw new O(n.line,n.col,"tag: expected add, set or remove");let i=o.take("word","a tag name"),s=r.tags.findIndex(u=>u.name===i.v);if(n.v==="add"){if(!OV.test(i.v)||NV.has(i.v))throw new O(i.line,i.col,`'${i.v}' is not a usable tag name`);if(s>=0)throw new O(i.line,i.col,`there is already a tag '${i.v}'`);let u=Rm(r,o.rest()[0],e);Gy(o,"tag add",["loop"]);let m=o.choice("loop",bA,"cycle");return{text:`tag add ${i.v} ${u.text} loop=${m}`,op:le(d=>{d.tags.push({name:i.v,from:u.from-1,to:u.to-1,loop:m})})}}if(s<0)throw new O(i.line,i.col,`no tag '${i.v}'${r.tags.length?` (tags: ${r.tags.map(u=>u.name).join(", ")})`:""}`);if(o.done(),n.v==="remove")return Gy(o,"tag remove",[]),{text:`tag remove ${i.v}`,op:le(u=>{u.tags=u.tags.filter(m=>m.name!==i.v)})};Gy(o,"tag set",["loop","frames"]);let a=vA(r,o),c=o.opts.get("loop");if(!a&&!c)throw new O(e.line,e.col,"tag set: give frames=<a>-<b> or loop=");let l=c?o.choice("loop",bA,"cycle"):null;return{text:`tag set ${i.v}${a?` frames=${a.from}-${a.to}`:""}${l?` loop=${l}`:""}`,op:le(u=>{let m=u.tags.find(d=>d.name===i.v);a&&(m.from=a.from-1,m.to=a.to-1),l&&(m.loop=l)})}}};function wA(e){if(!Ur.includes(e.v))throw new O(e.line,e.col,`view: '${e.v}' is not a direction (${Ur.join(", ")})`);return e.v}var DV={name:"view",summary:"view <dir> frames=<a>-<b> | view <dir> mirror=<dir>|off | view remove <dir> (directions S N E W SE SW NE NW; a mirror view is its source flipped left to right, kept up to date)",normalise(e,t){let r=De(e,t),o=new we(e,["frames","mirror"]);wk(o,"view");let n=o.take("word","a direction, or remove");if(n.v==="remove"){let u=o.take("word","a direction");o.done(),Gy(o,"view remove",[]);let m=wA(u);if(!r.views.some(d=>d.name===m))throw new O(u.line,u.col,`there is no view ${m}`);if(r.views.some(d=>d.mirror===m))throw new O(u.line,u.col,`view ${m} is the source of mirror view ${r.views.find(d=>d.mirror===m).name} (turn that off first)`);return{text:`view remove ${m}`,op:le(d=>{d.views=d.views.filter(f=>f.name!==m)})}}let i=wA(n);o.done();let s=vA(r,o),a=o.opts.get("mirror");if(!!s==!!a)throw new O(e.line,e.col,`view ${i}: give frames=<a>-<b> or mirror=<dir>|off`);let c=r.views.find(u=>u.name===i);if(s){if(c?.mirror)throw new O(e.line,e.col,`view ${i} is a mirror of ${c.mirror}: view ${i} mirror=off first`);let u=r.views.find(m=>m.name!==i&&m.from<=s.to-1&&s.from-1<=m.to);if(u)throw new O(e.line,e.col,`view ${i}: frames ${s.text} overlap view ${u.name} (${u.from+1}-${u.to+1})`);return{text:`view ${i} frames=${s.from}-${s.to}`,op:le(m=>{let d=m.views.find(f=>f.name===i);d?(d.from=s.from-1,d.to=s.to-1):m.views.push({name:i,from:s.from-1,to:s.to-1,mirror:null})})}}if(a.value==="off"){if(!c?.mirror)throw new O(a.line,a.vcol,`view ${i} is not a mirror`);return{text:`view ${i} mirror=off`,op:le(u=>{u.views.find(m=>m.name===i).mirror=null})}}let l=r.views.find(u=>u.name===a.value);if(!Ur.includes(a.value))throw new O(a.line,a.vcol,`mirror= must be a direction (${Ur.join(", ")}) or off`);if(!l)throw new O(a.line,a.vcol,`there is no view ${a.value} to mirror (view ${a.value} frames=<a>-<b> first)`);if(l.name===i)throw new O(a.line,a.vcol,"a view cannot mirror itself");if(l.mirror)throw new O(a.line,a.vcol,`view ${l.name} is itself a mirror (of ${l.mirror})`);if(r.views.some(u=>u.mirror===i))throw new O(e.line,e.col,`view ${i} is the source of another mirror`);if(im(i)!==l.name)throw new O(a.line,a.vcol,`view ${i} faces the other way from ${im(i)??"no view"}, not ${l.name} (a mirror flips left to right)`);return{text:`view ${i} mirror=${l.name}`,op:le(u=>{let m=u.views.find(d=>d.name===i);if(!m){let d=u.views.find(h=>h.name===l.name),f=u.frameCount,p=d.to-d.from+1;sm(u,f,p,()=>new Uint16Array(u.width*u.height).fill(65535),Array.from({length:p},()=>10)),u.views.push(m={name:i,from:f,to:f+p-1,mirror:null})}m.mirror=l.name})}}};function qV(e,t,r){let o=t.opts.get("layer");if(!o){let i=Me(e,r).layer;return{layers:[i],text:`layer=${e.layers[i].name}`}}if(o.value==="all")return{layers:e.layers.map((i,s)=>s),text:"layer=all"};let n=e.layers.findIndex(i=>i.name===o.value);if(n<0)throw new O(o.line,o.vcol,`no layer '${o.value}'`);return{layers:[n],text:`layer=${o.value}`}}function UV(e,t,r){for(let o=r.from-1;o<r.to;o++){let n=fi(e,o);if(n?.mirror)throw new O(t.line,t.col,`${t.name}: frame ${o+1} is in view ${n.name}, a live mirror of ${n.mirror}`)}}var LV={name:"cel",summary:"cel link <a>-<b> [layer=<name>|all] | cel unlink <a>-<b> [layer=<name>|all] (linked cels share their pixels: draw on one, all change; link copies frame <a>'s pixels)",normalise(e,t){let r=De(e,t),o=new we(e,["layer"]);wk(o,"cel");let n=o.take("word","link or unlink");if(n.v!=="link"&&n.v!=="unlink")throw new O(n.line,n.col,"cel: expected link or unlink");let i=Rm(r,o.rest()[0],e);if(n.v==="link"&&i.from===i.to)throw new O(e.line,e.col,"cel link: give two or more frames (<a>-<b>)");UV(r,e,i);let s=qV(r,o,t.by);return{text:`cel ${n.v} ${i.from}-${i.to} ${s.text}`,op:le(a=>{for(let c of s.layers){let l=a.cels[c];for(let u=i.from-1;u<i.to;u++)n.v==="link"?l[u]=l[i.from-1]:(l.indexOf(l[u])!==u||l.lastIndexOf(l[u])!==u)&&(l[u]=l[u].slice())}})}}},FV={name:"pivot",summary:"pivot <x,y> | pivot off (the pixel the sprite stands on: an export field, and what pivot drift is measured from)",normalise(e,t){let r=De(e,t),o=new we(e,[],["off"]);if(o.flags.length)return o.done(),{text:"pivot off",op:le(i=>{i.pivot=null})};let n=rn(o.take("point","a pixel x,y (or off)"));if(o.done(),n[0]<0||n[1]<0||n[0]>=r.width||n[1]>=r.height)throw new O(e.line,e.col,`pivot ${n[0]},${n[1]} is outside the ${r.width}x${r.height} canvas`);return{text:`pivot ${n[0]},${n[1]}`,op:le(i=>{i.pivot=[n[0],n[1]]})}}},VV={name:"ground",summary:"ground <y> | ground off (the row the feet rest on: every frame should touch it)",normalise(e,t){let r=De(e,t),o=new we(e,[],["off"]);if(o.flags.length)return o.done(),{text:"ground off",op:le(i=>{i.ground=null})};let n=o.take("int","a row y (or off)");if(o.done(),n.v<0||n.v>=r.height)throw new O(n.line,n.col,`ground ${n.v} is outside rows 0..${r.height-1}`);return{text:`ground ${n.v}`,op:le(i=>{i.ground=n.v})}}};for(let e of[MV,DV,LV,FV,VV])Te(e);function ZV(e,t){let r=De(e,t);if(!r.family)throw new O(e.line,e.col,`${e.name}: '${r.name}' is not a family (new family <name> <T>x<T> scheme=\u2026)`);return{doc:r,f:r.family}}function xA(e){if(e.flags.length)throw new O(e.flags[0].line,e.flags[0].col,`${e.cmd.name}: unexpected '${e.flags[0].v}'`)}function As(e,t,r){for(let o of e.opts.values())if(!r.includes(o.key))throw new O(o.line,o.col,`${t} takes no ${o.key}=`)}function Ut(e,t,r,o,n){let i=e.opts.get(t);if(!i)return n;if(!/^\d+$/.test(i.value)||Number(i.value)<r||Number(i.value)>o)throw new O(i.line,i.vcol,`${t}= must be a whole number ${r}..${o}`);return Number(i.value)}var Ic=(e,t)=>e.layers.findIndex(r=>r.name===t);function $A(e,t,r,o,n){let i=be(e,t),s=new Map;for(let l=0;l<n;l++)for(let u=0;u<n;u++){let m=i[(o*n+l)*e.width+r*n+u];m!==65535&&s.set(m,(s.get(m)??0)+1)}let a=65535,c=0;for(let[l,u]of s)(u>c||u===c&&l<a)&&(a=l,c=u);return a}function _A(e,t,r,o){let n=e.opts.get("from"),i=mt(r),s=Qe(r),a=r.tile,c=i.mapRow*a,l=t.width,u=new Map(t.palette.entries.map((F,M)=>[M,F.key])),m=e.rest(),d=m.at(-1)?.t==="block"?m.pop():null,f=(F,M)=>{if(F===i.inside[0]&&M===i.inside[1])return"inside";if(F===i.outside[0]&&M===i.outside[1])return"outside";let L=i.cells.findIndex(([A,z])=>A===F&&z===M);return L>=0?s.variants[L].name:`${F}:${M}`},p=F=>{let M=/^(\d+):(\d+)$/.exec(F);return M?Number(M[1])<l/a&&Number(M[2])<i.mapRow?[Number(M[1]),Number(M[2])]:null:zm(r,F)};if(!d&&!e.opts.get("cells")){if(m.length)throw new O(m[0].line,m[0].col,`family band from=: the band comes from '${n.value}' (give nothing else)`);As(e,"family band from=",["from"]);let F=o.asset?.(n.value);if(!F)throw new O(n.line,n.vcol,`family band: no asset '${n.value}' to copy the band from (not this one)`);let M=F.family;if(!M||M.scheme!==r.scheme||M.tile!==a)throw new O(n.line,n.vcol,`family band: '${n.value}' is not a ${r.scheme} family of ${a}px tiles`);let L=M.geometry,A=ae=>ae==="outside"||ae==="inside"?ae:F.palette.entries[ae].name;for(let ae of L.bands)if(typeof ae.fill=="number"&&!t.palette.entries.some(pe=>pe.name===A(ae.fill)))throw new O(n.line,n.vcol,`family band: '${n.value}' uses ${A(ae.fill)}, which palette '${t.palette.name}' does not have`);let z=`${L.bands.map(ae=>`${ae.w}:${A(ae.fill)}`).join(" ")} radius=${L.radius} inset=${L.inset}${L.fillet!==void 0?` fillet=${L.fillet}`:""}${L.jitter?` jitter=${L.jitter.px} seed=${L.jitter.seed}`:""}`,R=M.detached,C=Math.min(F.frameCount,t.frameCount),U=Ic(F,Sc),W=new Set(R),X=mt(M),Y=new Set(s.variants.map((ae,pe)=>s.sources[pe]&&!W.has(ae.name)?`${X.cells[pe][0]},${X.cells[pe][1]}`:"").filter(Boolean)),fe=(ae,pe,Ie)=>U>=0?F.cels[U][ae][Ie*F.width+pe]:65535,ye=[];for(let ae=0;ae<i.mapRow;ae++)for(let pe=0;pe<l/a;pe++){if(Y.has(`${pe},${ae}`))continue;let Ie=!1;for(let Je=0;Je<C&&!Ie;Je++)for(let Ze=0;Ze<a&&!Ie;Ze++)for(let Ye=0;Ye<a;Ye++)if(fe(Je,pe*a+Ye,ae*a+Ze)!==65535){Ie=!0;break}Ie&&ye.push([pe,ae])}let H=[];for(let ae=0;ae<C;ae++)for(let pe=0;pe<a;pe++){let Ie="";for(let[Je,Ze]of ye)for(let Ye=0;Ye<a;Ye++){let Xe=fe(ae,Je*a+Ye,Ze*a+pe);if(Xe===65535){Ie+=".";continue}let Pt=t.palette.entries.findIndex(bt=>bt.name===F.palette.entries[Xe].name);if(Pt<0)throw new O(n.line,n.vcol,`family band: '${n.value}' uses ${F.palette.entries[Xe].name}, which palette '${t.palette.name}' does not have`);Ie+=u.get(Pt)}H.push(Ie)}let Q=`band from=${n.value} ${z} detached=${R.length?R.join(","):"none"} frames=${C} cells=${ye.length?ye.map(([ae,pe])=>f(ae,pe)).join(","):"none"}${ye.length?` <<
145
+ ${Wt(H)}>>`:""}`,re=pn(`family ${Q}`);if(re.errors.length||re.commands.length!==1)throw new O(n.line,n.vcol,`family band from=: ${re.errors[0]?.message??"could not record the band"}`);let de=new we(re.commands[0],["radius","inset","fillet","jitter","draw","from","frame","seed","copies","fill","textures","detached","frames","cells"]);return de.take("word","band"),_A(de,t,r,o)}As(e,"family band from=",["from","radius","inset","fillet","jitter","seed","detached","frames","cells"]);let h=[],g=[];for(let F of m){let M=F.t==="word"?/^(\d+):(.+)$/.exec(F.v):null;if(!M)throw new O(F.line,F.col,"family band: expected <width>:<colour|outside|inside>");let L=M[2]==="outside"||M[2]==="inside"?M[2]:zt(M[2],t.palette,F.line,F.col).index;h.push({w:Number(M[1]),fill:L}),g.push(`${M[1]}:${M[2]}`)}let b=a/2,y=Ut(e,"radius",0,b,0),w=Ut(e,"inset",0,b-1,0),S=e.opts.get("fillet")?Ut(e,"fillet",1,b,1):void 0,_=Ut(e,"jitter",0,b,0),$=_?Ut(e,"seed",1,2147483647,1):0,x=e.opts.get("detached")?.value??"none",k=x==="none"?[]:x.split(",");for(let F of k)if(!s.byName.has(F))throw new O(e.opts.get("detached").line,e.opts.get("detached").vcol,`${s.name} has no variant '${F}'`);let P=Ut(e,"frames",1,t.frameCount,1),I=e.opts.get("cells"),E=[];if(I&&I.value!=="none")for(let F of I.value.split(",")){let M=p(F);if(!M)throw new O(I.line,I.vcol,`family band from=: '${F}' is not a cell of the sheet (a variant, inside, outside or <cx>:<cy>)`);E.push(M)}let N=I?E.length*a:l,T=I?E.length?P*a:0:P*c,q=d?.rows??[];if(q.length!==T||q.some(F=>F.text.length!==N)){let F=d??I;throw new O(F.line,F.col,`family band from=: the rows must be ${P} frame${P===1?"":"s"} of ${N}x${I?a:c}${I?` (the ${E.length} cells side by side)`:""}`)}let Z=new Map(t.palette.entries.map((F,M)=>[F.key,M])),D=q.map(F=>[...F.text].map((M,L)=>{if(M===".")return 65535;let A=Z.get(M);if(A===void 0)throw new O(F.line,F.col+L,`'${M}' is not a key in palette '${t.palette.name}'`);return A})),V={inset:w,radius:y,bands:h,...S!==void 0?{fillet:S}:{},..._?{jitter:{px:_,seed:$}}:{}};return{text:`band from=${n.value} ${g.join(" ")} radius=${y} inset=${w}${S!==void 0?` fillet=${S}`:""}${_?` jitter=${_} seed=${$}`:""} detached=${x} frames=${P}${I?` cells=${I.value}`:""}${q.length?` <<
146
+ ${Wt(q.map(F=>F.text))}>>`:""}`,run:F=>{let M=F.family;M.geometry=V,M.detached=s.variants.map(z=>z.name).filter(z=>k.includes(z));let L=Ic(F,Sc);if(L<0)return;let A=new Set;for(let z=0;z<P;z++){let R=F.cels[L][z];if(!A.has(R)){if(A.add(R),!I){for(let C=0;C<c;C++)for(let U=0;U<l;U++)R[C*l+U]=D[z*c+C][U];continue}R.fill(65535,0,c*l),E.forEach(([C,U],W)=>{for(let X=0;X<a;X++)for(let Y=0;Y<a;Y++)R[(U*a+X)*l+C*a+Y]=D[z*a+X][W*a+Y]})}}}}}function HV(e,t,r,o){let n=e.rest();if(!n.length)throw new O(e.cmd.line,e.cmd.col,"family band: give the band from the edge in, as <width>:<colour|outside|inside> (e.g. 3:outside 1:foam 2:sand1)");let i=[],s=[];for(let b of n){let y=b.t==="word"?b.v:"",w=/^(\d+):(.+)$/.exec(y);if(!w)throw new O(b.line,b.col,"family band: expected <width>:<colour|outside|inside>, like 2:foam");let v=Number(w[1]);if(v<1)throw new O(b.line,b.col,"family band: a width is at least 1");let S,_;if(w[2]==="outside"||w[2]==="inside")S=w[2],_=w[2];else{let $=zt(w[2],t.palette,b.line,b.col+w[1].length+1);if($.index===65535)throw new O(b.line,b.col,"family band: a band needs a colour, outside or inside (not none)");S=$.index,_=$.name}i.push({w:v,fill:S}),s.push(`${v}:${_}`)}let a=!!Qe(r).fillets;As(e,"family band",a?["radius","inset","draw","fillet","jitter","seed"]:["radius","inset","draw","jitter","seed"]);let c=r.tile/2,l=Ut(e,"radius",0,c,0),u=Ut(e,"inset",0,c-1,r.geometry.inset),m=e.choice("draw",["on","off"],"on")==="on",d=i.reduce((b,y)=>b+y.w,0);if(u+d+l>c)throw new O(e.cmd.line,e.cmd.col,`family band: the inset (${u}), the band (${d}) and the corner radius (${l}) must fit in half a tile (${c} px)`);let f=a?Ut(e,"fillet",1,c,r.geometry.fillet??Math.min(c,d||1)):void 0,p=Ut(e,"jitter",0,Math.max(0,c-u-d-l),0);if(!p&&e.opts.get("seed"))throw new O(e.opts.get("seed").line,e.opts.get("seed").col,"family band: seed= goes with jitter=");let h=p?e.opts.get("seed")?Ut(e,"seed",1,2147483647,1):o.newSeed():0,g={inset:u,radius:l,bands:i,...f!==void 0?{fillet:f}:{},...p?{jitter:{px:p,seed:h}}:{}};return{text:`band ${s.join(" ")} radius=${l} inset=${u}${f!==void 0?` fillet=${f}`:""}${p?` jitter=${p} seed=${h}`:""} draw=${m?"on":"off"}`,run:b=>{let y=b.family;y.geometry=g;let w=Ic(b,Sc);if(!m||w<0)return;let v=Qe(y),S=y.tile,_=mt(y),$=xo(v,S,g),x=v.pieces.map(P=>v.byName.get(P)).filter(P=>!pi(v.variants[P].on)),k=new Set;for(let P of b.cels[w])if(!k.has(P)){k.add(P);for(let I of x){let[E,N]=_.cells[I];for(let T=0;T<S;T++)for(let q=0;q<S;q++){let Z=$[I][T*S+q],D=Z>=0&&Z<i.length?i[Z].fill:"inside";P[(N*S+T)*b.width+E*S+q]=typeof D=="number"?D:65535}}}}}}function BV(e,t,r,o){let n=e.take("word","inside or outside");if(n.v!=="inside"&&n.v!=="outside")throw new O(n.line,n.col,"family texture: expected inside or outside");let i=e.peek()?.t==="block"?e.take("block","texture rows"):null;e.done(),As(e,"family texture",["from","frame"]);let s=r.tile,a=e.opts.get("from"),c=e.opts.get("frame"),l,u=1;if(i)l=i.rows.map(h=>h.text),c&&(u=Ut(e,"frame",1,4096,1));else{if(!a)throw new O(e.cmd.line,e.cmd.col,"family texture: give from=<tile asset> or the rows in a block");let h=o.asset?.(a.value);if(!h)throw new O(a.line,a.vcol,`family texture: no asset '${a.value}' to copy from`);if(h.width!==s||h.height!==s)throw new O(a.line,a.vcol,`family texture: '${a.value}' is ${h.width}x${h.height}, the family's tiles are ${s}x${s}`);u=Ut(e,"frame",1,h.frameCount,1);let g=be(h,u-1),b=h.palette.entries.map(w=>{let v=t.palette.entries.findIndex(S=>S.name===w.name);return v<0&&(v=t.palette.entries.findIndex(S=>S.hex===w.hex)),v}),y=[...new Set([...g].filter(w=>w!==65535&&b[w]<0).map(w=>h.palette.entries[w].name))];if(y.length)throw new O(a.line,a.vcol,`family texture: ${y.join(", ")} ${y.length>1?"are":"is"} not in palette '${t.palette.name}' (palette add first)`);l=Array.from({length:s},(w,v)=>Array.from({length:s},(S,_)=>{let $=g[v*s+_];return $===65535?" ":t.palette.entries[b[$]].key}).join(""))}if(l.length!==s||l.some(h=>[...h].length!==s))throw new O(i?.line??e.cmd.line,i?.col??e.cmd.col,`family texture: the rows must be ${s} rows of ${s} keys`);let m=new Map(t.palette.entries.map((h,g)=>[h.key,g])),d=new Uint16Array(s*s);l.forEach((h,g)=>[...h].forEach((b,y)=>{let w=b===" "?65535:m.get(b);if(w===void 0){let v=i?.rows[g];throw new O(v?.line??e.cmd.line,(v?.col??e.cmd.col)+y,`family texture: '${b}' is not a key in palette '${t.palette.name}'`)}d[g*s+y]=w}));let[f,p]=zm(r,n.v);return{text:`texture ${n.v}${a?` from=${a.value} frame=${u}`:""} <<
147
+ ${Wt(l)}>>`,run:(h,g)=>{let b=Ic(h,xs);if(b<0)return;let y=h.cels[b][Me(h,g).frame];for(let w=0;w<s;w++)y.set(d.subarray(w*s,w*s+s),(p*s+w)*h.width+f*s)}}}var WV={name:"family",summary:"family band <w>:<colour|outside|inside>\u2026 [radius=<r>] [inset=<n>] [draw=on|off] | family texture inside|outside from=<tile> [frame=<n>] | family detach|attach <variant>|all | family coverage [seed=<n>] [copies=<n>] [fill=on|off] | family cut [textures=on|off]",normalise(e,t){let{doc:r,f:o}=ZV(e,t),n=new we(e,["radius","inset","fillet","jitter","draw","from","frame","seed","copies","fill","textures","detached","frames","cells"]);xA(n);let i=n.take("word","band, texture, detach, attach, coverage or cut"),s=Qe(o);if(i.v==="band"&&n.opts.get("from")){let a=_A(n,r,o,t);return{text:`family ${a.text}`,op:le(c=>a.run(c))}}if(o.bandOf&&["cut","detach","attach"].includes(i.v))throw new O(i.line,i.col,`family ${i.v}: '${r.name}' inherits its band from '${o.bandOf}': do it there, or make the band its own (variant of=${o.bandOf} band=own)`);if(i.v==="band"&&o.bandOf)throw new O(i.line,i.col,`family band: '${r.name}' inherits its band from '${o.bandOf}' (variant of=${o.bandOf} band=inherit): fix the band there, or make it its own (variant of=${o.bandOf} band=own)`);if(i.v==="band"){let a=HV(n,r,o,t);return{text:`family ${a.text}`,op:le(c=>a.run(c))}}if(i.v==="texture"){let a=BV(n,r,o,t);return{text:`family ${a.text}`,op:le(a.run)}}if(i.v==="detach"||i.v==="attach"){let a=n.take("word","a variant name or all");n.done(),As(n,`family ${i.v}`,[]);let c=new Set(s.pieces),l;if(a.v==="all")l=s.variants.map(m=>m.name).filter(m=>!c.has(m));else{if(!s.byName.has(a.v))throw new O(a.line,a.col,`${s.name} has no variant '${a.v}'`);if(c.has(a.v))throw new O(a.line,a.col,`'${a.v}' is a piece: pieces are always drawn by hand (the other variants are built from them)`);l=[a.v]}let u=i.v==="detach";return{text:`family ${i.v} ${a.v}`,op:le(m=>{let d=m.family,f=new Set(d.detached);for(let p of l)u?f.add(p):f.delete(p);d.detached=s.variants.map(p=>p.name).filter(p=>f.has(p))})}}if(i.v==="coverage"){if(n.done(),As(n,"family coverage",["seed","copies","fill"]),!o.mapCols)throw new O(e.line,e.col,"family coverage: this family has no map area (new family \u2026 map=<C>x<R>)");let c=n.opts.get("seed")?Ut(n,"seed",1,2147483647,1):t.newSeed(),l=Ut(n,"copies",1,8,1),u=n.choice("fill",["on","off"],"off")==="on",m=qy(s,o.mapCols,o.mapRows,c,l);if(!m)throw new O(e.line,e.col,`family coverage: no ${o.mapCols}x${o.mapRows} layout with every variant ${l>1?`${l} times `:""}was found from seed ${c} (try another seed, fewer copies, or a bigger map)`);return{text:`family coverage seed=${c} copies=${l} fill=${u?"on":"off"}`,op:le(d=>{let f=d.family;f.terrain=m.cells.slice();let p=mt(f),h=f.tile,g=Ic(d,"template");g<0&&(d.layers.unshift(Dr("template",{reference:!0})),d.cels.unshift(Array.from({length:d.frameCount},()=>new Uint16Array(d.width*d.height).fill(65535))),xr(d,v=>v+1,v=>v),g=0);let b=Ic(d,xs),y=xo(s,h,f.geometry),w=f.geometry;for(let v=0;v<d.frameCount;v++){let S=$A(d,v,p.inside[0],p.inside[1],h),_=$A(d,v,p.outside[0],p.outside[1],h),$=_o(d,m,v),x=d.cels[g][v];if($.variants.forEach((k,P)=>{let I=P%f.mapCols,E=p.mapRow+Math.floor(P/f.mapCols);for(let N=0;N<h;N++)for(let T=0;T<h;T++){let q=k===null?-1:y[k][N*h+T],Z=q>=0&&q<w.bands.length?w.bands[q].fill:null,D=typeof Z=="number"?Z:q<0||Z==="outside"?_:S;x[(E*h+N)*d.width+I*h+T]=D}}),u&&b>=0){let k=d.cels[b][v];for(let P=0;P<$.h;P++)for(let I=0;I<$.w;I++)k[(p.mapRow*h+P)*d.width+I]=$.px[P*$.w+I]}}})}}if(i.v==="cut"){if(n.done(),As(n,"family cut",["textures"]),!o.terrain.length)throw new O(e.line,e.col,"family cut: lay out the coverage map first (family coverage), then paint it");if(!o.geometry.bands.length)throw new O(e.line,e.col,"family cut: the band's widths say what to keep from the map (family band \u2026 draw=off first)");let a=n.choice("textures",["on","off"],"off")==="on",c={cols:o.mapCols,rows:o.mapRows,cells:o.terrain},l=Es(s,c),u=bo(s).filter(m=>!l[m]).map(m=>s.variants[m].name);if(u.length)throw new O(e.line,e.col,`family cut: the map has no tile of ${u.join(", ")} (lay it out again with family coverage)`);return{text:`family cut textures=${a?"on":"off"}`,op:le(m=>{NC(m,a)})}}throw new O(i.line,i.col,"family: expected band, texture, detach, attach, coverage or cut")}},JV=/^(-?\d+),(-?\d+)$/,GV={name:"overlay",summary:"overlay set [mode=cycle|pingpong|wave|sparkle] [on=outside|inside|all] [anchor=<x,y>|centre] [spread=<dx>x<dy>] [every=<n>] [rest=<ticks>] [seed=<n>] (how an overlay plays over a map's tiles)",normalise(e,t){let r=De(e,t);if(!r.overlay)throw new O(e.line,e.col,`overlay: '${r.name}' is not an overlay (new overlay <name> <W>x<H>)`);let o=new we(e,["mode","on","anchor","spread","every","rest","seed"]);xA(o);let n=o.take("word","set");if(n.v!=="set")throw new O(n.line,n.col,"overlay: expected set");o.done();let i=r.overlay,s=o.choice("mode",[...WE],i.mode),a=o.choice("on",["outside","inside","all"],i.on),c=i.anchor,l=o.opts.get("anchor");if(l){let g=JV.exec(l.value);if(l.value==="centre"||l.value==="center")c=null;else if(g)c=[Number(g[1]),Number(g[2])];else throw new O(l.line,l.vcol,"anchor= must be a pixel x,y in the tile, or centre")}let u=i.spread,m=o.opts.get("spread");if(m){let g=/^(\d+)x(\d+)$/.exec(m.value);if(!g)throw new O(m.line,m.vcol,"spread= must be like 4x2 (pixels either way across and down)");u=[Number(g[1]),Number(g[2])]}let d=Ut(o,"every",1,1e3,i.every),f=Ut(o,"rest",0,1e5,i.rest),p=Ut(o,"seed",1,2147483647,i.seed),h={mode:s,on:a,anchor:c,spread:[u[0],u[1]],every:d,rest:f,seed:p};return{text:`overlay set mode=${s} on=${a} anchor=${c?`${c[0]},${c[1]}`:"centre"} spread=${u[0]}x${u[1]} every=${d} rest=${f} seed=${p}`,op:le(g=>{g.overlay={...h,anchor:h.anchor?[h.anchor[0],h.anchor[1]]:null,spread:[h.spread[0],h.spread[1]]}})}}};for(let e of[WV,GV])Te(e);function Os(e,t){let r=De(e,t);if(!r.map)throw new O(e.line,e.col,`${e.name}: '${r.name}' is not a map (new map <name> <C>x<R> tile=<T>)`);return r}function Si(e,t,r){let o=e.layers.findIndex(i=>i.name===t.v),n=e.layers.filter(i=>i.map&&r.includes(i.map.kind)).map(i=>i.name);if(o<0||!r.includes(e.layers[o].map?.kind??""))throw new O(t.line,t.col,`no ${r.join(" or ")} layer '${t.v}' (${n.length?n.join(", "):`none yet: layer add <name> ${r[0]==="terrain"?"terrain=<family>":r[0]}`})`);if(e.layers[o].locked)throw new O(t.line,t.col,`layer '${t.v}' is locked`);return o}function Sk(e,t,r){let o=e.opts.get("layer");if(o)return Si(t,{v:o.value,line:o.line,col:o.vcol},["tiles","objects"]);let n=Me(t,r).layer,i=t.layers[n];if(i.map?.kind!=="tiles"&&i.map?.kind!=="objects")throw new O(e.cmd.line,e.cmd.col,`${e.cmd.name}: your layer '${i.name}' is not a tiles or objects layer (give layer=<name>)`);if(i.locked)throw new O(e.cmd.line,e.cmd.col,`layer '${i.name}' is locked`);return n}function Em(e,t,r){if(!/^-?\d+$/.test(e.value)||Number(e.value)<t||Number(e.value)>r)throw new O(e.line,e.vcol,`${e.key}= must be a whole number ${t}..${r}`);return Number(e.value)}var kk=(e,t)=>{let r=e.opts.get("seed");return r?Em(r,1,2147483647):t.newSeed()},Pc=(e,t,r)=>t>=0&&r>=0&&t<e.width&&r<e.height,vk=["rect","ellipse","brush","fill","paint","clear"],KV={name:"terrain",summary:"terrain <layer> rect <x,y> <W>x<H> | ellipse <x,y> <W>x<H> | brush <x,y>... [size=<n>] | fill <x,y> | paint <x,y> << rows of # and . >> | clear [erase] (paints a terrain layer; the family's scheme picks the edge tiles)",normalise(e,t){let r=Os(e,t),o=new we(e,["size"],["erase"]),n=o.take("word","a terrain layer"),i=Si(r,n,["terrain"]),s=o.take("word",vk.join(", "));if(!vk.includes(s.v))throw new O(s.line,s.col,`terrain: expected ${vk.join(", ")}`);let a=o.flags.length>0,c=a?65535:1,l=o.opts.get("size");if(l&&s.v!=="brush")throw new O(l.line,l.col,"size= goes with brush");let u=a?" erase":"",m=[],d;if(s.v==="rect"||s.v==="ellipse"){let f=o.take("point","a corner x,y"),p=o.take("size","a size WxH");if(o.done(),p.w<1||p.h<1)throw new O(p.line,p.col,"terrain: size must be at least 1x1");m=s.v==="rect"?vo(f.x,f.y,p.w,p.h,!0):gi(f.x,f.y,f.x+p.w-1,f.y+p.h-1,!0),d=`${s.v} ${f.x},${f.y} ${p.w}x${p.h}`}else if(s.v==="brush"){let f=[];for(let g of o.rest()){if(g.t!=="point")throw new O(g.line,g.col,"terrain brush: expected a point x,y");f.push(rn(g))}if(!f.length)throw new O(s.line,s.col+6,"terrain brush: expected a point x,y");let p=l?Em(l,1,32):1,h=-Math.floor((p-1)/2);for(let[g,b]of bc(f,!1))for(let y=0;y<p;y++)for(let w=0;w<p;w++)m.push([g+h+w,b+h+y]);d=`brush ${f.map(rr).join(" ")} size=${p}`}else if(s.v==="fill"){let f=o.take("point","a start x,y");if(o.done(),!Pc(r,f.x,f.y))throw new O(f.line,f.col,`terrain fill: ${f.x},${f.y} is off the ${r.width}x${r.height} map`);return d=`fill ${f.x},${f.y}`,{text:`terrain ${n.v} ${d}${u}`,op:le(p=>py({width:p.width,height:p.height,wrap:!1,pixels:p.cels[i][0]},f.x,f.y,c,!1,4))}}else if(s.v==="paint"){let f=o.take("point","a top-left x,y"),p=o.take("block","a block of rows: '#' terrain, '-' not, '.' leave");if(o.done(),a)throw new O(o.flags[0].line,o.flags[0].col,"terrain paint: the rows say what is terrain ('#') and what is not ('-')");let h=[];return p.rows.forEach((g,b)=>[...g.text].forEach((y,w)=>{if(y==="#")h.push([f.x+w,f.y+b,1]);else if(y==="-")h.push([f.x+w,f.y+b,65535]);else if(y!==".")throw new O(g.line,g.col+w,`terrain paint: '${y}' is not '#' (terrain), '-' (not) or '.' (leave)`)})),{text:`terrain ${n.v} paint ${f.x},${f.y} <<
148
+ ${p.rows.map(g=>` ${g.text}
149
+ `).join("")}>>`,op:le(g=>{let b=g.cels[i][0];for(let[y,w,v]of h)Pc(g,y,w)&&(b[w*g.width+y]=v)})}}else{if(o.done(),a)throw new O(o.flags[0].line,o.flags[0].col,"terrain clear takes no erase");return{text:`terrain ${n.v} clear`,op:le(f=>{f.cels[i][0].fill(65535)})}}return{text:`terrain ${n.v} ${d}${u}`,op:le(f=>{let p=f.cels[i][0];for(let[h,g]of m)Pc(f,h,g)&&(p[g*f.width+h]=c)})}}};function RA(e){if(e.t!=="word")throw new O(e.line,e.col,"expected an asset name (or <family>.<variant>)");let t=/^([a-z][a-z0-9_-]*)(?:\.([a-z][a-z0-9_]*))?$/.exec(e.v);if(!t)throw new O(e.line,e.col,`'${e.v}' is not an asset name (or <family>.<variant>)`);return{name:t[1],variant:t[2]??null}}function xk(e,t,r,o,n,i){let s=e.opts.get("cells"),a=e.opts.get("anchor");if(s||a){if(!s||!a)throw new O((s??a).line,(s??a).col,"give cells= and anchor= together (or neither: they are read from the asset)");let u=/^(\d+)x(\d+)$/.exec(s.value);if(!u||Number(u[1])<1||Number(u[2])<1||Number(u[1])>64||Number(u[2])>64)throw new O(s.line,s.vcol,"cells= must be a footprint like 2x2");let m=/^(\d+),(\d+)$/.exec(a.value),d=Number(u[1]),f=Number(u[2]);if(!m||Number(m[1])>=d||Number(m[2])>=f)throw new O(a.line,a.vcol,`anchor= must be a cell of the ${d}x${f} footprint, like 0,${f-1}`);return{cols:d,rows:f,anchor:[Number(m[1]),Number(m[2])]}}let c=t.asset?.(r);if(!c)throw new O(n.line,n.col,`no asset '${r}' to place`);if(o!==null){if(!c.family)throw new O(n.line,n.col,`'${r}' is not a family, so it has no variant '${o}'`);return{cols:1,rows:1,anchor:[0,0]}}if(c.family||c.overlay||c.map)throw new O(n.line,n.col,`'${r}' is a ${c.kind}: ${c.family?"paint it as a terrain layer (layer add <name> terrain="+r+"), or place one of its variants by name ("+r+".<variant>)":c.overlay?"add it as an overlay layer":"maps do not nest"}`);if(i==="tiles"&&(c.width%c.cellW||c.height%c.cellH))throw new O(n.line,n.col,`'${r}' is ${c.width}x${c.height}, not whole cells of ${c.cellW}x${c.cellH}`);let l=Dn(c);return{cols:l.cols,rows:l.rows,anchor:l.anchor}}function IA(e){return`cells=${e.cols}x${e.rows} anchor=${e.anchor[0]},${e.anchor[1]}`}function jc(e,t){let r=e.map,o=r.entries.findIndex(n=>n.name===t.name&&n.variant===t.variant&&n.cols===t.cols&&n.rows===t.rows&&n.anchor[0]===t.anchor[0]&&n.anchor[1]===t.anchor[1]&&!n.exact==!t.exact);return o<0&&(r.entries.push({...t,anchor:[t.anchor[0],t.anchor[1]]}),o=r.entries.length-1),o}function PA(e,t,r,o,n,i,s){let a=Zr({name:"",variant:null,...r},o,n);if(a.x<0||a.y<0||a.x+a.w>e.width||a.y+a.h>e.height)throw new O(i.line,i.col,`the ${r.cols}x${r.rows} footprint at ${a.x},${a.y} runs off the ${e.width}x${e.height} map`);let{grid:c,placed:l}=vc(e,t);for(let u=a.y;u<a.y+a.h;u++)for(let m=a.x;m<a.x+a.w;m++){let d=c[u*e.width+m];if(d<0)continue;let f=l[d];if(s&&f.x===s.x&&f.y===s.y&&f.layer===s.layer)continue;let p=e.map.entries[f.entry];throw new O(i.line,i.col,`${m},${u} is taken by ${p.name}${p.variant?`.${p.variant}`:""} at ${f.x},${f.y} (on layer ${e.layers[f.layer].name})`)}}var YV={name:"place",summary:"place <asset>|<family>.<variant> <x,y> [layer=<tiles or objects layer>] [cells=<C>x<R> anchor=<x,y>] (by its anchor cell; footprints may not overlap)",normalise(e,t){let r=Os(e,t),o=new we(e,["layer","cells","anchor"]),n=o.take("word","an asset name"),i=RA(n),s=o.take("point","the cell x,y for its anchor");o.done();let a=Sk(o,r,t.by),c=r.layers[a].map.kind;if(i.variant&&c!=="tiles")throw new O(n.line,n.col,"a family's variant goes on a tiles layer");let l=xk(o,t,i.name,i.variant,n,c);PA(r,a,l,s.x,s.y,s);let u={name:i.name,variant:i.variant,...l};return{text:`place ${n.v} ${s.x},${s.y} layer=${r.layers[a].name} ${IA(l)}`,op:le(m=>{m.cels[a][0][s.y*m.width+s.x]=jc(m,u)})}}};function jA(e,t,r,o){let n=e.opts.get("layer"),i=n?[Sk(e,t,r)]:t.layers.map((s,a)=>a).filter(s=>t.layers[s].map?.kind==="objects"||t.layers[s].map?.kind==="tiles").reverse();for(let s of i){let{grid:a,placed:c}=vc(t,s),l=Pc(t,o.x,o.y)?a[o.y*t.width+o.x]:-1;if(l<0)continue;let u=c[l];if(!(u.layer!==s&&n)){if(t.layers[u.layer].locked)throw new O(o.line,o.col,`layer '${t.layers[u.layer].name}' is locked`);return{li:u.layer,x:u.x,y:u.y,entry:t.map.entries[u.entry]}}}throw new O(o.line,o.col,`nothing is placed at ${o.x},${o.y}${n?` on layer ${n.value}`:""}`)}var XV={name:"move",summary:"move <x,y> <x,y> [layer=<layer>] (moves what is placed at the first cell so its anchor is at the second)",normalise(e,t){let r=Os(e,t),o=new we(e,["layer"]),n=o.take("point","a cell x,y with something placed on it"),i=o.take("point","the cell x,y for its anchor");o.done();let s=jA(o,r,t.by,n);return PA(r,s.li,s.entry,i.x,i.y,i,{x:s.x,y:s.y,layer:s.li}),{text:`move ${s.x},${s.y} ${i.x},${i.y} layer=${r.layers[s.li].name}`,op:le(a=>{let c=a.cels[s.li][0],l=c[s.y*a.width+s.x];c[s.y*a.width+s.x]=65535,c[i.y*a.width+i.x]=l})}}},QV={name:"remove",summary:"remove <x,y> [layer=<layer>] (takes away what is placed on that cell)",normalise(e,t){let r=Os(e,t),o=new we(e,["layer"]),n=o.take("point","a cell x,y with something placed on it");o.done();let i=jA(o,r,t.by,n);return{text:`remove ${i.x},${i.y} layer=${r.layers[i.li].name}`,op:le(s=>{s.cels[i.li][0][i.y*s.width+i.x]=65535})}}};function SA(e){let t=e.layers.find(r=>r.name==="band");t&&(t.locked=!1)}function e8(e,t,r,o,n){let i=new dt(o,7170424),s=new Map,a=d=>s.get(d)??n(d),c=e.reduce((d,f)=>d+f.weight,0),l=new Map(e.map(d=>[d.name,0])),u=d=>Math.max(0,d.weight*t.length-l.get(d.name)*c),m=(d,f)=>{let p=d.reduce((g,b)=>g+f(b),0);if(!p)return null;let h=i.nextInt(p);for(let g of d){if(h<f(g))return g;h-=f(g)}return null};return t.map(d=>{let f=d%r,p=f>0?a(d-1):null,h=a(d-r),g=f>0?a(d-r-1):null,b=e.length===2?p&&p===h&&p===g?[p]:[]:[p,h],y=new Set(b.filter(_=>!!_)),w=e.filter(_=>!y.has(_.name)),v=w.length?w:e,S=m(v,u)??m(v,_=>_.weight);return s.set(d,S.name),l.set(S.name,l.get(S.name)+1),S.name})}var t8={name:"tiles",summary:"tiles <tiles layer> fill <asset>|<family>.<variant>|mix=<tile>:<weight>,... [<x,y> <W>x<H>] [replace] [variants=spread|named] [seed=] (lays a one-cell tile on every empty cell of the layer, or of the box; replace also covers one-cell tiles already there; the map picks among the tile's texture variants. mix=: a seeded scatter of several tiles by weight, no two equal neighbours where it can help it; each tile's weight is shared with its texture variants the mix does not name, unless variants=named; each cell shows the tile drawn for it)",normalise(e,t){let r=Os(e,t),o=new we(e,["cells","anchor","mix","seed","variants"],["replace"]),n=o.take("word","a tiles layer"),i=Si(r,n,["tiles"]),s=o.take("word","fill");if(s.v!=="fill")throw new O(s.line,s.col,"tiles: expected fill");let a=o.opts.get("mix"),c=a?null:o.take("word","an asset name (or mix=<tile>:<weight>,...)"),l=c?RA(c):null,u={x:0,y:0,w:r.width,h:r.height};if(o.peek()?.t==="point"){let x=o.take("point","a corner x,y"),k=o.take("size","a size WxH");if(k.w<1||k.h<1)throw new O(k.line,k.col,"tiles fill: the box must be at least 1x1");u={x:x.x,y:x.y,w:k.w,h:k.h}}o.done();let m=o.flags.some(x=>x.v==="replace");for(let x of["seed","variants"])if(!a&&o.opts.get(x))throw new O(o.opts.get(x).line,o.opts.get(x).col,`${x}= goes with mix=`);let d=o.opts.get("variants");if(d&&d.value!=="spread"&&d.value!=="named")throw new O(d.line,d.vcol,"variants= is spread (a tile's weight shared with its texture variants) or named (only the tiles the mix names)");let f=a?Fy(a):null,p=f?d?.value==="named"?f:Ly(f,t):null,h=xk(o,t,p?p[0].name:l.name,l?.variant??null,c??a,"tiles");if(p&&!o.opts.get("cells"))for(let x of p){let k=xk(o,t,x.name,null,a,"tiles"),P=t.asset?.(x.name);if(k.cols!==1||k.rows!==1||P&&P.kind!=="tile")throw new O(a.line,a.vcol,`mix= takes one-cell tiles; '${x.name}' is ${P&&P.kind!=="tile"?`a ${P.kind}`:`${k.cols}x${k.rows} cells`}`)}if(h.cols!==1||h.rows!==1)throw new O(c.line,c.col,`tiles fill lays one-cell tiles; '${l.name}' is ${h.cols}x${h.rows} cells (place it instead)`);let{grid:g,placed:b}=vc(r,i),y=[];for(let x=Math.max(0,u.y);x<Math.min(r.height,u.y+u.h);x++)for(let k=Math.max(0,u.x);k<Math.min(r.width,u.x+u.w);k++){let P=g[x*r.width+k];if(P<0){y.push(x*r.width+k);continue}let I=b[P],E=r.map.entries[I.entry];m&&E.cols===1&&E.rows===1&&I.x===k&&I.y===x&&y.push(x*r.width+k)}let w=`${u.x},${u.y} ${u.w}x${u.h} ${IA(h)}${m?" replace":""}`;if(!p){let x={name:l.name,variant:l.variant,...h};return{text:`tiles ${n.v} fill ${c.v} ${w}`,op:le(k=>{let P=jc(k,x),I=k.cels[i][0];for(let E of y)I[E]=P})}}let v=kk(o,t),S=new Set(y),_=x=>{if(x<0||S.has(x))return null;let k=g[x];return k<0?null:r.map.entries[b[k].entry].name},$=e8(p,y,r.width,v,_);return{text:`tiles ${n.v} fill mix=${p.map(x=>`${x.name}:${x.weight}`).join(",")} ${w} variants=named seed=${v}`,op:le(x=>{let k=new Map,P=E=>k.get(E)??k.set(E,jc(x,{name:E,variant:null,...h,exact:!0})).get(E),I=x.cels[i][0];y.forEach((E,N)=>{I[E]=P($[N])})})}}};function zk(e){let t=[e[0]];for(let r=1;r<e.length;r++){let[o,n]=t[t.length-1],[i,s]=e[r];for(;o!==i;)o+=Math.sign(i-o),t.push([o,n]);for(;n!==s;)n+=Math.sign(s-n),t.push([o,n])}return t}var n8={name:"road",summary:"road <terrain layer> <x,y> <x,y> [<x,y>...] [width=<n>] (lays the terrain along x then y between each pair of points)",normalise(e,t){let r=Os(e,t),o=new we(e,["width"]),n=o.take("word","a terrain layer (a path family)"),i=Si(r,n,["terrain"]),s=[];for(let u of o.rest()){if(u.t!=="point")throw new O(u.line,u.col,"road: expected a point x,y");s.push(rn(u))}if(s.length<2)throw new O(e.line,e.col,"road: give at least two points");let a=o.opts.get("width"),c=a?Em(a,1,8):1,l=zk(s);return{text:`road ${n.v} ${s.map(rr).join(" ")} width=${c}`,op:le(u=>{let m=u.cels[i][0];for(let[d,f]of l)for(let p=0;p<c;p++)for(let h=0;h<c;h++)Pc(u,d+h,f+p)&&(m[(f+p)*u.width+d+h]=1)})}}},EA=/^(\d+)x(\d+):(\d+),(\d+)$/;function r8(e,t,r){let o=new we(e,["count","on","off","minDist","layer","seed","fp"]),n=o.take("word","the assets to scatter (house or tree,bush)"),i=n.v.split(",");for(let E of i)if(!/^[a-z][a-z0-9_-]*$/.test(E))throw new O(n.line,n.col,`'${E}' is not an asset name`);let s=o.peek()?.t==="point"?{p:o.take("point","a corner"),s:o.take("size","a size in cells")}:null;o.done();let a=Sk(o,r,t.by),c=o.opts.get("count");if(!c)throw new O(e.line,e.col,"scatter: missing count=<n>");let l=Em(c,1,1e4),u=o.opts.get("minDist"),m=u?Em(u,0,512):1,d=o.opts.get("on"),f=d?Si(r,{v:d.value,line:d.line,col:d.vcol},["terrain"]):-1,p=o.opts.get("off"),h=p?Si(r,{v:p.value,line:p.line,col:p.vcol},["terrain"]):-1,g=o.opts.get("fp"),b;if(g){let E=g.value.split("/");if(E.length!==i.length)throw new O(g.line,g.vcol,"fp= needs one footprint per asset, like 2x2:0,1/1x1:0,0");b=E.map(N=>{let T=EA.exec(N);if(!T||Number(T[3])>=Number(T[1])||Number(T[4])>=Number(T[2]))throw new O(g.line,g.vcol,"fp= footprints look like 2x2:0,1 (cells, then the anchor)");return{cols:Number(T[1]),rows:Number(T[2]),anchor:[Number(T[3]),Number(T[4])]}})}else b=i.map(E=>{let N=t.asset?.(E);if(!N)throw new O(n.line,n.col,`no asset '${E}' to scatter`);let T=Dn(N);return{cols:T.cols,rows:T.rows,anchor:T.anchor}});let y=kk(o,t),w=s?s.p.x:0,v=s?s.p.y:0,S=s?s.s.w:r.width,_=s?s.s.h:r.height,$=new dt(y,23719),x={...r,cels:r.cels.map((E,N)=>N===a?[E[0].slice()]:E),map:{tile:r.map.tile,entries:r.map.entries.map(E=>({...E}))}},k=f>=0?r.cels[f][0]:null,P=h>=0?r.cels[h][0]:null,I=[];for(let E=0;I.length<l&&E<l*40;E++){let N=$.nextInt(i.length),T=b[N],q=w+$.nextInt(S),Z=v+$.nextInt(_),D=Zr({name:i[N],variant:null,...T},q,Z);if(D.x<w||D.y<v||D.x+D.w>w+S||D.y+D.h>v+_||D.x<0||D.y<0||D.x+D.w>r.width||D.y+D.h>r.height)continue;let V=!0;for(let M=D.y;M<D.y+D.h&&V;M++)for(let L=D.x;L<D.x+D.w;L++)if(k&&k[M*r.width+L]!==1||P&&P[M*r.width+L]===1){V=!1;break}if(!V||I.some(M=>Math.max(Math.abs(M.x-q),Math.abs(M.y-Z))<m))continue;let{grid:F}=vc(x,a);for(let M=D.y;M<D.y+D.h&&V;M++)for(let L=D.x;L<D.x+D.w;L++)if(F[M*r.width+L]>=0){V=!1;break}V&&(x.cels[a][0][Z*r.width+q]=jc(x,{name:i[N],variant:null,...T}),I.push({x:q,y:Z,k:N}))}return{text:`scatter ${n.v}${s?` ${s.p.x},${s.p.y} ${s.s.w}x${s.s.h}`:""} count=${l}${d?` on=${d.value}`:""}${p?` off=${p.value}`:""} minDist=${m} layer=${r.layers[a].name} fp=${b.map(E=>`${E.cols}x${E.rows}:${E.anchor[0]},${E.anchor[1]}`).join("/")} seed=${y}`,op:le(E=>{for(let N of I)E.cels[a][0][N.y*E.width+N.x]=jc(E,{name:i[N.k],variant:null,...b[N.k]})})}}function Rk(e,t,r,o=2,n=!0){let i=(s,a)=>s<0||a<0||s>=t||a>=r?0:e[a*t+s];for(let s=0;s<o;s++){let a=e.slice();for(let c=0;c<r;c++)for(let l=0;l<t;l++){let u=0;for(let m=-1;m<=1;m++)for(let d=-1;d<=1;d++)u+=i(l+d,c+m);a[c*t+l]=u>=5?1:0}e.set(a)}for(let s=0;s<4;s++){let a=!1;for(let c=0;c<r;c++)for(let l=0;l<t;l++){let u=e[c*t+l];[i(l+1,c),i(l-1,c),i(l,c+1),i(l,c-1)].filter(d=>d===u).length<2&&(e[c*t+l]=u?0:1,a=!0)}if(!a)break}if(n)for(let s=0;s<r;s++)for(let a=0;a<t;a++)(a===0||s===0||a===t-1||s===r-1)&&(e[s*t+a]=0)}function kA(e,t,r,o){let n=Math.floor(e/r)+2,i=Math.floor(t/r)+2,s=Array.from({length:n*i},()=>o.nextInt(256)),a=new Int32Array(e*t);for(let c=0;c<t;c++)for(let l=0;l<e;l++){let u=Math.floor(l/r),m=Math.floor(c/r),d=l%r,f=c%r,p=s[m*n+u],h=s[m*n+u+1],g=s[(m+1)*n+u],b=s[(m+1)*n+u+1];a[c*e+l]=Math.floor(((p*(r-d)+h*d)*(r-f)+(g*(r-d)+b*d)*f)/(r*r))}return a}function o8(e,t,r,o=2){let n=kA(e,t,4,r),i=kA(e,t,2,r),s=new Uint8Array(e*t);for(let a=0;a<t;a++)for(let c=0;c<e;c++){let l=2*c-(e-1),u=2*a-(t-1),m=Math.floor(l*l*256/((e-1-2*o)**2||1)+u*u*256/((t-1-2*o)**2||1)),d=(n[a*e+c]*3+i[a*e+c])/4;s[a*e+c]=d-128+200-m>0?1:0}return Rk(s,e,t,2,!0),s}function _k(e,t,r,o){let n=e.slice();for(let i=0;i<r;i++)for(let s=0;s<t;s++)if(e[i*t+s])for(let a=-o;a<=o&&n[i*t+s];a++)for(let c=-o;c<=o;c++){let l=s+c,u=i+a;if(l<0||u<0||l>=t||u>=r||!e[u*t+l]){n[i*t+s]=0;break}}return n}var $k=["island","village","dungeon"];function Ik(e,t,r,o,n){let i=new dt(o,1766);if(e==="dungeon"){let d=new Uint8Array(t*r),f=[];for(let p=0;p<200&&f.length<Math.max(3,Math.floor(t*r/90));p++){let h=4+i.nextInt(5),g=3+i.nextInt(4),b=1+i.nextInt(Math.max(1,t-h-2)),y=1+i.nextInt(Math.max(1,r-g-2));f.some(([w,v,S,_])=>b<w+S+2&&w<b+h+2&&y<v+_+2&&v<y+g+2)||f.push([b,y,h,g])}f.sort((p,h)=>p[0]-h[0]);for(let[p,h,g,b]of f)for(let y=0;y<b;y++)for(let w=0;w<g;w++)d[(h+y)*t+p+w]=1;for(let p=1;p<f.length;p++){let[h,g,b,y]=f[p-1],[w,v,S,_]=f[p];for(let[$,x]of zk([[h+(b>>1),g+(y>>1)],[w+(S>>1),v+(_>>1)]]))d[x*t+$]=1,x+1<r-1&&(d[(x+1)*t+$]=1)}return[d,...Array.from({length:n-1},()=>new Uint8Array(t*r))]}let s=o8(t,r,i,e==="village"?1:2);if(e==="island")return[s,...Array.from({length:n-1},()=>new Uint8Array(t*r))];let a=_k(s,t,r,2);Rk(a,t,r,1,!0);let c=new Uint8Array(t*r),l=_k(a,t,r,1),u=Math.floor(t/2)+i.nextInt(5)-2,m=Math.floor(r/2)+i.nextInt(5)-2;for(let d=0;d<t;d++)l[m*t+d]&&(c[m*t+d]=1);for(let d=0;d<r;d++)l[d*t+u]&&(c[d*t+u]=1);return[s,a,c,...Array.from({length:Math.max(0,n-3)},()=>new Uint8Array(t*r))].slice(0,Math.max(1,n))}function i8(e,t,r,o){let[n,i,s]=Ik(e,t,r,o,3);return e==="village"?i.map((a,c)=>a&&!s[c]?1:0):_k(n,t,r,1)}var s8=/^([a-z][a-z0-9_-]*)(?::(\d+))?$/;function a8(e,t,r,o,n){let i=new dt(n,2846),s=e.width,a=e.height,c=new Uint8Array(s*a),{grid:l}=vc(e,t);for(let d=0;d<s*a;d++)l[d]>=0&&(c[d]=1);let u=r.map((d,f)=>({o:d,k:f})).sort((d,f)=>f.o.fp.cols*f.o.fp.rows-d.o.fp.cols*d.o.fp.rows||d.k-f.k),m=[];for(let{o:d,k:f}of u)for(let p=0;p<d.count;p++)for(let h=0;h<400;h++){let g=i.nextInt(s),b=i.nextInt(a),y=Zr({name:d.name,variant:null,...d.fp},g,b);if(y.x<0||y.y<0||y.x+y.w>s||y.y+y.h>a)continue;let w=!0;for(let v=y.y-1;v<=y.y+y.h&&w;v++)for(let S=y.x-1;S<=y.x+y.w;S++){let _=S>=y.x&&S<y.x+y.w&&v>=y.y&&v<y.y+y.h;if(_&&(!o[v*s+S]||c[v*s+S])){w=!1;break}if(!_&&Pc(e,S,v)&&c[v*s+S]){w=!1;break}}if(w){for(let v=y.y;v<y.y+y.h;v++)for(let S=y.x;S<y.x+y.w;S++)c[v*s+S]=1;m.push({x:g,y:b,k:f});break}}return m}var c8={name:"map",summary:"map gen island|village|dungeon [layers=<terrain layer>,..] [objects=<asset>[:<n>],..] [layer=<objects layer>] [seed=<n>] (lays out the terrain layers for a quick scene and stands the objects on it (default: the objects the manifest says the map uses); edit it after)",normalise(e,t){let r=Os(e,t),o=new we(e,["layers","seed","objects","layer","fp"]),n=o.take("word","gen");if(n.v!=="gen")throw new O(n.line,n.col,"map: expected gen");let i=o.take("word",$k.join(", "));if(!$k.includes(i.v))throw new O(i.line,i.col,`map gen: expected ${$k.join(", ")}`);o.done();let s=o.opts.get("layers"),a=r.layers.flatMap(_=>_.map?.kind==="terrain"?[_.name]:[]),c=s?s.value.split(","):a.slice(0,i.v==="village"?3:1);if(!c.length)throw new O(e.line,e.col,"map gen: the map has no terrain layers (layer add <name> terrain=<family>)");let l=c.map(_=>Si(r,{v:_,line:s?.line??e.line,col:s?.vcol??e.col},["terrain"])),u=o.opts.get("objects"),m=u?{line:u.line,col:u.vcol}:{line:e.line,col:e.col},d=[];if(u)d=u.value.split(",").map(_=>{let $=s8.exec(_);if(!$)throw new O(u.line,u.vcol,"objects= is a list like well,house:2,tree:3");return{name:$[1],count:$[2]?Math.max(1,Math.min(64,Number($[2]))):1}});else{let _=t.defaults?.mapObjects?.(r.name)??[];r.layers.some(x=>x.map?.kind==="objects")&&(d=_.filter(x=>{let k=t.asset?.(x);return!!k&&!k.map&&!k.family&&!k.overlay}).map(x=>({name:x,count:1})))}let f=kk(o,t),p=Ik(i.v,r.width,r.height,f,l.length),h=_=>l.forEach(($,x)=>{_.cels[$][0].set(Uint16Array.from(p[x],k=>k?1:65535))});if(!d.length){if(o.opts.get("layer")||o.opts.get("fp"))throw new O(e.line,e.col,"map gen: layer= and fp= go with objects=");return{text:`map gen ${i.v} layers=${c.join(",")} seed=${f}`,op:le(h)}}let g=o.opts.get("layer"),b;if(g)b=Si(r,{v:g.value,line:g.line,col:g.vcol},["objects"]);else if(b=r.layers.findIndex(_=>_.map?.kind==="objects"),b<0)throw new O(m.line,m.col,"map gen: the map has no objects layer to stand objects on (layer add <name> objects)");if(r.layers[b].locked)throw new O(m.line,m.col,`layer '${r.layers[b].name}' is locked`);let y=o.opts.get("fp"),w;if(y){let _=y.value.split("/");if(_.length!==d.length)throw new O(y.line,y.vcol,"fp= needs one footprint per object, like 2x2:0,1/1x1:0,0");w=_.map($=>{let x=EA.exec($);if(!x||Number(x[3])>=Number(x[1])||Number(x[4])>=Number(x[2]))throw new O(y.line,y.vcol,"fp= footprints look like 2x2:0,1 (cells, then the anchor)");return{cols:Number(x[1]),rows:Number(x[2]),anchor:[Number(x[3]),Number(x[4])]}})}else w=d.map(_=>{let $=t.asset?.(_.name);if(!$)throw new O(m.line,m.col,`map gen: no asset '${_.name}' to stand on the map`);let x=Dn($);return{cols:x.cols,rows:x.rows,anchor:x.anchor}});let v=d.map((_,$)=>({..._,fp:w[$]})),S=a8(r,b,v,i8(i.v,r.width,r.height,f),f);return{text:`map gen ${i.v} layers=${c.join(",")} objects=${d.map(_=>_.count>1?`${_.name}:${_.count}`:_.name).join(",")} layer=${r.layers[b].name} fp=${w.map(_=>`${_.cols}x${_.rows}:${_.anchor[0]},${_.anchor[1]}`).join("/")} seed=${f}`,op:le(_=>{h(_);for(let $ of S)_.cels[b][0][$.y*_.width+$.x]=jc(_,{name:v[$.k].name,variant:null,...v[$.k].fp})})}}},l8=new Set([".","b","r","x"]),u8={name:"footprint",summary:"footprint <C>x<R> [at=<cx,cy>] [anchor=<x,y>] [<< a row per cell row of the art: . b (blocks) r (roof: drawn above actors) x (both) >>] | footprint off",normalise(e,t){let r=De(e,t);if(r.map||r.family||r.overlay)throw new O(e.line,e.col,`footprint: a ${r.kind} is not placed on a map as an object`);let o=new we(e,["at","anchor"]);if(o.peek()?.t==="word"&&o.peek().v==="off")return o.take("word","off"),o.done(),{text:"footprint off",op:le(f=>{f.footprint=null})};if(r.width%r.cellW||r.height%r.cellH)throw new O(e.line,e.col,`footprint: the ${r.width}x${r.height} canvas is not whole cells of ${r.cellW}x${r.cellH} (new \u2026 cell=<W>x<H>)`);let[n,i]=Br(r),s=o.take("size","the footprint in cells, like 2x2"),a=o.peek()?.t==="block"?o.take("block","flag rows"):null;if(o.done(),s.w<1||s.h<1||s.w>n||s.h>i)throw new O(s.line,s.col,`footprint: ${s.w}x${s.h} must fit the art's ${n}x${i} cells`);let c=(f,p,h,g,b)=>{if(!f)return p;let y=/^(\d+),(\d+)$/.exec(f.value);if(!y||Number(y[1])>=g||Number(y[2])>=b)throw new O(f.line,f.vcol,`${f.key}= must be ${h} (x 0..${g-1}, y 0..${b-1})`);return[Number(y[1]),Number(y[2])]},l=c(o.opts.get("at"),[0,i-s.h],"the footprint's top-left art cell",n-s.w+1,i-s.h+1),u=c(o.opts.get("anchor"),[0,s.h-1],"a cell of the footprint",s.w,s.h),m;if(a){if(m=a.rows.map(f=>f.text),m.length!==i||m.some(f=>f.length!==n))throw new O(a.line,a.col,`footprint: the flags are ${i} rows of ${n} (one per cell of the art)`);a.rows.forEach(f=>[...f.text].forEach((p,h)=>{if(!l8.has(p))throw new O(f.line,f.col+h,`footprint: '${p}' is not . b r or x`)}))}else m=Array.from({length:i},(f,p)=>Array.from({length:n},(h,g)=>g>=l[0]&&p>=l[1]&&g<l[0]+s.w&&p<l[1]+s.h?"b":".").join(""));let d={cols:s.w,rows:s.h,at:l,anchor:u,flags:m};return{text:`footprint ${s.w}x${s.h} at=${l[0]},${l[1]} anchor=${u[0]},${u[1]} <<
150
+ ${m.map(f=>` ${f}
151
+ `).join("")}>>`,op:le(f=>{f.footprint={...d,at:[l[0],l[1]],anchor:[u[0],u[1]],flags:[...m]}})}}},m8={name:"variant",summary:"variant of=<asset> [band=inherit|own] | variant off (this asset is a texture variant of another: maps pick among them cell by cell; check variant compares their colour mix; band=inherit: a family variant takes its band from the base, now and after every change to it, and overrides only the textures)",normalise(e,t){let r=De(e,t),o=new we(e,["of","band"]);if(o.peek()?.t==="word"&&o.peek().v==="off")return o.take("word","off"),o.done(),{text:"variant off",op:le(s=>{s.variantOf=null,s.family?.bandOf&&(delete s.family.bandOf,SA(s))})};o.done();let n=o.opts.get("of");if(!n)throw new O(e.line,e.col,"variant: give of=<the asset this is a variant of> (or off)");if(!/^[a-z][a-z0-9_-]*$/.test(n.value))throw new O(n.line,n.vcol,`'${n.value}' is not an asset name`);if(n.value===r.name)throw new O(n.line,n.vcol,"an asset is not a variant of itself");if(r.map)throw new O(e.line,e.col,"variant: a map has no variants");let i=o.choice("band",["inherit","own"],"own");if(i==="inherit"){if(!r.family)throw new O(o.opts.get("band").line,o.opts.get("band").col,"variant: band=inherit is for a family's texture variant");let s=t.asset?.(n.value);if(s&&(!s.family||s.family.scheme!==r.family.scheme||s.family.tile!==r.family.tile))throw new O(n.line,n.vcol,`variant: '${n.value}' is not a ${r.family.scheme} family of ${r.family.tile}px tiles, so its band does not fit`)}return{text:`variant of=${n.value}${i==="inherit"?" band=inherit":""}`,op:le(s=>{if(s.variantOf=n.value,!!s.family)if(i==="inherit"){s.family.bandOf=n.value;let a=s.layers.find(c=>c.name==="band");a&&(a.locked=!0)}else s.family.bandOf&&(delete s.family.bandOf,SA(s))})}}};for(let e of[KV,t8,YV,XV,QV,n8,c8,u8,m8])Te(e);var zA=Gr.get("scatter");Te({name:"scatter",summary:`${zA.summary} | (maps) scatter <asset>[,<asset>..] [<x,y> <W>x<H>] count=<n> [on=<terrain layer>] [off=<terrain layer>] [minDist=<n>] [layer=<objects layer>] [seed=<n>]`,normalise(e,t){return t.doc?.map?r8(e,t,t.doc):zA.normalise(e,t)}});var d8={name:"import",summary:`import <x,y> [from="<file>"] [blob=<sha256>] << rows of palette keys ('.' is transparent) >> | import <x,y> asset=<name> region=<x,y,WxH> [layer=<layer>] (an imported image's pixels, or a region of another asset's art (one layer of it, or its flat art); replaces the rectangle on your layer and frame)`,normalise(e,t){let r=Be(e,t),o=new we(e,["from","blob","asset","region","layer"]),n=o.take("point","a top-left corner x,y"),i=o.peek()?.t==="block"?o.take("block","the image's rows in a block"):null;o.done();let s=o.opts.get("from")?.value,a=o.opts.get("blob");if(a&&!/^[0-9a-f]{8,64}$/.test(a.value))throw new O(a.line,a.vcol,"blob= is the image's sha256 in hex");let c=o.opts.get("asset"),l,u;if(c){for(let k of["from","blob"])if(o.opts.get(k))throw new O(o.opts.get(k).line,o.opts.get(k).col,`import: asset= takes no ${k}=`);if(i)throw new O(i.line,i.col,"import: asset= reads the rows from the asset");let h=t.asset?.(c.value);if(!h)throw new O(c.line,c.vcol,`import: no asset '${c.value}' to read (not this one)`);let g=o.opts.get("region"),b=g?vy(g.value):null;if(!g||!b)throw new O(g?.line??e.line,g?.vcol??e.col,`import: give region=<x,y,WxH> of '${c.value}' (or "x,y WxH")`);let{x:y,y:w,w:v,h:S}=b;if(v<1||S<1||y+v>h.width||w+S>h.height)throw new O(g.line,g.vcol,`import: region ${g.value} is outside '${h.name}' (${h.width}x${h.height})`);let _=o.opts.get("layer"),$=_?h.layers.findIndex(k=>k.name===_.value):-1;if(_&&$<0)throw new O(_.line,_.vcol,`import: '${h.name}' has no layer '${_.value}'`);let x=$>=0?h.cels[$][0]:be(h,0);l=Array.from({length:S},(k,P)=>Array.from({length:v},(I,E)=>{let N=x[(w+P)*h.width+y+E];if(N===65535)return".";let T=h.palette.entries[N].name,q=r.palette.entries.findIndex(Z=>Z.name===T);if(q<0)throw new O(c.line,c.vcol,`import: '${h.name}' uses ${T}, which palette '${r.palette.name}' does not have`);return r.palette.entries[q].key}).join("")),u=l.map(()=>({line:e.line,col:e.col})),s=`${h.name}${$>=0?`:${h.layers[$].name}`:""} ${y},${w},${v}x${S}`}else{for(let h of["region","layer"])if(o.opts.get(h))throw new O(o.opts.get(h).line,o.opts.get(h).col,`import: ${h}= goes with asset=`);if(!i)throw new O(e.line,e.col,"import: expected the image's rows in a block (or asset= region=)");l=i.rows.map(h=>h.text),u=i.rows}let m=new Map(r.palette.entries.map((h,g)=>[h.key,g])),d=l.map((h,g)=>[...h].map((b,y)=>{if(b===".")return 65535;let w=m.get(b);if(w===void 0)throw new O(u[g].line,u[g].col+y,`import: '${b}' is not a key in palette '${r.palette.name}'`);return w})),f=Math.max(0,...d.map(h=>h.length)),p=`${s?` from=${tn(s)}`:""}${a?` blob=${a.value}`:""}`;return{text:`import ${n.x},${n.y}${p} <<
152
+ ${Wt(l)}>>`,op:le((h,g)=>{let b=Me(h,g),y=h.cels[b.layer][b.frame];d.forEach((w,v)=>{let S=n.y+v;if(!(S<0||S>=h.height))for(let _=0;_<f;_++){let $=n.x+_;$<0||$>=h.width||(y[S*h.width+$]=w[_]??65535)}})})}}};function Pk(e,t,r,o){return Array.from({length:r},(n,i)=>Array.from({length:t},(s,a)=>{let c=e[i*t+a];return c===65535?".":o[c]}).join(""))}function f8(e,t){let r=e.width,o=e.height;e.cels=e.cels.map(n=>{let i=new Map;return n.map(s=>i.get(s)??i.set(s,xm(s,r,o,t)).get(s))});for(let n of Object.values(e.stamps))n.px=xm(n.px,n.w,n.h,t),n.w*=t,n.h*=t;e.width*=t,e.height*=t,e.cellW*=t,e.cellH*=t,e.notes=e.notes.map(n=>({...n,x:n.x*t,y:n.y*t,w:n.w*t,h:n.h*t})),e.pivot&&(e.pivot=[e.pivot[0]*t+(t>>1),e.pivot[1]*t+t-1]),e.ground!==null&&(e.ground=e.ground*t+t-1);for(let n of Object.keys(e.ctx))e.ctx[n]={...e.ctx[n],sel:null,mirror:null}}var p8={name:"scale",summary:"scale <n> (the whole document n times larger, nearest neighbour: every layer, frame and stamp, the cell grid, pivot, ground and notes; selections and symmetry are dropped)",normalise(e,t){let r=De(e,t),o=new we(e,[]),n=o.take("int","a factor 2..8");if(o.done(),n.v<2||n.v>8)throw new O(n.line,n.col,"scale: the factor is 2..8");if(r.map||r.family)throw new O(e.line,e.col,`scale: a ${r.kind} is not scaled (its cells are tiles)`);if(r.width*n.v>4096||r.height*n.v>4096)throw new O(n.line,n.col,`scale: ${r.width*n.v}x${r.height*n.v} is over 4096`);return{text:`scale ${n.v}`,op:le(i=>f8(i,n.v))}}},h8={name:"density",summary:"density of=<asset> d=<2|4|n> | density off (this asset is <asset> at n times its size: the density check reduces it and compares; exports write it as that level)",normalise(e,t){let r=De(e,t),o=new we(e,["of","d"]);if(o.peek()?.t==="word"&&o.peek().v==="off")return o.take("word","off"),o.done(),{text:"density off",op:le(c=>{c.densityOf=null})};o.done();let n=o.opts.get("of"),i=o.opts.get("d");if(!n||!i)throw new O(e.line,e.col,"density: give of=<the base asset> d=<times its size> (or off)");if(!/^[a-z][a-z0-9_-]*$/.test(n.value))throw new O(n.line,n.vcol,`'${n.value}' is not an asset name`);if(n.value===r.name)throw new O(n.line,n.vcol,"an asset is not a density of itself");if(r.map)throw new O(e.line,e.col,"density: a map has no densities");let s=Ct(i,2,8);if(r.width%s||r.height%s)throw new O(i.line,i.vcol,`density: ${r.width}x${r.height} is not a whole ${s} times a base size`);let a=t.asset?.(n.value);if(a&&(a.width*s!==r.width||a.height*s!==r.height))throw new O(i.line,i.vcol,`density: '${n.value}' is ${a.width}x${a.height}; ${s} times that is ${a.width*s}x${a.height*s}, not ${r.width}x${r.height}`);return{text:`density of=${n.value} d=${s}`,op:le(c=>{c.densityOf={of:n.value,d:s}})}}};for(let e of[d8,p8,h8])Te(e);var g8={name:"mark",summary:`mark <name> ["text"] (names this point on the tape; reviewed, approved and rejected set the asset's status)`,normalise(e,t){De(e,t);let r=new we(e,[]),o=r.take("word","a mark name (reviewed, approved, rejected, or your own)"),n=r.peek()?.t==="string"?r.take("string","the text in quotes"):null;if(r.done(),!/^[a-z][a-z0-9_-]*$/.test(o.v))throw new O(o.line,o.col,"mark names use a-z, 0-9, _ and -, starting with a letter");let i=n?n.v.trim():"";if(n&&i.length>1e3)throw new O(n.line,n.col,"mark: the text is longer than 1000 characters");let s=t.seq;return{text:`mark ${o.v}${i?` ${tn(i)}`:""}`,op:le((a,c)=>{a.marks=[...a.marks,{name:o.v,seq:s,by:c,text:i,art:hc(a)}]})}}};Te(g8);function TA(e,t){if(!t.font)throw new O(e.line,e.col,`${e.name}: '${t.name}' is a ${t.kind}, not a font (new font <name> <W>x<H> chars=\u2026)`);return t}function y8(e,t){if(!e)throw new O(t.line,t.col+t.name.length+1,'glyph: expected a character (a letter or digit, U+XXXX, or "c")');let r=e.t==="word"||e.t==="string"?e.v:e.t==="int"?String(e.v):"",o=/^U\+([0-9A-Fa-f]{1,6})$/.exec(r);if(e.t!=="string"&&o)return parseInt(o[1],16);if([...r].length===1&&(e.t==="string"||/^[A-Za-z0-9]$/.test(r)))return r.codePointAt(0);throw new O(e.line,e.col,`glyph: '${r}' is not one character (letters and digits as themselves; anything else as U+XXXX or "c")`)}var b8={name:"glyph",summary:`glyph <char> [advance=<n>|auto] [<< rows of palette keys >>] (a font's glyph: the rows replace its cell from the top-left on your layer and frame; <char> is a letter or digit, U+XXXX or "c"; advance= sets its width, auto measures its ink)`,normalise(e,t){let r=TA(e,Be(e,t)),o=new we(e,["advance"]),n=y8(o.positional[0],e),i=o.rest()[0],s=o.positional.find(f=>f.t==="block");for(let f of o.positional.slice(1))if(f!==s)throw new O(f.line,f.col,`glyph: unexpected '${f.t==="word"?f.v:"\u2026"}'`);let a=r.font.chars.indexOf(n);if(a<0)throw new O(i.line,i.col,`glyph: ${go(n)} is not one of the font's characters`);let c=o.opts.get("advance"),l=null;if(c)if(c.value==="auto")l="auto";else if(/^\d+$/.test(c.value)&&Number(c.value)<=1024)l=Number(c.value);else throw new O(c.line,c.vcol,"advance= is a width in pixels (0..1024) or auto");if(!s&&l===null)throw new O(e.line,e.col,"glyph: give rows (<< \u2026 >>), advance= or both");let u=new Map(r.palette.entries.map((f,p)=>[f.key,p])),m=s?s.rows.map(f=>{if([...f.text].length>r.cellW)throw new O(f.line,f.col+r.cellW,`glyph: a row is wider than the ${r.cellW} px cell`);return[...f.text].map((p,h)=>{if(p==="."||p===" ")return 65535;let g=u.get(p);if(g===void 0)throw new O(f.line,f.col+h,`glyph: '${p}' is not a key in palette '${r.palette.name}'`);return g})}):null;if(m&&m.length>r.cellH)throw new O(s.line,s.col,`glyph: ${m.length} rows; the cell is ${r.cellH} high`);return{text:`glyph ${go(n)}${l!==null?` advance=${l}`:""}${s?` <<
153
+ ${Wt(s.rows.map(f=>f.text))}>>`:""}`,op:le((f,p)=>{if(m){let h=Me(f,p),g=f.cels[h.layer][h.frame],[b,y]=ny(f,a);for(let w=0;w<f.cellH;w++)for(let v=0;v<f.cellW;v++)g[(y+w)*f.width+b+v]=m[w]?.[v]??65535}l==="auto"?delete f.font.advances[n]:l!==null&&(f.font.advances[n]=l)})}}},w8={name:"font",summary:"font set [baseline=<row>] [line=<px>] [spacing=<px>] (a font's metrics: the cell row glyphs stand on, the line height, the pixels after each advance)",normalise(e,t){let r=TA(e,De(e,t)),o=new we(e,["baseline","line","spacing"]),n=o.take("word","set");if(n.v!=="set")throw new O(n.line,n.col,"font: expected 'set'");o.done();let i=r.font,s=(u,m)=>{let d=o.opts.get(u);if(!d)return i[u];if(!/^\d+$/.test(d.value)||Number(d.value)>m||u==="line"&&Number(d.value)<1)throw new O(d.line,d.vcol,`${u}= must be ${u==="line"?1:0}..${m}`);return Number(d.value)};if(!o.opts.size)throw new O(e.line,e.col,"font set: give baseline=, line= or spacing=");let a=s("baseline",r.cellH-1),c=s("line",1024),l=s("spacing",64);return{text:`font set baseline=${a} line=${c} spacing=${l}`,op:le(u=>{Object.assign(u.font,{baseline:a,line:c,spacing:l})})}}},v8={name:"icon",summary:"icon mode=tone|full|channel (how an icon is exported: tone art is recoloured by the game through role entries; full art is drawn as is; channel art is pure-RGB channel masks)",normalise(e,t){let r=De(e,t);if(r.kind!=="icon")throw new O(e.line,e.col,`icon: '${r.name}' is a ${r.kind}, not an icon`);let o=new we(e,["mode"]);if(o.done(),!o.opts.get("mode"))throw new O(e.line,e.col,`icon: give mode=${_S.join("|")}`);let n=o.choice("mode",[..._S],"full");return{text:`icon mode=${n}`,op:le(i=>{i.iconMode=n})}}};for(let e of[b8,w8,v8])Te(e);var ft=class extends Error{},$8=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],x8=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],_8=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],S8=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],k8=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function Tm(e,t){let r=new Uint16Array(16);for(let i=0;i<t;i++)r[e[i]]++;r[0]=0;let o=new Uint16Array(16);for(let i=1;i<16;i++)o[i]=o[i-1]+r[i-1];let n=new Uint16Array(t);for(let i=0;i<t;i++)e[i]&&(n[o[e[i]]++]=i);return{counts:r,symbols:n}}function z8(e,t=0){let r=t,o=0,n=0,i=new Uint8Array(Math.max(1024,e.length*4)),s=0,a=f=>{if(s+f<=i.length)return;let p=i.length*2;for(;p<s+f;)p*=2;let h=new Uint8Array(p);h.set(i.subarray(0,s)),i=h},c=f=>{for(;n<f;){if(r>=e.length)throw new ft("compressed data ends early");o|=e[r++]<<n,n+=8}let p=o&(1<<f)-1;return o>>>=f,n-=f,p},l=f=>{let p=0,h=0,g=0;for(let b=1;b<16;b++){p|=c(1);let y=f.counts[b];if(p-y<h)return f.symbols[g+(p-h)];g+=y,h+=y,h<<=1,p<<=1}throw new ft("bad compressed data (no such code)")},u=new Uint8Array(288);for(let f=0;f<288;f++)u[f]=f<144?8:f<256?9:f<280?7:8;let m=Tm(u,288),d=Tm(new Uint8Array(30).fill(5),30);for(;;){let f=c(1),p=c(2);if(p===0){if(o=0,n=0,r+4>e.length)throw new ft("compressed data ends early");let h=e[r]|e[r+1]<<8;if(r+=4,r+h>e.length)throw new ft("compressed data ends early");a(h),i.set(e.subarray(r,r+h),s),s+=h,r+=h}else if(p===1||p===2){let h=m,g=d;if(p===2){let b=c(5)+257,y=c(5)+1,w=c(4)+4,v=new Uint8Array(19);for(let $=0;$<w;$++)v[k8[$]]=c(3);let S=Tm(v,19),_=new Uint8Array(b+y);for(let $=0;$<b+y;){let x=l(S);if(x<16)_[$++]=x;else{let k=0,P=0;if(x===16){if(!$)throw new ft("bad compressed data (repeat with nothing before)");P=_[$-1],k=3+c(2)}else x===17?k=3+c(3):k=11+c(7);if($+k>b+y)throw new ft("bad compressed data (too many lengths)");_.fill(P,$,$+k),$+=k}}h=Tm(_.subarray(0,b),b),g=Tm(_.subarray(b),y)}for(;;){let b=l(h);if(b<256){a(1),i[s++]=b;continue}if(b===256)break;let y=b-257;if(y>=29)throw new ft("bad compressed data (length code)");let w=$8[y]+c(x8[y]),v=l(g);if(v>=30)throw new ft("bad compressed data (distance code)");let S=_8[v]+c(S8[v]);if(S>s)throw new ft("bad compressed data (distance too far back)");a(w);for(let _=0;_<w;_++,s++)i[s]=i[s-S]}}else throw new ft("bad compressed data (block type 3)");if(f)return i.slice(0,s)}}function Tk(e){if(e.length<2||(e[0]&15)!==8||(e[0]<<8|e[1])%31)throw new ft("not zlib data");return z8(e,2)}var jk=(e,t)=>(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0;function Kr(e){let t=[137,80,78,71,13,10,26,10];if(e.length<8||t.some(($,x)=>e[x]!==$))throw new ft("not a PNG file");let r=8,o=0,n=0,i=0,s=0,a=0,c=null,l=null,u=[];for(;r+8<=e.length;){let $=jk(e,r),x=String.fromCharCode(e[r+4],e[r+5],e[r+6],e[r+7]),k=e.subarray(r+8,r+8+$);if(k.length<$)throw new ft(`PNG chunk ${x} is cut short`);if(x==="IHDR")o=jk(k,0),n=jk(k,4),i=k[8],s=k[9],a=k[12];else if(x==="PLTE")c=k;else if(x==="tRNS")l=k;else if(x==="IDAT")u.push(k);else if(x==="IEND")break;r+=12+$}if(!o||!n)throw new ft("PNG has no IHDR");if(a)throw new ft("interlaced PNGs are not read; save it without interlacing");let m={0:1,2:3,3:1,4:2,6:4}[s];if(!m)throw new ft(`PNG colour type ${s} is not known`);if(s===3&&!c)throw new ft("indexed PNG without a palette");let d=new Uint8Array(u.reduce(($,x)=>$+x.length,0)),f=0;for(let $ of u)d.set($,f),f+=$.length;let p=Tk(d),h=Math.max(1,m*i>>3),g=o*m*i+7>>3;if(p.length<n*(g+1))throw new ft("PNG image data is cut short");let b=new Uint8Array(g),y=new Uint8Array(g),w=new Uint8Array(o*n*4),v=($,x)=>{if(i===8)return $[x];if(i===16)return $[x*2];let k=8/i,P=$[Math.floor(x/k)],I=8-i*(x%k+1);return P>>I&(1<<i)-1},S=$=>i>=8?$:Math.floor($*255/((1<<i)-1)),_=$=>l&&l.length>=$*2+2?l[$*2]<<8|l[$*2+1]:-1;for(let $=0;$<n;$++){let x=p[$*(g+1)],k=p.subarray($*(g+1)+1,($+1)*(g+1));for(let P=0;P<g;P++){let I=P>=h?b[P-h]:0,E=y[P],N=P>=h?y[P-h]:0,T=k[P];if(x===1)T+=I;else if(x===2)T+=E;else if(x===3)T+=I+E>>1;else if(x===4){let q=I+E-N,Z=Math.abs(q-I),D=Math.abs(q-E),V=Math.abs(q-N);T+=Z<=D&&Z<=V?I:D<=V?E:N}else if(x!==0)throw new ft(`PNG filter ${x} is not known`);b[P]=T&255}for(let P=0;P<o;P++){let I=($*o+P)*4,E,N,T,q=255;if(s===3){let Z=v(b,P);E=c[Z*3]??0,N=c[Z*3+1]??0,T=c[Z*3+2]??0,l&&Z<l.length&&(q=l[Z])}else if(s===0||s===4){let Z=i===16?b[P*m*2]<<8|b[P*m*2+1]:v(b,P*m);E=N=T=S(v(b,P*m)),s===4?q=v(b,P*m+1):_(0)===Z&&(q=0)}else E=v(b,P*m),N=v(b,P*m+1),T=v(b,P*m+2),s===6?q=v(b,P*m+3):l&&i===8&&l[1]===E&&l[3]===N&&l[5]===T&&(q=0);w[I]=E,w[I+1]=N,w[I+2]=T,w[I+3]=q}y.set(b)}return{width:o,height:n,data:w}}var CA=128;function R8(e,t,r,o,n,i){let s=e+o>>1,a=e-o,c=t-n,l=r-i;return((512+s)*a*a>>8)+4*c*c+((767-s)*l*l>>8)}function ir(e,t,r){let o=t.entries.map((l,u)=>it(r?.[u]??l.hex)),n=new Map;o.forEach(([l,u,m],d)=>{let f=l<<16|u<<8|m;n.has(f)||n.set(f,d)});let i=new Map,s=new Uint16Array(e.width*e.height),a=0,c=0;for(let l=0;l<s.length;l++){let u=e.data[l*4],m=e.data[l*4+1],d=e.data[l*4+2];if(e.data[l*4+3]<CA){s[l]=65535;continue}let p=u<<16|m<<8|d,h=n.get(p);if(h!==void 0){s[l]=h;continue}let g=i.get(p);if(!g){let b=0,y=1/0;o.forEach(([w,v,S],_)=>{let $=R8(u,m,d,w,v,S);$<y&&(y=$,b=_)}),i.set(p,g=[b,y])}s[l]=g[0],a++,c=Math.max(c,g[1])}return{px:s,inexact:a,worst:c}}var Ek=e=>e.toString(16).padStart(2,"0");function AA(e,t,r=256){let o=new Map,n=[];for(let c of t)for(let l=0;l<c.width*c.height;l++){if(c.data[l*4+3]<CA)continue;let u=c.data[l*4]<<16|c.data[l*4+1]<<8|c.data[l*4+2];o.has(u)||n.push(u),o.set(u,(o.get(u)??0)+1)}let i=n;if(n.length>r){let c=new Set([...n].sort((l,u)=>o.get(u)-o.get(l)||l-u).slice(0,r));i=n.filter(l=>c.has(l))}let s=ws(i.length),a=i.map((c,l)=>({key:s[l],name:`c${l}`,hex:`#${Ek(c>>16)}${Ek(c>>8&255)}${Ek(c&255)}`}));return bs({name:e,entries:a,ramps:{}})}function Ck(e,t){return e.entries.map(r=>r.role&&t?.[r.role]?t[r.role]:r.hex)}function Ky(e,t,r,o){let n=new Uint8Array(t*r*4),i=o.map(it);for(let s=0;s<t*r;s++){let a=e[s];if(a===65535)continue;let c=i[a];n[s*4]=c[0],n[s*4+1]=c[1],n[s*4+2]=c[2],n[s*4+3]=255}return{width:t,height:r,data:n}}function zo(e,t,r,o,n){let i=new Uint8Array(o*n*4);for(let s=0;s<n;s++){let a=r+s;if(!(a<0||a>=e.height))for(let c=0;c<o;c++){let l=t+c;l<0||l>=e.width||i.set(e.data.subarray((a*e.width+l)*4,(a*e.width+l)*4+4),(s*o+c)*4)}}return{width:o,height:n,data:i}}var Cm=.8,Am=.85;function MA(e,t){let r=e.width,o=e.height,n=e.data,i=t==="x"?r-1:o-1,s=new Float64Array(Math.max(0,i)),a=t==="x"?4:r*4;for(let c=0;c<(t==="x"?o:o-1);c++)for(let l=0;l<(t==="x"?r-1:r);l++){let u=(c*r+l)*4,m=n[u+3]<128,d=n[u+a+3]<128,f=m||d?m===d?0:765:Math.abs(n[u]-n[u+a])+Math.abs(n[u+1]-n[u+a+1])+Math.abs(n[u+2]-n[u+a+2]);s[t==="x"?l:c]+=f}return s}function Ak(e,t,r){let o=2*Math.PI/t,n=Math.cos(o),i=Math.sin(o),s=n,a=i,c=0,l=0;for(let d=0;d<e.length;d++){c+=e[d]*s,l+=e[d]*a;let f=s*n-a*i;a=s*i+a*n,s=f}let u=Math.hypot(c,l)/(r||1),m=Math.atan2(l,c)/(2*Math.PI)*t;return m<0&&(m+=t),{m:u,o:m}}function OA(e,t,r){let o=MA(e,t),n=t==="x"?e.width:e.height,i=o.reduce((h,g)=>h+g,0),s=i/Math.max(1,o.length);for(let h=0;h<o.length;h++)o[h]-=s;let a=r?Math.max(1.5,r*.85):1.5,c=r?Math.min(n/2,r*1.15):Math.min(64,n/8),l=1+.25/Math.max(16,n),u=[];for(let h=a;h<=c;h*=l)u.push({p:h,...Ak(o,h,i)});if(!u.length)return{pitch:a,offset:0,score:0};let m=Math.max(...u.map(h=>h.m)),d=u.filter((h,g)=>h.m>=.5*m&&h.m>=(u[g-1]?.m??-1)&&h.m>=(u[g+1]?.m??-1)),f=(r?void 0:d.at(-1))??u.find(h=>h.m===m),p=f;for(let h=f.p*(1-1/n);h<=f.p*(1+1/n);h*=1+.02/n){let g=Ak(o,h,i);g.m>p.m&&(p={p:h,...g})}return{pitch:p.p,offset:p.o,score:p.m}}function NA(e,t,r){let o=MA(e,t),n=o.reduce((a,c)=>a+c,0),i=n/Math.max(1,o.length);for(let a=0;a<o.length;a++)o[a]-=i;let s=Ak(o,r,n);return{pitch:r,offset:s.o,score:s.m}}function I8(e,t,r){if(r){let c=NA(e,"x",e.width/r.cols),l=NA(e,"y",e.height/r.rows),u=m=>m.offset>m.pitch/2?-1:0;return{x:c,y:l,cols:r.cols,rows:r.rows,i0:u(c),j0:u(l)}}let o=OA(e,"x",t?.x),n=OA(e,"y",t?.y),i=(c,l)=>{let u=f=>Math.min(l,c.offset+(f+1)*c.pitch)-Math.max(0,c.offset+f*c.pitch),m=u(-1)>=c.pitch/2?-1:0,d=m;for(;u(d+1)>=c.pitch/2;)d++;return{k0:m,n:d-m+1}},s=i(o,e.width),a=i(n,e.height);return{x:o,y:n,cols:s.n,rows:a.n,i0:s.k0,j0:a.k0}}function P8(e){let t=e.sort((r,o)=>r-o);return t.length%2?t[(t.length-1)/2]:(t[t.length/2-1]+t[t.length/2])/2}function j8(e,t){let r=e.width,o=e.height,n=e.data,i={width:t.cols,height:t.rows,data:new Uint8Array(t.cols*t.rows*4)},s=(g,b,y,w)=>{let v=g.offset+b*g.pitch,S=v+g.pitch,_=Math.ceil(v+g.pitch*w),$=Math.floor(S-g.pitch*w-1e-9);return _=Math.max(0,_),$=Math.min(y-1,$),$<_&&(_=$=Math.min(y-1,Math.max(0,Math.floor((v+S)/2)))),[_,$]};for(let g=0;g<t.rows;g++)for(let b=0;b<t.cols;b++){let[y,w]=s(t.x,t.i0+b,r,.25),[v,S]=s(t.y,t.j0+g,o,.25),_=[[],[],[],[]];for(let $=v;$<=S;$++)for(let x=y;x<=w;x++)for(let k=0;k<4;k++)_[k].push(n[($*r+x)*4+k]);for(let $=0;$<4;$++)i.data[(g*t.cols+b)*4+$]=Math.round(P8(_[$]))}let a=new Float64Array(t.cols*t.rows*3),c=new Float64Array(t.cols*t.rows),l=(g,b,y,w)=>{let v=Math.floor((g+.5-b.offset)/b.pitch)-y;return v>=0&&v<w?v:-1},u=Int32Array.from({length:r},(g,b)=>l(b,t.x,t.i0,t.cols)),m=Int32Array.from({length:o},(g,b)=>l(b,t.y,t.j0,t.rows)),d=0,f=[0,0,0];for(let g=0;g<o;g++)for(let b=0;b<r;b++){if(u[b]<0||m[g]<0)continue;let y=m[g]*t.cols+u[b],w=(g*r+b)*4;for(let v=0;v<3;v++)a[y*3+v]+=n[w+v],f[v]+=n[w+v];c[y]++,d++}let p=0,h=0;for(let g=0;g<o;g++)for(let b=0;b<r;b++){if(u[b]<0||m[g]<0)continue;let y=m[g]*t.cols+u[b],w=(g*r+b)*4;for(let v=0;v<3;v++){let S=n[w+v];p+=(S-f[v]/d)**2,h+=(S-a[y*3+v]/c[y])**2}}return{img:i,r2:p>0?1-h/p:1}}function E8(e,t){let r=e.width*e.height,o=new Int32Array(r),n=new Map;for(let l=0;l<e.height;l++)for(let u=0;u<e.width;u++){let m=Math.min(t.width-1,Math.floor((u+.5)*t.width/e.width)),f=(Math.min(t.height-1,Math.floor((l+.5)*t.height/e.height))*t.width+m)*4,p=t.data[f+3]<128?-1:t.data[f]<<16|t.data[f+1]<<8|t.data[f+2];n.has(p)||n.set(p,n.size),o[l*e.width+u]=n.get(p)}let i=n.size;if(i<2)return null;let s=new Float64Array(i*3),a=new Float64Array(i);for(let l=0;l<r;l++){for(let u=0;u<3;u++)s[o[l]*3+u]+=e.data[l*4+u];a[o[l]]++}for(let l=0;l<i;l++)for(let u=0;u<3;u++)s[l*3+u]/=a[l];let c=0;for(let l=0;l<r;l++){let u=-1,m=1/0;for(let d=0;d<i;d++){let f=0;for(let p=0;p<3;p++)f+=(e.data[l*4+p]-s[d*3+p])**2;f<m&&(m=f,u=d)}u===o[l]&&c++}return c/r}function DA(e,t,r={}){let o=I8(e,r.hint,r.cells),{img:n,r2:i}=j8(e,o),s=ir(n,t),a=r.layout?E8(n,r.layout):null,c=[];return i<Cm&&c.push(`block R\xB2 ${i.toFixed(2)} is below ${Cm}`),a!==null&&a<Am&&c.push(`material match ${a.toFixed(2)} is below ${Am}`),{fit:o,px:s.px,r2:i,material:a,inexact:s.inexact,worst:s.worst,reroll:c}}var VA=/^[a-z][a-z0-9_-]*$/,qA=/^[0-9a-f]{64}$/,T8=/^(\d+)x(\d+)$/,UA=["from","prompt","provider","model","quality","cost"];function ZA(e,t,r,o){e.layers.splice(t,0,Dr(r,o)),e.cels.splice(t,0,Array.from({length:e.frameCount},()=>new Uint16Array(e.width*e.height).fill(65535))),xr(e,n=>n>=t?n+1:n,n=>n)}function LA(e,t){let r=T8.exec(e.value);if(!r||Number(r[1])<1||Number(r[2])<1||Number(r[1])>16384||Number(r[2])>16384)throw new O(e.line,e.vcol,`${t} is a size like 1536x1024`);return[Number(r[1]),Number(r[2])]}function HA(e){let t=/^(-?\d+),(-?\d+)$/.exec(e.value);if(!t)throw new O(e.line,e.vcol,"at= is a point x,y");return[Number(t[1]),Number(t[2])]}function FA(e,t){throw new O(e.line,e.col,`underlay ${t} runs through the server (the MCP run tool, the watch view or pixelclaw run), which writes the image into blobs/ and this line as underlay <layer> blob=\u2026`)}var C8={name:"underlay",summary:'underlay generate "<prompt>" [layer=<name>] [layout=<template.png|layer>] [size=<W>x<H>] [provider=openai|fake] [model=] [quality=] [cap=<usd>] | underlay import <file.png> [layer=<name>] [layout=<template.png|layer>] | underlay <layer> blob=<sha256> image=<W>x<H> [at=<x,y>] [size=<W>x<H>] [layout=<sha256>] (an image under the art on a reference layer, never exported; the first two forms run through the server and are written as the third)',normalise(e,t){let r=De(e,t),o=e.args[0];o?.t==="word"&&o.v==="generate"&&FA(e,"generate"),o?.t==="word"&&o.v==="import"&&FA(e,"import");let n=new we(e,["blob","image","at","size","layout",...UA]),i=n.take("word","a layer name (or generate / import)");if(n.done(),!VA.test(i.v))throw new O(i.line,i.col,`'${i.v}' is not a usable layer name`);if(r.map)throw new O(e.line,e.col,"underlay: a map shows its tiles; put the underlay on a sheet of the same size in pixels");let s=n.opts.get("blob");if(!s)throw new O(e.line,e.col,"underlay: give blob=<sha256> (or underlay generate / underlay import)");if(!qA.test(s.value))throw new O(s.line,s.vcol,"blob= is the image's sha256 (64 hex digits)");let a=n.opts.get("image"),c,l;if(a)[c,l]=LA(a,"image=");else{let y=t.image?.(s.value);if(!y)throw new O(s.line,s.vcol,"underlay: give image=<W>x<H> (the blob's size); the image is not readable here");c=y.width,l=y.height}let[u,m]=n.opts.get("at")?HA(n.opts.get("at")):[0,0],[d,f]=n.opts.get("size")?LA(n.opts.get("size"),"size="):[r.width,r.height],p=n.opts.get("layout");if(p&&!qA.test(p.value))throw new O(p.line,p.vcol,"layout= is the flat template's sha256 here (the server reads a file or layer and writes its hash)");let h=r.layers.findIndex(y=>y.name===i.v);if(h>=0&&!r.layers[h].reference)throw new O(i.line,i.col,`layer '${i.v}' is an art layer; an underlay goes on a reference layer (a new name makes one)`);if(h>=0&&r.cels[h].some(y=>y.some(w=>w!==65535)))throw new O(i.line,i.col,`layer '${i.v}' has pixels; an underlay goes on its own reference layer`);let g={blob:s.value,iw:c,ih:l,x:u,y:m,w:d,h:f,layout:p?.value??null},b=UA.flatMap(y=>{let w=n.opts.get(y);if(!w)return[];if(y==="cost"&&!/^\d+(\.\d+)?$/.test(w.value))throw new O(w.line,w.vcol,"cost= is in US dollars, like 0.05");return[` ${y}=${w.quoted||/[\s";#]/.test(w.value)||!w.value?tn(w.value):w.value}`]}).join("");return{text:`underlay ${i.v} blob=${g.blob} image=${c}x${l} at=${u},${m} size=${d}x${f}${g.layout?` layout=${g.layout}`:""}${b}`,op:le(y=>{let w=y.layers.findIndex(v=>v.name===i.v);w<0&&(ZA(y,0,i.v,{reference:!0}),w=0),y.layers[w]={...y.layers[w],underlay:g}})}}},A8={name:"snap",summary:"snap [from=<underlay layer>] [into=<new layer>] [fit=placement|free] (fits the underlay's pixel grid, quantises each block to the palette into a new draft layer, and reports block R\xB2 and, with the layout it was made from, the material match; below 0.8 or 0.85 it suggests a reroll)",normalise(e,t){let r=De(e,t);if(r.map)throw new O(e.line,e.col,"snap: a map holds cells by name");let o=new we(e,["from","into","fit","at","grid","pitch","offset","r2","material"]),n=o.peek()?.t==="block"?o.take("block","rows"):null;o.done();let i=o.opts.get("from"),s=r.layers.filter(y=>y.underlay),a=i?r.layers.find(y=>y.name===i.value):s.length===1?s[0]:void 0;if(!a?.underlay)throw new O(i?.line??e.line,i?.vcol??e.col,i?`snap: layer '${i.value}' has no underlay`:s.length?`snap: give from=<layer> (underlays: ${s.map(y=>y.name).join(", ")})`:"snap: there is no underlay (underlay generate / import first)");let c=o.opts.get("fit");if(c&&c.value!=="placement"&&c.value!=="free")throw new O(c.line,c.vcol,"snap: fit= is placement (the placement's grid, the default) or free");let l=c?.value==="free",u=o.opts.get("into"),m=u?.value??"draft";if(!VA.test(m))throw new O(u.line,u.vcol,`'${m}' is not a usable layer name`);if(r.layers.some(y=>y.name===m))throw new O(u?.line??e.line,u?.vcol??e.col,`snap: there is already a layer '${m}' (snap makes a new draft layer; give into=<name>)`);let d=a.underlay,f=new Map(r.palette.entries.map((y,w)=>[y.key,w])),p,h,g;if(n)p=n.rows.map(y=>y.text),n.rows.forEach(y=>[...y.text].forEach((w,v)=>{if(w!=="."&&!f.has(w))throw new O(y.line,y.col+v,`snap: '${w}' is not a key in palette '${r.palette.name}'`)})),h=o.opts.get("at")?HA(o.opts.get("at")):[d.x,d.y],g=["grid","pitch","offset","r2","material"].flatMap(y=>o.opts.get(y)?[` ${y}=${o.opts.get(y).value}`]:[]).join("");else{let y=t.image?.(d.blob);if(!y)throw new O(e.line,e.col,`snap: the underlay image (blobs/${d.blob}.png) is not readable here; run snap through the server`);if(y.width!==d.iw||y.height!==d.ih)throw new O(e.line,e.col,`snap: the blob is ${y.width}x${y.height}, the underlay says ${d.iw}x${d.ih}`);let w=d.layout?t.image?.(d.layout)??null:null,v=DA(y,r.palette,{hint:{x:d.iw/d.w,y:d.ih/d.h},...l?{}:{cells:{cols:d.w,rows:d.h}},layout:w}),S=r.palette.entries.map(x=>x.key);p=Array.from({length:v.fit.rows},(x,k)=>Array.from({length:v.fit.cols},(P,I)=>{let E=v.px[k*v.fit.cols+I];return E===65535?".":S[E]}).join("")),h=[d.x+Math.round((v.fit.x.offset+v.fit.i0*v.fit.x.pitch)*d.w/d.iw),d.y+Math.round((v.fit.y.offset+v.fit.j0*v.fit.y.pitch)*d.h/d.ih)];let _=x=>x.toFixed(2),$=x=>x.toFixed(3);g=` grid=${v.fit.cols}x${v.fit.rows} pitch=${$(v.fit.x.pitch)}x${$(v.fit.y.pitch)} offset=${_(v.fit.x.offset)},${_(v.fit.y.offset)} r2=${_(v.r2)} material=${v.material===null?"none":_(v.material)}`}let b=p.map(y=>[...y].map(w=>w==="."?65535:f.get(w)));return{text:`snap from=${a.name} into=${m}${l?" fit=free":""} at=${h[0]},${h[1]}${g} <<
154
+ ${Wt(p)}>>`,op:le(y=>{ZA(y,y.layers.length,m,{});let w=y.cels[y.layers.length-1];for(let v of w)b.forEach((S,_)=>S.forEach(($,x)=>{let k=h[0]+x,P=h[1]+_;k>=0&&P>=0&&k<y.width&&P<y.height&&(v[P*y.width+k]=$)}))})}}};for(let e of[C8,A8])Te(e);function Ok(){return[...Gr.values()].map(e=>e.summary).join(`
155
+ `)}var Nk=/^(?:undo|redo) group=(\S+)$/;function Mk(e){let t=new Map;for(let r of e){let o=t.get(r.group);o||t.set(r.group,o={id:r.group,by:r.by,undoTargets:[],hasNew:!1,onlyUndo:!0});let n=Nk.exec(r.cmd);n?o.undoTargets.push(n[1]):o.onlyUndo=!1,(r.cmd.startsWith("new ")||r.cmd.startsWith("fork "))&&(o.hasNew=!0)}return[...t.values()]}function Ns(e){let t=Mk(e),r=new Set,o=new Set;for(let n=t.length-1;n>=0;n--){let i=t[n];if(!r.has(i.id)){o.add(i.id);for(let s of i.undoTargets)r.add(s)}}return o}function O8(e){return e==="human"||e.startsWith("human:")?"h":"g"}function N8(e,t="g"){let r=0,o=new RegExp(`^${t}(\\d+)$`);for(let n of e){let i=o.exec(n.group);i&&(r=Math.max(r,Number(i[1])))}return`${t}${r+1}`}function M8(e,t,r=null,o){let n=Mk(e).filter(s=>s.id!==o),i=Ns(e);if(t!==null){if(t===o)return{error:"a batch cannot undo its own group"};let s=n.find(a=>a.id===t);return s?i.has(t)?s.hasNew?{error:`group '${t}' created the document and cannot be undone`}:{group:t}:{error:`group '${t}' is already undone`}:{error:`no group '${t}' on this tape`}}for(let s=n.length-1;s>=0;s--){let a=n[s];if(!(r!==null&&a.by!==r)&&i.has(a.id)&&!a.onlyUndo&&!a.hasNew)return{group:a.id}}return{error:r!==null?`nothing of ${r}'s to undo`:"nothing to undo"}}function D8(e,t,r=null,o){let n=Mk(e).filter(c=>c.id!==o),i=new Map(n.map(c=>[c.id,c])),s=Ns(e),a=c=>c.onlyUndo&&c.undoTargets.every(l=>!i.get(l)?.onlyUndo);if(t!==null){let c=i.get(t);return c?!c.onlyUndo||!a(c)?{error:`group '${t}' is not an undo, so there is nothing to redo`}:s.has(t)?{group:t}:{error:`group '${t}' is already taken back`}:{error:`no group '${t}' on this tape`}}for(let c=n.length-1;c>=0;c--){let l=n[c];if(!(r!==null&&l.by!==r)){if(!l.onlyUndo)break;if(a(l)&&s.has(l.id))return{group:l.id}}}return{error:r!==null?`nothing of ${r}'s to redo`:"nothing to redo"}}var q8=/^note .* id=n(\d+)$/;function U8(e){let t=0;for(let r of e){let o=q8.exec(r.cmd);o&&(t=Math.max(t,Number(o[1])))}return`n${t+1}`}function Dk(e,t,r,o,n,i,s,a,c,l){return{...c?{image:c}:{},...s?{asset:s}:{},...l?{assetNames:l}:{},...a?{defaults:a}:{},doc:e,seq:n,by:i,palette:u=>o.get(u),defaultPalette:o.defaultName,scheme:u=>o.scheme?.(u),newSeed:()=>cy(new dt(n,ly(e?.name??"doc"))),undoTarget:(u,m)=>M8(t,u,m??null,r),redoTarget:(u,m)=>D8(t,u,m??null,r),noteId:()=>U8(t)}}var ki=class e{snaps=[];every;constructor(t=100){this.every=t}static key(t,r,o){let n=new Set;for(let i=0;i<r;i++){let s=t[i];!o.has(s.group)&&!Nk.test(s.cmd)&&n.add(s.group)}return[...n].sort().join(" ")}record(t,r){let o=t.length;o===0||o%this.every!==0||this.snaps.some(n=>n.n===o&&n.last===t[o-1])||(this.snaps=this.snaps.filter(n=>n.n!==o),this.snaps.push({n:o,last:t[o-1],undone:e.key(t,o,Ns(t)),doc:r?qr(r):null}))}get size(){return this.snaps.length}replay(t,r){let o=Ns(t);this.snaps=this.snaps.filter(s=>s.n<=t.length&&t[s.n-1]===s.last);let n={n:0,doc:null};for(let s of[...this.snaps].sort((a,c)=>c.n-a.n))if(e.key(t,s.n,o)===s.undone){n=s;break}let i=n.doc?qr(n.doc):null;for(let s=n.n;s<t.length;s++){let a=t[s];if(o.has(a.group)&&!Nk.test(a.cmd)){let{commands:l,errors:u}=pn(a.cmd);if(u.length||l.length!==1)throw new Error(`tape seq ${a.seq}: '${a.cmd}' does not parse`);let m=_i(l[0],Dk(i,[],a.group,r,a.seq,a.by));i=Ts(i,m.op,a.by)}let c=s+1;c%this.every===0&&c<t.length&&!this.snaps.some(l=>l.n===c&&l.last===a)&&(this.snaps=this.snaps.filter(l=>l.n!==c),this.snaps.push({n:c,last:a,undone:e.key(t,c,o),doc:i?qr(i):null}))}return i}};function BA(e,t,r){return(r??new ki).replay(e,t)}function L8(e,t){if(!t)return 0;let r=e&&e.width===t.width&&e.height===t.height,o=0;for(let n=0;n<t.frameCount;n++){let i=be(t,n),s=r&&n<e.frameCount?be(e,n):null;if(!s){o+=i.length;continue}for(let a=0;a<i.length;a++)i[a]!==s[a]&&o++}return o}function qk(e,t,r){let{commands:o,errors:n}=pn(t),i=e.doc?qr(e.doc):null,s=[...e.entries],a=e.cache??new ki,c=N8(e.entries,O8(r.by)),l=(e.entries[e.entries.length-1]?.seq??0)+1,u=[],m=[];for(let d of o)try{let f=_i(d,Dk(i,s,c,r.palettes,l,r.by,r.assets,r.defaults,r.images,r.assetNames)),p={seq:l,by:r.by,...r.at?{at:r.at}:{},group:c,cmd:f.text};s.push(p),u.push(p),l++,i=f.op.k==="undo"?BA(s,r.palettes,a):Ts(i,f.op,r.by),a.record(s,i);let h=/^palette save as=(\S+)$/.exec(f.text);h&&i&&m.push({name:h[1],palette:i.palette})}catch(f){if(!(f instanceof O))throw f;n.push({line:f.line,col:f.col,message:f.message})}return n.length?{ok:!1,errors:n.sort((d,f)=>d.line-f.line||d.col-f.col)}:{ok:!0,state:{doc:i,entries:s,cache:a},added:u,group:u.length?c:null,changed:L8(e.doc,i),saves:m}}var zi=class e{doc=null;done=[];palettes;cache=new ki;constructor(t){this.palettes=t}static resume(t,r,o){let n=new e(t);return n.doc=r?qr(r):null,n.done.push(...o),n}step(t){let{commands:r,errors:o}=pn(t.cmd);if(o.length||r.length!==1)return o[0]?`does not parse: ${o[0].message}`:`holds ${r.length} commands`;try{let n=Dk(this.doc,this.done,t.group,this.palettes,t.seq,t.by),i=_i(r[0],n);return i.text!==t.cmd&&WA(t.cmd)&&(i=_i(r[0],{...n,lang:1})),i.text!==t.cmd?`not in normal form: expected '${i.text}'`:(this.done.push(t),this.doc=i.op.k==="undo"?BA(this.done,this.palettes,this.cache):Ts(this.doc,i.op,t.by),this.cache.record(this.done,this.doc),null)}catch(n){if(!(n instanceof O))throw n;return n.message}}},Ec=class{palettes;every;snaps=[];constructor(t,r=100){this.palettes=t,this.every=r}docAt(t,r){r=Math.max(0,Math.min(r,t.length)),this.snaps=this.snaps.filter(i=>i.n<=t.length&&t[i.n-1]===i.last);let o;for(let i of this.snaps)i.n<=r&&(!o||i.n>o.n)&&(o=i);let n=zi.resume(this.palettes,o?.doc??null,t.slice(0,o?.n??0));for(let i=o?.n??0;i<r;i++){let s=n.step(t[i]);if(s!==null)return{doc:n.doc,problem:`#${t[i].seq}: ${s}`};(i+1)%this.every===0&&!this.snaps.some(a=>a.n===i+1)&&this.snaps.push({n:i+1,last:t[i],doc:n.doc?qr(n.doc):null})}return{doc:n.doc,problem:null}}seed(t,r,o){r<1||r>t.length||this.snaps.some(n=>n.n===r)||this.snaps.push({n:r,last:t[r-1],doc:o?qr(o):null})}docAfter(t,r){let o=0;for(;o<t.length&&t[o].seq<=r;)o++;return this.docAt(t,o)}get size(){return this.snaps.length}};function Om(e,t){let r=new zi(t);for(let o of e){let n=r.step(o);if(n!==null)return{doc:r.doc,problems:[{seq:o.seq,message:n}]}}return{doc:r.doc,problems:[],cache:r.cache}}var WA=e=>e.startsWith("new ")&&!e.includes(`
156
+ `);function kr(e){return e[0]&&WA(e[0].cmd)?1:Sr}function F8(e=Sr){return JSON.stringify({pclaw:"tape",lang:e})}function Uk(e){return JSON.stringify(e.at?{seq:e.seq,by:e.by,at:e.at,group:e.group,cmd:e.cmd}:{seq:e.seq,by:e.by,group:e.group,cmd:e.cmd})}function Yy(e){return[F8(kr(e)),...e.map(Uk)].join(`
157
+ `)+`
158
+ `}function JA(e){let t=e.split(`
159
+ `).filter(n=>n.trim()!=="");if(t.length===0)throw new Error("tape is empty (no header line)");let r=JSON.parse(t[0]);if(r.pclaw!=="tape")throw new Error("tape line 1 is not a tape header");if(r.lang!==1&&r.lang!==Sr)throw new Error(`tape language version ${r.lang} is not supported (this build reads 1 and ${Sr})`);let o=t.slice(1).map((n,i)=>{let s=JSON.parse(n);if(typeof s.seq!="number"||typeof s.cmd!="string"||typeof s.group!="string"||typeof s.by!="string")throw new Error(`tape line ${i+2}: needs seq, by, group and cmd`);return s});if(o.length&&kr(o)!==r.lang)throw new Error(`tape header says language ${r.lang} but its first line is written in language ${kr(o)}`);return o}function GA(e,t){if(!e.length||kr(e)===Sr)return null;let r=e[0],{commands:o,errors:n}=pn(r.cmd);if(n.length||o.length!==1)throw new Error("line 1 does not parse");let i=_i(o[0],{lang:Sr,doc:null,palette:s=>t.get(s),defaultPalette:t.defaultName,newSeed:()=>0,seq:r.seq,undoTarget:()=>({error:"no"}),redoTarget:()=>({error:"no"}),noteId:()=>"n1",by:r.by});return[{...r,cmd:i.text},...e.slice(1)]}function V8(e,t){let r=[],o=e??{},n=(o.palettes??[]).flatMap(i=>{let s=t(i);return s||r.push(`style.palettes: no palette '${i}' in the project`),s?[s]:[]});return{style:{...n.length?{palettes:n}:{},...o.outline?{outline:o.outline}:{},...o.sizes?{sizes:o.sizes}:{},...o.checks?{checks:o.checks}:{},...o.assets?{assets:o.assets}:{},...o.density?{density:o.density}:{},...o.light?{light:o.light}:{},...o.reserved?{reserved:o.reserved}:{}},problems:r}}function KA(e){let t=Object.entries(e??{}).map(([r,o])=>pT(r,o??{}));return[...fT.filter(r=>!t.some(o=>o.name===r.name)),...t]}function Ro(e,t=24){let r=e?.drawScale;return typeof r=="number"&&Number.isInteger(r)&&r>=1&&r<=16?r:t>=48?1:2}function Io(e,t=24){let r=/^(\d+)x(\d+)$/.exec(e?.camera??"");return r&&Number(r[1])>0&&Number(r[2])>0?[Number(r[1]),Number(r[2])]:[16*t,9*t]}function Ms(e,t,r,o){let n=o??r?.assets?.[e]?.ground??r?.ground;return n?t.find(i=>i.name===n)??null:[...t].sort((i,s)=>i.name<s.name?-1:1).find(i=>i.doc.wrap&&i.name!==e)??null}function Nm(e,t,r,o,n){let i=n??o?.assets?.[e]?.set;if(i)return r.filter(c=>i.includes(c.name)&&c.name!==e);let s=c=>{let l=c;for(let u=0;u<32;u++){let m=r.find(d=>d.name===l)?.forkOf;if(!m)break;l=m}return l},a=s(e);return r.filter(c=>c.name!==e&&!c.doc.wrap&&c.doc.kind===t.kind&&c.doc.width===t.width&&c.doc.height===t.height&&s(c.name)!==a)}function YA(e,t,r,o,n,i={}){let{style:s,problems:a}=V8(o,n);i.setChecks&&(s.checks=Z8(s.checks??{},i.setChecks));let c=Ms(e,r,o,i.ground);i.ground&&!c&&a.push(`no asset '${i.ground}' to use as ground`);let l=i.ref?r.find(u=>u.name===i.ref)??null:null;return i.ref&&!l&&a.push(`no asset '${i.ref}' to compare with`),{ctx:{frame:i.frame,style:s,ground:c?.doc??null,ref:l?.doc??null,set:Nm(e,t,r,o,i.set).map(u=>({name:u.name,doc:u.doc})),...t.map||t.variantOf||t.densityOf?{world:qn(r)}:{},peers:(i.peers?r.filter(u=>i.peers.includes(u.name)&&Xy(u.doc)===Xy(t)):B8(e,t,r)).map(u=>({name:u.name,doc:u.doc})),...i.expect?{expect:i.expect}:{}},problems:a}}function Z8(e,t){let r={...e};for(let[o,n]of Object.entries(t)){let i=r[o];r[o]=i&&typeof i=="object"&&n&&typeof n=="object"?{...i,...n}:n}return r}var H8=e=>!e.wrap&&!e.family&&!e.overlay&&!e.map&&!e.font&&e.kind!=="icon";function B8(e,t,r){let o=Xy(t);return o==="other"?[]:r.filter(n=>n.name!==e&&Xy(n.doc)===o&&!n.doc.densityOf&&!t.densityOf)}function Xy(e){return e.wrap&&!e.family?"tile":H8(e)?"figure":e.kind==="icon"?"icon":"other"}var Lk=class{buf=new Uint8Array(1024);length=0;push(...t){for(let r of t){if(this.length===this.buf.length){let o=new Uint8Array(this.buf.length*2);o.set(this.buf),this.buf=o}this.buf[this.length++]=r&255}}u16(t){this.push(t&255,t>>8)}ascii(t){for(let r of t)this.push(r.charCodeAt(0))}done(){return this.buf.slice(0,this.length)}};function W8(e,t,r){e.push(r);let o=1<<r,n=o+1,i=r+1,s=n+1,a=new Map,c=0,l=0,u=[],m=()=>{u.length&&(e.push(u.length,...u),u=[])},d=p=>{for(c|=p<<l,l+=i;l>=8;)u.push(c&255),u.length===255&&m(),c>>>=8,l-=8};d(o);let f=t[0];for(let p=1;p<t.length;p++){let h=t[p],g=f<<8|h,b=a.get(g);if(b!==void 0){f=b;continue}d(f),s===4096?(d(o),a=new Map,s=n+1,i=r+1):(s>=1<<i&&i++,a.set(g,s++)),f=h}d(f),d(n),l>0&&(u.push(c&255),u.length===255&&m()),m(),e.push(0)}function Ds(e,t={}){if(!e.length)throw new Error("encodeGif: no frames");let{width:r,height:o}=e[0].img,n=[],i=new Map,s=e.map(({img:l})=>{if(l.width!==r||l.height!==o)throw new Error("encodeGif: frames differ in size");let u=new Uint8Array(r*o);for(let m=0;m<u.length;m++){let d=l.data[m*4]<<16|l.data[m*4+1]<<8|l.data[m*4+2],f=i.get(d);if(f===void 0){if(n.length===256)throw new Error("encodeGif: more than 256 colours");i.set(d,f=n.length),n.push(d)}u[m]=f}return u}),a=1;for(;1<<a<n.length;)a++;let c=new Lk;c.ascii("GIF89a"),c.u16(r),c.u16(o),c.push(128|a-1<<4|a-1,0,0);for(let l=0;l<1<<a;l++){let u=n[l]??0;c.push(u>>16,u>>8,u)}return c.push(33,255,11),c.ascii("NETSCAPE2.0"),c.push(3,1,0,0,0),e.forEach((l,u)=>{let[m,d,f,p]=[0,0,r-1,o-1],h=s[u];if(t.delta&&u>0){let g=s[u-1],b=h;[m,d,f,p]=[r,o,-1,-1];for(let w=0;w<o;w++)for(let v=0;v<r;v++)g[w*r+v]!==b[w*r+v]&&(v<m&&(m=v),v>f&&(f=v),w<d&&(d=w),w>p&&(p=w));f<0&&([m,d,f,p]=[0,0,0,0]);let y=f-m+1;h=new Uint8Array(y*(p-d+1));for(let w=d;w<=p;w++)h.set(b.subarray(w*r+m,w*r+f+1),(w-d)*y)}c.push(33,249,4,t.delta?4:0),c.u16(Math.max(1,Math.min(65535,Math.round(l.delay)))),c.push(0,0),c.push(44),c.u16(m),c.u16(d),c.u16(f-m+1),c.u16(p-d+1),c.push(0),W8(c,h,Math.max(2,a))}),c.push(59),c.done()}var Fk=class{buf=new Uint8Array(4096);n=0;room(t){if(this.n+t<=this.buf.length)return;let r=this.buf.length*2;for(;r<this.n+t;)r*=2;let o=new Uint8Array(r);o.set(this.buf.subarray(0,this.n)),this.buf=o}u8(t){this.room(1),this.buf[this.n++]=t&255}u16(t){this.u8(t),this.u8(t>>8)}u32(t){this.u16(t&65535),this.u16(t>>>16&65535)}zeros(t){for(let r=0;r<t;r++)this.u8(0)}bytes(t){this.room(t.length),this.buf.set(t,this.n),this.n+=t.length}str(t){let r=Qg(t);this.u16(r.length),this.bytes(r)}setU32(t,r){this.buf[t]=r&255,this.buf[t+1]=r>>8&255,this.buf[t+2]=r>>16&255,this.buf[t+3]=r>>>24&255}setU16(t,r){this.buf[t]=r&255,this.buf[t+1]=r>>8&255}done(){return this.buf.slice(0,this.n)}},Vk=(e,t)=>Math.max(1,Math.round(e*1e3/t)),Zk=(e,t)=>Math.max(1,Math.round(e*t/1e3));function Hk(e,t=60,r){if(e.palette.entries.length>255)throw new Error(`an .aseprite file holds 255 colours besides transparent; '${e.palette.name}' has ${e.palette.entries.length}`);let o=new Fk;o.u32(0),o.u16(42464),o.u16(e.frameCount),o.u16(e.width),o.u16(e.height),o.u16(8),o.u32(1),o.u16(100),o.u32(0),o.u32(0),o.u8(0),o.zeros(3),o.u16(e.palette.entries.length+1),o.u8(1),o.u8(1),o.u16(0),o.u16(0),o.u16(e.cellW),o.u16(e.cellH),o.zeros(84);let n=(s,a)=>{let c=o.n;o.u32(0),o.u16(s),a(o),o.setU32(c,o.n-c)},i=[...e.tags.map(s=>({name:s.name,from:s.from,to:s.to,dir:s.loop==="pingpong"?2:0})),...e.views.map(s=>({name:s.mirror?`view ${s.name} mirror ${s.mirror}`:`view ${s.name}`,from:s.from,to:s.to,dir:0}))];for(let s=0;s<e.frameCount;s++){let a=o.n;o.u32(0),o.u16(61946),o.u16(0),o.u16(Vk(e.ticks[s],t)),o.zeros(2),o.u32(0);let c=0;if(s===0){n(8199,u=>{u.u16(1),u.u16(0),u.u32(0),u.zeros(8)}),c++;let l=e.palette.entries.length+1;n(8217,u=>{u.u32(l),u.u32(0),u.u32(l-1),u.zeros(8),u.u16(0),u.u8(0),u.u8(0),u.u8(0),u.u8(0);for(let[m,d]of e.palette.entries.entries()){let[f,p,h]=it(r?.[m]??d.hex);u.u16(1),u.u8(f),u.u8(p),u.u8(h),u.u8(255),u.str(d.name)}}),c++;for(let u of e.layers)n(8196,m=>{m.u16((u.hidden?0:1)|2|(u.reference?64:0)),m.u16(0),m.u16(0),m.u16(0),m.u16(0),m.u16(0),m.u8(255),m.zeros(3),m.str(u.name)}),c++;i.length&&(n(8216,u=>{u.u16(i.length),u.zeros(8);for(let m of i)u.u16(m.from),u.u16(m.to),u.u8(m.dir),u.u16(0),u.zeros(6),u.zeros(3),u.u8(0),u.str(m.name)}),c++)}e.layers.forEach((l,u)=>{let m=e.cels[u],d=m[s],f=m.indexOf(d);if(f!==s){n(8197,h=>{h.u16(u),h.u16(0),h.u16(0),h.u8(255),h.u16(1),h.u16(0),h.zeros(5),h.u16(f)}),c++;return}if(d.every(h=>h===65535))return;let p=new Uint8Array(e.width*e.height);for(let h=0;h<p.length;h++)p[h]=d[h]===65535?0:d[h]+1;n(8197,h=>{h.u16(u),h.u16(0),h.u16(0),h.u8(255),h.u16(2),h.u16(0),h.zeros(5),h.u16(e.width),h.u16(e.height),h.bytes(CS(p))}),c++}),o.setU32(a,o.n-a),o.setU16(a+6,Math.min(c,65535)),o.setU32(a+12,c)}return o.setU32(0,o.n),o.done()}function Mm(e){if(e.length<128)throw new ft("not an .aseprite file (too short)");let t=0,r=()=>e[t++],o=()=>{let p=e[t]|e[t+1]<<8;return t+=2,p},n=()=>{let p=o();return p>=32768?p-65536:p},i=()=>{let p=(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0;return t+=4,p},s=()=>{let p=o(),h=SS(e.subarray(t,t+p));return t+=p,h};if(i(),o()!==42464)throw new ft("not an .aseprite file (bad magic number)");let a=o(),c=o(),l=o(),u=o();if(u!==8&&u!==16&&u!==32)throw new ft(`colour depth ${u} is not known`);t=28;let m=r();t=128;let d={width:c,height:l,depth:u,transparent:m,palette:[],layers:[],frames:[],tags:[]},f=u/8;for(let p=0;p<a;p++){let h=t,g=i();if(o()!==61946)throw new ft(`frame ${p+1}: bad frame magic number`);let b=o(),y=o();t+=2;let v=i()||b,S={ms:y,cels:[]};for(let _=0;_<v;_++){let $=t,x=i(),k=o();if(k===8196){let P=o(),I=o();o(),o(),o(),o(),r(),t+=3;let E=s();d.layers.push({name:E,visible:!!(P&1),reference:!!(P&64),type:I}),I===2&&i()}else if(k===8197){let P=o(),I=n(),E=n();r();let N=o();if(n(),t+=5,N===1)S.cels.push({layer:P,x:I,y:E,w:0,h:0,px:new Uint16Array(0),link:o()});else if(N===0||N===2){let T=o(),q=o(),Z=N===0?e.subarray(t,t+T*q*f):Tk(e.subarray(t,$+x));if(Z.length<T*q*f)throw new ft(`frame ${p+1}: a cel's pixels are cut short`);let D;if(u===8){D=new Uint16Array(T*q);for(let V=0;V<T*q;V++)D[V]=Z[V]===m?65535:Z[V]}else if(u===16){D=new Uint8Array(T*q*4);for(let V=0;V<T*q;V++){let F=Z[V*2];D[V*4]=F,D[V*4+1]=F,D[V*4+2]=F,D[V*4+3]=Z[V*2+1]}}else D=Z.slice(0,T*q*4);S.cels.push({layer:P,x:I,y:E,w:T,h:q,px:D})}}else if(k===8217){let P=i(),I=i(),E=i();for(t+=8;d.palette.length<P;)d.palette.push({r:0,g:0,b:0,a:255});for(let N=I;N<=E;N++){let T=o(),q={r:r(),g:r(),b:r(),a:r()};T&1&&(q.name=s()),d.palette[N]=q}}else if((k===4||k===17)&&!d.palette.length){let P=o(),I=0;for(let E=0;E<P;E++){I+=r();let N=r();N===0&&(N=256);for(let T=0;T<N;T++,I++){let q=k===17?4:1;d.palette[I]={r:Math.min(255,r()*q),g:Math.min(255,r()*q),b:Math.min(255,r()*q),a:255}}}}else if(k===8216){let P=o();t+=8;for(let I=0;I<P;I++){let E=o(),N=o(),T=r();t+=12,d.tags.push({name:s(),from:E,to:N,dir:T})}}t=$+x}d.frames.push(S),t=h+g}return d}function Dm(e){let t=e.layers.flatMap((l,u)=>l.type===0?[u]:[]),r=e.width,o=e.height,n=t.map(()=>e.frames.map(()=>null)),i=e.depth===8?t.map(()=>e.frames.map(()=>null)):null,s=[];e.frames.forEach((l,u)=>{for(let m of l.cels){let d=t.indexOf(m.layer);if(d<0)continue;if(m.link!==void 0){s.push([d,u,m.link]);continue}let f=new Uint8Array(r*o*4),p=i?new Uint16Array(r*o).fill(65535):null;for(let h=0;h<m.h;h++)for(let g=0;g<m.w;g++){let b=m.x+g,y=m.y+h;if(b<0||y<0||b>=r||y>=o)continue;let w=y*r+b;if(e.depth===8){let v=m.px[h*m.w+g];if(v===65535||v===e.transparent)continue;p[w]=v;let S=e.palette[v]??{r:0,g:0,b:0,a:255};f[w*4]=S.r,f[w*4+1]=S.g,f[w*4+2]=S.b,f[w*4+3]=S.a}else f.set(m.px.subarray((h*m.w+g)*4,(h*m.w+g)*4+4),w*4)}n[d][u]=f,i&&(i[d][u]=p)}});for(let[l,u,m]of s)n[l][u]=n[l][m]??null,i&&(i[l][u]=i[l][m]??null);let a=[],c=[];for(let l of e.tags){let u=/^view (\S+)(?: mirror (\S+))?$/.exec(l.name);u?c.push({name:u[1],from:l.from,to:l.to,mirror:u[2]??null}):a.push({name:l.name.replace(/[^A-Za-z0-9_-]/g,"_")||"tag",from:l.from,to:l.to,loop:l.dir===2||l.dir===3?"pingpong":"cycle"})}return{width:r,height:o,cell:null,layers:t.map(l=>({name:e.layers[l].name,hidden:!e.layers[l].visible,reference:e.layers[l].reference})),rgba:n,indices:i,links:s,ms:e.frames.map(l=>l.ms),tags:a,views:c}}var XA={format:"pixelclaw-profile",version:1,name:"aseprite",description:"One .aseprite file per asset (indexed: layers, frames and durations, linked cels, tags, views as tags named 'view S'); density copies as <asset>@<d>x.aseprite",layout:"aseprite",variants:"names"};var QA={format:"pixelclaw-profile",version:1,name:"aseprite-json",description:"Aseprite's sheet export: a PNG of each asset's frames in a row and the JSON Aseprite writes (frames with durations, tags, and views as tags named 'view S')",layout:"aseprite-json",variants:"names",mirrors:"bake",oversized:"sprite"};var eO={format:"pixelclaw-profile",version:1,name:"atlas",description:"One atlas page (trimmed images, shelf-packed) with JSON records: every column, including frame, ticks, view, pivot and footprint",layout:"atlas",page:{name:"atlas",width:256,padding:1,trim:!0},records:{format:"json",columns:["sprite","x","y","w","h","cropX","cropY","frameW","frameH","pivotX","pivotY","asset","frame","n","view","ticks","ms","cols","rows","anchorX","anchorY","flags","variant"]},variants:"frames",mirrors:"bake",oversized:"sprite"};var tO={format:"pixelclaw-profile",version:1,name:"godot",description:"Godot 4: a TileSet resource (.tres) per autotile family with one terrain set (match corners and sides for blob47, corners for wang16-corner, sides for path), frames as tile animations, and each tile's name as custom data",layout:"godot",variants:"names"};var nO={format:"pixelclaw-profile",version:1,name:"png",description:"Loose PNGs: one file per image, named <asset>, <asset>_<n> for frames, <asset>_<view>_<n> for directions, <family>_<variant> for autotile variants; mirror views written flipped; texture variants under their own names",layout:"loose",image:"{name}.png",variants:"names",mirrors:"bake",oversized:"sprite"};var rO={format:"pixelclaw-profile",version:1,name:"tiled",description:"Tiled: a .tsx per autotile family (its sheet, frames as tile animations, a wang set: mixed for blob47, corner for wang16-corner, edge for path), a collection tileset of every other image, and a .tmx per map that uses them",layout:"tiled",variants:"names",mirrors:"bake",oversized:"sprite"};var oO=["loose","atlas","sheet","tiled","godot","aseprite-json","aseprite"],yt=class extends Error{},iO=["sprite","x","y","w","h","cropX","cropY","frameW","frameH","pivotX","pivotY","page","asset","frame","n","view","mirror","ticks","ms","d","cols","rows","anchorX","anchorY","flags","variant","kind","mode"],cO=["sprite","x","y","w","h","cropX","cropY","frameW","frameH","pivotX","pivotY"],Jk=["asset","name","kind","mode","frames","names","first","ticks","ms","frameTicks","loop","tags","views","directions","mirror","w","h","cols","rows","anchorX","anchorY","pivotX","pivotY","variants","scheme"],Tc=["asset","n","view","cx","cy","variant","sides","corners","shape","name","d","page","stem"],sO=["lone","end","straight","corner","tee","cross"],e9=["ne","se","sw","nw"];function _t(e,t,r){return e.replace(/\{\{|\}\}|\{([A-Za-z][A-Za-z0-9]*)\}/g,(o,n)=>{if(o==="{{")return"{";if(o==="}}")return"}";if(r&&!r.includes(n))throw new yt(`unknown placeholder {${n}} (known: ${r.join(", ")})`);let i=t[n];if(i===void 0)throw new yt(`placeholder {${n}} has no value here`);return String(i)})}function qs(e){let t=`profile '${e?.name??"?"}'`;if(!e||typeof e!="object")throw new yt("a profile is a JSON object");if(!/^[a-z][a-z0-9_-]*$/.test(e.name??""))throw new yt(`${t}: name uses a-z, 0-9, _ and -`);if(!oO.includes(e.layout))throw new yt(`${t}: layout must be one of ${oO.join(", ")}`);let r=e.names??{};for(let[o,n]of Object.entries(r))o!=="start"&&_t(String(n),Object.fromEntries(Tc.map(i=>[i,""])),Tc);for(let[o,n]of Object.entries(e.autotile??{})){for(let i of[n.template,...Object.values(n.names??{})])i&&_t(i,Object.fromEntries(Tc.map(s=>[s,""])),Tc);if(n.sides&&!/^(?=.*n)(?=.*e)(?=.*s)(?=.*w)[nesw]{4}$/.test(n.sides))throw new yt(`${t}: autotile.${o}.sides orders the letters n, e, s and w`);if(n.corners!==void 0&&(typeof n.corners!="string"||[...new Set(n.corners.split(","))].sort().join()!==[...e9].sort().join()||n.corners.split(",").length!==4))throw new yt(`${t}: autotile.${o}.corners orders the corners ne, se, sw and nw, like "nw,ne,se,sw"`);for(let[i,s]of Object.entries(n.shapes??{})){if(!sO.includes(i))throw new yt(`${t}: autotile.${o}.shapes.${i} is not a shape (${sO.join(", ")})`);_t(String(s),Object.fromEntries(Tc.map(a=>[a,""])),Tc)}}for(let o of Object.keys(e.roles??{}))if(!Ht.includes(o))throw new yt(`${t}: roles.${o} is not a role (${Ht.join(", ")})`);for(let[o,n]of Object.entries(e.roles??{}))if(!/^#[0-9a-fA-F]{6}$/.test(String(n)))throw new yt(`${t}: roles.${o} must be #rrggbb`);for(let[o,n]of Object.entries(e.colours??{})){if(!/^([a-z][a-z0-9_-]*\.)?[a-z][a-z0-9_]*$/i.test(o))throw new yt(`${t}: colours: '${o}' is not an entry name (or <palette>.<entry>)`);if(!/^#[0-9a-fA-F]{6}$/.test(String(n))){if(!Ht.includes(String(n)))throw new yt(`${t}: colours.${o} must be #rrggbb or a role (${Ht.join(", ")})`);if(!e.roles?.[n])throw new yt(`${t}: colours.${o} is the role '${n}', which roles does not give a colour`)}}if(e.density&&(!Array.isArray(e.density.levels)||!e.density.levels.length||e.density.levels.some(o=>![1,2,3,4,6,8].includes(o))))throw new yt(`${t}: density.levels lists sizes like 1, 2, 4`);for(let o of e.records?.columns??[])if(!iO.includes(o))throw new yt(`${t}: records.columns: '${o}' is not a column (${iO.join(", ")})`);if(e.fonts){if(e.fonts.format&&!["strip","bmfont","both","sheet"].includes(e.fonts.format))throw new yt(`${t}: fonts.format is strip, bmfont, both or sheet`);if(e.fonts.separator&&!/^#[0-9a-fA-F]{6}$/.test(e.fonts.separator))throw new yt(`${t}: fonts.separator must be #rrggbb`);if(e.fonts.maxLine!==void 0&&(!Number.isInteger(e.fonts.maxLine)||e.fonts.maxLine<1))throw new yt(`${t}: fonts.maxLine is a line height in pixels`)}if(e.snippets)for(let o of Object.values(e.snippets.templates??{}))_t(o,Object.fromEntries(Jk.map(n=>[n,""])),Jk);return e}var lO=new Map([nO,eO,rO,tO,QA,XA].map(e=>[e.name,qs(e)])),t9=e=>e.toLowerCase(),n9=(e,t)=>e.views.find(r=>r.mirror===t)?.name??null;function r9(e,t="nesw",r){let[o,...n]=e.split("_"),i=l=>{let u=r?r.split(","):null;return(u?[...l].sort((m,d)=>u.indexOf(m)-u.indexOf(d)):l).map(m=>`_${m}`).join("")};if(!/^(o|[nesw]+)$/.test(o)||n.some(l=>!/^(ne|se|sw|nw)$/.test(l)))return/^(ne|se|sw|nw)$/.test(o)&&n.every(l=>/^(ne|se|sw|nw)$/.test(l))?{sides:"",corners:i([o,...n]),shape:"lone"}:null;let s=o==="o"?"":[...t].filter(l=>o.includes(l)).join(""),c=["lone","end",s.length===2&&/n/.test(s)===/s/.test(s)?"straight":"corner","tee","cross"][s.length];return{sides:s,corners:i(n),shape:c}}function o9(e,t,r){let o=t.family.def?.name??t.family.scheme,n=e.autotile?.[o]??e.autotile?.["*"],i={asset:t.name,variant:r,sides:"",corners:"",shape:""},s=n?.names?.[r];if(s)return _t(s,i);if(r==="inside"||r==="outside")return`${t.name}_${r}`;let a=n?.template||n?.shapes?r9(r,n.sides,n.corners):null;if(a){let c=n.shapes?.[a.shape]??n.template;if(c)return _t(c,{...i,...a})}return`${t.name}_${r}`}var uO=e=>!e.family&&!e.map&&(e.kind==="object"||e.kind==="tile")&&(e.width>e.cellW||e.height>e.cellH||!!e.footprint);function Cc(e,t){if(t.densityOf)return!1;let r=o=>o.includes(t.name)||o.includes(t.kind);return e.exclude&&r(e.exclude)?!1:e.include?r(e.include):t.map?e.layout==="tiled":t.kind==="overlay"&&e.layout==="godot"?!1:e.layout!=="godot"||!!t.family}var nb=e=>e.fonts?.format??"strip";function Gk(e,t,r){if(e.kind==="icon"&&pc(e)!=="tone")return e.palette.entries.map(n=>n.hex);let o=Ck(e.palette,t);return r?e.palette.entries.map((n,i)=>{let s=r[`${e.palette.name}.${n.name}`]??r[n.name];return s===void 0?o[i]:/^#/.test(s)?s.toLowerCase():t[s]}):o}function Kk(e,t){let r=new Map(t.map(u=>[u.name,u])),o=(e.variants??"frames")==="frames",n=[],i=[...t].sort((u,m)=>u.name<m.name?-1:u.name>m.name?1:0);for(let u of i)!Cc(e,u)||u.map||u.font&&nb(e)!=="sheet"||o&&u.variantOf&&r.has(u.variantOf)&&Cc(e,r.get(u.variantOf))||n.push([u,...o?i.filter(m=>m.variantOf===u.name&&Cc(e,m)&&m.width===u.width&&m.height===u.height):[]]);let s=e.names?.start??0,a={single:"{asset}",frame:"{asset}_{n}",view:"{asset}_{view}_{n}",piece:"{asset}_{cx}_{cy}",...e.names},c=[];for(let u of n){let m=u[0],d=f=>u.length>1||f>1;u.forEach((f,p)=>{let h=f.frameCount,g=y=>s+p*h+y,b=(y,w,v,S,_,$,x={})=>{let k=d(h)?g(w):null,P=k===null?y:_t(a.frame,{asset:y,n:k,stem:y});c.push({name:P,doc:f,frame:w,x:v,y:S,w:_,h:$,n:k,view:null,mirror:null,cell:null,ticks:f.ticks[w],group:m.name,...x})};if(f.family){let y=mt(f.family),w=Qe(f.family),v=f.family.tile,S=[["inside",y.inside],["outside",y.outside],...w.variants.map((_,$)=>[_.name,y.cells[$]])];for(let _=0;_<h;_++)for(let[$,[x,k]]of S)b(o9(e,m,$),_,x*v,k*v,v,v,{cell:$});return}if(uO(f)&&e.oversized==="split"){let[y,w]=Br(f);for(let v=0;v<h;v++)for(let S=0;S<w;S++)for(let _=0;_<y;_++)b(_t(a.piece,{asset:m.name,cx:_,cy:S}),v,_*f.cellW,S*f.cellH,f.cellW,f.cellH,{cell:`${_}_${S}`});return}if(f.views.length&&e.layout!=="aseprite-json"){let y=e.mirrors==="flag";for(let w=0;w<h;w++){let v=f.views.find($=>$.from<=w&&w<=$.to);if(!v){b(m.name,w,0,0,f.width,f.height);continue}if(v.mirror&&y)continue;let S=w-v.from,_=s+(u.length>1?p*h:0)+S;c.push({name:_t(a.view,{asset:m.name,view:t9(v.name),n:_}),doc:f,frame:w,x:0,y:0,w:f.width,h:f.height,n:_,view:v.name,mirror:y?n9(f,v.name):null,cell:null,ticks:f.ticks[w],group:m.name})}return}for(let y=0;y<h;y++)b(_t(a.single,{asset:m.name}),y,0,0,f.width,f.height)})}let l=new Map;for(let u of c){let m=l.get(u.name);if(m)throw new yt(`profile '${e.name}': two images are named '${u.name}' (${m.doc.name} frame ${m.frame+1} and ${u.doc.name} frame ${u.frame+1}); change a template`);l.set(u.name,u)}return c}function mO(e,t,r,o){let n=o.filter(l=>l.densityOf?.of===t.doc.name),i=(l,u,m)=>{let d=t.w*m,f=t.h*m,p=new Uint16Array(d*f);for(let h=0;h<f;h++)p.set(l.subarray((t.y*m+h)*u+t.x*m,(t.y*m+h)*u+t.x*m+d),h*d);return p},s=l=>Ay(be(l,Math.min(t.frame,l.frameCount-1)),l.palette,t.doc.palette);if(r===1)return{px:i(be(t.doc,t.frame),t.doc.width,1),how:"authored"};let a=n.find(l=>l.densityOf.d===r);if(a)return{px:i(s(a),a.width,r),how:"authored"};let c=n.filter(l=>l.densityOf.d>r&&l.densityOf.d%r===0).sort((l,u)=>u.densityOf.d-l.densityOf.d)[0];if(c&&e.density?.reduce!==!1){let l=c.densityOf.d,u=i(s(c),c.width,l),{reducer:m="ink-vote",...d}=e.density??{levels:[1]};return{px:YS(u,t.w*l,t.h*l,l/r,t.doc.palette,m,d),how:"reduced"}}return{px:xm(i(be(t.doc,t.frame),t.doc.width,1),t.w,t.h,r),how:"scaled"}}var i9=e=>{let t=[];for(let r of e){let o=r.codePointAt(0);o<128?t.push(o):o<2048?t.push(192|o>>6,128|o&63):o<65536?t.push(224|o>>12,128|o>>6&63,128|o&63):t.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|o&63)}return Uint8Array.from(t)},s9=e=>{let t="";for(let r=0;r<e.length;){let o=e[r],n;o<128?(n=o,r+=1):o<224?(n=(o&31)<<6|e[r+1]&63,r+=2):o<240?(n=(o&15)<<12|(e[r+1]&63)<<6|e[r+2]&63,r+=3):(n=(o&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63,r+=4),t+=String.fromCodePoint(n)}return t},dO=e=>e.density?.levels??[1];function Yk(e,t,r){let o=e.density?.plain??1;return r===o?t:t+_t(e.density?.suffix??"@{d}x",{d:r})}var a9=e=>{let t=/^(.*?)(\.[^./]+)$/.exec(e);return t?[t[1],t[2]]:[e,""]},Po=(e,t,r)=>{let[o,n]=a9(t);return Yk(e,o,r)+n};function c9(e,t,r){let o=t,n=r,i=-1,s=-1;for(let a=0;a<r;a++)for(let c=0;c<t;c++)e[a*t+c]!==65535&&(c<o&&(o=c),c>i&&(i=c),a<n&&(n=a),a>s&&(s=a));return i<0?[0,0,0,0]:[o,n,i-o+1,s-n+1]}function rb(e,t,r,o,n,i,s,a,c,l){for(let u=0;u<a;u++)for(let m=0;m<s;m++)e[(l+u)*t+c+m]=r[(i+u)*o+n+m]}function aO(e,t,r,o,n){let i=t.it,s=i.doc,a=uO(s)?Dn(s):null,c=s.pivot&&!i.cell?[s.pivot[0]*o+(o>>1),s.pivot[1]*o+o-1]:null;switch(e){case"sprite":return i.name;case"x":return t.x;case"y":return t.y;case"w":return t.w;case"h":return t.h;case"cropX":return t.cropX;case"cropY":return t.cropY;case"frameW":return t.frameW;case"frameH":return t.frameH;case"pivotX":return c?.[0]??null;case"pivotY":return c?.[1]??null;case"page":return r;case"asset":return s.name;case"frame":return i.frame+1;case"n":return i.n;case"view":return i.view;case"mirror":return i.mirror;case"ticks":return i.ticks;case"ms":return n(i.ticks);case"d":return o;case"cols":return a?.cols??null;case"rows":return a?.rows??null;case"anchorX":return a?a.at[0]+a.anchor[0]:null;case"anchorY":return a?a.at[1]+a.anchor[1]:null;case"flags":return a?a.flags.join("/"):null;case"variant":return i.cell;case"kind":return s.kind;case"mode":return s.kind==="icon"?pc(s):""}return null}var l9=e=>e===null?"":typeof e=="number"?String(e):/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e;function Bk(e,t,r,o,n,i){let s=e.records,a=s.columns??cO;if(s.format==="csv"){let l=t.map(u=>a.map(m=>l9(aO(m,u,r,o,i))).join(","));return[...s.header===!1?[]:[a.join(",")],...l].join(`
160
+ `)+`
161
+ `}let c=t.map(l=>Object.fromEntries(a.flatMap(u=>{let m=aO(u,l,r,o,i);return m===null?[]:[[u,m]]})));return JSON.stringify({page:r,size:n,d:o,sprites:c},null,1)+`
162
+ `}function u9(e,t,r){let o=[...e].filter(c=>c.w&&c.h).sort((c,l)=>l.h-c.h||l.w-c.w||(c.it.name<l.it.name?-1:1)),n=Math.max(t,...o.map(c=>c.w+2*r)),i=r,s=r,a=0;for(let c of o)i+c.w+r>n&&(i=r,s+=a+r,a=0),c.x=i,c.y=s,i+=c.w+r,a=Math.max(a,c.h);return[n,Math.max(1,s+a+r)]}function fO(e,t,r={}){let o=qs(e),n=r.tickRate??60,i=b=>Vk(b,n),s=new Map,a=[],c=(b,y)=>s.set(b,typeof y=="string"?i9(y):y),l=Kk(o,t),u=new Map,m=b=>{let y=u.get(b);if(!y){y=Gk(b,o.roles,o.colours);let w=new Map;b.palette.entries.forEach((v,S)=>{let _=y[S].toLowerCase(),$=w.get(_);$?a.push(`${b.name}: ${$} and ${v.name} are both written as ${_}; an import reads it back as ${$}`):w.set(_,v.name)}),u.set(b,y)}return y},d=(b,y,w,v)=>Le(Ky(b,y,w,m(v))),f=dO(o),p=new Map,h=(b,y)=>{let w=mO(o,b,y,t);return y>1&&p.set(w.how,(p.get(w.how)??0)+1),w.px},g=(b,y,w)=>b.map(v=>{let S=h(v,y),_=v.w*y,$=v.h*y,[x,k,P,I]=w?c9(S,_,$):[0,0,_,$];return{it:v,px:S,x:0,y:0,w:P,h:I,cropX:x,cropY:k,frameW:_,frameH:$}});if(o.layout==="loose")for(let b of f){let y=g(l,b,!1);for(let w of y)c(Po(o,_t(o.image??"{name}.png",{name:w.it.name,asset:w.it.group}),b),d(w.px,w.frameW,w.frameH,w.it.doc));o.records&&c(Po(o,o.records.file??`sprites.${o.records.format}`,b),Bk(o,y,"",b,[0,0],i))}else if(o.layout==="atlas"){let b=o.page?.padding??1,y=o.page?.name??"atlas";for(let w of f){let v=g(l,w,o.page?.trim!==!1),[S,_]=u9(v,(o.page?.width??256)*w,b),$=new Uint16Array(S*_).fill(65535),x=Ky($,S,_,[]);for(let I of v){if(!I.w)continue;let E=Ky(I.px,I.frameW,I.frameH,m(I.it.doc));for(let N=0;N<I.h;N++)x.data.set(E.data.subarray(((I.cropY+N)*I.frameW+I.cropX)*4,((I.cropY+N)*I.frameW+I.cropX+I.w)*4),((I.y+N)*S+I.x)*4)}let k=Po(o,_t(o.page?.file??"{page}.png",{page:y}),w);c(k,Le(x));let P=o.records??{format:"csv"};c(Po(o,_t(P.file??`{page}.${P.format}`,{page:y}),w),Bk({...o,records:P},v,k,w,[S,_],i))}}else if(o.layout==="sheet"||o.layout==="aseprite-json"){let b=[...new Set(l.map(y=>y.group))];for(let y of b){let w=l.filter(_=>_.group===y),v=w[0].doc,S=o.layout==="sheet"&&v.family&&!o.page?.columns?mt(v.family).cols:Math.max(1,Math.min(o.page?.columns??w.length,w.length));for(let _ of f){let $=g(w,_,!1),x=Math.max(...$.map(D=>D.frameW)),k=Math.max(...$.map(D=>D.frameH)),P=o.page?.padding??0,I=$.map((D,V)=>V);if(o.layout==="sheet"&&v.family&&!o.page?.columns){let V=mt(v.family).rows-(v.family.mapRows?v.family.mapRows:0);I=$.map(F=>(Math.floor(F.it.y/v.family.tile)+F.it.frame*V)*S+Math.floor(F.it.x/v.family.tile))}let E=Math.max(...I.map(D=>Math.floor(D/S)))+1,N=S*(x+P)-P||1,T=E*(k+P)-P||1,q=new Uint16Array(N*T).fill(65535);$.forEach((D,V)=>{D.x=I[V]%S*(x+P),D.y=Math.floor(I[V]/S)*(k+P),D.w=D.frameW,D.h=D.frameH,rb(q,N,D.px,D.frameW,0,0,D.frameW,D.frameH,D.x,D.y)});let Z=Po(o,_t(o.image??"{asset}.png",{asset:y,name:y}),_);if(c(Z,d(q,N,T,v)),o.layout==="aseprite-json"){let D=v,V={frames:$.map(F=>({filename:F.it.name,frame:{x:F.x,y:F.y,w:F.w,h:F.h},rotated:!1,trimmed:!1,spriteSourceSize:{x:0,y:0,w:F.w,h:F.h},sourceSize:{w:F.w,h:F.h},duration:i(F.it.ticks)})),meta:{app:"https://github.com/pixelclaw",version:"1",image:Z.split("/").pop(),format:"RGBA8888",size:{w:N,h:T},scale:String(_),frameTags:D.family||w.length!==D.frameCount?[]:[...D.tags.map(F=>({name:F.name,from:F.from,to:F.to,direction:F.loop==="pingpong"?"pingpong":"forward"})),...D.views.map(F=>({name:F.mirror?`view ${F.name} mirror ${F.mirror}`:`view ${F.name}`,from:F.from,to:F.to,direction:"forward"}))],layers:[],slices:[]}};c(Po(o,`${y}.json`,_),JSON.stringify(V,null,1)+`
163
+ `)}else o.records&&c(Po(o,_t(o.records.file??`{asset}.${o.records.format}`,{asset:y,page:y}),_),Bk(o,$,Z,_,[N,T],i))}}}else if(o.layout==="aseprite")for(let b of t.filter(y=>Cc(o,y)&&!y.map)){c(`${b.name}.aseprite`,Hk(b,n,m(b)));for(let y of t.filter(w=>w.densityOf?.of===b.name))c(`${Yk(o,b.name,y.densityOf.d)}.aseprite`,Hk(y,n,Ck(y.palette,o.roles)))}else o.layout==="tiled"?p9(o,t,l,c,d,i,r.world,a):h9(o,t,l,c,d,n,a);if(nb(o)!=="sheet")for(let b of t.filter(y=>y.font&&Cc(o,y))){try{if(nb(o)!=="bmfont"){let y=iy(b,m(b),o.fonts?.separator??AS);c(`${b.name}.png`,Le(y.img)),c(`${b.name}.txt`,y.chars+`
164
+ `)}if(nb(o)!=="strip"){let y=sy(b,m(b),`${b.name}_0.png`);c(`${b.name}.fnt`,y.fnt),c(`${b.name}_0.png`,Le(y.img))}}catch(y){throw y instanceof ho?new yt(y.message):y}o.fonts?.maxLine&&b.font.line>o.fonts.maxLine&&a.push(`${b.name}: the line height ${b.font.line} is over the profile's limit ${o.fonts.maxLine}`)}o.snippets&&c(o.snippets.file,m9(o,t,l,i));for(let[b,y]of p)b!=="authored"&&a.push(`${y} images at a higher density were ${b} (no authored copy at that level)`);return{files:s,items:l,notes:a}}function m9(e,t,r,o){let n=e.snippets,i=[];for(let s of[...new Set(r.map(a=>a.group))]){let a=r.filter(d=>d.group===s),c=a[0].doc,l=n.templates[c.family?"family":c.kind]??n.templates.default;if(!l)continue;let u=Dn(c),m=a.map(d=>d.ticks);i.push(_t(l,{asset:s,name:a[0].name,kind:c.kind,mode:c.kind==="icon"?pc(c):"",frames:a.length,names:a.map(d=>`"${d.name}"`).join(", "),first:a[0].name,ticks:m.join(", "),ms:m.map(o).join(", "),frameTicks:m[0]??10,loop:c.tags[0]?.loop??"cycle",tags:c.tags.map(d=>d.name).join(", "),views:c.views.map(d=>d.name).join(", "),directions:c.views.length||1,mirror:c.views.filter(d=>d.mirror).map(d=>`${d.name}=${d.mirror}`).join(", "),w:c.width,h:c.height,cols:u.cols,rows:u.rows,anchorX:u.at[0]+u.anchor[0],anchorY:u.at[1]+u.anchor[1],pivotX:c.pivot?.[0]??"",pivotY:c.pivot?.[1]??"",variants:t.filter(d=>d.variantOf===s).length+1,scheme:c.family?c.family.def?.name??c.family.scheme:""},Jk))}return(n.header?n.header+`
165
+ `:"")+i.join(n.join??`
166
+ `)+(n.footer?`
167
+ `+n.footer:"")+`
168
+ `}var En=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function d9(e,t){let{N:r,NE:o,E:n,SE:i,S:s,SW:a,W:c,NW:l}=pt,u=m=>t&m?1:0;return e==="corners"?[0,u(o),0,u(i),0,u(a),0,u(l)]:e==="4"?[u(r),0,u(n),0,u(s),0,u(c),0]:[u(r),u(o),u(n),u(i),u(s),u(a),u(c),u(l)]}function f9(e,t){let r=t.family.tile,o=mt(t.family),n=o.rows-t.family.mapRows,i=o.cols*r,s=n*r*t.frameCount,a=new Uint16Array(i*s).fill(65535),c=new Map;for(let l of e){let u=l.x/r,m=l.y/r+l.frame*n;rb(a,i,be(l.doc,l.frame),l.doc.width,l.x,l.y,r,r,u*r,m*r),c.set(l,m*o.cols+u)}return{px:a,w:i,h:s,cols:o.cols,perFrame:n*o.cols,id:c}}function p9(e,t,r,o,n,i,s,a){let c=[...new Set(r.filter(m=>m.doc.family).map(m=>m.doc))],l=new Map;for(let m of c){let d=r.filter(v=>v.doc===m),f=f9(d,m),p=Qe(m.family),h=m.family.tile;o(`${m.name}.png`,n(f.px,f.w,f.h,m));let g=new Map,b=[];for(let v of d){if(g.set(`${v.cell}@${v.frame}`,f.id.get(v)),v.frame)continue;let S=m.frameCount>1?[" <animation>",...Array.from({length:m.frameCount},(_,$)=>` <frame tileid="${f.id.get(v)+$*f.perFrame}" duration="${i(m.ticks[$])}"/>`)," </animation>"]:[];b.push(` <tile id="${f.id.get(v)}">`," <properties>",` <property name="name" value="${En(v.name)}"/>`,` <property name="variant" value="${En(v.cell)}"/>`," </properties>",...S," </tile>")}for(let v of d.filter(S=>S.frame>0))b.push(` <tile id="${f.id.get(v)}">`," <properties>",` <property name="name" value="${En(v.name)}"/>`," </properties>"," </tile>");l.set(m.name,g);let y=p.neighbours==="corners"?"corner":p.neighbours==="4"?"edge":p.neighbours==="8"?"mixed":null,w=y?[" <wangsets>",` <wangset name="${En(m.name)}" type="${y}" tile="-1">`,` <wangcolor name="${En(m.name)}" color="#ff0000" tile="-1" probability="1"/>`,...p.variants.flatMap((v,S)=>v.key===null||v.on?[]:[` <wangtile tileid="${f.id.get(d.find(_=>_.cell===v.name&&_.frame===0))}" wangid="${d9(p.neighbours,v.key).join(",")}"/>`]).filter((v,S)=>S>=0)," </wangset>"," </wangsets>"]:[];o(`${m.name}.tsx`,['<?xml version="1.0" encoding="UTF-8"?>',`<tileset version="1.10" tiledversion="1.10.2" name="${En(m.name)}" tilewidth="${h}" tileheight="${h}" tilecount="${f.cols*(f.h/h)}" columns="${f.cols}">`,` <image source="${En(m.name)}.png" width="${f.w}" height="${f.h}"/>`,...b,...w,"</tileset>",""].join(`
169
+ `))}let u=r.filter(m=>!m.doc.family);if(u.length){let m=u.flatMap((d,f)=>(o(`tiles/${d.name}.png`,n(mO(e,d,1,t).px,d.w,d.h,d.doc)),[` <tile id="${f}">`," <properties>",` <property name="name" value="${En(d.name)}"/>`," </properties>",` <image width="${d.w}" height="${d.h}" source="tiles/${En(d.name)}.png"/>`," </tile>"]));o("tiles.tsx",['<?xml version="1.0" encoding="UTF-8"?>',`<tileset version="1.10" tiledversion="1.10.2" name="tiles" tilewidth="${Math.max(...u.map(d=>d.w))}" tileheight="${Math.max(...u.map(d=>d.h))}" tilecount="${u.length}" columns="0">`,' <grid orientation="orthogonal" width="1" height="1"/>',...m,"</tileset>",""].join(`
170
+ `))}for(let m of t.filter(d=>d.map&&Cc(e,d))){if(!s){a.push(`${m.name}: maps need the project's assets`);continue}let d=[],f=1;for(let _ of c){let $=mt(_.family),x=$.cols*($.rows-_.family.mapRows)*_.frameCount;d.push({source:`${_.name}.tsx`,first:f,count:x,name:_.name}),f+=x}let p=f;u.length&&d.push({source:"tiles.tsx",first:f,count:u.length,name:"tiles"});let h=_=>d.find($=>$.name===_)?.first,g=(_,$=0)=>{let x=u.findIndex(k=>k.doc.name===_&&k.frame===$);return x<0?0:p+x},b=m.map.tile,y=m.width,w=m.height,v=[],S=1;m.layers.forEach((_,$)=>{let x=_.map;if(!x||x.kind==="overlay")return;let k={...m,layers:m.layers.map((N,T)=>({...N,hidden:T!==$}))},P=Bt(k,s);if(x.kind==="objects"){v.push(` <objectgroup id="${$+1}" name="${En(_.name)}"${_.hidden?' visible="0"':""}>`);for(let N of P.objects.filter(T=>T.layer===$&&T.doc)){let T=m.map.entries[N.entry];v.push(` <object id="${S++}" name="${En(T.name)}" gid="${g(N.doc.name)}" x="${N.px}" y="${N.py+N.doc.height}" width="${N.doc.width}" height="${N.doc.height}">`," <properties>",` <property name="cell" value="${N.x},${N.y}"/>`,` <property name="footprint" value="${T.cols}x${T.rows}"/>`,` <property name="anchor" value="${T.anchor.join(",")}"/>`,` <property name="flags" value="${En(N.fp.flags.join("/"))}"/>`," </properties>"," </object>")}v.push(" </objectgroup>");return}let I=P.top.map(N=>{if(!N)return 0;let T=l.get(N.asset);if(T){let q=T.get(`${N.variant}@0`);return q===void 0?0:h(N.asset)+q}return g(N.asset)}),E=Array.from({length:w},(N,T)=>I.slice(T*y,T*y+y).join(",")).join(`,
171
+ `);v.push(` <layer id="${$+1}" name="${En(_.name)}" width="${y}" height="${w}"${_.hidden?' visible="0"':""}>
172
+ <data encoding="csv">
173
+ ${E}
174
+ </data>
175
+ </layer>`)}),o(`${m.name}.tmx`,['<?xml version="1.0" encoding="UTF-8"?>',`<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="${y}" height="${w}" tilewidth="${b}" tileheight="${b}" infinite="0" nextlayerid="${m.layers.length+1}" nextobjectid="${S}">`,...d.map(_=>` <tileset firstgid="${_.first}" source="${En(_.source)}"/>`),...v,"</map>",""].join(`
176
+ `))}}var Wk=[[pt.E,"right_side"],[pt.SE,"bottom_right_corner"],[pt.S,"bottom_side"],[pt.SW,"bottom_left_corner"],[pt.W,"left_side"],[pt.NW,"top_left_corner"],[pt.N,"top_side"],[pt.NE,"top_right_corner"]];function h9(e,t,r,o,n,i,s){let a=[...new Set(r.filter(l=>l.doc.family).map(l=>l.doc))],c=r.filter(l=>!l.doc.family).map(l=>l.doc.name);c.length&&s.push(`godot: only families are written (terrains); left out ${[...new Set(c)].join(", ")}`);for(let l of a){let u=r.filter($=>$.doc===l),m=Qe(l.family),d=l.family.tile,f=mt(l.family),p=f.rows-l.family.mapRows,h=f.cols*d*l.frameCount,g=p*d,b=new Uint16Array(h*g).fill(65535);for(let $ of u)rb(b,h,be(l,$.frame),l.width,$.x,$.y,d,d,$.x+$.frame*f.cols*d,$.y);o(`${l.name}.png`,n(b,h,g,l));let y=m.neighbours==="corners"?1:m.neighbours==="4"?2:0,w=[];for(let $ of u.filter(x=>x.frame===0)){let x=`${$.x/d}:${$.y/d}/0`,k=x.slice(0,-2);if(l.frameCount>1){w.push(`${k}/animation_separation = Vector2i(${f.cols-1}, 0)`);for(let E=0;E<l.frameCount;E++)w.push(`${k}/animation_frame_${E}/duration = ${(l.ticks[E]/i).toFixed(4)}`)}w.push(`${x} = 0`,`${x}/custom_data_0 = "${$.name}"`);let P=m.byName.get($.cell),I=P===void 0?null:m.variants[P];if(I&&I.key!==null&&!I.on){w.push(`${x}/terrain_set = 0`,`${x}/terrain = 0`);let E=y===1?Wk.filter(([N])=>N&(pt.NE|pt.SE|pt.SW|pt.NW)):y===2?Wk.filter(([N])=>N&(pt.N|pt.E|pt.S|pt.W)):Wk;for(let[N,T]of E)I.key&N&&w.push(`${x}/terrains_peering_bit/${T} = 0`)}}let[v,S,_]=it(l.palette.entries[0]?.hex??"#808080");o(`${l.name}.tres`,['[gd_resource type="TileSet" load_steps=3 format=3]',"",`[ext_resource type="Texture2D" path="res://${l.name}.png" id="1_tex"]`,"",'[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_1"]','texture = ExtResource("1_tex")',`texture_region_size = Vector2i(${d}, ${d})`,...w,"","[resource]",`tile_size = Vector2i(${d}, ${d})`,`terrain_set_0/mode = ${y}`,`terrain_set_0/terrain_0/name = "${l.name}"`,`terrain_set_0/terrain_0/color = Color(${(v/255).toFixed(3)}, ${(S/255).toFixed(3)}, ${(_/255).toFixed(3)}, 1)`,'custom_data_layer_0/name = "name"',"custom_data_layer_0/type = 4",'sources/0 = SubResource("TileSetAtlasSource_1")',""].join(`
177
+ `))}}var Qy=(e,t)=>{let r=e.get(t);if(!r)throw new yt(`no file '${t}'`);return s9(r)},Ri=(e,t)=>{let r=e.get(t);if(!r)throw new yt(`no image '${t}'`);return Kr(r)},eb=e=>e.includes("/")?e.slice(0,e.lastIndexOf("/")+1):"";function g9(e){let t=[],r=[],o="",n=!1;for(let i=0;i<e.length;i++){let s=e[i];if(n){s==='"'&&e[i+1]==='"'?(o+='"',i++):s==='"'?n=!1:o+=s;continue}s==='"'?n=!0:s===","?(r.push(o),o=""):s===`
178
+ `||s==="\r"?(s==="\r"&&e[i+1]===`
179
+ `&&i++,r.push(o),t.push(r),r=[],o=""):o+=s}return(o||r.length)&&(r.push(o),t.push(r)),t.filter(i=>i.length>1||i[0]!=="")}function y9(e,t){let r=e.records??{format:"csv"};if(r.format==="json")return JSON.parse(t).sprites;let o=g9(t),n=r.header===!1?r.columns??cO:o.shift()??[];return o.map(i=>Object.fromEntries(n.map((s,a)=>[s,i[a]??""])))}function b9(e,t){let r=(l,u=0)=>t[l]===void 0||t[l]===""?u:Number(t[l]),o=r("w"),n=r("h"),i=r("frameW",o),s=r("frameH",n),a={width:i,height:s,data:new Uint8Array(i*s*4)},c=zo(e,r("x"),r("y"),o,n);for(let l=0;l<n;l++)a.data.set(c.data.subarray(l*o*4,(l+1)*o*4),((r("cropY")+l)*i+r("cropX"))*4);return a}var tb=(e,t,r,o)=>{let n=Po(e,r,o);return t.has(n)?n:null};function w9(e,t,r){let o=qs(e),n=[],i=[],s=dO(o),a=Kk(o,r);if(o.layout==="loose"){let c=o.image??"{name}.png";for(let u of s)for(let m of a){let d=tb(o,t,_t(c,{name:m.name,asset:m.group}),u);d&&n.push({name:m.name,d:u,img:Ri(t,d)})}let l=new Set(s.flatMap(u=>a.map(m=>Po(o,_t(c,{name:m.name,asset:m.group}),u))));for(let u of[...t.keys()].sort())if(u.endsWith(".png")&&!l.has(u)){let m=/^(.*?)(?:@(\d)x)?\.png$/.exec(u.split("/").pop());n.push({name:m[1],d:Number(m[2]??1),img:Ri(t,u)})}}else if(o.layout==="atlas"){let c=o.page?.name??"atlas",l=o.records??{format:"csv"};for(let u of s){let m=tb(o,t,_t(l.file??`{page}.${l.format}`,{page:c}),u),d=tb(o,t,_t(o.page?.file??"{page}.png",{page:c}),u);if(!m||!d)continue;let f=Ri(t,d);for(let p of y9({...o,records:l},Qy(t,m)))n.push({name:String(p.sprite),d:u,img:b9(f,p)})}}else if(o.layout==="sheet")for(let c of[...new Set(a.map(l=>l.group))])for(let l of s){let u=tb(o,t,_t(o.image??"{asset}.png",{asset:c,name:c}),l);if(!u)continue;let m=Ri(t,u);for(let d of $9(o,a.filter(f=>f.group===c),l))n.push({name:d.name,d:l,img:zo(m,d.x,d.y,d.w,d.h)})}else if(o.layout==="aseprite-json")for(let c of[...t.keys()].sort()){if(!c.endsWith(".json"))continue;let l=JSON.parse(Qy(t,c));if(!l.meta?.image)continue;let u=Ri(t,eb(c)+l.meta.image),m=Number(l.meta.scale??1)||1;for(let d of l.frames)n.push({name:d.filename,d:m,img:zo(u,d.frame.x,d.frame.y,d.frame.w,d.frame.h)})}else if(o.layout==="tiled")for(let c of[...t.keys()].sort()){if(!c.endsWith(".tsx"))continue;let l=Qy(t,c),u=Number(/tilewidth="(\d+)"/.exec(l)?.[1]),m=Number(/tileheight="(\d+)"/.exec(l)?.[1]),d=Number(/columns="(\d+)"/.exec(l)?.[1]),f=/<tileset[^>]*>\s*<image source="([^"]+)"/.exec(l)?.[1],p=f?Ri(t,eb(c)+f):null;for(let h of l.matchAll(/<tile id="(\d+)">([\s\S]*?)<\/tile>/g)){let g=Number(h[1]),b=/<property name="name" value="([^"]*)"/.exec(h[2])?.[1];if(!b)continue;let y=/<image width="\d+" height="\d+" source="([^"]+)"/.exec(h[2])?.[1],w=y?Ri(t,eb(c)+y):p?zo(p,g%d*u,Math.floor(g/d)*m,u,m):null;w&&n.push({name:v9(b),d:1,img:w})}}else if(o.layout==="godot")for(let c of[...t.keys()].sort()){if(!c.endsWith(".tres"))continue;let l=Qy(t,c),u=/path="res:\/\/([^"]+)"/.exec(l)?.[1],m=/texture_region_size = Vector2i\((\d+), (\d+)\)/.exec(l);if(!u||!m)continue;let d=Ri(t,eb(c)+u),f=Number(m[1]);for(let p of l.matchAll(/^(\d+):(\d+)\/0\/custom_data_0 = "([^"]*)"$/gm)){let h=Number(p[1]),g=Number(p[2]),b=new RegExp(`^${h}:${g}/animation_separation = Vector2i\\((\\d+), 0\\)$`,"m").exec(l),y=[...l.matchAll(new RegExp(`^${h}:${g}/animation_frame_(\\d+)/duration`,"gm"))].length||1,w=a.find(v=>v.name===p[3]);for(let v=0;v<y;v++){let S=v===0?p[3]:a.find(_=>w&&_.doc===w.doc&&_.cell===w.cell&&_.frame===v)?.name;S&&n.push({name:S,d:1,img:zo(d,(h+v*(Number(b?.[1]??0)+1))*f,g*f,f,f)})}}}return{images:n,notes:i}}var v9=e=>e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");function $9(e,t,r){let o=t[0].doc,n=o.family&&!e.page?.columns?o.family:null,i=n?mt(n).cols:Math.max(1,Math.min(e.page?.columns??t.length,t.length)),s=Math.max(...t.map(u=>u.w*r)),a=Math.max(...t.map(u=>u.h*r)),c=e.page?.padding??0,l=n?mt(n).rows-n.mapRows:0;return t.map((u,m)=>{let d=n?(Math.floor(u.y/n.tile)+u.frame*l)*i+Math.floor(u.x/n.tile):m;return{name:u.name,x:d%i*(s+c),y:Math.floor(d/i)*(a+c),w:u.w*r,h:u.h*r}})}function pO(e,t,r){let o=qs(e),n=new Map,i=[];if(o.layout==="aseprite"){for(let m of[...t.keys()].sort()){if(!/\.(aseprite|ase)$/.test(m))continue;let d=m.split("/").pop().replace(/\.(aseprite|ase)$/,""),f=r.find(y=>y.name===d)??r.find(y=>Yk(o,y.densityOf?.of??"",y.densityOf?.d??0)===d);if(!f){i.push(`${m}: no asset named '${d}'`);continue}let p=Dm(Mm(t.get(m))),h=Gk(f,o.roles,o.colours),g=0,b=p.ms.map((y,w)=>{let v=new Uint16Array(p.width*p.height).fill(65535);return p.layers.forEach((S,_)=>{if(S.hidden||S.reference)return;let $=p.rgba[_][w];if(!$)return;let x=ir({width:p.width,height:p.height,data:$},f.palette,h);g+=x.inexact;for(let k=0;k<v.length;k++)x.px[k]!==65535&&(v[k]=x.px[k])}),v});n.set(f.name,{frames:b,inexact:g,images:b.length})}return{assets:n,unknown:[],notes:i}}let{images:s,notes:a}=w9(o,t,r);i.push(...a);let c=Kk(o,r),l=new Map(c.map(m=>[m.name,m])),u=[];for(let m of s){let d=l.get(m.name);if(!d){u.push(m);continue}let f=m.d===1?d.doc:r.find(w=>w.densityOf?.of===d.doc.name&&w.densityOf.d===m.d);if(!f)continue;let p=m.d,h=n.get(f.name);h||n.set(f.name,h={frames:Array.from({length:f.frameCount},()=>new Uint16Array(f.width*f.height).fill(65535)),inexact:0,images:0});let g=ir(m.img,d.doc.palette,Gk(d.doc,o.roles,o.colours));h.inexact+=g.inexact,h.images++;let b=f===d.doc?g.px:Ay(g.px,d.doc.palette,f.palette),y=h.frames[Math.min(d.frame,f.frameCount-1)];if(rb(y,f.width,b,m.img.width,0,0,Math.min(m.img.width,d.w*p),Math.min(m.img.height,d.h*p),d.x*p,d.y*p),d.mirror){let w=d.doc.views.find(_=>_.name===d.mirror),v=d.doc.views.find(_=>_.name===d.view),S=w.from+(d.frame-v.from);if(S<=w.to){let _=h.frames[S];for(let $=0;$<f.height;$++)for(let x=0;x<f.width;x++)_[$*f.width+x]=y[$*f.width+f.width-1-x]}}}return{assets:n,unknown:u,notes:i}}function hO(e,t){let r=[];for(let[o,n]of e.assets){let i=t.find(s=>s.name===o);n.frames.forEach((s,a)=>{let c=be(i,a),l=0;for(let u=0;u<s.length;u++)s[u]!==c[u]&&l++;l&&r.push(`${o} frame ${a+1}: ${l} pixels differ`)})}return r}var gO="pixelclaw-manifest",Xk=["planned","drafted","checked","reviewed","approved","exported"],yO=["S","N","E","W"],qm=/^[a-z][a-z0-9_-]*$/,x9=/^(\d+)x(\d+)$/,_9=/^#[0-9a-fA-F]{6}$/,S9=new Set(["name","kind","size","set","description","palette","scheme","inside","outside","band","frames","ticks","views","mirror","cells","height","variantOf","recolourOf","uses","flat","chars"]),bO=new Set(["format","version","theme","sets","export","assets","scenes"]),wO=new Set(["name","description","uses","map"]);function Yr(e){let t=x9.exec(e);return t&&Number(t[1])>0&&Number(t[2])>0?[Number(t[1]),Number(t[2])]:null}function Us(e,t={}){let r=[],o=(u,m)=>r.push({path:u,message:m});if(!e||typeof e!="object"||Array.isArray(e))return{manifest:null,errors:[{path:"",message:"a manifest is a JSON object"}]};let n=e;for(let u of Object.keys(n))bO.has(u)||o(u,`unknown field '${u}' (fields: ${[...bO].join(", ")})`);n.format!==gO&&o("format",`must be "${gO}"`),n.version!==1&&o("version","must be 1"),(typeof n.theme!="string"||!n.theme.trim())&&o("theme","the theme is a paragraph of text");let i=n.sets;if(i!==void 0)if(!i||typeof i!="object"||Array.isArray(i))o("sets","an object of set names");else for(let[u,m]of Object.entries(i))qm.test(u)||o(`sets.${u}`,"set names use a-z, 0-9, _ and -, starting with a letter"),(!m||typeof m!="object"||m.description!==void 0&&typeof m.description!="string")&&o(`sets.${u}`,'a set is { "description": "\u2026" }');let s=n.export;if(s!==void 0&&(!s||typeof s!="object"||typeof s.profile!="string"?o("export",'export is { "profile": "<name>", "dest": "<folder>" }'):(t.profiles&&!t.profiles.includes(s.profile)&&o("export.profile",`no profile '${s.profile}' (profiles: ${t.profiles.join(", ")})`),s.dest!==void 0&&typeof s.dest!="string"&&o("export.dest","a folder path"))),!Array.isArray(n.assets))return o("assets","a list of assets"),{manifest:null,errors:r};let a=new Map,c=n.assets;c.forEach((u,m)=>{let d=u?.name;typeof d=="string"&&(a.has(d)?o(`assets[${m}].name`,`'${d}' is already assets[${a.get(d)}]`):a.set(d,m))});let l=u=>c[a.get(u)??-1]?.kind;if(c.forEach((u,m)=>{let d=y=>`assets[${m}].${y}`;if(!u||typeof u!="object"||Array.isArray(u)){o(`assets[${m}]`,"an asset is an object");return}let f=u;for(let y of Object.keys(f))S9.has(y)||o(d(y),`unknown field '${y}'`);(typeof f.name!="string"||!qm.test(f.name))&&o(d("name"),"a name uses a-z, 0-9, _ and -, starting with a letter");let p=f.kind;ys.includes(p)||o(d("kind"),`one of ${ys.join(", ")}`);let h=typeof f.size=="string"?Yr(f.size):null;h?p==="family"&&(h[0]!==h[1]||h[0]%2)?o(d("size"),`a family's tiles are square and even (${f.size})`):p!=="map"&&(h[0]>4096||h[1]>4096)&&o(d("size"),"at most 4096 px a side"):o(d("size"),p==="map"?'cells like "40x30"':'pixels like "24x24"');let g=y=>{f[y]!==void 0&&typeof f[y]!="string"&&o(d(y),"text")};for(let y of["set","description","palette","scheme","inside","outside","band","cells","variantOf","recolourOf","flat"])g(y);if(typeof f.set=="string"&&!qm.test(f.set)&&o(d("set"),"set names use a-z, 0-9, _ and -, starting with a letter"),typeof f.palette=="string"&&t.palettes&&!t.palettes.includes(f.palette)&&o(d("palette"),`no palette '${f.palette}' in the project`),p==="family")typeof f.scheme!="string"?o(d("scheme"),"a family needs a scheme"):t.schemes&&!t.schemes.includes(f.scheme)&&o(d("scheme"),`no scheme '${f.scheme}' (schemes: ${t.schemes.join(", ")})`),typeof f.band=="string"&&!/^(\d+:[A-Za-z0-9_-]+\s*)+(\s+(radius|inset|fillet)=\d+)*$/.test(f.band.trim())&&o(d("band"),'a band profile like "3:outside 1:foam 2:sand0 radius=3"');else for(let y of["scheme","inside","outside","band"])f[y]!==void 0&&o(d(y),`${y} is for families`);for(let y of["inside","outside"]){let w=f[y];typeof w=="string"&&w!=="none"&&a.has(w)&&!["tile","family"].includes(l(w)??"")&&o(d(y),`'${w}' is not a tile`)}let b=(y,w,v)=>{f[y]!==void 0&&(!Number.isInteger(f[y])||f[y]<w||f[y]>v)&&o(d(y),`a whole number ${w}..${v}`)};if(b("frames",1,256),b("ticks",1,600),f.height!==void 0&&(b("height",1,4096),h&&Number.isInteger(f.height)&&f.height>h[1]&&o(d("height"),`taller than its size (${f.size})`)),f.views!==void 0&&((!Array.isArray(f.views)||!f.views.every(y=>yO.includes(y))||new Set(f.views).size!==f.views.length)&&o(d("views"),`directions from ${yO.join(", ")}, each once`),["sprite","object","sheet"].includes(p)||o(d("views"),"views are for sprites and objects")),f.mirror!==void 0){let y=Array.isArray(f.views)?f.views:[];if(!f.mirror||typeof f.mirror!="object"||Array.isArray(f.mirror))o(d("mirror"),'an object like { "W": "E" }');else for(let[w,v]of Object.entries(f.mirror))(!y.includes(w)||typeof v!="string"||!y.includes(v)||w===v)&&o(d(`mirror.${w}`),`a mirror pairs two of the asset's views (${y.join(", ")||"none"})`)}f.cells!==void 0&&((typeof f.cells!="string"||!Yr(f.cells))&&o(d("cells"),'cells like "2x2"'),p!=="object"&&o(d("cells"),"a footprint is for objects"));for(let y of["variantOf","recolourOf"]){let w=f[y];typeof w=="string"&&(a.has(w)?w===f.name?o(d(y),"not itself"):l(w)!==p&&o(d(y),`'${w}' is a ${l(w)}, not a ${p}`):o(d(y),`no asset '${w}' in the manifest`))}if(f.uses!==void 0){if(!Array.isArray(f.uses)||!f.uses.every(y=>typeof y=="string"))o(d("uses"),"a list of asset names");else for(let y of f.uses)a.has(y)||o(d("uses"),`no asset '${y}' in the manifest`);p!=="map"&&o(d("uses"),"uses is for maps")}f.chars!==void 0&&(p!=="font"?o(d("chars"),"chars is for fonts"):(typeof f.chars!="string"||typeof cm(f.chars,!/^[0-9U+,\-]+$/.test(f.chars))=="string")&&o(d("chars"),'code points and ranges like "32-126", or the characters themselves')),typeof f.flat=="string"&&!_9.test(f.flat)&&!qm.test(f.flat.toLowerCase())&&o(d("flat"),"a palette entry name or #rrggbb"),typeof f.set=="string"&&i&&typeof i=="object"&&!(f.set in i)&&o(d("set"),`no set '${f.set}' in sets`)}),n.scenes!==void 0)if(!Array.isArray(n.scenes))o("scenes","a list of scenes");else{let u=new Set;n.scenes.forEach((m,d)=>{let f=h=>`scenes[${d}]${h?`.${h}`:""}`;if(!m||typeof m!="object"||Array.isArray(m)){o(f(""),'a scene is { "name", "description", "uses": [...], "map" }');return}let p=m;for(let h of Object.keys(p))wO.has(h)||o(f(h),`unknown field '${h}' (fields: ${[...wO].join(", ")})`);if(typeof p.name!="string"||!qm.test(p.name)?o(f("name"),"a name uses a-z, 0-9, _ and -, starting with a letter"):u.has(p.name)?o(f("name"),`scene '${p.name}' is already listed`):u.add(p.name),p.description!==void 0&&typeof p.description!="string"&&o(f("description"),"text"),!Array.isArray(p.uses)||!p.uses.every(h=>typeof h=="string"))o(f("uses"),"a list of asset names");else for(let h of p.uses)a.has(h)||o(f("uses"),`no asset '${h}' in the manifest`);p.map!==void 0&&(typeof p.map!="string"||!a.has(p.map)?o(f("map"),`no asset '${String(p.map)}' in the manifest`):l(p.map)!=="map"&&o(f("map"),`'${p.map}' is a ${l(p.map)}, not a map`))})}return{manifest:r.length?null:n,errors:r}}function $O(e,t,r){let o=[],n=a=>{o.includes(a)||o.push(a)};for(let a of t.uses)n(a);if(t.map){for(let a of e.assets.find(c=>c.name===t.map)?.uses??[])n(a);n(t.map)}let i=o.filter(a=>r(a)==="planned"),s=o.filter(a=>r(a)==="drafted");return{needs:o,missing:i,unfinished:s}}function Ls(e){return e.set??e.kind}function vO(e,t){for(let r=e.length-1;r>=0;r--)if(t.includes(e[r].name))return e[r];return null}function xO(e){let t=[];if(!e.exists)return{status:"planned",next:"draw it",flags:t};if(e.checksPass!==!0)return{status:"drafted",next:e.checksPass===null?"run the checks":"make every check pass",flags:t};let r=vO(e.marks,["reviewed"]);if(r&&r.art!==e.art&&t.push(`the art changed since it was reviewed (#${r.seq})`),!r||r.art!==e.art)return{status:"checked",next:"a blind review, then `mark reviewed`",flags:t};let o=vO(e.marks,["approved","rejected"]);return o?.name==="rejected"&&t.push(`changes asked for (#${o.seq}${o.text?`: ${o.text}`:""})`),o?.name==="approved"&&o.art!==e.art&&t.push(`the art changed since it was approved (#${o.seq})`),!o||o.name!=="approved"||o.art!==e.art||o.seq<r.seq?{status:"reviewed",next:o?.name==="rejected"?"make the changes asked for, then review again":"a person approves it in the dashboard",flags:t}:(e.exportedArt&&e.exportedArt!==e.art&&t.push("exported before its last change: export again"),e.exportedArt!==e.art?{status:"approved",next:"export it through the profile",flags:t}:{status:"exported",next:"done",flags:t})}var Qk=[[122,158,88],[84,128,168],[196,170,112],[150,112,84],[128,128,136],[176,98,82],[104,150,140],[190,140,70],[136,104,150],[92,112,72],[208,196,160],[70,90,120]],Um=(e,t=.68)=>[Math.round(e[0]*t),Math.round(e[1]*t),Math.round(e[2]*t)];function zr(e,t,r,o,n,i){for(let s=Math.max(0,r);s<Math.min(e.height,r+n);s++)for(let a=Math.max(0,t);a<Math.min(e.width,t+o);a++){let c=(s*e.width+a)*4;e.data[c]=i[0],e.data[c+1]=i[1],e.data[c+2]=i[2],e.data[c+3]=255}}function k9(e,t,r,o,n,i){zr(e,t,r,o,1,i),zr(e,t,r+n-1,o,1,i),zr(e,t,r,1,n,i),zr(e,t+o-1,r,1,n,i)}function _O(e,t,r=0){let o=[],n=0;for(let a of(e??"").trim().split(/\s+/).filter(Boolean)){let c=/^(\d+):(\S+)$/.exec(a);c&&o.push({w:Number(c[1]),what:c[2]});let l=/^radius=(\d+)$/.exec(a);l&&(n=Number(l[1]))}o.length||o.push({w:Math.max(1,Math.floor(t/12)),what:"edge"});let i=o.map(a=>({w:a.w,fill:a.what==="outside"?"outside":a.what==="inside"?"inside":0})),s=i.reduce((a,c)=>a+c.w,0);return{inset:r,radius:Math.min(n,Math.max(0,Math.floor(t/2)-r-s)),bands:i}}function SO(e,t,r,o,n,i,s=0,a=0){let c=hi(t,r),l=xo(t,o,n);return c.forEach((u,m)=>{let d=m%r.cols*o+s,f=Math.floor(m/r.cols)*o+a;if(u!==null&&pi(t.variants[u].on)){i.outside&&zr(e,d,f,o,o,i.outside);let p=t.variants[u];p.on==="face"?zr(e,d,f,o,Math.max(1,o/2),Um(i.band)):p.quads.forEach((h,g)=>{h!=="out"&&zr(e,d+(g&1?o/2:0),f+(g&2?o/2:0),o/2,o/2,Um(i.band))});return}for(let p=0;p<o;p++)for(let h=0;h<o;h++){let g=u===null?-1:l[u][p*o+h],b=g>=0&&g<n.bands.length?n.bands[g].fill:null,y=g<0||b==="outside"?i.outside:typeof b=="number"?i.band:i.inside;y&&zr(e,d+h,f+p,1,1,y)}}),c}function z9(e){let t=bo(e).length;if(t<=16)return[6,6];let r=Math.ceil(t*2.6),o=Math.max(6,Math.round(Math.sqrt(r*3/4)));return[Math.max(8,Math.ceil(r/o)),o]}function kO(e,t){let[r,o]=t.size??z9(e),n=null;for(let f=0;f<4&&!n;f++)n=qy(e,r,o,t.seed??1),n||(r+=2,o+=2);if(!n)return null;let i=ut(r*t.tile,o*t.tile),s=_O(t.band,t.tile,t.inset??0),a=SO(i,e,n,t.tile,s,{inside:t.inside,outside:t.outside,band:Um(t.inside)}),c=a.map(f=>f===null?"-":e.variants[f].name),l=Math.max(...c.map(f=>f.length)),u=Array.from({length:o},(f,p)=>`${String(p).padStart(3)}: ${c.slice(p*r,p*r+r).map(h=>h.padEnd(l)).join(" ").trimEnd()}`),m=Es(e,n),d=bo(e).filter(f=>!m[f]);return{cols:r,rows:o,tile:t.tile,terrain:n,variants:a,img:i,text:`${e.name}: ${r}x${o} tiles of ${t.tile} px, ${bo(e).length-d.length} of ${bo(e).length} variants
180
+
181
+ ${u.join(`
182
+ `)}
183
+ `}}function zO(e,t){let{cols:r,rows:o,tile:n}=t,i=new dt(t.seed??1,960),s=ut(r*n,o*n),a=new Map(e.assets.map((x,k)=>[x.name,t.colour(x,k)])),c=e.assets.filter(x=>x.kind==="tile"&&!x.variantOf&&!x.recolourOf),l=e.assets.filter(x=>x.kind==="family"&&!x.variantOf&&!x.recolourOf),u=l.find(x=>x.outside&&c.some(k=>k.name===x.outside))?.outside??c[0]?.name??null,m=u?a.get(u):[60,60,60];zr(s,0,0,s.width,s.height,m);let d=new Map,f="abcdefghijklmnopqrstuvwxyz",p=x=>d.get(x)??d.set(x,f[d.size%26]).get(x),h=Array.from({length:r*o},()=>u?p(u):"."),g=new Uint8Array(r*o).fill(1);l.slice(0,4).forEach((x,k)=>{let P=t.scheme(x.scheme??"");if(!P)return;let I={cols:r,rows:o,cells:new Uint8Array(P.neighbours==="corners"?(r+1)*(o+1):r*o)},E=P.neighbours==="corners"?r+1:r;if(P.name==="path"||P.name==="bridge8"){let Z=1+i.nextInt(Math.max(1,o-2)),D=1+i.nextInt(Math.max(1,o-2)),V=2+i.nextInt(Math.max(1,r-4));for(let F=0;F<E;F++)I.cells[(F<V?Z:D)*E+F]=1;for(let F=Math.min(Z,D);F<=Math.max(Z,D);F++)I.cells[F*E+V]=1}else{let Z=$i(P,Math.ceil(r*.6),Math.ceil(o*.7),(t.seed??1)+k*7),D=P.neighbours==="corners"?Z.cols+1:Z.cols,V=k%2?r-Z.cols:0,F=k>=2?o-Z.rows:0;for(let M=0;M<Z.cells.length/D;M++)for(let L=0;L<D;L++)Z.cells[M*D+L]&&M+F<I.cells.length/E&&L+V<E&&(I.cells[(M+F)*E+L+V]=1)}let N=x.inside&&a.has(x.inside)?a.get(x.inside):a.get(x.name),T=_O(x.band,n);SO(s,P,I,n,T,{inside:N,outside:null,band:Um(N)}).forEach((Z,D)=>{Z!==null&&(h[D]=p(x.inside??x.name),g[D]=0)})});let b=e.assets.filter(x=>(x.kind==="object"||x.kind==="sprite")&&!x.variantOf&&!x.recolourOf).sort((x,k)=>x.kind===k.kind?0:x.kind==="object"?-1:1),y=[];for(let x of b){let[k,P]=Yr(x.size)??[n,n],I=Math.max(1,Math.ceil(k/n)),E=Math.max(1,Math.ceil(P/n)),N=[];for(let z=0;z+E<=o;z++)for(let R=0;R+I<=r;R++){let C=!0;for(let U=-1;U<=E&&C;U++)for(let W=-1;W<=I&&C;W++){let X=R+W,Y=z+U;if(X<0||Y<0||X>=r||Y>=o)continue;(W>=0&&U>=0&&W<I&&U<E?!g[Y*r+X]:g[Y*r+X]===2)&&(C=!1)}C&&N.push(z*r+R)}if(!N.length)continue;let T=N[i.nextInt(N.length)],q=T%r,Z=Math.floor(T/r),D=x.cells?Math.min(E,Yr(x.cells)[1]):E;for(let z=0;z<E;z++)for(let R=0;R<I;R++)g[(Z+z)*r+q+R]=2,z>=E-D&&(h[(Z+z)*r+q+R]=p(x.name).toUpperCase());let V=Math.min(P,x.height??P),F=x.kind==="sprite"?Math.max(4,Math.round(k*2/3)):k,M=q*n+Math.floor((I*n-F)/2),L=(Z+E)*n-V-(x.kind==="sprite"?1:0),A=a.get(x.name);zr(s,M,L,F,V,A),k9(s,M,L,F,V,Um(A,.45)),y.push({name:x.name,x:M,y:L,w:F,h:V})}let w=t.scale??2,v=ut(s.width*w,s.height*w);for(let x=0;x<v.height;x++)for(let k=0;k<v.width;k++){let P=(Math.floor(x/w)*s.width+Math.floor(k/w))*4,I=(x*v.width+k)*4;v.data.set(s.data.subarray(P,P+4),I)}for(let x of y){let k=Math.max(1,w-1),P=x.name.length*4*k-k,I=Math.max(k,Math.min(v.width-P-2*k,x.x*w+Math.floor((x.w*w-P)/2))),E=Math.max(k,x.y*w-7*k);zr(v,I-k,E-k,P+2*k,7*k,[24,24,28]),eC(v,I,E,x.name,[236,236,236],k)}let S=[...d].map(([x,k])=>b.some(P=>P.name===x)?` ${k.toUpperCase()} ${x} stands here`:` ${k} ${x}`),_=Array.from({length:o},(x,k)=>`${String(k).padStart(3)}: ${h.slice(k*r,k*r+r).join("")}`),$=[...new Set(e.assets.map(Ls))];return{cols:r,rows:o,tile:n,img:s,labelled:v,placed:y,text:`A mockup screen, ${r}x${o} cells of ${n} px, laid out from the manifest (sets: ${$.join(", ")}).
184
+
185
+ ${_.join(`
186
+ `)}
187
+
188
+ ${S.join(`
189
+ `)}
190
+ `}}var RO=["draw","change","new"];var R9=/^r\d+$/,I9=/^[a-z][a-z0-9_-]*$/;function Lm(e,t){if(!t||typeof t!="object"||typeof t.id!="string"||!R9.test(t.id))return"a request id looks like r12";if(typeof t.by!="string"||!t.by)return"a record needs who wrote it (by)";if(typeof t.at!="string")return"a record needs a time (at)";if(t.type==="request")return e.has(t.id)?`request ${t.id} already exists`:typeof t.asset!="string"||!I9.test(t.asset)?"a request names an asset (a-z, 0-9, _ and -)":RO.includes(t.kind)?typeof t.note!="string"?"a request has a note (it may be empty)":t.kind==="change"&&!t.note.trim()?"a change request says what should change":null:`a request's kind is ${RO.join(", ")}`;let r=e.get(t.id);if(!r)return`no request ${t.id}`;if(t.text!==void 0&&typeof t.text!="string")return"text is text";let o=(n,i)=>n?null:`${t.id} is ${r.state}: ${i}`;switch(t.type){case"claim":return o(r.state==="open"||r.state==="claimed"&&r.claimedBy===t.by,r.state==="claimed"?`${r.claimedBy} has it`:"only an open request can be claimed");case"progress":return o(r.state==="claimed"&&r.claimedBy===t.by,"progress is posted by whoever claimed it")??(t.text?.trim()?null:"progress needs text");case"done":return o(r.state==="claimed"&&r.claimedBy===t.by,"claim it before finishing it")??(t.text?.trim()?null:"say what changed");case"blocked":return o(r.state==="claimed"&&r.claimedBy===t.by,"claim it before blocking it")??(t.text?.trim()?null:"a blocked request asks a question");case"reply":return o(r.state==="blocked","only a blocked request takes a reply")??(t.text?.trim()?null:"a reply needs text");case"cancel":return o(r.state==="open"||r.state==="claimed"||r.state==="blocked","it is already finished");default:return`unknown record type '${t.type}'`}}function P9(e,t){if(t.type==="request"){e.set(t.id,{id:t.id,asset:t.asset,kind:t.kind,note:t.note,by:t.by,at:t.at,...t.mark!==void 0?{mark:t.mark}:{},state:"open",claimedBy:null,latest:null,question:null,events:[]});return}let r=e.get(t.id);switch(r.events.push({type:t.type,by:t.by,at:t.at,...t.text!==void 0?{text:t.text}:{}}),t.type){case"claim":r.state="claimed",r.claimedBy=t.by;break;case"progress":r.latest=t.text??null;break;case"done":r.state="done",r.latest=t.text??null,r.question=null;break;case"blocked":r.state="blocked",r.latest=t.text??null,r.question=t.text??null;break;case"reply":r.state="open",r.claimedBy=null,r.question=null,r.latest=t.text??null;break;case"cancel":r.state="cancelled";break}}function e1(e){let t=new Map,r=[];return e.forEach((o,n)=>{let i=Lm(t,o);i?r.push(`record ${n+1}: ${i}`):P9(t,o)}),{requests:t,problems:r}}function IO(e){let t=0;for(let r of e.keys())t=Math.max(t,Number(r.slice(1)));return`r${t+1}`}function Rr(e){let t={open:0,claimed:1,blocked:2,done:3,cancelled:4};return[...e.values()].filter(r=>t[r.state]<3).sort((r,o)=>t[r.state]-t[o.state]||Number(r.id.slice(1))-Number(o.id.slice(1)))}function PO(e,t,r){let[o,n]=r.cell,[i,s]=r.offset??[0,0],[a,c]=r.gap??[0,0];if(o<1||n<1||i<0||s<0||a<0||c<0)return[];let l=[];for(let u=0,m=s;m+n<=t;u++,m+=n+c)for(let d=0,f=i;f+o<=e;d++,f+=o+a)l.push({col:d,row:u,x:f,y:m});return l}var j9="{name}_{n}";function Fm(e,t="imported"){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"_").replace(/^[^a-z]+/,"").replace(/_+$/,"")||t}function jO(e,t){let r;if(t.names){if(t.names.length<e.length)return`${e.length} cells but only ${t.names.length} names`;r=t.names.slice(0,e.length)}else{let n=t.pattern?.trim()||j9;r=e.map((i,s)=>Fm(n.replace(/\{name\}/g,t.base).replace(/\{n\}/g,String(s+1)).replace(/\{col\}/g,String(i.col)).replace(/\{row\}/g,String(i.row)),t.base))}let o=new Set;for(let n of r){if(o.has(n))return`the name '${n}' comes out twice (put {n}, or {col} and {row}, in the pattern)`;o.add(n)}return r}import{mkdirSync as FO,writeFileSync as L9}from"node:fs";import{join as VO}from"node:path";import{createHash as E9}from"node:crypto";import{existsSync as Ir,mkdirSync as ob,readFileSync as Xr,readdirSync as Vm,realpathSync as T9,rmSync as CO,writeFileSync as Fs}from"node:fs";import{basename as AO,dirname as C9,join as Ge,resolve as EO,sep as A9}from"node:path";var t1="pixelclaw-project",n1=200,ee=class extends Error{};function Tn(e){return E9("sha256").update(e).digest("hex")}function Zm(e,t){Fs(e,JSON.stringify(t,null,2)+`
191
+ `)}function ib(e,t){if(Ir(Ge(e,"project.json")))throw new ee(`${e} is already a project`);let r=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop().replace(/\.pclaw$/,""),o={format:t1,version:1,name:t.name??r,tickRate:60,defaultPalette:t.palettes[0]?.name??null,grid:t.grid??24,style:{},profiles:[]};ob(Ge(e,"palettes"),{recursive:!0}),ob(Ge(e,"assets"),{recursive:!0});for(let n of t.palettes)Fs(Ge(e,"palettes",`${n.name}.json`),po(n));return Zm(Ge(e,"project.json"),o),At(e)}function At(e){let t=Ge(e,"project.json");if(!Ir(t))throw new ee(`${e} is not a PixelClaw project (no project.json); create one with 'pixelclaw new ${e}'`);let r=JSON.parse(Xr(t,"utf8"));if(r.format!==t1)throw new ee(`${t}: not a ${t1} file`);let o=new Map,n=Ge(e,"palettes");if(Ir(n))for(let i of Vm(n).sort()){if(!/\.(json|hex|gpl)$/i.test(i))continue;let s;try{s=RS(i,Xr(Ge(n,i),"utf8"))}catch(a){throw new ee(`palettes/${i}: ${a.message}`)}if(o.has(s.name))throw new ee(`palettes/${i}: a palette named '${s.name}' is already loaded`);o.set(s.name,s)}return{dir:e,json:r,palettes:o}}function jo(e){return{get:t=>e.palettes.get(t),defaultName:e.json.defaultPalette??void 0,scheme:t=>O9(e.dir,t)}}function O9(e,t){let r=Ge(e,"schemes");if(Ir(r))for(let o of Vm(r).filter(n=>n.endsWith(".json")).sort())try{let n=JSON.parse(Xr(Ge(r,o),"utf8"));if(n.name===t)return n}catch{}}function Vs(e,t){if(!t||/[\\/]/.test(t)||t.startsWith("."))throw new ee(`'${t}' is not an asset name`);return Ge(e.dir,"assets",t)}function TO(e){let t=[],r=e;for(;;)try{return Ge(T9(r),...t.reverse())}catch{let o=C9(r);if(o===r)return e;t.push(AO(r)),r=o}}function N9(e,t){let r=TO(EO(e.dir)),o=TO(EO(t));return o===r||o.startsWith(r+A9)}function Hm(e,t,r){if(!N9(e,t))throw new ee(`${r}: '${t}' is outside the project folder, and the worker stays inside it`)}function Ii(e){let t=Ge(e.dir,"assets");return Ir(t)?Vm(t).filter(r=>Ir(Ge(t,r,"tape.jsonl"))).sort():[]}function Eo(e,t){return Ir(Ge(Vs(e,t),"tape.jsonl"))}function Bm(e,t){return Wm(e,t).entries}function Wm(e,t){let r=Ge(Vs(e,t),"tape.jsonl");if(!Ir(r))throw new ee(`no asset '${t}' in ${e.dir}`);let o=Xr(r);return{bytes:o,entries:JA(o.toString("utf8"))}}function OO(e,t){return JSON.parse(Xr(Ge(Vs(e,t),"asset.json"),"utf8"))}var M9=/^fork (\S+) \S+ at=(\d+)$/;function sb(e){for(let t of e){let r=M9.exec(t.cmd);if(r)return{from:r[1],at:Number(r[2])}}return null}function D9(e,t){let r=sb(t);return{name:e.name,kind:e.kind,size:[e.width,e.height],cell:[e.cellW,e.cellH],wrap:e.wrap,palette:e.palette.name,layers:e.layers.map(o=>({...o})),frames:e.frameCount,paletteLocked:e.paletteLocked,stamps:Object.keys(e.stamps).sort(),macros:Object.keys(e.macros).sort(),tags:[],views:[],links:r?[{fork:r}]:[],notes:e.notes,tape:{lang:kr(t),commands:t.length,groups:new Set(t.map(o=>o.group)).size},state:{sha256:Tn(Rn(e))},checkpoints:{every:n1,files:cb(t.length)}}}function ab(e){try{return RS(AO(e),Xr(e,"utf8"))}catch(t){throw new ee(`${e}: ${t.message}`)}}function NO(e,t){if(!Number.isInteger(t)||t<4||t>256)throw new ee("grid must be the cell size in pixels, 4..256");e.json.grid=t,Zm(Ge(e.dir,"project.json"),e.json)}function MO(e,t){for(let r of t)if(e.palettes.has(r.name))throw new ee(`the project already has a palette named '${r.name}'`);ob(Ge(e.dir,"palettes"),{recursive:!0});for(let r of t)Fs(Ge(e.dir,"palettes",`${r.name}.json`),po(r)),e.palettes.set(r.name,r);!e.json.defaultPalette&&t[0]&&(e.json.defaultPalette=t[0].name,Zm(Ge(e.dir,"project.json"),e.json))}function r1(e){return Le(vi(e))}var q9="PCLAWCKPT 1";function cb(e){let t=[];for(let r=n1;r<=e;r+=n1)t.push(`${String(r).padStart(6,"0")}.gwc`);return t}function lb(e,t){return Tn(Buffer.from(e.slice(0,t).map(Uk).join(`
192
+ `),"utf8"))}function U9(e,t,r){let o=Buffer.from(`${q9} ${t} ${lb(e,t)}
193
+ `,"utf8"),n=r?Rn(r):new Uint8Array(0);return Buffer.concat([o,n])}function o1(e,t){let r=Ge(Vs(e,t),"checkpoints");if(!Ir(r))return[];let o=[];for(let n of Vm(r).filter(i=>i.endsWith(".gwc")).sort()){let i=Xr(Ge(r,n)),s=i.indexOf(10),a=s>0?/^PCLAWCKPT 1 (\d+) ([0-9a-f]{64})$/.exec(i.subarray(0,s).toString("utf8")):null;o.push(a?{file:n,n:Number(a[1]),hash:a[2],body:i.subarray(s+1)}:{file:n,n:-1,hash:"",body:new Uint8Array(0)})}return o}function DO(e,t,r){let o=o1(e,t).filter(n=>n.n>0&&n.n<=r.length).sort((n,i)=>i.n-n.n);for(let n of o)if(!(n.hash!==lb(r,n.n)||n.body.length===0))try{return{n:n.n,doc:ey(n.body)}}catch{}return null}function ub(e,t,r,o=!1){let n=t.doc;if(!n)throw new ee("nothing to save: the tape has no document");let i=Vs(e,n.name),s=Ge(i,"checkpoints");ob(s,{recursive:!0}),Fs(Ge(i,"tape.jsonl"),Yy(t.entries)),Zm(Ge(i,"asset.json"),D9(n,t.entries)),Fs(Ge(i,"preview.png"),r1(n));let a=new Set(cb(t.entries.length));for(let c of Vm(s))c.endsWith(".gwc")&&(o||!a.has(c))&&CO(Ge(s,c),{force:!0});if(r)for(let c of a){if(Ir(Ge(s,c)))continue;let l=Number(c.slice(0,6));Fs(Ge(s,c),U9(t.entries,l,r(l)))}return i}var qO="reads.json";function UO(e){try{return JSON.parse(Xr(Ge(e.dir,qO),"utf8"))}catch{return{}}}function LO(e,t){Zm(Ge(e.dir,qO),t)}var i1=".pixelclaw.lock";function s1(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function Jm(e){let t=Ge(e,i1);if(!Ir(t))return null;try{let r=JSON.parse(Xr(t,"utf8"));return r.pid!==process.pid&&s1(r.pid)?r:null}catch{return null}}function a1(e,t){let r=Jm(e);if(r)throw new ee(`another pixelclaw server (pid ${r.pid}) owns ${e}; watch it at ${r.url.replace(/\?.*$/,"")}`);Fs(Ge(e,i1),JSON.stringify({pid:process.pid,url:t.replace(/\?.*$/,"")})+`
194
+ `)}function c1(e){let t=Ge(e,i1);try{JSON.parse(Xr(t,"utf8")).pid===process.pid&&CO(t,{force:!0})}catch{}}var Km=["split","png","strip","bmfont"];function Gm(e,t,r,o){let n=new Uint8Array(t*r*4),i=o.map(s=>[parseInt(s.hex.slice(1,3),16),parseInt(s.hex.slice(3,5),16),parseInt(s.hex.slice(5,7),16)]);for(let s=0;s<e.length;s++){let a=e[s];if(a===65535)continue;let c=i[a];n[s*4]=c[0],n[s*4+1]=c[1],n[s*4+2]=c[2],n[s*4+3]=255}return{width:t,height:r,data:n}}function mb(e,t,r,o){FO(o,{recursive:!0});let n=[],i=(s,a)=>{let c=VO(o,s);FO(VO(c,".."),{recursive:!0}),L9(c,a),n.push(c)};if(r==="split"){if(e.map||e.family||e.overlay)throw new ee(`'${e.name}' is a ${e.kind}; split takes an oversized tile or object`);if(e.width%e.cellW||e.height%e.cellH)throw new ee(`'${e.name}' is ${e.width}x${e.height}, not whole ${e.cellW}x${e.cellH} cells (new \u2026 cell=<W>x<H>)`);let{pieces:s,stamp:a}=BT(e);for(let c of s)i(`${e.name}/${c.name}.png`,Le(Gm(c.px,e.cellW,e.cellH,e.palette.entries)));return i(`${e.name}/${e.name}.stamp.json`,JSON.stringify(a,null,2)+`
195
+ `),n}if(r==="strip"||r==="bmfont"){if(!e.font)throw new ee(`'${e.name}' is a ${e.kind}; ${r} takes a font`);let s=e.palette.entries.map(a=>a.hex);try{if(r==="strip"){let a=iy(e,s);i(`${e.name}.png`,Le(a.img)),i(`${e.name}.txt`,a.chars+`
196
+ `)}else{let a=sy(e,s,`${e.name}_0.png`);i(`${e.name}.fnt`,a.fnt),i(`${e.name}_0.png`,Le(a.img))}}catch(a){throw a instanceof ho?new ee(a.message):a}return n}if(e.map){let s=Bt(e,qn(t));i(`${e.name}.png`,Le(Gm(s.px,s.w,s.h,s.palette)))}else i(`${e.name}.png`,Le(Gm(be(e,0),e.width,e.height,e.palette.entries)));return n}var Ym=/^human:[A-Za-z0-9_.-]{1,32}$/;import{existsSync as YO,mkdirSync as G9,readFileSync as K9,writeFileSync as XO}from"node:fs";import{join as od}from"node:path";import{existsSync as Zs,mkdirSync as ZO,readFileSync as To,readdirSync as fb,statSync as u1,writeFileSync as f1}from"node:fs";import{basename as Un,extname as m1,isAbsolute as F9,join as on,relative as p1,resolve as d1}from"node:path";function Qm(e){let t=new Map,r=on(e,"schemes");if(!Zs(r))return t;for(let o of fb(r).filter(n=>n.endsWith(".json")).sort())try{let n=JSON.parse(To(on(r,o),"utf8"));t.set(n.name,n)}catch(n){throw new ee(`schemes/${o}: ${n.message}`)}return t}function ed(e){let t=new Map(lO),r=[],o=on(e.dir,"profiles");Zs(o)&&r.push(...fb(o).filter(n=>n.endsWith(".json")).sort().map(n=>on(o,n)));for(let n of e.json.profiles??[])r.push(F9(n)?n:on(e.dir,n));for(let n of r)try{let i=qs(JSON.parse(To(n,"utf8")));t.set(i.name,i)}catch(i){throw new ee(`${p1(e.dir,n)||n}: ${i.message}`)}return t}function HO(e,t){if(t.endsWith(".json")&&Zs(d1(t)))return qs(JSON.parse(To(d1(t),"utf8")));let r=ed(e),o=r.get(t);if(!o)throw new ee(`no profile '${t}' (profiles: ${[...r.keys()].join(", ")})`);return o}function V9(e,t){if(!t?.length)return e.map(i=>i.doc);let r=new Map(e.map(i=>[i.name,i.doc])),o=new Set,n=i=>{if(o.has(i)||!r.has(i))return;o.add(i);let s=r.get(i);if(s.map){for(let a of s.map.entries)n(a.name);for(let a of s.layers)a.map?.kind==="terrain"?n(a.map.family):a.map?.kind==="overlay"&&n(a.map.overlay)}for(let a of e)(a.doc.variantOf===i||a.doc.densityOf?.of===i)&&n(a.name)};for(let i of t){if(!r.has(i))throw new ee(`no asset '${i}'`);n(i)}return e.filter(i=>o.has(i.name)).map(i=>i.doc)}var BO="exported.json";function h1(e){try{return JSON.parse(To(on(e.dir,BO),"utf8"))}catch{return{}}}function Z9(e,t,r,o,n){let i=h1(e),s=p1(e.dir,o),a=s&&!s.startsWith("..")?s:o;for(let l of t)i[l.name]={profile:r,dir:a,at:n,art:hc(l)};let c=Object.fromEntries(Object.keys(i).sort().map(l=>[l,i[l]]));f1(on(e.dir,BO),JSON.stringify(c,null,2)+`
197
+ `)}function pb(e,t,r,o={}){let n=HO(e,r),i=V9(t,o.names),s=fO(n,i,{tickRate:e.json.tickRate,world:qn(t)}),a=o.dest??on(e.dir,"exports",n.name),c=[];for(let[l,u]of s.files){let m=on(a,l);ZO(on(m,".."),{recursive:!0}),f1(m,u),c.push(m)}return o.at&&Z9(e,i,n.name,a,o.at),{dir:a,files:c,images:s.items.length,notes:s.notes}}function H9(e){let t=new Map,r=o=>{for(let n of fb(o).sort()){let i=on(o,n);u1(i).isDirectory()?r(i):t.set(p1(e,i).split("\\").join("/"),To(i))}};return r(e),t}function Pi(e,t,r){let o=Tn(t),n=on(e.dir,"blobs");ZO(n,{recursive:!0});let i=on(n,`${o}${r}`);return Zs(i)||f1(i,t),o}var db=(e,t)=>e.toLowerCase().replace(/[^a-z0-9_-]+/g,"_").replace(/^[^a-z]+/,"")||t;function Ac(e){let t=e.palette.entries.map(a=>a.key),r=e.cels[0]?.length??1,o=e.cell?` cell=${e.cell[0]}x${e.cell[1]}`:"",n=[`new ${e.kind} ${e.name} ${e.width}x${e.height} palette=${e.palette.name}${e.kind==="tile"?" wrap=off":""}${o} bg=none <<
198
+ ${Wt(ty(e.palette))}>>`],i=[];e.layers.forEach((a,c)=>{let l=db(a.name,`layer${c+1}`);for(;i.includes(l);)l+="_";i.push(l),c===0?l!=="main"&&n.push(`layer rename main ${l}`):n.push(`layer add ${l} above=${i[c-1]}`)});for(let a=1;a<r;a++)n.push("frame add empty");(e.ticks??[]).forEach((a,c)=>{a!==10&&n.push(`frame set ${c+1} ticks=${a}`)});let s=e.from.replace(/"/g,"");for(let a=0;a<r;a++)e.layers.forEach((c,l)=>{let u=e.cels[l]?.[a];!u||u.every(m=>m===65535)||n.push(`layer ${i[l]}`,`frame ${a+1}`,`import 0,0 from="${s}" blob=${e.blob} <<
199
+ ${Wt(Pk(u,e.width,e.height,t))}>>`)});e.layers.forEach((a,c)=>{a.reference&&n.push(`layer set ${i[c]} reference=on`),a.hidden&&n.push(`layer set ${i[c]} hidden=on`)});for(let a of e.tags??[])n.push(`tag add ${db(a.name,"tag")} ${a.from+1}-${a.to+1} loop=${a.loop}`);for(let a of(e.views??[]).filter(c=>!c.mirror))n.push(`view ${a.name} frames=${a.from+1}-${a.to+1}`);for(let a of(e.views??[]).filter(c=>c.mirror))n.push(`view ${a.name} frames=${a.from+1}-${a.to+1}`,`view ${a.name} mirror=${a.mirror}`);return n.join(`
200
+ `)}function td(e,t,r){if(r.files)return l1(e,r,r.files);let o=d1(r.path);if(!Zs(o))throw new ee(`no file or folder '${r.path}'`);let n={create:[],same:[],differ:[],notes:[]};if(!r.profile&&u1(o).isDirectory()){let d=fb(o).filter(f=>/\.(png|aseprite|ase)$/i.test(f)).sort().map(f=>({name:f,bytes:new Uint8Array(To(on(o,f)))}));if(!d.length)throw new ee(`no .png or .aseprite files in ${r.path}`);return l1(e,r,d)}if(r.slice)return l1(e,r,[{name:Un(o),bytes:new Uint8Array(To(o))}]);if(r.profile){let d=HO(e,r.profile),f=u1(o).isDirectory()?H9(o):new Map([[Un(o),To(o)]]),p=t.map(b=>b.doc),h=pO(d,f,p);n.notes.push(...h.notes);let g=hO(h,p);for(let b of[...h.assets.keys()].sort())(g.some(y=>y.startsWith(`${b} `))?n.differ:n.same).push(b);n.notes.push(...g);for(let b of h.unknown){let y=Xm(e,r,[b.img],b.name),w=ir(b.img,y),v=Pi(e,f.get([...f.keys()].find(S=>S.includes(b.name))??"")??new Uint8Array,".png");n.create.push({name:b.name,inexact:w.inexact,worst:w.worst,tape:Ac({name:db(b.name,"imported"),kind:r.kind??"sprite",palette:y,width:b.img.width,height:b.img.height,layers:[{name:"main"}],cels:[[w.px]],from:b.name,blob:v})})}return n}let i=To(o),s=m1(o).toLowerCase(),a=db(r.as??Un(o,s),"imported"),c=Pi(e,i,s);if(s===".aseprite"||s===".ase"){let d=Dm(Mm(i)),f=d.rgba.flatMap(y=>y.flatMap(w=>w?[{width:d.width,height:d.height,data:w}]:[])),p=Xm(e,r,f,a),h=0,g=0,b=d.rgba.map(y=>y.map(w=>{if(!w)return null;let v=ir({width:d.width,height:d.height,data:w},p);return h+=v.inexact,g=Math.max(g,v.worst),v.px}));return n.create.push({name:a,inexact:h,worst:g,kind:r.kind??"sprite",size:`${d.width}x${d.height}`,from:Un(o),tape:Ac({name:a,kind:r.kind??"sprite",palette:p,width:d.width,height:d.height,layers:d.layers,cels:b,ticks:d.ms.map(y=>Zk(y,e.json.tickRate)),tags:d.tags,views:d.views,from:Un(o),blob:c})}),n}if(s!==".png")throw new ee(`import reads .png and .aseprite files (or a folder with a profile), not '${s}'`);let l=Kr(i),u=Xm(e,r,[l],a);if(r.grid&&!r.cells){let[d,f]=r.grid,p=Math.floor(l.width/d),h=Math.floor(l.height/f);if(!p||!h)throw new ee(`a ${d}x${f} grid does not fit the ${l.width}x${l.height} image`);let g=[],b=0,y=0;for(let w=0;w<h;w++)for(let v=0;v<p;v++){let S=ir(zo(l,v*d,w*f,d,f),u);S.px.every(_=>_===65535)||(b+=S.inexact,y=Math.max(y,S.worst),g.push(S.px))}return n.create.push({name:a,inexact:b,worst:y,kind:r.kind??"sprite",size:`${d}x${f}`,from:Un(o),tape:Ac({name:a,kind:r.kind??"sprite",palette:u,width:d,height:f,layers:[{name:"main"}],cels:[g],from:Un(o),blob:c})}),n}let m=ir(l,u);return n.create.push({name:a,inexact:m.inexact,worst:m.worst,kind:r.kind??"sprite",size:`${l.width}x${l.height}`,from:Un(o),tape:Ac({name:a,kind:r.kind??"sprite",palette:u,width:l.width,height:l.height,cell:r.grid??null,layers:[{name:"main"}],cels:[[m.px]],from:Un(o),blob:c})}),n}function l1(e,t,r){let o={create:[],same:[],differ:[],notes:[]},n=[];for(let a of r){let c=m1(a.name).toLowerCase(),l=Fm(Un(a.name,m1(a.name))),u=Pi(e,a.bytes,c);if(c===".aseprite"||c===".ase"){n.push({file:a.name,ase:a.bytes,from:Un(a.name),base:l,blob:u});continue}if(c!==".png")throw new ee(`import reads .png and .aseprite files, not '${a.name}'`);let m=Kr(a.bytes);if(!t.slice){n.push({file:a.name,img:m,from:Un(a.name),base:l,blob:u});continue}let d=PO(m.width,m.height,t.slice);if(!d.length)throw new ee(`a ${t.slice.cell.join("x")} grid does not fit the ${m.width}x${m.height} image ${a.name}`);let f=0;for(let p of d){let h=zo(m,p.x,p.y,t.slice.cell[0],t.slice.cell[1]),g=!0;for(let b=3;b<h.data.length;b+=4)if(h.data[b]>=128){g=!1;break}g||(f++,n.push({file:a.name,img:h,from:`${Un(a.name)} cell ${p.col},${p.row}`,base:l,col:p.col,row:p.row,blob:u}))}f||o.notes.push(`${a.name}: every cell is empty`)}let i;if(t.names?.length||t.namesFrom==="manifest"){let a=t.names??[];if(t.namesFrom==="manifest"){let l=Jt(e).manifest;if(!l)throw new ee("no valid manifest.json to take names from");a=l.assets.filter(u=>(!t.set||(u.set??u.kind)===t.set)&&!Zs(on(e.dir,"assets",u.name))).map(u=>u.name)}let c=jO(n.map((l,u)=>({col:l.col??u,row:l.row??0,x:0,y:0})),{base:"imported",names:a});if(typeof c=="string")throw new ee(`names: ${c}`);i=c}else{i=[];let a=new Map;for(let l of n){let u=(a.get(l.file)??0)+1;a.set(l.file,u);let m=t.pattern??(l.col!==void 0?"{name}_{n}":"{name}");i.push(Fm(m.replace(/\{name\}/g,l.base).replace(/\{n\}/g,String(u)).replace(/\{col\}/g,String(l.col??0)).replace(/\{row\}/g,String(l.row??0)),l.base))}r.length===1&&n.length===1&&t.as&&(i[0]=Fm(t.as));let c=i.find((l,u)=>i.indexOf(l)!==u);if(c)throw new ee(`names: '${c}' comes out twice (put {n}, or {col} and {row}, in the pattern)`)}let s=Jt(e).manifest;return n.forEach((a,c)=>{let l=i[c],u=bn(s,l)?.kind,m=t.kind??(u&&["sprite","tile","object","icon","sheet"].includes(u)?u:"sprite");if(a.ase){let g=Dm(Mm(a.ase)),b=g.rgba.flatMap(_=>_.flatMap($=>$?[{width:g.width,height:g.height,data:$}]:[])),y=Xm(e,t,b,l),w=0,v=0,S=g.rgba.map(_=>_.map($=>{if(!$)return null;let x=ir({width:g.width,height:g.height,data:$},y);return w+=x.inexact,v=Math.max(v,x.worst),x.px}));o.create.push({name:l,inexact:w,worst:v,kind:m,size:`${g.width}x${g.height}`,from:a.from,tape:Ac({name:l,kind:m,palette:y,width:g.width,height:g.height,layers:g.layers,cels:S,ticks:g.ms.map(_=>Zk(_,e.json.tickRate)),tags:g.tags,views:g.views,from:a.from,blob:a.blob})});return}let d=a.img,f=Xm(e,t,[d],l),p=ir(d,f),h=Ac({name:l,kind:m,palette:f,width:d.width,height:d.height,layers:[{name:"main"}],cels:[[p.px]],from:a.from,blob:a.blob});m==="tile"&&t.wrap&&(h=h.replace(/ wrap=off /," wrap=on ")),o.create.push({name:l,inexact:p.inexact,worst:p.worst,kind:m,size:`${d.width}x${d.height}`,from:a.from,tape:h})}),o}function Oc(e,t,r){let o=e.project;if(!t.path&&!t.files)throw new ee("import: give a path or files");let n=td(o,e.assetDocs(),{...t,path:t.path??""});if(t.profile)throw new ee("importIntoProject takes images, not a profile export");for(let u of n.create)if(Zs(on(o.dir,"assets",u.name))&&!t.replace)throw new ee(`an asset '${u.name}' already exists (choose other names, or replace)`);let i=Jt(o),s=[],a=[...n.notes];if(t.manifest!==!1)if(i.manifest){for(let u of n.create)bn(i.manifest,u.name)||s.push({name:u.name,kind:u.kind??"sprite",size:u.size??"",...t.set?{set:t.set}:{},description:`imported from ${u.from??"a file"}`});if(s.length){let u={...i.manifest,assets:[...i.manifest.assets,...s]},m=Us(u,Nc(o));if(!m.manifest)throw new ee(`the manifest entries would have problems: ${m.errors.map(d=>`${d.path}: ${d.message}`).join("; ")}`)}}else{if(t.manifest===!0||i.exists)throw new ee(i.exists?"manifest.json has problems; fix it before importing into it":"there is no manifest to add entries to (import with manifest: false, or plan first)");a.push("no manifest.json: the assets are not planned (the dashboard lists them as unplanned)")}let c=[];for(let u of n.create){let m=e.run({asset:u.name,commands:u.tape,by:r,replace:t.replace});if(!m.ok)throw new ee(`${u.name}: ${m.errors.map(d=>`${d.line}:${d.col} ${d.message}`).join("; ")}`)}s.length&&ji(o,{...i.manifest,assets:[...i.manifest.assets,...s]});for(let u of n.create){let m=e.checks(u.name).results.filter(d=>d.status!=="skip");c.push({name:u.name,kind:u.kind??"sprite",size:u.size??"",inexact:u.inexact,failing:m.filter(d=>d.status==="fail").map(d=>d.id),checks:m.length,planned:!!bn(Jt(o).manifest,u.name)})}e.planChanged();let l=[...c.map(u=>`created ${u.name} (${u.kind} ${u.size})${u.inexact?`, ${u.inexact} pixels quantised to the nearest palette colour`:""}: ${u.failing.length?`failing ${u.failing.join(", ")}`:`all ${u.checks} checks pass`}`),...s.length?[`manifest: added ${s.map(u=>u.name).join(", ")}${t.set?` to set ${t.set}`:""}`]:[],...a].join(`
201
+ `);return{created:c,added:s.map(u=>u.name),notes:a,text:l}}function Xm(e,t,r,o){if(t.build){let s=AA(o.replace(/_/g,"-"),r);return bs({...s,entries:s.entries.map((a,c)=>({...a,key:ws(s.entries.length)[c]}))})}let n=t.palette??e.json.defaultPalette,i=n?e.palettes.get(n):void 0;if(!i)throw new ee(n?`no palette '${n}' in the project`:"say which palette to quantise to (palette), or build one from the image (build)");return i}function hb(e,t){let r=[];e.same.length&&r.push(`read back exactly: ${e.same.join(", ")}`),e.differ.length&&r.push(`differ from the project: ${e.differ.join(", ")}`);for(let o of e.create)r.push(`${t.includes(o.name)?"created":"would create"} ${o.name}: ${o.inexact?`${o.inexact} pixels were not palette colours (nearest taken; worst distance ${o.worst})`:"every pixel a palette colour"}`);return r.push(...e.notes),r.join(`
202
+ `)}import{appendFileSync as B9,existsSync as W9,readFileSync as J9}from"node:fs";import{join as JO}from"node:path";var GO="requests.jsonl";function KO(e){let t=JO(e.dir,GO);if(!W9(t))return[];let r=[];for(let o of J9(t,"utf8").split(`
203
+ `))if(o.trim())try{r.push(JSON.parse(o))}catch{}return r}function sn(e){return e1(KO(e)).requests}function Co(e,t){let r=sn(e),o=Lm(r,t);if(o)throw new ee(o);return B9(JO(e.dir,GO),JSON.stringify(t)+`
204
+ `),e1([...KO(e)]).requests.get(t.id)}function Hs(e,t,r){let o=e.project,n=e.stamp();if(r.action==="reply")return Co(o,{type:"reply",id:r.id,by:t,at:n,text:String(r.text??"")});if(r.action==="cancel")return Co(o,{type:"cancel",id:r.id,by:t,at:n,...r.text?{text:r.text}:{}});let i=sn(o),s=IO(i),a=(r.note??"").trim(),c=(f,p)=>[...i.values()].find(h=>h.asset===f&&h.kind===p&&["open","claimed","blocked"].includes(h.state));if(r.kind==="new"){let f=r.entry,p=Jt(o);if(!p.manifest)throw new ee(p.exists?`manifest.json has problems; fix it first (${p.errors.map(w=>`${w.path}: ${w.message}`).join("; ")})`:"there is no manifest yet: the agent writes the plan first");if(bn(p.manifest,f?.name))throw new ee(`'${f.name}' is already in the manifest`);if(f?.name&&Eo(o,f.name))throw new ee(`an asset '${f.name}' already exists`);let h={...p.manifest,assets:[...p.manifest.assets,f]},g=Us(h,Nc(o));if(!g.manifest)throw new ee(`the new entry has problems: ${g.errors.map(w=>`${w.path}: ${w.message}`).join("; ")}`);let b={type:"request",id:s,asset:f.name,kind:"new",note:a,by:t,at:n},y=Lm(i,b);if(y)throw new ee(y);return ji(o,h),e.planChanged(),Co(o,b)}let l=Jt(o).manifest;if(r.kind==="draw"){if(!bn(l,r.asset))throw new ee(`'${r.asset}' is not planned in ${rd}`);if(Eo(o,r.asset))throw new ee(`'${r.asset}' is drawn already: ask for changes instead`);let f=c(r.asset,"draw");if(f)throw new ee(`${f.id} already asks for '${r.asset}' (${f.state})`);return Co(o,{type:"request",id:s,asset:r.asset,kind:"draw",note:a,by:t,at:n})}if(!Eo(o,r.asset))throw new ee(`'${r.asset}' is not drawn yet: ask for it to be drawn instead`);if(!a)throw new ee("say what should change");let u={type:"request",id:s,asset:r.asset,kind:"change",note:a,by:t,at:n},m=Lm(i,u);if(m)throw new ee(m);let d=e.run({asset:r.asset,commands:`mark rejected ${tn(a)}`,by:t});if(!d.ok)throw new ee(d.errors.map(f=>f.message).join("; "));return Co(o,{...u,mark:d.added.at(-1)?.seq})}function Ei(e){let t=e.kind==="draw"?`draw ${e.asset}`:e.kind==="change"?`change ${e.asset}`:`new asset ${e.asset}`,r=e.state==="claimed"?`claimed by ${e.claimedBy}`:e.state==="blocked"?`blocked: "${e.question}"`:e.state;return`${e.id} ${t}${e.note?`: "${e.note}"`:""} (from ${e.by} at ${e.at}; ${r})`}function nd(e){let t=e.action??"request";if(t==="reply"||t==="cancel"){if(!e.id||!/^r\d+$/.test(e.id))throw new ee(`${t}: give the request's id (like r3)`);if(t==="reply"){if(!e.text?.trim())throw new ee("reply: give the answer (text)");return{action:t,id:e.id,text:e.text}}return{action:t,id:e.id,...e.text?.trim()?{text:e.text}:{}}}if(t!=="request")throw new ee(`unknown action '${t}' (request, reply, cancel)`);let r=e.kind==="new"?"add":e.kind;if(r==="add"){if(!e.entry||typeof e.entry!="object")throw new ee("add: give the new asset's manifest entry (name, kind, size, set, description)");return{action:t,kind:"new",entry:e.entry,...e.note?.trim()?{note:e.note}:{}}}if(r!=="draw"&&r!=="change")throw new ee("a request's kind is draw, change or add");if(!e.asset)throw new ee(`${r}: give the asset`);return r==="change"?{action:t,kind:r,asset:e.asset,note:e.note??""}:{action:t,kind:r,asset:e.asset,...e.note?.trim()?{note:e.note}:{}}}function WO(e,t){return[...e.values()].filter(r=>r.state==="claimed"&&r.claimedBy===t).at(-1)}function g1(e,t,r){let o=e.project,n=sn(o),i=e.stamp();if(r.action==="list")return{request:null,message:""};if(r.action==="next"){let l=r.id?void 0:WO(n,t);if(l)return{request:l,message:`you already have ${l.id}; finish it (done or blocked) before taking another`};let u=r.id?n.get(r.id):Rr(n).find(m=>m.state==="open");return u?{request:Co(o,{type:"claim",id:u.id,by:t,at:i}),message:`claimed ${u.id}`}:{request:null,message:r.id?`no request ${r.id}`:"no open requests"}}let s=r.id??WO(n,t)?.id;if(!s)throw new ee(`no claimed request to post ${r.action} on (give id)`);let a=n.get(s);if(r.action==="done"&&a&&a.state==="claimed"&&a.claimedBy===t){if(!Eo(o,a.asset))throw new ee(`${s} is not done: ${a.asset} is not drawn yet. Draw it, or work(action="blocked", text=<one clear question>) if you cannot`);let l=e.checks(a.asset).results.filter(u=>u.status==="fail");if(l.length)throw new ee(`${s} is not done: ${a.asset} fails ${l.length} check${l.length===1?"":"s"}:
205
+ `+l.map(u=>` ${u.id}${u.score!==null?` ${u.shown}`:""}${u.limit?` (limit ${u.limit})`:""}${u.detail?`: ${u.detail}`:""}`).join(`
206
+ `)+`
207
+ Fix ${l.length===1?"it":"them"} (check shows the pixels) and finish again, or work(action="blocked", text=<one clear question>) if you cannot.`)}return{request:Co(o,{type:r.action,id:s,by:t,at:i,text:r.text}),message:`${s}: ${r.action}`}}var rd="manifest.json";function Nc(e){let t;try{t=[...ed(e).keys()]}catch{t=void 0}return{palettes:[...e.palettes.keys()],schemes:[...yo.keys(),...Qm(e.dir).keys()],profiles:t}}function Jt(e){let t=od(e.dir,rd);if(!YO(t))return{exists:!1,manifest:null,errors:[]};let r;try{r=JSON.parse(K9(t,"utf8"))}catch(o){return{exists:!0,manifest:null,errors:[{path:"",message:`manifest.json is not JSON: ${o.message}`}]}}return{exists:!0,...Us(r,Nc(e))}}function ji(e,t){let r=Us(t,Nc(e));return r.manifest?(XO(od(e.dir,rd),JSON.stringify(t,null,2)+`
208
+ `),{exists:!0,...r}):{exists:YO(od(e.dir,rd)),...r}}function bn(e,t){return e?.assets.find(r=>r.name===t)}function QO(e,t){let r=e.json.style??{},o=e.json.grid??24;return{asset:(n,i)=>{let s=bn(t,i),a=s&&s.kind===n?Yr(s.size):(()=>{let l=r.sizes?.[n]?.split("|")[0];return l?Yr(l):null})();if(!a&&!s)return;let c=n==="object"&&a&&a[0]%o===0&&a[1]%o===0?[o,o]:void 0;return{...a?{size:a}:{},...s?.palette?{palette:s.palette}:{},...s?.scheme&&n==="family"?{scheme:s.scheme}:{},...c?{cell:c}:{},...s?.chars&&n==="font"?{chars:s.chars}:{}}},...r.light?{light:r.light}:{},...r.shadow?{shadow:r.shadow}:{},...r.outline?{outline:r.outline}:{},grid:o,mapObjects:n=>{let i=bn(t,n);return i?.kind==="map"?(i.uses??[]).filter(s=>["object","sprite"].includes(bn(t,s)?.kind??"")):[]}}}function Y9(e){let t=new Set;if(e.map)for(let r of e.map.entries)t.add(r.name);for(let r of e.layers)r.map?.kind==="terrain"?t.add(r.map.family):r.map?.kind==="overlay"&&t.add(r.map.overlay);return[...t].sort()}function Bs(e,t={}){let r=e.project,o=Jt(r),n=o.manifest,i=h1(r),s=new Set(e.assets()),a=[...(n?.assets??[]).map(p=>({...p,planned:!0})),...[...s].filter(p=>!bn(n,p)).map(p=>{let h="sprite",g="";try{let b=e.doc(p);h=b.kind,g=`${b.width}x${b.height}`}catch{}return{name:p,kind:h,size:g,planned:!1}})],c=[];for(let p of a){let h=p.planned?Ls(p):"unplanned";if(t.set&&h!==t.set)continue;let g=null,b=null,y=[],w=[],v=null,S=[];if(s.has(p.name))try{let P=e.state(p.name);g=P.doc,b=P.entries.at(-1)?.seq??null;let I=e.checks(p.name).results;w=I.filter(E=>E.status!=="skip").map(E=>({id:E.id,status:E.status,shown:E.shown})),y=I.filter(E=>E.status==="fail").map(E=>E.id),v=y.length===0}catch(P){S.push(`does not load: ${P.message}`)}let _=g?hc(g):null,$=i[p.name]??null,x=b!==null?e.state(p.name).entries.at(-1):void 0,k=xO({exists:!!g,checksPass:v,marks:g?.marks??[],art:_,exportedArt:$?.art??null});if(g&&p.planned){let P=Yr(p.size),I=g.map?[g.width,g.height]:g.family?[g.family.tile,g.family.tile]:g.font?[g.cellW,g.cellH]:[g.width,g.height];g.kind!==p.kind&&S.push(`planned as a ${p.kind}, drawn as a ${g.kind}`),P&&(I[0]!==P[0]||I[1]!==P[1])&&S.push(`planned ${p.size}, drawn ${I[0]}x${I[1]}`)}g?.notes.length&&S.push(`${g.notes.length} open note${g.notes.length===1?"":"s"}`),c.push({name:p.name,kind:p.kind,size:p.size,set:h,description:p.description??"",status:k.status,next:k.next,flags:[...S,...k.flags],planned:p.planned,exists:!!g,failing:y,checks:w,notes:g?.notes.length??0,seq:b,exported:$,at:x?.at??null,by:x?.by??null,width:g?.width??0,height:g?.height??0,frames:g?.frameCount??0,ticks:g&&g.frameCount>1?[...g.ticks]:[],uses:g?Y9(g):[...p.uses??[]],usedBy:[],scenes:[]})}for(let p of c)for(let h of p.uses)c.find(g=>g.name===h)?.usedBy.push(p.name);let l=p=>c.find(h=>h.name===p)?.status??"planned",u=(n?.scenes??[]).map(p=>({name:p.name,description:p.description??"",map:p.map??null,...$O(n,p,l)}));for(let p of u)for(let h of p.needs)c.find(g=>g.name===h)?.scenes.push(p.name);let m=[...sn(r).values()],d=Object.fromEntries(Xk.map(p=>[p,c.filter(h=>h.planned&&h.status===p).length])),f=[...new Set([...c.map(p=>p.set),...t.set?[]:Object.keys(n?.sets??{})])];return{project:r.json.name,theme:n?.theme??null,manifest:{exists:o.exists,errors:o.errors},sets:f.map(p=>({name:p,description:n?.sets?.[p]?.description??"",assets:c.filter(h=>h.set===p).map(h=>h.name)})),assets:c,counts:d,scenes:u,requests:m}}function y1(e){let t=[e.failing.length?`failing: ${e.failing.join(", ")}`:"",...e.flags].filter(Boolean).join("; ");return` ${e.status.padEnd(8)} ${e.name} (${e.kind} ${e.size})${e.status!=="exported"?` \u2192 ${e.next}`:e.exported?` \u2192 ${e.exported.profile} in ${e.exported.dir}`:""}${t?` [${t}]`:""}`}function gb(e,t={}){let r=[],o=Rr(new Map(e.requests.map(a=>[a.id,a])));if(o.length){r.push(`Requests from people (${o.length}): take these before planned work, with \`work\` (it claims the next open one):`);for(let a of o){let c=a.kind==="draw"?`draw ${a.asset}`:a.kind==="change"?`change ${a.asset}`:`new asset ${a.asset}`,l=a.state==="claimed"?`claimed by ${a.claimedBy}`:a.state==="blocked"?`blocked, waiting for ${a.by}: "${a.question}"`:"open";r.push(` ${a.id} ${c}${a.note?`: "${a.note}"`:""} (from ${a.by}; ${l})`)}r.push("")}e.manifest.exists?e.manifest.errors.length&&r.push(`manifest.json has ${e.manifest.errors.length} problem${e.manifest.errors.length===1?"":"s"}:`,...e.manifest.errors.map(a=>` ${a.path||"(top)"}: ${a.message}`)):r.push(`project '${e.project}' has no manifest.json yet. Write one (plan with manifest=\u2026): format "pixelclaw-manifest", version 1, a theme paragraph, and the assets (name, kind, size, set, \u2026; docs/pipeline.md).`);let n=e.assets.filter(a=>a.planned);e.theme&&r.push(`${e.project}: ${e.theme}`),n.length&&r.push("",`${n.length} planned: ${Xk.map(a=>`${e.counts[a]} ${a}`).join(" \xB7 ")}`);let i=a=>e.assets.find(c=>c.name===a);if(t.order==="scene"&&e.scenes.length){let a=new Set;for(let l of e.scenes){let u=[l.missing.length?`missing ${l.missing.join(", ")}`:"",l.unfinished.length?`failing checks: ${l.unfinished.join(", ")}`:""].filter(Boolean).join("; ");r.push("",`scene ${l.name}${l.description?` (${l.description})`:""}${l.map?`, built by the map ${l.map}`:""}: ${u||"everything it needs is drawn and checked"}`);for(let m of l.needs){let d=i(m);d&&(r.push(y1(d)+(a.has(m)?" (above)":"")),a.add(m))}}let c=e.assets.filter(l=>!a.has(l.name));if(c.length){r.push("","in no scene:");for(let l of c)r.push(y1(l))}}else{for(let a of e.sets){r.push("",`${a.name}${a.description?` (${a.description})`:""}:`);for(let c of a.assets)r.push(y1(i(c)))}if(e.scenes.length){r.push("","scenes (plan order=scene works scene by scene):");for(let a of e.scenes)r.push(` ${a.name}: ${a.missing.length?`missing ${a.missing.join(", ")}`:"nothing missing"}${a.unfinished.length?`; failing checks: ${a.unfinished.join(", ")}`:""}`)}}let s=n.filter(a=>a.status!=="exported").length;return r.push("",n.length?`${s} of ${n.length} still to finish.`:"nothing planned yet."),r.join(`
209
+ `)}function X9(e,t,r){let o=t.flat;if(o&&/^#[0-9a-fA-F]{6}$/.test(o))return it(o);if(o)for(let n of[t.palette?e.palettes.get(t.palette):void 0,e.json.defaultPalette?e.palettes.get(e.json.defaultPalette):void 0,...e.palettes.values()]){let i=n?.entries.find(s=>s.name===o);if(i)return it(i.hex)}return Qk[r%Qk.length]}function Q9(e){let t=Qm(e.dir);return r=>yo.get(r)??(t.has(r)?vs(t.get(r)):void 0)}function yb(e,t={}){let r=e.project,o=Jt(r);if(!o.manifest)throw new ee(o.exists?`manifest.json has problems: ${o.errors.map(h=>`${h.path}: ${h.message}`).join("; ")}`:"no manifest.json: plan the assets first");let n=o.manifest,i=od(r.dir,"templates");G9(i,{recursive:!0});let s=[],a=(h,g)=>{XO(od(i,h),g),s.push(h)},c=r.json.grid??24,[l,u]=Io(r.json.style,c),m=Q9(r),d=new Map(n.assets.map((h,g)=>[h.name,g])),f=h=>X9(r,h,d.get(h.name)??0),p=zO(n,{cols:Math.ceil(l/c),rows:Math.ceil(u/c),tile:c,seed:t.seed??1,scale:2,colour:f,scheme:m});a("mockup.png",Le(p.img)),a("mockup@2x.png",Le(p.labelled)),a("mockup.txt",p.text);for(let h of n.assets.filter(g=>g.kind==="family")){let g=m(h.scheme??"");if(!g)continue;let b=Yr(h.size)?.[0]??c,y=(v,S)=>{let _=v?n.assets.find($=>$.name===v):void 0;return _?f(_):S},w=kO(g,{tile:b,band:h.band,seed:t.seed??1,inside:y(h.inside,f(h)),outside:y(h.outside,[70,70,76])});w&&(a(`${h.name}.coverage.png`,Le(w.img)),a(`${h.name}.coverage.txt`,w.text))}return{dir:i,files:s}}import{spawn as nZ}from"node:child_process";import{randomBytes as rZ}from"node:crypto";import{appendFileSync as oN,chmodSync as oZ,existsSync as iZ,mkdirSync as sZ,mkdtempSync as aZ,readFileSync as v1,rmSync as iN,writeFileSync as sN}from"node:fs";import{tmpdir as cZ}from"node:os";import{basename as lZ,join as sr}from"node:path";import{fileURLToPath as uZ}from"node:url";import{readFileSync as tN}from"node:fs";import{join as nN}from"node:path";var id={enabled:!1,command:["claude"],args:[],cap:5,maxSessions:10,stall:10},eN=["--model","--fallback-model","--effort"],eZ=["--tools","--allowedTools","--allowed-tools","--disallowedTools","--disallowed-tools","--permission-mode","--permission-prompt-tool","--permission-prompts","--dangerously-skip-permissions","--allow-dangerously-skip-permissions","--add-dir","--mcp-config","--strict-mcp-config","--settings","--setting-sources","--plugin-dir","--plugin-url","--agents","--agent","--chrome","--ide","--system-prompt","--system-prompt-file","--append-system-prompt","--append-system-prompt-file","--resume","-r","--continue","-c","--fork-session","--worktree","-w","--file","--bare","--safe-mode","--restricted","--remote-control","--cloud","--bg","--background"];function rN(e){for(let t=0;t<e.args.length;t++){let r=e.args[t],[o,n]=r.startsWith("--")&&r.includes("=")?[r.slice(0,r.indexOf("=")),r.slice(r.indexOf("=")+1)]:[r,void 0];if(!eN.includes(o))return`worker.args may hold only ${eN.join(", ")} with a value (not '${r}'): the worker's tools and reach are fixed (docs/worker.md)`;if(n===void 0){let i=e.args[t+1];if(i===void 0||i.startsWith("-"))return`worker.args: ${o} needs a value`;t++}else if(!n)return`worker.args: ${o} needs a value`}for(let t of e.command.slice(1)){let r=t.startsWith("-")&&t.includes("=")?t.slice(0,t.indexOf("=")):t;if(eZ.includes(r))return`worker.command may not pass ${r}: the worker's tools and reach are fixed (docs/worker.md)`}return null}function Ws(e){let t={};try{let i=JSON.parse(tN(nN(e,"project.json"),"utf8"));i.worker&&typeof i.worker=="object"&&(t=i.worker)}catch{}let r=(i,s)=>Array.isArray(i)&&i.every(a=>typeof a=="string")?i:s,o=(i,s,a,c)=>typeof i=="number"&&Number.isFinite(i)&&i>=a&&i<=c?i:s,n=r(t.command,id.command);return{enabled:t.enabled===!0,command:n.length?n:id.command,args:r(t.args,[]),cap:o(t.cap,id.cap,0,1e3),maxSessions:Math.floor(o(t.maxSessions,id.maxSessions,1,100)),stall:o(t.stall,id.stall,.001,240)}}var bb="worker-spend.jsonl";function tZ(e){try{return tN(nN(e,bb),"utf8").split(`
210
+ `).filter(Boolean).flatMap(t=>{try{let r=JSON.parse(t);return typeof r.cost=="number"&&Number.isFinite(r.cost)&&r.cost>=0?[r]:[]}catch{return[]}})}catch{return[]}}function sd(e){return Math.round(tZ(e).reduce((t,r)=>t+r.cost,0)*1e6)/1e6}var w1=".pixelclaw-worker.lock",aN=sr("logs","worker.log"),b1="claude";function mZ(){let e=uZ(new URL(".",import.meta.url));for(let t of[sr(e,"skill","SKILL.md"),sr(e,"..","..","skill","SKILL.md")])if(iZ(t))return v1(t,"utf8");return""}var dZ=e=>`You are PixelClaw's worker for the project at ${e}. People asked for work in its dashboard; nobody reads this chat, so do not ask questions here.
211
+
212
+ You have only the PixelClaw tools (no shell, no files, no web): everything you need is in them and in your instructions, which end with every command of the language.
213
+
214
+ Follow the PixelClaw skill (in your instructions). Loop:
215
+ 1. Call the \`work\` tool: it claims the next open request and says what is asked (draw a planned asset, change a drawn one, or a new asset).
216
+ 2. Do it with the PixelClaw tools (plan, run, view, check, changes, ...), to the skill's house rules. Post a short \`work\` progress note when a step is done.
217
+ 3. Finish it: \`work\` with action "done" and what changed (refused while the asset fails a check: fix what the reply lists), or action "blocked" with one clear question for the person when you cannot go on without them.
218
+ 4. Call \`work\` again. Stop when it says there are no open requests.`,fZ=e=>`You made no tool call for ${e} minute${e===1?"":"s"}, so the session was stopped and resumed. Carry on with the request you claimed: call a PixelClaw tool now. Finish it with work(action="done") or, if you are stuck, work(action="blocked") with one clear question.`,pZ=["Bash","BashOutput","KillShell","KillBash","PowerShell","Read","Write","Edit","MultiEdit","NotebookEdit","NotebookRead","Glob","Grep","LS","WebFetch","WebSearch","Task","Agent","TaskOutput","TaskStop","TodoWrite","Skill","SlashCommand","ToolSearch","ExitPlanMode","EnterPlanMode","EnterWorktree","ExitWorktree","Monitor","Workflow","CronCreate","CronDelete","CronList","ScheduleWakeup","SendMessage","ListAgents","RemoteTrigger","PushNotification","ListMcpResourcesTool","ReadMcpResourceTool","AskUserQuestion","ReportFindings"],hZ=["--tools","","--disallowedTools",pZ.join(","),"--allowedTools","mcp__pixelclaw","--permission-mode","dontAsk","--setting-sources","user","--strict-mcp-config"];function gZ(e){return`${e?`${e.trim()}
219
+
220
+ `:""}# Every PixelClaw command
221
+
222
+ One line each, from the editor itself (the MCP server's instructions explain them; this is the full list):
223
+
224
+ ${Ok()}
225
+ `}function yZ(e){return[...e.command,"-p",e.resume?fZ(e.resume.minutes):dZ(e.dir),...e.resume?["--resume",e.resume.session]:[],"--output-format","stream-json","--verbose","--mcp-config",e.mcpConfig,...hZ,"--max-budget-usd",e.budget.toFixed(2),"--append-system-prompt",gZ(e.skill),...e.args]}var wb={input:15,cacheWrite:18.75,cacheRead:1.5,output:75};function bZ(e){let t=r=>typeof r=="number"&&Number.isFinite(r)&&r>0?r:0;return(t(e.input_tokens)*wb.input+t(e.cache_creation_input_tokens)*wb.cacheWrite+t(e.cache_read_input_tokens)*wb.cacheRead+t(e.output_tokens)*wb.output)/1e6}function $1(e){try{let t=JSON.parse(v1(sr(e,w1),"utf8"));return s1(t.pid)?t:null}catch{return null}}var ad=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e,Pr=e=>`$${e.toFixed(2)}`;function wZ(e){let t;try{t=JSON.parse(e)}catch{return{text:e.trim()?ad(e.trim(),300):null}}if(t.type==="system"&&t.subtype==="init"){let r=Array.isArray(t.tools)?t.tools.map(String):null,o=r?.filter(n=>!n.startsWith("mcp__pixelclaw__"))??[];return{text:`session started${typeof t.model=="string"?` (${t.model})`:""}${r?`; tools: ${r.length-o.length} PixelClaw${o.length?`, and ${o.join(", ")}`:", nothing else"}`:""}`,...typeof t.session_id=="string"?{session:t.session_id}:{}}}if(t.type==="assistant"){let r=t.message??{},o=r.content??[],n=o.flatMap(i=>i.type==="text"&&i.text?.trim()?[`claude: ${ad(i.text.trim().replace(/\s+/g," "),300)}`]:i.type==="tool_use"?[`\u2192 ${String(i.name).replace(/^mcp__pixelclaw__/,"")} ${ad(JSON.stringify(i.input??{}),160)}`]:[]);return{text:n.length?n.join(`
226
+ `):null,...o.some(i=>i.type==="tool_use")?{tool:!0}:{},...r.usage?{usage:{id:r.id??`line:${e.length}:${e.slice(0,40)}`,usage:r.usage}}:{}}}if(t.type==="user"){let r=t.message?.content??[],o=r.filter(n=>n.type==="tool_result"&&n.is_error);return{text:o.length?`\u2190 error: ${ad(JSON.stringify(o[0].content),200)}`:null,...r.some(n=>n.type==="tool_result")?{tool:!0}:{}}}if(t.type==="result"){let r=typeof t.total_cost_usd=="number"?t.total_cost_usd:void 0;return{text:`session ended (${String(t.subtype??"done")}${typeof t.num_turns=="number"?`, ${t.num_turns} turns`:""}${r!==void 0?`, ${Pr(r)}`:""})`,...r!==void 0?{cost:r}:{}}}return{text:null}}var vb=class{child=null;stopping=null;run=null;token=null;w;endpoint;constructor(t,r){this.w=t,this.endpoint=r}running(){return this.run!==null}mcpToken(){return this.token}log(t){let r=this.w.stamp(),o=t.flatMap(n=>n.split(`
227
+ `)).map(n=>`${r} ${n}`);try{sZ(sr(this.w.project.dir,"logs"),{recursive:!0}),oN(sr(this.w.project.dir,aN),o.join(`
228
+ `)+`
229
+ `)}catch{}this.w.workerLog(o)}start(t){let r=this.w.project.dir,o=Ws(r);if(!o.enabled)throw new ee('the worker is off for this project: set "worker": { "enabled": true } in project.json (it runs Claude Code headless and spends money; see docs/worker.md)');let n=rN(o);if(n)throw new ee(n);if(this.run)throw new ee("a worker is already running for this project");let i=$1(r);if(i)throw new ee(`a worker is already running for this project (pid ${i.pid}, started by ${i.by} at ${i.startedAt})`);let s=sd(r);if(s>=o.cap-.005)throw new ee(`the worker has spent ${Pr(s)} of its ${Pr(o.cap)} cap on this project (${bb}); raise worker.cap in project.json to go on`);let a=this.w.stamp();return sN(sr(r,w1),JSON.stringify({pid:process.pid,by:t,startedAt:a})+`
230
+ `),this.stopping=null,this.token=rZ(16).toString("hex"),this.w.setWorker({running:!0,by:t,startedAt:a,spent:s,cap:o.cap,sessions:0,stopped:null}),this.run=this.loop(t,a).finally(()=>{iN(sr(r,w1),{force:!0}),this.run=null,this.child=null,this.token=null}),this.run}stop(t){if(!this.run)throw new ee("no worker is running");this.stopping=`stopped by ${t}`,this.child?.kill("SIGTERM")}async settled(){await this.run?.catch(()=>{})}async loop(t,r){let o=this.w.project.dir,n=Ws(o),i=0,s="",a=()=>sd(o);this.log([`run started by ${t}: cap ${Pr(n.cap)} (${Pr(a())} spent before), at most ${n.maxSessions} sessions, stall ${n.stall} min, command ${n.command.map(m=>lZ(m)).join(" ")}`]);let c=()=>Rr(sn(this.w.project)).filter(m=>m.state==="open"||m.state==="claimed"&&m.claimedBy===b1),l=()=>JSON.stringify([...sn(this.w.project).values()].map(m=>[m.id,m.state,m.events.length])),u=(m,d,f)=>{let p=Math.min(f.cost??f.estimate,d);return oN(sr(o,bb),JSON.stringify({at:this.w.stamp(),run:r,session:m,cost:Math.round(p*1e6)/1e6,...f.cost===null?{estimated:!0}:{}})+`
231
+ `),this.w.setWorker({spent:a()}),this.log([`session ${m}: ${Pr(p)}${f.cost===null?" (no cost reported: estimated from its tokens, at the dearest rates)":""}; ${Pr(a())} of ${Pr(n.cap)} spent`]),f.cost!==null||f.stalled};for(;;){if(this.stopping){s=this.stopping;break}if(!c().length){s="the queue is empty";break}if(a()>=n.cap-.005){s=`the budget cap was reached (${Pr(a())} of ${Pr(n.cap)})`;break}if(i>=n.maxSessions){s=`the session limit was reached (${n.maxSessions})`;break}let m=l();i++;let d=n.cap-a();this.w.setWorker({sessions:i}),this.log([`session ${i}: budget ${Pr(d)}; ${c().length} request${c().length===1?"":"s"} waiting`]);let f=await this.session(n,d);if(!u(i,d,f)){s=this.stopping??"a session ended without reporting its cost; stopping";break}if(f.stalled&&!this.stopping){let p=()=>[...sn(this.w.project).values()].find(g=>g.state==="claimed"&&g.claimedBy===b1);d=n.cap-a(),f.session&&d>.005&&(this.log([`session ${i}: no tool call for ${n.stall} min; stopped it; resuming it once`]),f=await this.session(n,d,f.session),u(i,d,f));let h=p();f.stalled&&!this.stopping&&h?(Co(this.w.project,{type:"blocked",id:h.id,by:b1,at:this.w.stamp(),text:`The worker stalled on this (no tool call for ${n.stall} min, twice): please look at ${h.asset}, then reply to open it again.`}),this.w.requestsChanged(),this.log([`session ${i}: stalled again; ${h.id} marked blocked`])):f.stalled&&!this.stopping&&this.log([`session ${i}: stalled again (no request claimed)`])}if(this.stopping){s=this.stopping;break}if(!(a()>=n.cap-.005)&&l()===m){s="a session left the queue as it was; stopping";break}}return this.log([`run stopped: ${s}`]),this.w.setWorker({running:!1,stopped:s}),s}session(t,r,o){let n=this.w.project.dir,i=this.endpoint(),s=aZ(sr(cZ(),"pixelclaw-worker-")),a=sr(s,"mcp.json");sN(a,JSON.stringify({mcpServers:{pixelclaw:{type:"http",url:i.url,headers:{Authorization:`Bearer ${this.token}`}}}}),{mode:384}),oZ(a,384);let c=yZ({command:t.command,args:t.args,dir:n,mcpConfig:a,budget:r,skill:mZ(),...o?{resume:{session:o,minutes:t.stall}}:{}}),l=t.stall*6e4;return new Promise(u=>{let m=null,d=o??null,f=!1,p=new Map,h="",g=Date.now(),b=nZ(c[0],c.slice(1),{cwd:n,stdio:["ignore","pipe","pipe"],env:process.env});this.child=b;let y=setInterval(()=>{Date.now()-g<=l||f||(f=!0,this.log([`watchdog: no tool call for ${t.stall} min; stopping the session`]),b.kill("SIGTERM"),setTimeout(()=>{b.exitCode===null&&b.signalCode===null&&b.kill("SIGKILL")},5e3).unref())},Math.max(50,Math.min(5e3,l/4))),w=_=>{let $=wZ(_);$.cost!==void 0&&(m=$.cost),$.session&&(d=$.session),$.tool&&(g=Date.now()),$.usage&&p.set($.usage.id,$.usage.usage),$.text&&this.log([$.text])};b.stdout.setEncoding("utf8").on("data",_=>{h+=_;let $;for(;($=h.indexOf(`
232
+ `))>=0;)w(h.slice(0,$)),h=h.slice($+1)}),b.stderr.setEncoding("utf8").on("data",_=>{for(let $ of _.split(`
233
+ `))$.trim()&&this.log([`stderr: ${ad($.trim(),300)}`])});let v=!1,S=(_,$)=>{v||(v=!0,clearInterval(y),h.trim()&&w(h),h="",$?this.log([`could not start ${c[0]}: ${$.message}`]):_&&!f&&this.log([`${c[0]} exited with ${_}`]),iN(s,{recursive:!0,force:!0}),u({cost:f?null:m,estimate:[...p.values()].reduce((x,k)=>x+bZ(k),0),session:d,stalled:f}))};b.on("error",_=>S(null,_)),b.on("close",_=>S(_))})}};function cN(e,t=200){try{return v1(sr(e,aN),"utf8").split(`
234
+ `).filter(Boolean).slice(-t)}catch{return[]}}import{createHash as vZ}from"node:crypto";var $Z="258EAFA5-E914-47DA-95CA-C5AB0DC85B11",x1=1<<20,S1=class{socket;buf=Buffer.alloc(0);parts=[];closed=!1;onmessage=()=>{};onclose=()=>{};constructor(t){this.socket=t,t.on("data",r=>this.read(r)),t.on("close",()=>this.finish()),t.on("error",()=>this.finish())}get open(){return!this.closed}send(t){this.closed||this.socket.write(_1(1,Buffer.from(t,"utf8")))}close(t=1e3){if(this.closed)return;let r=Buffer.alloc(2);r.writeUInt16BE(t),this.socket.end(_1(8,r)),this.finish()}finish(){this.closed||(this.closed=!0,this.socket.destroy(),this.onclose())}read(t){for(this.buf=Buffer.concat([this.buf,t]);;){if(this.buf.length<2)return;let r=this.buf[0],o=this.buf[1],n=(r&128)!==0,i=r&15,s=(o&128)!==0,a=o&127,c=2;if(a===126){if(this.buf.length<4)return;a=this.buf.readUInt16BE(2),c=4}else if(a===127){if(this.buf.length<10)return;let m=this.buf.readBigUInt64BE(2);if(m>BigInt(x1))return this.close(1009);a=Number(m),c=10}if(!s)return this.close(1002);if(a>x1)return this.close(1009);if(this.buf.length<c+4+a)return;let l=this.buf.subarray(c,c+4),u=Buffer.from(this.buf.subarray(c+4,c+4+a));for(let m=0;m<u.length;m++)u[m]=u[m]^l[m&3];if(this.buf=this.buf.subarray(c+4+a),i===8)return this.close();if(i===9){this.closed||this.socket.write(_1(10,u));continue}if(i!==10){if(i===1||i===0){if(this.parts.push(u),this.parts.reduce((m,d)=>m+d.length,0)>x1)return this.close(1009);if(n){let m=Buffer.concat(this.parts).toString("utf8");this.parts=[],this.onmessage(m)}continue}return this.close(1003)}}}};function _1(e,t){let r=t.length,o=r<126?Buffer.from([128|e,r]):r<65536?Buffer.alloc(4):Buffer.alloc(10);return r>=126&&r<65536?(o[0]=128|e,o[1]=126,o.writeUInt16BE(r,2)):r>=65536&&(o[0]=128|e,o[1]=127,o.writeBigUInt64BE(BigInt(r),2)),Buffer.concat([o,t])}function lN(e,t){let r=e.headers["sec-websocket-key"];if(String(e.headers.upgrade??"").toLowerCase()!=="websocket"||typeof r!="string"||e.headers["sec-websocket-version"]!=="13")return t.end(`HTTP/1.1 400 Bad Request\r
235
+ Connection: close\r
236
+ \r
237
+ `),null;let n=vZ("sha1").update(r+$Z).digest("base64");return t.write(`HTTP/1.1 101 Switching Protocols\r
238
+ Upgrade: websocket\r
239
+ Connection: Upgrade\r
240
+ Sec-WebSocket-Accept: ${n}\r
241
+ \r
242
+ `),new S1(t)}var mN={".html":"text/html; charset=utf-8",".js":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".json":"application/json",".woff2":"font/woff2",".map":"application/json"};function IZ(){let e=[process.env.PIXELCLAW_UI_DIR,uN(new URL("./ui/",import.meta.url)),uN(new URL("../../ui/dist/",import.meta.url))];for(let t of e)if(t&&_b(Mc(t,"index.html")))return t;return null}function xb(e,t){if(!e)return!1;let r=Buffer.from(e),o=Buffer.from(t);return r.length===o.length&&xZ(r,o)}var Ot={"X-Content-Type-Options":"nosniff","Referrer-Policy":"no-referrer","X-Frame-Options":"DENY"},PZ="default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; connect-src 'self'; frame-ancestors 'none'";function dN(e,t,r,o){e.writeHead(t,{...Ot,"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store"}),e.end(`<!doctype html><meta charset="utf-8"><title>${r}</title>
243
+ <body style="font:15px system-ui;background:#16171b;color:#d8dbe0;padding:3em;max-width:40em">
244
+ <h1 style="font-size:20px">PixelClaw: ${r}</h1>${o}</body>`)}var jZ=256*1024;async function EZ(e,t){let r=o=>({type:"result",id:t.id,ok:!1,errors:[{line:0,col:0,message:o}]});return typeof t.by!="string"||!Ym.test(t.by)?r("a page writes as human:<name> (letters, digits, . _ -)"):typeof t.asset!="string"||typeof t.commands!="string"?r("run needs an asset and commands"):t.commands.length>jZ?r("too many commands in one message"):e.enqueue(async()=>{try{let o=await e.runAsync({asset:t.asset||void 0,commands:t.commands,by:t.by});return o.ok?{type:"result",id:t.id,ok:!0,asset:o.asset,group:o.group,seq:o.added.at(-1)?.seq??null}:{type:"result",id:t.id,ok:!1,errors:o.errors}}catch(o){return o instanceof ee?r(o.message):r(`internal error: ${o.message}`)}})}async function TZ(e,t){return typeof t.by!="string"||!Ym.test(t.by)?{type:"answer",id:t.id,ok:!1,error:"a page writes as human:<name>"}:e.enqueue(()=>{try{let r=Hs(e,t.by,t.body);return e.requestsChanged(),{type:"answer",id:t.id,ok:!0,request:r}}catch(r){return{type:"answer",id:t.id,ok:!1,error:r instanceof ee?r.message:`internal error: ${r.message}`}}})}function CZ(e,t){let r=e.doc(t);if(r.map){let n=Bt(r,qn(e.assetDocs()));return Le(Gm(n.px,n.w,n.h,n.palette))}if(r.frameCount<=1||r.family)return Le(vi(r));let o=ut(r.width*r.frameCount,r.height);for(let n=0;n<r.frameCount;n++){let i=vi(r,n);for(let s=0;s<r.height;s++)o.data.set(i.data.subarray(s*r.width*4,(s+1)*r.width*4),(s*o.width+n*r.width)*4)}return Le(o)}var AZ=32*1024*1024;function fN(e,t){return new Promise((r,o)=>{let n=[],i=0;e.on("data",s=>{if(i+=s.length,i>t){o(new ee("too large")),e.destroy();return}n.push(s)}),e.on("end",()=>r(Buffer.concat(n))),e.on("error",o)})}async function pN(e){let t=e.host??"127.0.0.1",r=IZ(),o=new Set,n=0,i=()=>[`127.0.0.1:${n}`,`localhost:${n}`,`[::1]:${n}`],s=b=>{let y=JSON.stringify(b);for(let w of o)w.send(y)},a=e.writer.on(s),c=e.mcp?xS(()=>e.mcp({confined:!1}),{onerror:()=>{}}):null,l=e.mcp?xS(()=>e.mcp({confined:!0}),{onerror:()=>{}}):null,u=(b,y,w)=>{b.writeHead(y,{...Ot,"Content-Type":"application/json","Cache-Control":"no-store"}),b.end(JSON.stringify(w)+`
245
+ `)},m=async(b,y,w)=>{let v=String(b.headers.authorization??""),S=v.startsWith("Bearer ")?v.slice(7):w.searchParams.get("token"),_=e.worker?.mcpToken()??null,$=c?xb(S,e.token)?c:_&&xb(S,_)?l:null:null;if(!$){y.writeHead(c?401:404,{...Ot,"Content-Type":"text/plain"}).end(c?`token required
246
+ `:`not found
247
+ `);return}let x=b.method==="POST"?await fN(b,8*1024*1024):void 0,k=new Headers;for(let[T,q]of Object.entries(b.headers))typeof q=="string"?k.set(T,q):Array.isArray(q)&&k.set(T,q.join(", "));let P=new AbortController;y.on("close",()=>P.abort());let I=await $.fetch(new Request(w,{method:b.method,headers:k,body:x?new Uint8Array(x):void 0,signal:P.signal})),E={};if(I.headers.forEach((T,q)=>{E[q]=T}),y.writeHead(I.status,E),!I.body){y.end();return}let N=I.body.getReader();try{for(;;){let{done:T,value:q}=await N.read();if(T)break;y.write(q)}}catch{}y.end()},f=SZ((b,y)=>{if(!i().includes(String(b.headers.host))){y.writeHead(421,Ot).end(`wrong host
248
+ `);return}let w=new URL(b.url??"/",`http://${b.headers.host}`),v=xb(w.searchParams.get("token"),e.token);if(w.pathname==="/mcp"){m(b,y,w).catch(x=>{y.headersSent?y.end():u(y,500,{error:x.message})});return}if(w.pathname==="/api/import"&&b.method==="POST"){if(!v){u(y,401,{error:"token required"});return}fN(b,AZ).then(async x=>{let k=JSON.parse(x.toString("utf8"));if(typeof k.by!="string"||!Ym.test(k.by))throw new ee("a page writes as human:<name>");if(!Array.isArray(k.files)||!k.files.length)throw new ee("no files");let P=k.files.map(E=>({name:String(E.name),bytes:new Uint8Array(Buffer.from(String(E.data),"base64"))})),I=await e.writer.enqueue(()=>Oc(e.writer,{...k.options??{},files:P},k.by));u(y,200,I)}).catch(x=>u(y,x instanceof ee||x instanceof SyntaxError?400:500,{error:x.message}));return}if(b.method!=="GET"&&b.method!=="HEAD"){y.writeHead(405,Ot).end();return}if(w.pathname==="/api/worker"){if(!v){u(y,401,{error:"token required"});return}u(y,200,{status:e.writer.workerStatus(),log:cN(e.writer.project.dir)});return}let S=/^\/api\/strip\/([a-z][a-z0-9_-]*)\.png$/.exec(w.pathname);if(S){if(!v){u(y,401,{error:"token required"});return}e.writer.enqueue(()=>CZ(e.writer,S[1])).then(x=>{y.writeHead(200,{...Ot,"Content-Type":"image/png","Cache-Control":"no-store"}),y.end(x)},()=>{y.writeHead(404,{...Ot,"Content-Type":"text/plain"}).end(`not found
249
+ `)});return}if(w.pathname==="/"||w.pathname==="/index.html"){if(!v){dN(y,401,"token required",`<p>This view needs the link with its token, as printed when the server
250
+ started (<code>pixelclaw: watch at http://127.0.0.1:${n}/?token=\u2026</code>). Ask the agent for the
251
+ link, or look in the server's log.</p>`);return}if(!r){dN(y,503,"UI not built","<p>The watch view has not been built. Run <code>pnpm build</code> in the repo.</p>");return}y.writeHead(200,{...Ot,"Content-Security-Policy":PZ,"Content-Type":mN[".html"],"Cache-Control":"no-store"}),y.end($b(Mc(r,"index.html")));return}if(w.pathname==="/api/state"){if(!v){y.writeHead(401,{...Ot,"Content-Type":"application/json"}).end(`{"error":"token required"}
252
+ `);return}y.writeHead(200,{...Ot,"Content-Type":"application/json","Cache-Control":"no-store"}),y.end(JSON.stringify(e.writer.snapshot()));return}if(w.pathname==="/api/plan"){if(!v){y.writeHead(401,{...Ot,"Content-Type":"application/json"}).end(`{"error":"token required"}
253
+ `);return}e.writer.enqueue(()=>Bs(e.writer)).then(x=>{y.writeHead(200,{...Ot,"Content-Type":"application/json","Cache-Control":"no-store"}),y.end(JSON.stringify(x))},x=>{y.writeHead(500,{...Ot,"Content-Type":"application/json"}).end(JSON.stringify({error:x.message})+`
254
+ `)});return}let _=/^\/api\/preview\/([a-z][a-z0-9_-]*)\.png$/.exec(w.pathname);if(_){let x=Mc(e.writer.project.dir,"assets",_[1],"preview.png");if(!v||!_b(x)){y.writeHead(v?404:401,{...Ot,"Content-Type":"text/plain"}).end(v?`not found
255
+ `:`token required
256
+ `);return}y.writeHead(200,{...Ot,"Content-Type":"image/png","Cache-Control":"no-store"}),y.end($b(x));return}let $=/^\/api\/blob\/([0-9a-f]{64})\.png$/.exec(w.pathname);if($){let x=Mc(e.writer.project.dir,"blobs",`${$[1]}.png`);if(!v||!_b(x)){y.writeHead(v?404:401,{...Ot,"Content-Type":"text/plain"}).end(v?`not found
257
+ `:`token required
258
+ `);return}y.writeHead(200,{...Ot,"Content-Type":"image/png","Cache-Control":"private, max-age=86400, immutable"}),y.end($b(x));return}if(r&&w.pathname.startsWith("/assets/")){let x=zZ(Mc(r,decodeURIComponent(w.pathname)));if(x.startsWith(Mc(r,"assets")+RZ)&&_b(x)&&_Z(x).isFile()){y.writeHead(200,{...Ot,"Content-Type":mN[kZ(x)]??"application/octet-stream","Cache-Control":"public, max-age=31536000, immutable"}),y.end($b(x));return}}y.writeHead(404,{...Ot,"Content-Type":"text/plain"}).end(`not found
259
+ `)});f.on("upgrade",(b,y)=>{let w=new URL(b.url??"/",`http://${b.headers.host}`);if(!i().includes(String(b.headers.host))||w.pathname!=="/ws"){y.end(`HTTP/1.1 404 Not Found\r
260
+ Connection: close\r
261
+ \r
262
+ `);return}if(!xb(w.searchParams.get("token"),e.token)){y.end(`HTTP/1.1 401 Unauthorized\r
263
+ Connection: close\r
264
+ \r
265
+ `);return}let v=lN(b,y);v&&(o.add(v),v.onclose=()=>o.delete(v),v.onmessage=S=>{let _;try{_=JSON.parse(S)}catch{return}if(_.type==="ping")v.send(JSON.stringify({type:"pong"}));else if(_.type==="run")EZ(e.writer,_).then($=>v.send(JSON.stringify($)));else if(_.type==="request")TZ(e.writer,_).then($=>v.send(JSON.stringify($)));else if(_.type==="worker"){let $=(x,k)=>v.send(JSON.stringify({type:"answer",id:_.id,ok:x,...k?{error:k}:{}}));if(typeof _.by!="string"||!Ym.test(_.by))$(!1,"a page writes as human:<name>");else if(!e.worker)$(!1,"this server runs no worker");else try{_.action==="stop"?e.worker.stop(_.by):e.worker.start(_.by).catch(()=>{}),$(!0)}catch(x){$(!1,x.message)}}},v.send(JSON.stringify({type:"hello",snapshot:e.writer.snapshot()})))});let p=e.port===0?1:Math.max(1,e.tries??20),h;for(let b=0;b<p;b++)try{await new Promise((y,w)=>{f.once("error",w),f.listen(e.port===0?0:e.port+b,t,()=>{f.off("error",w),y()})}),h=void 0;break}catch(y){if(h=y,y.code!=="EADDRINUSE")break}if(h)throw a(),h;return n=f.address().port,{url:`http://127.0.0.1:${n}/?token=${e.token}`,port:n,token:e.token,clients:()=>o.size,close:()=>new Promise(b=>{a(),c?.close();for(let y of o)y.close(1001);f.close(()=>b()),f.closeAllConnections()})}}function OZ(e,t=40){let r=e.slice(0,t).map(([o,n])=>`${o},${n}`).join(" ");return e.length>t?`${r} \u2026 and ${e.length-t} more`:r}function Sb(e,t,r=[],o){let n=t.filter(a=>a.status!=="skip"),i=n.filter(a=>a.status==="fail"),s=[`${e}${o!==void 0?` frame ${o+1}`:""}: ${i.length?`${i.length} of ${n.length} checks failing`:`all ${n.length} checks pass`}`];for(let a of t){if(a.status==="skip"){s.push(` \u2013 ${a.id.padEnd(11)} skipped: ${a.detail}`);continue}s.push(` ${a.status==="pass"?"\u2713":"\u2717"} ${a.id.padEnd(11)} ${a.shown.padEnd(6)} ${a.limit.padEnd(7)} ${a.detail}`);for(let c of a.parts??[])c.pass===!1&&s.push(` ${c.name}: ${c.detail} (needs ${c.limit})`);if(a.status==="fail")for(let c of a.groups)s.push(` ${c.label}: ${OZ(c.pts)}`)}for(let a of r)s.push(` note: ${a}`);return s.join(`
266
+ `)}function kb(e,t){if(!t.length)return`${e}: no seeds tried`;let r=[...new Set(t.flatMap(l=>l.results.filter(u=>u.status!=="skip"&&u.score!==null).map(u=>u.id)))],o=r.filter(l=>t.some(u=>u.failing.includes(l))),n=[...o,...r.filter(l=>!o.includes(l))].slice(0,8),i=n.map(l=>t[0].results.find(u=>u.id===l)?.limit??""),s=`${e}: ${t.length} seed${t.length===1?"":"s"} ranked by the checks (fewest failing, then least over, then most room)`,a=l=>l.map((u,m)=>u.padEnd(m===0?6:Math.max(13,u.length+2))).join("").trimEnd(),c=[s,`limits: ${n.map((l,u)=>`${l} ${i[u]}`).join(", ")} (a limit in brackets: that seed's own, e.g. repetition's raised by its spread)`];c.push(a(["seed",...n,"failing"]));for(let l of t)c.push(a([String(l.seed),...n.map((u,m)=>{let d=l.results.find(f=>f.id===u);return!d||d.status==="skip"?"\u2013":`${d.shown}${d.limit!==i[m]?` (${d.limit})`:""} ${d.status==="pass"?"\u2713":"\u2717"}`}),l.failing.length?l.failing.join(","):"none"]));return c.push(`best: ${t[0].line}`),c.join(`
267
+ `)}import{existsSync as NZ,mkdirSync as Js,readFileSync as MZ,writeFileSync as DZ}from"node:fs";import{join as Qr}from"node:path";function qZ(e){let t=r=>r.length?r.map(o=>`- ${o}`).join(`
268
+ `):"- (none)";return`# Review: ${e.project}
269
+
270
+ You are reviewing pixel art for a game, with fresh eyes. Judge only what you see in this folder.
271
+
272
+ ## What is here
273
+
274
+ - \`assets/<name>.png\`: each asset enlarged with a pixel grid and rulers (numbers every 8 pixels,
275
+ from 0 at the top left), for reading coordinates.
276
+ - \`assets/<name>.game.png\`: each asset at ${e.scale===1?"its real size, which is the game's draw scale (1x)":`its real size (1x) and at the game's draw scale (${e.scale}x)`}.
277
+ - \`tiles/<name>.3x3.png\`: each tile repeated 3x3, at 1x and 4x, as it will cover the ground.
278
+ - \`scenes/<name>.png\`: each sprite on its usual ground beside the rest of its set, at ${e.scale===1?"1x (the draw scale)":`1x and ${e.scale}x`}.
279
+ - \`anim/<name>.png\`: each animated asset's frames, one row per sequence (a direction or a named
280
+ loop), each frame with its length in game ticks (${e.tickRate} a second) and the frame before it
281
+ tinted red underneath; \`anim/<name>.gif\` plays them at the game's speed.
282
+ - \`maps/<name>.png\`: each autotile set laid out as a small map at the game's draw scale (${e.scale}x),
283
+ the way the game will place its tiles; \`maps/<name>.gif\` plays it (at 1x) when anything moves, and
284
+ \`maps/<name>.tiles.txt\` says which tile is at each column and row of the map.
285
+ - \`sets/<name>.png\`: every tile of each autotile set, each in the middle of the neighbours that
286
+ call for it (the neighbours dimmed), named.
287
+ - \`scenes/<map>.png\`: each scene (a place built from the tiles and objects) whole, at 1x;
288
+ \`scenes/<map>.screen<n>.png\`: screens of it at the game's draw scale (${e.scale}x), what a player
289
+ sees, \`scenes/<map>.screens.txt\` says which cells each shows; \`scenes/<map>.cells.txt\` maps every cell (a letter per
290
+ ground it shows, a capital where an object stands).
291
+ - \`palette.md\`: the colours the art uses.${e.style?"\n- `style.md`: the style guide.":""}${e.brief?"\n- `brief.md`: the game's theme and what each piece is meant to be.":""}
292
+
293
+ Tiles:
294
+ ${t(e.tiles)}
295
+
296
+ Sprites:
297
+ ${t(e.sprites)}
298
+
299
+ Animated:
300
+ ${t(e.animated)}
301
+
302
+ Autotile sets (judge them on their maps):
303
+ ${t(e.families)}
304
+
305
+ Scenes:
306
+ ${t(e.maps)}
307
+
308
+ ## How to judge
309
+
310
+ Look at the game-scale images first, as a player would, then at the enlarged ones for detail.
311
+ Score each part from 1 (poor) to 5 (excellent) and say why in a sentence or two:
312
+
313
+ 1. **Readability.** At 1x on its ground, does each sprite read at a glance: its shape, what it
314
+ is${e.brief?" (is it what brief.md says it is?)":""}, its front? Is its edge clear of the ground?
315
+ 2. **Cohesion.** Do the pieces look like one set: the same light direction, outline rule,
316
+ shading depth, level of detail and palette use?
317
+ 3. **Seams and repetition.** Do the tiles join without visible lines at their edges? Does the
318
+ 3x3 show stripes, a grid, or a mark that repeats too obviously?
319
+ 4. **Style-guide fit.** Does the art follow the style guide and use only the palette?
320
+ 5. **Defects.** Stray pixels, jagged lines (uneven steps), doubled corners, pillow shading
321
+ (shading that follows the outline on every side), muddy or flat areas, broken outlines.
322
+ 6. **Animation.** Does the motion read (a walk, a shimmer)? Does a figure slide, float or jump
323
+ from frame to frame? Does each loop join its end to its start without a hitch? Do the
324
+ directions of a figure look like one figure, and different enough to tell apart?
325
+ 7. **Autotiling.** On each map, does the edge between the two grounds read as one natural edge
326
+ (a shore, a border), with convincing outer and inner corners? Does the map show the tile grid
327
+ (lines or blocks every tile), or the same corner piece repeating too obviously?
328
+ 8. **Scenes.** At game scale, does each scene read as one coherent place? Do the buildings,
329
+ trees and props sit on their ground (bases meeting it, sizes that agree, one light), in a
330
+ sensible order front to back? Does any stretch of ground or edge repeat so that the grid shows?
331
+
332
+ ## How to report
333
+
334
+ End with a list of defects, one per line, each pinned to pixels in the asset's own coordinates
335
+ (x from the left, y from the top, as the rulers show), in this form:
336
+
337
+ \`\`\`
338
+ <asset> <x>,<y> "what is wrong and what to do"
339
+ <asset> <x>,<y> <w>x<h> "for a region"
340
+ \`\`\`
341
+
342
+ For a scene, point at the cell by its column and row (as \`cells.txt\` numbers them):
343
+
344
+ \`\`\`
345
+ <scene> cell <col>,<row> "what is wrong and what to do"
346
+ \`\`\`
347
+
348
+ For a map, point at the tile by its column and row on the map (from 0 at the top left; each
349
+ tile is the set's tile size at 1x), and at the pixel inside that tile:
350
+
351
+ \`\`\`
352
+ <set> map <col>,<row> <x>,<y> "what is wrong and what to do"
353
+ \`\`\`
354
+
355
+ Only list what you can point at. If an asset is fine, say so.
356
+ `}function zb(e,t={}){let r=e.assetDocs(),o=Jt(e.project).manifest,n=t.assets??r.map($=>$.name);if(t.set){if(!o)throw new ee(`set '${t.set}': the project has no valid manifest.json`);let $=o.assets.filter(x=>Ls(x)===t.set).map(x=>x.name);if(!$.length)throw new ee(`no set '${t.set}' in the manifest (sets: ${[...new Set(o.assets.map(Ls))].join(", ")})`);if(n=(t.assets??$).filter(x=>$.includes(x)&&r.some(k=>k.name===x)),!n.length)throw new ee(`nothing in set '${t.set}' is drawn yet`)}let i=n.map($=>{let x=r.find(k=>k.name===$);if(!x)throw new ee(`no asset '${$}' to review`);return x});if(!i.length)throw new ee("no assets to review");let s=e.stamp().slice(0,10),a=Qr(e.project.dir,"reviews",`${s}-${t.name??t.set??"all"}`);Js(Qr(a,"assets"),{recursive:!0});let c=[],l=($,x)=>{DZ(Qr(a,$),x),c.push($)},u=e.project.json.style,m=Ro(u,e.project.json.grid),d=i.filter($=>$.doc.wrap),f=i.filter($=>$.doc.family),p=i.filter($=>$.doc.overlay).map($=>$.doc),h=i.filter($=>$.doc.map),g=i.filter($=>!$.doc.wrap&&!$.doc.family&&!$.doc.overlay&&!$.doc.map);for(let $ of i)$.doc.family||$.doc.map||(l(`assets/${$.name}.png`,Le(ky($.doc,{scale:Math.max(4,Math.min(16,Math.floor(256/Math.max($.doc.width,$.doc.height))))}))),l(`assets/${$.name}.game.png`,Le($m([{doc:$.doc}],{scale:m}))));d.length&&Js(Qr(a,"tiles"),{recursive:!0});for(let $ of d)l(`tiles/${$.name}.3x3.png`,Le(zy($.doc)));g.length&&Js(Qr(a,"scenes"),{recursive:!0});for(let $ of g){let x=Ms($.name,r,u),k=Nm($.name,$.doc,r,u).slice(0,7).map(I=>I.doc),P=$.doc.views.length?$.doc.views.map(I=>({doc:$.doc,frame:I.from})):[{doc:$.doc}];l(`scenes/${$.name}.png`,Le($m([...P,...k.map(I=>({doc:I}))],{ground:x?.doc??null,scale:m})))}f.length&&(Js(Qr(a,"maps"),{recursive:!0}),Js(Qr(a,"sets"),{recursive:!0}));for(let $ of f){let x={cols:t.map?.cols??16,rows:t.map?.rows??12,seed:t.map?.seed??1,overlays:p,scale:m};l(`maps/${$.name}.png`,Le(jy($.doc,x)));let k=Ey($.doc,{...x,scale:1,tickRate:e.project.json.tickRate??60});k.length>1&&l(`maps/${$.name}.gif`,Ds(k,{delta:!0}));let P=Qe($.doc.family),I=_o($.doc,$i(P,x.cols,x.rows,x.seed),0),E=Array.from({length:x.rows},(N,T)=>`${String(T).padStart(2)}: `+Array.from({length:x.cols},(q,Z)=>{let D=I.variants[T*x.cols+Z];return D==null?"-":P.variants[D].name}).join(" "));l(`maps/${$.name}.tiles.txt`,`The tile at each column and row of maps/${$.name}.png ('-': the plain outside ground).
357
+
358
+ ${E.join(`
359
+ `)}
360
+ `),l(`sets/${$.name}.png`,Le(Ty($.doc,{scale:1})))}h.length&&Js(Qr(a,"scenes"),{recursive:!0});for(let $ of h){let x=qn(r),k=Bt($.doc,x);l(`scenes/${$.name}.png`,Le(yi(k,{scale:1}))),l(`scenes/${$.name}.cells.txt`,`The cells of scenes/${$.name}.png (${k.t} px each at 1x).
361
+
362
+ ${VT($.doc,k)}
363
+ `);let[P,I]=Io(u,e.project.json.grid),E=k.top.map((M,L)=>M&&M.variant!=="outside"?L:-1).filter(M=>M>=0),N=E.map(M=>M%k.cols),T=E.map(M=>Math.floor(M/k.cols)),q=E.length?{x0:Math.min(...N),y0:Math.min(...T),x1:Math.max(...N),y1:Math.max(...T)}:{x0:0,y0:0,x1:k.cols-1,y1:k.rows-1},Z=Math.ceil(P/k.t),D=Math.ceil(I/k.t),V=0,F=[];for(let M=q.y0+Math.floor(D/2);M<=q.y1+Math.floor(D/2)&&V<9;M+=D)for(let L=q.x0+Math.floor(Z/2);L<=q.x1+Math.floor(Z/2)&&V<9;L+=Z){let A=wy(k,L,M,P,I);l(`scenes/${$.name}.screen${++V}.png`,Le(yi(k,{scale:m,region:A}))),F.push(`scenes/${$.name}.screen${V}.png: cells ${A.x},${A.y} to ${A.x+A.w-1},${A.y+A.h-1} (columns and rows of cells.txt)`)}l(`scenes/${$.name}.screens.txt`,`${F.join(`
364
+ `)}
365
+ `)}let b=i.filter($=>$.doc.frameCount>1&&!$.doc.family&&!$.doc.map),y=e.project.json.tickRate??60;b.length&&Js(Qr(a,"anim"),{recursive:!0});for(let $ of b)l(`anim/${$.name}.png`,Le(Iy($.doc))),l(`anim/${$.name}.gif`,Ds(Py($.doc,{tickRate:y})));let w=new Map;for(let $ of i){if($.doc.map)continue;let x=new Set;for(let k=0;k<$.doc.frameCount;k++)for(let P of be($.doc,k))x.add(P);$.doc.palette.entries.forEach((k,P)=>{x.has(P)&&w.set(k.name,k.hex+(k.role?` (role: ${k.role})`:""))})}l("palette.md",`# Palette
366
+
367
+ The colours the art uses:
368
+
369
+ ${[...w].map(([$,x])=>`- ${$}: ${x}`).join(`
370
+ `)}
371
+ `);let v=o?i.flatMap($=>{let x=o.assets.find(k=>k.name===$.name);return x?[x]:[]}):[];o&&v.length&&l("brief.md",`# Brief
372
+
373
+ ${o.theme.trim()}
374
+
375
+ ## The pieces
376
+
377
+ ${v.map($=>`- **${$.name}** (${$.kind}, ${$.size}${$.height?`, about ${$.height} px tall`:""})${$.description?`: ${$.description}`:""}`).join(`
378
+ `)}
379
+ `);let S=Qr(e.project.dir,"style.md"),_=NZ(S)?MZ(S,"utf8"):null;return _&&l("style.md",_),l("rubric.md",qZ({brief:!!(o&&v.length),project:e.project.json.name,tiles:d.map($=>$.name),sprites:g.map($=>$.name),animated:b.map($=>$.name),families:f.map($=>$.name),maps:h.map($=>$.name),scale:m,tickRate:y,style:_})),{dir:a,files:c}}import{readFileSync as CN}from"node:fs";import{join as AN}from"node:path";import{mkdirSync as UZ,writeFileSync as ar}from"node:fs";import{join as cr}from"node:path";var Gs=["render","grid","tile3x3","diff","game","recolour","anim","map","family","density"];function hN(e){return Gs.includes(e)}function Rb(e){return vy(e)}function LZ(e,t){if(t.scale!==void 0&&(!Number.isInteger(t.scale)||t.scale<1||t.scale>64))throw new ee("scale must be an integer 1..64");if(t.frame!==void 0&&(!Number.isInteger(t.frame)||t.frame<0||t.frame>=e.frameCount))throw new ee(`frame ${t.frame+1} does not exist (frames 1..${e.frameCount})`);let r=t.region;if(r){if(r.w<1||r.h<1)throw new ee("region size must be at least 1x1");if(!e.wrap&&(r.x+r.w>e.width||r.y+r.h>e.height))throw new ee(`region runs past the ${e.width}x${e.height} canvas`)}}function cd(e,t,r,o,n){if(LZ(e,r),UZ(o,{recursive:!0}),t==="diff"&&e.map&&r.mapDoc){let c=WT(n??null,e,r.mapDoc.world,r.scale??r.mapDoc.drawScale),l=Le(c.img),u=cr(o,`${e.name}.diff.png`);return ar(u,l),{mode:t,kind:"image",png:l,width:c.img.width,height:c.img.height,path:u,text:`${c.text} (before | after, the cells around them at game scale, changed cells outlined)`}}if(t==="diff"){let c=oC(n??null,e,{scale:r.scale}),l=Le(c),u=cr(o,`${e.name}.diff.png`);ar(u,l);let m=Ry(n??null,e,vm(n??null,e));return{mode:t,kind:"image",png:l,width:c.width,height:c.height,path:u,text:m}}if(t==="grid"){let c=r.region,l=rC(e,c,r.frame),u=cr(o,`${e.name}.grid${c?`.${c.x}-${c.y}-${c.w}x${c.h}`:""}.txt`);return ar(u,l),{mode:t,kind:"text",text:l,path:u}}if(t==="map"&&r.mapDoc)return FZ(e,r,o);if(t==="map"){let c={cols:r.map?.cols,rows:r.map?.rows,seed:r.map?.seed,overlays:r.map?.overlays,ground:r.map?.ground,scale:r.scale,theme:r.theme,tickRate:r.tickRate},l=jy(e,c),u=Le(l),m=cr(o,`${e.name}.map.png`);ar(m,u);let d=dC(e,c),f,p=Ey(e,c);return p.length>1&&(f=cr(o,`${e.name}.map.gif`),ar(f,Ds(p,{delta:!0})),d+=`
380
+ animated GIF at game speed: ${f}`),{mode:t,kind:"image",png:u,width:l.width,height:l.height,path:m,text:d,...f?{gif:f}:{}}}if(t==="density"){if(!r.density)throw new ee("the density view needs the base asset and its copies");let{base:c,copies:l,...u}=r.density,m=$C(c,l,{...u,frame:r.frame,scale:r.scale}),d=Le(m.img),f=cr(o,`${e.name}.density.png`);return ar(f,d),{mode:t,kind:"image",png:d,width:m.img.width,height:m.img.height,path:f,text:m.text}}if(t==="family"){if(!e.family)throw new ee(`'${e.name}' is not a family (the family view shows each variant among its neighbours)`);let c=Ty(e,{scale:r.scale,frame:r.frame,theme:r.theme}),l=Le(c),u=cr(o,`${e.name}.family.png`);return ar(u,l),{mode:t,kind:"image",png:l,width:c.width,height:c.height,path:u,text:VZ(e)}}if(t==="anim"){let c=Iy(e,{scale:r.scale,theme:r.theme}),l=Le(c),u=cr(o,`${e.name}.anim.png`);ar(u,l);let m=cr(o,`${e.name}.anim.gif`);ar(m,Ds(Py(e,{theme:r.theme,tickRate:r.tickRate})));let d=`${uC(e,{tickRate:r.tickRate})}
381
+ animated GIF (every sequence side by side, at game speed): ${m}`;return{mode:t,kind:"image",png:l,width:c.width,height:c.height,path:u,text:d,gif:m}}let i=t==="render"?ky(e,{scale:r.scale,frame:r.frame,marks:r.marks,theme:r.theme,underlay:r.underlay,...r.region?{region:r.region}:{}}):t==="tile3x3"?zy(e,r.frame,{marks:r.marks,theme:r.theme,...r.scale?{scale:r.scale}:{}}):t==="game"?$m([...(r.game?.frames??[r.frame??0]).map(c=>({doc:e,frame:c})),...(r.game?.with??[]).map(c=>({doc:c}))],{ground:r.game?.ground,scale:r.game?.scale??2,theme:r.theme,marks:r.marks}):iC(e,r.themes??[],{scale:r.scale,frame:r.frame}),s=Le(i),a=cr(o,`${e.name}.${t}${t==="render"&&r.region?`.${r.region.x}-${r.region.y}-${r.region.w}x${r.region.h}`:""}.png`);return ar(a,s),{mode:t,kind:"image",png:s,width:i.width,height:i.height,path:a}}function FZ(e,t,r){let o=t.mapDoc,n=o.doc,i=Bt(n,o.world),s=o.region?{...o.region}:void 0,a="";if(o.camera){let g=wy(i,o.camera[0],o.camera[1],o.screen[0],o.screen[1]);s={x:g.x,y:g.y,w:g.w,h:g.h},a=`the camera at ${o.camera[0]},${o.camera[1]}: a ${o.screen[0]}x${o.screen[1]} px screen, cells ${g.x},${g.y} ${g.w}x${g.h}`}else if(s){if(s.x+s.w>i.cols||s.y+s.h>i.rows)throw new ee(`region runs past the ${i.cols}x${i.rows} cells of the map`);a=`cells ${s.x},${s.y} ${s.w}x${s.h}`}let c=t.scale??(s||o.note?o.drawScale:1),l={scale:c,region:s,marks:t.marks},u=yi(i,l),m=Le(u),d=o.camera?".camera":s?`.${s.x}-${s.y}-${s.w}x${s.h}`:"",f=cr(r,`${e.name}.map${d}.png`);ar(f,m);let p=o.note??LT(n,o.world,i);!o.note&&n.width<=80&&(p+=`
382
+ ${FT(n)}`),p+=`
383
+ showing ${a||"the whole map"} at ${c}x${t.marks?.length?`; ${t.marks.length} flagged cells outlined in magenta`:""}`;let h;if(u.width*u.height<=1200*900){let g=UT(n,o.world,{...l,tickRate:t.tickRate});g.length>1&&(h=cr(r,`${e.name}.map${d}.gif`),ar(h,Ds(g,{delta:!0})),p+=`
384
+ animated GIF at game speed: ${h}`)}return{mode:"map",kind:"image",png:m,width:u.width,height:u.height,path:f,text:p,...h?{gif:h}:{}}}function VZ(e){let t=e.family,r=Qe(t),o=mt(t),n=t.tile,i=new Set(r.pieces),s=new Set(t.detached),a=t.geometry,c=[`${e.name}: ${r.name}, ${r.variants.length} variants of ${n}x${n}; band ${a.bands.length?a.bands.map(l=>`${l.w}:${typeof l.fill=="number"?e.palette.entries[l.fill].name:l.fill}`).join(" "):"none"} radius ${a.radius} inset ${a.inset}`,`textures: inside @cell(inside) at ${o.inside[0]*n},${o.inside[1]*n}; outside @cell(outside) at ${o.outside[0]*n},${o.outside[1]*n}`,`pieces (draw these on layer band; the others are built from their quadrants): ${r.pieces.join(", ")}`,"cells: "+r.variants.map((l,u)=>`${l.name} ${o.cells[u][0]*n},${o.cells[u][1]*n}${i.has(l.name)?" (piece)":s.has(l.name)?" (detached)":""}`).join("; ")];return t.mapCols&&c.push(`coverage map: ${t.mapCols}x${t.mapRows} tiles from 0,${o.mapRow*n}${t.terrain.length?"":" (not laid out yet: family coverage)"}`),c.join(`
385
+ `)}import{appendFileSync as ZZ,existsSync as k1,mkdirSync as HZ,readFileSync as z1,statSync as BZ}from"node:fs";import{basename as gN,isAbsolute as yN,join as jb,resolve as bN}from"node:path";var ld=new Map;function R1(e,t){if(!/^[0-9a-f]{64}$/.test(t))return;let r=jb(e.dir,"blobs",`${t}.png`);if(!k1(r))return;let o=BZ(r).mtimeMs,n=ld.get(r);if(n&&n.mtime===o)return n.img;let i=Kr(z1(r));return ld.set(r,{mtime:o,img:i}),ld.size>16&&ld.delete(ld.keys().next().value),i}function wN(e,t){let r=e.replace(/\b(sk|rk|pk)-[A-Za-z0-9_*\-.]{2,}/g,"[key]").replace(/\*{4,}[A-Za-z0-9_-]*/g,"[key]");if(!t)return r;r=r.split(t).join("[key]");for(let o=t.length-1;o>=4;o--)for(let n of[t.slice(0,o),t.slice(-o)])r.includes(n)&&(r=r.split(n).join("[key]"));return r}function WZ(e,t){let r=Math.min(1,2048/Math.max(e,t)),o=e*r,n=t*r;return r=Math.min(1,768/Math.min(o,n)),o*=r,n*=r,85+170*Math.ceil(o/512)*Math.ceil(n/512)}var vN="https://api.openai.com/v1",JZ={name:"openai",defaults:{model:"gpt-image-1.5",quality:"medium"},async generate(e,t){let o=(t.env??process.env).OPENAI_API_KEY;if(!o)throw new ee("underlay generate: OPENAI_API_KEY is not set in the environment of the PixelClaw process (the server, or the CLI running this; or use provider=fake)");let n=t.fetch??globalThis.fetch,i=`${e.size[0]}x${e.size[1]}`,s;try{if(e.layout){let l=new FormData;l.append("model",e.model),l.append("prompt",e.prompt),l.append("size",i),l.append("quality",e.quality),l.append("n","1"),l.append("image[]",new Blob([Buffer.from(e.layout)],{type:"image/png"}),"layout.png"),s=await n(`${vN}/images/edits`,{method:"POST",headers:{Authorization:`Bearer ${o}`},body:l})}else s=await n(`${vN}/images/generations`,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({model:e.model,prompt:e.prompt,size:i,quality:e.quality,n:1})})}catch(l){throw new ee(`underlay generate: the request failed: ${wN(l.message,o)}`)}if(!s.ok){let l="";try{l=await s.text()}catch{}let u=l;try{u=JSON.parse(l).error?.message??l}catch{}throw new ee(`underlay generate: OpenAI answered ${s.status}: ${wN(u,o).slice(0,400)}`)}let a=await s.json(),c=a.data?.[0]?.b64_json;if(!c)throw new ee("underlay generate: the answer held no image");return{png:new Uint8Array(Buffer.from(c,"base64")),...a.usage?{usage:a.usage}:{}}}};function GZ(e){let[t,r]=e.size,o=new dt(ly(`${e.prompt}|${t}x${r}`),7),n=e.layoutImage??null,[i,s]=e.grid??(n?[n.width,n.height]:[Math.round(t/8),Math.round(r/8)]),a=(e.palette?.entries??[]).map(y=>it(y.hex)),c=new Uint8Array(i*s*4),l=new Map,u=(y,w)=>{let v=`${y},${w}`;return l.has(v)||l.set(v,o.nextInt(1e3)/1e3),l.get(v)},m=(y,w)=>{let v=Math.floor(y),S=Math.floor(w),_=y-v,$=w-S,x=_*_*(3-2*_),k=$*$*(3-2*$),P=u(v,S)*(1-x)+u(v+1,S)*x,I=u(v,S+1)*(1-x)+u(v+1,S+1)*x;return P*(1-k)+I*k};for(let y=0;y<s;y++)for(let w=0;w<i;w++){let v;if(n){let S=(Math.min(n.height-1,Math.floor((y+.5)*n.height/s))*n.width+Math.min(n.width-1,Math.floor((w+.5)*n.width/i)))*4;v=[n.data[S],n.data[S+1],n.data[S+2]]}else v=[o.nextInt(256),o.nextInt(256),o.nextInt(256)];if(a.length){let S=I=>(a[I][0]-v[0])**2+(a[I][1]-v[1])**2+(a[I][2]-v[2])**2,_=a.reduce((I,E,N)=>S(N)<S(I)?N:I,0),$=e.palette.entries[_].name,x=Object.values(e.palette.ramps).find(I=>I.includes($)),k=I=>{let E=x?.[x.indexOf($)+I],N=E?e.palette.entries.findIndex(T=>T.name===E):-1;return N>=0?N:_},P=m(w/2,y/2)*.5+o.nextInt(1e3)/1e3*.5;v=a[P>.66?k(1):P<.3?k(-1):_]}c.set([v[0],v[1],v[2],255],(y*i+w)*4)}let d=t/i,f=r/s,p=d*(o.nextInt(31)-15)/100,h=f*(o.nextInt(31)-15)/100,g=new Float64Array(t*r*3);for(let y=0;y<r;y++)for(let w=0;w<t;w++){let v=Math.min(i-1,Math.max(0,Math.floor((w+.5-p)/d))),S=Math.min(s-1,Math.max(0,Math.floor((y+.5-h)/f)));for(let _=0;_<3;_++)g[(y*t+w)*3+_]=c[(S*i+v)*4+_]}let b=ut(t,r);for(let y=0;y<r;y++)for(let w=0;w<t;w++){for(let v=0;v<3;v++){let S=0,_=0;for(let $=-1;$<=1;$++)for(let x=-1;x<=1;x++){let k=w+x,P=y+$;k<0||P<0||k>=t||P>=r||(S+=g[(P*t+k)*3+v],_++)}b.data[(y*t+w)*4+v]=Math.max(0,Math.min(255,Math.round(S/_+o.nextInt(7)-3)))}b.data[(y*t+w)*4+3]=255}return b}var KZ={name:"fake",defaults:{model:"draft",quality:"medium"},async generate(e){return{png:Le(GZ(e))}}},$N=new Map([JZ,KZ].map(e=>[e.name,e])),YZ={"gpt-image-1.5":{image:{low:{"1024x1024":.009,"1536x1024":.013,"1024x1536":.013},medium:{"1024x1024":.034,"1536x1024":.05,"1024x1536":.05},high:{"1024x1024":.133,"1536x1024":.2,"1024x1536":.2}},tokens:{textIn:5,imageIn:8,imageOut:32}},"gpt-image-1":{image:{low:{"1024x1024":.011,"1536x1024":.016,"1024x1536":.016},medium:{"1024x1024":.042,"1536x1024":.063,"1024x1536":.063},high:{"1024x1024":.167,"1536x1024":.25,"1024x1536":.25}},tokens:{textIn:5,imageIn:10,imageOut:40}},"gpt-image-1-mini":{image:{low:{"1024x1024":.005,"1536x1024":.006,"1024x1536":.006},medium:{"1024x1024":.011,"1536x1024":.015,"1024x1536":.015},high:{"1024x1024":.036,"1536x1024":.052,"1024x1536":.052}},tokens:{textIn:2,imageIn:2.5,imageOut:8}},draft:{image:{low:{},medium:{},high:{}}}},XZ=.25;function QZ(e,t,r,o,n,i){if(e==="fake")return 0;let a=n[t]?.image?.[r]?.[o];if(a===void 0)return null;let c=n[t]?.tokens,l=i?.image?WZ(i.image[0],i.image[1])*(c?.imageIn??0):0,u=i?.prompt?Math.ceil(i.prompt.length/4)*(c?.textIn??0):0;return a+(l+u)/1e6}function eH(e,t,r){let o=r[e]?.tokens;if(!t||!o)return null;let n=t.input_tokens_details??{},i=Number(n.text_tokens??0),s=Number(n.image_tokens??0),a=Number(t.output_tokens??0);return Number.isFinite(i+s+a)?(i*(o.textIn??0)+s*(o.imageIn??0)+a*(o.imageOut??0))/1e6:null}var tH=jb("logs","underlay-costs.jsonl");function Ib(e,t){let r=jb(e.dir,tH);HZ(jb(r,".."),{recursive:!0}),ZZ(r,JSON.stringify(t)+`
386
+ `)}var nH=[[1024,1024],[1536,1024],[1024,1536]];function rH(e){if(!e)return[1536,1024];let t=e[0]/e[1];return nH.reduce((r,o)=>Math.abs(Math.log(o[0]/o[1]/t))<Math.abs(Math.log(r[0]/r[1]/t))?o:r)}function oH(e,t,r){let o=ut(t,r);for(let n=0;n<r;n++)for(let i=0;i<t;i++){let s=Math.min(e.width-1,Math.floor((i+.5)*e.width/t)),a=Math.min(e.height-1,Math.floor((n+.5)*e.height/r));o.data.set(e.data.subarray((a*e.width+s)*4,(a*e.width+s)*4+4),(n*t+i)*4)}return o}function iH(e,t,r){let o=e.layers.findIndex(a=>a.name===t);if(o<0)return null;let n=e.cels[o][0],i=r??{x:0,y:0,w:e.width,h:e.height},s=ut(i.w,i.h);for(let a=0;a<i.h;a++)for(let c=0;c<i.w;c++){let l=i.x+c,u=i.y+a;if(l<0||u<0||l>=e.width||u>=e.height)continue;let m=n[u*e.width+l];if(m===65535)continue;let d=it(e.palette.entries[m].hex);s.data.set([d[0],d[1],d[2],255],(a*i.w+c)*4)}return s}function sH(e,t,r){let o=e.get("at"),n=e.get("size"),i=o?/^(\d+),(\d+)$/.exec(o):null,s=n?/^(\d+)x(\d+)$/.exec(n):null;if(o&&!i)throw new ee(`${r}: at= is a point x,y`);if(n&&(!s||Number(s[1])<1||Number(s[2])<1))throw new ee(`${r}: size= is the placed area, like 72x48`);let[a,c]=i?[Number(i[1]),Number(i[2])]:[0,0];return s?{x:a,y:c,w:Number(s[1]),h:Number(s[2])}:t?{x:a,y:c,w:t.width,h:t.height}:null}var Pb=/^\s*underlay\s+(generate|import)\b/;function Ti(e){return e.split(/\r?\n/).some(t=>Pb.test(t))}async function Eb(e,t,r){let o=t.split(/\r?\n/),n=!1,i=e.json.underlay??{},s={...YZ,...i.prices??{}};for(let a=0;a<o.length;a++){let c=o[a];if(n){c.trim()===">>"&&(n=!1);continue}if(/<<\s*(#.*)?$/.test(c)&&!Pb.test(c)){n=!0;continue}if(!Pb.test(c))continue;let l=pn(c),u=`line ${a+1}`;if(l.errors.length)throw new ee(`${u}: ${l.errors[0].message}`);if(l.commands.length!==1)throw new ee(`${u}: put underlay ${Pb.exec(c)[1]} on a line of its own`);let m=l.commands[0],d=new Map,f=[];for(let z of m.args)if(z.t==="kv")d.set(z.key,z.value);else if(z.t==="string"||z.t==="word")f.push(z.v);else throw new ee(`${u}: underlay: unexpected '${z.t}'`);let p=f.shift();if(r.confined&&p==="generate")throw new ee(`${u}: the worker does not call the image provider (underlay generate); use underlay import with a file in the project, or ask the person`);let h=p==="generate"?["layer","layout","image","provider","model","quality","cap","at","size"]:["layer","layout","at","size"];for(let z of d.keys())if(!h.includes(z))throw new ee(`${u}: underlay ${p} has no option '${z}' (options: ${h.join(", ")})`);let g=d.get("layer")??(p==="generate"?"mockup":"underlay"),b=`${d.has("at")?` at=${d.get("at")}`:""}${d.has("size")?` size=${d.get("size")}`:""}`,y=sH(d,r.doc,u),w=null,v=null,S=d.get("layout");if(S&&S!=="none"){let z=yN(S)?S:bN(e.dir,S);if(r.confined&&/\.png$/i.test(S)&&Hm(e,z,`${u}: layout`),/\.png$/i.test(S)&&k1(z)){let R=z1(z);w=Kr(R),v=Pi(e,R,".png")}else{if(w=r.doc?iH(r.doc,S,y??void 0):null,!w)throw new ee(`${u}: layout=${S} is neither a PNG file in the project nor a layer of the asset`);v=Pi(e,Le(w),".png")}}if(p==="import"){let z=f[0];if(!z||f.length>1)throw new ee(`${u}: underlay import <file.png>`);let R=yN(z)?z:bN(e.dir,z);if(r.confined&&Hm(e,R,`${u}: underlay import`),!k1(R))throw new ee(`${u}: underlay import: no file ${z}`);let C=z1(R),U;try{U=Kr(C)}catch(X){throw new ee(`${u}: underlay import: ${gN(z)}: ${X.message}`)}let W=Pi(e,C,".png");o[a]=`underlay ${g} blob=${W} image=${U.width}x${U.height}${b}${v?` layout=${v}`:""} from=${tn(gN(z))}`;continue}let _=f[0];if(!_||f.length>1)throw new ee(`${u}: underlay generate "<prompt>" (the prompt in quotes)`);let $=d.get("provider")??i.provider??"openai",x=$N.get($);if(!x)throw new ee(`${u}: no provider '${$}' (providers: ${[...$N.keys()].join(", ")})`);let k=d.get("model")??($===(i.provider??"openai")?i.model:void 0)??x.defaults.model,P=d.get("quality")??i.quality??x.defaults.quality,I=d.get("image")??i.size,E=I?(()=>{let z=/^(\d+)x(\d+)$/.exec(I);if(!z)throw new ee(`${u}: image= is the size to ask for, like 1536x1024`);return[Number(z[1]),Number(z[2])]})():rH(y?[y.w,y.h]:null),N=d.get("cap")??process.env.PIXELCLAW_UNDERLAY_CAP??(i.cap!==void 0?String(i.cap):void 0),T=N!==void 0?Number(N):XZ;if(!Number.isFinite(T)||T<0)throw new ee(`${u}: cap= is US dollars, like 0.25`);let q=`${E[0]}x${E[1]}`,Z=QZ($,k,P,q,s,{image:w?E:null,prompt:_}),D={at:r.now,provider:$,model:k,quality:P,size:q,layout:v,prompt:_,estimate:Z,cap:T};if(Z===null)throw Ib(e,{...D,ok:!1,error:"no price for this model, quality and size"}),new ee(`${u}: no price for ${k} at ${P} ${q}, so the cost cap cannot be checked; add it to project.json underlay.prices`);if(Z>T)throw Ib(e,{...D,ok:!1,error:"over the cap"}),new ee(`${u}: ${k} at ${P} ${q} is about $${Z.toFixed(3)}, over the cap of $${T.toFixed(2)} a call (cap=, PIXELCLAW_UNDERLAY_CAP or project.json underlay.cap)`);let V;try{V=await x.generate({prompt:_,size:E,model:k,quality:P,layout:w?Le(oH(w,E[0],E[1])):null,...r.doc?{grid:[y.w,y.h],palette:r.doc.palette}:{},layoutImage:w},r)}catch(z){throw Ib(e,{...D,ok:!1,error:z.message}),z}let F;try{F=Kr(V.png)}catch(z){throw new ee(`${u}: the provider's image does not decode: ${z.message}`)}let M=Pi(e,V.png,".png"),L=eH(k,V.usage,s),A=L??Z;Ib(e,{...D,ok:!0,blob:M,...V.usage?{usage:V.usage}:{},...L!==null?{actual:L}:{}}),o[a]=`underlay ${g} blob=${M} image=${F.width}x${F.height}${b}${v?` layout=${v}`:""} prompt=${tn(_)} provider=${$} model=${k} quality=${P} cost=${A.toFixed(4).replace(/0+$/,"").replace(/\.$/,"")||"0"}`}return o.join(`
387
+ `)}import{readFileSync as lH,statSync as uH}from"node:fs";import{join as EN}from"node:path";import{existsSync as Dc,mkdirSync as xN,readFileSync as Cb,readdirSync as aH,renameSync as _N,rmSync as Qre,writeFileSync as Tb}from"node:fs";import{dirname as P1,join as lr}from"node:path";import{fileURLToPath as cH}from"node:url";var j1="PCLAWSTATE 1",Ab=".cache",I1=null;function SN(){if(I1)return I1;let e=cH(import.meta.url),t=lr(P1(e),"..","..","core"),r=[];if(e.endsWith(".ts")&&Dc(lr(t,"src")))for(let n of["src","schemes"]){let i=lr(t,n);if(Dc(i))for(let s of aH(i).sort())/\.(ts|json)$/.test(s)&&r.push(lr(i,s))}else r.push(e);let o=r.map(n=>`${n.slice(t.length)}
388
+ ${Tn(Cb(n))}`);return I1=Tn(Buffer.from(o.join(`
389
+ `),"utf8"))}function ud(e,t,r){let o=r===1?[...e.palettes.values()].map(po).join(`
390
+ `):"";return Tn(Buffer.concat([Buffer.from(`${SN()}
391
+ ${o}
392
+ `,"utf8"),t]))}function E1(e,t){return lr(e.dir,Ab,"state",`${t}.gwc`)}function kN(e,t,r){let o=E1(e,t);if(!Dc(o))return null;try{let n=Cb(o),i=n.indexOf(10);return i<0||n.subarray(0,i).toString("utf8")!==`${j1} ${r}`?null:ey(n.subarray(i+1))}catch{return null}}function zN(e,t){let r=E1(e,t);if(!Dc(r))return null;let o=Cb(r),n=o.indexOf(10),i=n>0?new RegExp(`^${j1} ([0-9a-f]{64})$`).exec(o.subarray(0,n).toString("utf8")):null;return i?{key:i[1],body:o.subarray(n+1)}:null}function T1(e,t,r,o){let n=E1(e,t);try{let i=lr(e.dir,Ab);xN(P1(n),{recursive:!0}),Dc(lr(i,".gitignore"))||Tb(lr(i,".gitignore"),`*
393
+ `);let s=`${n}.${process.pid}.tmp`;Tb(s,Buffer.concat([Buffer.from(`${j1} ${r}
394
+ `,"utf8"),o])),_N(s,n)}catch{}}function RN(e,t){return lr(e.dir,Ab,"checks",`${t}.json`)}function IN(e){return Tn(Buffer.from(JSON.stringify([SN(),e]),"utf8"))}function PN(e,t,r){try{let o=JSON.parse(Cb(RN(e,t),"utf8"));return o.key===r?o.out:null}catch{return null}}function jN(e,t,r,o){let n=RN(e,t);try{let i=lr(e.dir,Ab);xN(P1(n),{recursive:!0}),Dc(lr(i,".gitignore"))||Tb(lr(i,".gitignore"),`*
395
+ `);let s=`${n}.${process.pid}.tmp`;Tb(s,JSON.stringify({key:r,out:o})),_N(s,n)}catch{}}var md=1<<18,qc=class extends ee{},Uc=class extends ee{asset;constructor(t){super(`asset '${t}' already exists; set replace to start its tape again`),this.asset=t}};function mH(e){let t=/^([≤≥<>]) ?(-?[\d.]+)/.exec(e.limit);if(!t||e.score===null||!Number.isFinite(e.score))return null;let r=Number(t[2]);return t[1]==="\u2264"||t[1]==="<"?r>0?e.score/r:e.score>0?1+e.score:0:e.score>0?r/e.score:r>0?2:0}var dH=/^(px|line|rect|ellipse|fill|paint|stroke|shift|flip|rotate|clear|curve|polygon|dither|gradient|outline|shade|clean|noise|scatter|voronoi|bricks|stamp (?!save |remove )|call)\b/,C1=e=>e.flatMap(t=>t.t==="word"?[t.v]:[]);function TN(e,t){let r=[];e.some(n=>dH.test(n.cmd))&&t===0&&r.push("the batch changed no pixels");for(let n of e){let i=/^snap .* r2=([\d.]+) material=([\d.]+|none)/.exec(n.cmd);if(!i)continue;let s=[Number(i[1])<Cm?`block R\xB2 ${i[1]} < ${Cm}`:"",i[2]!=="none"&&Number(i[2])<Am?`material match ${i[2]} < ${Am}`:""].filter(Boolean);s.length&&r.push(`snap: ${s.join(", ")}; the draft is unreliable: reroll the underlay (a new prompt or seed) or trace over it instead`)}return r}var fH=()=>new Date().toISOString().replace(/\.\d{3}Z$/,"Z"),Lt=class{project;states=new Map;timelines=new Map;listeners=new Set;queue=Promise.resolve();now;live=null;styleStamp="";versions=new Map;clock=0;checkMemo=new Map;keys=new Map;checkCache;lastEye=null;worker={running:!1,by:null,startedAt:null,spent:0,cap:0,sessions:0,stopped:null};constructor(t,r={}){this.project=t,this.now=r.now??fH,this.checkCache=r.checkCache??!0}requestsChanged(){this.emit({type:"requests",requests:[...sn(this.project).values()]})}workerStatus(){let t=Ws(this.project.dir);return{enabled:t.enabled,...this.worker,...this.worker.running?{}:{spent:sd(this.project.dir),cap:t.cap}}}setWorker(t){this.worker={...this.worker,...t},this.emit({type:"worker",status:this.workerStatus()})}workerLog(t){t.length&&this.emit({type:"workerLog",lines:t})}stamp(){return this.now()}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(let r of this.listeners)try{r(t)}catch{}}enqueue(t){let r=this.queue.then(t);return this.queue=r.catch(()=>{}),r}setProject(t){this.project=t,this.styleStamp="",this.states.clear(),this.timelines.clear(),this.checkMemo.clear(),this.keys.clear(),this.live=null,this.lastEye=null,this.emit({type:"hello",snapshot:this.snapshot()})}setGrid(t){NO(this.project,t),this.emit({type:"hello",snapshot:this.snapshot()})}addPalettes(t){MO(this.project,t),this.emit({type:"palettes",palettes:[...this.project.palettes.values()],defaultPalette:this.project.json.defaultPalette})}state(t){let r=this.states.get(t);if(r)return r;let{bytes:o,entries:n}=Wm(this.project,t),i=ud(this.project,o,kr(n));this.keys.set(t,i);let s=n.length?kN(this.project,t,i):null;if(s){this.timeline(t).seed(n,n.length,s);let l={doc:s,entries:n,cache:new ki};return this.states.set(t,l),l}let a=DO(this.project,t,n),c;if(a){let l=zi.resume(jo(this.project),a.doc,n.slice(0,a.n));for(let u of n.slice(a.n)){let m=l.step(u);if(m)throw new ee(`asset '${t}': tape seq ${u.seq}: ${m} (run 'pixelclaw verify')`)}this.timeline(t).seed(n,a.n,a.doc),c={doc:l.doc,entries:n,cache:l.cache}}else{let l=Om(n,jo(this.project));if(l.problems.length)throw new ee(`asset '${t}': tape seq ${l.problems[0].seq}: ${l.problems[0].message} (run 'pixelclaw verify')`);c={doc:l.doc,entries:n,cache:l.cache}}return c.doc&&T1(this.project,t,i,Rn(c.doc)),this.states.set(t,c),c}timeline(t){let r=this.timelines.get(t);return r||this.timelines.set(t,r=new Ec(jo(this.project))),r}doc(t){let{doc:r}=this.state(t);if(!r)throw new ee(`asset '${t}' has an empty tape`);return r}docAt(t,r){let o=this.timeline(t).docAfter(this.state(t).entries,r);if(o.problem)throw new ee(`asset '${t}': ${o.problem}`);return o.doc}async runAsync(t,r={},o={}){if(!Ti(t.commands))return this.run(t);let n=null,i=t.asset;if(i&&Eo(this.project,i))try{n=this.doc(i)}catch{n=null}let s=await Eb(this.project,t.commands,{...r,doc:n,now:this.now(),confined:o.confined});return this.run({...t,commands:s})}run(t){let r=this.batch(t);if(!r.ok)return r;let{name:o,creates:n,r:i}=r,s={asset:o,doc:i.state.doc,group:i.group,added:i.added,changed:i.changed,created:n},a=p=>({commands:p.entries.length,groups:new Set(p.entries.map(h=>h.group)).size});if(!i.state.doc||i.added.length===0)return{ok:!0,...s,warnings:["no commands"],...a(i.state),dir:null};let c=this.checkSaves(i.saves);n&&this.timelines.delete(o);let l=this.timeline(o),u=ub(this.project,i.state,p=>{let h=l.docAt(i.state.entries,p);if(h.problem)throw new ee(`asset '${o}': ${h.problem}`);return h.doc},n);this.writePalettes(c);let m=ud(this.project,Buffer.from(Yy(i.state.entries),"utf8"),kr(i.state.entries));this.keys.set(o,m),T1(this.project,o,m,Rn(i.state.doc)),this.states.set(o,i.state),this.versions.set(o,++this.clock),this.live=o,this.freshStyle();let d=TN(i.added,i.changed);i.state.doc.family&&i.added.some(p=>/^family cut\b/.test(p.cmd))&&d.push(...this.cutWarnings(o)),this.emit({type:"batch",asset:o,by:t.by,group:i.group,entries:n?i.state.entries:i.added,changed:i.changed,reset:n});let f=this.follow(o,t.by,i.added.some(p=>/^variant of=\S+ band=inherit/.test(p.cmd)));return{ok:!0,...s,warnings:d,...a(i.state),dir:u,...f.length?{followed:f}:{}}}dry(t,r={}){let o=this.batch(t,!0);if(!o.ok)return o;let{name:n,r:i}=o,s=i.added.length?i.state.doc:null,a=s?TN(i.added,i.changed):["no commands"];s?.family&&i.added.some(l=>/^family cut\b/.test(l.cmd))&&a.push(...this.cutWarnings(n,s));let c=s?this.checks(n,r,s).results:[];return{ok:!0,asset:n,doc:s,added:i.added,changed:i.changed,warnings:a,results:c}}seeds(t){let r=pn(t.line);if(r.errors.length)return{ok:!1,errors:r.errors};if(r.commands.length!==1)throw new ee(`seeds: give one generator command (got ${r.commands.length})`);let o=t.seeds?.length?[...new Set(t.seeds)]:Array.from({length:t.count??8},(s,a)=>(t.from??1)+a);if(o.some(s=>!Number.isInteger(s)||s<1))throw new ee("seeds: seeds are whole numbers from 1");if(o.length>64)throw new ee("seeds: at most 64 seeds at once");let n=t.line.trim().replace(/\s+seed=\S+/,""),i=[];for(let s of o){let a=`${n} seed=${s}`,c=this.dry({asset:t.asset,commands:t.before?`${t.before}
396
+ ${a}`:a,by:t.by},{checks:t.checks});if(!c.ok){if(c.errors.some(f=>/no option 'seed'/.test(f.message)))throw new ee(`seeds: '${r.commands[0].name}' takes no seed (only generators do: noise, scatter, voronoi, bricks, pebbles, tufts, map gen, family coverage, \u2026)`);return c}let l=c.added.at(-1)?.cmd??"";if(!new RegExp(`\\bseed=${s}\\b`).test(l))throw new ee(`seeds: '${r.commands[0].name}' takes no seed (only generators do: noise, scatter, voronoi, bricks, pebbles, tufts, map gen, family coverage, \u2026)`);let u=c.results.filter(f=>f.status!=="skip"),m=u.filter(f=>f.status==="fail"),d=f=>mH(f)??(f.status==="fail"?2:0);i.push({seed:s,line:l,results:c.results,failing:m.map(f=>f.id),excess:m.reduce((f,p)=>f+Math.max(0,d(p)-1),0),margin:u.filter(f=>f.status==="pass").reduce((f,p)=>Math.max(f,d(p)),0)})}return i.sort((s,a)=>s.failing.length-a.failing.length||s.excess-a.excess||s.margin-a.margin||s.seed-a.seed),{ok:!0,trials:i}}cutWarnings(t,r){let o=this.checks(t,{checks:["seam"]},r).results[0];return!o||o.status!=="fail"?[]:[`family cut: the cut family's seam is ${o.shown} (limit ${o.limit}) on a sample island: its tiles do not join; look at view map, fix the band or the textures by coordinates (check seam), or cut again from a cleaner map`]}following=!1;follow(t,r,o){if(this.following)return[];this.following=!0;let n=[];try{let i=[t],s=new Set,a=(c,l)=>{let u=this.doc(c),m=this.dry({asset:c,commands:l,by:r});if(!m.ok||!m.doc||Buffer.compare(Buffer.from(Rn(m.doc)),Buffer.from(Rn(u)))===0)return;this.run({asset:c,commands:l,by:r}).ok&&(n.includes(c)||n.push(c),i.push(c))};if(o){let c=this.doc(t).family;c?.bandOf&&this.assets().includes(c.bandOf)&&a(t,`family band from=${c.bandOf}`)}for(;i.length;){let c=i.shift();if(!s.has(c)){s.add(c);for(let l of this.assets()){if(l===c||s.has(l))continue;let u;try{u=this.doc(l).family}catch{continue}if(!u)continue;u.bandOf===c&&a(l,`family band from=${c}`);let m=this.textureFollow(l,c,r);m&&a(l,m)}}}}finally{this.following=!1}return n}textureFollow(t,r,o){let{entries:n}=this.state(t);if(!n.some(d=>d.cmd.startsWith("family texture ")&&d.cmd.split(`
397
+ `)[0].includes(` from=${r} `)))return null;let i=this.doc(t),s=Ns(n),a=new Map;for(let d of n){if(!s.has(d.group))continue;let f=/^family texture (inside|outside)\b([^\n]*)/.exec(d.cmd);if(!f)continue;let p=/ from=(\S+)/.exec(f[2])?.[1]??null,h=Number(/ frame=(\d+)/.exec(f[2])?.[1]??1),g=0;if(i.frameCount>1){let b=this.docAt(t,d.seq);g=b?Me(b,d.by).frame:0}a.set(`${f[1]}@${g}`,{from:p,frame:h,on:g})}let c=[...a].filter(([,d])=>d.from===r);if(!c.length)return null;let l=[],u=Me(i,o).frame,m=u;for(let[d,f]of c.sort((p,h)=>p[1].on-h[1].on||p[0].localeCompare(h[0])))i.frameCount>1&&m!==f.on&&(l.push(`frame ${f.on+1}`),m=f.on),l.push(`family texture ${d.split("@")[0]} from=${r} frame=${f.frame}`);return m!==u&&l.push(`frame ${u+1}`),l.join(`
398
+ `)}batch(t,r=!1){let o=pn(t.commands),n=o.commands[0],i=n?.name==="new",s=n?.name==="fork",a=i||s?C1(n.args)[1]:void 0,c=t.asset??a;if(!c){if(o.errors.length)return{ok:!1,errors:o.errors};throw new qc("say which asset to draw on (or start the commands with 'new')")}if(a&&t.asset&&a!==t.asset)throw new ee(`the commands create '${a}' but the asset is '${t.asset}'`);let l={doc:null,entries:[]},u=Eo(this.project,c),m=i||s;if(u){if(m&&!t.replace)throw new Uc(c);m||(l=r?{...this.state(c),cache:new ki}:this.state(c))}else if(!m&&!o.errors.length)throw new ee(`no asset '${c}' in ${this.project.dir}; start the commands with 'new <kind> ${c} <W>x<H>'`);s&&!o.errors.length&&(l=this.forkPrefix(n));let d=h=>{if(!(h===c||!this.assets().includes(h)))try{return this.doc(h)}catch{return}},f=QO(this.project,Jt(this.project).manifest),p=qk(l,t.commands,{by:t.by,at:this.now(),palettes:jo(this.project),assets:d,assetNames:()=>this.assets(),defaults:f,images:h=>R1(this.project,h)});if(!p.ok)return{ok:!1,errors:p.errors};if(p.state.doc&&p.added.length&&p.state.doc.name!==c)throw new ee(`the commands create '${p.state.doc.name}' but the asset is '${c}'`);return{ok:!0,name:c,creates:m,r:p}}checkSaves(t){let r=new Map;for(let o of t){let n={...o.palette,name:o.name},i=this.project.palettes.get(o.name);if(i&&po(i)!==po(n))throw new ee(`palette save: the project already has a different palette '${o.name}' (tapes made with it would replay differently); save as another name`);i||r.set(o.name,n)}return[...r.values()]}writePalettes(t){t.length&&this.addPalettes(t)}forkPrefix(t){let r=C1(t.args)[0];if(!r)return{doc:null,entries:[]};if(!Eo(this.project,r))throw new ee(`fork: no asset '${r}' to fork from`);let o=this.state(r).entries,n=t.args.find(c=>c.t==="kv"&&c.key==="at"),i=o.at(-1)?.seq??0,s=n?.t==="kv"?Number(n.value):i;if(!Number.isInteger(s)||s<1||s>i)throw new ee(`fork: at=${n?.t==="kv"?n.value:s} is not a command of '${r}' (1..${i})`);let a=o.filter(c=>c.seq<=s);return{doc:this.docAt(r,s),entries:a}}changes(t,r={}){let o=UO(this.project),n=o[t]??={},i=r.asset?[r.asset]:this.assets(),s=[];for(let a of i){let{doc:c,entries:l}=this.state(a);if(!c)continue;let u=l.at(-1)?.seq??0,m=r.since??n[a]??sb(l)?.at??0;if(m>u&&(m=0),r.since===void 0){let h=l.findIndex(g=>g.seq>m);for(;h>=0&&h<l.length&&l[h].by===t;)m=l[h++].seq}n[a]=u;let d=l.filter(h=>h.seq>m),f=d.filter(h=>h.by!==t);if(f.length===0)continue;let p=f.flatMap(h=>/^note .* id=(n\d+)$/.exec(h.cmd)?.slice(1)??[]);s.push({asset:a,from:m,to:u,lines:f,own:d.length-f.length,notes:c.notes,newNotes:p,before:m>0?this.docAt(a,m):null,after:c})}return LO(this.project,o),s}freshStyle(){let t=EN(this.project.dir,"project.json"),r;try{let n=uH(t);r=`${n.mtimeMs}:${n.size}`}catch{return}if(r===this.styleStamp)return;let o=this.styleStamp==="";this.styleStamp=r;try{let n=JSON.parse(lH(t,"utf8")),i=JSON.stringify([n.style,n.themes])!==JSON.stringify([this.project.json.style,this.project.json.themes]);this.project.json.style=n.style??{},this.project.json.themes=n.themes,i&&!o&&this.emit({type:"style",style:this.project.json.style,themes:this.themes()})}catch{this.styleStamp=""}}assetDocs(){return this.assets().flatMap(t=>{try{let{doc:r,entries:o}=this.state(t);return r?[{name:t,doc:r,forkOf:sb(o)?.from??null}]:[]}catch{return[]}})}themes(){return KA(this.project.json.themes)}themeNamed(t){let r=this.themes().find(o=>o.name===t);if(!r)throw new ee(`no theme '${t}' (themes: ${this.themes().map(o=>o.name).join(", ")})`);return r}checks(t,r={},o){this.freshStyle();let n=o??this.doc(t);if(r.frame!==void 0&&(r.frame<0||r.frame>=n.frameCount))throw new ee(`frame ${r.frame+1} does not exist (frames 1..${n.frameCount})`);let i=Jt(this.project).manifest,s=bn(i,t),a=s?s.set??s.kind:null,c=s&&i?{peers:i.assets.filter(S=>(S.set??S.kind)===a&&S.name!==t).map(S=>S.name),...s.height!==void 0?{expect:{height:s.height}}:{},...a&&this.project.json.style?.sets?.[a]?.checks?{setChecks:this.project.json.style.sets[a].checks}:{}}:{},l=this.assetDocs(),u=o?[...l.filter(S=>S.name!==t),{name:t,doc:o,forkOf:l.find(S=>S.name===t)?.forkOf??null}]:l,{ctx:m,problems:d}=YA(t,n,u,this.project.json.style,S=>this.project.palettes.get(S),{...r,...c}),f=!o&&!r.checks&&r.frame===void 0&&r.budget===void 0&&r.ground===void 0&&r.ref===void 0&&r.set===void 0,p=S=>`${S}:${this.versions.get(S)??0}`,h=m.world?u.map(S=>S.name):[t,...m.ground?[m.ground.name]:[],...(m.set??[]).map(S=>S.name),...(m.peers??[]).map(S=>S.name)],g=f?JSON.stringify([this.project.json.style,i,h.map(p),u.length,[...this.project.palettes.keys()]]):"",b=f?this.checkMemo.get(t):void 0;if(b&&b.key===g)return b.out;let y=f&&this.checkCache&&h.every(S=>this.keys.has(S))?IN([this.project.json.style,i,[...new Set(h)].sort().map(S=>[S,this.keys.get(S)]),u.map(S=>S.name),[...this.project.palettes.values()].map(po),d]):null,w=y?PN(this.project,t,y):null;if(w)return this.checkMemo.set(t,{key:g,out:w}),w;let v={results:jC(n,r.checks??jn,{...m,budget:r.budget,focus:r.focus}),problems:d};return f&&this.checkMemo.set(t,{key:g,out:v}),y&&jN(this.project,t,y,v),v}view(t,r,o={},n,i){let s=n??EN(this.project.dir,"views");this.freshStyle();let a=this.doc(t),c=this.project.json.style,l={scale:o.scale,region:o.region,since:o.since,frame:o.frame,tickRate:this.project.json.tickRate??60};if(r==="render"&&a.layers.some(d=>d.underlay)&&(l.underlay=nC(a,d=>R1(this.project,d))),o.theme&&(l.theme=this.themeNamed(o.theme)),o.marks){let d=o.marks==="failing"?void 0:o.marks,f=this.checks(t,{checks:d}).results,p=new Set,h=[];for(let g of f)if(!(o.marks==="failing"&&g.status!=="fail"))for(let b of zC(g,o.frame??0))p.has(String(b))||(p.add(String(b)),h.push(b));l.marks=h}if(r==="game"){let d=this.assetDocs(),f=Ms(t,d,c,o.ground);if(o.ground&&!f)throw new ee(`no asset '${o.ground}' to use as ground`);let p=o.with?o.with.map(y=>({name:y,doc:this.doc(y)})):Nm(t,a,d,c).slice(0,7),h=o.frame??0,g=a.views.find(y=>y.from<=h&&h<=y.to),b=[h,...[...a.views].sort((y,w)=>Ur.indexOf(y.name)-Ur.indexOf(w.name)).flatMap(y=>y===g?[]:[y.from])];l.game={ground:f?.doc??null,with:p.map(y=>y.doc),scale:Ro(c,this.project.json.grid),frames:[...new Set(b)]}}if(r==="density"){let d=this.assetDocs(),f=a.densityOf?.of??t,p=d.find(g=>g.name===f)?.doc;if(!p)throw new ee(`no asset '${f}' (the base of ${t})`);let h=c?.density??{};l.density={base:p,copies:d.filter(g=>g.doc.densityOf?.of===f).map(g=>g.doc),reducer:h.reducer,ink:h.ink,share:h.share}}if(r==="map"&&a.family&&o.scale===void 0&&(l.scale=Ro(c,this.project.json.grid)),r==="diff"&&a.map&&(l.mapDoc={doc:a,world:qn(this.assetDocs()),screen:Io(c,this.project.json.grid),drawScale:Ro(c,this.project.json.grid)}),r==="map"&&(a.map||a.kind==="object"||a.footprint)){let d=this.assetDocs(),p={world:qn(d),region:o.region,camera:o.camera,screen:Io(c,this.project.json.grid),drawScale:Ro(c,this.project.json.grid)};if(a.map)l.mapDoc={doc:a,...p};else{if(o.camera)throw new ee("camera= is for a map document");l.mapDoc={...this.objectScene(t,a,d,o.ground),...p,region:void 0}}l.marks&&!a.map&&(l.marks=void 0)}else if(r==="map"){let d=(o.with??[]).map(p=>{let h=this.doc(p);if(!h.overlay)throw new ee(`'${p}' is not an overlay (with= takes overlays for the map view)`);return h}),f=null;if(a.overlay){let p=this.assetDocs().filter(g=>g.name!==t&&(g.doc.family||g.doc.wrap)),h=o.ground?p.find(g=>g.name===o.ground):p.find(g=>g.doc.family)??Ms(t,p,c,void 0)??p[0];if(!h)throw new ee(o.ground?`no family or tile '${o.ground}' to put the overlay on`:"no family or tile to put the overlay on (ground=<asset>)");f=h.doc}l.map={cols:o.size?.cols,rows:o.size?.rows,seed:o.seed,overlays:d,ground:f}}if(r==="recolour"&&(l.themes=o.themes?o.themes.map(d=>this.themeNamed(d)):this.themes().slice(0,6)),r!=="diff"||i!==void 0)return cd(a,r,l,s,i);let{entries:u}=this.state(t),m=o.since;if(m===void 0){let d=u.at(-1)?.group;m=(u.find(f=>f.group===d)?.seq??1)-1}return cd(a,r,l,s,m>0?this.docAt(t,m):null)}objectScene(t,r,o,n){let i=this.project.json.style,s=n?o.find(y=>y.name===n):Ms(t,o,i,void 0)??o.find(y=>y.doc.family);if(!s)throw new ee(n?`no asset '${n}' to use as ground`:"no ground tile or family to stand the object on (ground=<asset>)");let a=r.cellW,c=Dn(r),[l,u]=[Math.ceil(r.width/a),Math.ceil(r.height/r.cellH)],m=Math.max(7,l+4),d=Math.max(6,u+3),f=Math.floor((m-c.cols)/2)+c.anchor[0],p=d-2-(c.rows-1)+c.anchor[1],h=[`new map scene ${m}x${d} tile=${a}`];if(s.doc.family)h.push(`layer add ground terrain=${s.name} outside=on above=floor`,`terrain ground rect 0,0 ${m}x${d}`);else for(let y=0;y<d;y++)for(let w=0;w<m;w++)h.push(`place ${s.name} ${w},${y} layer=floor cells=1x1 anchor=0,0`);h.push("layer add props objects",`place ${t} ${f},${p} layer=props`);let g=qk({doc:null,entries:[]},h.join(`
399
+ `),{by:"scene",palettes:jo(this.project),assets:y=>o.find(w=>w.name===y)?.doc});if(!g.ok)throw new ee(`the scene: ${g.errors.map(y=>y.message).join("; ")}`);let b=c.flags.map(y=>y.replace(/\./g,"\xB7")).join(" / ");return{doc:g.state.doc,note:`${t} on ${s.name} at the game's scale: ${r.width}x${r.height} px, ${l}x${u} cells; footprint ${c.cols}x${c.rows} at art cell ${c.at.join(",")}, anchor ${c.anchor.join(",")} (placed at ${f},${p}); cell flags by art row (b blocks, r roof): ${b}`}}planChanged(){this.emit({type:"plan"})}showEye(t,r){r.kind==="image"&&(this.lastEye={asset:t,mode:r.mode,png:Buffer.from(r.png).toString("base64"),width:r.width,height:r.height,path:r.path,at:this.now()},this.emit({type:"eye",eye:this.lastEye}))}history(t){let{entries:r}=this.state(t.asset),o=Ns(r),n=r.filter(s=>(t.from===void 0||s.seq>=t.from)&&(t.to===void 0||s.seq<=t.to));t.last!==void 0&&(n=n.slice(Math.max(0,n.length-t.last)));let i=[...new Set(r.map(s=>s.group))];return{asset:t.asset,entries:n,total:r.length,groups:i.length,undone:i.filter(s=>!o.has(s))}}assets(){return Ii(this.project)}snapshot(){this.freshStyle();let t=this.assets().map(r=>({name:r,entries:this.states.get(r)?.entries??Bm(this.project,r)}));return{project:{name:this.project.json.name,dir:this.project.dir,tickRate:this.project.json.tickRate??60,grid:this.project.json.grid??24},palettes:[...this.project.palettes.values()],defaultPalette:this.project.json.defaultPalette,style:this.project.json.style??{},themes:this.themes(),assets:t,live:this.live,eye:this.lastEye,worker:this.workerStatus()}}};var an="claude",pH="pixelclaw",hH=`PixelClaw is a pixel art editor you drive with a small command language. All art is indexed colour (every pixel is a palette entry).
400
+
401
+ Start with the \`project\` tool: it lists palettes and assets, and gives a watch link (http://127.0.0.1:\u2026/?token=\u2026). Give the person that link so they can watch you draw live, and edit too.
402
+
403
+ Draw with \`run\` (one batch = one undo group; any error applies nothing); every result ends with a one-line check summary. \`run\` with dry=true applies to a copy, checks it and keeps nothing. \`seeds\` tries a generator line (noise, scatter, voronoi, bricks, map gen, family coverage) with N seeds and ranks them by the checks (apply=true runs the best): use it instead of guessing seeds by hand. Look with \`view\` (render: scaled PNG with grid and rulers; tile3x3: seams and repetition; grid: exact palette keys per pixel; diff: what the last group changed; game: a sprite on its ground at 1x and the draw scale beside its set; recolour: role art under preview themes; map: a family on a random island with the seam score; family: every variant among its neighbours; marks: "failing" circles flagged pixels in magenta). \`check\` gives the full table: each check's score against the style guide's threshold and the exact pixels it flags; fix them by coordinates. Read the tape with \`history\`. \`review\` writes a blind review bundle: hand its folder to a fresh agent with no context, and bring its findings back as notes on the pixels.
404
+
405
+ People edit in the watch view too. Their edits are commands on the same tape, written by human:<name>. Call \`changes\` at the start of each turn while someone is watching, and whenever they say they changed something: it returns their commands and notes since you last looked, with a before/after diff image. Carry on from what they did; never silently redo their pixels. Close a note you have dealt with: note done <id>.
406
+
407
+ Commands (one per line, or ';' between them; '#' comments). Full reference: docs/commands.md in the PixelClaw repo.
408
+ new tile|sprite|sheet|icon|object|font <name> <W>x<H> [palette=<p>] [wrap=on|off] [cell=WxH] [bg=<colour>]
409
+ px <x,y> [<x,y>...] c=<colour>
410
+ line <x,y> <x,y> [<x,y>...] c=<colour> [pp=on|off] pixel-perfect lines and polylines
411
+ curve <x,y> <ctrl> [<ctrl>] <x,y> c=<colour> quadratic or cubic Bezier, pixel-perfect
412
+ rect <x,y> <W>x<H> c=<colour> [outline|fill] ellipse <cx,cy> r=<RX>x<RY> ... polygon <x,y> <x,y> <x,y>... c= [outline|fill]
413
+ fill <x,y> c=<colour> [mode=contiguous|global] [conn=4|8]
414
+ paint <x,y> << rows of palette keys; '.' leaves a pixel, a space clears it
415
+ ..kk..
416
+ >>
417
+ stroke pencil c=<colour> [pp=on|off] <x,y> <x,y>... a freehand drag; stroke eraser <x,y>...
418
+ layer add <name> [above=|below=<layer>] [reference] | layer <name> (draw on it) | layer set <name> hidden=|locked=|reference=on|off | layer move|merge|rename|remove
419
+ frame add [<n>] [copy=<m>|link=<m>|empty] | frame <n> (draw on it, from 1) | frame remove|move | frame set <n>|<a>-<b>|all ticks=<t>
420
+ tag add <name> <a>-<b> [loop=cycle|pingpong] | view S|N|E|W frames=<a>-<b> | view W mirror=E (live mirror) | cel link|unlink <a>-<b> | pivot <x,y> | ground <y>
421
+ select rect|ellipse|lasso|wand|colour|layer|all|none|invert ... [add|sub|and]; deselect your selection clips your drawing
422
+ clear | shift <dx,dy> [wrap] | flip h|v | rotate 90|180|270 the selection, or your whole layer
423
+ mirror x=11.5 [y=..] live (later strokes mirrored) | mirror off | mirror x=11.5 from=left (copy once)
424
+ dither <x,y> <W>x<H> a= b= [pattern=checker|bayer2|bayer4|bayer8|hlines|vlines] [level=0.25]
425
+ gradient <x,y> <W>x<H> ramp=<ramp> [dir=down|up|right|left|radial] [steps=n] [pattern=none|checker|bayer4..]
426
+ ramp <name> = <darkest> ... <lightest> | palette lock|unlock | palette save as=<new palette>
427
+ outline c=<colour> [mode=outer|inner] [corners=on|off] [from=<layer>] shade light=nw [ramp=<r>|all] [edge=1] shadow [c=<colour>] [dir=se] (an ellipse under the art, away from the light) clean orphans [size=1] [keep=texture]
428
+ noise [<x,y> <W>x<H>] ramp=<r> [weights=6,2,1] [cluster=1..3] [density=0.15] [base=<c>|keep] [seed=n]
429
+ scatter [box] stamp=<s>[,<s>]|c=<colour> count=<n> [minDist=<n>] [flip=on] [seed=n]
430
+ voronoi [box] cells=<n> ramp=<r> [gap=<colour>] [relax=1] [seed=n] bricks [box] size=8x4 ramp=<r> [gap=<colour>] [seed=n]
431
+ pebbles [box] ramp=<r> [size=a..b] [density=0.3] [cast=<colour>] [edges=<seed>] [seed=n] stones: a shadow side and a lit pixel from the style's light, none overlapping, rows and columns kept even
432
+ tufts [box] ramp=<r> [size=a..b] [blades=a..b] [density=0.2] [foot=<colour>|none] [edges=<seed>] [seed=n] grass tufts lit from the style's light
433
+ looks of one ground: the same edges= and other seeds share what crosses the tile's edges, so they join any way round (variant of=, then fill mix=)
434
+ stamp save <name> <x,y> <W>x<H> (or a << block >>) | stamp <name> <x,y> [flip=h|v|hv] brush square|circle <n> | brush stamp <name> | brush off
435
+ def tuft(x,y) { px $x,$y $x+1,$y-1 c=moss2 } call tuft 5,18
436
+ palette set <entry> hex=#rrggbb [role=<r>|none] | palette add [<name>] hex=#rrggbb|role=<r> [key=<k>] this asset's palette; roles black|white|light|dark|darkest for recolourable art
437
+ note <x,y> [<W>x<H>] "text" | note done <id>
438
+ undo [group=<g>] [by=<author>] | redo [group=<undo group>]
439
+ fork <from> <to> [at=<n>] (as the first command of a run on a new asset: a branch of <from>)
440
+ Underlays (an image under the art, never exported) and snap:
441
+ underlay generate "<prompt>" [layout=templates/mockup.png|<layer>] [image=1536x1024] [provider=openai|fake] [model=] [quality=low|medium|high] [cap=<usd>] [layer=mockup]
442
+ calls the image provider (the key is the server's OPENAI_API_KEY; a cost cap per call, logged in logs/underlay-costs.jsonl); the tape gets underlay <layer> blob=<sha256> \u2026
443
+ underlay import <file.png> [layout=<template.png|layer>] [layer=underlay] [at=x,y] [size=WxH] any image (a sketch, a photo of a drawing) as an underlay
444
+ snap [from=<underlay layer>] [into=draft] [fit=placement|free] fits the image's pixel grid (by default the placement's: one block per placed pixel) and quantises it to the palette on a new draft layer; reports block R\xB2 and the material match against the layout (below 0.8 / 0.85: reroll)
445
+ import <x,y> asset=<name> region=<x,y,WxH> [layer=<layer>] copy a region of another asset (cut a tile from a snapped scene)
446
+ Fonts and icons:
447
+ new font <name> <W>x<H> chars="ABC\u2026"|32-126 [cols=16] [baseline=<row>] [line=<px>] [spacing=1] a glyph sheet: one W x H cell per character
448
+ glyph A [advance=<n>|auto] << rows >> (letters and digits as themselves; other characters as U+0021 or "!") font set baseline= line= spacing=
449
+ icon mode=tone|full|channel how an icon is exported (tone: roles recoloured by the game; full: as drawn; channel: pure-RGB masks)
450
+ Autotile families (a sheet of every variant of a scheme: blob47, blob47-round, wang16-corner, path, bridge8, single, face, lane):
451
+ new family <name> <T>x<T> scheme=<scheme> [map=<C>x<R>] layers ground (the textures, laid by the band) and band (the band's art)
452
+ family texture inside|outside from=<tile asset> [frame=<n>] copy a seamless tile into the inside or outside texture
453
+ family band <w>:<colour|outside|inside>... [radius=<r>] [inset=<n>] [jitter=<n> [seed=]] [draw=on|off] the band from the edge in (3:outside 1:foam 2:sand1); draws it on the pieces; jitter: edges wobble up to n px (try seeds with the seeds tool)
454
+ family band from=<family> copy another family's band (variant of=<base> band=inherit does this after every change to the base: a texture variant that follows later fixes)
455
+ layer band ; paint @cell(o) 0,0 << ... >> hand-detail a piece (cells by name: @cell(inside), @cell(nesw)); every other variant is built from the pieces' quadrants, live
456
+ face scheme (cliffs): south faces below the terrain (face_o, face_ew, face_ie_iw: ends, middle, inner corners), side faces beside it (side_e, side_e_ns, side_w, side_w_ns), corner_ew; draw them on the band layer; face_ew_b/_c, side_*_ns_b are other looks of the middles (family detach face_ew_b, then draw it)
457
+ lane scheme: a path that fills where it is wide (a plain middle) and turns diagonally (a cell joined across a corner draws a strip to it)
458
+ family detach|attach <variant>|all draw a variant by hand instead | family coverage [seed=] [copies=] [fill=on] (a coverage map to paint) | family cut [textures=on]
459
+ new overlay <name> <W>x<H> ; overlay set mode=cycle|pingpong|wave|sparkle on=outside|inside|all [anchor=x,y] [spread=4x2] [every=3] sub-tile sprites over a map (view map with=)
460
+ Oversized tiles and objects (48x48, 24x48, \u2026; cell= the grid): new object house 48x48 cell=24x24 ; footprint 2x1 [at=<cx,cy>] [anchor=<x,y>] << a row per art cell row: . b (blocks) r (roof, drawn above actors) x (both) >>
461
+ variant of=<asset> [band=inherit] this asset is a texture variant of another (fork it, change the inside, keep the border): maps pick among them cell by cell; band=inherit (families): the band stays the base's, now and after later fixes
462
+ Maps (cells of tile px holding names; a map redraws itself when a tile changes):
463
+ new map <name> <C>x<R> tile=24 layer add <name> terrain=<family> [outside=on] [walkable=on] | tiles | objects [shadow=darker|<colour>|off] (objects cast shadows on the ground; default the style guide's style.shadow) | overlay=<overlay> on=<terrain layer>[:out]|all (walkable: objects may stand on its filled ground; layer set <layer> walkable=on|off)
464
+ tiles <tiles layer> fill <tile> [<x,y> <W>x<H>] [replace] a one-cell tile on every empty cell (the floor in one line)
465
+ tiles <tiles layer> fill mix=<tile>:<weight>,... [box] [variants=named] a seeded scatter of several tiles by weight, no two equal neighbours where it can help it (two tiles: no 2x2 block of one; a tile's weight is shared with its variants the mix does not name)
466
+ terrain <layer> rect <x,y> <W>x<H> | ellipse \u2026 | brush <x,y>... [size=n] | fill <x,y> | paint <x,y> << # terrain, - not, . leave >> | clear [erase] the scheme picks the edge tiles
467
+ place <asset>|<family>.<variant> <x,y> [layer=] by its anchor cell; footprints may not overlap | move <x,y> <x,y> | remove <x,y>
468
+ road <terrain layer> <x,y> <x,y>... [width=n] | scatter <asset>[,<asset>] count=<n> [on=<terrain layer>] [minDist=n] [layer=] [seed=] | map gen island|village|dungeon [layers=a,b,c] [seed=]
469
+ view map: the whole map at 1x; region="x,y WxH" (cells) or camera="x,y" (the engine's screen around a cell) at game scale; marks="failing" outlines hot spots. export: tmx (Tiled), split (one-cell pieces + stamp), png.
470
+ Colours: an entry name (c=stone3), its key (c=3), its exact hex, or none. Coordinates wrap on wrap=on documents (tiles by default). @cell(cx,cy) after a command name offsets it to a cell of the cell grid. Generators write their seed into the tape line; give seed= to choose one (another seed is another variant). Your layer, frame, selection, symmetry and brush are yours alone: people in the watch view have their own.
471
+
472
+ The project pipeline: \`plan\` shows the asset plan (manifest.json) and each asset's status (planned \u2192 drafted \u2192 checked \u2192 reviewed \u2192 approved \u2192 exported) by set; plan(manifest=\u2026) writes a manifest (schema-checked), plan(templates=true) draws a flat mockup screen and coverage maps. A planned asset's \`new\` may leave out its size, palette and scheme. After a blind review's findings are dealt with: mark reviewed "\u2026". A person approves in the dashboard (the watch link with &tab=dashboard), writing mark approved, or asks for changes (mark rejected "\u2026"): read it with \`changes\`. The consistency check holds each asset to its set and to its planned height. docs/pipeline.md.
473
+
474
+ Requests: people ask for work in the dashboard (Draw this, Ask for changes, Add an asset); \`plan\` lists open requests first. Take them before planned work: \`work\` claims the next open request and says what is asked; post progress with work(action="progress", text=\u2026); finish with work(action="done", text=<what changed>) (refused while the asset fails a check) or, when you need the person, work(action="blocked", text=<one clear question>). Call \`plan\` at the start of a session and after each finished asset. \`request\` files work the same way (draw, change, add; reply, cancel), e.g. to plan a set and leave the drawing to the worker.
475
+
476
+ Habits: after each meaningful batch, look once at an image (render or tile3x3), and use the grid to check exact pixels. Never judge a tile alone when it will be seen tiled; judge a sprite in the game view, on its ground. Keep the checks green, but do not stop at green: look at the 3x3 or the game view and judge it as a player would.
477
+
478
+ Map checks: seam (over the composed ground), repetition (hot spots: the same edge tile in a long straight run, one textured tile filling a 4x4 window; fix with texture variants), lattice (a mark at the same spot of the cell in too many cells of one ground, variants included: a grid of dots at map scale; fix with variants that move or drop it, filled as a mix), footprint (overlaps, off the map, standing on an edge or the outside ground), draworder (overhangs not marked roof, roofs hiding what stands in front), coverage (missing assets or undrawn variants). Assets: fit (footprint cells drawn, overhangs are roofs), variant (colour mix against the base).
479
+
480
+ Checks: palette (colours in the style palettes; role art uses only roles; style.reserved colours only on their assets), orphans (stray pixels per 100), jaggies (doubled L-corners, irregular step runs, spikes, notches on outlines and one-colour lines; steps between neighbouring entries of one ramp are shading), banding (pillow shading), outline (share of the silhouette edge in ink), seam (tiles: the border vs the interior; families: over a random island map, a cliff's faces as the ground under them; about 1 or less reads as no seam), coverage (sizes, empty frames or cells; families: every variant and texture drawn), readability (edge contrast against the ground in \u0394L*, silhouette distinct from the set, lightness spread), revert (share copied from a reference: ref=), repetition (tiles: the most visible stripe when tiled, \u0394L*\xB7\u221Awidth), consistency (against the set; icons: stroke weight, box fill, optical centre), font (cap height, x-height, baseline, advances, line height), margin (sprites: art on the top or side edges of its cell), pieces (sprites and objects: parts apart from the rest). Thresholds come from project.json style.checks.`,et=e=>({type:"text",text:e}),jr=e=>({content:[et(e)],isError:!0});function Ln(e){if(e instanceof ee||e instanceof SyntaxError)return jr(`error: ${e.message}`);throw e}function A1(e,t=""){let[r,...o]=e.cmd.split(`
481
+ `);return[`#${e.seq} ${e.by} ${e.group} ${r}${t}`,...o.map(n=>` ${n}`)].join(`
482
+ `)}function dd(e){return e.kind==="text"?[et(e.text),et(`saved ${e.path}`)]:[...e.text?[et(e.text)]:[],{type:"image",data:Buffer.from(e.png).toString("base64"),mimeType:"image/png"},et(`${e.mode}: ${e.width}x${e.height} px, saved ${e.path}`)]}function gH(e,t){let r=e.project,o=r.json.grid??24,n=[`project '${r.json.name}' at ${r.dir}`,`grid ${o} px (new maps' tile; camera ${Io(r.json.style,o).join("x")}; draw scale ${Ro(r.json.style,o)}x)`,`watch live: ${t} (give this link to the person watching)`,""];r.palettes.size===0&&n.push('palettes: none yet. Add one with project(palettes: ["/path/to/palette.json|.hex|.gpl"]).');for(let a of r.palettes.values()){n.push(`palette ${a.name}${a.name===r.json.defaultPalette?" (default)":""}: ${a.entries.length} colours`),n.push(" "+a.entries.map(l=>`${l.key}=${l.name}`).join(" "));let c=Object.entries(a.ramps);c.length&&n.push(" ramps: "+c.map(([l,u])=>`${l} [${u.join(" ")}]`).join("; "))}n.push(`autotile schemes: ${[...yo.values()].map(a=>`${a.name} (${a.variants.length})`).join(", ")}`);let i=Qm(r.dir);i.size&&n.push(`project schemes (copied into a family's tape): ${[...i.values()].map(a=>`${a.name} (${a.variants.length})`).join(", ")}`);try{n.push(`export profiles: ${[...ed(r).values()].map(a=>`${a.name} (${a.layout})`).join(", ")}`)}catch(a){n.push(`export profiles: ${a.message}`)}let s=Ii(r);n.push("",s.length?`assets (${s.length}):`:`assets: none yet. Create one with run(asset, "new tile <name> ${o}x${o} ...").`);for(let a of s)try{let{doc:c,entries:l}=e.state(a),u=new Set(l.map(f=>f.group)).size,m=c?.notes.length?`; open notes: ${c.notes.map(f=>f.id).join(", ")}`:"",d=c?[c.layers.length>1?`layers ${c.layers.map(f=>f.name+(f.reference?" (ref)":"")+(f.hidden?" (hidden)":"")+(f.locked?" (locked)":"")).join(", ")}`:"",c.frameCount>1?`${c.frameCount} frames`:"",c.paletteLocked?"palette locked":"",Object.keys(c.stamps).length?`stamps ${Object.keys(c.stamps).sort().join(", ")}`:"",Object.keys(c.macros).length?`macros ${Object.keys(c.macros).sort().join(", ")}`:"",c.family?`family ${c.family.scheme} of ${c.family.tile}px tiles`:"",c.overlay?`overlay (${c.overlay.mode} on ${c.overlay.on})`:""].filter(Boolean).map(f=>`; ${f}`).join(""):"";n.push(` ${a}: ${c?`${c.kind} ${c.width}x${c.height}${c.wrap?" wrap":""}${c.cellW<c.width||c.cellH<c.height?` cell ${c.cellW}x${c.cellH}`:""}, palette ${c.palette.name}, `:""}${l.length} commands in ${u} groups${d}${m}`)}catch(c){n.push(` ${a}: cannot load: ${c.message}`)}return n.join(`
483
+ `)}function yH(e,t=!1){let r=e.w===1&&e.h===1?`${e.x},${e.y}`:`${e.x},${e.y} ${e.w}x${e.h}`;return` ${e.id} at ${r}: ${JSON.stringify(e.text)}${t?" (new)":""}`}function ON(e){let t=new Map;for(let i of e.lines)t.set(i.by,(t.get(i.by)??0)+1);let r=[...t].map(([i,s])=>`${s} by ${i}`).join(", "),o=[`${e.asset}: ${e.lines.length} command${e.lines.length===1?"":"s"} (${r}) ${e.from>0?`since #${e.from}`:"on a tape you have not read yet"}; now at #${e.to}`];o.push(...e.lines.map(i=>A1(i))),e.own&&o.push(`(${e.own} of your own command${e.own===1?"":"s"} in the same range are not listed; the diff includes them)`);let n=new Set(e.newNotes);return o.push(e.notes.length?`open notes (${e.notes.length}):`:"open notes: none"),o.push(...e.notes.map(i=>yH(i,n.has(i.id)))),o.push(`diff ${e.from>0?`#${e.from}`:"(nothing)"} \u2192 #${e.to}: ${Ry(e.before,e.after,vm(e.before,e.after))}`),o.join(`
484
+ `)}function O1(e,t,r={}){let o=e.writer,n=(s,a)=>{r.confined&&Hm(o.project,s,a)},i=new li({name:pH,version:t},{capabilities:{tools:{}},instructions:hH});return i.registerTool("project",{title:"Project",description:"Show the open project: its palettes (keys and names), its assets, and the live watch link for the person. With path, open another project folder (create: true makes a new one). With palettes, add palette files (.json, Lospec .json, .hex, .gpl) to the project. With grid, set the project's tile size in px (48 for a 48 px game).",inputSchema:ce.object({path:ce.string().optional().describe("A project folder to open (conventionally named *.pclaw)"),create:ce.boolean().optional().describe("Create the project at path if it does not exist"),name:ce.string().optional().describe("The new project's name (with create)"),palettes:ce.array(ce.string()).optional().describe("Palette files to add to the project"),grid:ce.number().int().min(4).max(256).optional().describe("The project's grid: its tile size in px (default 24). New maps, the camera (16x9 cells) and the draw scale (2 below 48 px, 1 from 48) follow it")})},s=>o.enqueue(()=>{try{if(s.path&&r.confined)throw new ee("the worker stays in its project: it cannot open another");s.path&&e.open(s.path,{create:s.create??!1,name:s.name}),s.grid!==void 0&&o.setGrid(s.grid);for(let a of s.palettes??[])n(a,"palettes");return s.palettes?.length&&o.addPalettes(s.palettes.map(ab)),{content:[et(gH(o,e.url()))]}}catch(a){return Ln(a)}})),i.registerTool("run",{title:"Run commands",description:"Apply command text to an asset as one undo group. Returns the commands as written to the tape (normal form), the pixels changed, warnings, and an optional view. Any parse or semantic error is reported with its line and column, and nothing is applied. To create an asset, start the commands with `new <kind> <name> <W>x<H> ...`. The person watching sees each command play on the canvas.",inputSchema:ce.object({asset:ce.string().describe("The asset to draw on (or to create, with a leading `new` command)"),commands:ce.string().describe("One or more lines of the command language"),view:ce.enum(Gs).optional().describe("Also return this view of the result"),replace:ce.boolean().optional().describe("With a leading `new` for an existing asset: start its tape again"),dry:ce.boolean().optional().describe("Apply to a copy, check it and report, then discard: nothing is written to the tape (try a change before keeping it)")})},s=>o.enqueue(async()=>{try{if(s.dry){if(Ti(s.commands))return jr("error: a dry run cannot call the image provider (underlay generate/import); run it for real");let u=o.dry({asset:s.asset,commands:s.commands,by:an,replace:s.replace});if(!u.ok)return jr(u.errors.map(f=>`${f.line}:${f.col}: error: ${f.message}`).join(`
485
+ `)+`
486
+ ${u.errors.length} error${u.errors.length===1?"":"s"}; nothing was applied.`);let m=[`${u.asset}: dry run of ${u.added.length} command${u.added.length===1?"":"s"}; ${u.changed} px would change; nothing was kept`];m.push(...u.added.map(f=>` ${f.cmd.split(`
487
+ `)[0]}`)),m.push(u.warnings.length?`warnings: ${u.warnings.join("; ")}`:"warnings: none"),u.doc&&m.push(xi(u.results));let d=[et(m.join(`
488
+ `))];return s.view&&u.doc&&!["render","grid","tile3x3"].includes(s.view)?jr(`error: a dry run shows render, grid or tile3x3 (not ${s.view})`):(s.view&&u.doc&&d.push(...dd(cd(u.doc,s.view,{frame:Me(u.doc,an).frame,tickRate:o.project.json.tickRate??60},AN(o.project.dir,"views","dry")))),{content:d})}let a=await o.runAsync({asset:s.asset,commands:s.commands,by:an,replace:s.replace},{},{confined:r.confined});if(!a.ok)return jr(a.errors.map(u=>`${u.line}:${u.col}: error: ${u.message}`).join(`
489
+ `)+`
490
+ ${a.errors.length} error${a.errors.length===1?"":"s"}; nothing was applied.`);let c=[];a.added.length===0?c.push(`${a.asset}: no commands`):(c.push(`${a.asset}: applied ${a.added.length} command${a.added.length===1?"":"s"} as group ${a.group}; ${a.changed} px changed`),c.push(...a.added.map(u=>A1(u))),c.push(`tape: ${a.commands} commands in ${a.groups} groups`)),c.push(a.warnings.length?`warnings: ${a.warnings.join("; ")}`:"warnings: none"),a.followed?.length&&c.push(`brought up to date: ${a.followed.join(", ")} (variants that inherit the band, families whose textures came from=${a.asset})`),a.doc&&c.push(xi(o.checks(a.asset,{budget:md,focus:Me(a.doc,an).frame}).results));let l=[et(c.join(`
491
+ `))];if(s.view&&a.doc){let u=o.view(a.asset,s.view,{frame:Me(a.doc,an).frame});o.showEye(a.asset,u),l.push(...dd(u))}return{content:l}}catch(a){return Ln(a)}})),i.registerTool("view",{title:"View an asset",description:`Look at an asset. render: a scaled PNG (about 192 px, faint pixel grid, rulers every 8 px). tile3x3: the asset repeated 3x3 at 1x and 4x, for seams and repetition. grid: text, one palette key per pixel, with coordinates and a legend. diff: before and after the latest group (or since a command number) with changed pixels outlined in magenta and notes in yellow, plus the changed pixels as text (up to 60; per frame on animated assets). game: the asset on its ground tile at 1x and at the engine's draw scale, beside its other directions (views) and the rest of its set. recolour: role art under several preview themes. anim: a contact sheet of every sequence (tags, views): each frame with its ticks, the frame before it as a tinted onion skin, the pivot and ground line, and the share of pixels changed from the frame before; plus an animated GIF at the game's speed saved for the person, and the numbers as text. map: a sample map built with a family's autotile scheme (a random island; size and seed choose another), at the game's draw scale, with the seam score over it and the variants it used; overlays given in with= play over it (a GIF when anything moves). family: every variant of a family in the middle of the 3x3 map that resolves to it, plus where each cell is on the sheet (for @cell(<name>)). map of a map document: the whole map at 1x (its layers and placements as text), a region of cells or the camera (the engine's screen around a cell) at the game's draw scale; marks="failing" outlines the cells the map checks flag. map of an object: it stands on its ground among plain tiles at game scale, with its footprint in words. marks="failing" circles every pixel a failing check flags. Images come back inline and are also saved as files; the person watching sees the last image you were shown.`,annotations:{readOnlyHint:!0},inputSchema:ce.object({asset:ce.string(),mode:ce.enum(Gs).default("render"),scale:ce.number().int().min(1).max(64).optional().describe("render: pixels per pixel; tile3x3: the enlarged copy's scale (default 4); map, diff, family, anim, recolour, density: their scale"),region:ce.string().optional().describe('render, grid: part of the canvas, "x,y WxH" (e.g. "8,0 12x10"; "8,0,12x10" works too); map of a map document: a region of cells'),camera:ce.string().regex(/^\d+,\d+$/).optional().describe(`map of a map document: the camera's view around this cell, "x,y" (the screen size is project.json style.camera, default 16x9 cells of the project's grid: 384x216 at 24 px)`),since:ce.number().int().min(0).optional().describe("diff only: compare with the document after this command number (default: before the latest group)"),frame:ce.number().int().min(1).optional().describe("render, grid, tile3x3, game, recolour: the frame to show (default: the frame you are drawing on)"),marks:ce.string().optional().describe('render, tile3x3, game: circle the pixels checks flag in magenta: "failing", or check names ("orphans,jaggies")'),theme:ce.string().optional().describe("render, tile3x3, game: show role entries under this preview theme"),themes:ce.array(ce.string()).optional().describe("recolour: the themes to show (default: the first six)"),ground:ce.string().optional().describe("game: the ground tile (default: the style guide's, else the first tile)"),with:ce.array(ce.string()).optional().describe("game: the assets shown beside this one (default: its set: same kind and size). map: overlays to play over the map"),size:ce.string().optional().describe(`map: the map's size in tiles, "16x12" (default 12x10)`),seed:ce.number().int().min(1).optional().describe("map: the random island's seed (default 1)")})},s=>o.enqueue(()=>{try{let a=s.region?Rb(s.region):void 0;if(a===null)return jr('error: region must look like "8,0 12x10" (or "8,0,12x10")');let c=s.frame!==void 0?s.frame-1:Me(o.doc(s.asset),an).frame,l=wH(s.marks);if(l===null)return jr(`error: marks must be "failing" or check names (${jn.join(", ")})`);let u=s.size?/^(\d+)x(\d+)$/.exec(s.size):null;if(s.size&&(!u||Number(u[1])<1||Number(u[2])<1||Number(u[1])>128||Number(u[2])>128))return jr('error: size must look like "16x12" (tiles, up to 128 each way)');let m=u?{cols:Number(u[1]),rows:Number(u[2])}:void 0,d=s.camera?s.camera.split(",").map(Number):void 0,f=o.view(s.asset,s.mode,{scale:s.scale,region:a,since:s.since,frame:c,marks:l,theme:s.theme,themes:s.themes,ground:s.ground,with:s.with,size:m,seed:s.seed,camera:d});return o.showEye(s.asset,f),{content:dd(f)}}catch(a){return Ln(a)}})),i.registerTool("seeds",{title:"Try seeds",description:"Try a generator line (noise, scatter, voronoi, bricks, pebbles, tufts, map gen, family coverage, \u2026) with several seeds, each as a dry run on the asset, and rank them by the checks: fewest failing first, then the least over their limits, then the most room on the rest. Nothing is kept unless apply is true (then the best seed is run as one undo group).",inputSchema:ce.object({asset:ce.string(),line:ce.string().describe("One generator command; any seed= in it is replaced"),before:ce.string().optional().describe("Commands run first in the same batch (a selection, a clear)"),count:ce.number().int().min(1).max(64).optional().describe("How many seeds (default 8)"),from:ce.number().int().min(1).optional().describe("The first seed (default 1); seeds from..from+count-1"),seeds:ce.array(ce.number().int().min(1)).max(64).optional().describe("These seeds instead"),checks:ce.array(ce.enum(jn)).optional().describe("Rank by these checks only (default all)"),apply:ce.boolean().optional().describe("Run the best seed for real"),view:ce.enum(Gs).optional().describe("With apply: also return this view of the result")})},s=>o.enqueue(()=>{try{let a=o.seeds({asset:s.asset,line:s.line,before:s.before,by:an,count:s.count,from:s.from,seeds:s.seeds,checks:s.checks});if(!a.ok)return jr(a.errors.map(u=>`${u.line}:${u.col}: error: ${u.message}`).join(`
492
+ `));let c=[kb(s.asset,a.trials)],l=[];if(s.apply&&a.trials[0]){let u=a.trials[0],m=o.run({asset:s.asset,commands:s.before?`${s.before}
493
+ ${u.line}`:u.line,by:an});if(!m.ok)return jr(m.errors.map(d=>`${d.line}:${d.col}: error: ${d.message}`).join(`
494
+ `));if(c.push("",`applied seed ${u.seed} as group ${m.group}; ${m.changed} px changed`),m.doc&&c.push(xi(o.checks(s.asset,{budget:md}).results)),l.push(et(c.join(`
495
+ `))),s.view&&m.doc){let d=o.view(s.asset,s.view,{frame:Me(m.doc,an).frame});o.showEye(s.asset,d),l.push(...dd(d))}return{content:l}}return c.push("",a.trials[0]?`nothing was kept; run the best: ${a.trials[0].line} (or seeds apply=true)`:"no seeds tried"),{content:[et(c.join(`
496
+ `))]}}catch(a){return Ln(a)}})),i.registerTool("history",{title:"Read the tape",description:"Read an asset's tape: every command in order with its number, author and undo group. Undone groups are marked. By default the last 50 commands; from/to select by command number. Undo is a command (`undo` or `undo group=g4` through run).",annotations:{readOnlyHint:!0},inputSchema:ce.object({asset:ce.string(),from:ce.number().int().optional().describe("First command number"),to:ce.number().int().optional().describe("Last command number"),last:ce.number().int().min(1).optional().describe("Only the last N commands of the selection (default 50 when from/to are not given)")})},s=>o.enqueue(()=>{try{let a=s.last??(s.from===void 0&&s.to===void 0?50:void 0),c=o.history({asset:s.asset,from:s.from,to:s.to,last:a}),l=new Set(c.undone),u=`${c.asset}: ${c.total} commands in ${c.groups} groups${c.undone.length?`; undone: ${c.undone.join(", ")}`:""}`+(c.entries.length<c.total?`; showing ${c.entries.length} (#${c.entries[0]?.seq??"-"}..#${c.entries.at(-1)?.seq??"-"})`:"");return{content:[et([u,...c.entries.map(m=>A1(m,l.has(m.group)?" (undone)":""))].join(`
497
+ `))]}}catch(a){return Ln(a)}})),i.registerTool("changes",{title:"What people changed",description:"What people did in the watch view since you last called this: their commands per asset (with author and undo group), the open notes they pinned to pixels or regions, and a diff image per asset (before / after, changed pixels outlined in magenta, notes in yellow) plus its saved path. Your read position then moves to the end, so a second call returns only what is new. Call it at the start of each turn while someone is watching.",inputSchema:ce.object({asset:ce.string().optional().describe("Only this asset (default: every asset)"),since:ce.number().int().min(0).optional().describe("Read from after this command number instead of where you last stopped")})},s=>o.enqueue(()=>{try{let a=o.changes(an,{asset:s.asset,since:s.since});if(a.length===0)return{content:[et(`No changes since you last looked${s.asset?` at ${s.asset}`:""}.`)]};let c=[et(`Changes since you last looked: ${a.length} asset${a.length===1?"":"s"} (${a.map(l=>l.asset).join(", ")}).`)];for(let l of a){let u=o.view(l.asset,"diff",{},void 0,l.before);c.push(et(l.after.map&&u.kind==="image"?ON(l).replace(/\ndiff [^\n]*$/,`
498
+ diff ${l.from>0?`#${l.from}`:"(nothing)"} \u2192 #${l.to}: ${u.text??""}`):ON(l))),o.showEye(l.asset,u),u.kind==="image"&&(c.push({type:"image",data:Buffer.from(u.png).toString("base64"),mimeType:"image/png"}),c.push(et(`diff image: ${u.width}x${u.height} px, saved ${u.path}`)))}return{content:c}}catch(a){return Ln(a)}})),i.registerTool("check",{title:"Check an asset",description:`Run the quality checks on an asset against the project's style guide: each check's score, pass or fail, and the exact pixel coordinates it flags. With one asset, also returns its render (tile3x3 for tiles) with the flagged pixels of failing checks circled in magenta. Without an asset, one line per asset. Checks: ${jn.join(", ")}.`,annotations:{readOnlyHint:!0},inputSchema:ce.object({asset:ce.string().optional().describe("The asset to check (default: every asset, one summary line each)"),checks:ce.array(ce.enum(jn)).optional().describe("Only these checks (default: all)"),frame:ce.number().int().min(1).optional().describe("Only this frame (default: every frame; flagged pixels name their frame)"),ground:ce.string().optional().describe("readability: the ground tile (default: the style guide's, else the first tile)"),ref:ce.string().optional().describe("revert: the reference asset the art must not simply copy"),set:ce.array(ce.string()).optional().describe("readability: the assets its silhouette must differ from (default: same kind and size)"),image:ce.boolean().optional().describe("Return the image with the flagged pixels (default: true when something fails)")})},s=>o.enqueue(()=>{try{if(!s.asset){let d=o.assets().map(f=>{try{return`${f}: ${xi(o.checks(f,{checks:s.checks}).results).replace(/^checks: /,"")}`}catch(p){return`${f}: cannot check: ${p.message}`}});return{content:[et(d.length?d.join(`
499
+ `):"no assets yet")]}}let a=s.frame!==void 0?s.frame-1:void 0,{results:c,problems:l}=o.checks(s.asset,{checks:s.checks,frame:a,ground:s.ground,ref:s.ref,set:s.set}),u=[et(Sb(s.asset,c,l,o.doc(s.asset).frameCount>1?a:void 0))],m=c.filter(d=>d.status==="fail").map(d=>d.id);if(s.image??m.length>0){let d=a??c.find(p=>p.status==="fail")?.frame??Me(o.doc(s.asset),an).frame,f=o.view(s.asset,o.doc(s.asset).wrap?"tile3x3":"render",{frame:d,marks:m.length?m:void 0});o.showEye(s.asset,f),u.push(...dd(f))}return{content:u}}catch(a){return Ln(a)}})),i.registerTool("export",{title:"Export through a profile",description:"Write assets out through an export profile: built-in png (loose PNGs), atlas (a page plus JSON records), tiled (.tsx wang sets per family, .tmx per map), godot (a TileSet with terrains per family), aseprite-json (Aseprite sheets), aseprite (.aseprite files), or the project's own (profiles/*.json: naming templates, numbered sets, density pages, role colours, CSV, snippets; docs/profiles.md). Without assets, every asset; a map brings what it draws, an asset its texture variants and density copies. format=split|png|strip|bmfont instead writes one asset on its own (one-cell pieces plus a stamp, a PNG, or a font as a glyph strip or BMFont).",inputSchema:ce.object({profile:ce.string().optional().describe("A profile name (see project) or a profile .json path (default png)"),assets:ce.array(ce.string()).optional().describe("The assets to export (default: all)"),asset:ce.string().optional().describe("With format: the asset"),format:ce.enum(Km).optional(),dest:ce.string().optional().describe("The folder to write into, e.g. a game folder (default: <project>/exports/<profile>)")})},s=>o.enqueue(()=>{try{if(s.dest&&n(s.dest,"dest"),s.profile?.endsWith(".json")&&n(s.profile,"profile"),s.format){if(!s.asset)throw new ee("format= exports one asset: give asset");let l=mb(o.doc(s.asset),o.assetDocs(),s.format,s.dest??AN(o.project.dir,"exports",s.format));return{content:[et(`${s.format}: wrote ${l.length} files
500
+ ${l.map(u=>` ${u}`).join(`
501
+ `)}`)]}}let a=pb(o.project,o.assetDocs(),s.profile??"png",{names:s.assets??(s.asset?[s.asset]:void 0),dest:s.dest,at:o.stamp()});o.planChanged();let c=a.files.length>24?[...a.files.slice(0,24),`\u2026 ${a.files.length-24} more`]:a.files;return{content:[et(`${s.profile??"png"}: ${a.images} images, wrote ${a.files.length} files into ${a.dir}
502
+ ${c.map(l=>` ${l}`).join(`
503
+ `)}${a.notes.length?`
504
+ notes:
505
+ ${a.notes.map(l=>` ${l}`).join(`
506
+ `)}`:""}`)]}}catch(a){return Ln(a)}})),i.registerTool("import",{title:"Import images",description:`Bring art in. A PNG becomes a new asset quantised to a palette (palette=, default the project's; build=true makes one from the image); grid="24x24" slices a sheet into frames (cells=true keeps it one image with that cell grid); slice="24x24" instead cuts a sheet into separate assets, one per non-empty cell (offset="x,y", gap="x,y"), named by pattern ("{name}_{n}", "{name}_{col}_{row}"), names (a list, in reading order), or namesFrom="manifest" (the planned, undrawn entries of set=, in order). A folder (without profile) imports every .png and .aseprite in it. An .aseprite file keeps its layers, frames, durations, tags and views. New assets the manifest does not plan get entries (in set=; manifest=false leaves the manifest alone), and every check is run on each. With profile=, path is a folder a profile wrote: each image is read back by name into the asset it came from and the result says which match the project exactly; images no asset exports become new assets. The new tapes start with import commands; the files are kept under blobs/.`,inputSchema:ce.object({path:ce.string().describe("A .png or .aseprite file, a folder of them, or (with profile) the folder an export wrote"),profile:ce.string().optional(),as:ce.string().regex(/^[a-z][a-z0-9_-]*$/).optional().describe("The new asset's name (one file; default: the file's)"),kind:ce.enum(["sprite","tile","object","icon","sheet"]).optional(),palette:ce.string().optional(),build:ce.boolean().optional(),grid:ce.string().regex(/^\d+x\d+$/).optional(),cells:ce.boolean().optional(),slice:ce.string().regex(/^\d+x\d+$/).optional().describe("Cut the sheet into assets of this cell size"),offset:ce.string().regex(/^\d+,\d+$/).optional(),gap:ce.string().regex(/^\d+,\d+$/).optional(),pattern:ce.string().optional(),names:ce.array(ce.string().regex(/^[a-z][a-z0-9_-]*$/)).optional(),namesFrom:ce.enum(["manifest"]).optional(),set:ce.string().optional().describe("The manifest set for new entries (and for namesFrom)"),wrap:ce.boolean().optional().describe("Tiles: on a wrapping canvas"),manifest:ce.boolean().optional().describe("Add manifest entries for the new assets (default: when there is a manifest)"),replace:ce.boolean().optional().describe("Start an existing asset's tape again")})},s=>o.enqueue(()=>{try{let a=(u,m)=>u?u.split(m).map(Number):void 0;if(n(s.path,"path"),!s.profile){let u=Oc(o,{...s,grid:a(s.grid,"x"),slice:s.slice?{cell:a(s.slice,"x"),offset:a(s.offset,","),gap:a(s.gap,",")}:void 0},an);return{content:[et(u.text||"nothing to import")]}}let c=td(o.project,o.assetDocs(),{...s,grid:a(s.grid,"x"),slice:void 0}),l=[];for(let u of c.create){let m=o.run({asset:u.name,commands:u.tape,by:an,replace:s.replace});if(!m.ok)throw new ee(`${u.name}: ${m.errors.map(d=>`${d.line}:${d.col} ${d.message}`).join("; ")}`);l.push(u.name)}return{content:[et(hb(c,l)||"nothing to import")]}}catch(a){return Ln(a)}})),r.confined||i.registerTool("request",{title:"File, answer or withdraw a request",description:'Ask for work the way the dashboard does: kind "draw" a planned asset not drawn yet; "change" a drawn one (note says what; this also writes `mark rejected "<note>"` on its tape); "add" a new asset (entry: its manifest entry, validated with the whole manifest; nothing is written if it has problems). action "reply" answers a blocked request (id, text) and opens it again; "cancel" withdraws one (id, optional text). The worker (`pixelclaw work`, Start Claude) or an agent with `work` takes open requests. Returns the request as it stands.',inputSchema:ce.object({action:ce.enum(["request","reply","cancel"]).optional().describe("Default request"),kind:ce.enum(["draw","change","add"]).optional(),asset:ce.string().optional().describe("draw, change: the asset"),note:ce.string().optional().describe("change: what should change; draw, add: anything to know"),entry:ce.record(ce.string(),ce.unknown()).optional().describe('add: the manifest entry, e.g. { "name": "crate", "kind": "sprite", "size": "16x16", "set": "props", "description": "\u2026" }'),id:ce.string().regex(/^r\d+$/).optional().describe("reply, cancel: the request"),text:ce.string().optional().describe("reply: the answer; cancel: why")})},s=>o.enqueue(()=>{try{let a=Hs(o,an,nd(s));return o.requestsChanged(),{content:[et(Ei(a))]}}catch(a){return Ln(a)}})),i.registerTool("work",{title:"Work on requests",description:`The request queue: what people asked for in the dashboard (draw a planned asset, change a drawn one, a new asset). With no action (or action "next"), claim the next open request (or the one named by id) and get what is asked, with the asset's plan entry and status. action "progress" posts a short note the person sees; "done" finishes it with what changed; "blocked" stops it with one clear question for the person (they answer in the dashboard and it opens again). "list" shows every request still open, claimed or blocked. Take requests before planned work; call plan after each one.`,inputSchema:ce.object({action:ce.enum(["next","progress","done","blocked","list"]).optional(),id:ce.string().regex(/^r\d+$/).optional().describe("A request id (default: the next open one, or the one you claimed)"),text:ce.string().optional().describe("progress: a short note; done: what changed; blocked: the question")})},s=>o.enqueue(()=>{try{let a=s.action??"next";if(a==="list"){let u=Rr(sn(o.project));return{content:[et(u.length?u.map(m=>Ei(m)).join(`
507
+ `):"no open requests")]}}let c=a==="next"?g1(o,an,{action:a,id:s.id}):g1(o,an,{action:a,id:s.id,text:s.text??""});if(o.requestsChanged(),!c.request)return{content:[et(`${c.message}. Carry on with the plan (call plan for what is left).`)]};let l=c.request;if(a!=="next"){let u=Rr(sn(o.project)).filter(m=>m.state==="open").length;return{content:[et(`${c.message}${a==="progress"?"":`. ${u?`${u} open request${u===1?"":"s"} left: call work for the next.`:"No open requests left."}`}`)]}}return{content:[et(`${c.message}
508
+ ${bH(o,l)}`)]}}catch(a){return Ln(a)}})),i.registerTool("review",{title:"Write a blind review bundle",description:"Write a review bundle for a fresh-context reviewer: each asset at game scale and with rulers for coordinates, tiles repeated 3x3, sprites on their ground beside their set, autotile families on a map (size and seed choose it) and every variant among its neighbours, the palette, the style guide and a rubric (readability, cohesion, seams, style-guide fit, defects with coordinates). It names no method and no author, so the reviewer judges blind. Hand the folder to a new agent with no other context, ask it to follow rubric.md, then pin its findings on the pixels with note commands.",inputSchema:ce.object({assets:ce.array(ce.string()).optional().describe("The assets to review (default: all, or the set's)"),set:ce.string().optional().describe("A set from the manifest: its assets (drawn so far) are reviewed"),name:ce.string().regex(/^[a-z0-9][a-z0-9_-]*$/).optional().describe("A name for the set, used in the folder name (default: the set, else all)"),size:ce.string().regex(/^\d+x\d+$/).optional().describe("Families: the map's size in tiles (default 16x12)"),seed:ce.number().int().min(1).optional().describe("Families: the random island's seed (default 1)")})},s=>o.enqueue(()=>{try{let[a,c]=s.size?s.size.split("x").map(Number):[void 0,void 0],l=zb(o,{assets:s.assets,set:s.set,name:s.name,map:{cols:a,rows:c,seed:s.seed}});return{content:[et(`review bundle: ${l.dir}
509
+ ${l.files.length} files: ${l.files.join(", ")}
510
+ Give the folder to a fresh agent: "Review the art in ${l.dir} by following rubric.md in it."`)]}}catch(a){return Ln(a)}})),i.registerTool("plan",{title:"The plan: manifest and statuses",description:'The project\'s asset plan and where each asset stands: planned \u2192 drafted (exists) \u2192 checked (every check passes) \u2192 reviewed (`mark reviewed` after a blind review\'s findings are dealt with) \u2192 approved (a person, in the dashboard) \u2192 exported (through a profile, with the art as it is now). Lists what is left and what is failing, by set. manifest= writes manifest.json (checked against its schema first; nothing is written if it has problems): { "format": "pixelclaw-manifest", "version": 1, "theme": "\u2026", "sets": {\u2026}, "export": { "profile": "\u2026" }, "assets": [{ "name", "kind", "size", "set", "description", "palette", "scheme", "inside", "outside", "band", "frames", "ticks", "views", "mirror", "cells", "height", "variantOf", "recolourOf", "uses", "flat" }] } (docs/pipeline.md). A planned asset\'s `new` line may leave out its size, palette and scheme: the manifest fills them in. templates=true draws the flat templates (a mockup screen and a coverage map per family) into templates/.',inputSchema:ce.object({set:ce.string().optional().describe("Only this set"),manifest:ce.record(ce.string(),ce.unknown()).optional().describe("Write this manifest (validated)"),templates:ce.boolean().optional().describe("Draw the flat templates from the manifest"),seed:ce.number().int().min(1).optional().describe("Templates: the layout's seed (default 1)"),order:ce.enum(["set","scene"]).optional().describe("List the work by set (default) or scene by scene (what each scene still needs)")})},s=>o.enqueue(()=>{try{let a=[];if(s.manifest){let c=ji(o.project,s.manifest);if(!c.manifest)return jr(`the manifest was not written; ${c.errors.length} problem${c.errors.length===1?"":"s"}:
511
+ ${c.errors.map(l=>` ${l.path||"(top)"}: ${l.message}`).join(`
512
+ `)}`);a.push(et(`wrote manifest.json: ${c.manifest.assets.length} assets`)),o.planChanged()}if(s.templates){let c=yb(o,{seed:s.seed});a.push(et(`templates in ${c.dir}: ${c.files.join(", ")}`)),a.push({type:"image",data:CN(`${c.dir}/mockup@2x.png`).toString("base64"),mimeType:"image/png"}),a.push(et(CN(`${c.dir}/mockup.txt`,"utf8")))}return a.push(et(gb(Bs(o,{set:s.set}),{order:s.order}))),a.push(et(`the dashboard (for the person): ${e.url()}&tab=dashboard`)),{content:a}}catch(a){return Ln(a)}})),i}function bH(e,t){let r=[Ei(t)],o=bn(Jt(e.project).manifest,t.asset);o&&r.push(`plan: ${t.asset} is a ${o.kind} ${o.size}${o.set?` in set ${o.set}`:""}${o.description?`: ${o.description}`:""}${o.height?` (drawn height ${o.height} px)`:""}`);let n=Bs(e).assets.find(i=>i.name===t.asset);return n&&r.push(`status: ${n.status} \u2192 ${n.next}${n.failing.length?`; failing: ${n.failing.join(", ")}`:""}${n.flags.length?`; ${n.flags.join("; ")}`:""}`),t.kind==="draw"||t.kind==="new"?r.push(`Draw it: run with \`new ${o?.kind??"sprite"} ${t.asset}\` (the manifest fills in its size and palette), look, check, fix; then work(action="done", text=<what you drew>).`):r.push(`Change it as asked (the request is also a \`mark rejected\` on its tape${t.mark?` at #${t.mark}`:""}; \`changes\` shows the person's edits and notes); then work(action="done", text=<what changed>).`),t.events.some(i=>i.type==="reply")&&r.push(`The person answered: "${t.events.filter(i=>i.type==="reply").at(-1).text}"`),r.push('If you cannot go on without the person, work(action="blocked", text=<one clear question>).'),r.join(`
513
+ `)}function wH(e){if(!e)return;if(e.trim()==="failing")return"failing";let t=e.split(",").map(r=>r.trim()).filter(Boolean);return t.every(r=>jn.includes(r))?t:null}var MN="0.1.0",N1=7417;function DN(e,t,r,o){if($H(xH(e,"project.json")))return At(e);if(!t)throw new ee(`${e} is not a PixelClaw project (no project.json); pass create: true to make one`);return o(`pixelclaw: created an empty project at ${e}`),ib(e,{name:r,palettes:[]})}async function M1(e){let t=e.log??(h=>process.stderr.write(h+`
514
+ `)),r=e.token??vH(16).toString("hex"),o=NN(e.project),n=new Lt(DN(o,!0,void 0,t)),i,s={writer:n,url:()=>i.url,open(h,g){let b=NN(h);if(b===n.project.dir)return;if(a.running())throw new ee("the worker is running on this project; stop it before opening another");let y=DN(b,g.create,g.name,t);a1(b,i.url),c1(n.project.dir),n.setProject(y),t(`pixelclaw: now serving ${b}`)}},a=new vb(n,()=>({url:`http://127.0.0.1:${i.port}/mcp`}));i=await pN({writer:n,token:r,port:e.port??N1,mcp:h=>O1(s,MN,h),worker:a});try{a1(o,i.url)}catch(h){throw await i.close(),h}let c=null,l=null,u,m=new Promise(h=>{u=h}),d=()=>(l??=(async()=>{process.stdin.off("end",f),process.off("SIGINT",p),process.off("SIGTERM",p),a.running()&&a.stop("the server stopping"),await a.settled(),c1(n.project.dir),await c?.close().catch(()=>{}),await i.close(),u()})(),l),f=()=>{d()},p=()=>{d()};return process.on("SIGINT",p),process.on("SIGTERM",p),(e.mcp??!0)&&(c=LE(()=>O1(s,MN),{onerror:h=>t(`pixelclaw: mcp: ${h.message}`)}),process.stdin.on("end",f)),t(`pixelclaw: serving ${o}`),t(`pixelclaw: watch at ${i.url}`),{url:i.url,port:i.port,token:r,writer:n,web:i,worker:a,close:d,closed:m}}import{resolve as WH}from"node:path";import{cpSync as qN,existsSync as Lc,mkdirSync as _H,readFileSync as pd,readdirSync as SH}from"node:fs";import{homedir as kH}from"node:os";import{dirname as zH,join as Fn,relative as RH}from"node:path";import{fileURLToPath as IH}from"node:url";var UN={out:e=>process.stdout.write(e),err:e=>process.stderr.write(e),stdin:()=>pd(0,"utf8"),now:()=>new Date().toISOString().replace(/\.\d{3}Z$/,"Z")},fd=`pixelclaw: a pixel art editor driven by commands
515
+
516
+ pixelclaw new <project> [--name <name>] [--palette <file.json|.hex|.gpl>]... [--grid <px>]
517
+ Create a project folder. The first palette becomes the default. --grid is the tile size
518
+ (default 24): new maps, the camera (16x9 cells) and the draw scale (1x from 48 px) follow it.
519
+ pixelclaw new <project> <kind> <name> <W>x<H> [palette=..] [wrap=on|off] [cell=WxH] [bg=..] [--replace]
520
+ Create an asset (kinds: tile, sprite, sheet, icon, object, map, \u2026). Same as running a 'new' command.
521
+ pixelclaw run <project> (<script.pclaw> | - | -e "<commands>") [--asset <name>] [--replace] [--by <author>] [--view <mode>]
522
+ Apply commands as one undo group. Any error applies nothing. --dry applies them to a copy,
523
+ prints the checks and keeps nothing.
524
+ A script that starts with 'new' creates the asset (--replace starts its tape again).
525
+ underlay generate|import lines are resolved first (an image provider, the key from
526
+ OPENAI_API_KEY, a cost cap per call, logs/underlay-costs.jsonl; or a PNG file).
527
+ pixelclaw seeds <project> <asset> <generator line> [--count 8] [--from 1 | --seeds 3,7,9] [--checks a,b] [--before "<commands>"] [--apply]
528
+ Try the line (noise, scatter, voronoi, bricks, map gen, family coverage, \u2026) with each seed as a
529
+ dry run and rank the seeds by the checks; --apply runs the best one.
530
+ pixelclaw view <project> <asset> [render|grid|tile3x3|diff|game|recolour|anim|map|family|density|all]... [--scale N] [--region x,y,WxH] [--frame N] [--out <dir>]
531
+ [--marks failing|<check>,...] [--theme <name>] [--themes a,b,c] [--ground <tile>] [--with <asset>]... [--size CxR] [--seed N] [--camera x,y]
532
+ Write views (default: <project>/views/<asset>.<mode>.png|txt). The grid is also printed.
533
+ diff shows what the latest group changed; game shows a sprite on its ground at 1x and the
534
+ draw scale beside its set; recolour shows role art under preview themes; map puts a family
535
+ on a random island (--size, --seed; overlays --with) with the seam score; family shows each
536
+ variant among its neighbours; all is render, grid and tile3x3. --marks circles the pixels
537
+ checks flag. map of a map document: the whole map at 1x, --region x,y,WxH (cells) or
538
+ --camera x,y (the engine's screen around a cell) at game scale; of an object: on its ground.
539
+ pixelclaw check <project> [<asset>...] [--checks a,b] [--frame N] [--ground <tile>] [--ref <asset>] [--marks]
540
+ Run the quality checks against the style guide (project.json style): scores, pass or fail,
541
+ and the flagged pixels. Exits 1 if any check fails. --marks writes the render (tile3x3 for
542
+ tiles) with the flagged pixels circled.
543
+ pixelclaw review <project> [<asset>...] [--set <manifest set>] [--name <name>] [--size CxR] [--seed N]
544
+ Write a blind review bundle under <project>/reviews/<date>-<name>/ (rubric.md inside; brief.md
545
+ from the manifest). --set reviews a manifest set's drawn assets.
546
+ pixelclaw plan <project> [--set <set>] [--order set|scene] [--json] [--manifest <file.json>] [--templates [--seed N]]
547
+ The asset plan (manifest.json) and each asset's status: planned, drafted, checked, reviewed,
548
+ approved, exported; requests from people first; what is left and what is failing (by set, or
549
+ scene by scene with what each still needs). --manifest writes a manifest (checked first);
550
+ --templates draws the flat templates (mockup screen, coverage maps) into templates/.
551
+ pixelclaw request <project> [draw <asset> | change <asset> --note "<what>" | add <name> --kind <k> --size WxH [--set <s>] [--description "\u2026"] [--height N]] [--note "\u2026"] [--by <author>]
552
+ Ask for work as the dashboard does: draw a planned asset, change a drawn one (also writes
553
+ mark rejected "<note>" on its tape), or add a new asset (its manifest entry, validated first).
554
+ Without a kind, lists the requests still open, claimed or blocked. Refused while a server
555
+ owns the project (use its dashboard or MCP request).
556
+ pixelclaw reply <project> <id> "<answer>" [--by <author>] answer a blocked request (it opens again)
557
+ pixelclaw cancel <project> <id> ["<why>"] [--by <author>] withdraw a request
558
+ pixelclaw work <project> [--port N]
559
+ Work the request queue with a headless Claude Code session (claude -p with the PixelClaw MCP
560
+ server and the skill) until it is empty or the budget cap is reached. Runs only when
561
+ project.json has "worker": { "enabled": true } (it spends money; cap, command and args are
562
+ settings there; docs/worker.md). Never two at once; with a server running, use its
563
+ dashboard's Start Claude button instead. The log is logs/worker.log (shown in the dashboard).
564
+ pixelclaw skill install [--dest <dir> | --project <dir>]
565
+ Install the Claude Code skill (workflows, house rules, the blind-review hand-off) into
566
+ ~/.claude/skills/pixelclaw (or <dir>/.claude/skills/pixelclaw). skill path prints where it is.
567
+ pixelclaw export <project> [<asset>...] [--profile <name|file.json>] [--out <dir>]
568
+ Write assets through an export profile (default png): built-in png, atlas, tiled, godot,
569
+ aseprite-json, aseprite, or the project's profiles/*.json (docs/profiles.md). Without assets,
570
+ all; a map brings what it draws. Default folder: <project>/exports/<profile>/.
571
+ pixelclaw export <project> <asset> --format split|png|strip|bmfont [--out <dir>]
572
+ split: an oversized asset as one-cell pieces plus a stamp; png: a map at 1x or a first frame;
573
+ strip: a font as a glyph strip (red separator columns) plus its characters; bmfont: a font as .fnt + page.
574
+ pixelclaw import <project> <file.png|file.aseprite|folder> [--profile <name>] [--as <name>] [--kind <kind>]
575
+ [--palette <name> | --build] [--grid WxH [--cells]] [--slice WxH [--offset x,y] [--gap x,y]]
576
+ [--pattern '{name}_{n}' | --names a,b,c | --names-from manifest] [--set <set>] [--wrap] [--no-manifest] [--by <author>] [--replace]
577
+ A PNG or .aseprite file becomes a new asset quantised to a palette (--build: one made from
578
+ the image); --grid slices a sheet into frames (--cells: one image with that cell grid);
579
+ --slice cuts a sheet into separate assets, one per non-empty cell, named by a pattern, a
580
+ list, or the manifest's planned entries (of --set) in order. A folder imports every PNG and
581
+ .aseprite in it. New assets get manifest entries (in --set) and every check is run. With
582
+ --profile, a folder an export wrote is read back by name and compared with the project;
583
+ images no asset exports become new assets.
584
+ pixelclaw upgrade <project> [<asset>...]
585
+ Rewrite language 1 tapes in the current language: the palette goes into the 'new'
586
+ line. Each is replayed before and after; it is written only if the pixels are the same.
587
+ pixelclaw verify <project> [<asset>...]
588
+ Replay every tape and compare with asset.json, preview.png and checkpoints.
589
+ pixelclaw serve --project <project> [--port 7417] [--no-mcp]
590
+ Own the project: MCP on stdin/stdout for the agent, and the live watch view on
591
+ http://127.0.0.1:<port>/?token=... (printed to stderr). Creates the project if needed.
592
+
593
+ Command reference: docs/commands.md
594
+ `,Pe=class extends Error{};function Ft(e,t,r){let o=[],n=new Map;for(let i=0;i<e.length;i++){let s=e[i];if(s.startsWith("-")&&s!=="-"){let a=s.replace(/^--?/,"");if(t.includes(a)){let c=e[++i];if(c===void 0)throw new Pe(`${s} needs a value`);n.set(a,[...n.get(a)??[],c])}else if(r.includes(a))n.set(a,[""]);else throw new Pe(`unknown option ${s}`)}else o.push(s)}return{pos:o,flags:n}}var Se=(e,t)=>e.flags.get(t)?.at(-1);function D1(e,t,r){for(let o of r)e.err(`${t}:${o.line}:${o.col}: error: ${o.message}
595
+ `);e.err(`${r.length} error${r.length===1?"":"s"}; nothing was applied.
596
+ `)}function PH(e,t,r){let o=(r.flags.get("palette")??[]).map(ab),n=Se(r,"grid");if(n!==void 0&&(!/^\d+$/.test(n)||Number(n)<4||Number(n)>256))throw new Pe("new: --grid is the tile size in pixels, 4..256");let i=ib(t,{name:Se(r,"name"),palettes:o,...n!==void 0?{grid:Number(n)}:{}});e.out(`created project '${i.json.name}' at ${t}
597
+ `);for(let s of i.palettes.values())e.out(` palette ${s.name}: ${s.entries.length} entries${s.name===i.json.defaultPalette?" (default)":""}
598
+ `);return 0}function jH(e,t){return new Lt(e).state(t)}function Ci(e){let t=Jm(e.dir);if(t)throw new ee(`a pixelclaw server (pid ${t.pid}) owns ${e.dir}; send commands through it (MCP: run, export, import, request; or its dashboard), or stop it first`)}function q1(e,t,r,o,n){let i=new Lt(t,{now:e.now});if(n.dry)return EH(e,i,r,o,n);Ci(t);let s;try{s=i.run({asset:n.asset,commands:r,by:n.by,replace:n.replace})}catch(a){if(a instanceof qc)return e.err(`error: say which asset with --asset <name> (or start the script with 'new')
599
+ `),{code:1};if(a instanceof Uc)return e.err(`error: asset '${a.asset}' already exists; use --replace to start its tape again
600
+ `),{code:1};throw a}if(!s.ok)return D1(e,o,s.errors),{code:1};if(!s.doc)return e.out(`nothing to do
601
+ `),{code:0};if(s.added.length===0)return e.out(`${s.asset}: no commands
602
+ `),{code:0,doc:s.doc};e.out(`${s.asset}: applied ${s.added.length} command${s.added.length===1?"":"s"} as group ${s.group}; ${s.changed} px changed
603
+ `),e.out(` tape: ${s.commands} commands in ${s.groups} group${s.groups===1?"":"s"}; preview: ${Fn(s.dir,"preview.png")}
604
+ `);for(let a of s.warnings)e.out(` warning: ${a}
605
+ `);return s.followed?.length&&e.out(` brought up to date: ${s.followed.join(", ")} (variants that inherit the band, families whose textures came from=${s.asset})
606
+ `),e.out(` ${xi(i.checks(s.asset,{budget:md}).results)}
607
+ `),{code:0,doc:s.doc}}function EH(e,t,r,o,n){if(Ti(r))throw new Pe("run --dry: a dry run cannot call the image provider (underlay generate/import)");let i;try{i=t.dry({asset:n.asset,commands:r,by:n.by,replace:n.replace})}catch(s){if(s instanceof qc)return e.err(`error: say which asset with --asset <name> (or start the script with 'new')
608
+ `),{code:1};if(s instanceof Uc)return e.err(`error: asset '${s.asset}' already exists; use --replace to try starting its tape again
609
+ `),{code:1};throw s}if(!i.ok)return D1(e,o,i.errors),{code:1};e.out(`${i.asset}: dry run of ${i.added.length} command${i.added.length===1?"":"s"}; ${i.changed} px would change; nothing was kept
610
+ `);for(let s of i.warnings)e.out(` warning: ${s}
611
+ `);return i.doc&&e.out(` ${xi(i.results)}
612
+ `),{code:0,doc:i.doc??void 0}}function TH(e,t){let[r,o,...n]=t.pos;if(!r||!o||!n.length)throw new Pe("seeds: give a project, an asset and a generator line");let i=At(r),s=p=>{let h=Se(t,p);if(h===void 0)return;let g=Number(h);if(!Number.isInteger(g)||g<1)throw new Pe(`--${p} must be a whole number from 1`);return g},a=Se(t,"checks")?.split(",");for(let p of a??[])if(!My(p))throw new Pe(`unknown check '${p}' (checks: ${jn.join(", ")})`);let c=Se(t,"seeds")?.split(",").map(Number),l=new Lt(i,{now:e.now}),u=Se(t,"by")??"claude",m=Se(t,"before"),d=l.seeds({asset:o,line:n.join(" "),before:m,by:u,count:s("count"),from:s("from"),seeds:c,checks:a});if(!d.ok)return D1(e,"<line>",d.errors),1;if(e.out(kb(o,d.trials)+`
613
+ `),!t.flags.has("apply")||!d.trials[0])return 0;let f=d.trials[0];return q1(e,i,m?`${m}
614
+ ${f.line}`:f.line,"<seeds>",{asset:o,replace:!1,by:u}).code}function CH(e,t,r){let o=At(t),n="new "+r.pos.slice(1).join(" ");return q1(e,o,n,"<new>",{replace:r.flags.has("replace"),by:Se(r,"by")??"claude"}).code}function AH(e,t){let[r,o]=t.pos;if(!r)throw new Pe("run: give a project folder");let n=At(r),i,s,a=t.flags.get("e");if(a){if(o)throw new Pe("run: give a script or -e, not both");i=a.join(`
615
+ `),s="<-e>"}else if(o==="-")i=e.stdin(),s="<stdin>";else if(o){if(!Lc(o))throw new Pe(`run: no such script ${o}`);i=pd(o,"utf8"),s=o}else throw new Pe('run: give a script file, - for stdin, or -e "<commands>"');let c=q1(e,n,i,s,{asset:Se(t,"asset"),replace:t.flags.has("replace"),by:Se(t,"by")??"claude",dry:t.flags.has("dry")});return c.code===0&&c.doc&&t.flags.has("view")?VN(e,n,c.doc,t.flags.get("view"),t):c.code}var LN=["asset","by","e","view","scale","region","out","frame","marks","theme","themes","ground","with","size","seed","camera"];async function FN(e,t=UN){if(e[0]!=="run")return e;let r;try{r=Ft(e.slice(1),LN,["replace","dry"])}catch{return e}let[o,n]=r.pos;if(!o||r.flags.has("dry"))return e;let i=r.flags.get("e"),s=i?i.join(`
616
+ `):n==="-"?t.stdin():n&&Lc(n)?pd(n,"utf8"):null;if(s===null||!Ti(s)&&n!=="-")return e;let a=At(o);Ci(a);let c=s;if(Ti(s)){let u=new Lt(a,{now:t.now}),m=Se(r,"asset"),d=null;if(m&&Ii(a).includes(m))try{d=u.doc(m)}catch{d=null}c=await Eb(a,s,{doc:d,now:u.stamp()})}let l=["run",o,"-e",c];for(let[u,m]of r.flags)if(u!=="e"){m.length===0&&l.push(`--${u}`);for(let d of m)l.push(`--${u}`,d)}return l}function VN(e,t,r,o,n){let i=o.length?o:["render"];i.includes("all")&&(i=["render","grid","tile3x3"]);for(let $ of i)if(!hN($))throw new Pe(`unknown view '${$}' (views: ${Gs.join(", ")}, all)`);let s=Se(n,"scale"),a=s===void 0?void 0:Number(s);if(a!==void 0&&(!Number.isInteger(a)||a<1||a>64))throw new Pe("--scale must be an integer 1..64");let c=Se(n,"region"),l=c?Rb(c):void 0;if(l===null)throw new Pe('--region must look like 8,0,12x10 or "8,0 12x10"');if(l&&(l.w<1||l.h<1))throw new Pe("--region size must be at least 1x1");let u=Se(n,"camera"),m=u?/^(\d+),(\d+)$/.exec(u):null;if(u&&!m)throw new Pe("--camera must look like 12,9 (a cell)");let d=m?[Number(m[1]),Number(m[2])]:void 0;if(l&&!r.wrap&&(l.x+l.w>r.width||l.y+l.h>r.height))throw new Pe(`--region runs past the ${r.width}x${r.height} canvas`);let f=Se(n,"frame"),p=f===void 0?void 0:Number(f)-1;if(p!==void 0&&(!Number.isInteger(p)||p<0||p>=r.frameCount))throw new Pe(`--frame must be 1..${r.frameCount}`);let h=Se(n,"marks"),g=h===void 0?void 0:h==="failing"?"failing":h.split(",").map($=>$.trim());if(Array.isArray(g)&&!g.every(My))throw new Pe(`--marks takes failing or check names (${jn.join(", ")})`);let b=Se(n,"size"),y=b?/^(\d+)x(\d+)$/.exec(b):null;if(b&&!y)throw new Pe("--size must look like 16x12 (tiles)");let w=y?{cols:Number(y[1]),rows:Number(y[2])}:void 0,v=Se(n,"seed"),S=v===void 0?void 0:Number(v);if(S!==void 0&&(!Number.isInteger(S)||S<1))throw new Pe("--seed must be a whole number from 1");let _=new Lt(t);for(let $ of i){let x=Se(n,"out")??Fn(t.dir,"views"),k=_.view(r.name,$,{scale:a,region:l,frame:p,marks:g,theme:Se(n,"theme"),themes:Se(n,"themes")?.split(","),ground:Se(n,"ground"),with:n.flags.get("with"),size:w,seed:S,camera:d},x);k.kind==="text"?(e.out(k.text),e.out(`wrote ${k.path}
617
+ `)):e.out(`${k.text?k.text+`
618
+ `:""}wrote ${k.path} (${k.width}x${k.height})
619
+ `)}return 0}function OH(e,t){let[r,...o]=t.pos;if(!r)throw new Pe("check: give a project folder");let n=At(r),i=new Lt(n),s=Se(t,"checks")?.split(",").map(u=>u.trim());if(s&&!s.every(My))throw new Pe(`--checks takes check names (${jn.join(", ")})`);let a=Se(t,"frame"),c=a===void 0?void 0:Number(a)-1;if(c!==void 0&&(!Number.isInteger(c)||c<0))throw new Pe("--frame must be a frame number from 1");let l=0;for(let u of o.length?o:i.assets()){let{results:m,problems:d}=i.checks(u,{checks:s,frame:c,ground:Se(t,"ground"),ref:Se(t,"ref")}),f=m.filter(p=>p.status==="fail").map(p=>p.id);if(f.length&&l++,e.out(Sb(u,m,d,c)+`
620
+ `),t.flags.has("marks")&&f.length){let p=i.view(u,i.doc(u).wrap?"tile3x3":"render",{frame:c??m.find(h=>h.status==="fail")?.frame,marks:f});e.out(` wrote ${p.path}
621
+ `)}}return l?1:0}function NH(e,t){let[r,...o]=t.pos;if(!r)throw new Pe("review: give a project folder");let n=Se(t,"size"),i=n?/^(\d+)x(\d+)$/.exec(n):null;if(n&&!i)throw new Pe("--size must look like 16x12 (tiles)");let s=Se(t,"seed")===void 0?void 0:Number(Se(t,"seed"));if(s!==void 0&&(!Number.isInteger(s)||s<1))throw new Pe("--seed must be a whole number from 1");let a={...i?{cols:Number(i[1]),rows:Number(i[2])}:{},...s?{seed:s}:{}},c=zb(new Lt(At(r),{now:e.now}),{assets:o.length?o:void 0,set:Se(t,"set"),name:Se(t,"name"),map:a});return e.out(`wrote ${c.files.length} files to ${c.dir}
622
+ ${c.files.map(l=>` ${l}
623
+ `).join("")}Hand the folder to a fresh reviewer: "Review the art in ${c.dir} by following rubric.md."
624
+ `),0}function MH(e,t){let[r,o,n,...i]=t.pos;if(!r)throw new Pe("request: give a project folder");if(i.length)throw new Pe(`request: unexpected argument '${i[0]}'`);let s=At(r);if(!o){let u=Rr(sn(s));return e.out(u.length?u.map(m=>Ei(m)+`
625
+ `).join(""):`no open requests
626
+ `),0}if(!["draw","change","add"].includes(o))throw new Pe(`request: the kind is draw, change or add (not '${o}')`);if(!n)throw new Pe(`request ${o}: give the asset${o==="add"?"'s name":""}`);if(o!=="add"){for(let u of["kind","size","set","description","height"])if(Se(t,u)!==void 0)throw new Pe(`request ${o}: --${u} is for add`)}let a;if(o==="add"){let u=Se(t,"height");if(u!==void 0&&!/^\d+$/.test(u))throw new Pe("--height is a number of pixels");a={name:n,kind:Se(t,"kind"),size:Se(t,"size"),...Se(t,"set")?{set:Se(t,"set")}:{},...Se(t,"description")?{description:Se(t,"description")}:{},...u?{height:Number(u)}:{}}}Ci(s);let c=new Lt(s,{now:e.now}),l=Hs(c,Se(t,"by")??"claude",nd({action:"request",kind:o,asset:n,note:Se(t,"note"),entry:a}));return e.out(`${Ei(l)}
627
+ `),0}function DH(e,t,r){let[o,n,i,...s]=r.pos;if(!o||!n)throw new Pe(`${t}: give a project folder and a request id`);if(s.length)throw new Pe(`${t}: put the text in quotes (unexpected '${s[0]}')`);let a=At(o);Ci(a);let c=new Lt(a,{now:e.now}),l=Hs(c,Se(r,"by")??"claude",nd({action:t,id:n,text:i}));return e.out(`${Ei(l)}
628
+ `),0}function qH(e,t){let[r]=t.pos;if(!r)throw new Pe("plan: give a project folder");let o=new Lt(At(r),{now:e.now}),n=Se(t,"manifest");if(n){let a;try{a=JSON.parse(pd(n,"utf8"))}catch(l){throw new ee(`${n}: ${l.message}`)}let c=ji(o.project,a);if(!c.manifest)return e.err(`error: the manifest was not written; ${c.errors.length} problem${c.errors.length===1?"":"s"}:
629
+ ${c.errors.map(l=>` ${l.path||"(top)"}: ${l.message}
630
+ `).join("")}`),1;e.out(`wrote ${Fn(o.project.dir,"manifest.json")}: ${c.manifest.assets.length} assets
631
+ `)}if(t.flags.has("templates")){let a=Se(t,"seed")===void 0?void 0:Number(Se(t,"seed")),c=yb(o,{seed:a});e.out(`wrote ${c.files.length} templates to ${c.dir}
632
+ ${c.files.map(l=>` ${l}
633
+ `).join("")}`)}let i=Se(t,"order");if(i!==void 0&&i!=="set"&&i!=="scene")throw new Pe("--order is set or scene");let s=Bs(o,{set:Se(t,"set")});return e.out(t.flags.has("json")?JSON.stringify(s,null,2)+`
634
+ `:gb(s,{order:i})+`
635
+ `),s.manifest.errors.length?1:0}function UH(){let e=zH(IH(import.meta.url));for(let t of[Fn(e,"skill"),Fn(e,"..","..","skill")])if(Lc(Fn(t,"SKILL.md")))return t;throw new ee("the skill is not in this build (no skill/SKILL.md)")}function LH(e,t){let[r]=t.pos;if(r!=="install"&&r!=="path")throw new Pe("skill: install [--dest <dir> | --project <dir>], or path");let o=UH();if(r==="path")return e.out(o+`
636
+ `),0;let n=Se(t,"project"),i=Se(t,"dest")??(n?Fn(n,".claude","skills","pixelclaw"):Fn(kH(),".claude","skills","pixelclaw"));_H(i,{recursive:!0}),qN(o,i,{recursive:!0});let s=Fn(o,"..","docs","commands.md");!Lc(Fn(o,"commands.md"))&&Lc(s)&&qN(s,Fn(i,"commands.md"));let a=SH(i,{recursive:!0}).map(String).filter(c=>c.includes(".")).sort();return e.out(`installed the PixelClaw skill in ${i} (${a.join(", ")})
637
+ Claude Code finds it as /pixelclaw; connect the tools with:
638
+ claude mcp add pixelclaw -- npx pixelclaw serve --project <your project>.pclaw
639
+ `),0}function FH(e,t){let[r,o,...n]=t.pos;if(!r||!o)throw new Pe("view: give a project folder and an asset name");let i=At(r),{doc:s}=jH(i,o);if(!s)throw new ee(`asset '${o}' has an empty tape`);return VN(e,i,s,n,t)}function VH(e,t){let[r,o]=t.pos;if(!r||!o)throw new Pe("export: give a project folder and an asset name");let n=Se(t,"format");if(!Km.includes(n))throw new Pe(`--format must be one of ${Km.join(", ")}`);let i=At(r);Ci(i);let s=new Lt(i),a=mb(s.doc(o),s.assetDocs(),n,Se(t,"out")??Fn(i.dir,"exports",n));return e.out(`${n}: wrote ${a.length} files
640
+ ${a.map(c=>` ${c}
641
+ `).join("")}`),0}function ZH(e,t){let[r,...o]=t.pos;if(!r)throw new Pe("export: give a project folder");let n=At(r);Ci(n);let i=new Lt(n),s=Se(t,"profile")??"png",a=pb(n,i.assetDocs(),s,{names:o.length?o:void 0,dest:Se(t,"out"),at:e.now()});return e.out(`${s}: ${a.images} images, wrote ${a.files.length} files into ${a.dir}
642
+ ${a.notes.map(c=>` note: ${c}
643
+ `).join("")}`),0}function HH(e,t){let[r,o]=t.pos;if(!r||!o)throw new Pe("import: give a project folder and a file or folder");let n=At(r);Ci(n);let i=new Lt(n,{now:e.now}),s=(g,b,y,w)=>{let v=Se(t,g);if(v!==void 0){if(!b.test(v))throw new Pe(`--${g} is ${w}`);return v.split(y).map(Number)}},a=s("grid",/^\d+x\d+$/,"x","a size like 24x24"),c=s("slice",/^\d+x\d+$/,"x","a size like 24x24"),l=s("offset",/^\d+,\d+$/,",","a point like 2,2"),u=s("gap",/^\d+,\d+$/,",","a point like 1,1"),m=Se(t,"names-from");if(m!==void 0&&m!=="manifest")throw new Pe("--names-from takes manifest");let d=Se(t,"by")??"claude",f={as:Se(t,"as"),kind:Se(t,"kind"),palette:Se(t,"palette"),build:t.flags.has("build"),grid:a,cells:t.flags.has("cells")};if(!Se(t,"profile")){let g=Oc(i,{path:o,...f,slice:c?{cell:c,offset:l,gap:u}:void 0,pattern:Se(t,"pattern"),names:Se(t,"names")?.split(","),namesFrom:m,set:Se(t,"set"),wrap:t.flags.has("wrap"),manifest:t.flags.has("no-manifest")?!1:void 0,replace:t.flags.has("replace")},d);return e.out((g.text||"nothing to import")+`
644
+ `),0}let p=td(n,i.assetDocs(),{path:o,profile:Se(t,"profile"),...f}),h=[];for(let g of p.create){let b=i.run({asset:g.name,commands:g.tape,by:d,replace:t.flags.has("replace")});if(!b.ok)throw new ee(`${g.name}: ${b.errors.map(y=>`${y.line}:${y.col} ${y.message}`).join("; ")}`);h.push(g.name)}return e.out((hb(p,h)||"nothing to import")+`
645
+ `),p.differ.length?1:0}function BH(e,t){let[r,...o]=t.pos;if(!r)throw new Pe("upgrade: give a project folder");let n=At(r);Ci(n);let i=jo(n),s=0,a=[];for(let c of o.length?o:Ii(n)){let l=Bm(n,c),u;try{u=GA(l,i)}catch(h){e.out(`FAIL ${c}: ${h.message}
646
+ `),s++;continue}if(!u){e.out(`ok ${c}: already language ${Sr}
647
+ `);continue}let m=Om(l,i),d=Om(u,i);if(!(!m.problems.length&&!d.problems.length&&m.doc&&d.doc&&Buffer.compare(Rn(m.doc),Rn(d.doc))===0)){e.out(`FAIL ${c}: the upgraded tape does not replay to the same document; left as it was
648
+ `),s++;continue}let p=new Ec(i);ub(n,{doc:d.doc,entries:u},h=>p.docAt(u,h).doc,!0),e.out(`ok ${c}: language 1 \u2192 ${Sr}, the same pixels (${u.length} commands)
649
+ `),a.push(c)}return a.length?Math.max(s?1:0,ZN(e,{...t,pos:[r,...a]})):s?1:0}function ZN(e,t){let[r,...o]=t.pos;if(!r)throw new Pe("verify: give a project folder");let n=At(r),i=o.length?o:Ii(n),s=0;for(let a of i){let c=[],l;try{l=Bm(n,a)}catch(b){e.out(`FAIL ${a}: ${b.message}
650
+ `),s++;continue}let u=o1(n,a),m=new Map(u.filter(b=>b.n>0).map(b=>[b.n,b])),d=()=>{let b=new zi(jo(n));for(let y of l){let w=b.step(y);if(w!==null)return{doc:b.doc,problems:[{seq:y.seq,message:w}]};let v=m.get(b.done.length);v&&f&&(v.hash!==lb(l,v.n)?c.push(`checkpoint ${v.file} was made from another tape`):(!b.doc||Buffer.compare(Buffer.from(Rn(b.doc)),Buffer.from(v.body))!==0)&&c.push(`checkpoint ${v.file} differs from the replay`))}return{doc:b.doc,problems:[]}},f=!0,p=d();f=!1;let h=d();for(let b of p.problems)c.push(`tape seq ${b.seq}: ${b.message}`);let g="";if(!p.problems.length&&p.doc&&h.doc){let b=Rn(p.doc);Tn(b)!==Tn(Rn(h.doc))&&c.push("two replays differ");let y=Tn(b),w=OO(n,a),v=rT(p.doc),S=w.state.sha256!==y&&v!==null&&w.state.sha256===Tn(v);w.state.sha256!==y&&!S&&c.push(`replayed state ${y.slice(0,12)} differs from asset.json ${w.state.sha256.slice(0,12)}`),w.tape.commands!==l.length&&c.push(`asset.json counts ${w.tape.commands} commands, the tape has ${l.length}`);let _=Fn(Vs(n,a),"preview.png");Lc(_)?Buffer.compare(Buffer.from(r1(p.doc)),pd(_))!==0&&c.push("preview.png differs from the replayed document"):c.push("preview.png is missing");for(let P of u)P.n<0?c.push(`checkpoint ${P.file} is not a checkpoint file`):P.n>l.length?c.push(`checkpoint ${P.file} is past the end of the tape`):P.file!==`${String(P.n).padStart(6,"0")}.gwc`&&c.push(`checkpoint ${P.file} holds command ${P.n}`);let $=zN(n,a),x=$?.key===ud(n,Wm(n,a).bytes,kr(l));$&&x&&Buffer.compare(Buffer.from(b),Buffer.from($.body))!==0&&c.push("the state cache differs from the replay (delete .cache/ to rebuild it)");let k=cb(l.length).filter(P=>!u.some(I=>I.file===P));k.length&&c.push(`checkpoint${k.length===1?"":"s"} missing: ${k.join(", ")}`),g=`${l.length} commands, ${new Set(l.map(P=>P.group)).size} groups, state ${y.slice(0,12)}${S?" (asset.json has a hash in the older state format; it is updated on the next save)":""}, ${u.length?u.length+" checkpoint"+(u.length===1?"":"s")+" checked":"no checkpoints"}${x?", cache checked":""}`}else!p.doc&&!p.problems.length&&c.push("the tape has no document");c.length?(s++,e.out(`FAIL ${a}
651
+ ${c.map(b=>` ${b}
652
+ `).join("")}`)):e.out(`ok ${a}: ${g}
653
+ `)}return e.out(s?`${s} of ${i.length} assets failed
654
+ `:`${i.length} asset${i.length===1?"":"s"} verified in ${RH(process.cwd(),n.dir)||"."}
655
+ `),s?1:0}function U1(e,t=UN){let[r,...o]=e;try{switch(r){case"new":{let n=Ft(o,["name","palette","by","grid"],["replace"]);if(!n.pos[0])throw new Pe("new: give a project folder");return n.pos.length===1?PH(t,n.pos[0],n):CH(t,n.pos[0],n)}case"run":return AH(t,Ft(o,LN,["replace","dry"]));case"seeds":return TH(t,Ft(o,["count","from","seeds","checks","before","by"],["apply"]));case"view":return FH(t,Ft(o,["scale","region","out","frame","marks","theme","themes","ground","with","size","seed","camera"],[]));case"export":{let n=Ft(o,["format","out","profile"],[]);return Se(n,"format")?VH(t,n):ZH(t,n)}case"import":return HH(t,Ft(o,["profile","as","kind","palette","grid","by","slice","offset","gap","pattern","names","names-from","set"],["build","cells","replace","wrap","no-manifest"]));case"check":return OH(t,Ft(o,["checks","frame","ground","ref"],["marks"]));case"review":return NH(t,Ft(o,["name","set","size","seed"],[]));case"plan":return qH(t,Ft(o,["set","manifest","seed","order"],["json","templates"]));case"request":return MH(t,Ft(o,["note","by","kind","size","set","description","height"],[]));case"reply":case"cancel":return DH(t,r,Ft(o,["by"],[]));case"skill":return LH(t,Ft(o,["dest","project"],[]));case"verify":return ZN(t,Ft(o,[],[]));case"upgrade":return BH(t,Ft(o,[],[]));case void 0:case"help":case"-h":case"--help":return t.out(fd),r===void 0?1:0;default:throw new Pe(`unknown command '${r}'`)}}catch(n){if(n instanceof Pe)return t.err(`error: ${n.message}
656
+
657
+ ${fd}`),2;if(n instanceof ee)return t.err(`error: ${n.message}
658
+ `),1;throw n}}async function JH(e){try{let t=Ft(e,["project","port","token"],["no-mcp"]),r=Se(t,"project")??t.pos[0];if(!r)throw new Pe("serve: give a project folder with --project <dir>");if(t.pos.length>(Se(t,"project")?0:1))throw new Pe(`serve: unexpected argument '${t.pos.at(-1)}'`);let o=Se(t,"port"),n=o===void 0?N1:Number(o);if(!Number.isInteger(n)||n<0||n>65535)throw new Pe("--port must be 0..65535");return await(await M1({project:r,port:n,mcp:!t.flags.has("no-mcp"),token:Se(t,"token")})).closed,0}catch(t){if(t instanceof Pe)return process.stderr.write(`error: ${t.message}
659
+
660
+ ${fd}`),2;if(t instanceof ee)return process.stderr.write(`error: ${t.message}
661
+ `),1;throw t}}async function GH(e){try{let t=Ft(e,["port"],[]),[r]=t.pos;if(!r||t.pos.length>1)throw new Pe("work: give one project folder");let o=WH(r),n=Ws(o);if(!n.enabled)throw new ee(`the worker is off for ${o}: set "worker": { "enabled": true } in its project.json first (it runs Claude Code headless and spends money, up to "cap" US dollars a run, default ${n.cap}; see docs/worker.md)`);let i=Jm(o);if(i)throw new ee(`a pixelclaw server (pid ${i.pid}) owns ${o}: start the worker from its dashboard (Start Claude) instead`);let s=$1(o);if(s)throw new ee(`a worker is already running for ${o} (pid ${s.pid}, started by ${s.by} at ${s.startedAt})`);let a=Se(t,"port"),c=a===void 0?0:Number(a);if(!Number.isInteger(c)||c<0||c>65535)throw new Pe("--port must be 0..65535");let l=await M1({project:o,port:c,mcp:!1}),u;try{u=await l.worker.start("cli")}finally{await l.close()}return process.stderr.write(`pixelclaw: worker stopped: ${u}
662
+ `),0}catch(t){if(t instanceof Pe)return process.stderr.write(`error: ${t.message}
663
+
664
+ ${fd}`),2;if(t instanceof ee)return process.stderr.write(`error: ${t.message}
665
+ `),1;throw t}}async function HN(e){if(process.stdout.on("error",t=>{throw t.code==="EPIPE"&&process.exit(0),t}),e[0]==="work"&&process.exit(await GH(e.slice(1))),e[0]==="serve"){let t=await JH(e.slice(1));process.exit(t)}if(e[0]==="run")try{return U1(await FN(e))}catch(t){if(t instanceof ee)return process.stderr.write(`error: ${t.message}
666
+ `),1;throw t}return U1(e)}process.exitCode=await HN(process.argv.slice(2));