pixelclaw 0.0.0-stage → 0.2.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,712 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __pclawRequire } from 'node:module'; const require = __pclawRequire(import.meta.url);
3
+ var PM=Object.defineProperty;var ro=(e,t)=>{for(var r in t)PM(e,r,{get:t[r],enumerable:!0})};import{randomBytes as fB}from"node:crypto";import{existsSync as pB}from"node:fs";import{join as hB,resolve as pM}from"node:path";var jM=Object.create,Ld=Object.defineProperty,EM=Object.getOwnPropertyDescriptor,TM=Object.getOwnPropertyNames,CM=Object.getPrototypeOf,AM=Object.prototype.hasOwnProperty,ue=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),mz=(e,t)=>{let r={};for(var o in e)Ld(r,o,{get:e[o],enumerable:!0});return t&&Ld(r,Symbol.toStringTag,{value:"Module"}),r},OM=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(var n=TM(t),i=0,s=n.length,a;i<s;i++)a=n[i],!AM.call(e,a)&&a!==r&&Ld(e,a,{get:(c=>t[c]).bind(null,a),enumerable:!(o=EM(t,a))||o.enumerable});return e},Fd=(e,t,r)=>(r=e!=null?jM(CM(e)):{},OM(t||!e||!e.__esModule?Ld(r,"default",{value:e,enumerable:!0}):r,e));var NM=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),dz=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),MM=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),DM=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function fz(e){return typeof e=="string"&&dz.has(e.replace(/#$/,""))}function pz(e,t){if(!("$schema"in e)||typeof e.$schema!="string")return"2020-12";let r=e.$schema.replace(/#$/,"");if(NM.has(r))return"2020-12";if(dz.has(r))return"2019-09";if(MM.has(r)||DM.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 ae={};ro(ae,{$brand:()=>mw,$input:()=>M$,$output:()=>N$,INVALID:()=>mn,NEVER:()=>Ol,TimePrecision:()=>G$,ZodAny:()=>Tx,ZodArray:()=>Nx,ZodBase64:()=>qp,ZodBase64URL:()=>Up,ZodBigInt:()=>Ka,ZodBigIntFormat:()=>Vp,ZodBoolean:()=>Ga,ZodCIDRv4:()=>Mp,ZodCIDRv6:()=>Dp,ZodCUID:()=>jp,ZodCUID2:()=>Ep,ZodCatch:()=>t_,ZodCodec:()=>wu,ZodCompileAsyncError:()=>hr,ZodCompileUnsupportedError:()=>We,ZodCreditCard:()=>Rx,ZodCustom:()=>vu,ZodCustomStringFormat:()=>ss,ZodDate:()=>pu,ZodDefault:()=>Gx,ZodDiscriminatedUnion:()=>Dx,ZodE164:()=>Lp,ZodEmail:()=>Sp,ZodEmoji:()=>Ip,ZodEnum:()=>Wa,ZodError:()=>r6,ZodExactOptional:()=>Hp,ZodFile:()=>Wx,ZodFirstPartyTypeKind:()=>p_,ZodFunction:()=>u_,ZodGUID:()=>Rp,ZodIBAN:()=>Ix,ZodIPv4:()=>Op,ZodIPv6:()=>Np,ZodISODate:()=>Xo,ZodISODateTime:()=>Ko,ZodISODuration:()=>Qo,ZodISOTime:()=>Yo,ZodInstanceOf:()=>f_,ZodIntersection:()=>qx,ZodIssueCode:()=>h_,ZodJWT:()=>Fp,ZodKSUID:()=>Ap,ZodLazy:()=>c_,ZodLiteral:()=>Zx,ZodMAC:()=>zx,ZodMap:()=>Fx,ZodNaN:()=>r_,ZodNanoID:()=>Pp,ZodNever:()=>Ax,ZodNonOptional:()=>Jp,ZodNull:()=>Ex,ZodNullable:()=>Jx,ZodNumber:()=>Ja,ZodNumberFormat:()=>as,ZodObject:()=>hu,ZodOptional:()=>yu,ZodPipe:()=>bu,ZodPrefault:()=>Xx,ZodPreprocess:()=>o_,ZodPromise:()=>l_,ZodReadonly:()=>i_,ZodRealError:()=>kn,ZodRecord:()=>Za,ZodSet:()=>Vx,ZodString:()=>Ba,ZodStringFormat:()=>st,ZodSuccess:()=>e_,ZodSymbol:()=>Px,ZodTemplateLiteral:()=>a_,ZodTransform:()=>Bx,ZodTuple:()=>Ux,ZodType:()=>Fe,ZodULID:()=>Tp,ZodURL:()=>fu,ZodUUID:()=>Or,ZodUndefined:()=>jx,ZodUnion:()=>gu,ZodUnknown:()=>Cx,ZodVoid:()=>Ox,ZodXID:()=>Cp,ZodXor:()=>Mx,_ZodString:()=>kp,_default:()=>Kx,_function:()=>LP,any:()=>Zp,array:()=>te,base64:()=>rP,base64url:()=>oP,bigint:()=>bP,boolean:()=>xe,catch:()=>n_,check:()=>FP,cidrv4:()=>tP,cidrv6:()=>nP,clone:()=>tt,codec:()=>MP,coerce:()=>_u,compile:()=>L$,config:()=>xt,core:()=>co,creditCard:()=>sP,cuid:()=>HI,cuid2:()=>JI,currencyCode:()=>dP,custom:()=>VP,date:()=>kP,decode:()=>wx,decodeAsync:()=>$x,deepPartial:()=>tj,describe:()=>ZP,discriminatedUnion:()=>ei,e164:()=>iP,email:()=>zp,emoji:()=>WI,encode:()=>bx,encodeAsync:()=>vx,endsWith:()=>Ca,enum:()=>Ce,exactOptional:()=>Hx,file:()=>CP,flattenError:()=>Nl,float32:()=>pP,float64:()=>hP,formatError:()=>Ml,fromJSONSchema:()=>QP,function:()=>LP,getDiscriminatedOption:()=>u$,getErrorMap:()=>a6,globalRegistry:()=>Wt,gt:()=>Cr,gte:()=>qn,guid:()=>qI,hash:()=>fP,hex:()=>mP,hostname:()=>uP,httpUrl:()=>ZI,iban:()=>aP,includes:()=>Ea,input:()=>rj,instanceof:()=>BP,int:()=>xp,int32:()=>gP,int64:()=>wP,intersection:()=>yr,invertCodec:()=>DP,ipv4:()=>YI,ipv6:()=>eP,iso:()=>Yn,json:()=>JP,jwt:()=>cP,keyof:()=>SP,ksuid:()=>XI,lazy:()=>ti,length:()=>ns,literal:()=>ne,locales:()=>ru,looseObject:()=>je,looseRecord:()=>PP,lowercase:()=>Pa,lt:()=>Tr,lte:()=>Dn,mac:()=>QI,map:()=>jP,maxLength:()=>ts,maxSize:()=>Bo,memoizer:()=>tu,meta:()=>WP,mime:()=>Oa,minLength:()=>ao,minSize:()=>Ar,multipleOf:()=>Wo,nan:()=>NP,nanoid:()=>BI,nativeEnum:()=>TP,negative:()=>dp,never:()=>Wp,nonnegative:()=>pp,nonoptional:()=>Qx,nonpositive:()=>fp,normalize:()=>Na,null:()=>Nr,nullable:()=>du,nullish:()=>AP,number:()=>me,object:()=>J,optional:()=>Re,output:()=>oj,overwrite:()=>gr,parse:()=>hx,parseAsync:()=>gx,partialRecord:()=>IP,pipe:()=>_p,positive:()=>mp,prefault:()=>Yx,preprocess:()=>lo,prettifyError:()=>gw,promise:()=>UP,properties:()=>Aa,property:()=>hp,readonly:()=>s_,record:()=>ve,refine:()=>m_,regex:()=>Ia,regexes:()=>Xn,registry:()=>Uf,safeDecode:()=>_x,safeDecodeAsync:()=>Sx,safeEncode:()=>xx,safeEncodeAsync:()=>kx,safeParse:()=>mu,safeParseAsync:()=>yx,set:()=>EP,setErrorMap:()=>s6,size:()=>es,slugify:()=>Ua,startsWith:()=>Ta,strictObject:()=>zP,string:()=>E,stringFormat:()=>lP,stringbool:()=>HP,success:()=>OP,superRefine:()=>d_,symbol:()=>$P,templateLiteral:()=>qP,toJSONSchema:()=>os,toLowerCase:()=>Da,toUpperCase:()=>qa,toZod:()=>Sl,transform:()=>Bp,treeifyError:()=>hw,trim:()=>Ma,tuple:()=>Lx,uint32:()=>yP,uint64:()=>vP,ulid:()=>GI,undefined:()=>xP,union:()=>_e,unknown:()=>Ie,uppercase:()=>ja,url:()=>Ha,util:()=>oe,uuid:()=>UI,uuidv4:()=>LI,uuidv6:()=>FI,uuidv7:()=>VI,validate:()=>Dl,validateAsync:()=>ql,void:()=>_P,withParser:()=>Lf,xid:()=>KI,xor:()=>RP});var co={};ro(co,{$ZodAny:()=>t$,$ZodArray:()=>a$,$ZodAsyncError:()=>xn,$ZodBase64:()=>Vv,$ZodBase64URL:()=>Zv,$ZodBigInt:()=>zf,$ZodBigIntFormat:()=>Xv,$ZodBoolean:()=>Gl,$ZodCIDRv4:()=>Lv,$ZodCIDRv6:()=>Fv,$ZodCUID:()=>Pv,$ZodCUID2:()=>jv,$ZodCatch:()=>z$,$ZodCheck:()=>lt,$ZodCheckBigIntFormat:()=>nv,$ZodCheckEndsWith:()=>pv,$ZodCheckGreaterThan:()=>uf,$ZodCheckIncludes:()=>dv,$ZodCheckLengthEquals:()=>cv,$ZodCheckLessThan:()=>lf,$ZodCheckLowerCase:()=>uv,$ZodCheckMaxLength:()=>sv,$ZodCheckMaxSize:()=>rv,$ZodCheckMimeType:()=>yv,$ZodCheckMinLength:()=>av,$ZodCheckMinSize:()=>ov,$ZodCheckMultipleOf:()=>ev,$ZodCheckNumberFormat:()=>tv,$ZodCheckOverwrite:()=>bv,$ZodCheckProperties:()=>gv,$ZodCheckProperty:()=>hv,$ZodCheckRegex:()=>lv,$ZodCheckSizeEquals:()=>iv,$ZodCheckStartsWith:()=>fv,$ZodCheckStringFormat:()=>_a,$ZodCheckUpperCase:()=>mv,$ZodCodec:()=>Xl,$ZodCreditCard:()=>Bv,$ZodCustom:()=>C$,$ZodCustomStringFormat:()=>Gv,$ZodCyclicError:()=>Cf,$ZodDate:()=>i$,$ZodDefault:()=>x$,$ZodDiscriminatedUnion:()=>m$,$ZodE164:()=>Wv,$ZodEmail:()=>_v,$ZodEmoji:()=>Rv,$ZodEncodeError:()=>Vo,$ZodEnum:()=>g$,$ZodError:()=>pw,$ZodExactOptional:()=>v$,$ZodFile:()=>b$,$ZodFunction:()=>E$,$ZodGUID:()=>$v,$ZodIBAN:()=>Hv,$ZodIPv4:()=>Dv,$ZodIPv6:()=>qv,$ZodISODate:()=>Ov,$ZodISODateTime:()=>Av,$ZodISODuration:()=>Mv,$ZodISOTime:()=>Nv,$ZodIntersection:()=>d$,$ZodJWT:()=>Jv,$ZodKSUID:()=>Cv,$ZodLazy:()=>Yl,$ZodLiteral:()=>y$,$ZodMAC:()=>Uv,$ZodMap:()=>p$,$ZodNaN:()=>R$,$ZodNanoID:()=>Iv,$ZodNever:()=>r$,$ZodNonOptional:()=>k$,$ZodNull:()=>e$,$ZodNullable:()=>$$,$ZodNumber:()=>Sf,$ZodNumberFormat:()=>Kv,$ZodObject:()=>Gz,$ZodObjectJIT:()=>c$,$ZodOptional:()=>If,$ZodPipe:()=>Pf,$ZodPrefault:()=>_$,$ZodPreprocess:()=>I$,$ZodPromise:()=>T$,$ZodReadonly:()=>P$,$ZodRealError:()=>_n,$ZodRecord:()=>f$,$ZodRegistry:()=>qf,$ZodSet:()=>h$,$ZodString:()=>Ki,$ZodStringFormat:()=>nt,$ZodSuccess:()=>S$,$ZodSymbol:()=>Yv,$ZodTemplateLiteral:()=>j$,$ZodTransform:()=>w$,$ZodTuple:()=>Rf,$ZodType:()=>Ne,$ZodULID:()=>Ev,$ZodURL:()=>zv,$ZodUUID:()=>xv,$ZodUndefined:()=>Qv,$ZodUnion:()=>Kl,$ZodUnknown:()=>n$,$ZodVoid:()=>o$,$ZodXID:()=>Tv,$ZodXor:()=>l$,$brand:()=>mw,$constructor:()=>G,$input:()=>M$,$output:()=>N$,Doc:()=>Gi,INVALID:()=>mn,JSONSchema:()=>NI,JSONSchemaGenerator:()=>wp,NEVER:()=>Ol,TimePrecision:()=>G$,URL_BAD_FORMAT:()=>kv,URL_UNPARSEABLE:()=>Zl,ZodCompileAsyncError:()=>hr,ZodCompileUnsupportedError:()=>We,_any:()=>d0,_array:()=>w0,_base64:()=>ap,_base64url:()=>cp,_bigint:()=>i0,_boolean:()=>r0,_catch:()=>W4,_check:()=>vI,_cidrv4:()=>ip,_cidrv6:()=>sp,_coercedBigint:()=>s0,_coercedBoolean:()=>o0,_coercedDate:()=>y0,_coercedNumber:()=>X$,_coercedString:()=>W$,_creditCard:()=>H$,_cuid:()=>Yf,_cuid2:()=>Qf,_custom:()=>$0,_date:()=>g0,_decode:()=>Xd,_decodeAsync:()=>Qd,_default:()=>F4,_discriminatedUnion:()=>j4,_e164:()=>lp,_email:()=>Zf,_emoji:()=>Kf,_encode:()=>Kd,_encodeAsync:()=>Yd,_endsWith:()=>Ca,_enum:()=>N4,_file:()=>v0,_float32:()=>Q$,_float64:()=>e0,_gt:()=>Cr,_gte:()=>qn,_guid:()=>Wf,_iban:()=>J$,_includes:()=>Ea,_int:()=>Y$,_int32:()=>t0,_int64:()=>a0,_intersection:()=>E4,_ipv4:()=>rp,_ipv6:()=>op,_isoDate:()=>su,_isoDateTime:()=>iu,_isoDuration:()=>cu,_isoTime:()=>au,_jwt:()=>up,_ksuid:()=>np,_lazy:()=>G4,_length:()=>ns,_literal:()=>D4,_lowercase:()=>Pa,_lt:()=>Tr,_lte:()=>Dn,_mac:()=>B$,_map:()=>A4,_max:()=>Dn,_maxLength:()=>ts,_maxSize:()=>Bo,_mime:()=>Oa,_min:()=>qn,_minLength:()=>ao,_minSize:()=>Ar,_multipleOf:()=>Wo,_nan:()=>b0,_nanoid:()=>Xf,_nativeEnum:()=>M4,_negative:()=>dp,_never:()=>p0,_nonnegative:()=>pp,_nonoptional:()=>V4,_nonpositive:()=>fp,_normalize:()=>Na,_null:()=>m0,_nullable:()=>L4,_number:()=>K$,_optional:()=>U4,_overwrite:()=>gr,_parse:()=>wa,_parseAsync:()=>va,_pipe:()=>B4,_positive:()=>mp,_promise:()=>K4,_properties:()=>Aa,_property:()=>hp,_readonly:()=>H4,_record:()=>C4,_refine:()=>x0,_regex:()=>Ia,_safeDecode:()=>tf,_safeDecodeAsync:()=>rf,_safeEncode:()=>ef,_safeEncodeAsync:()=>nf,_safeParse:()=>$a,_safeParseAsync:()=>xa,_set:()=>O4,_size:()=>es,_slugify:()=>Ua,_startsWith:()=>Ta,_string:()=>Z$,_stringFormat:()=>rs,_stringbool:()=>z0,_success:()=>Z4,_superRefine:()=>_0,_symbol:()=>l0,_templateLiteral:()=>J4,_toLowerCase:()=>Da,_toUpperCase:()=>qa,_transform:()=>q4,_trim:()=>Ma,_tuple:()=>T4,_uint32:()=>n0,_uint64:()=>c0,_ulid:()=>ep,_undefined:()=>u0,_union:()=>I4,_unknown:()=>f0,_uppercase:()=>ja,_url:()=>ou,_uuid:()=>Bf,_uuidv4:()=>Hf,_uuidv6:()=>Jf,_uuidv7:()=>Gf,_void:()=>h0,_xid:()=>tp,_xor:()=>P4,base64Charset:()=>vf,base64urlCharset:()=>Jl,canParseURL:()=>Sv,clone:()=>tt,compile:()=>L$,compileFn:()=>Ff,config:()=>xt,createStandardJSONSchemaMethod:()=>La,createToJSONSchemaMethod:()=>I0,decode:()=>P2,decodeAsync:()=>E2,describe:()=>k0,encode:()=>I2,encodeAsync:()=>j2,extractDefs:()=>Jo,finalize:()=>Go,flattenError:()=>Nl,formatError:()=>Ml,getDiscriminatedOption:()=>u$,globalConfig:()=>qt,globalRegistry:()=>Wt,handleUnrepresentable:()=>At,initializeContext:()=>Ho,isBackEdge:()=>Of,isRecursiveSchema:()=>Af,isValidBase64:()=>Hl,isValidBase64URL:()=>$f,isValidCIDRv6:()=>wf,isValidCreditCard:()=>xf,isValidIBAN:()=>_f,isValidIPv6:()=>Bl,isValidJWT:()=>kf,locales:()=>ru,memoizer:()=>tu,mergeValues:()=>ka,meta:()=>S0,parse:()=>Jd,parseAsync:()=>Gd,parseURLObject:()=>Bz,prettifyError:()=>gw,process:()=>rt,processSchema:()=>rt,regexes:()=>Xn,registry:()=>Uf,safeDecode:()=>C2,safeDecodeAsync:()=>O2,safeEncode:()=>T2,safeEncodeAsync:()=>A2,safeParse:()=>_2,safeParseAsync:()=>k2,standardProps:()=>hf,stripTabAndNewline:()=>Wl,toDotPath:()=>Sz,toJSONSchema:()=>os,toZod:()=>Sl,treeifyError:()=>hw,urlHostnameOk:()=>yf,urlProtocolOk:()=>bf,util:()=>oe,validate:()=>Dl,validateAsync:()=>ql,validateURL:()=>gf,version:()=>wv,withParser:()=>Lf});var oe={};ro(oe,{BIGINT_FORMAT_RANGES:()=>jl,CONSTANT_CATCH:()=>Bd,Class:()=>tw,NUMBER_FORMAT_RANGES:()=>Pl,aborted:()=>un,allowsEval:()=>ow,assert:()=>VM,assertEqual:()=>qM,assertIs:()=>LM,assertNever:()=>FM,assertNotEqual:()=>UM,assignProp:()=>Zt,attachSchema:()=>El,base64ToUint8Array:()=>wz,base64urlToUint8Array:()=>c2,cached:()=>ha,captureStackTrace:()=>Zd,cleanEnum:()=>a2,cleanRegex:()=>io,clone:()=>tt,cloneDef:()=>BM,codePointLength:()=>Hi,constantCatch:()=>lw,createTransparentProxy:()=>YM,defineLazy:()=>nw,defineLazyInternal:()=>Ve,derived:()=>d2,esc:()=>ln,escapeRegex:()=>Kn,explicitlyAborted:()=>aw,extend:()=>t2,finalizeIssue:()=>$n,floatSafeRemainder:()=>zl,getElementAtPath:()=>HM,getEnumValues:()=>fa,getLengthableOrigin:()=>Cl,getParsedType:()=>XM,getSizableOrigin:()=>Tl,hexToUint8Array:()=>u2,hide:()=>Al,installLazyProp:()=>g2,isObject:()=>Bi,isPlainObject:()=>Gn,issue:()=>ba,joinValues:()=>K,jsonStringifyReplacer:()=>pa,members:()=>cw,merge:()=>r2,mergeDefs:()=>pr,normalizeParams:()=>he,nullish:()=>Vd,numKeys:()=>KM,objectClone:()=>ZM,omit:()=>e2,optionalKeys:()=>sw,own:()=>Fo,parsedType:()=>se,partial:()=>o2,pick:()=>QM,prefixIssues:()=>vn,primitiveTypes:()=>iw,promiseAllObject:()=>JM,propertyKeyTypes:()=>Il,randomString:()=>GM,rawShape:()=>ga,required:()=>i2,safeExtend:()=>n2,shallowClone:()=>Rl,sizeCaps:()=>ya,slugify:()=>rw,stringifyPrimitive:()=>ie,toZod:()=>Sl,uint8ArrayToBase64:()=>vz,uint8ArrayToBase64url:()=>l2,uint8ArrayToHex:()=>m2,unwrapMessage:()=>da});function qM(e){return e}function UM(e){return e}function Sl(){return e=>e}function LM(e){}function FM(e){throw new Error("Unexpected value in exhaustive check")}function VM(e){}function fa(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 pa(e,t){return typeof t=="bigint"?t.toString():t}var ew=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 ha(e){return new ew(e)}function Vd(e){return e==null}function io(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function zl(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 hz=Symbol("evaluating");function nw(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==hz)return o===void 0&&(o=hz,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ZM(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Zt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ga(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function oo(e){return ga(e._zod.def)??e._zod.def.shape}function gz(e,t,r){Object.defineProperty(e,t,{get(){let o=r();return Zt(this,t,o),o},enumerable:!0,configurable:!0})}function yz(e,t,r){t in e?Zt(e,t,r):e[t]=r}function Wi(e,t,r,o){let n=oo(t);for(let i of r){let s=Object.getOwnPropertyDescriptor(n,i);s.enumerable&&(s.get?gz(e,i,()=>{let a=t._zod.def.shape[i];return o?o(a,i):a}):yz(e,i,o?o(s.value,i):s.value))}}function WM(e,t){for(let r of Reflect.ownKeys(t)){let o=Object.getOwnPropertyDescriptor(t,r);o.enumerable&&(o.get?gz(e,r,()=>t[r]):yz(e,r,o.value))}}function pr(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function BM(e){return pr(e._zod.def)}function HM(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function JM(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 GM(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 rw(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Zd="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Bi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ow=ha(()=>{if(qt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Gn(e){if(Bi(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Bi(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Rl(e){return Gn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function KM(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var XM=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}`)}},Il=new Set(["string","number","symbol"]),iw=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Kn(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 YM(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 sw(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Pl={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]},jl={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function QM(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 Wi(i,e,Wd(e,t)),tt(e,pr(r,{shape:i,checks:[]}))}function Wd(e,t){let r=oo(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 e2(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(Wd(e,t)),s={};return Wi(s,e,Reflect.ownKeys(oo(e)).filter(a=>!i.has(a))),tt(e,pr(r,{shape:s,checks:[]}))}function t2(e,t){if(!Gn(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=oo(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,pr(e._zod.def,{shape:bz(e,t)}))}function bz(e,t){let r={};return Wi(r,e,Reflect.ownKeys(oo(e))),WM(r,t),r}function n2(e,t){if(!Gn(t))throw new Error("Invalid input to safeExtend: expected a plain object");return tt(e,pr(e._zod.def,{shape:bz(e,t)}))}function r2(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={};Wi(r,e,Reflect.ownKeys(oo(e))),Wi(r,t,Reflect.ownKeys(oo(t)));let o=pr(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return tt(e,o)}function o2(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(Wd(t,r)):void 0,c={};return Wi(c,t,Reflect.ownKeys(oo(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),tt(t,pr(t._zod.def,{shape:c,checks:[]}))}function i2(e,t,r){let o=r?new Set(Wd(t,r)):void 0,n={};return Wi(n,t,Reflect.ownKeys(oo(t)),(i,s)=>o&&!o.has(s)?i:new e({type:"nonoptional",innerType:i})),tt(t,pr(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 aw(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 vn(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function da(e){return typeof e=="string"?e:e?.message}function ya(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 El(e,t,r){var o;for(let n=t;n<e.length;n++)(o=e[n]).schema??(o.schema=r)}function $n(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:da(e.inst?._zod.def?.error?.(e))??da(i?.(e))??da(t?.error?.(e))??da(r.customError?.(e))??da(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 Tl(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var s2=/[\uD800-\uDBFF]/;function Hi(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 Cl(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 ba(...e){let[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function a2(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function wz(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 vz(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function c2(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return wz(t+r)}function l2(e){return vz(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function u2(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 m2(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var tw=class{constructor(...t){}};function cw(e,t){for(let r in t){let o=Object.getOwnPropertyDescriptor(t,r);o.get?Object.defineProperty(e,r,{...o,enumerable:!1}):f2(e,r,o.value)}}function Fo(e,t,r,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:r}),r}function Al(e,t,r){return Fo(e,t,r,!1)}function d2(e,t){for(let r in e){let o=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Fo(this,r,o(this))},set(n){Fo(this,r,n)}})}return t}function f2(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Fo(this,t,r.bind(this))},set(o){Fo(this,t,o)}})}function p2(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Qb,Lo=!1,h2={configurable:!0,get(){Lo=!0}};function Ve(e,t,r){let o=Object.getPrototypeOf(e._zod);if(t in o&&Qb!==e._zod){Qb=void 0;return}Qb=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,h2);let n=Lo;Lo=!1;try{let i=r(this);return Lo?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),Lo=Lo||n,i}catch(i){throw delete this[t],Lo=Lo||n,i}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function g2(e,t,r,o){let n=p2(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 Bd="~constantCatch";function lw(e){let t=()=>e;return t[Bd]=!0,t}var $z,Ol=Object.freeze({status:"aborted"}),uw={value:void 0,enumerable:!1},xz="captureStackTrace"in Error?Error:null;function y2(e){let t=xz;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return xz=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{uw.value=new i(f);try{Object.defineProperty(d,"_zod",uw)}finally{uw.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),cw(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?y2(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 mw=Symbol("zod_brand"),xn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Vo=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};($z=globalThis).__zod_globalConfig??($z.__zod_globalConfig={});var qt=globalThis.__zod_globalConfig;function xt(e){return e&&Object.assign(qt,e),qt}function b2(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,pa,2)),e.message}function w2(e){this._zod.message=e}var v2={get:b2,set:w2,enumerable:!0,configurable:!0},fw={value:void 0,enumerable:!1},_z=new WeakSet([Object.prototype,Error.prototype]),kz=(e,t)=>{e.name="$ZodError",fw.value=t,Object.defineProperty(e,"issues",fw),fw.value=void 0,Object.defineProperty(e,"message",v2);let r=Object.getPrototypeOf(e);_z.has(r)||(_z.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})}}))},pw=G("$ZodError",kz),_n=G("$ZodError",kz,void 0,{Parent:Error});function $2(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 Nl(e,t=r=>r.message){let r={},o=[];for(let n of e.issues)n.path.length>0?$2(r,n.path[0],()=>[]).push(t(n)):o.push(t(n));return{formErrors:o,fieldErrors:r}}function Ml(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 hw(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 Sz(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 gw(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 ${Sz(o.path)}`);return t.join(`
4
+ `)}function Hd(e,t){return{callee:t?.callee??e,Err:t?.Err}}var wa=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 xn;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map(l=>$n(l,s,xt())));throw Zd(c,i?.callee??t),c}return a.value};return t},Jd=wa(_n),va=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=>$n(l,s,xt())));throw Zd(c,i?.callee??t),c}return a.value};return t},Gd=va(_n),$a=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 xn;return i.issues.length?zz(e,i.issues,n):{success:!0,data:i.value}},_2=$a(_n);function zz(e,t,r){let o;return{success:!1,get error(){return o||(o=new e(t.map(n=>$n(n,r,xt()))),t=void 0,r=void 0),o},set error(n){o=n,t=void 0,r=void 0}}}var xa=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?zz(e,i.issues,n):{success:!0,data:i.value}},k2=xa(_n),S2=Symbol.for("zod.compile.invalid"),z2=Symbol.for("zod.compile.fallback"),Dl=((e,t,r)=>{let o=e._zod.bag.validator;if(o!==void 0){if(o(t)!==S2)return!0;if(o.definite===!0&&r===void 0)return!1}return R2(e,t,r)});function R2(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 xn;return i.issues.length===0}var ql=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},Kd=e=>{let t=wa(e),r=(o,n,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(o,n,a,Hd(r,s))};return r},I2=Kd(_n),Xd=e=>{let t=wa(e),r=(o,n,i,s)=>t(o,n,i,Hd(r,s));return r},P2=Xd(_n),Yd=e=>{let t=va(e),r=async(o,n,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(o,n,a,Hd(r,s))};return r},j2=Yd(_n),Qd=e=>{let t=va(e),r=async(o,n,i,s)=>await t(o,n,i,Hd(r,s));return r},E2=Qd(_n),ef=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return $a(e)(t,r,n)},T2=ef(_n),tf=e=>(t,r,o)=>$a(e)(t,r,o),C2=tf(_n),nf=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return xa(e)(t,r,n)},A2=nf(_n),rf=e=>async(t,r,o)=>xa(e)(t,r,o),O2=rf(_n);var Xn={};ro(Xn,{anyString:()=>Vw,base64:()=>Aw,base64url:()=>Ow,bigint:()=>Ww,boolean:()=>Bw,browserEmail:()=>V2,cidrv4:()=>Tw,cidrv6:()=>Cw,creditCard:()=>of,cuid:()=>bw,cuid2:()=>ww,currencyCode:()=>qw,date:()=>Uw,datetime:()=>Fw,domain:()=>Mw,duration:()=>Sw,e164:()=>Dw,email:()=>Rw,emoji:()=>Iw,extendedDuration:()=>N2,guid:()=>zw,hex:()=>Xw,hostname:()=>Nw,html5Email:()=>U2,httpProtocol:()=>Ul,iban:()=>sf,idnEmail:()=>F2,integer:()=>Ll,ipv4:()=>Pw,ipv6:()=>jw,ksuid:()=>xw,lowercase:()=>Gw,mac:()=>Ew,md5_base64:()=>H2,md5_base64url:()=>J2,md5_hex:()=>B2,nanoid:()=>_w,nanoidOfLength:()=>kw,null:()=>Hw,number:()=>so,rfc5322Email:()=>L2,sha1_base64:()=>K2,sha1_base64url:()=>X2,sha1_hex:()=>G2,sha256_base64:()=>Q2,sha256_base64url:()=>eD,sha256_hex:()=>Y2,sha384_base64:()=>nD,sha384_base64url:()=>rD,sha384_hex:()=>tD,sha512_base64:()=>iD,sha512_base64url:()=>sD,sha512_hex:()=>oD,string:()=>Zw,time:()=>Lw,ulid:()=>vw,undefined:()=>Jw,unicodeEmail:()=>Rz,uppercase:()=>Kw,uuid:()=>Ji,uuid4:()=>M2,uuid6:()=>D2,uuid7:()=>q2,xid:()=>$w});var bw=/^[cC][0-9a-z]{6,}$/,ww=/^[0-9a-z]+$/,vw=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,$w=/^[0-9a-vA-V]{20}$/,xw=/^[A-Za-z0-9]{27}$/,_w=/^[a-zA-Z0-9_-]{21}$/;function kw(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Sw=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,N2=/^[-+]?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)?)??$/,zw=/^([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})$/,Ji=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)$/,M2=Ji(4),D2=Ji(6),q2=Ji(7),Rw=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,U2=/^[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])?)*$/,L2=/^(([^<>()\[\]\\.,;:\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,}))$/,Rz=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,F2=Rz,V2=/^[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])?)*$/,Z2="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Iw(){return new RegExp(Z2,"u")}var Pw=/^(?:(?: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])$/,jw=/^(([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}|:))$/,Ew=e=>{let t=Kn(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Tw=/^((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])$/,Cw=/^(([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])$/,Aw=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ow=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Nw=/^(?=.{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])?)*\.?$/,Mw=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,Ul=/^https?$/,Dw=/^\+[1-9]\d{6,14}$/,of=/^\d(?:[ -]?\d){11,18}$/,qw=/^(?: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)$/,sf=/^[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 W2(e){return new RegExp(`^${e}$`)}var Uw=W2(Iz);function yw(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 Lw(e){return new RegExp(`^${yw(e)}$`)}function Fw(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${yw({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,o=e.local?`${r}|${yw({precision:e.precision})}`:r;return new RegExp(`^${Iz}T(?:${o})$`)}var Vw=/^[\s\S]{0,}$/,Zw=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ww=/^-?\d+n?$/,Ll=/^-?\d+$/,so=/^-?\d+(?:\.\d+)?$/,Bw=/^(?:true|false)$/i,Hw=/^null$/i;var Jw=/^undefined$/i;var Gw=/^[^A-Z]*$/,Kw=/^[^a-z]*$/,Xw=/^[0-9a-fA-F]*$/;function Fl(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Vl(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var B2=/^[0-9a-fA-F]{32}$/,H2=Fl(22,"=="),J2=Vl(22),G2=/^[0-9a-fA-F]{40}$/,K2=Fl(27,"="),X2=Vl(27),Y2=/^[0-9a-fA-F]{64}$/,Q2=Fl(43,"="),eD=Vl(43),tD=/^[0-9a-fA-F]{96}$/,nD=Fl(64,""),rD=Vl(64),oD=/^[0-9a-fA-F]{128}$/,iD=Fl(86,"=="),sD=Vl(86);var lt=G("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Yw=e=>{let t=e.value;return!Vd(t)&&t.size!==void 0},Qw=e=>{let t=e.value;return!Vd(t)&&t.length!==void 0},af={number:"number",bigint:"bigint",object:"date"},lf=G("$ZodCheckLessThan",(e,t)=>{lt.init(e,t);let r=af[typeof t.value];e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:af[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})}}),uf=G("$ZodCheckGreaterThan",(e,t)=>{lt.init(e,t);let r=af[typeof t.value];e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:af[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})}}),ev=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):zl(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})}}),tv=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]=Pl[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})}}),nv=G("$ZodCheckBigIntFormat",(e,t)=>{lt.init(e,t);let[r,o]=jl[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})}}),rv=G("$ZodCheckMaxSize",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Yw),e._zod.check=o=>{let n=o.value;n.size<=t.maximum||o.issues.push({origin:Tl(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ov=G("$ZodCheckMinSize",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Yw),e._zod.check=o=>{let n=o.value;n.size>=t.minimum||o.issues.push({origin:Tl(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),iv=G("$ZodCheckSizeEquals",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Yw),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:Tl(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})}}),sv=G("$ZodCheckMaxLength",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Qw),e._zod.check=o=>{let n=o.value,i=n.length;if((typeof n=="string"&&i>t.maximum?Hi(n):i)<=t.maximum)return;let a=Cl(n);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),av=G("$ZodCheckMinLength",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Qw),e._zod.check=o=>{let n=o.value,i=n.length;if((typeof n=="string"&&i>=t.minimum&&i<t.minimum*2?Hi(n):i)>=t.minimum)return;let a=Cl(n);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),cv=G("$ZodCheckLengthEquals",(e,t)=>{var r;lt.init(e,t),(r=e._zod.def).when??(r.when=Qw),e._zod.check=o=>{let n=o.value,i=n.length,s=typeof n=="string"&&i>=t.length&&i<=t.length*2?Hi(n):i;if(s===t.length)return;let a=Cl(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})}}),_a=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=()=>{})}),lv=G("$ZodCheckRegex",(e,t)=>{_a.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})}}),uv=G("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Gw),_a.init(e,t)}),mv=G("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Kw),_a.init(e,t)}),dv=G("$ZodCheckIncludes",(e,t)=>{lt.init(e,t);let r=Kn(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})}}),fv=G("$ZodCheckStartsWith",(e,t)=>{lt.init(e,t);let r=new RegExp(`^${Kn(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})}}),pv=G("$ZodCheckEndsWith",(e,t)=>{lt.init(e,t);let r=new RegExp(`.*${Kn(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 cf(e,t,r){e.issues.length&&t.issues.push(...vn(r,e.issues))}var hv=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=>cf(n,r,t.property));cf(o,r,t.property)}}),gv=G("$ZodCheckProperties",(e,t)=>{lt.init(e,t),Al(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=>cf(l,o,s)))):cf(c,o,s)}if(i)return Promise.all(i).then(()=>{})}}),yv=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})}}),bv=G("$ZodCheckOverwrite",(e,t)=>{lt.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Gi=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 wv={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=wv;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(aw(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 xn;if(m||p instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(El(a.issues,f,e),u||(u=un(a,f)))});else{if(a.issues.length===f)continue;El(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 xn;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 xn;return l.then(u=>i(u,n,c))}return i(l,n,c)}}},{get"~standard"(){return Al(this,"~standard",hf(this))},set"~standard"(e){Fo(this,"~standard",e)}}),Wz=(e,t)=>e.issues.length?{issues:e.issues.map(r=>$n(r,t,xt()))}:{value:e.value};async function aD(e,t){let r={async:!0};return Wz(await e._zod.run({value:t,issues:[]},r),r)}function hf(e){return{validate:t=>{let r={async:!1};try{let o=e._zod.run({value:t,issues:[]},r);if(!(o instanceof Promise))return Wz(o,r)}catch{}return aD(e,t)},vendor:"zod",version:1}}var Ki=G("$ZodString",(e,t)=>{Ne.init(e,t),e._zod.pattern=t.pattern??Vw,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)=>{_a.init(e,t),Ki.init(e,t)}),$v=G("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=zw),nt.init(e,t)}),xv=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=Ji(o))}else t.pattern??(t.pattern=Ji());nt.init(e,t)}),_v=G("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Rw),nt.init(e,t)}),kv=1,Zl=2;function Sv(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function gf(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Sv(e)||Zl:Bz(e,t)}function Bz(e,t){if(!t.normalize&&t.protocol?.source===Ul.source&&!/^https?:\/\//i.test(e))return kv;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Zl}return new URL(e)}catch{return Zl}}var cD=/[\t\n\r]/g;function Wl(e){return e.replace(cD,"")}function yf(e,t){return t.lastIndex=0,t.test(e.hostname)}function bf(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var zv=G("$ZodURL",(e,t)=>{nt.init(e,t),e._zod.check=r=>{try{let o=r.value.trim(),n=gf(o,t);if(n===kv){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(n===Zl){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(n===!0){r.value=Wl(o);return}t.hostname&&!yf(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&&!bf(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:Wl(o);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Rv=G("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Iw()),nt.init(e,t)}),Iv=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?_w:kw(t.length)),nt.init(e,t)}),Pv=G("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=bw),nt.init(e,t)}),jv=G("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ww),nt.init(e,t)}),Ev=G("$ZodULID",(e,t)=>{t.pattern??(t.pattern=vw),nt.init(e,t)}),Tv=G("$ZodXID",(e,t)=>{t.pattern??(t.pattern=$w),nt.init(e,t)}),Cv=G("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=xw),nt.init(e,t)}),Av=G("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Fw(t)),nt.init(e,t)}),Ov=G("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Uw),nt.init(e,t)}),Nv=G("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Lw(t)),nt.init(e,t)}),Mv=G("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Sw),nt.init(e,t)}),Dv=G("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Pw),nt.init(e,t)}),lD=/^[0-9a-fA-F:.]+$/;function Bl(e){return lD.test(e)?Sv(`http://[${e}]`):!1}var qv=G("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=jw),nt.init(e,t),e._zod.check=r=>{Bl(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}),Uv=G("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Ew(t.delimiter)),nt.init(e,t)}),Lv=G("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Tw),nt.init(e,t)});function wf(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:Bl(r)}var Fv=G("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Cw),nt.init(e,t),e._zod.check=r=>{wf(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Hl(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var vf=/^[0-9a-zA-Z+/]*={0,2}$/,Vv=G("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=vf),nt.init(e,t),e._zod.check=r=>{Hl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Jl=/^[A-Za-z0-9_-]*$/;function $f(e){if(!Jl.test(e))return!1;let t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Hl(r)}var Zv=G("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Jl),nt.init(e,t),e._zod.check=r=>{$f(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Wv=G("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Dw),nt.init(e,t)}),uD=/[- ]/g;function mD(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 xf(e){return of.test(e)?mD(e.replace(uD,"")):!1}var Bv=G("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=of),nt.init(e,t),e._zod.check=r=>{xf(r.value)||r.issues.push({code:"invalid_format",format:"credit_card",input:r.value,inst:e,continue:!t.abort})}});function dD(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 _f(e){return sf.test(e)?dD(e):!1}var Hv=G("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=sf),nt.init(e,t),e._zod.check=r=>{_f(r.value)||r.issues.push({code:"invalid_format",format:"iban",input:r.value,inst:e,continue:!t.abort})}});function kf(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 Jv=G("$ZodJWT",(e,t)=>{nt.init(e,t),e._zod.check=r=>{kf(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Gv=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})}}),Sf=G("$ZodNumber",(e,t)=>{Ne.init(e,t),e._zod.pattern=so,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}}),Kv=G("$ZodNumberFormat",(e,t)=>{tv.init(e,t),Sf.init(e,t)}),Gl=G("$ZodBoolean",(e,t)=>{Ne.init(e,t),e._zod.pattern=Bw,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}}),zf=G("$ZodBigInt",(e,t)=>{Ne.init(e,t),e._zod.pattern=Ww,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}}),Xv=G("$ZodBigIntFormat",(e,t)=>{nv.init(e,t),zf.init(e,t)}),Yv=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}}),Qv=G("$ZodUndefined",(e,t)=>{Ne.init(e,t),e._zod.pattern=Jw,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}}),e$=G("$ZodNull",(e,t)=>{Ne.init(e,t),e._zod.pattern=Hw,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}}),t$=G("$ZodAny",(e,t)=>{Ne.init(e,t),e._zod.parse=r=>r}),n$=G("$ZodUnknown",(e,t)=>{Ne.init(e,t),e._zod.parse=r=>r}),r$=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)}),o$=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}}),i$=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 s$(e,t){let r=ya(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 ya(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,El(i.issues,u,e),i}}return n(i,s)}}var fD=e=>Array.isArray(e)?e.length:-1,pD=e=>e instanceof Map?e.size:-1,hD=e=>e instanceof Set?e.size:-1;function jz(e,t,r){e.issues.length&&t.issues.push(...vn(r,e.issues)),t.value[r]=e.value}var a$=G("$ZodArray",(e,t)=>{Ne.init(e,t);let r=qt.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=>jz(m,o,c)));else if(jz(u,o,c),a&&u.issues.length!==0&&un(u))break}return s.length?Promise.all(s).then(()=>o):o},s$(e,fD)});function pf(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(...vn(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 gD=[];function Hz(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),o=r.length?r:gD,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=sw(e.shape);return{...e,allKeys:n,symbolKeys:o,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Jz(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=>pf(g,r,p,t,m,d))):pf(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 Gz=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=ha(()=>Hz(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)||Zt(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=Bi,s=t.catchall,a,c=qt.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(k=>pf(k,l,g,m,y,w))):pf(v,l,g,m,y,w)}return s?Jz(d,m,l,u,n.value,e,p===!0):d.length?Promise.all(d).then(()=>l):l}}),c$=G("$ZodObjectJIT",(e,t)=>{Gz.init(e,t);let r=e._zod.parse,o=ha(()=>Hz(t)),n=qt.memoizer,i=f=>{let p=o.value,h=p.symbolKeys,g=new Gi(["payload","ctx"],{shape:f,inst:e,memo:n,syms:h}),b=k=>`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`,y=(k,_)=>`
9
+ let ${k}_ab = false;
10
+ for (let i = 0; i < ${k}.issues.length; i++) {
11
+ const iss = ${k}.issues[i];
12
+ iss.path = iss.path ? [${_}, ...iss.path] : [${_}];
13
+ payload.issues.push(iss);
14
+ if (iss.continue !== true) ${k}_ab = true;
15
+ }
16
+ if (${k}_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 k of p.allKeys)w[k]=`key_${v++}`;g.write(n?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let k of p.allKeys){if(k==="__proto__")continue;let _=w[k],$=typeof k=="symbol"?`syms[${h.indexOf(k)}]`:ln(k),x=`${$} in input`,S=f[k],R=S?._zod?.optin,P=R!==void 0,j=S?._zod?.optout==="optional";if(g.write(`const ${_} = ${b($)};`),P&&j){let N=R==="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 P?(g.write(`
31
+ if (${_}.issues.length) {${y(_,$)}
32
+ }
33
+ `),R==="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=Bi,c=!qt.jitless,u=c&&ow.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?Jz([],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 Ez(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=>$n(s,o,xt())))}),t)}var Kl=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=>io(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=>Ez(a,o,e,n)):Ez(s,o,e,n)}});function Tz(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=>$n(s,o,xt())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1,matches:n}),t)}var l$=G("$ZodXor",(e,t)=>{Kl.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=>Tz(a,o,e,n)):Tz(s,o,e,n)}});function u$(e,t){let r=e._zod,o=r.bag.optionsMap;o||(o=Kz(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 Kz(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 m$=G("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Kl.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)||Zt(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=ga(n._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});let o=ha(()=>Kz(t));e._zod.parse=(n,i)=>{let s=n.value;if(!Bi(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)}}),d$=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])=>Cz(r,c,l)):Cz(r,i,s)}});function ka(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(Gn(e)&&Gn(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=ka(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=ka(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 Cz(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=ka(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 Rf=G("$ZodTuple",(e,t)=>{Ne.init(e,t);let r=t.items,o=qt.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=Az(r,"optin"),l=Az(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=>Oz(y,n,f))):Oz(b,n,f)}}return a.length?Promise.all(a).then(()=>Nz(u,n,r,s,l)):Nz(u,n,r,s,l)}});function Az(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 Oz(e,t,r){e.issues.length&&t.issues.push(...vn(r,e.issues)),t.value[r]=e.value}function Nz(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(...vn(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 f$=G("$ZodRecord",(e,t)=>{Ne.init(e,t);let r=qt.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let i=o.value;if(!Gn(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=>$n(p,n,xt())),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(...vn(u,p.issues)),o.value[d]=p.value})):(f.issues.length&&o.issues.push(...vn(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"&&so.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=>$n(p,n,xt())),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(...vn(l,p.issues)),o.value[d]=p.value})):(f.issues.length&&o.issues.push(...vn(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}}),p$=G("$ZodMap",(e,t)=>{Ne.init(e,t);let r=qt.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])=>{Mz(f,p,o,l,i,e,n)})):Mz(m,d,o,l,i,e,n)}return s.length?Promise.all(s).then(()=>o):o},s$(e,pD)});function Mz(e,t,r,o,n,i,s){e.issues.length&&(Il.has(typeof o)?r.issues.push(...vn(o,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:i,issues:e.issues.map(a=>$n(a,s,xt()))})),t.issues.length&&(Il.has(typeof o)?r.issues.push(...vn(o,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:i,key:o,issues:t.issues.map(a=>$n(a,s,xt()))})),r.value.set(e.value,t.value)}var h$=G("$ZodSet",(e,t)=>{Ne.init(e,t);let r=qt.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=>Dz(m,o))):Dz(u,o)}return s.length?Promise.all(s).then(()=>o):o},s$(e,hD)});function Dz(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var g$=G("$ZodEnum",(e,t)=>{Ne.init(e,t);let r=fa(t.entries),o=new Set(r);e._zod.values=o,Ve(e,"pattern",n=>{let i=fa(n.def.entries).filter(s=>Il.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>Kn(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}}),y$=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"?Kn(i):i?Kn(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}}),b$=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}}),w$=G("$ZodTransform",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",qt.memoizer?.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Vo(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 xn;return r.value=n,r}});function qz(e,t){return e.value=t.issues.length?void 0:t.value,e}var If=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(`^(${io(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=>qz(r,i)):qz(r,n)}return t.innerType._zod.run(r,o)}}),v$=G("$ZodExactOptional",(e,t)=>{If.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)}),$$=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(`^(${io(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)}),x$=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=>Uz(i,t)):Uz(n,t)}});function Uz(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var _$=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))}),k$=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=>Lz(i,e)):Lz(n,e)}});function Lz(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 S$=G("$ZodSuccess",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Vo("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 Fz(e,t,r,o){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(n=>$n(n,o,xt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var z$=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=>Fz(r,i,t,o)):Fz(r,n,t,o)}}),R$=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)}),Pf=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=>mf(s,t.in,o)):mf(i,t.in,o)}let n=t.in._zod.run(r,o);return n instanceof Promise?n.then(i=>mf(i,t.out,o)):mf(n,t.out,o)}});function mf(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 Xl=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=>df(s,t,o)):df(i,t,o)}else{let i=t.out._zod.run(r,o);return i instanceof Promise?i.then(s=>df(s,t,o)):df(i,t,o)}}});function df(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=>ff(e,i,t.out,r)):ff(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(i=>ff(e,i,t.in,r)):ff(e,n,t.in,r)}}function ff(e,t,r,o){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},o)}var I$=G("$ZodPreprocess",(e,t)=>{Pf.init(e,t)}),P$=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 yD(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 Zw({minimum:n,maximum:i}).source;let s=e._zod.pattern;return(o&&s===so?Ll:s)?.source}function vv(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=vv(o);return r&&n&&i&&i!==n?r.replace(io(n),()=>io(i)):r}if(t.options){let n=t.options.map(vv);if(n.every(Boolean))return`^(${n.map(i=>io(i)).join("|")})$`}return yD(e)}var j$=G("$ZodTemplateLiteral",(e,t)=>{Ne.init(e,t);let r=[];for(let o of t.parts)if(typeof o=="object"&&o!==null){let n=vv(o);if(!n)throw new Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);r.push(io(n))}else if(o===null||iw.has(typeof o))r.push(Kn(`${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)}),E$=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?Jd(e._def.input,o):o,i=Reflect.apply(r,this,n);return e._def.output?Jd(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 Gd(e._def.input,o):o,i=await Reflect.apply(r,this,n);return e._def.output?await Gd(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 Rf({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)),T$=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))}),Yl=G("$ZodLazy",(e,t)=>{Ne.init(e,t),nw(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)}),C$=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=>Zz(i,r,o,e));Zz(n,r,o,e)}});function Zz(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(ba(n))}}var Cf=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},O$="~memo",Yz=[];function Qz(e){return e!==null&&typeof e=="object"}function A$(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var eR=new WeakMap,Sa=0,Tf=1,Ql=2;function eu(e,t,r){let o=eR.get(e);if(o!==void 0)return o?Ql:Sa;if(t.has(e))return Ql;t.add(e);let n=Sa,i=u=>{if(n!==Ql&&u?._zod){let m=eu(u,t,r);m>n&&(n=m)}},s=(u,m)=>{let d=Sa;for(let f of Reflect.ownKeys(u)){let p=Object.getOwnPropertyDescriptor(u,f);if(m&&!p.enumerable)continue;let h=p.get?Tf:p.value?._zod?eu(p.value,t,r):Sa;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=ga(c);a(u?s(u,!0):Tf),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?eu(u,t,!1):Tf);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),bD(e,n)}function bD(e,t){return t!==Tf&&eR.set(e,t===Ql),t}function Af(e){return eu(e,new Set,!0)!==Sa}function wD(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var jf,Ef=[],vD={alloc(e,t,r){let o=jf;if(!o)return r;jf=void 0;let n={value:r,issues:null};return o.set(t.value,n),Ef.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"&&Of(i,n.value))throw new Cf;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=eu(e,new Set,!1);if(b===Sa)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,l);b===Ql||o?r=!0:o=!0}let u=c.value;if(!Qz(u))return s(c,l);let m=l[O$];m||(m={buckets:new WeakMap,backEdges:void 0},l[O$]=m);let d;n===l?d=i:(d=wD(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(...A$(f.issues)):(c.memo=!0,m.backEdges??(m.backEdges=new WeakSet),m.backEdges.add(f.value)),c;jf=d;let p=Ef.length,h=s(c,l);jf=void 0;let g=Ef.length>p?Ef.pop():void 0;return h instanceof Promise?h.then(b=>(g&&(g.issues=b.issues.length?A$(b.issues):Yz),b)):(g&&(g.issues=h.issues.length?A$(h.issues):Yz),h)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function tu(){return vD}function Of(e,t){let r=e[O$]?.backEdges;return r!==void 0&&Qz(t)&&r.has(t)}var ru={};ro(ru,{ar:()=>tR,az:()=>nR,be:()=>oR,bg:()=>iR,bn:()=>sR,ca:()=>aR,ckb:()=>cR,cs:()=>lR,da:()=>uR,de:()=>mR,el:()=>dR,en:()=>Nf,eo:()=>fR,es:()=>pR,fa:()=>hR,fi:()=>gR,fr:()=>yR,frCA:()=>bR,gu:()=>wR,he:()=>vR,hi:()=>$R,hr:()=>xR,hu:()=>_R,hy:()=>SR,id:()=>zR,is:()=>RR,it:()=>IR,ja:()=>PR,ka:()=>jR,kh:()=>ER,km:()=>Mf,kn:()=>TR,ko:()=>CR,lt:()=>OR,mk:()=>NR,ms:()=>MR,ne:()=>DR,nl:()=>qR,nn:()=>UR,no:()=>LR,ota:()=>FR,pl:()=>ZR,ps:()=>VR,pt:()=>WR,ptBR:()=>BR,ro:()=>HR,ru:()=>GR,sk:()=>KR,sl:()=>XR,sv:()=>YR,ta:()=>QR,tg:()=>eI,th:()=>tI,tk:()=>nI,tr:()=>rI,ua:()=>oI,uk:()=>Df,ur:()=>iI,uz:()=>sI,vi:()=>aI,yo:()=>uI,zhCN:()=>cI,zhTW:()=>lI});var $D=()=>{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 tR(){return{localeError:$D()}}var xD=()=>{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 nR(){return{localeError:xD()}}function rR(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 _D=()=>{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=rR(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=rR(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 oR(){return{localeError:_D()}}var kD=()=>{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 iR(){return{localeError:kD()}}var SD=()=>{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 sR(){return{localeError:SD()}}var zD=()=>{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 aR(){return{localeError:zD()}}var RD=()=>{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 cR(){return{localeError:RD()}}var ID=()=>{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 lR(){return{localeError:ID()}}var PD=()=>{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 uR(){return{localeError:PD()}}var jD=()=>{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 mR(){return{localeError:jD()}}var ED=()=>{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 dR(){return{localeError:ED()}}var TD=()=>{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 Nf(){return{localeError:TD()}}var CD=()=>{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 fR(){return{localeError:CD()}}var AD=()=>{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 pR(){return{localeError:AD()}}var OD=()=>{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 hR(){return{localeError:OD()}}var ND=()=>{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 gR(){return{localeError:ND()}}var MD=()=>{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 yR(){return{localeError:MD()}}var DD=()=>{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 bR(){return{localeError:DD()}}var qD=()=>{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 wR(){return{localeError:qD()}}var UD=()=>{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 vR(){return{localeError:UD()}}var LD=()=>{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 $R(){return{localeError:LD()}}var FD=()=>{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 xR(){return{localeError:FD()}}var VD=()=>{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 _R(){return{localeError:VD()}}function kR(e,t,r){return Math.abs(e)===1?t:r}function za(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 ZD=()=>{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=kR(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 ${za(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 ${za(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=kR(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 ${za(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 ${za(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 ${za(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 ${za(n.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function SR(){return{localeError:ZD()}}var WD=()=>{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 zR(){return{localeError:WD()}}var BD=()=>{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 RR(){return{localeError:BD()}}var HD=()=>{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:HD()}}var JD=()=>{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 PR(){return{localeError:JD()}}var GD=()=>{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 jR(){return{localeError:GD()}}var KD=()=>{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 Mf(){return{localeError:KD()}}function ER(){return Mf()}var XD=()=>{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 TR(){return{localeError:XD()}}var YD=()=>{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 CR(){return{localeError:YD()}}var nu=e=>e.charAt(0).toUpperCase()+e.slice(1);function AR(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 QD=()=>{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,AR(Number(n.maximum)),n.inclusive??!1,"smaller");if(s?.verb)return`${nu(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`${nu(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,AR(Number(n.minimum)),n.inclusive??!1,"bigger");if(s?.verb)return`${nu(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`${nu(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`${nu(i??n.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function OR(){return{localeError:QD()}}var eq=()=>{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 NR(){return{localeError:eq()}}var tq=()=>{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 MR(){return{localeError:tq()}}var nq=()=>{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 DR(){return{localeError:nq()}}var rq=()=>{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 qR(){return{localeError:rq()}}var oq=()=>{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 UR(){return{localeError:oq()}}var iq=()=>{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 LR(){return{localeError:iq()}}var sq=()=>{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 FR(){return{localeError:sq()}}var aq=()=>{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:aq()}}var cq=()=>{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 ZR(){return{localeError:cq()}}var lq=()=>{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 WR(){return{localeError:lq()}}var uq=()=>{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 BR(){return{localeError:uq()}}var mq=()=>{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 HR(){return{localeError:mq()}}function JR(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 dq=()=>{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=JR(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=JR(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 GR(){return{localeError:dq()}}var fq=()=>{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 KR(){return{localeError:fq()}}var pq=()=>{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 XR(){return{localeError:pq()}}var hq=()=>{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 YR(){return{localeError:hq()}}var gq=()=>{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 QR(){return{localeError:gq()}}var yq=()=>{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 eI(){return{localeError:yq()}}var bq=()=>{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 tI(){return{localeError:bq()}}var wq=()=>{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 nI(){return{localeError:wq()}}var vq=()=>{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 rI(){return{localeError:vq()}}var $q=()=>{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 Df(){return{localeError:$q()}}function oI(){return Df()}var xq=()=>{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 iI(){return{localeError:xq()}}var _q=()=>{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 sI(){return{localeError:_q()}}var kq=()=>{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 aI(){return{localeError:kq()}}var Sq=()=>{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 cI(){return{localeError:Sq()}}var zq=()=>{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 lI(){return{localeError:zq()}}var Rq=()=>{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 uI(){return{localeError:Rq()}}var mI,N$=Symbol("ZodOutput"),M$=Symbol("ZodInput"),qf=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 Uf(){return new qf}(mI=globalThis).__zod_globalRegistry??(mI.__zod_globalRegistry=Uf());var Wt=globalThis.__zod_globalRegistry;var mn=Symbol.for("zod.compile.invalid"),dI=Symbol.for("zod.compile.fallback"),hr=class extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}},We=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 Pq(e,t){try{return Ff(e,{assertOnly:!0})}catch{return t}}function L$(e,t){try{let r=Ff(e),o=Lf(e,r);return o._zod.bag.validator=Pq(e,r),o}catch(r){if(t?.strict)throw r;return e}}function Lf(e,t){if(Af(e))throw new We("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?.[dI]||a&&Of(a,s.value))return n(s,a);let c=t(s.value);return c!==mn?(s.value=c,s):(a&&(a[dI]=!0),n(s,a))};return i.__originalRun=n,r._zod.bag.fallbackRun=n,r._zod.bag.validator=t,r._zod.run=i,o.__originalRun||jq(r,e,t),r}function jq(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 Ff(e,t){let r=!0;try{r=Af(e)}catch{}if(r)throw new We("a schema whose subtree contains a reference cycle");let o={constants:new Map,constantCounter:0,varCounter:0,definite:!0},n=new Gi(["input"]),i=yt(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 We(`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 Yi(e,t){return e.definite=!1,Ae(e,t)}function Ee(e){return`v${e.varCounter++}`}function Eq(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 Yt(e,t,r,o,n=!0){let i=e.content.length,s=t.constants.size,a=t.constantCounter,c=t.varCounter;try{return yt(e,t,r,o,n)}catch(l){if(!(l instanceof We)||!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,Tq(e,t,r,o)}}function Tq(e,t,r,o){t.definite=!1;let n=Ae(t,r),i=Ae(t,Eq),s=Ee(t);return e.write(`const ${s} = ${i}(${n}, ${o});`),e.write(`if (${s} === INVALID) return INVALID;`),s}var Cq=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function Aq(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&&!Cq.has(a.check))throw new We('check with a custom "when" condition');switch(a.check){case"greater_than":Oq(e,t,a,i);break;case"less_than":Nq(e,t,a,i);break;case"multiple_of":Mq(e,t,a,i);break;case"number_format":bI(e,a,i);break;case"min_length":{let c=Zo(a.minimum,"min_length"),l=D$(e,t,i,`${i}.length >= ${c} && ${i}.length < ${a.minimum*2}`);e.write(`if (${l} < ${c}) return INVALID;`);break}case"max_length":{let c=Zo(a.maximum,"max_length"),l=D$(e,t,i,`${i}.length > ${c}`);e.write(`if (${l} > ${c}) return INVALID;`);break}case"length_equals":{let c=Zo(a.length,"length_equals"),l=D$(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 < ${Zo(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${i}.size > ${Zo(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${i}.size !== ${Zo(a.size,"size_equals")}) return INVALID;`);break;case"string_format":i=wI(e,t,a,i);break;case"custom":i=Vq(e,t,s,i);break;case"bigint_format":Dq(e,a,i);break;case"mime_type":qq(e,t,a,i);break;case"property":Lq(e,t,a,i);break;case"properties":Uq(e,t,a,i);break;case"overwrite":{let c=Ee(t);Fq(e,t,s,i,c),i=c;break}default:throw new We(`check type ${a.check}`)}}return i}function D$(e,t,r,o){let n=Ae(t,Hi),i=Ee(t);return e.write(`const ${i} = typeof ${r} === "string" && ${o} ? ${n}(${r}) : ${r}.length;`),i}function Zo(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new We(`${t} bound of type ${typeof e}`);return`${e}`}function yI(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new We("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new We("comparison check with Invalid Date bound");return Ae(e,t)}throw new We(`comparison check bound of type ${typeof t}`)}function Oq(e,t,r,o){let n=r.inclusive?"<":"<=";e.write(`if (${o} ${n} ${yI(t,r.value)}) return INVALID;`)}function Nq(e,t,r,o){let n=r.inclusive?">":">=";e.write(`if (${o} ${n} ${yI(t,r.value)}) return INVALID;`)}function Mq(e,t,r,o){if(typeof r.value=="bigint"){if(r.value===BigInt(0))throw new We("multiple_of check with a zero divisor");e.write(`if (${o} % ${r.value}n !== 0n) return INVALID;`)}else{let n=Ae(t,zl);e.write(`if (${n}(${o}, ${Zo(r.value,"multiple_of")}) !== 0) return INVALID;`)}}function bI(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 We(`number format ${o}`)}}function Dq(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 We(`bigint format ${o}`)}}function qq(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 Uq(e,t,r,o){if(r.when)throw new We('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}];`),Yt(e,t,n[i],a,!1)}}function Lq(e,t,r,o){let n=`${o}[${JSON.stringify(r.property)}]`;yt(e,t,r.schema,n)}function Fq(e,t,r,o,n){let i=r._zod.def.tx;if(!i)throw new We("overwrite check without a transform function");if(Qi(i))throw new hr("z.compile: async overwrite transforms are not supported");let s=Ae(t,i);e.write(`const ${n} = ${s}(${o});`)}function q$(){throw new xn}function F$(e){this.issues.push(e)}function Vq(e,t,r,o){let n=r._zod.def;if(n.fn){if(Qi(n.fn))throw new hr("z.compile: async .refine() predicates are not supported");let i=Yi(t,n.fn),s=Ae(t,q$),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(Qi(r._zod.check))throw new hr("z.compile: async .superRefine() / check functions are not supported");let i=r._zod.check,a=Yi(t,l=>{let u={value:l,issues:[],addIssue:F$};return i(u)instanceof Promise&&q$(),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 We("custom check without a predicate or check function")}var Zq=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 wI(e,t,r,o,n=!0){let i=r.format;if(i==="base64"){let l=Ae(t,Hl);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="base64url"){let l=Ae(t,$f);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="jwt"){let l=Ae(t,kf),u=Ae(t,r.alg??null);return e.write(`if (!${l}(${o}, ${u})) return INVALID;`),o}if(i==="ipv6"){let l=Ae(t,Bl);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="cidrv6"){let l=Ae(t,wf);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="credit_card"){let l=Ae(t,xf);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="iban"){let l=Ae(t,_f);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,gf),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,yf);e.write(`if (!${h}(${d}, ${u}.hostname)) return INVALID;`)}if(s.protocol!==void 0){let h=Ae(t,bf);e.write(`if (!${h}(${d}, ${u}.protocol)) return INVALID;`)}if(!n)return null;let f=Ee(t),p=s.normalize?`${d}.href`:`${Ae(t,Wl)}(${m})`;return e.write(`const ${f} = ${p};`),f}let a=r.fn;if(a){if(Qi(a))throw new We(`async string format ${i}`);let l=Ae(t,a);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(Zq.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 We("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 We(`string format ${c}`)}return o}function yt(e,t,r,o,n=!0){let i=r._zod.def,s=i.type;if(i.coerce)throw new We(`coercion (z.coerce.${s}())`);let a=n||!!i.checks?.length,c;switch(s){case"string":c=Wq(e,t,r,o,a);break;case"number":c=Bq(e,r,o);break;case"boolean":c=Hq(e,o);break;case"bigint":c=Jq(e,r,o);break;case"symbol":c=Gq(e,o);break;case"undefined":c=Kq(e,o);break;case"null":c=Xq(e,o);break;case"any":case"unknown":c=o;break;case"never":e.write("return INVALID;"),c=o;break;case"void":c=Yq(e,o);break;case"nan":c=Qq(e,o);break;case"date":c=e4(e,o);break;case"object":c=t4(e,t,r,o,a);break;case"optional":c=n4(e,t,r,o,a);break;case"nullable":c=i4(e,t,r,o,a);break;case"array":c=s4(e,t,r,o,a);break;case"literal":c=a4(e,t,r,o);break;case"enum":c=c4(e,t,r,o);break;case"readonly":{let l=pI(e,t,r,o),u=Ee(t);e.write(`const ${u} = Object.freeze(${l});`),c=u;break}case"success":pI(e,t,r,o),c="true";break;case"default":case"prefault":c=l4(e,t,r,o);break;case"nonoptional":c=u4(e,t,r,o);break;case"tuple":c=m4(e,t,r,o);break;case"union":c=d4(e,t,r,o);break;case"intersection":c=h4(e,t,r,o);break;case"record":c=g4(e,t,r,o);break;case"map":c=b4(e,t,r,o);break;case"set":c=w4(e,t,r,o);break;case"file":c=v4(e,o);break;case"template_literal":c=$4(e,t,r,o);break;case"lazy":c=x4(e,t,r,o);break;case"pipe":c=_4(e,t,r,o);break;case"custom":c=k4(e,t,r,o);break;case"transform":c=R4(e,t,r,o);break;case"catch":c=z4(e,t,r,o);break;default:throw new We(`schema type ${s}`)}return c===null?null:Aq(e,t,r,c)}function Wq(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:wI(e,t,i,o,n)}function Bq(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&&bI(e,{format:o.format},r),r}function Hq(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function Jq(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 Gq(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function Kq(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function Xq(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function Yq(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function Qq(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function e4(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function t4(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 We('object shape key "__proto__"');let f=new Map;for(let y of l){let w=d[y],v=u(y),k=Ee(t);if(e.write(`const ${k} = ${o}[${v}];`),w._zod.optin!==void 0){let _=Ee(t);e.write(`let ${_} = (() => {`),e.indented($=>{let x=Yt($,t,w,k);$.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{o4(w)&&e.write(`if (!(${v} in ${o})) return INVALID;`);let _=Yt(e,t,w,k,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=>fI(d[y])||U$(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];`),Yt(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);U$(d[y])?e.write(`if (${w} in ${o}) ${g}[${w}] = ${v};`):fI(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 k=Yt(w,t,p,v);w.write(`${g}[k] = ${k};`)}}),e.write("}")}return g}function n4(e,t,r,o,n=!0){let i=r._zod.def;if(r4(r))return yt(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=yt(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=yt(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=yt(a,t,i.innerType,o,n);s&&c!==null&&a.write(`${s} = ${c};`)}),e.write("}"),s}function r4(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function o4(e){return e._zod.optin===void 0&&Xi(e)}function Xi(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?Xi(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?Xi(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Xi):!0;case"intersection":return!t.left||!t.right?!0:Xi(t.left)&&Xi(t.right);case"pipe":return t.in?Xi(t.in):!0;default:return!0}}function U$(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function fI(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&Ra(e)}function Ra(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?Ra(t.innerType):!0;case"union":return t.options?t.options.some(Ra):!0;case"intersection":return!t.left||!t.right||Ra(t.left)||Ra(t.right);case"pipe":return t.out?Ra(t.out):!0;default:return!0}}function i4(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=yt(a,t,i.innerType,o,n);s&&c!==null&&a.write(`${s} = ${c};`)}),e.write("}"),s}function V$(e,t,r){for(let[o,n]of ya(t._zod.def.checks))e.write(`if (${r} > ${Zo(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;`),V$(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=Yt(l,t,i.element,c,n);s&&u!==null&&l.write(`${s}[${a}] = ${u};`)}),e.write("}"),s}function a4(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 We(`literal type ${typeof s}`);return o}function c4(e,t,r,o){let n=r._zod.values;if(!n)throw new We("enum schema without enumerated values");let i=Ae(t,n);return e.write(`if (!${i}.has(${o})) return INVALID;`),o}function pI(e,t,r,o){let n=r._zod.def;return yt(e,t,n.innerType,o)}function l4(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 yt(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}();`),yt(e,t,n.innerType,l)}let a=Ee(t);if(s){let c=Ae(t,s),l=Ae(t,Rl);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=yt(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=yt(c,t,n.innerType,o);c.write(`${a} = ${l};`)}),e.write("}");return a}function u4(e,t,r,o){let n=r._zod.def,i=yt(e,t,n.innerType,o),s=Ee(t);return e.write(`const ${s} = ${i};`),e.write(`if (${s} === undefined) return INVALID;`),s}function m4(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=hI(i,"optin"),c=hI(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=Yt(f,t,m,p);f.write(`${l}[${u}] = ${h};`)}),d.write("} else {"),d.indented(f=>{if(U$(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=Yt(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=Yt(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=Yt(d,t,s,m);d.write(`${l}[${u}] = ${f};`)}),e.write("}")}return l}function hI(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 d4(e,t,r,o){let n=r._zod.def,i=n.options;if(n.discriminator)return f4(e,t,n,o);if(n.inclusive===!1)throw new We("exclusive unions (z.xor)");if(i.length===0)return e.write("return INVALID;"),o;if(i.length===1)return yt(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=yt(u,t,l,o);u.write(`return ${m};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function f4(e,t,r,o){if(r.unionFallback)throw new We("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 We("discriminated union option without static discriminator values");for(let d of l){if(a.has(d))throw new We(`duplicate discriminator value ${String(d)}`);a.add(d)}let u=Array.from(l,d=>p4(t,n,d)),m=s?"if":"else if";e.write(`${m} (${u.join(" || ")}) {`),e.indented(d=>{let f=yt(d,t,c,o);d.write(`${i} = ${f};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),i}function p4(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 We(`literal discriminator value ${String(r)}`)}function h4(e,t,r,o){let n=r._zod.def;t.definite=!1;let i=Yt(e,t,n.left,o),s=Yt(e,t,n.right,o),a=Ae(t,ka),c=Ee(t);return e.write(`const ${c} = ${a}(${i}, ${s});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function g4(e,t,r,o){let n=r._zod.def,i=Ae(t,Gn);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 We(`record key value ${String(h)}`);let g=typeof h=="number"?h.toString():h;if(g==="__proto__")throw new We('record key "__proto__"');f.push(g);let b=Ae(t,h),y=yt(e,t,n.keyType,b),w=Ee(t);e.write(`const ${w} = ${o}[${y4(t,g)}];`);let v=Yt(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=Ff(n.keyType);p.definite===!1&&(t.definite=!1);let h=Ae(t,p),g=Ae(t,so),b=Ee(t);return gI(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=Yt(y,t,n.valueType,w);y.write(`${s}[${b}] = ${v};`)}),s}return gI(e,t,o,a,f=>{f.write(`const ${c} = ${o}[${a}];`);let p=Yt(f,t,n.valueType,c);f.write(`${s}[${a}] = ${p};`)},"return INVALID;"),s}function gI(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 y4(e,t){return typeof t=="string"?ln(t):Ae(e,t)}function b4(e,t,r,o){let n=r._zod.def;e.write(`if (!(${o} instanceof Map)) return INVALID;`),V$(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=yt(c,t,n.keyType,s),u=yt(c,t,n.valueType,a);c.write(`${i}.set(${l}, ${u});`)}),e.write("}"),i}function w4(e,t,r,o){let n=r._zod.def;e.write(`if (!(${o} instanceof Set)) return INVALID;`),V$(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=yt(a,t,n.valueType,s);a.write(`${i}.add(${c});`)}),e.write("}"),i}function v4(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function $4(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 x4(e,t,r,o){let n=r._zod.def,i=Yi(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 _4(e,t,r,o){let n=r._zod.def,i=yt(e,t,n.in,o);if(n.transform){if(Qi(n.transform))throw new hr("z.compile: async transforms in pipes are not supported");let s=n.transform,c=Yi(t,u=>{let m={value:u,issues:[],addIssue:F$},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;`),yt(e,t,n.out,l)}else return yt(e,t,n.out,i)}function Qi(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function k4(e,t,r,o){let n=r._zod.def;if(n.fn){if(Qi(n.fn))throw new hr("z.compile: async custom predicates are not supported");let i=Yi(t,n.fn),s=Ae(t,q$),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 We("custom schema without a predicate function");return o}function S4(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[Bd])throw new We("catch with a callback (only a constant catch value compiles)",!1);let i=Ee(t);e.write(`let ${i} = (() => {`),e.indented(l=>{let u=Yt(l,t,n.innerType,o);l.write(`return ${u};`)}),e.write("})();");let s=Ae(t,n.innerType),a=Yi(t,n.catchValue),c=Ae(t,S4);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 R4(e,t,r,o){let n=r._zod.def;if(n.transform){if(Qi(n.transform))throw new hr("z.compile: async transforms are not supported");let i=n.transform,a=Yi(t,l=>{let u={value:l,issues:[],addIssue:F$},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 Vf(e){return e.checks&&(e.checks=[...e.checks]),e}function Z$(e,t){return new e(Vf({type:"string",...he(t)}))}function W$(e,t){return new e(Vf({type:"string",coerce:!0,...he(t)}))}function Zf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...he(t)})}function Wf(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...he(t)})}function Bf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...he(t)})}function Hf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...he(t)})}function Jf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...he(t)})}function Gf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...he(t)})}function ou(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...he(t)})}function Kf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...he(t)})}function Xf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...he(t)})}function Yf(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...he(t)})}function Qf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...he(t)})}function ep(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...he(t)})}function tp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...he(t)})}function np(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...he(t)})}function rp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...he(t)})}function op(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...he(t)})}function B$(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...he(t)})}function ip(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...he(t)})}function sp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...he(t)})}function ap(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...he(t)})}function cp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...he(t)})}function lp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...he(t)})}function H$(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...he(t)})}function J$(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...he(t)})}function up(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...he(t)})}var G$={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function iu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...he(t)})}function su(e,t){return new e({type:"string",format:"date",check:"string_format",...he(t)})}function au(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...he(t)})}function cu(e,t){return new e({type:"string",format:"duration",check:"string_format",...he(t)})}function K$(e,t){return new e(Vf({type:"number",checks:[],...he(t)}))}function X$(e,t){return new e(Vf({type:"number",coerce:!0,checks:[],...he(t)}))}function Y$(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...he(t)})}function Q$(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...he(t)})}function e0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...he(t)})}function t0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...he(t)})}function n0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...he(t)})}function r0(e,t){return new e({type:"boolean",...he(t)})}function o0(e,t){return new e({type:"boolean",coerce:!0,...he(t)})}function i0(e,t){return new e({type:"bigint",...he(t)})}function s0(e,t){return new e({type:"bigint",coerce:!0,...he(t)})}function a0(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...he(t)})}function c0(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...he(t)})}function l0(e,t){return new e({type:"symbol",...he(t)})}function u0(e,t){return new e({type:"undefined",...he(t)})}function m0(e,t){return new e({type:"null",...he(t)})}function d0(e){return new e({type:"any"})}function f0(e){return new e({type:"unknown"})}function p0(e,t){return new e({type:"never",...he(t)})}function h0(e,t){return new e({type:"void",...he(t)})}function g0(e,t){return new e({type:"date",...he(t)})}function y0(e,t){return new e({type:"date",coerce:!0,...he(t)})}function b0(e,t){return new e({type:"nan",...he(t)})}function Tr(e,t){return new lf({check:"less_than",...he(t),value:e,inclusive:!1})}function Dn(e,t){return new lf({check:"less_than",...he(t),value:e,inclusive:!0})}function Cr(e,t){return new uf({check:"greater_than",...he(t),value:e,inclusive:!1})}function qn(e,t){return new uf({check:"greater_than",...he(t),value:e,inclusive:!0})}function mp(e){return Cr(0,e)}function dp(e){return Tr(0,e)}function fp(e){return Dn(0,e)}function pp(e){return qn(0,e)}function Wo(e,t){return new ev({check:"multiple_of",...he(t),value:e})}function Bo(e,t){return new rv({check:"max_size",...he(t),maximum:e})}function Ar(e,t){return new ov({check:"min_size",...he(t),minimum:e})}function es(e,t){return new iv({check:"size_equals",...he(t),size:e})}function ts(e,t){return new sv({check:"max_length",...he(t),maximum:e})}function ao(e,t){return new av({check:"min_length",...he(t),minimum:e})}function ns(e,t){return new cv({check:"length_equals",...he(t),length:e})}function Ia(e,t){return new lv({check:"string_format",format:"regex",...he(t),pattern:e})}function Pa(e){return new uv({check:"string_format",format:"lowercase",...he(e)})}function ja(e){return new mv({check:"string_format",format:"uppercase",...he(e)})}function Ea(e,t){return new dv({check:"string_format",format:"includes",...he(t),includes:e})}function Ta(e,t){return new fv({check:"string_format",format:"starts_with",...he(t),prefix:e})}function Ca(e,t){return new pv({check:"string_format",format:"ends_with",...he(t),suffix:e})}function hp(e,t,r){return new hv({check:"property",property:e,schema:t,...he(r)})}function Aa(e,t){return new gv({check:"properties",shape:e,...he(t)})}function Oa(e,t){return new yv({check:"mime_type",mime:e,...he(t)})}function gr(e){return new bv({check:"overwrite",tx:e})}function Na(e){return gr(t=>t.normalize(e))}function Ma(){return gr(e=>e.trim())}function Da(){return gr(e=>e.toLowerCase())}function qa(){return gr(e=>e.toUpperCase())}function Ua(){return gr(e=>rw(e))}function w0(e,t,r){return new e({type:"array",element:t,...he(r)})}function I4(e,t,r){return new e({type:"union",options:t,...he(r)})}function P4(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 E4(e,t,r){return new e({type:"intersection",left:t,right:r})}function T4(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 C4(e,t,r,o){return new e({type:"record",keyType:t,valueType:r,...he(o)})}function A4(e,t,r,o){return new e({type:"map",keyType:t,valueType:r,...he(o)})}function O4(e,t,r){return new e({type:"set",valueType:t,...he(r)})}function N4(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 M4(e,t,r){return new e({type:"enum",entries:t,...he(r)})}function D4(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...he(r)})}function v0(e,t){return new e({type:"file",...he(t)})}function q4(e,t){return new e({type:"transform",transform:t})}function U4(e,t){return new e({type:"optional",innerType:t})}function L4(e,t){return new e({type:"nullable",innerType:t})}function F4(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Rl(r)}})}function V4(e,t,r){return new e({type:"nonoptional",innerType:t,...he(r)})}function Z4(e,t){return new e({type:"success",innerType:t})}function W4(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:lw(r)})}function B4(e,t,r){return new e({type:"pipe",in:t,out:r})}function H4(e,t){return new e({type:"readonly",innerType:t})}function J4(e,t,r){return new e({type:"template_literal",parts:t,...he(r)})}function G4(e,t){return new e({type:"lazy",getter:t})}function K4(e,t){return new e({type:"promise",innerType:t})}function $0(e,t,r){let o=he(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function x0(e,t,r){return new e({type:"custom",check:"custom",fn:t,...he(r)})}function _0(e,t){let r=vI(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(ba(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(ba(i))}},e(o.value,o)),t);return r}function vI(e,t){let r=new lt({check:"custom",...he(t)});return r._zod.check=e,r}function k0(e){let t=new lt({check:"describe"});return t._zod.onattach=[r=>{let o=Wt.get(r)??{};Wt.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function S0(e){let t=new lt({check:"meta"});return t._zod.onattach=[r=>{let o=Wt.get(r)??{};Wt.add(r,{...o,...e})}],t._zod.check=()=>{},t}function z0(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??Xl,c=e.Boolean??Gl,l=e.String??Ki,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 rs(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 lu(e,...t){for(let r of t)for(let o of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,o)&&Zt(e,o,r[o]);return e}function Ho(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??Wt,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 At(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&&lu(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 $I(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Jo(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}/${$I(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+$I(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 kI(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;kI(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 SI=new Set(["type","properties","required","additionalProperties"]),xI=["oneOf","anyOf"];function _I(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function R0(e){let t=[];for(let i of e){if(typeof i!="object"||i.type!=="object")return null;for(let s in i)if(!SI.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]??_I(l);u!=null&&(a.some(m=>JSON.stringify(m)===JSON.stringify(u))||a.push(u))}let c=a.length===1?a[0]:R0(a)??{allOf:a};Zt(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=_I(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 X4(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of SI)if(n in e)return;let r=t.filter(n=>xI.some(i=>Array.isArray(n[i]))),o=null;if(!r.length)o=R0(t);else{let n=r[0],i=xI.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=>R0([...s,c]));if(a.some(c=>!c))return;o={[i]:a}}o&&(delete e.allOf,lu(e,o))}function Go(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)):lu(l,p),lu(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())kI(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)??[])X4(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)}lu(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,Zt(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:La(t,"input",e.processors),output:La(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 I0=(e,t={})=>r=>{let o=Ho({...r,processors:t});return rt(e,o),Jo(o,e),Go(o,e)},La=(e,t,r={})=>o=>{let{libraryOptions:n,target:i}=o??{},s=Ho({...n??{},target:i,io:t,processors:r});return rt(e,s),Jo(s,e),Go(s,e)};var Fa=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Va=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},zI=(e,t)=>{Fa(e,"minimum",t),Va(e,"maximum",t)},jI=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},EI=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},TI=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},CI=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},RI=(e,t)=>Fa(e,"minimum",t.minimum),II=(e,t)=>Va(e,"maximum",t.maximum),PI=e=>(t,r)=>{CI(t,r.format);let[o,n]=e[r.format];Fa(t,"minimum",o),Va(t,"maximum",n)},Y4={greater_than:(e,t)=>Fa(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Va(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>jI(e,t.value),number_format:PI(Pl),bigint_format:PI(jl),min_length:RI,max_length:II,length_equals:(e,t)=>zI(e,t.length),min_size:RI,max_size:II,size_equals:(e,t)=>zI(e,t.size),string_format:(e,t)=>{CI(e,t.format),t.pattern&&EI(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)=>TI(e,t.mime)};function Ot(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of o)Y4[i._zod.def.check]?.(t,i._zod.def);let n=e._zod.bag;n.minimum!==void 0&&Fa(t,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&Fa(t,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&Va(t,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&Va(t,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&jI(t,n.multipleOf),n.format!==void 0&&(t.format??(t.format=n.format),n.format.includes("int")&&(t.isInt=!0)),n.mime&&TI(t,n.mime);for(let i of n.patterns??[])EI(t,i);return t}var Q4={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},e6=new Map([[vf,Aw],[Jl,Ow]]),AI=e=>e6.get(e)??e,E0=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Ot(e);if(typeof i=="number"&&(n.minLength=i),typeof s=="number"&&(n.maxLength=s),a&&(n.format=Q4[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(AI);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}))])}},T0=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Ot(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)):At(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}))])}},C0=(e,t,r,o)=>{r.type="boolean"},A0=(e,t,r,o)=>{At(e,t,r,o,"BigInt cannot be represented in JSON Schema")},O0=(e,t,r,o)=>{At(e,t,r,o,"Symbols cannot be represented in JSON Schema")},N0=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},M0=(e,t,r,o)=>{At(e,t,r,o,"Undefined cannot be represented in JSON Schema")},D0=(e,t,r,o)=>{At(e,t,r,o,"Void cannot be represented in JSON Schema")},q0=(e,t,r,o)=>{r.not={}},U0=(e,t,r,o)=>{},L0=(e,t,r,o)=>{},F0=(e,t,r,o)=>{At(e,t,r,o,"Date cannot be represented in JSON Schema")},V0=(e,t,r,o)=>{let n=e._zod.def,i=fa(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},Z0=(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(At(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(At(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},W0=(e,t,r,o)=>{At(e,t,r,o,"NaN cannot be represented in JSON Schema")},B0=(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},H0=(e,t,r,o)=>{let n=r;n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=Ot(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})))},J0=(e,t,r,o)=>{r.type="boolean"},G0=(e,t,r,o)=>{At(e,t,r,o,"Custom types cannot be represented in JSON Schema")},K0=(e,t,r,o)=>{At(e,t,r,o,"Function types cannot be represented in JSON Schema")},X0=(e,t,r,o)=>{At(e,t,r,o,"Transforms cannot be represented in JSON Schema")},Y0=(e,t,r,o)=>{At(e,t,r,o,"Map cannot be represented in JSON Schema")},Q0=(e,t,r,o)=>{At(e,t,r,o,"Set cannot be represented in JSON Schema")},ex=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:a}=Ot(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 uu(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?uu(t.out):t.type==="catch"?uu(t.innerType):e._zod.optin}var tx=(e,t,r,o)=>{let n=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&At(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let l in s)Zt(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"?uu(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)},yp=(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},nx=(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)},rx=(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"?uu(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}=Ot(e);typeof f=="number"&&(n.minItems=f),typeof p=="number"&&(n.maxItems=p)};function P0(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=P0(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=>P0(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")?so:Ll).source)),f}var j0=new WeakMap;function t6(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 j0.get(e)??[]){let n=e.seen.get(o),i=(n?.def??n?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=P0(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 ox=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,a=Ot(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)Zt(n.patternProperties,AI(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=j0.get(t);u||(u=[],j0.set(t,u),t.deferred.push(()=>t6(t))),u.push(e)}n.additionalProperties=rt(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let c=s._zod.values,l=t.io==="input"&&uu(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))}},ix=(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"}]},sx=(e,t,r,o)=>{let n=e._zod.def;rt(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},ax=Symbol();function OI(e,t,r,o,n){let i=!1,s=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(i=!0,null));return i?(At(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),ax):JSON.parse(s)}var cx=(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=OI(n.defaultValue,e,t,r,o);s!==ax&&(r.default=s)},lx=(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=OI(n.defaultValue,e,t,r,o);s!==ax&&(r._prefault=s)},ux=(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{At(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},mx=(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},dx=(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},fx=(e,t,r,o)=>{let n=e._zod.def;rt(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},bp=(e,t,r,o)=>{let n=e._zod.def;rt(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},px=(e,t,r,o)=>{let n=e._zod.innerType;rt(n,t,o);let i=t.seen.get(e);i.ref=n},gp={string:E0,number:T0,boolean:C0,bigint:A0,symbol:O0,null:N0,undefined:M0,void:D0,never:q0,any:U0,unknown:L0,date:F0,enum:V0,literal:Z0,nan:W0,template_literal:B0,file:H0,success:J0,custom:G0,function:K0,transform:X0,map:Y0,set:Q0,array:ex,object:tx,union:yp,intersection:nx,tuple:rx,record:ox,nullable:ix,nonoptional:sx,default:cx,prefault:lx,catch:ux,pipe:mx,readonly:dx,promise:fx,optional:bp,lazy:px};function os(e,t){if("_idmap"in e){let o=e,n=Ho({...t,processors:gp}),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;Jo(n,u),Zt(s,l,Go(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=Ho({...t,processors:gp});return rt(e,r),Jo(r,e),Go(r,e)}var wp=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=Ho({processors:gp,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,Jo(this.ctx,t);let o=Go(this.ctx,t),{"~standard":n,...i}=o;return i}};var NI={};var Xa={};ro(Xa,{ZodAny:()=>Tx,ZodArray:()=>Nx,ZodBase64:()=>qp,ZodBase64URL:()=>Up,ZodBigInt:()=>Ka,ZodBigIntFormat:()=>Vp,ZodBoolean:()=>Ga,ZodCIDRv4:()=>Mp,ZodCIDRv6:()=>Dp,ZodCUID:()=>jp,ZodCUID2:()=>Ep,ZodCatch:()=>t_,ZodCodec:()=>wu,ZodCreditCard:()=>Rx,ZodCustom:()=>vu,ZodCustomStringFormat:()=>ss,ZodDate:()=>pu,ZodDefault:()=>Gx,ZodDiscriminatedUnion:()=>Dx,ZodE164:()=>Lp,ZodEmail:()=>Sp,ZodEmoji:()=>Ip,ZodEnum:()=>Wa,ZodExactOptional:()=>Hp,ZodFile:()=>Wx,ZodFunction:()=>u_,ZodGUID:()=>Rp,ZodIBAN:()=>Ix,ZodIPv4:()=>Op,ZodIPv6:()=>Np,ZodISODate:()=>Xo,ZodISODateTime:()=>Ko,ZodISODuration:()=>Qo,ZodISOTime:()=>Yo,ZodInstanceOf:()=>f_,ZodIntersection:()=>qx,ZodJWT:()=>Fp,ZodKSUID:()=>Ap,ZodLazy:()=>c_,ZodLiteral:()=>Zx,ZodMAC:()=>zx,ZodMap:()=>Fx,ZodNaN:()=>r_,ZodNanoID:()=>Pp,ZodNever:()=>Ax,ZodNonOptional:()=>Jp,ZodNull:()=>Ex,ZodNullable:()=>Jx,ZodNumber:()=>Ja,ZodNumberFormat:()=>as,ZodObject:()=>hu,ZodOptional:()=>yu,ZodPipe:()=>bu,ZodPrefault:()=>Xx,ZodPreprocess:()=>o_,ZodPromise:()=>l_,ZodReadonly:()=>i_,ZodRecord:()=>Za,ZodSet:()=>Vx,ZodString:()=>Ba,ZodStringFormat:()=>st,ZodSuccess:()=>e_,ZodSymbol:()=>Px,ZodTemplateLiteral:()=>a_,ZodTransform:()=>Bx,ZodTuple:()=>Ux,ZodType:()=>Fe,ZodULID:()=>Tp,ZodURL:()=>fu,ZodUUID:()=>Or,ZodUndefined:()=>jx,ZodUnion:()=>gu,ZodUnknown:()=>Cx,ZodVoid:()=>Ox,ZodXID:()=>Cp,ZodXor:()=>Mx,_ZodString:()=>kp,_default:()=>Kx,_function:()=>LP,any:()=>Zp,array:()=>te,base64:()=>rP,base64url:()=>oP,bigint:()=>bP,boolean:()=>xe,catch:()=>n_,check:()=>FP,cidrv4:()=>tP,cidrv6:()=>nP,codec:()=>MP,creditCard:()=>sP,cuid:()=>HI,cuid2:()=>JI,currencyCode:()=>dP,custom:()=>VP,date:()=>kP,describe:()=>ZP,discriminatedUnion:()=>ei,e164:()=>iP,email:()=>zp,emoji:()=>WI,enum:()=>Ce,exactOptional:()=>Hx,file:()=>CP,float32:()=>pP,float64:()=>hP,function:()=>LP,guid:()=>qI,hash:()=>fP,hex:()=>mP,hostname:()=>uP,httpUrl:()=>ZI,iban:()=>aP,instanceof:()=>BP,int:()=>xp,int32:()=>gP,int64:()=>wP,intersection:()=>yr,invertCodec:()=>DP,ipv4:()=>YI,ipv6:()=>eP,json:()=>JP,jwt:()=>cP,keyof:()=>SP,ksuid:()=>XI,lazy:()=>ti,literal:()=>ne,looseObject:()=>je,looseRecord:()=>PP,mac:()=>QI,map:()=>jP,meta:()=>WP,nan:()=>NP,nanoid:()=>BI,nativeEnum:()=>TP,never:()=>Wp,nonoptional:()=>Qx,null:()=>Nr,nullable:()=>du,nullish:()=>AP,number:()=>me,object:()=>J,optional:()=>Re,partialRecord:()=>IP,pipe:()=>_p,prefault:()=>Yx,preprocess:()=>lo,promise:()=>UP,readonly:()=>s_,record:()=>ve,refine:()=>m_,set:()=>EP,strictObject:()=>zP,string:()=>E,stringFormat:()=>lP,stringbool:()=>HP,success:()=>OP,superRefine:()=>d_,symbol:()=>$P,templateLiteral:()=>qP,transform:()=>Bp,tuple:()=>Lx,uint32:()=>yP,uint64:()=>vP,ulid:()=>GI,undefined:()=>xP,union:()=>_e,unknown:()=>Ie,url:()=>Ha,uuid:()=>UI,uuidv4:()=>LI,uuidv6:()=>FI,uuidv7:()=>VI,void:()=>_P,xid:()=>KI,xor:()=>RP});var vp={};ro(vp,{endsWith:()=>Ca,gt:()=>Cr,gte:()=>qn,includes:()=>Ea,length:()=>ns,lowercase:()=>Pa,lt:()=>Tr,lte:()=>Dn,maxLength:()=>ts,maxSize:()=>Bo,mime:()=>Oa,minLength:()=>ao,minSize:()=>Ar,multipleOf:()=>Wo,negative:()=>dp,nonnegative:()=>pp,nonpositive:()=>fp,normalize:()=>Na,overwrite:()=>gr,positive:()=>mp,properties:()=>Aa,property:()=>hp,regex:()=>Ia,size:()=>es,slugify:()=>Ua,startsWith:()=>Ta,toLowerCase:()=>Da,toUpperCase:()=>qa,trim:()=>Ma,uppercase:()=>ja});var MI=new WeakSet([Object.prototype,Error.prototype]);function $p(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 DI=(e,t)=>{pw.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);MI.has(r)||(MI.add(r),$p(r,"format",o=>n=>Ml(o,n)),$p(r,"flatten",o=>n=>Nl(o,n)),$p(r,"addIssue",o=>n=>{o.issues.push(n),o.message=JSON.stringify(o.issues,pa,2)}),$p(r,"addIssues",o=>n=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,pa,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},r6=G("ZodError",DI),kn=G("ZodError",DI,void 0,{Parent:Error});var hx=wa(kn),gx=va(kn),mu=$a(kn),yx=xa(kn),bx=Kd(kn),wx=Xd(kn),vx=Yd(kn),$x=Qd(kn),xx=ef(kn),_x=tf(kn),kx=nf(kn),Sx=rf(kn);function i6(){qt.localeError||xt(Nf())}function is(){qt.memoizer||xt({memoizer:tu()})}var Fe=G("ZodType",(e,t)=>(i6(),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(m_(e,t))},superRefine(e,t){return this.check(d_(e,t))},overwrite(e){return this.check(gr(e))},optional(){return Re(this)},exactOptional(){return Hx(this)},nullable(){return du(this)},nullish(){return Re(du(this))},nonoptional(e){return Qx(this,e)},array(){return te(this)},or(e){return _e([this,e])},and(e){return yr(this,e)},transform(e){return _p(this,Bp(e))},default(e){return Kx(this,e)},prefault(e){return Yx(this,e)},catch(e){return n_(this,e)},pipe(e){return _p(this,e)},readonly(){return s_(this)},describe(e){let t=this.clone();return Wt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Wt.get(this);let t=this.clone();return Wt.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",{...hf(this),jsonSchema:{input:La(this,"input"),output:La(this,"output")}})},set"~standard"(e){oe.own(this,"~standard",e)},parse:function e(t,r){return hx(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await gx(this,t,r,{callee:e})},safeParse(e,t){return mu(this,e,t)},async safeParseAsync(e,t){return yx(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){oe.own(this,"spa",e)},validate(e,t){return Dl(this,e,t)},validateAsync(e,t){return ql(this,e,t)},encode:function e(t,r){return bx(this,t,r,{callee:e})},decode:function e(t,r){return wx(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await vx(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await $x(this,t,r,{callee:e})},safeEncode(e,t){return xx(this,e,t)},safeDecode(e,t){return _x(this,e,t)},async safeEncodeAsync(e,t){return kx(this,e,t)},async safeDecodeAsync(e,t){return Sx(this,e,t)},toJSONSchema(e){return I0(this,{})(e)},get description(){return Wt.get(this)?.description},get _def(){return this._zod.def}}),kp=G("_ZodString",(e,t)=>{Ki.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>E0(e,r,o,n)},oe.derived({format:e=>Ot(e).format??null,minLength:e=>Ot(e).minimum??null,maxLength:e=>Ot(e).maximum??null},{regex(...e){return this.check(Ia(...e))},includes(...e){return this.check(Ea(...e))},startsWith(...e){return this.check(Ta(...e))},endsWith(...e){return this.check(Ca(...e))},min(...e){return this.check(ao(...e))},max(...e){return this.check(ts(...e))},length(...e){return this.check(ns(...e))},nonempty(...e){return this.check(ao(1,...e))},lowercase(e){return this.check(Pa(e))},uppercase(e){return this.check(ja(e))},trim(){return this.check(Ma())},normalize(...e){return this.check(Na(...e))},toLowerCase(){return this.check(Da())},toUpperCase(){return this.check(qa())},slugify(){return this.check(Ua())}})),Ba=G("ZodString",(e,t)=>{Ki.init(e,t),kp.init(e,t)},{email(e){return this.check(Zf(Sp,e))},url(e){return this.check(ou(fu,e))},jwt(e){return this.check(up(Fp,e))},emoji(e){return this.check(Kf(Ip,e))},guid(e){return this.check(Wf(Rp,e))},uuid(e){return this.check(Bf(Or,e))},uuidv4(e){return this.check(Hf(Or,e))},uuidv6(e){return this.check(Jf(Or,e))},uuidv7(e){return this.check(Gf(Or,e))},nanoid(e){return this.check(Xf(Pp,e))},cuid(e){return this.check(Yf(jp,e))},cuid2(e){return this.check(Qf(Ep,e))},ulid(e){return this.check(ep(Tp,e))},base64(e){return this.check(ap(qp,e))},base64url(e){return this.check(cp(Up,e))},xid(e){return this.check(tp(Cp,e))},ksuid(e){return this.check(np(Ap,e))},ipv4(e){return this.check(rp(Op,e))},ipv6(e){return this.check(op(Np,e))},cidrv4(e){return this.check(ip(Mp,e))},cidrv6(e){return this.check(sp(Dp,e))},e164(e){return this.check(lp(Lp,e))},datetime(e){return this.check(iu(Ko,e))},date(e){return this.check(su(Xo,e))},time(e){return this.check(au(Yo,e))},duration(e){return this.check(cu(Qo,e))}});function E(e){return Z$(Ba,e)}var st=G("ZodStringFormat",(e,t)=>{nt.init(e,t),kp.init(e,t)}),Ko=G("ZodISODateTime",(e,t)=>{Av.init(e,t),st.init(e,t)}),Xo=G("ZodISODate",(e,t)=>{Ov.init(e,t),st.init(e,t)}),Yo=G("ZodISOTime",(e,t)=>{Nv.init(e,t),st.init(e,t)}),Qo=G("ZodISODuration",(e,t)=>{Mv.init(e,t),st.init(e,t)}),Sp=G("ZodEmail",(e,t)=>{_v.init(e,t),st.init(e,t)});function zp(e){return Zf(Sp,e)}var Rp=G("ZodGUID",(e,t)=>{$v.init(e,t),st.init(e,t)});function qI(e){return Wf(Rp,e)}var Or=G("ZodUUID",(e,t)=>{xv.init(e,t),st.init(e,t)});function UI(e){return Bf(Or,e)}function LI(e){return Hf(Or,e)}function FI(e){return Jf(Or,e)}function VI(e){return Gf(Or,e)}var fu=G("ZodURL",(e,t)=>{zv.init(e,t),st.init(e,t)});function Ha(e){return ou(fu,e)}function ZI(e){return ou(fu,{protocol:Ul,hostname:Mw,...oe.normalizeParams(e)})}var Ip=G("ZodEmoji",(e,t)=>{Rv.init(e,t),st.init(e,t)});function WI(e){return Kf(Ip,e)}var Pp=G("ZodNanoID",(e,t)=>{Iv.init(e,t),st.init(e,t)});function BI(e){return Xf(Pp,e)}var jp=G("ZodCUID",(e,t)=>{Pv.init(e,t),st.init(e,t)});function HI(e){return Yf(jp,e)}var Ep=G("ZodCUID2",(e,t)=>{jv.init(e,t),st.init(e,t)});function JI(e){return Qf(Ep,e)}var Tp=G("ZodULID",(e,t)=>{Ev.init(e,t),st.init(e,t)});function GI(e){return ep(Tp,e)}var Cp=G("ZodXID",(e,t)=>{Tv.init(e,t),st.init(e,t)});function KI(e){return tp(Cp,e)}var Ap=G("ZodKSUID",(e,t)=>{Cv.init(e,t),st.init(e,t)});function XI(e){return np(Ap,e)}var Op=G("ZodIPv4",(e,t)=>{Dv.init(e,t),st.init(e,t)});function YI(e){return rp(Op,e)}var zx=G("ZodMAC",(e,t)=>{Uv.init(e,t),st.init(e,t)});function QI(e){return B$(zx,e)}var Np=G("ZodIPv6",(e,t)=>{qv.init(e,t),st.init(e,t)});function eP(e){return op(Np,e)}var Mp=G("ZodCIDRv4",(e,t)=>{Lv.init(e,t),st.init(e,t)});function tP(e){return ip(Mp,e)}var Dp=G("ZodCIDRv6",(e,t)=>{Fv.init(e,t),st.init(e,t)});function nP(e){return sp(Dp,e)}var qp=G("ZodBase64",(e,t)=>{Vv.init(e,t),st.init(e,t)});function rP(e){return ap(qp,e)}var Up=G("ZodBase64URL",(e,t)=>{Zv.init(e,t),st.init(e,t)});function oP(e){return cp(Up,e)}var Lp=G("ZodE164",(e,t)=>{Wv.init(e,t),st.init(e,t)});function iP(e){return lp(Lp,e)}var Rx=G("ZodCreditCard",(e,t)=>{Bv.init(e,t),st.init(e,t)});function sP(e){return H$(Rx,e)}var Ix=G("ZodIBAN",(e,t)=>{Hv.init(e,t),st.init(e,t)});function aP(e){return J$(Ix,e)}var Fp=G("ZodJWT",(e,t)=>{Jv.init(e,t),st.init(e,t)});function cP(e){return up(Fp,e)}var ss=G("ZodCustomStringFormat",(e,t)=>{Gv.init(e,t),st.init(e,t)});function lP(e,t,r={}){return rs(ss,e,t,r)}function uP(e){return rs(ss,"hostname",Nw,e)}function mP(e){return rs(ss,"hex",Xw,e)}function dP(e){return rs(ss,"currency_code",qw,e)}function fP(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Xn[o];if(!n)throw new Error(`Unrecognized hash format: ${o}`);return rs(ss,o,n,t)}var Ja=G("ZodNumber",(e,t)=>{Sf.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>T0(e,r,o,n),e.isFinite=!0},oe.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Ot(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Ot(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Ot(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Ot(e).format??null},{gt(e,t){return this.check(Cr(e,t))},gte(e,t){return this.check(qn(e,t))},min(e,t){return this.check(qn(e,t))},lt(e,t){return this.check(Tr(e,t))},lte(e,t){return this.check(Dn(e,t))},max(e,t){return this.check(Dn(e,t))},int(e){return this.check(xp(e))},safe(e){return this.check(xp(e))},positive(e){return this.check(Cr(0,e))},nonnegative(e){return this.check(qn(0,e))},negative(e){return this.check(Tr(0,e))},nonpositive(e){return this.check(Dn(0,e))},multipleOf(e,t){return this.check(Wo(e,t))},step(e,t){return this.check(Wo(e,t))},finite(){return this}}));function me(e){return K$(Ja,e)}var as=G("ZodNumberFormat",(e,t)=>{Kv.init(e,t),Ja.init(e,t)});function xp(e){return Y$(as,e)}function pP(e){return Q$(as,e)}function hP(e){return e0(as,e)}function gP(e){return t0(as,e)}function yP(e){return n0(as,e)}var Ga=G("ZodBoolean",(e,t)=>{Gl.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>C0(e,r,o,n)});function xe(e){return r0(Ga,e)}var Ka=G("ZodBigInt",(e,t)=>{zf.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>A0(e,r,o,n)},oe.derived({minValue:e=>Ot(e).minimum??null,maxValue:e=>Ot(e).maximum??null,format:e=>Ot(e).format??null},{gte(e,t){return this.check(qn(e,t))},min(e,t){return this.check(qn(e,t))},gt(e,t){return this.check(Cr(e,t))},lt(e,t){return this.check(Tr(e,t))},lte(e,t){return this.check(Dn(e,t))},max(e,t){return this.check(Dn(e,t))},positive(e){return this.check(Cr(BigInt(0),e))},negative(e){return this.check(Tr(BigInt(0),e))},nonpositive(e){return this.check(Dn(BigInt(0),e))},nonnegative(e){return this.check(qn(BigInt(0),e))},multipleOf(e,t){return this.check(Wo(e,t))}}));function bP(e){return i0(Ka,e)}var Vp=G("ZodBigIntFormat",(e,t)=>{Xv.init(e,t),Ka.init(e,t)});function wP(e){return a0(Vp,e)}function vP(e){return c0(Vp,e)}var Px=G("ZodSymbol",(e,t)=>{Yv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>O0(e,r,o,n)});function $P(e){return l0(Px,e)}var jx=G("ZodUndefined",(e,t)=>{Qv.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>M0(e,r,o,n)});function xP(e){return u0(jx,e)}var Ex=G("ZodNull",(e,t)=>{e$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>N0(e,r,o,n)});function Nr(e){return m0(Ex,e)}var Tx=G("ZodAny",(e,t)=>{t$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>U0(e,r,o,n)});function Zp(){return d0(Tx)}var Cx=G("ZodUnknown",(e,t)=>{n$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>L0(e,r,o,n)});function Ie(){return f0(Cx)}var Ax=G("ZodNever",(e,t)=>{r$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>q0(e,r,o,n)});function Wp(e){return p0(Ax,e)}var Ox=G("ZodVoid",(e,t)=>{o$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>D0(e,r,o,n)});function _P(e){return h0(Ox,e)}var pu=G("ZodDate",(e,t)=>{i$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>F0(e,r,o,n),e.min=(r,o)=>e.check(qn(r,o)),e.max=(r,o)=>e.check(Dn(r,o))},oe.derived({minDate:e=>{let{minimum:t}=Ot(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=Ot(e);return t?new Date(t):null}},{}));function kP(e){return g0(pu,e)}var Nx=G("ZodArray",(e,t)=>{is(),a$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ex(e,r,o,n),e.element=t.element},{min(e,t){return this.check(ao(e,t))},nonempty(e){return this.check(ao(1,e))},max(e,t){return this.check(ts(e,t))},length(e,t){return this.check(ns(e,t))},unwrap(){return this.element}});function te(e,t){return w0(Nx,e,t)}function SP(e){let t=e._zod.def.shape;return Ce(Object.keys(t))}var hu=G("ZodObject",(e,t)=>{is(),c$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>tx(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:Ie()}))},loose(){return this.clone(oe.mergeDefs(this._zod.def,{catchall:Ie()}))},strict(){return this.clone(oe.mergeDefs(this._zod.def,{catchall:Wp()}))},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(yu,this,e[0])},exactPartial(...e){return oe.partial(Hp,this,e[0],"exactPartial")},required(...e){return oe.required(Jp,this,e[0])}});function J(e,t){let r={type:"object",shape:e??{},...oe.normalizeParams(t)};return new hu(r)}function zP(e,t){return new hu({type:"object",shape:e,catchall:Wp(),...oe.normalizeParams(t)})}function je(e,t){return new hu({type:"object",shape:e,catchall:Ie(),...oe.normalizeParams(t)})}var gu=G("ZodUnion",(e,t)=>{Kl.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>yp(e,r,o,n),e.options=t.options});function _e(e,t){return new gu({type:"union",options:e,...oe.normalizeParams(t)})}var Mx=G("ZodXor",(e,t)=>{gu.init(e,t),l$.init(e,t),e._zod.processJSONSchema=(r,o,n)=>yp(e,r,o,n),e.options=t.options});function RP(e,t){return new Mx({type:"union",options:e,inclusive:!1,...oe.normalizeParams(t)})}var Dx=G("ZodDiscriminatedUnion",(e,t)=>{gu.init(e,t),m$.init(e,t)});function ei(e,t,r){return new Dx({type:"union",options:t,discriminator:e,...oe.normalizeParams(r)})}var qx=G("ZodIntersection",(e,t)=>{d$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>nx(e,r,o,n)});function yr(e,t){return new qx({type:"intersection",left:e,right:t})}var Ux=G("ZodTuple",(e,t)=>{is(),Rf.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rx(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 yu({type:"optional",innerType:t}))})}});function Lx(e,t,r){let o=t instanceof Ne,n=o?r:t,i=o?t:null;return new Ux({type:"tuple",items:e,rest:i,...oe.normalizeParams(n)})}var Za=G("ZodRecord",(e,t)=>{is(),f$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ox(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function ve(e,t,r){return!t||!t._zod?new Za({type:"record",keyType:E(),valueType:e,...oe.normalizeParams(t)}):new Za({type:"record",keyType:e,valueType:t,...oe.normalizeParams(r)})}function IP(e,t,r){return new Za({type:"record",keyType:e,valueType:t,...oe.normalizeParams(r),partial:!0})}function PP(e,t,r){return new Za({type:"record",keyType:e,valueType:t,mode:"loose",...oe.normalizeParams(r)})}var Fx=G("ZodMap",(e,t)=>{is(),p$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Y0(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Ar(...r)),e.nonempty=r=>e.check(Ar(1,r)),e.max=(...r)=>e.check(Bo(...r)),e.size=(...r)=>e.check(es(...r))});function jP(e,t,r){return new Fx({type:"map",keyType:e,valueType:t,...oe.normalizeParams(r)})}var Vx=G("ZodSet",(e,t)=>{is(),h$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Q0(e,r,o,n),e.min=(...r)=>e.check(Ar(...r)),e.nonempty=r=>e.check(Ar(1,r)),e.max=(...r)=>e.check(Bo(...r)),e.size=(...r)=>e.check(es(...r))});function EP(e,t){return new Vx({type:"set",valueType:e,...oe.normalizeParams(t)})}var Wa=G("ZodEnum",(e,t)=>{g$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(o,n,i)=>V0(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 Wa({...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 Wa({...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 Wa({type:"enum",entries:r,...oe.normalizeParams(t)})}function TP(e,t){return new Wa({type:"enum",entries:e,...oe.normalizeParams(t)})}var Zx=G("ZodLiteral",(e,t)=>{y$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Z0(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 Zx({type:"literal",values:Array.isArray(e)?e:[e],...oe.normalizeParams(t)})}var Wx=G("ZodFile",(e,t)=>{b$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>H0(e,r,o,n),e.min=(r,o)=>e.check(Ar(r,o)),e.max=(r,o)=>e.check(Bo(r,o)),e.mime=(r,o)=>e.check(Oa(Array.isArray(r)?r:[r],o))});function CP(e){return v0(Wx,e)}var Bx=G("ZodTransform",(e,t)=>{is(),w$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>X0(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Vo(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 Bp(e){return new Bx({type:"transform",transform:e})}var yu=G("ZodOptional",(e,t)=>{If.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>bp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Re(e){return new yu({type:"optional",innerType:e})}var Hp=G("ZodExactOptional",(e,t)=>{v$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>bp(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Hx(e){return new Hp({type:"optional",innerType:e})}var Jx=G("ZodNullable",(e,t)=>{$$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ix(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function du(e){return new Jx({type:"nullable",innerType:e})}function AP(e){return Re(du(e))}var Gx=G("ZodDefault",(e,t)=>{x$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>cx(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kx(e,t){return new Gx({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():oe.shallowClone(t)}})}var Xx=G("ZodPrefault",(e,t)=>{_$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>lx(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Yx(e,t){return new Xx({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():oe.shallowClone(t)}})}var Jp=G("ZodNonOptional",(e,t)=>{k$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sx(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Qx(e,t){return new Jp({type:"nonoptional",innerType:e,...oe.normalizeParams(t)})}var e_=G("ZodSuccess",(e,t)=>{S$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>J0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function OP(e){return new e_({type:"success",innerType:e})}var t_=G("ZodCatch",(e,t)=>{z$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ux(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function n_(e,t){return new t_({type:"catch",innerType:e,catchValue:typeof t=="function"?t:oe.constantCatch(t)})}var r_=G("ZodNaN",(e,t)=>{R$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>W0(e,r,o,n)});function NP(e){return b0(r_,e)}var bu=G("ZodPipe",(e,t)=>{Pf.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>mx(e,r,o,n),e.in=t.in,e.out=t.out});function _p(e,t){return new bu({type:"pipe",in:e,out:t})}var wu=G("ZodCodec",(e,t)=>{bu.init(e,t),Xl.init(e,t)});function MP(e,t,r){return new wu({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function DP(e){let t=e._zod.def;return new wu({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var o_=G("ZodPreprocess",(e,t)=>{bu.init(e,t),I$.init(e,t)}),i_=G("ZodReadonly",(e,t)=>{P$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>dx(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function s_(e){return new i_({type:"readonly",innerType:e})}var a_=G("ZodTemplateLiteral",(e,t)=>{j$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>B0(e,r,o,n)});function qP(e,t){return new a_({type:"template_literal",parts:e,...oe.normalizeParams(t)})}var c_=G("ZodLazy",(e,t)=>{Yl.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>px(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});function ti(e){return new c_({type:"lazy",getter:e})}var l_=G("ZodPromise",(e,t)=>{T$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fx(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function UP(e){return new l_({type:"promise",innerType:e})}var u_=G("ZodFunction",(e,t)=>{E$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>K0(e,r,o,n)});function LP(e){return new u_({type:"function",input:Array.isArray(e?.input)?Lx(e?.input):e?.input??te(Ie()),output:e?.output??Ie()})}var vu=G("ZodCustom",(e,t)=>{C$.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(r,o,n)=>G0(e,r,o,n)});function FP(e){let t=new lt({check:"custom"});return t._zod.check=e,t}function VP(e,t){return $0(vu,e??(()=>!0),t)}function m_(e,t={}){return x0(vu,e,t)}function d_(e,t){return _0(e,t)}var ZP=k0,WP=S0,f_=G("ZodInstanceOf",(e,t)=>{vu.init(e,t)},{properties(e,t){return this.check(Aa(e,t))}});function BP(e,t={}){let r=new f_({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 HP=(...e)=>z0({Codec:wu,Boolean:Ga,String:Ba},...e);function JP(e){let t=ti(()=>_e([E(e),me(),xe(),Nr(),te(t),ve(E(),t)]));return t}function lo(e,t){return new o_({type:"pipe",in:Bp(e),out:t})}var h_={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 s6(e){xt({customError:e})}function a6(){return xt().customError}var p_;p_||(p_={});var Yn={};ro(Yn,{ZodISODate:()=>Xo,ZodISODateTime:()=>Ko,ZodISODuration:()=>Qo,ZodISOTime:()=>Yo,date:()=>l6,datetime:()=>c6,duration:()=>m6,time:()=>u6});function c6(e){return iu(Ko,e)}function l6(e){return su(Xo,e)}function u6(e){return au(Yo,e)}function m6(e){return cu(Qo,e)}var ke={...Xa,...vp,iso:Yn},d6=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 f6(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 GP(e,t){return e.map((r,o)=>o<t?r:r.optional())}function p6(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function h6(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:p6(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 g6(e,t){return ke.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 g_(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=g_(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=g_(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 y6=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),b6=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function $u(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some($u):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,r])=>y6.has(t)?$u(r):!b6.has(t)||typeof r!="object"||r===null?!1:Object.values(r).some($u))}function KP(e){return e===1?"element":"elements"}function w6(e,t){return ke.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=g_(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 ${KP(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 ${KP(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function XP(e,t){if(e!==!1)return e===void 0||e===!0?ke.any():fn(e,t)}var v6=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function YP(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return ke.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 ke.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=h6(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 ke.null();if(n.length===0)return ke.never();if(n.length===1)return ke.literal(n[0]);if(n.every(s=>typeof s=="string"))return ke.enum(n);let i=n.map(s=>ke.literal(s));return i.length<2?i[0]:ke.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return ke.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(i=>{let s={...e,type:i};return YP(s,t)});return n.length===0?ke.never():n.length===1?n[0]:ke.union(n)}if(!r)return ke.any();let o;switch(r){case"string":{let n=ke.string();if(e.format){let i=e.format;i==="email"?n=n.check(ke.email()):i==="uri"||i==="uri-reference"?n=n.check(ke.url()):i==="uuid"||i==="guid"?n=n.check(ke.uuid()):i==="date-time"?n=n.check(ke.iso.datetime({offset:!0})):i==="date"?n=n.check(ke.iso.date()):i==="time"?n=n.check(ke.regex(v6)):i==="duration"?n=n.check(ke.iso.duration()):i==="hostname"?n=n.check(ke.hostname()):i==="ipv4"?n=n.check(ke.ipv4()):i==="ipv6"?n=n.check(ke.ipv6()):i==="mac"?n=n.check(ke.mac()):i==="cidr"?n=n.check(ke.cidrv4()):i==="cidr-v6"?n=n.check(ke.cidrv6()):i==="base64"?n=n.check(ke.base64()):i==="base64url"?n=n.check(ke.base64url()):i==="e164"?n=n.check(ke.e164()):i==="credit_card"?n=n.check(ke.creditCard()):i==="iban"?n=n.check(ke.iban()):i==="jwt"?n=n.check(ke.jwt()):i==="emoji"?n=n.check(ke.emoji()):i==="nanoid"?n=n.check(ke.nanoid()):i==="cuid"?n=n.check(ke.cuid()):i==="cuid2"?n=n.check(ke.cuid2()):i==="ulid"?n=n.check(ke.ulid()):i==="xid"?n=n.check(ke.xid()):i==="ksuid"&&(n=n.check(ke.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"?ke.number().int():ke.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=ke.boolean();break}case"null":{o=ke.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);Zt(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=ke.string().regex(new RegExp(h));f.push(ke.looseRecord(b,g))}let p=[];if(Object.keys(n).length>0&&p.push(ke.object(n).passthrough()),p.push(...f),p.length===0)o=ke.object({}).passthrough();else if(p.length===1)o=p[0];else{let h=ke.intersection(p[0],p[1]);for(let g=2;g<p.length;g++)h=ke.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(!Gn(y.value))return;let w=[];for(let v of Object.keys(y.value))h.includes(v)||g.some(k=>k.test(v))||w.push(v);w.length&&y.issues.push({code:"unrecognized_keys",keys:w,input:y.value,inst:b})})}}else{let m=ke.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=g6(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=GP(a,s),l=Array.isArray(i)?void 0:XP(i,t),u=ke.tuple(c);o=l?u.rest(l):u,typeof e.minItems=="number"&&(o=o.check(ke.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(ke.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=GP(a,s),l=XP(e.additionalItems,t),u=ke.tuple(c);o=l?u.rest(l):u,typeof e.minItems=="number"&&(o=o.check(ke.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(ke.maxLength(e.maxItems)))}else if(i!==void 0){let s=fn(i,t),a=ke.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),o=a}else o=ke.array(ke.any());(e.uniqueItems===!0||e.contains!==void 0)&&(o=w6(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?ke.any():ke.never();let r=YP(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=ke.union(a);r=o?ke.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(l=>fn(l,t)),c=ke.xor(a);r=o?ke.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:ke.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=ke.intersection(a,fn(e.allOf[l],t));r=a}e.nullable===!0&&t.version==="openapi-3.0"&&(r=ke.nullable(r)),e.readOnly===!0&&(r=ke.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&&!$u(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&&!$u(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))d6.has(a)||Zt(n,a,e[a]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function QP(e,t){if(typeof e=="boolean")return e?ke.any():ke.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=f6(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Wt};return fn(r,i)}var ej=Symbol("z.visit/resolving");function xu(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===ej)return new Yl({type:"lazy",getter:()=>o.get(s)});if(a!==void 0)return a;o.set(s,ej);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 tj(e){return xu(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:_e(r.options)}})}function $6(e,t){if(!t?.length)return e;let r=e._zod.def;return tt(e,pr(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function nj(e){return $6(e.out,e.checks)}function x6(e){return e.in._zod.traits.has("$ZodTransform")?nj(e):e.in}function rj(e){return xu(e,{pipe:t=>x6(t._zod.def),default:(t,r)=>r?Re(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function oj(e){return xu(e,{pipe:t=>nj(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var _u={};ro(_u,{bigint:()=>z6,boolean:()=>S6,date:()=>R6,number:()=>k6,string:()=>_6});function _6(e){return W$(Ba,e)}function k6(e){return X$(Ja,e)}function S6(e){return o0(Ga,e)}function z6(e){return s0(Ka,e)}function R6(e){return y0(pu,e)}var ls="2025-11-25",Gp="2025-03-26",ku=[ls,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Kp="io.modelcontextprotocol/related-task",Qn="io.modelcontextprotocol/protocolVersion",us="io.modelcontextprotocol/clientInfo",br="io.modelcontextprotocol/serverInfo",Mr="io.modelcontextprotocol/clientCapabilities",ri="io.modelcontextprotocol/subscriptionId",oi="io.modelcontextprotocol/logLevel";var ms="2.0";var ni=ti(()=>_e([E(),me(),xe(),Nr(),ve(E(),ni),te(ni)])),_t=ve(E(),ni),y_=te(ni),Su=_e([E(),me().int()]),zu=E(),Xp=J({ttl:me().optional()}),Yp=J({taskId:E()}),Ru=je({progressToken:Su.optional(),[Kp]:Yp.optional()}),Ut=J({_meta:Ru.optional()}),ds=Ut.extend({task:Xp.optional()}),kt=J({method:E(),params:Ut.loose().optional()}),Qt=J({_meta:Ru.optional()}),en=J({method:E(),params:Qt.loose().optional()}),Iu=je({get[br](){return ec.optional().catch(void 0)}}),St=je({_meta:Iu.optional()}),ii=_e([E(),me().int()]),Pu=J({jsonrpc:ne(ms),id:ii,...kt.shape}).strict(),ju=J({jsonrpc:ne(ms),...en.shape}).strict(),Ya=J({jsonrpc:ne(ms),id:ii,result:St}).strict(),Qa=J({jsonrpc:ne(ms),id:ii.optional(),error:J({code:me().int(),message:E(),data:Ie().optional()})}).strict(),fs=_e([Pu,ju,Ya,Qa]),b_=_e([Ya,Qa]),Eu=St.strict(),Qp=Qt.extend({requestId:ii.optional(),reason:E().optional()}),Tu=en.extend({method:ne("notifications/cancelled"),params:Qp}),eh=J({src:E(),mimeType:E().optional(),sizes:te(E()).optional(),theme:Ce(["light","dark"]).optional()}),si=J({icons:te(eh).optional()}),uo=J({name:E(),title:E().optional()}),ec=uo.extend({...uo.shape,...si.shape,version:E(),websiteUrl:E().optional(),description:E().optional()}),I6=yr(J({applyDefaults:xe().optional()}),_t),P6=lo(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,yr(J({form:I6.optional(),url:_t.optional()}),_t.optional())),th=je({list:_t.optional(),cancel:_t.optional(),requests:je({sampling:je({createMessage:_t.optional()}).optional(),elicitation:je({create:_t.optional()}).optional()}).optional()}),nh=je({list:_t.optional(),cancel:_t.optional(),requests:je({tools:je({call:_t.optional()}).optional()}).optional()}),rh=J({experimental:ve(E(),_t).optional(),sampling:J({context:_t.optional(),tools:_t.optional()}).optional(),elicitation:P6.optional(),roots:J({listChanged:xe().optional()}).optional(),tasks:th.optional(),extensions:ve(E(),_t).optional()}),oh=Ut.extend({protocolVersion:E(),capabilities:rh,clientInfo:ec}),Cu=kt.extend({method:ne("initialize"),params:oh}),Au=J({experimental:ve(E(),_t).optional(),logging:_t.optional(),completions:_t.optional(),prompts:J({listChanged:xe().optional()}).optional(),resources:J({subscribe:xe().optional(),listChanged:xe().optional()}).optional(),tools:J({listChanged:xe().optional()}).optional(),tasks:nh.optional(),extensions:ve(E(),_t).optional()}),ih=St.extend({protocolVersion:E(),capabilities:Au,serverInfo:ec,instructions:E().optional()}),sh=en.extend({method:ne("notifications/initialized"),params:Qt.optional()}),ah=kt.extend({method:ne("server/discover"),params:Ut.optional()}),ch=St.extend({supportedVersions:te(E()),capabilities:Au,instructions:E().optional()}),Ou=kt.extend({method:ne("ping"),params:Ut.optional()}),lh=J({progress:me(),total:Re(me()),message:Re(E())}),uh=J({...Qt.shape,...lh.shape,progressToken:Su}),Nu=en.extend({method:ne("notifications/progress"),params:uh}),mh=Ut.extend({cursor:zu.optional()}),ai=kt.extend({params:mh.optional()}),ci=St.extend({nextCursor:zu.optional()}),Mu=J({uri:E(),mimeType:Re(E()),_meta:ve(E(),Ie()).optional()}),Du=Mu.extend({text:E()}),w_=E().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),qu=Mu.extend({blob:w_}),li=Ce(["user","assistant"]),mo=J({audience:te(li).optional(),priority:me().min(0).max(1).optional(),lastModified:Yn.datetime({offset:!0}).optional()}),Uu=J({...uo.shape,...si.shape,uri:E(),description:Re(E()),mimeType:Re(E()),size:Re(me()),annotations:mo.optional(),_meta:Re(je({}))}),dh=J({...uo.shape,...si.shape,uriTemplate:E(),description:Re(E()),mimeType:Re(E()),annotations:mo.optional(),_meta:Re(je({}))}),fh=ai.extend({method:ne("resources/list")}),ph=ci.extend({resources:te(Uu)}),hh=ai.extend({method:ne("resources/templates/list")}),gh=ci.extend({resourceTemplates:te(dh)}),tc=Ut.extend({uri:E()}),yh=tc,bh=kt.extend({method:ne("resources/read"),params:yh}),wh=St.extend({contents:te(_e([Du,qu]))}),vh=en.extend({method:ne("notifications/resources/list_changed"),params:Qt.optional()}),$h=tc,xh=kt.extend({method:ne("resources/subscribe"),params:$h}),_h=tc,kh=kt.extend({method:ne("resources/unsubscribe"),params:_h}),Lu=J({toolsListChanged:xe().optional(),promptsListChanged:xe().optional(),resourcesListChanged:xe().optional(),resourceSubscriptions:te(E()).optional()}),Sh=Ut.extend({notifications:Lu}),zh=kt.extend({method:ne("subscriptions/listen"),params:Sh}),Rh=Qt.extend({notifications:Lu}),Ih=en.extend({method:ne("notifications/subscriptions/acknowledged"),params:Rh}),Ph=Iu.extend({[ri]:ii}),jh=St.extend({_meta:Ph}),Eh=Qt.extend({uri:E()}),Th=en.extend({method:ne("notifications/resources/updated"),params:Eh}),Ch=J({name:E(),description:Re(E()),required:Re(xe())}),Ah=J({...uo.shape,...si.shape,description:Re(E()),arguments:Re(te(Ch)),_meta:Re(je({}))}),Oh=ai.extend({method:ne("prompts/list")}),Nh=ci.extend({prompts:te(Ah)}),Mh=Ut.extend({name:E(),arguments:ve(E(),E()).optional()}),Dh=kt.extend({method:ne("prompts/get"),params:Mh}),nc=J({type:ne("text"),text:E(),annotations:mo.optional(),_meta:ve(E(),Ie()).optional()}),rc=J({type:ne("image"),data:w_,mimeType:E(),annotations:mo.optional(),_meta:ve(E(),Ie()).optional()}),oc=J({type:ne("audio"),data:w_,mimeType:E(),annotations:mo.optional(),_meta:ve(E(),Ie()).optional()}),qh=J({type:ne("tool_use"),name:E(),id:E(),input:ve(E(),Ie()),_meta:ve(E(),Ie()).optional()}),Uh=J({type:ne("resource"),resource:_e([Du,qu]),annotations:mo.optional(),_meta:ve(E(),Ie()).optional()}),Lh=Uu.extend({type:ne("resource_link")}),ic=_e([nc,rc,oc,Lh,Uh]),Fh=J({role:li,content:ic}),Vh=St.extend({description:E().optional(),messages:te(Fh)}),Zh=en.extend({method:ne("notifications/prompts/list_changed"),params:Qt.optional()}),Wh=J({title:E().optional(),readOnlyHint:xe().optional(),destructiveHint:xe().optional(),idempotentHint:xe().optional(),openWorldHint:xe().optional()}),Bh=J({taskSupport:Ce(["required","optional","forbidden"]).optional()}),Fu=J({...uo.shape,...si.shape,description:E().optional(),inputSchema:J({type:ne("object"),properties:ve(E(),ni).optional(),required:te(E()).optional()}).catchall(Ie()),outputSchema:je({$schema:E().optional()}).optional(),annotations:Wh.optional(),execution:Bh.optional(),_meta:ve(E(),Ie()).optional()}),Hh=ai.extend({method:ne("tools/list")}),Jh=ci.extend({tools:te(Fu)}),Vu=St.extend({content:te(ic).default([]),structuredContent:Ie().optional(),isError:xe().optional()}),v_=Vu.or(St.extend({toolResult:Ie()})),Gh=ds.extend({name:E(),arguments:ve(E(),Ie()).optional()}),Kh=kt.extend({method:ne("tools/call"),params:Gh}),Xh=en.extend({method:ne("notifications/tools/list_changed"),params:Qt.optional()}),$_=J({autoRefresh:xe().default(!0),debounceMs:me().int().nonnegative().default(300)}),ui=Ce(["debug","info","notice","warning","error","critical","alert","emergency"]),Yh=Ut.extend({level:ui}),Qh=kt.extend({method:ne("logging/setLevel"),params:Yh}),eg=Qt.extend({level:ui,logger:E().optional(),data:Ie()}),tg=en.extend({method:ne("notifications/message"),params:eg}),ng=J({name:E().optional()}),rg=J({hints:te(ng).optional(),costPriority:me().min(0).max(1).optional(),speedPriority:me().min(0).max(1).optional(),intelligencePriority:me().min(0).max(1).optional()}),og=J({mode:Ce(["auto","required","none"]).optional()}),ig=J({type:ne("tool_result"),toolUseId:E().describe("The unique identifier for the corresponding tool call."),content:te(ic),structuredContent:Ie().optional(),isError:xe().optional(),_meta:ve(E(),Ie()).optional()}),sg=ei("type",[nc,rc,oc]),cs=ei("type",[nc,rc,oc,qh,ig]),ag=J({role:li,content:_e([cs,te(cs)]),_meta:ve(E(),Ie()).optional()}),cg=ds.extend({messages:te(ag),modelPreferences:rg.optional(),systemPrompt:E().optional(),includeContext:Ce(["none","thisServer","allServers"]).optional(),temperature:me().optional(),maxTokens:me().int(),stopSequences:te(E()).optional(),metadata:_t.optional(),tools:te(Fu).optional(),toolChoice:og.optional()}),lg=kt.extend({method:ne("sampling/createMessage"),params:cg}),ug=St.extend({model:E(),stopReason:Re(Ce(["endTurn","stopSequence","maxTokens"]).or(E())),role:li,content:sg}),mg=St.extend({model:E(),stopReason:Re(Ce(["endTurn","stopSequence","maxTokens","toolUse"]).or(E())),role:li,content:_e([cs,te(cs)])}),Zu=J({type:ne("boolean"),title:E().optional(),description:E().optional(),default:xe().optional()}),sc=J({type:ne("string"),title:E().optional(),description:E().optional(),minLength:me().optional(),maxLength:me().optional(),format:Ce(["email","uri","date","date-time"]).optional(),default:E().optional()}),ac=J({type:Ce(["number","integer"]),title:E().optional(),description:E().optional(),minimum:me().optional(),maximum:me().optional(),default:me().optional()}),Wu=J({type:ne("string"),title:E().optional(),description:E().optional(),enum:te(E()),default:E().optional()}),Bu=J({type:ne("string"),title:E().optional(),description:E().optional(),oneOf:te(J({const:E(),title:E()})),default:E().optional()}),Hu=J({type:ne("string"),title:E().optional(),description:E().optional(),enum:te(E()),enumNames:te(E()).optional(),default:E().optional()}),dg=_e([Wu,Bu]),Ju=J({type:ne("array"),title:E().optional(),description:E().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({type:ne("string"),enum:te(E())}),default:te(E()).optional()}),Gu=J({type:ne("array"),title:E().optional(),description:E().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({anyOf:te(J({const:E(),title:E()}))}),default:te(E()).optional()}),fg=_e([Ju,Gu]),pg=_e([Hu,dg,fg]),Ku=_e([pg,Zu,sc,ac]),cc=ds.extend({mode:ne("form").optional(),message:E(),requestedSchema:J({type:ne("object"),properties:ve(E(),Ku),required:te(E()).optional()}).catchall(Ie())}),hg=ds.extend({mode:ne("url"),message:E(),elicitationId:E(),url:E().url()}),gg=_e([cc,hg]),yg=kt.extend({method:ne("elicitation/create"),params:gg}),bg=Qt.extend({elicitationId:E()}),wg=en.extend({method:ne("notifications/elicitation/complete"),params:bg}),vg=St.extend({action:Ce(["accept","decline","cancel"]),content:lo(e=>e===null?void 0:e,ve(E(),_e([E(),me(),xe(),te(E())])).optional())}),$g=J({type:ne("ref/resource"),uri:E()}),xg=J({type:ne("ref/prompt"),name:E()}),_g=Ut.extend({ref:_e([xg,$g]),argument:J({name:E(),value:E()}),context:J({arguments:ve(E(),E()).optional()}).optional()}),kg=kt.extend({method:ne("completion/complete"),params:_g}),Sg=St.extend({completion:je({values:te(E()).max(100),total:Re(me().int()),hasMore:Re(xe())})}),zg=J({uri:E().startsWith("file://"),name:E().optional(),_meta:ve(E(),Ie()).optional()}),Rg=kt.extend({method:ne("roots/list"),params:Ut.optional()}),Ig=St.extend({roots:te(zg)}),Pg=en.extend({method:ne("notifications/roots/list_changed"),params:Qt.optional()}),x_=je({ttl:me().optional(),pollInterval:me().optional()}),jg=Ce(["working","input_required","completed","failed","cancelled"]),mi=J({taskId:E(),status:jg,ttl:_e([me(),Nr()]),createdAt:E(),lastUpdatedAt:E(),pollInterval:Re(me()),statusMessage:Re(E())}),__=St.extend({task:mi}),Eg=Qt.merge(mi),k_=en.extend({method:ne("notifications/tasks/status"),params:Eg}),S_=kt.extend({method:ne("tasks/get"),params:Ut.extend({taskId:E()})}),z_=St.merge(mi),R_=kt.extend({method:ne("tasks/result"),params:Ut.extend({taskId:E()})}),I_=St.loose(),P_=ai.extend({method:ne("tasks/list")}),j_=ci.extend({tasks:te(mi)}),E_=kt.extend({method:ne("tasks/cancel"),params:Ut.extend({taskId:E()})}),T_=St.merge(mi),C_=_e([Ou,Cu,ah,kg,Qh,Dh,Oh,fh,hh,bh,xh,kh,zh,Kh,Hh]),A_=_e([Tu,Nu,sh,Pg]),O_=_e([Eu,ug,mg,vg,Ig]),N_=_e([Ou,lg,yg,Rg]),M_=_e([Tu,Nu,tg,Th,vh,Xh,Zh,Ih,wg]),D_=_e([Eu,ih,ch,Sg,Vh,Nh,ph,gh,wh,Vu,Jh,jh]);var Lt=Ha().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:h_.custom,message:"URL must be parseable",fatal:!0}),Ol}).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"}),U_=je({resource:E().url(),authorization_servers:te(Lt).optional(),jwks_uri:E().url().optional(),scopes_supported:te(E()).optional(),bearer_methods_supported:te(E()).optional(),resource_signing_alg_values_supported:te(E()).optional(),resource_name:E().optional(),resource_documentation:E().optional(),resource_policy_uri:E().url().optional(),resource_tos_uri:E().url().optional(),tls_client_certificate_bound_access_tokens:xe().optional(),authorization_details_types_supported:te(E()).optional(),dpop_signing_alg_values_supported:te(E()).optional(),dpop_bound_access_tokens_required:xe().optional()}),Tg=je({issuer:E(),authorization_endpoint:Lt,token_endpoint:Lt,registration_endpoint:Lt.optional(),scopes_supported:te(E()).optional(),response_types_supported:te(E()),response_modes_supported:te(E()).optional(),grant_types_supported:te(E()).optional(),token_endpoint_auth_methods_supported:te(E()).optional(),token_endpoint_auth_signing_alg_values_supported:te(E()).optional(),service_documentation:Lt.optional(),revocation_endpoint:Lt.optional(),revocation_endpoint_auth_methods_supported:te(E()).optional(),revocation_endpoint_auth_signing_alg_values_supported:te(E()).optional(),introspection_endpoint:E().optional(),introspection_endpoint_auth_methods_supported:te(E()).optional(),introspection_endpoint_auth_signing_alg_values_supported:te(E()).optional(),code_challenge_methods_supported:te(E()).optional(),client_id_metadata_document_supported:xe().optional(),authorization_response_iss_parameter_supported:xe().optional().catch(void 0),dpop_signing_alg_values_supported:te(E()).optional()}),Cg=je({issuer:E(),authorization_endpoint:Lt,token_endpoint:Lt,userinfo_endpoint:Lt.optional(),jwks_uri:Lt,registration_endpoint:Lt.optional(),scopes_supported:te(E()).optional(),response_types_supported:te(E()),response_modes_supported:te(E()).optional(),grant_types_supported:te(E()).optional(),acr_values_supported:te(E()).optional(),subject_types_supported:te(E()),id_token_signing_alg_values_supported:te(E()),id_token_encryption_alg_values_supported:te(E()).optional(),id_token_encryption_enc_values_supported:te(E()).optional(),userinfo_signing_alg_values_supported:te(E()).optional(),userinfo_encryption_alg_values_supported:te(E()).optional(),userinfo_encryption_enc_values_supported:te(E()).optional(),request_object_signing_alg_values_supported:te(E()).optional(),request_object_encryption_alg_values_supported:te(E()).optional(),request_object_encryption_enc_values_supported:te(E()).optional(),token_endpoint_auth_methods_supported:te(E()).optional(),token_endpoint_auth_signing_alg_values_supported:te(E()).optional(),display_values_supported:te(E()).optional(),claim_types_supported:te(E()).optional(),claims_supported:te(E()).optional(),service_documentation:E().optional(),claims_locales_supported:te(E()).optional(),ui_locales_supported:te(E()).optional(),claims_parameter_supported:xe().optional(),request_parameter_supported:xe().optional(),request_uri_parameter_supported:xe().optional(),require_request_uri_registration:xe().optional(),op_policy_uri:Lt.optional(),op_tos_uri:Lt.optional(),client_id_metadata_document_supported:xe().optional(),authorization_response_iss_parameter_supported:xe().optional().catch(void 0)}),L_=J({...Cg.shape,...Tg.pick({code_challenge_methods_supported:!0}).shape}),F_=J({access_token:E(),id_token:E().optional(),token_type:E(),expires_in:_u.number().optional(),scope:E().optional(),refresh_token:E().optional(),issuer:E().optional().catch(void 0)}).strip(),V_=J({issued_token_type:ne("urn:ietf:params:oauth:token-type:id-jag"),access_token:E(),token_type:E().optional(),expires_in:me().optional(),scope:E().optional()}).strip(),Z_=J({error:E(),error_description:E().optional(),error_uri:E().optional()}),q_=Lt.optional().or(ne("").transform(()=>{})),Ag=J({redirect_uris:te(Lt),token_endpoint_auth_method:E().optional(),grant_types:te(E()).optional(),response_types:te(E()).optional(),application_type:E().optional(),client_name:E().optional(),client_uri:Lt.optional(),logo_uri:q_,scope:E().optional(),contacts:te(E()).optional(),tos_uri:q_,policy_uri:E().optional(),jwks_uri:Lt.optional(),jwks:Zp().optional(),software_id:E().optional(),software_version:E().optional(),software_statement:E().optional()}).strip(),Og=J({client_id:E(),client_secret:E().optional(),client_id_issued_at:me().optional(),client_secret_expires_at:me().optional(),issuer:E().optional().catch(void 0)}).strip(),W_=Ag.merge(Og),B_=J({error:E(),error_description:E().optional()}).strip(),H_=J({token:E(),token_type_hint:E().optional()}).strip();var Y_=Symbol.for("mcp.sdk.errorBrands");function nk(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,Y_,{value:r,enumerable:!1,configurable:!0})}function dc(e,t){try{if(typeof t=="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand=="string"&&Object.prototype.hasOwnProperty.call(t,Y_)){let r=t[Y_];if(r&&typeof r.has=="function"&&r.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var gs=(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})({}),rm=class Pj extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return dc(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 dc(this,t)}constructor(t,r,o){super(r),this.code=t,this.errorUri=o,this.name="OAuthError",nk(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 Pj(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 dc(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 dc(this,e)}constructor(e,t,r,o){super(t,o),this.code=e,this.data=r,this.name="SdkError",nk(this,new.target)}},j6=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 pj={};function jj(e){return Object.hasOwn(pj,e)?pj[e]:void 0}function hj(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function E6(e,t,r){return e==="elicitation"&&t==="form"&&r.form===void 0&&r.url===void 0}function Ej(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 om(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(hj(n)&&hj(i)){let s={};for(let[a,c]of Object.entries(n))c!==void 0&&i[a]===void 0&&!E6(o,a,i)&&(s[a]=c);Object.keys(s).length>0&&(r[o]=s)}}return Object.keys(r).length>0?r:void 0}var Tj="2026-07-28",Sn=[Tj];function po(e){return e>=Tj}function Cj(e){return e.filter(t=>!po(t))}function Lg(e){return e.filter(t=>po(t))}function Aj(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 Oj=["task","inputRequests","requestState"];function rk(e){return e===null||typeof e!="object"||Array.isArray(e)||e.content!==void 0||Oj.some(t=>t in e)?e:{...e,content:[]}}function T6(){let e=ti(()=>_e([E(),me(),xe(),Nr(),ve(E(),e),te(e)])),t=ve(E(),e),r=_e([E(),me().int()]),o=E(),n=J({ttl:me().optional()}),i=J({taskId:E()}),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:E(),params:a.loose().optional()}),u=J({_meta:s.optional()}),m=J({method:E(),params:u.loose().optional()}),d=je({_meta:s.optional()}),f=_e([E(),me().int()]),p=d.strict(),h=u.extend({requestId:f.optional(),reason:E().optional()}),g=m.extend({method:ne("notifications/cancelled"),params:h}),b=J({src:E(),mimeType:E().optional(),sizes:te(E()).optional(),theme:Ce(["light","dark"]).optional()}),y=J({icons:te(b).optional()}),w=J({name:E(),title:E().optional()}),v=w.extend({...w.shape,...y.shape,version:E(),websiteUrl:E().optional(),description:E().optional()}),k=yr(J({applyDefaults:xe().optional()}),t),_=lo(Xt=>Xt&&typeof Xt=="object"&&!Array.isArray(Xt)&&Object.keys(Xt).length===0?{form:{}}:Xt,yr(J({form:k.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()}),S=J({experimental:ve(E(),t).optional(),sampling:J({context:t.optional(),tools:t.optional()}).optional(),elicitation:_.optional(),roots:J({listChanged:xe().optional()}).optional(),tasks:$.optional(),extensions:ve(E(),t).optional()}),R=a.extend({protocolVersion:E(),capabilities:S,clientInfo:v}),P=l.extend({method:ne("initialize"),params:R}),j=J({experimental:ve(E(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:J({listChanged:xe().optional()}).optional(),resources:J({subscribe:xe().optional(),listChanged:xe().optional()}).optional(),tools:J({listChanged:xe().optional()}).optional(),tasks:x.optional(),extensions:ve(E(),t).optional()}),N=d.extend({protocolVersion:E(),capabilities:j,serverInfo:v,instructions:E().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:Re(me()),message:Re(E())}),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:E(),mimeType:Re(E()),_meta:ve(E(),Ie()).optional()}),z=A.extend({text:E()}),I=E().refine(Xt=>{try{return atob(Xt),!0}catch{return!1}},{message:"Invalid Base64 string"}),C=A.extend({blob:I}),U=Ce(["user","assistant"]),H=J({audience:te(U).optional(),priority:me().min(0).max(1).optional(),lastModified:Yn.datetime({offset:!0}).optional()}),Y=J({...w.shape,...y.shape,uri:E(),description:Re(E()),mimeType:Re(E()),size:Re(me()),annotations:H.optional(),_meta:Re(je({}))}),X=J({...w.shape,...y.shape,uriTemplate:E(),description:Re(E()),mimeType:Re(E()),annotations:H.optional(),_meta:Re(je({}))}),fe=M.extend({method:ne("resources/list")}),ye=L.extend({resources:te(Y)}),W=M.extend({method:ne("resources/templates/list")}),ee=L.extend({resourceTemplates:te(X)}),re=a.extend({uri:E()}),de=re,ce=l.extend({method:ne("resources/read"),params:de}),pe=d.extend({contents:te(_e([z,C]))}),Pe=m.extend({method:ne("notifications/resources/list_changed"),params:u.optional()}),Je=re,Ze=l.extend({method:ne("resources/subscribe"),params:Je}),Ye=re,Qe=l.extend({method:ne("resources/unsubscribe"),params:Ye}),Ct=u.extend({uri:E()}),vt=m.extend({method:ne("notifications/resources/updated"),params:Ct}),bn=J({name:E(),description:Re(E()),required:Re(xe())}),Gt=J({...w.shape,...y.shape,description:Re(E()),arguments:Re(te(bn)),_meta:Re(je({}))}),On=M.extend({method:ne("prompts/list")}),Wn=L.extend({prompts:te(Gt)}),Bn=a.extend({name:E(),arguments:ve(E(),E()).optional()}),dr=l.extend({method:ne("prompts/get"),params:Bn}),Hn=J({type:ne("text"),text:E(),annotations:H.optional(),_meta:ve(E(),Ie()).optional()}),Mi=J({type:ne("image"),data:I,mimeType:E(),annotations:H.optional(),_meta:ve(E(),Ie()).optional()}),Di=J({type:ne("audio"),data:I,mimeType:E(),annotations:H.optional(),_meta:ve(E(),Ie()).optional()}),Xc=J({type:ne("tool_use"),name:E(),id:E(),input:ve(E(),Ie()),_meta:ve(E(),Ie()).optional()}),Do=J({type:ne("resource"),resource:_e([z,C]),annotations:H.optional(),_meta:ve(E(),Ie()).optional()}),Yc=Y.extend({type:ne("resource_link")}),Jn=_e([Hn,Mi,Di,Yc,Do]),ta=J({role:U,content:Jn}),na=d.extend({description:E().optional(),messages:te(ta)}),qi=m.extend({method:ne("notifications/prompts/list_changed"),params:u.optional()}),Qc=J({title:E().optional(),readOnlyHint:xe().optional(),destructiveHint:xe().optional(),idempotentHint:xe().optional(),openWorldHint:xe().optional()}),ra=J({taskSupport:Ce(["required","optional","forbidden"]).optional()}),Ui=J({...w.shape,...y.shape,description:E().optional(),inputSchema:J({type:ne("object"),properties:ve(E(),e).optional(),required:te(E()).optional()}).catchall(Ie()),outputSchema:J({type:ne("object"),properties:ve(E(),e).optional(),required:te(E()).optional()}).catchall(Ie()).optional(),annotations:Qc.optional(),execution:ra.optional(),_meta:ve(E(),Ie()).optional()}),oa=M.extend({method:ne("tools/list")}),ia=L.extend({tools:te(Ui)}),sa=d.extend({content:te(Jn),structuredContent:ve(E(),Ie()).optional(),isError:xe().optional()}),Kt=c.extend({name:E(),arguments:ve(E(),Ie()).optional()}),el=l.extend({method:ne("tools/call"),params:Kt}),Sd=m.extend({method:ne("notifications/tools/list_changed"),params:u.optional()}),aa=Ce(["debug","info","notice","warning","error","critical","alert","emergency"]),tl=a.extend({level:aa}),nl=l.extend({method:ne("logging/setLevel"),params:tl}),rl=u.extend({level:aa,logger:E().optional(),data:Ie()}),ol=m.extend({method:ne("notifications/message"),params:rl}),il=J({name:E().optional()}),sl=J({hints:te(il).optional(),costPriority:me().min(0).max(1).optional(),speedPriority:me().min(0).max(1).optional(),intelligencePriority:me().min(0).max(1).optional()}),al=J({mode:Ce(["auto","required","none"]).optional()}),zd=J({type:ne("tool_result"),toolUseId:E().describe("The unique identifier for the corresponding tool call."),content:te(Jn),structuredContent:J({}).loose().optional(),isError:xe().optional(),_meta:ve(E(),Ie()).optional()}),cl=ei("type",[Hn,Mi,Di]),qo=ei("type",[Hn,Mi,Di,Xc,zd]),ll=J({role:U,content:_e([qo,te(qo)]),_meta:ve(E(),Ie()).optional()}),ul=c.extend({messages:te(ll),modelPreferences:sl.optional(),systemPrompt:E().optional(),includeContext:Ce(["none","thisServer","allServers"]).optional(),temperature:me().optional(),maxTokens:me().int(),stopSequences:te(E()).optional(),metadata:t.optional(),tools:te(Ui).optional(),toolChoice:al.optional()}),ml=l.extend({method:ne("sampling/createMessage"),params:ul}),dl=d.extend({model:E(),stopReason:Re(Ce(["endTurn","stopSequence","maxTokens"]).or(E())),role:U,content:cl}),fl=d.extend({model:E(),stopReason:Re(Ce(["endTurn","stopSequence","maxTokens","toolUse"]).or(E())),role:U,content:_e([qo,te(qo)])}),pl=J({type:ne("boolean"),title:E().optional(),description:E().optional(),default:xe().optional()}),hl=J({type:ne("string"),title:E().optional(),description:E().optional(),minLength:me().optional(),maxLength:me().optional(),format:Ce(["email","uri","date","date-time"]).optional(),default:E().optional()}),gl=J({type:Ce(["number","integer"]),title:E().optional(),description:E().optional(),minimum:me().optional(),maximum:me().optional(),default:me().optional()}),yl=J({type:ne("string"),title:E().optional(),description:E().optional(),enum:te(E()),default:E().optional()}),bl=J({type:ne("string"),title:E().optional(),description:E().optional(),oneOf:te(J({const:E(),title:E()})),default:E().optional()}),wl=J({type:ne("string"),title:E().optional(),description:E().optional(),enum:te(E()),enumNames:te(E()).optional(),default:E().optional()}),vl=_e([yl,bl]),Li=J({type:ne("array"),title:E().optional(),description:E().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({type:ne("string"),enum:te(E())}),default:te(E()).optional()}),Fi=J({type:ne("array"),title:E().optional(),description:E().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({anyOf:te(J({const:E(),title:E()}))}),default:te(E()).optional()}),Rd=_e([Li,Fi]),Id=_e([wl,vl,Rd]),Nn=_e([Id,pl,hl,gl]),Mn=c.extend({mode:ne("form").optional(),message:E(),requestedSchema:J({type:ne("object"),properties:ve(E(),Nn),required:te(E()).optional()}).catchall(Ie())}),$l=c.extend({mode:ne("url"),message:E(),elicitationId:E(),url:E().url()}),fr=_e([Mn,$l]),Pd=l.extend({method:ne("elicitation/create"),params:fr}),jd=u.extend({elicitationId:E()}),Ed=m.extend({method:ne("notifications/elicitation/complete"),params:jd}),Td=d.extend({action:Ce(["accept","decline","cancel"]),content:lo(Xt=>Xt===null?void 0:Xt,ve(E(),_e([E(),me(),xe(),te(E())])).optional())}),Cd=J({type:ne("ref/resource"),uri:E()}),Ad=J({type:ne("ref/prompt"),name:E()}),Od=a.extend({ref:_e([Ad,Cd]),argument:J({name:E(),value:E()}),context:J({arguments:ve(E(),E()).optional()}).optional()}),xl=l.extend({method:ne("completion/complete"),params:Od}),Nd=d.extend({completion:je({values:te(E()).max(100),total:Re(me().int()),hasMore:Re(xe())})}),Md=J({uri:E().startsWith("file://"),name:E().optional(),_meta:ve(E(),Ie()).optional()}),ca=l.extend({method:ne("roots/list"),params:a.optional()}),_l=d.extend({roots:te(Md)}),Dd=m.extend({method:ne("notifications/roots/list_changed"),params:u.optional()}),qd=je({ttl:me().optional(),pollInterval:me().optional()}),kl=Ce(["working","input_required","completed","failed","cancelled"]),Uo=J({taskId:E(),status:kl,ttl:_e([me(),Nr()]),createdAt:E(),lastUpdatedAt:E(),pollInterval:Re(me()),statusMessage:Re(E())}),wn=d.extend({task:Uo}),Ud=u.merge(Uo),Vi=m.extend({method:ne("notifications/tasks/status"),params:Ud}),la=l.extend({method:ne("tasks/get"),params:a.extend({taskId:E()})}),ua=d.merge(Uo),ma=l.extend({method:ne("tasks/result"),params:a.extend({taskId:E()})}),Yb=d.loose(),cn=M.extend({method:ne("tasks/list")}),Rt=L.extend({tasks:te(Uo)}),Zi=l.extend({method:ne("tasks/cancel"),params:a.extend({taskId:E()})});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:S,InitializeRequestParamsSchema:R,InitializeRequestSchema:P,ServerCapabilitiesSchema:j,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:H,ResourceSchema:Y,ResourceTemplateSchema:X,ListResourcesRequestSchema:fe,ListResourcesResultSchema:ye,ListResourceTemplatesRequestSchema:W,ListResourceTemplatesResultSchema:ee,ResourceRequestParamsSchema:re,ReadResourceRequestParamsSchema:de,ReadResourceRequestSchema:ce,ReadResourceResultSchema:pe,ResourceListChangedNotificationSchema:Pe,SubscribeRequestParamsSchema:Je,SubscribeRequestSchema:Ze,UnsubscribeRequestParamsSchema:Ye,UnsubscribeRequestSchema:Qe,ResourceUpdatedNotificationParamsSchema:Ct,ResourceUpdatedNotificationSchema:vt,PromptArgumentSchema:bn,PromptSchema:Gt,ListPromptsRequestSchema:On,ListPromptsResultSchema:Wn,GetPromptRequestParamsSchema:Bn,GetPromptRequestSchema:dr,TextContentSchema:Hn,ImageContentSchema:Mi,AudioContentSchema:Di,ToolUseContentSchema:Xc,EmbeddedResourceSchema:Do,ResourceLinkSchema:Yc,ContentBlockSchema:Jn,PromptMessageSchema:ta,GetPromptResultSchema:na,PromptListChangedNotificationSchema:qi,ToolAnnotationsSchema:Qc,ToolExecutionSchema:ra,ToolSchema:Ui,ListToolsRequestSchema:oa,ListToolsResultSchema:ia,CallToolResultSchema:sa,CallToolRequestParamsSchema:Kt,CallToolRequestSchema:el,ToolListChangedNotificationSchema:Sd,LoggingLevelSchema:aa,SetLevelRequestParamsSchema:tl,SetLevelRequestSchema:nl,LoggingMessageNotificationParamsSchema:rl,LoggingMessageNotificationSchema:ol,ModelHintSchema:il,ModelPreferencesSchema:sl,ToolChoiceSchema:al,ToolResultContentSchema:zd,SamplingContentSchema:cl,SamplingMessageContentBlockSchema:qo,SamplingMessageSchema:ll,CreateMessageRequestParamsSchema:ul,CreateMessageRequestSchema:ml,CreateMessageResultSchema:dl,CreateMessageResultWithToolsSchema:fl,BooleanSchemaSchema:pl,StringSchemaSchema:hl,NumberSchemaSchema:gl,UntitledSingleSelectEnumSchemaSchema:yl,TitledSingleSelectEnumSchemaSchema:bl,LegacyTitledEnumSchemaSchema:wl,SingleSelectEnumSchemaSchema:vl,UntitledMultiSelectEnumSchemaSchema:Li,TitledMultiSelectEnumSchemaSchema:Fi,MultiSelectEnumSchemaSchema:Rd,EnumSchemaSchema:Id,PrimitiveSchemaDefinitionSchema:Nn,ElicitRequestFormParamsSchema:Mn,ElicitRequestURLParamsSchema:$l,ElicitRequestParamsSchema:fr,ElicitRequestSchema:Pd,ElicitationCompleteNotificationParamsSchema:jd,ElicitationCompleteNotificationSchema:Ed,ElicitResultSchema:Td,ResourceTemplateReferenceSchema:Cd,PromptReferenceSchema:Ad,CompleteRequestParamsSchema:Od,CompleteRequestSchema:xl,CompleteResultSchema:Nd,RootSchema:Md,ListRootsRequestSchema:ca,ListRootsResultSchema:_l,RootsListChangedNotificationSchema:Dd,TaskCreationParamsSchema:qd,TaskStatusSchema:kl,TaskSchema:Uo,CreateTaskResultSchema:wn,TaskStatusNotificationParamsSchema:Ud,TaskStatusNotificationSchema:Vi,GetTaskRequestSchema:la,GetTaskResultSchema:ua,GetTaskPayloadRequestSchema:ma,GetTaskPayloadResultSchema:Yb,ListTasksRequestSchema:cn,ListTasksResultSchema:Rt,CancelTaskRequestSchema:Zi,CancelTaskResultSchema:d.merge(Uo),ClientRequestSchema:_e([q,P,xl,nl,dr,On,fe,W,ce,Ze,Qe,el,oa,la,ma,cn,Zi]),ClientNotificationSchema:_e([g,V,T,Dd,Vi]),ClientResultSchema:_e([p,dl,fl,Td,_l,ua,Rt,wn]),ServerRequestSchema:_e([q,ml,Pd,ca,la,ma,cn,Zi]),ServerNotificationSchema:_e([g,V,ol,vt,Pe,Sd,qi,Vi,Ed]),ServerResultSchema:_e([p,N,Nd,na,Wn,ye,ee,pe,sa,ia,ua,Rt,wn]),CallToolResultWireSchema:Ie().superRefine((Xt,IM)=>{if(!(typeof Xt!="object"||Xt===null||Array.isArray(Xt)||Xt.content!==void 0)){for(let uz of Oj)if(uz in Xt){IM.addIssue({code:"custom",message:`content is required when the body carries '${uz}' \u2014 another result family cannot default into an empty tools/call success`});return}}}).transform(rk).pipe(sa)}}var C6;function Nj(){return C6??=T6()}function Mj(e){return e.type!=="object"}var A6=new Set(["const","enum","default","examples"]),O6=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function gj(e){return e!==void 0&&!(typeof e=="string"&&e.startsWith("#"))}function N6(e){let t=typeof e.$schema=="string"?e.$schema:void 0;if(gj(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let r=fz(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&&gj(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:A6.has(c)?s[c]=l:O6.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 Dj={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},qj={"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},M6={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},Ng;function ok(){if(Ng)return Ng;let e=Nj();return Ng={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}},Ng}function Uj(e){return Object.prototype.hasOwnProperty.call(Dj,e)}function Lj(e){return Object.prototype.hasOwnProperty.call(qj,e)}function D6(e){return Object.prototype.hasOwnProperty.call(M6,e)}function q6(e){return D6(e)?ok().resultSchemas[e]:void 0}function U6(e){return Uj(e)?ok().requestSchemas[e]:void 0}function L6(e){return Lj(e)?ok().notificationSchemas[e]:void 0}var HK=Object.keys(Dj),JK=Object.keys(qj);function Q_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Mg(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 yj={ok:!1,reason:"not-in-era"};function bj(e){return Q_(e)&&Q_(e.outputSchema)&&Mj(e.outputSchema)}var ik={era:"2025-11-25",hasRequestMethod:Uj,hasNotificationMethod:Lj,validateRequest:(e,t)=>Mg(U6(e),t),validateResult:(e,t)=>Mg(q6(e),t),validateNotification:(e,t)=>Mg(L6(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>yj,validateInputResponse:()=>yj,samplingResultVariant:((e,t)=>{let r=Nj();return Mg(e?r.CreateMessageResultWithToolsSchema:r.CreateMessageResultSchema,t)}),outboundEnvelope:e=>{},validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let r=Aj(e),o=r.structuredContent;if(o===void 0)return r;let n=typeof o!="object"||o===null||Array.isArray(o),i=t!==void 0&&Mj(t);return!n&&!i?r:{...r,structuredContent:{result:o}}},decodeResult(e,t){if(Q_(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=>bj(o))?t:{...t,tools:r.map(o=>bj(o)?{...o,outputSchema:N6(o.outputSchema)}:o)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>{}};function F6(){let e=ti(()=>_e([E(),me(),xe(),Nr(),ve(E(),e),te(e)])),t=ve(E(),e),r=_e([E(),me().int()]),o=E(),n=_e([E(),me().int()]),i=Ce(["user","assistant"]),s=Ce(["debug","info","notice","warning","error","critical","alert","emergency"]),a=E().refine(Rt=>{try{return atob(Rt),!0}catch{return!1}},{message:"Invalid Base64 string"}),c=J({ttl:me().optional()}),l=J({taskId:E()}),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:E(),params:f.loose().optional()}),h=J({src:E(),mimeType:E().optional(),sizes:te(E()).optional(),theme:Ce(["light","dark"]).optional()}),g=J({icons:te(h).optional()}),b=J({name:E(),title:E().optional()}),y=b.extend({...b.shape,...g.shape,version:E(),websiteUrl:E().optional(),description:E().optional()}),w=yr(J({applyDefaults:xe().optional()}),t),v=lo(Rt=>Rt&&typeof Rt=="object"&&!Array.isArray(Rt)&&Object.keys(Rt).length===0?{form:{}}:Rt,yr(J({form:w.optional(),url:t.optional()}),t.optional())),k=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(E(),t).optional(),sampling:J({context:t.optional(),tools:t.optional()}).optional(),elicitation:v.optional(),roots:J({listChanged:xe().optional()}).optional(),tasks:k.optional(),extensions:ve(E(),t).optional()}),x=J({experimental:ve(E(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:J({listChanged:xe().optional()}).optional(),resources:J({subscribe:xe().optional(),listChanged:xe().optional()}).optional(),tools:J({listChanged:xe().optional()}).optional(),tasks:_.optional(),extensions:ve(E(),t).optional()}),S=J({progress:me(),total:Re(me()),message:Re(E())}),R=J({...f.shape,...S.shape,progressToken:r}),P=p.extend({method:ne("notifications/progress"),params:R}),j=f.extend({level:s,logger:E().optional(),data:Ie()}),N=p.extend({method:ne("notifications/message"),params:j}),T=J({uri:E(),mimeType:Re(E()),_meta:ve(E(),Ie()).optional()}),q=T.extend({text:E()}),Z=T.extend({blob:a}),D=J({audience:te(i).optional(),priority:me().min(0).max(1).optional(),lastModified:Yn.datetime({offset:!0}).optional()}),V=J({...b.shape,...g.shape,uri:E(),description:Re(E()),mimeType:Re(E()),size:Re(me()),annotations:D.optional(),_meta:Re(je({}))}),F=J({...b.shape,...g.shape,uriTemplate:E(),description:Re(E()),mimeType:Re(E()),annotations:D.optional(),_meta:Re(je({}))}),M=p.extend({method:ne("notifications/resources/list_changed"),params:f.optional()}),L=f.extend({uri:E()}),A=p.extend({method:ne("notifications/resources/updated"),params:L}),z=J({name:E(),description:Re(E()),required:Re(xe())}),I=J({...b.shape,...g.shape,description:Re(E()),arguments:Re(te(z)),_meta:Re(je({}))}),C=p.extend({method:ne("notifications/prompts/list_changed"),params:f.optional()}),U=J({type:ne("text"),text:E(),annotations:D.optional(),_meta:ve(E(),Ie()).optional()}),H=J({type:ne("image"),data:a,mimeType:E(),annotations:D.optional(),_meta:ve(E(),Ie()).optional()}),Y=J({type:ne("audio"),data:a,mimeType:E(),annotations:D.optional(),_meta:ve(E(),Ie()).optional()}),X=J({type:ne("tool_use"),name:E(),id:E(),input:ve(E(),Ie()),_meta:ve(E(),Ie()).optional()}),fe=J({type:ne("resource"),resource:_e([q,Z]),annotations:D.optional(),_meta:ve(E(),Ie()).optional()}),ye=V.extend({type:ne("resource_link")}),W=_e([U,H,Y,ye,fe]),ee=J({role:i,content:W}),re=J({title:E().optional(),readOnlyHint:xe().optional(),destructiveHint:xe().optional(),idempotentHint:xe().optional(),openWorldHint:xe().optional()}),de=p.extend({method:ne("notifications/tools/list_changed"),params:f.optional()}),ce=J({name:E().optional()}),pe=J({hints:te(ce).optional(),costPriority:me().min(0).max(1).optional(),speedPriority:me().min(0).max(1).optional(),intelligencePriority:me().min(0).max(1).optional()}),Pe=J({mode:Ce(["auto","required","none"]).optional()}),Je=J({type:ne("boolean"),title:E().optional(),description:E().optional(),default:xe().optional()}),Ze=J({type:ne("string"),title:E().optional(),description:E().optional(),minLength:me().optional(),maxLength:me().optional(),format:Ce(["email","uri","date","date-time"]).optional(),default:E().optional()}),Ye=J({type:Ce(["number","integer"]),title:E().optional(),description:E().optional(),minimum:me().optional(),maximum:me().optional(),default:me().optional()}),Qe=J({type:ne("string"),title:E().optional(),description:E().optional(),enum:te(E()),default:E().optional()}),Ct=J({type:ne("string"),title:E().optional(),description:E().optional(),oneOf:te(J({const:E(),title:E()})),default:E().optional()}),vt=J({type:ne("string"),title:E().optional(),description:E().optional(),enum:te(E()),enumNames:te(E()).optional(),default:E().optional()}),bn=_e([Qe,Ct]),Gt=J({type:ne("array"),title:E().optional(),description:E().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({type:ne("string"),enum:te(E())}),default:te(E()).optional()}),On=J({type:ne("array"),title:E().optional(),description:E().optional(),minItems:me().optional(),maxItems:me().optional(),items:J({anyOf:te(J({const:E(),title:E()}))}),default:te(E()).optional()}),Wn=_e([Gt,On]),Bn=_e([vt,bn,Wn]),dr=_e([Bn,Je,Ze,Ye]),Hn=d.extend({mode:ne("form").optional(),message:E(),requestedSchema:J({type:ne("object"),properties:ve(E(),dr),required:te(E()).optional()}).catchall(Ie())}),Mi=J({type:ne("ref/resource"),uri:E()}),Di=J({type:ne("ref/prompt"),name:E()}),Xc=J({uri:E().startsWith("file://"),name:E().optional(),_meta:ve(E(),Ie()).optional()}),Do=$.shape,Yc=J({experimental:Do.experimental,sampling:Do.sampling,elicitation:Do.elicitation,roots:Do.roots,extensions:Do.extensions}),Jn=x.shape,ta=J({experimental:Jn.experimental,logging:Jn.logging,completions:Jn.completions,prompts:Jn.prompts,resources:Jn.resources,tools:Jn.tools,extensions:Jn.extensions}),na=je({progressToken:r.optional(),[Qn]:E(),[us]:y.optional(),[Mr]:Yc,[oi]:s.optional()}),qi=J({...b.shape,...g.shape,description:E().optional(),inputSchema:je({$schema:E().optional(),type:ne("object")}),outputSchema:je({$schema:E().optional()}).optional(),annotations:re.optional(),_meta:ve(E(),Ie()).optional()}),Qc=J({type:ne("tool_result"),toolUseId:E(),content:te(W),structuredContent:Ie().optional(),isError:xe().optional(),_meta:ve(E(),Ie()).optional()}),ra=_e([U,H,Y,X,Qc]),Ui=J({role:i,content:_e([ra,te(ra)]),_meta:ve(E(),Ie()).optional()}),oa=E(),ia=je({[br]:y.optional().catch(void 0)}),sa=ia.optional();function Kt(Rt){return je({_meta:sa,resultType:oa.default("complete"),...Rt})}let el=Kt({}),Sd=Kt({nextCursor:o.optional()}),aa=Kt({content:te(W),structuredContent:Ie().optional(),isError:xe().optional()}),tl=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),tools:te(qi),nextCursor:o.optional()}),nl=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),prompts:te(I),nextCursor:o.optional()}),rl=Kt({description:E().optional(),messages:te(ee)}),ol=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),resources:te(V),nextCursor:o.optional()}),il=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),resourceTemplates:te(F),nextCursor:o.optional()}),sl=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),contents:te(_e([q,Z]))}),al=Kt({completion:J({values:te(E()).max(100),total:me().int().optional(),hasMore:xe().optional()}).loose()}),zd=Kt({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"])}),cl=Kt({ttlMs:me().int().min(0).catch(0),cacheScope:Ce(["public","private"]).catch("private"),supportedVersions:te(E()),capabilities:ta,instructions:E().optional()}),qo=J({messages:te(Ui),modelPreferences:pe.optional(),systemPrompt:E().optional(),includeContext:Ce(["none","thisServer","allServers"]).optional(),temperature:me().optional(),maxTokens:me().int(),stopSequences:te(E()).optional(),metadata:t.optional(),tools:te(qi).optional(),toolChoice:Pe.optional()}),ll=J({method:ne("sampling/createMessage"),params:qo}),ul=J({method:ne("roots/list"),params:J({_meta:ve(E(),Ie()).optional()}).optional()}),ml=J({...Ui.shape,model:E(),stopReason:E().optional()}),dl=J({roots:te(Xc)}),fl=J({action:Ce(["accept","decline","cancel"]),content:ve(E(),_e([E(),me(),xe(),te(E())])).optional()}),pl=J({mode:ne("url"),message:E(),url:E().url()}),hl=_e([Hn,pl]),gl=J({method:ne("elicitation/create"),params:hl}),yl=_e([ll,ul,gl]),bl=_e([ml,dl,fl]),wl=ve(E(),yl),vl=ve(E(),bl),Li=Kt({inputRequests:wl.optional(),requestState:E().optional()}),Fi={inputResponses:vl.optional(),requestState:E().optional()},Rd=J({_meta:na,...Fi}),Id=je({progressToken:r.optional()});function Nn(Rt,Zi){return J({method:ne(Rt),params:J({_meta:na,...Zi})})}function Mn(Rt,Zi){return J({method:ne(Rt),params:J({_meta:Id.optional(),...Zi}).optional()})}let $l={name:E(),arguments:ve(E(),Ie()).optional(),...Fi},fr={cursor:o.optional()},Pd=Nn("tools/call",$l),jd=Nn("tools/list",fr),Ed=Nn("prompts/list",fr),Td=Nn("prompts/get",{name:E(),arguments:ve(E(),E()).optional(),...Fi}),Cd=Nn("resources/list",fr),Ad=Nn("resources/templates/list",fr),Od=Nn("resources/read",{uri:E(),...Fi}),xl={ref:_e([Di,Mi]),argument:J({name:E(),value:E()}),context:J({arguments:ve(E(),E()).optional()}).optional()},Nd=Nn("completion/complete",xl),Md=Nn("server/discover",{}),ca=J({toolsListChanged:xe().optional(),promptsListChanged:xe().optional(),resourcesListChanged:xe().optional(),resourceSubscriptions:te(E()).optional()}),_l={notifications:ca},Dd=Nn("subscriptions/listen",_l),qd=ia.extend({"io.modelcontextprotocol/subscriptionId":n}),kl=je({_meta:qd,resultType:oa.default("complete")}),Uo={"tools/call":Mn("tools/call",$l),"tools/list":Mn("tools/list",fr),"prompts/get":Mn("prompts/get",{name:E(),arguments:ve(E(),E()).optional()}),"prompts/list":Mn("prompts/list",fr),"resources/list":Mn("resources/list",fr),"resources/templates/list":Mn("resources/templates/list",fr),"resources/read":Mn("resources/read",{uri:E()}),"completion/complete":Mn("completion/complete",xl),"server/discover":Mn("server/discover",{}),"subscriptions/listen":Mn("subscriptions/listen",_l)};function wn(Rt){return je({_meta:sa,...Rt})}let Ud={"tools/call":wn({content:te(W),structuredContent:Ie().optional(),isError:xe().optional()}),"tools/list":wn({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),tools:te(qi),nextCursor:o.optional()}),"prompts/get":wn({description:E().optional(),messages:te(ee)}),"prompts/list":wn({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),prompts:te(I),nextCursor:o.optional()}),"resources/list":wn({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),resources:te(V),nextCursor:o.optional()}),"resources/templates/list":wn({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),resourceTemplates:te(F),nextCursor:o.optional()}),"resources/read":wn({ttlMs:me().int().min(0),cacheScope:Ce(["public","private"]),contents:te(_e([q,Z]))}),"completion/complete":wn({completion:J({values:te(E()).max(100),total:me().int().optional(),hasMore:xe().optional()}).loose()}),"server/discover":wn({ttlMs:me().int().min(0).catch(0),cacheScope:Ce(["public","private"]).catch("private"),supportedVersions:te(E()),capabilities:ta,instructions:E().optional()}),"subscriptions/listen":wn({})},Vi=je({"io.modelcontextprotocol/subscriptionId":n.optional()}),la=J({method:ne("notifications/subscriptions/acknowledged"),params:J({_meta:Vi.optional(),notifications:ca})}),ua=J({_meta:Vi.optional(),requestId:n,reason:E().optional()}),ma=J({method:ne("notifications/cancelled"),params:ua}),Yb={"notifications/cancelled":ma,"notifications/progress":P,"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":la},cn=Rt=>J({jsonrpc:ne("2.0"),id:_e([E(),me().int()]),result:Rt}).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:k,ServerTasksCapabilitySchema:_,ClientCapabilitiesSchema:$,ServerCapabilitiesSchema:x,ProgressSchema:S,ProgressNotificationParamsSchema:R,ProgressNotificationSchema:P,LoggingMessageNotificationParamsSchema:j,LoggingMessageNotificationSchema:N,ResourceContentsSchema:T,TextResourceContentsSchema:q,BlobResourceContentsSchema:Z,AnnotationsSchema:D,ResourceSchema:V,ResourceTemplateSchema:F,ResourceListChangedNotificationSchema:M,ResourceUpdatedNotificationParamsSchema:L,ResourceUpdatedNotificationSchema:A,PromptArgumentSchema:z,PromptSchema:I,PromptListChangedNotificationSchema:C,TextContentSchema:U,ImageContentSchema:H,AudioContentSchema:Y,ToolUseContentSchema:X,EmbeddedResourceSchema:fe,ResourceLinkSchema:ye,ContentBlockSchema:W,PromptMessageSchema:ee,ToolAnnotationsSchema:re,ToolListChangedNotificationSchema:de,ModelHintSchema:ce,ModelPreferencesSchema:pe,ToolChoiceSchema:Pe,BooleanSchemaSchema:Je,StringSchemaSchema:Ze,NumberSchemaSchema:Ye,UntitledSingleSelectEnumSchemaSchema:Qe,TitledSingleSelectEnumSchemaSchema:Ct,LegacyTitledEnumSchemaSchema:vt,SingleSelectEnumSchemaSchema:bn,UntitledMultiSelectEnumSchemaSchema:Gt,TitledMultiSelectEnumSchemaSchema:On,MultiSelectEnumSchemaSchema:Wn,EnumSchemaSchema:Bn,PrimitiveSchemaDefinitionSchema:dr,ElicitRequestFormParamsSchema:Hn,ResourceTemplateReferenceSchema:Mi,PromptReferenceSchema:Di,RootSchema:Xc,ClientCapabilities2026Schema:Yc,ServerCapabilities2026Schema:ta,RequestMetaEnvelopeSchema:na,ToolSchema:qi,ToolResultContentSchema:Qc,SamplingMessageContentBlockSchema:ra,SamplingMessageSchema:Ui,ResultTypeSchema:oa,ResultMetaSchema:ia,ResultSchema:el,PaginatedResultSchema:Sd,CallToolResultSchema:aa,ListToolsResultSchema:tl,ListPromptsResultSchema:nl,GetPromptResultSchema:rl,ListResourcesResultSchema:ol,ListResourceTemplatesResultSchema:il,ReadResourceResultSchema:sl,CompleteResultSchema:al,CacheableResultSchema:zd,DiscoverResultSchema:cl,CreateMessageRequestParamsSchema:qo,CreateMessageRequestSchema:ll,ListRootsRequestSchema:ul,CreateMessageResultSchema:ml,ListRootsResultSchema:dl,ElicitResultSchema:fl,ElicitRequestURLParamsSchema:pl,ElicitRequestParamsSchema:hl,ElicitRequestSchema:gl,InputRequestSchema:yl,InputResponseSchema:bl,InputRequestsSchema:wl,InputResponsesSchema:vl,InputRequiredResultSchema:Li,InputResponseRequestParamsSchema:Rd,CallToolRequestSchema:Pd,ListToolsRequestSchema:jd,ListPromptsRequestSchema:Ed,GetPromptRequestSchema:Td,ListResourcesRequestSchema:Cd,ListResourceTemplatesRequestSchema:Ad,ReadResourceRequestSchema:Od,CompleteRequestSchema:Nd,DiscoverRequestSchema:Md,SubscriptionFilterSchema:ca,SubscriptionsListenRequestSchema:Dd,SubscriptionsListenResultMetaSchema:qd,SubscriptionsListenResultSchema:kl,dispatchRequestSchemas:Uo,dispatchResultSchemas:Ud,NotificationMetaSchema:Vi,SubscriptionsAcknowledgedNotificationSchema:la,CancelledNotificationParamsSchema:ua,CancelledNotificationSchema:ma,notificationSchemas2026:Yb,JSONRPCResultResponseSchema:cn(el),CallToolResultResponseSchema:cn(_e([aa,Li])),ListToolsResultResponseSchema:cn(tl),ListPromptsResultResponseSchema:cn(nl),GetPromptResultResponseSchema:cn(_e([rl,Li])),ListResourcesResultResponseSchema:cn(ol),ListResourceTemplatesResultResponseSchema:cn(il),ReadResourceResultResponseSchema:cn(_e([sl,Li])),CompleteResultResponseSchema:cn(al),DiscoverResultResponseSchema:cn(cl),SubscriptionsListenResultResponseSchema:cn(kl)}}var V6;function di(){return V6??=F6()}var Z6=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function W6(e){return Z6.includes(e)}var uc=Symbol("modelcontextprotocol.resultCacheHintFallback");function Fg(e,t){if(t===void 0)return e;let r=e[uc];if(r===void 0)return{...e,[uc]: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,[uc]:o}}function B6(e){return e[uc]}function sk(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function ak(e){return e==="public"||e==="private"}function ck(e,t){if(e.ttlMs!==void 0&&!sk(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&&!ak(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})({}),ze=class Fj extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return dc(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 dc(this,t)}constructor(t,r,o){super(r),this.code=t,this.data=o,this.name="ProtocolError",nk(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 ys({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 Vg(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 im({requiredCapabilities:n.requiredCapabilities},r)}return new Fj(t,r,o)}},Vg=class extends ze{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 ze{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??[]}},ys=class extends ze{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}},im=class extends ze{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}},H6=0,J6="private",G6=["tools/call","prompts/get","resources/read"];function K6(e,t){let r=t.resultType;if(r===void 0)return{...t,resultType:"complete"};if(r==="complete"||G6.includes(e))return t;throw new ze(ge.InternalError,`Handler for ${e} returned resultType '${String(r)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function X6(e,t){let r=B6(t);if(t.resultType!=="complete"||!W6(e))return r===void 0?t:nU(t);let o=t,n=sk(o.ttlMs)?o.ttlMs:eU(r),i=ak(o.cacheScope)?o.cacheScope:tU(r),s={...o,ttlMs:n,cacheScope:i};return delete s[uc],s}function Y6(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Q6(e,t){if(t===void 0)return e;let r=e._meta;return r===void 0?{...e,_meta:{[br]:t}}:!Y6(r)||r[br]!==void 0?e:{...e,_meta:{...r,[br]:t}}}function eU(e){return e!==void 0&&sk(e.ttlMs)?e.ttlMs:H6}function tU(e){return e!==void 0&&ak(e.cacheScope)?e.cacheScope:J6}function nU(e){let t={...e};return delete t[uc],t}var rU=["elicitation/create","sampling/createMessage","roots/list"],Dg;function Zj(){if(Dg)return Dg;let e=di();return Dg={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}},Dg}function Wj(e){return rU.includes(e)}function J_(e){return Wj(e)?Zj().request[e]:void 0}function oU(e){return Wj(e)?Zj().response[e]:void 0}var lk={"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},Bj={"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 Hj(e){return Object.prototype.hasOwnProperty.call(lk,e)}function Jj(e){return Object.prototype.hasOwnProperty.call(Bj,e)}function iU(e){return Object.prototype.hasOwnProperty.call(lk,e)}function sU(e){return Hj(e)?di().dispatchRequestSchemas[e]:void 0}function aU(e){return iU(e)?di().dispatchResultSchemas[e]:void 0}function cU(e){return Jj(e)?di().notificationSchemas2026[e]:void 0}var GK=Object.keys(lk),KK=Object.keys(Bj);function Qu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Xu(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 lU={ok:!1,reason:"not-in-era"},uU=[Qn,Mr];function mU(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=>Qu(a)&&"execution"in a)&&(n().tools=i.map(a=>{if(!Qu(a)||!("execution"in a))return a;let c={...a};return delete c.execution,c}));let s=t.capabilities;if(Qu(s)&&"tasks"in s){let a={...s};delete a.tasks,n().capabilities=a}return r}var uk={era:"2026-07-28",hasRequestMethod:Hj,hasNotificationMethod:Jj,hasInputRequestMethod:e=>J_(e)!==void 0,validateRequest:(e,t)=>Xu(sU(e),t),validateResult:(e,t)=>Xu(aU(e),t),validateNotification:(e,t)=>Xu(cU(e),t),validateInputRequest:(e,t)=>Xu(J_(e),t),validateInputResponse:(e,t)=>Xu(oU(e),t),samplingResultVariant:()=>lU,outboundEnvelope(e){return{[Qn]:e.protocolVersion,[us]:e.clientInfo,[Mr]:e.clientCapabilities,...e.logLevel!==void 0&&{[oi]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let o of uU)o in e||t.push({key:o,problem:"missing"});let r=di().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=>Aj(e),inputRequestSchema:J_,decodeResult(e,t){if(!Qu(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=Qu(s)?s:{},c=t.requestState,l=t._meta===void 0?void 0:di().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=dU(),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 Q6(X6(e,K6(e,mU(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=di().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("; ")}`}},qg;function dU(){if(qg)return qg;let e=di();return qg={"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},qg}var sm="2026-07-28";function fo(e){return e!==void 0&&po(e)?uk:ik}function wj(e){return e.revision!==void 0?fo(e.revision).era:e.era==="modern"?uk.era:ik.era}function G_(e){return Gj.some(t=>t.hasRequestMethod(e))}function K_(e){return Gj.some(t=>t.hasNotificationMethod(e))}function vj(e){return e==="tasks/get"||e==="tasks/cancel"}var Gj=[ik,uk];function $j(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function vr(e){if(!$j(e))return;let t=e._meta;return $j(t)?t:void 0}function bs(e){let t=vr(e);return t!==void 0&&Qn in t}function pc(e){let t=vr(e)?.[Qn];return typeof t=="string"?t:void 0}function hs(e){return fo(sm).validateEnvelopeMeta(e)}var fU=mz({AnnotationsSchema:()=>mo,AudioContentSchema:()=>oc,BaseMetadataSchema:()=>uo,BaseRequestParamsSchema:()=>Ut,BlobResourceContentsSchema:()=>qu,BooleanSchemaSchema:()=>Zu,CallToolRequestParamsSchema:()=>Gh,CallToolRequestSchema:()=>Kh,CallToolResultSchema:()=>Vu,CancelTaskRequestSchema:()=>E_,CancelTaskResultSchema:()=>T_,CancelledNotificationParamsSchema:()=>Qp,CancelledNotificationSchema:()=>Tu,ClientCapabilitiesSchema:()=>rh,ClientNotificationSchema:()=>A_,ClientRequestSchema:()=>C_,ClientResultSchema:()=>O_,ClientTasksCapabilitySchema:()=>th,CompatibilityCallToolResultSchema:()=>v_,CompleteRequestParamsSchema:()=>_g,CompleteRequestSchema:()=>kg,CompleteResultSchema:()=>Sg,ContentBlockSchema:()=>ic,CreateMessageRequestParamsSchema:()=>cg,CreateMessageRequestSchema:()=>lg,CreateMessageResultSchema:()=>ug,CreateMessageResultWithToolsSchema:()=>mg,CreateTaskResultSchema:()=>__,CursorSchema:()=>zu,DiscoverRequestSchema:()=>ah,DiscoverResultSchema:()=>ch,ElicitRequestFormParamsSchema:()=>cc,ElicitRequestParamsSchema:()=>gg,ElicitRequestSchema:()=>yg,ElicitRequestURLParamsSchema:()=>hg,ElicitResultSchema:()=>vg,ElicitationCompleteNotificationParamsSchema:()=>bg,ElicitationCompleteNotificationSchema:()=>wg,EmbeddedResourceSchema:()=>Uh,EmptyResultSchema:()=>Eu,EnumSchemaSchema:()=>pg,GetPromptRequestParamsSchema:()=>Mh,GetPromptRequestSchema:()=>Dh,GetPromptResultSchema:()=>Vh,GetTaskPayloadRequestSchema:()=>R_,GetTaskPayloadResultSchema:()=>I_,GetTaskRequestSchema:()=>S_,GetTaskResultSchema:()=>z_,IconSchema:()=>eh,IconsSchema:()=>si,ImageContentSchema:()=>rc,ImplementationSchema:()=>ec,InitializeRequestParamsSchema:()=>oh,InitializeRequestSchema:()=>Cu,InitializeResultSchema:()=>ih,InitializedNotificationSchema:()=>sh,JSONArraySchema:()=>y_,JSONObjectSchema:()=>_t,JSONRPCErrorResponseSchema:()=>Qa,JSONRPCMessageSchema:()=>fs,JSONRPCNotificationSchema:()=>ju,JSONRPCRequestSchema:()=>Pu,JSONRPCResponseSchema:()=>b_,JSONRPCResultResponseSchema:()=>Ya,JSONValueSchema:()=>ni,LegacyTitledEnumSchemaSchema:()=>Hu,ListChangedOptionsBaseSchema:()=>$_,ListPromptsRequestSchema:()=>Oh,ListPromptsResultSchema:()=>Nh,ListResourceTemplatesRequestSchema:()=>hh,ListResourceTemplatesResultSchema:()=>gh,ListResourcesRequestSchema:()=>fh,ListResourcesResultSchema:()=>ph,ListRootsRequestSchema:()=>Rg,ListRootsResultSchema:()=>Ig,ListTasksRequestSchema:()=>P_,ListTasksResultSchema:()=>j_,ListToolsRequestSchema:()=>Hh,ListToolsResultSchema:()=>Jh,LoggingLevelSchema:()=>ui,LoggingMessageNotificationParamsSchema:()=>eg,LoggingMessageNotificationSchema:()=>tg,ModelHintSchema:()=>ng,ModelPreferencesSchema:()=>rg,MultiSelectEnumSchemaSchema:()=>fg,NotificationSchema:()=>en,NotificationsParamsSchema:()=>Qt,NumberSchemaSchema:()=>ac,PaginatedRequestParamsSchema:()=>mh,PaginatedRequestSchema:()=>ai,PaginatedResultSchema:()=>ci,PingRequestSchema:()=>Ou,PrimitiveSchemaDefinitionSchema:()=>Ku,ProgressNotificationParamsSchema:()=>uh,ProgressNotificationSchema:()=>Nu,ProgressSchema:()=>lh,ProgressTokenSchema:()=>Su,PromptArgumentSchema:()=>Ch,PromptListChangedNotificationSchema:()=>Zh,PromptMessageSchema:()=>Fh,PromptReferenceSchema:()=>xg,PromptSchema:()=>Ah,ReadResourceRequestParamsSchema:()=>yh,ReadResourceRequestSchema:()=>bh,ReadResourceResultSchema:()=>wh,RelatedTaskMetadataSchema:()=>Yp,RequestIdSchema:()=>ii,RequestMetaSchema:()=>Ru,RequestSchema:()=>kt,ResourceContentsSchema:()=>Mu,ResourceLinkSchema:()=>Lh,ResourceListChangedNotificationSchema:()=>vh,ResourceRequestParamsSchema:()=>tc,ResourceSchema:()=>Uu,ResourceTemplateReferenceSchema:()=>$g,ResourceTemplateSchema:()=>dh,ResourceUpdatedNotificationParamsSchema:()=>Eh,ResourceUpdatedNotificationSchema:()=>Th,ResultMetaObjectSchema:()=>Iu,ResultSchema:()=>St,RoleSchema:()=>li,RootSchema:()=>zg,RootsListChangedNotificationSchema:()=>Pg,SamplingContentSchema:()=>sg,SamplingMessageContentBlockSchema:()=>cs,SamplingMessageSchema:()=>ag,ServerCapabilitiesSchema:()=>Au,ServerNotificationSchema:()=>M_,ServerRequestSchema:()=>N_,ServerResultSchema:()=>D_,ServerTasksCapabilitySchema:()=>nh,SetLevelRequestParamsSchema:()=>Yh,SetLevelRequestSchema:()=>Qh,SingleSelectEnumSchemaSchema:()=>dg,StringSchemaSchema:()=>sc,SubscribeRequestParamsSchema:()=>$h,SubscribeRequestSchema:()=>xh,SubscriptionFilterSchema:()=>Lu,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Rh,SubscriptionsAcknowledgedNotificationSchema:()=>Ih,SubscriptionsListenRequestParamsSchema:()=>Sh,SubscriptionsListenRequestSchema:()=>zh,SubscriptionsListenResultMetaSchema:()=>Ph,SubscriptionsListenResultSchema:()=>jh,TaskAugmentedRequestParamsSchema:()=>ds,TaskCreationParamsSchema:()=>x_,TaskMetadataSchema:()=>Xp,TaskSchema:()=>mi,TaskStatusNotificationParamsSchema:()=>Eg,TaskStatusNotificationSchema:()=>k_,TaskStatusSchema:()=>jg,TextContentSchema:()=>nc,TextResourceContentsSchema:()=>Du,TitledMultiSelectEnumSchemaSchema:()=>Gu,TitledSingleSelectEnumSchemaSchema:()=>Bu,ToolAnnotationsSchema:()=>Wh,ToolChoiceSchema:()=>og,ToolExecutionSchema:()=>Bh,ToolListChangedNotificationSchema:()=>Xh,ToolResultContentSchema:()=>ig,ToolSchema:()=>Fu,ToolUseContentSchema:()=>qh,UnsubscribeRequestParamsSchema:()=>_h,UnsubscribeRequestSchema:()=>kh,UntitledMultiSelectEnumSchemaSchema:()=>Ju,UntitledSingleSelectEnumSchemaSchema:()=>Wu});var It=e=>Pu.safeParse(e).success,Dr=e=>ju.safeParse(e).success,tr=e=>Ya.safeParse(e).success,nr=e=>Qa.safeParse(e).success;var ho=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var mk=e=>Cu.safeParse(e).success;function dk(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function fk(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var pU="Mcp-Param-",xj="x-mcp-header",hU=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,gU=new Set(["string","integer","boolean"]);function Zg(e){let t=[],r=new Map,o,n=(s,a,c)=>{if(s===null||typeof s!="object")return;let l=s;if(xj in l){if(!c||a.length===0)return`${lc(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[xj];if(typeof m!="string"||m.length===0)return`${lc(a)}: x-mcp-header MUST be a non-empty string`;if(!hU.test(m))return`${lc(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||!gU.has(d)){let h=`${lc(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 yU){let d=l[m];if(d===void 0)continue;let f=Array.isArray(d)?d:d!==null&&typeof d=="object"&&bU.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 yU=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],bU=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function lc(e){return e.length===0?"<root>":e.join(".")}var wU="=?base64?",vU="?=",$U=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,xU=/^-?\d+(\.\d+)?$/;function _U(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 kU(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 Kj(e){if(!(e.startsWith(wU)&&e.endsWith(vU)))return e;let t=e.slice(9,e.length-2);if($U.test(t))try{return kU(t)}catch{return}}function SU(e,t){let r=e;for(let o of t){if(r===null||typeof r!="object")return;r=r[o]}return r}function Xj(e,t,r){for(let o of e){let n=`${pU}${o.headerName}`,i=r.get(n),s=SU(t,o.path);if(s==null)continue;let a=_U(s);if(a===void 0)continue;if(i===null)return X_("param-header-missing",n,`the body carries ${lc(o.path)}=${JSON.stringify(s)} but the ${n} header is absent`);let c=Kj(i);if(c===void 0)return X_("param-header-invalid-encoding",n,`the ${n} header carries an invalid Base64 sentinel value`);if(!((o.type==="integer"||o.type==="number")&&xU.test(c)&&typeof s=="number"?Number(c)===s:c===a))return X_("param-header-mismatch",n,`the ${n} header decodes to ${JSON.stringify(c)} but the body carries ${lc(o.path)}=${JSON.stringify(s)}`)}}function X_(e,t,r){return{kind:"reject",rung:"param-header-validation",cell:e,httpStatus:400,code:mc,message:`Bad Request: the request headers and body disagree: ${r}`,data:{mismatch:{header:t,body:r}},settled:!0}}var mc=-32020,XK=[{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:[mc,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:[mc],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:[mc],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."}],pk={[ge.ParseError]:400,[ge.InvalidRequest]:400,[ge.MethodNotFound]:404,[ge.UnsupportedProtocolVersion]:400,[ge.MissingRequiredClientCapability]:400,[mc]:400};function Yj(e,t){return t==="in-band"?e===ge.MissingRequiredClientCapability?400:200:pk[e]??400}function er(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 wr(e,t,r,o="era-classification"){return er(o,e,400,new ze(mc,`Bad Request: the request headers and body disagree: ${r}`,{mismatch:{header:t,body:r}}),!0)}var _j={"tools/call":"name","prompts/get":"name","resources/read":"uri","tasks/get":"taskId","tasks/update":"taskId","tasks/cancel":"taskId"};function zU(e,t){let r=Object.hasOwn(_j,e)?_j[e]:void 0;if(r===void 0)return;let o=tm(t)?t[r]:void 0;return{field:r,value:typeof o=="string"?o:void 0}}function Ug(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 Qj(e,t){if(t.messageKind!=="request")return;let r=t.message.method;if(e.protocolVersionHeader===void 0){let c=t.classification.revision;return wr("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 wr("method-header-missing","(missing)",`the body names method ${r} but the required Mcp-Method header is absent`,"standard-header-validation");let o=zU(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:wr("name-header-missing","(missing)",`the body carries params.${n}="${i}" but the required Mcp-Name header is absent`,"standard-header-validation");let s=Ug(e.mcpNameHeader),a=Kj(s);if(a===void 0)return wr("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 wr("name-header-mismatch",s,`the body carries params.${n}="${i}" but the Mcp-Name header names "${a}"`,"standard-header-validation")}function tm(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function eE(e){return e===void 0?{era:"modern"}:{era:po(e)?"modern":"legacy",revision:e}}function Wg(e){if(!bs(e))return!1;let t=pc(e);if(t===void 0||!po(t))return!1;let r=vr(e);return r!==void 0&&hs(r).length===0}function RU(e){if(e.length===0)return er("jsonrpc-shape","empty-batch",400,new ze(ge.InvalidRequest,"Bad Request: empty JSON-RPC batch"),!0);for(let t of e){if(bs(tm(t)?t.params:void 0))return er("jsonrpc-shape","batch-with-modern-element",400,new ze(ge.InvalidRequest,"Bad Request: JSON-RPC batches may not contain requests for protocol revision 2026-07-28 or later"),!0);if(!(It(t)||Dr(t)||tr(t)||nr(t)))return er("jsonrpc-shape","batch-with-invalid-element",400,new ze(ge.InvalidRequest,"Bad Request: JSON-RPC batch contains an invalid message"),!0)}return{kind:"legacy",reason:"batch"}}function IU(e,t){let r=t.params,o=t.method,n=e.protocolVersionHeader,i=n!==void 0&&po(n);if(o==="initialize"&&!Wg(r)){if(i)return wr("initialize-with-modern-header",n,"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header");let s=tm(r)&&typeof r.protocolVersion=="string"?r.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...s!==void 0&&{requestedVersion:s}}}if(bs(r)){let s=vr(r),a=(s===void 0?[]:hs(s))[0];if(a!==void 0)return er("envelope","envelope-invalid",400,new ze(ge.InvalidParams,`Invalid _meta envelope for protocol revision 2026-07-28: ${a.key}: ${a.problem}`,{envelope:a}),!0);let c=pc(r);return n!==void 0&&c!==void 0&&n!==c?wr("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?wr("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:eE(c)}}if(i){let s=vr(r),a=hs(s??{}).filter(l=>l.problem==="missing").map(l=>l.key),c=s===void 0?["_meta"]:a.length>0?a:[Qn];return er("envelope","modern-header-without-claim",400,new ze(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 PU(e,t){let r=t.params,o=t.method,n=e.protocolVersionHeader,i=n!==void 0&&po(n);if(bs(r)){let s=pc(r);if(s===void 0){let c=vr(r),l=(c===void 0?[]:hs(c)).find(u=>u.key===Qn)??{key:Qn,problem:"expected a protocol version string"};return er("envelope","notification-envelope-invalid",400,new ze(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 wr("notification-header-body-version-mismatch",n,`the notification envelope names protocol version ${s} but the MCP-Protocol-Version header names ${n}`);let a=eE(s);return a.era==="modern"&&e.mcpMethodHeader!==void 0&&e.mcpMethodHeader!==o?wr("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?wr("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 tE(e){if(e={...e,...e.protocolVersionHeader!==void 0&&{protocolVersionHeader:Ug(e.protocolVersionHeader)},...e.mcpMethodHeader!==void 0&&{mcpMethodHeader:Ug(e.mcpMethodHeader)},...e.mcpNameHeader!==void 0&&{mcpNameHeader:Ug(e.mcpNameHeader)}},e.httpMethod.toUpperCase()!=="POST")return{kind:"legacy",reason:"http-method"};let t=e.body;return Array.isArray(t)?RU(t):tr(t)||nr(t)?{kind:"legacy",reason:"response"}:tm(t)&&It(t)?IU(e,t):tm(t)&&Dr(t)?PU(e,t):er("jsonrpc-shape","invalid-json-rpc-body",400,new ze(ge.InvalidRequest,"Bad Request: the request body is not a valid JSON-RPC message"),!0)}function Bg(e,t){switch(e.reason){case"http-method":return er("http-method","modern-only-method-not-allowed",405,new ze(-32e3,"Method not allowed."),!0);case"batch":return er("jsonrpc-shape","modern-only-batch-not-supported",400,new ze(ge.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return er("jsonrpc-shape","modern-only-response-post",400,new ze(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 er("era-classification","modern-only-missing-envelope",400,r===void 0?new ze(ge.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new ys({supported:[...t],requested:r}),!0)}}}function Hg(e,t){return mu(e,t)}function Yu(e){return new Set(e.flatMap(t=>Object.keys(t.shape)))}function fc(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 kj=!1,ek="draft-2020-12";function ws(e,t="input"){let r=e["~standard"],o;if(r.jsonSchema)o=r.jsonSchema[t]({target:ek});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().");kj||(kj=!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=os(e,{target:ek,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:nE(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 jU=/^#\/(\$defs|definitions)\/([^/~%]+)$/;function nE(e,t=e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;let r=typeof e.$ref=="string"&&jU.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"||nE(i,"$id"in i?{}:t)))}return!1}function EU(e){return e.path?.length?`${e.path.map(t=>String(typeof t=="object"?t.key:t)).join(".")}: ${e.message}`:e.message}async function ps(e,t){let r=await e["~standard"].validate(t);return r.issues&&r.issues.length>0?{success:!1,error:r.issues.map(o=>EU(o)).join(", ")}:{success:!0,data:r.value}}function TU(e){let t=os(e,{target:ek,io:"input"});return typeof t.pattern=="string"?t.pattern:void 0}var CU=/\\\.\\d\{(\d+)\}/;function AU(e){let t=CU.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=>Yn.datetime({local:o,offset:n,precision:i}))))}function OU(e,t){let r;switch(e){case"email":r=[zp()];break;case"uri":r=[Ha()];break;case"date":r=[Yn.date()];break;case"date-time":r=AU(t);break}return new Set(r.map(o=>TU(o)).filter(o=>o!==void 0))}function NU(e,t,r){return r!=="zod"?!0:OU(e,t).has(t)}function rE(e){let t=ws(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 nm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function MU(e){try{return ws(e,"input")}catch(t){let r=t instanceof Error?t.message:String(t);throw new ze(ge.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${r}`)}}var DU=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function hk(e){return DU.has(e)||e.startsWith("x-")}var qU=new Set(["$schema",...Object.keys(cc.shape.requestedSchema.shape)]),Sj={string:Yu([sc,Wu,Bu,Hu]),number:Yu([ac]),integer:Yu([ac]),boolean:Yu([Zu]),array:Yu([Ju,Gu])},UU=new Set(sc.shape.format.unwrap().options);function LU(e,t,r,o){if(!nm(e))return e;let n=typeof e.type=="string"&&Object.hasOwn(Sj,e.type)?Sj[e.type]:void 0;if(n===void 0)return e;let i={};for(let[s,a]of Object.entries(e))n.has(s)||hk(s)?i[s]=a:s==="pattern"&&e.type==="string"&&typeof e.format=="string"?UU.has(e.format)?(typeof a!="string"||!NU(e.format,a,r))&&o.push(`${t}.${s}`):i[s]=a:o.push(`${t}.${s}`);return i}function FU(e,t){let r={},o=[];for(let[n,i]of Object.entries(e))n==="properties"&&nm(i)?r[n]=Object.fromEntries(Object.entries(i).map(([s,a])=>[s,LU(a,`properties.${s}`,t,o)])):qU.has(n)?r[n]=i:hk(n)||o.push(n);if(o.length>0)throw new ze(ge.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${o.join(", ")}`);return r}function VU(e,t){if(!nm(e.properties))return t;let r=Object.entries(e.properties).filter(([,o])=>!Hg(Ku,o).success).map(([o])=>`properties.${o}`);return r.length>0?r.join(", "):t}function tk(e,t,r=""){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((o,n)=>tk(o,t[n],`${r}[${n}]`)):!nm(e)||!nm(t)?[]:Object.entries(e).flatMap(([o,n])=>{let i=r?`${r}.${o}`:o;return Object.prototype.hasOwnProperty.call(t,o)?tk(n,t[o],i):hk(o)?[]:[i]})}function ZU(e){if(!fc(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,r=FU(MU(e.requestedSchema),t),o=Hg(cc.shape.requestedSchema,r);if(!o.success)throw new ze(ge.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${VU(r,o.error.message)}`);let n=tk(r,o.data);if(n.length>0)throw new ze(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 ze(ge.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:o.data}}function WU(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 BU=Object.assign(WU,{elicit(e){try{return{method:"elicitation/create",params:ZU(e)}}catch(t){throw t instanceof ze?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 oE=250;function iE(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function sE(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 aE(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 HU=["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"],JU={IdJagTokenExchangeResponseSchema:V_,OAuthClientInformationFullSchema:W_,OAuthClientInformationSchema:Og,OAuthClientMetadataSchema:Ag,OAuthClientRegistrationErrorSchema:B_,OAuthErrorResponseSchema:Z_,OAuthMetadataSchema:Tg,OAuthProtectedResourceMetadataSchema:U_,OAuthTokenRevocationRequestSchema:H_,OAuthTokensSchema:F_,OpenIdProviderDiscoveryMetadataSchema:L_,OpenIdProviderMetadataSchema:Cg},cE={},lE={};function uE(e,t){let r=e.slice(0,-6);cE[r]=t,lE[r]=o=>t.safeParse(o).success}for(let e of HU)uE(e,fU[e]);for(let[e,t]of Object.entries(JU))uE(e,t);var GU=Object.freeze(cE),KU=Object.freeze(lE);function XU(e){switch(e){case"initialize":case"notifications/initialized":return fo(void 0);case"server/discover":return fo(sm);default:return}}var mE=6e4,YU=[Qn,us,Mr,oi],QU=["inputResponses","requestState"];function zj(e,t){let r=e.params;if(!em(r))return{message:e,lifted:{}};let o=r._meta,n=em(o)?YU.filter(c=>c in o):[],i=t==="request"?QU.filter(c=>c in r):[];if(n.length===0&&i.length===0)return{message:e,lifted:{}};let s={},a={...r};if(n.length>0&&em(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 Rj(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 am(e){return()=>e}var eL=am(void 0);function gk(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:am(t)}}}var dE;function Jg(e,t){dE(e,t)}var yk=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{dE=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??ku,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),tr(n)||nr(n)?this._onresponse(n):It(n)?this._onrequest(n,i):Dr(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}=zj(e,"notification"),o=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let s=wj(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(K_(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}=zj(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=wj(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(G_(r.method)&&!n.hasRequestMethod(r.method)&&!(vj(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:tL(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?eL:am(o.requestState),signal:m.signal,send:((h,g,b)=>{let y=this._resolveOutboundCodec(h.method);if(this._assertOutboundRequestInEra(y,h.method),fc(g))return u(h,g,b);let w=Rj(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),tr(e)?r(e):r(ze.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(fc(t))return vj(e.method)||this._assertOutboundRequestInEra(o,e.method),this._requestWithSchemaViaCodec(o,e,t,r);this._assertOutboundRequestInEra(o,e.method);let n=Rj(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 fo(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=XU(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(G_(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===sm&&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(S){return d(S instanceof Error?S:new Error(String(S)))}if($.kind==="invalid")return d($.error);if($.kind==="input_required"){if(o?.allowInputRequired===!0)return m(nL($));let S={codec:e,request:t,resultSchema:r,options:o,flowStartedAt:c,retry:(R,P)=>this._requestWithSchemaViaCodec(e,R===void 0?{method:t.method}:{method:t.method,params:R},r,P)};return m(this._resolveNonCompleteResult($,S))}let x=$.result;ps(r,x).then(S=>{S.success?m(S.data):d(new Oe(Ue.InvalidResult,`Invalid result for ${t.method}: ${S.error}`))},d)}),l=()=>w(o?.signal?.reason),o?.signal?.addEventListener("abort",l,{once:!0});let v=o?.timeout??mE,k=()=>w(new Oe(Ue.RequestTimeout,"Request timed out",{timeout:v}));this._setupTimeout(h,v,o?.maxTotalTimeout,k,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(K_(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(!G_(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 ze(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 ps(t.params,{...n.params});if(!s.success)throw new ze(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(!K_(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 ze(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 ps(t.params,{...o.params});if(!n.success)throw new ze(ge.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await r(n.data,o)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function em(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function bk(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]=em(s)&&em(i)?{...s,...i}:i}return r}function Ij(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function tL(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 nL(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var rL=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}})),oL=Fd(rL(),1);function wk(e){if(e)try{return oL.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function vk(e){return e==="application/json"?!0:wk(e)==="application/json"}var fE=10*1024*1024,$k=class{_buffer;_maxBufferSize;constructor(e){this._maxBufferSize=e?.maxBufferSize??fE}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 pE(t)}catch(r){if(r instanceof SyntaxError)continue;throw r}}return null}clear(){this._buffer=void 0}};function pE(e){return fs.parse(JSON.parse(e))}function xk(e){return JSON.stringify(e)+`
66
+ `}var iL=/^[A-Za-z0-9._-]{1,128}$/;function sL(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"),!iL.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 aL(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 _k(e){let t=sL(e);return aL(e,t.warnings),t.isValid}function cL(e){return typeof e=="object"&&e!==null&&"_zod"in e}function lL(e){return typeof e=="object"&&e!==null&&!("_zod"in e)&&"_def"in e&&typeof e._def?.typeName=="string"}function uL(e){if(typeof e!="object"||e===null||fc(e))return!1;let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null?!1:Object.values(e).every(r=>cL(r))}function Gg(e){if(e!==void 0){if(uL(e))return J(e);if(typeof e=="object"&&e!==null&&!fc(e)&&Object.values(e).some(t=>lL(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(!fc(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 Xg=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})),hE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Xg();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=Xg(),r=hE();var o=Xg();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=hE();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,I){return this}},s=class extends i{constructor(z,I,C){super(),this.varKind=z,this.name=I,this.rhs=C}render({es5:z,_n:I}){let C=z?r.varKinds.var:this.varKind,U=this.rhs===void 0?"":` = ${this.rhs}`;return`${C} ${this.name}${U};`+I}optimizeNames(z,I){if(z[this.name.str])return this.rhs&&(this.rhs=T(this.rhs,z,I)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},a=class extends i{constructor(z,I,C){super(),this.lhs=z,this.rhs=I,this.sideEffects=C}render({_n:z}){return`${this.lhs} = ${this.rhs};`+z}optimizeNames(z,I){if(!(this.lhs instanceof t.Name&&!z[this.lhs.str]&&!this.sideEffects))return this.rhs=T(this.rhs,z,I),this}get names(){return N(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends a{constructor(z,I,C,U){super(z,C,U),this.op=I}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,I){return this.code=T(this.code,z,I),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((I,C)=>I+C.render(z),"")}optimizeNodes(){let{nodes:z}=this,I=z.length;for(;I--;){let C=z[I].optimizeNodes();Array.isArray(C)?z.splice(I,1,...C):C?z[I]=C:z.splice(I,1)}return z.length>0?this:void 0}optimizeNames(z,I){let{nodes:C}=this,U=C.length;for(;U--;){let H=C[U];H.optimizeNames(z,I)||(q(z,H.names),C.splice(U,1))}return C.length>0?this:void 0}get names(){return this.nodes.reduce((z,I)=>j(z,I.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 Kg extends p{constructor(I,C){super(C),this.condition=I}render(I){let C=`if(${this.condition})`+super.render(I);return this.else&&(C+="else "+this.else.render(I)),C}optimizeNodes(){super.optimizeNodes();let I=this.condition;if(I===!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 I===!1?C instanceof Kg?C:C.nodes:this.nodes.length?this:new Kg(Z(I),C instanceof Kg?[C]:C.nodes);if(!(I===!1||!this.nodes.length))return this}optimizeNames(I,C){var U;if(this.else=(U=this.else)===null||U===void 0?void 0:U.optimizeNames(I,C),!!(super.optimizeNames(I,C)||this.else))return this.condition=T(this.condition,I,C),this}get names(){let I=super.names;return N(I,this.condition),this.else&&j(I,this.else.names),I}};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,I){if(super.optimizeNames(z,I))return this.iteration=T(this.iteration,z,I),this}get names(){return j(super.names,this.iteration.names)}},v=class extends y{constructor(z,I,C,U){super(),this.varKind=z,this.name=I,this.from=C,this.to=U}render(z){let I=z.es5?r.varKinds.var:this.varKind,{name:C,from:U,to:H}=this;return`for(${I} ${C}=${U}; ${C}<${H}; ${C}++)`+super.render(z)}get names(){return N(N(super.names,this.from),this.to)}},k=class extends y{constructor(z,I,C,U){super(),this.loop=z,this.varKind=I,this.name=C,this.iterable=U}render(z){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(z)}optimizeNames(z,I){if(super.optimizeNames(z,I))return this.iterable=T(this.iterable,z,I),this}get names(){return j(super.names,this.iterable.names)}},_=class extends p{constructor(z,I,C){super(),this.name=z,this.args=I,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 I="try"+super.render(z);return this.catch&&(I+=this.catch.render(z)),this.finally&&(I+=this.finally.render(z)),I}optimizeNodes(){var z,I;return super.optimizeNodes(),(z=this.catch)===null||z===void 0||z.optimizeNodes(),(I=this.finally)===null||I===void 0||I.optimizeNodes(),this}optimizeNames(z,I){var C,U;return super.optimizeNames(z,I),(C=this.catch)===null||C===void 0||C.optimizeNames(z,I),(U=this.finally)===null||U===void 0||U.optimizeNames(z,I),this}get names(){let z=super.names;return this.catch&&j(z,this.catch.names),this.finally&&j(z,this.finally.names),z}},S=class extends p{constructor(z){super(),this.error=z}render(z){return`catch(${this.error})`+super.render(z)}};S.kind="catch";var R=class extends p{render(z){return"finally"+super.render(z)}};R.kind="finally";var P=class{constructor(z,I={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...I,_n:I.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,I){let C=this._extScope.value(z,I);return(this._values[C.prefix]||(this._values[C.prefix]=new Set)).add(C),C}getScopeValue(z,I){return this._extScope.getValue(z,I)}scopeRefs(z){return this._extScope.scopeRefs(z,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(z,I,C,U){let H=this._scope.toName(I);return C!==void 0&&U&&(this._constants[H.str]=C),this._leafNode(new s(z,H,C)),H}const(z,I,C){return this._def(r.varKinds.const,z,I,C)}let(z,I,C){return this._def(r.varKinds.let,z,I,C)}var(z,I,C){return this._def(r.varKinds.var,z,I,C)}assign(z,I,C){return this._leafNode(new a(z,I,C))}add(z,I){return this._leafNode(new c(z,e.operators.ADD,I))}code(z){return typeof z=="function"?z():z!==t.nil&&this._leafNode(new d(z)),this}object(...z){let I=["{"];for(let[C,U]of z)I.length>1&&I.push(","),I.push(C),(C!==U||this.opts.es5)&&(I.push(":"),(0,t.addCodeArg)(I,U));return I.push("}"),new t._Code(I)}if(z,I,C){if(this._blockNode(new b(z)),I&&C)this.code(I).else().code(C).endIf();else if(I)this.code(I).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,I){return this._blockNode(z),I&&this.code(I).endFor(),this}for(z,I){return this._for(new w(z),I)}forRange(z,I,C,U,H=this.opts.es5?r.varKinds.var:r.varKinds.let){let Y=this._scope.toName(z);return this._for(new v(H,Y,I,C),()=>U(Y))}forOf(z,I,C,U=r.varKinds.const){let H=this._scope.toName(z);if(this.opts.es5){let Y=I instanceof t.Name?I:this.var("_arr",I);return this.forRange("_i",0,(0,t._)`${Y}.length`,X=>{this.var(H,(0,t._)`${Y}[${X}]`),C(H)})}return this._for(new k("of",U,H,I),()=>C(H))}forIn(z,I,C,U=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(z,(0,t._)`Object.keys(${I})`,C);let H=this._scope.toName(z);return this._for(new k("in",U,H,I),()=>C(H))}endFor(){return this._endBlockNode(y)}label(z){return this._leafNode(new l(z))}break(z){return this._leafNode(new u(z))}return(z){let I=new $;if(this._blockNode(I),this.code(z),I.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode($)}try(z,I,C){if(!I&&!C)throw new Error('CodeGen: "try" without "catch" and "finally"');let U=new x;if(this._blockNode(U),this.code(z),I){let H=this.name("e");this._currNode=U.catch=new S(H),I(H)}return C&&(this._currNode=U.finally=new R,this.code(C)),this._endBlockNode(S,R)}throw(z){return this._leafNode(new m(z))}block(z,I){return this._blockStarts.push(this._nodes.length),z&&this.code(z).endBlock(I),this}endBlock(z){let I=this._blockStarts.pop();if(I===void 0)throw new Error("CodeGen: not in self-balancing block");let C=this._nodes.length-I;if(C<0||z!==void 0&&C!==z)throw new Error(`CodeGen: wrong number of nodes: ${C} vs ${z} expected`);return this._nodes.length=I,this}func(z,I=t.nil,C,U){return this._blockNode(new _(z,I,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,I){let C=this._currNode;if(C instanceof z||I&&C instanceof I)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${I?`${z.kind}/${I.kind}`:z.kind}"`)}_elseNode(z){let I=this._currNode;if(!(I instanceof b))throw new Error('CodeGen: "else" without "if"');return this._currNode=I.else=z,this}get _root(){return this._nodes[0]}get _currNode(){let z=this._nodes;return z[z.length-1]}set _currNode(z){let I=this._nodes;I[I.length-1]=z}};e.CodeGen=P;function j(z,I){for(let C in I)z[C]=(z[C]||0)+(I[C]||0);return z}function N(z,I){return I instanceof t._CodeOrName?j(z,I.names):z}function T(z,I,C){if(z instanceof t.Name)return U(z);if(!H(z))return z;return new t._Code(z._items.reduce((Y,X)=>(X instanceof t.Name&&(X=U(X)),X instanceof t._Code?Y.push(...X._items):Y.push(X),Y),[]));function U(Y){let X=C[Y.str];return X===void 0||I[Y.str]!==1?Y:(delete I[Y.str],X)}function H(Y){return Y instanceof t._Code&&Y._items.some(X=>X instanceof t.Name&&I[X.str]===1&&C[X.str]!==void 0)}}function q(z,I){for(let C in I)z[C]=(z[C]||0)-(I[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(I,C)=>I===t.nil?C:C===t.nil?I:(0,t._)`${A(I)} ${z} ${A(C)}`}function A(z){return z instanceof t.Name?z:(0,t._)`(${z})`}})),He=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=Xg();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:S}=_;if(!x.strictSchema||typeof $=="boolean")return;let R=S.RULES.keywords;for(let P in $)R[P]||k(_,`unknown keyword: "${P}"`)}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,S,R){if(!R){if(typeof x=="number"||typeof x=="boolean")return x;if(typeof x=="string")return(0,t._)`${x}`}return(0,t._)`${_}${$}${(0,t.getProperty)(S)}`}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:S}){return(R,P,j,N)=>{let T=j===void 0?P:j instanceof t.Name?(P instanceof t.Name?_(R,P,j):$(R,P,j),j):P instanceof t.Name?($(R,j,P),P):x(P,j);return N===t.Name&&!(T instanceof t.Name)?S(R,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(S=>_.assign((0,t._)`${$}${(0,t.getProperty)(S)}`,!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 S=$===w.Num;return x?S?(0,t._)`"[" + ${_} + "]"`:(0,t._)`"['" + ${_} + "']"`:S?(0,t._)`"/" + ${_}`:(0,t._)`"/" + ${_}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return x?(0,t.getProperty)(_).toString():"/"+m(_)}e.getErrorPath=v;function k(_,$,x=_.opts.strictSchema){if(x){if($=`strict mode: ${$}`,x===!0)throw new Error($);_.self.logger.warn($)}}e.checkStrictMode=k})),$r=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})),Qg=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=He(),o=$r();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:k,compositeRule:_,allErrors:$}=v,x=m(g,b,y);w??(_||$)?c(k,x):l(v,(0,t._)`[${x}]`)}e.reportError=n;function i(g,b=e.keywordError,y){let{it:w}=g,{gen:v,compositeRule:k,allErrors:_}=w;c(v,m(g,b,y)),k||_||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:k}){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,k.errorPath))),g.assign((0,t._)`${_}.schemaPath`,(0,t.str)`${k.errSchemaPath}/${b}`),k.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,k=[f(v,y),p(g,y)];return h(g,b,k),w.object(...k)}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:k,schemaValue:_,it:$}=g,{opts:x,propertyName:S,topSchemaRef:R,schemaPath:P}=$;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._)`${R}${P}`],[o.default.data,k]),S&&w.push([u.propertyName,S])}})),mL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Qg(),r=qe(),o=$r(),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)}})),gE=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})),yE=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})),Yg=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=gE(),r=yE(),o=Qg(),n=qe(),i=He();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:k,data:_,opts:$}=w,x=m(v,$.coerceTypes),S=v.length>0&&!(x.length===0&&v.length===1&&(0,r.schemaHasRulesForType)(w,v[0]));if(S){let R=h(v,_,$.strictNumbers,s.Wrong);k.if(R,()=>{x.length?d(w,v,x):b(w)})}return S}e.coerceAndCheckDataType=l;let u=new Set(["string","number","integer","boolean","null"]);function m(w,v){return v?w.filter(k=>u.has(k)||v==="array"&&k==="array"):[]}function d(w,v,k){let{gen:_,data:$,opts:x}=w,S=_.let("dataType",(0,n._)`typeof ${$}`),R=_.let("coerced",(0,n._)`undefined`);x.coerceTypes==="array"&&_.if((0,n._)`${S} == 'object' && Array.isArray(${$}) && ${$}.length == 1`,()=>_.assign($,(0,n._)`${$}[0]`).assign(S,(0,n._)`typeof ${$}`).if(h(v,$,x.strictNumbers),()=>_.assign(R,$))),_.if((0,n._)`${R} !== undefined`);for(let j of k)(u.has(j)||j==="array"&&x.coerceTypes==="array")&&P(j);_.else(),b(w),_.endIf(),_.if((0,n._)`${R} !== undefined`,()=>{_.assign($,R),f(w,R)});function P(j){switch(j){case"string":_.elseIf((0,n._)`${S} == "number" || ${S} == "boolean"`).assign(R,(0,n._)`"" + ${$}`).elseIf((0,n._)`${$} === null`).assign(R,(0,n._)`""`);return;case"number":_.elseIf((0,n._)`${S} == "boolean" || ${$} === null
68
+ || (${S} == "string" && ${$} && ${$} == +${$})`).assign(R,(0,n._)`+${$}`);return;case"integer":_.elseIf((0,n._)`${S} === "boolean" || ${$} === null
69
+ || (${S} === "string" && ${$} && ${$} == +${$} && !(${$} % 1))`).assign(R,(0,n._)`+${$}`);return;case"boolean":_.elseIf((0,n._)`${$} === "false" || ${$} === 0 || ${$} === null`).assign(R,!1).elseIf((0,n._)`${$} === "true" || ${$} === 1`).assign(R,!0);return;case"null":_.elseIf((0,n._)`${$} === "" || ${$} === 0 || ${$} === false`),_.assign(R,null);return;case"array":_.elseIf((0,n._)`${S} === "string" || ${S} === "number"
70
+ || ${S} === "boolean" || ${$} === null`).assign(R,(0,n._)`[${$}]`)}}}function f({gen:w,parentData:v,parentDataProperty:k},_){w.if((0,n._)`${v} !== undefined`,()=>w.assign((0,n._)`${v}[${k}]`,_))}function p(w,v,k,_=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=S((0,n._)`!(${v} % 1) && !isNaN(${v})`);break;case"number":x=S();break;default:return(0,n._)`typeof ${v} ${$} ${w}`}return _===s.Correct?x:(0,n.not)(x);function S(R=n.nil){return(0,n.and)((0,n._)`typeof ${v} == "number"`,R,k?(0,n._)`isFinite(${v})`:n.nil)}}e.checkDataType=p;function h(w,v,k,_){if(w.length===1)return p(w[0],v,k,_);let $,x=(0,i.toHash)(w);if(x.array&&x.object){let S=(0,n._)`typeof ${v} != "object"`;$=x.null?S:(0,n._)`!${v} || ${S}`,delete x.null,delete x.array,delete x.object}else $=n.nil;x.number&&delete x.integer;for(let S in x)$=(0,n.and)($,p(S,v,k,_));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:k,schema:_}=w,$=(0,i.schemaRefOrVal)(w,_,"type");return{gen:v,keyword:"type",data:k,schema:_.type,schemaCode:$,schemaValue:$,parentSchema:_,params:{},it:w}}})),dL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;let t=qe(),r=He();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)}`)}})),xr=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=He(),o=$r(),n=He();function i(w,v){let{gen:k,data:_,it:$}=w;k.if(m(k,_,v,$.opts.ownProperties),()=>{w.setParams({missingProperty:(0,t._)`${v}`},!0),w.error()})}e.checkReportMissingProp=i;function s({gen:w,data:v,it:{opts:k}},_,$){return(0,t.or)(..._.map(x=>(0,t.and)(m(w,v,x,k.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,k){return(0,t._)`${c(w)}.call(${v}, ${k})`}e.isOwnProperty=l;function u(w,v,k,_){let $=(0,t._)`${v}${(0,t.getProperty)(k)} !== undefined`;return _?(0,t._)`${$} && ${l(w,v,k)}`:$}e.propertyInData=u;function m(w,v,k,_){let $=(0,t._)`${v}${(0,t.getProperty)(k)} === undefined`;return _?(0,t.or)($,(0,t.not)(l(w,v,k))):$}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(k=>!(0,r.alwaysValidSchema)(w,v[k]))}e.schemaProperties=f;function p({schemaCode:w,data:v,it:{gen:k,topSchemaRef:_,schemaPath:$,errorPath:x},it:S},R,P,j){let N=j?(0,t._)`${w}, ${v}, ${_}${$}`:v,T=[[o.default.instancePath,(0,t.strConcat)(o.default.instancePath,x)],[o.default.parentData,S.parentData],[o.default.parentDataProperty,S.parentDataProperty],[o.default.rootData,o.default.rootData]];S.opts.dynamicRef&&T.push([o.default.dynamicAnchors,o.default.dynamicAnchors]);let q=(0,t._)`${N}, ${k.object(...T)}`;return P!==t.nil?(0,t._)`${R}.call(${P}, ${q})`:(0,t._)`${R}(${q})`}e.callValidateCode=p;let h=(0,t._)`new RegExp`;function g({gen:w,it:{opts:v}},k){let _=v.unicodeRegExp?"u":"",{regExp:$}=v.code,x=$(k,_);return w.scopeValue("pattern",{key:x.toString(),ref:x,code:(0,t._)`${$.code==="new RegExp"?h:(0,n.useFunc)(w,$)}(${k}, ${_})`})}e.usePattern=g;function b(w){let{gen:v,data:k,keyword:_,it:$}=w,x=v.name("valid");if($.allErrors){let R=v.let("valid",!0);return S(()=>v.assign(R,!1)),R}return v.var(x,!0),S(()=>v.break()),x;function S(R){let P=v.const("len",(0,t._)`${k}.length`);v.forRange("i",0,P,j=>{w.subschema({keyword:_,dataProp:j,dataPropType:r.Type.Num},x),v.if((0,t.not)(x),R)})}}e.validateArray=b;function y(w){let{gen:v,schema:k,keyword:_,it:$}=w;if(!Array.isArray(k))throw new Error("ajv implementation error");if(k.some(R=>(0,r.alwaysValidSchema)($,R))&&!$.opts.unevaluated)return;let x=v.let("valid",!1),S=v.name("_valid");v.block(()=>k.forEach((R,P)=>{let j=w.subschema({keyword:_,schemaProp:P,compositeRule:!0},S);v.assign(x,(0,t._)`${x} || ${S}`),w.mergeValidEvaluated(j,S)||v.if((0,t.not)(x))})),w.result(x,()=>w.reset(),()=>w.error(!0))}e.validateUnion=y})),fL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=qe(),r=$r(),o=xr(),n=Qg();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),k=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:k,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:k}=f;l(k,p);let _=u(g,b,!v&&p.compile?p.compile.call(k.self,y,w,k):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)P(),p.modifying&&a(f),j(()=>f.error());else{let N=p.async?S():R();p.modifying&&a(f),j(()=>c(f,N))}}function S(){let N=g.let("ruleErrs",null);return g.try(()=>P((0,t._)`await `),T=>g.assign($,!1).if((0,t._)`${T} instanceof ${k.ValidationError}`,()=>g.assign(N,(0,t._)`${T}.errors`),()=>g.throw(T))),N}function R(){let N=(0,t._)`${_}.errors`;return g.assign(N,null),P(t.nil),N}function P(N=p.async?(0,t._)`await `:t.nil){let T=k.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 j(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})),pL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=qe(),r=He();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})),bE=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}})),hL=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")}})),ey=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=He(),r=bE(),o=hL(),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),k={"":v},_=l(w,v,!1),$={},x=new Set;return o(g,{allKeys:!0},(P,j,N,T)=>{if(T===void 0)return;let q=_+j,Z=k[T];typeof P[y]=="string"&&(Z=D.call(this,P[y])),V.call(this,P.$anchor),V.call(this,P.$dynamicAnchor),k[j]=Z;function D(F){let M=this.opts.uriResolver.resolve;if(F=d(Z?M(Z,F):F),x.has(F))throw R(F);x.add(F);let L=this.refs[F];return typeof L=="string"&&(L=this.refs[L]),typeof L=="object"?S(P,L.schema,F):F!==d(q)&&(F[0]==="#"?(S(P,$[F],F),$[F]=P):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 S(P,j,N){if(j!==void 0&&!r(P,j))throw R(N)}function R(P){return new Error(`reference "${P}" resolves to more than one schema`)}}e.getSchemaRefs=h})),hc=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=mL(),r=Yg(),o=yE(),n=Yg(),i=dL(),s=fL(),a=pL(),c=qe(),l=$r(),u=ey(),m=He(),d=Qg();function f(W){if(_(W)&&(x(W),k(W))){b(W);return}p(W,()=>(0,t.topBoolOrEmptySchema)(W))}e.validateFunctionCode=f;function p({gen:W,validateName:ee,schema:re,schemaEnv:de,opts:ce},pe){ce.code.es5?W.func(ee,(0,c._)`${l.default.data}, ${l.default.valCxt}`,de.$async,()=>{W.code((0,c._)`"use strict"; ${w(re,ce)}`),g(W,ce),W.code(pe)}):W.func(ee,(0,c._)`${l.default.data}, ${h(ce)}`,de.$async,()=>W.code(w(re,ce)).code(pe))}function h(W){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${W.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(W,ee){W.if(l.default.valCxt,()=>{W.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),W.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),W.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),W.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),ee.dynamicRef&&W.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{W.var(l.default.instancePath,(0,c._)`""`),W.var(l.default.parentData,(0,c._)`undefined`),W.var(l.default.parentDataProperty,(0,c._)`undefined`),W.var(l.default.rootData,l.default.data),ee.dynamicRef&&W.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function b(W){let{schema:ee,opts:re,gen:de}=W;p(W,()=>{re.$comment&&ee.$comment&&T(W),P(W),de.let(l.default.vErrors,null),de.let(l.default.errors,0),re.unevaluated&&y(W),S(W),q(W)})}function y(W){let{gen:ee,validateName:re}=W;W.evaluated=ee.const("evaluated",(0,c._)`${re}.evaluated`),ee.if((0,c._)`${W.evaluated}.dynamicProps`,()=>ee.assign((0,c._)`${W.evaluated}.props`,(0,c._)`undefined`)),ee.if((0,c._)`${W.evaluated}.dynamicItems`,()=>ee.assign((0,c._)`${W.evaluated}.items`,(0,c._)`undefined`))}function w(W,ee){let re=typeof W=="object"&&W[ee.schemaId];return re&&(ee.code.source||ee.code.process)?(0,c._)`/*# sourceURL=${re} */`:c.nil}function v(W,ee){if(_(W)&&(x(W),k(W))){$(W,ee);return}(0,t.boolOrEmptySchema)(W,ee)}function k({schema:W,self:ee}){if(typeof W=="boolean")return!W;for(let re in W)if(ee.RULES.all[re])return!0;return!1}function _(W){return typeof W.schema!="boolean"}function $(W,ee){let{schema:re,gen:de,opts:ce}=W;ce.$comment&&re.$comment&&T(W),j(W),N(W);let pe=de.const("_errs",l.default.errors);S(W,pe),de.var(ee,(0,c._)`${pe} === ${l.default.errors}`)}function x(W){(0,m.checkUnknownRules)(W),R(W)}function S(W,ee){if(W.opts.jtd)return D(W,[],!1,ee);let re=(0,r.getSchemaTypes)(W.schema);D(W,re,!(0,r.coerceAndCheckDataType)(W,re),ee)}function R(W){let{schema:ee,errSchemaPath:re,opts:de,self:ce}=W;ee.$ref&&de.ignoreKeywordsWithRef&&(0,m.schemaHasRulesButRef)(ee,ce.RULES)&&ce.logger.warn(`$ref: keywords ignored in schema at path "${re}"`)}function P(W){let{schema:ee,opts:re}=W;ee.default!==void 0&&re.useDefaults&&re.strictSchema&&(0,m.checkStrictMode)(W,"default is ignored in the schema root")}function j(W){let ee=W.schema[W.opts.schemaId];ee&&(W.baseId=(0,u.resolveUrl)(W.opts.uriResolver,W.baseId,ee))}function N(W){if(W.schema.$async&&!W.schemaEnv.$async)throw new Error("async schema in sync schema")}function T({gen:W,schemaEnv:ee,schema:re,errSchemaPath:de,opts:ce}){let pe=re.$comment;if(ce.$comment===!0)W.code((0,c._)`${l.default.self}.logger.log(${pe})`);else if(typeof ce.$comment=="function"){let Pe=(0,c.str)`${de}/$comment`,Je=W.scopeValue("root",{ref:ee.root});W.code((0,c._)`${l.default.self}.opts.$comment(${pe}, ${Pe}, ${Je}.schema)`)}}function q(W){let{gen:ee,schemaEnv:re,validateName:de,ValidationError:ce,opts:pe}=W;re.$async?ee.if((0,c._)`${l.default.errors} === 0`,()=>ee.return(l.default.data),()=>ee.throw((0,c._)`new ${ce}(${l.default.vErrors})`)):(ee.assign((0,c._)`${de}.errors`,l.default.vErrors),pe.unevaluated&&Z(W),ee.return((0,c._)`${l.default.errors} === 0`))}function Z({gen:W,evaluated:ee,props:re,items:de}){re instanceof c.Name&&W.assign((0,c._)`${ee}.props`,re),de instanceof c.Name&&W.assign((0,c._)`${ee}.items`,de)}function D(W,ee,re,de){let{gen:ce,schema:pe,data:Pe,allErrors:Je,opts:Ze,self:Ye}=W,{RULES:Qe}=Ye;if(pe.$ref&&(Ze.ignoreKeywordsWithRef||!(0,m.schemaHasRulesButRef)(pe,Qe))){ce.block(()=>Y(W,"$ref",Qe.all.$ref.definition));return}Ze.jtd||F(W,ee),ce.block(()=>{for(let vt of Qe.rules)Ct(vt);Ct(Qe.post)});function Ct(vt){(0,o.shouldUseGroup)(pe,vt)&&(vt.type?(ce.if((0,n.checkDataType)(vt.type,Pe,Ze.strictNumbers)),V(W,vt),ee.length===1&&ee[0]===vt.type&&re&&(ce.else(),(0,n.reportTypeError)(W)),ce.endIf()):V(W,vt),Je||ce.if((0,c._)`${l.default.errors} === ${de||0}`))}}function V(W,ee){let{gen:re,schema:de,opts:{useDefaults:ce}}=W;ce&&(0,i.assignDefaults)(W,ee.type),re.block(()=>{for(let pe of ee.rules)(0,o.shouldUseRule)(de,pe)&&Y(W,pe.keyword,pe.definition,ee.type)})}function F(W,ee){W.schemaEnv.meta||!W.opts.strictTypes||(M(W,ee),W.opts.allowUnionTypes||L(W,ee),A(W,W.dataTypes))}function M(W,ee){if(ee.length){if(!W.dataTypes.length){W.dataTypes=ee;return}ee.forEach(re=>{I(W.dataTypes,re)||U(W,`type "${re}" not allowed by context "${W.dataTypes.join(",")}"`)}),C(W,ee)}}function L(W,ee){ee.length>1&&!(ee.length===2&&ee.includes("null"))&&U(W,"use allowUnionTypes to allow union type keyword")}function A(W,ee){let re=W.self.RULES.all;for(let de in re){let ce=re[de];if(typeof ce=="object"&&(0,o.shouldUseRule)(W.schema,ce)){let{type:pe}=ce.definition;pe.length&&!pe.some(Pe=>z(ee,Pe))&&U(W,`missing type "${pe.join(",")}" for keyword "${de}"`)}}}function z(W,ee){return W.includes(ee)||ee==="number"&&W.includes("integer")}function I(W,ee){return W.includes(ee)||ee==="integer"&&W.includes("number")}function C(W,ee){let re=[];for(let de of W.dataTypes)I(ee,de)?re.push(de):ee.includes("integer")&&de==="number"&&re.push("integer");W.dataTypes=re}function U(W,ee){let re=W.schemaEnv.baseId+W.errSchemaPath;ee+=` at "${re}" (strictTypes)`,(0,m.checkStrictMode)(W,ee,W.opts.strictTypes)}var H=class{constructor(W,ee,re){if((0,s.validateKeywordUsage)(W,ee,re),this.gen=W.gen,this.allErrors=W.allErrors,this.keyword=re,this.data=W.data,this.schema=W.schema[re],this.$data=ee.$data&&W.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,m.schemaRefOrVal)(W,this.schema,re,this.$data),this.schemaType=ee.schemaType,this.parentSchema=W.schema,this.params={},this.it=W,this.def=ee,this.$data)this.schemaCode=W.gen.const("vSchema",ye(this.$data,W));else if(this.schemaCode=this.schemaValue,!(0,s.validSchemaType)(this.schema,ee.schemaType,ee.allowUndefined))throw new Error(`${re} value must be ${JSON.stringify(ee.schemaType)}`);("code"in ee?ee.trackErrors:ee.errors!==!1)&&(this.errsCount=W.gen.const("_errs",l.default.errors))}result(W,ee,re){this.failResult((0,c.not)(W),ee,re)}failResult(W,ee,re){this.gen.if(W),re?re():this.error(),ee?(this.gen.else(),ee(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(W,ee){this.failResult((0,c.not)(W),void 0,ee)}fail(W){if(W===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(W),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(W){if(!this.$data)return this.fail(W);let{schemaCode:ee}=this;this.fail((0,c._)`${ee} !== undefined && (${(0,c.or)(this.invalid$data(),W)})`)}error(W,ee,re){if(ee){this.setParams(ee),this._error(W,re),this.setParams({});return}this._error(W,re)}_error(W,ee){(W?d.reportExtraError:d.reportError)(this,this.def.error,ee)}$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(W){this.allErrors||this.gen.if(W)}setParams(W,ee){ee?Object.assign(this.params,W):this.params=W}block$data(W,ee,re=c.nil){this.gen.block(()=>{this.check$data(W,re),ee()})}check$data(W=c.nil,ee=c.nil){if(!this.$data)return;let{gen:re,schemaCode:de,schemaType:ce,def:pe}=this;re.if((0,c.or)((0,c._)`${de} === undefined`,ee)),W!==c.nil&&re.assign(W,!0),(ce.length||pe.validateSchema)&&(re.elseIf(this.invalid$data()),this.$dataError(),W!==c.nil&&re.assign(W,!1)),re.else()}invalid$data(){let{gen:W,schemaCode:ee,schemaType:re,def:de,it:ce}=this;return(0,c.or)(pe(),Pe());function pe(){if(re.length){if(!(ee instanceof c.Name))throw new Error("ajv implementation error");let Je=Array.isArray(re)?re:[re];return(0,c._)`${(0,n.checkDataTypes)(Je,ee,ce.opts.strictNumbers,n.DataType.Wrong)}`}return c.nil}function Pe(){if(de.validateSchema){let Je=W.scopeValue("validate$data",{ref:de.validateSchema});return(0,c._)`!${Je}(${ee})`}return c.nil}}subschema(W,ee){let re=(0,a.getSubschema)(this.it,W);(0,a.extendSubschemaData)(re,this.it,W),(0,a.extendSubschemaMode)(re,W);let de={...this.it,...re,items:void 0,props:void 0};return v(de,ee),de}mergeEvaluated(W,ee){let{it:re,gen:de}=this;re.opts.unevaluated&&(re.props!==!0&&W.props!==void 0&&(re.props=m.mergeEvaluated.props(de,W.props,re.props,ee)),re.items!==!0&&W.items!==void 0&&(re.items=m.mergeEvaluated.items(de,W.items,re.items,ee)))}mergeValidEvaluated(W,ee){let{it:re,gen:de}=this;if(re.opts.unevaluated&&(re.props!==!0||re.items!==!0))return de.if(ee,()=>this.mergeEvaluated(W,c.Name)),!0}};e.KeywordCxt=H;function Y(W,ee,re,de){let ce=new H(W,re,ee);"code"in re?re.code(ce,de):ce.$data&&re.validate?(0,s.funcKeywordCode)(ce,re):"macro"in re?(0,s.macroKeywordCode)(ce,re):(re.compile||re.validate)&&(0,s.funcKeywordCode)(ce,re)}let X=/^\/(?:[^~]|~0|~1)*$/,fe=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ye(W,{dataLevel:ee,dataNames:re,dataPathArr:de}){let ce,pe;if(W==="")return l.default.rootData;if(W[0]==="/"){if(!X.test(W))throw new Error(`Invalid JSON-pointer: ${W}`);ce=W,pe=l.default.rootData}else{let Ye=fe.exec(W);if(!Ye)throw new Error(`Invalid JSON-pointer: ${W}`);let Qe=+Ye[1];if(ce=Ye[2],ce==="#"){if(Qe>=ee)throw new Error(Ze("property/index",Qe));return de[ee-Qe]}if(Qe>ee)throw new Error(Ze("data",Qe));if(pe=re[ee-Qe],!ce)return pe}let Pe=pe,Je=ce.split("/");for(let Ye of Je)Ye&&(pe=(0,c._)`${pe}${(0,c.getProperty)((0,m.unescapeJsonPointer)(Ye))}`,Pe=(0,c._)`${Pe} && ${pe}`);return Pe;function Ze(Ye,Qe){return`Cannot access ${Ye} ${Qe} levels up, current level is ${ee}`}}e.getData=ye})),cm=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})),gc=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=ey();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})),ty=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=qe(),r=cm(),o=$r(),n=ey(),i=He(),s=hc();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:k}=this.opts.code,{ownProperties:_}=this.opts,$=new t.CodeGen(this.scope,{es5:v,lines:k,ownProperties:_}),x;b.$async&&(x=$.scopeValue("Error",{ref:r.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let S=$.scopeName("validate");b.validateName=S;let R={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:S,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},P;try{this._compilations.add(b),(0,s.validateFunctionCode)(R),$.optimize(this.opts.code.optimize);let j=$.toString();P=`${$.scopeRefs(o.default.scope)}return ${j}`,this.opts.code.process&&(P=this.opts.code.process(P,b));let N=new Function(`${o.default.self}`,`${o.default.scope}`,P)(this,this.scope.get());if(this.scope.value(S,{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:S,validateCode:j,scopeValues:$._values}),this.opts.unevaluated){let{props:T,items:q}=R;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(j){throw delete b.validate,delete b.validateName,P&&this.logger.error("Error compiling schema, function code:",P),j}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 k=b.refs[w];if(k)return k;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),k=(0,n.getFullPath)(this.opts.uriResolver,b.baseId,void 0);if(Object.keys(b.schema).length>0&&v===k)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:S}=this.opts,R=x[S];return R&&(k=(0,n.resolveUrl)(this.opts.uriResolver,k,R)),new a({schema:x,schemaId:S,root:b,baseId:k})}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 k;if(((k=b.fragment)===null||k===void 0?void 0:k[0])!=="/")return;for(let x of b.fragment.slice(1).split("/")){if(typeof w=="boolean")return;let S=w[(0,i.unescapeFragment)(x)];if(S===void 0)return;w=S;let R=typeof w=="object"&&w[this.opts.schemaId];!h.has(x)&&R&&(y=(0,n.resolveUrl)(this.opts.uriResolver,y,R))}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 _}})),gL=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}})),wE=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="",I=0,C=0;for(C=0;C<A.length;C++)if(I=A[C].charCodeAt(0),I!==48){if(!(I>=48&&I<=57||I>=65&&I<=70||I>=97&&I<=102))return"";z+=A[C];break}for(C+=1;C<A.length;C++){if(I=A[C].charCodeAt(0),!(I>=48&&I<=57||I>=65&&I<=70||I>=97&&I<=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,I=0,C=-1,U=0;for(let X=0;X<A.length;X++)A[X]==="0"?(C===-1&&(C=X),U++,U>I&&(I=U,z=C)):(C=-1,U=0);if(I<2)return A.join(":");let H=A.slice(0,z).join(":"),Y=A.slice(z+I).join(":");return H+"::"+Y}function w(A){let z=A.indexOf("::");if(z!==-1&&A.indexOf("::",z+1)!==-1)return;let I=z===-1?A.split(":"):A.slice(0,z).split(":"),C=z===-1?[]:A.slice(z+2).split(":");z!==-1&&(I.length===1&&I[0]===""&&(I.length=0),C.length===1&&C[0]===""&&(C.length=0));let U=I.concat(C),H=0;for(let X=0;X<U.length;X++){let fe=U[X];if(fe==="")return;if(fe.indexOf(".")!==-1){if(X!==U.length-1||z!==-1&&C.length===0||!o(fe))return;H+=2;continue}if(!f(fe))return;U[X]=parseInt(fe,16).toString(16),H++}if(z===-1)return H!==8?void 0:y(U);if(H>=8)return;let Y=U.slice(0,I.length);for(let X=H;X<8;X++)Y.push("0");for(let X=I.length;X<U.length;X++)Y.push(U[X]);return y(Y)}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 I=z?A.slice(1,-1):A;if(z&&p(I))return I=I.toLowerCase(),{host:`[${I}]`,escapedHost:I,isIPV6:!1,isIPVFuture:!0};if(k(I,":")<2)return{host:A,isIPV6:!1,error:z};let C="",U=I.indexOf("%");if(U!==-1){let Y=I.slice(U,U+3).toLowerCase()==="%25"?3:1;if(C=I.slice(U+Y),!b(C))return{host:A,isIPV6:!1,error:!0};I=I.slice(0,U)}let H=w(I);return H===void 0?{host:A,isIPV6:!1,error:!0}:{host:H+(C?"%"+C:""),escapedHost:H+(C?"%25"+C:""),isIPV6:!0}}function k(A,z){let I=0;for(let C=0;C<A.length;C++)A[C]===z&&I++;return I}function _(A){let z=A,I=[],C=-1,U=0;for(;U=z.length;){if(U===1){if(z===".")break;if(z==="/"){I.push("/");break}else{I.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]==="/")){I.push("/");break}}else if(U===3&&z==="/.."){I.length!==0&&I.pop(),I.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),I.length!==0&&I.pop();continue}}if((C=z.indexOf("/",1))===-1){I.push(z);break}else I.push(z.slice(0,C)),z=z.slice(C)}return I.join("")}let $={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},x=/[@/?#:]/g,S=/[@/?#]/g;function R(A,z){let I=z?S:x;return I.lastIndex=0,A.replace(I,C=>$[C])}function P(A,z=!1){if(A.indexOf("%")===-1)return A;let I="";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 H=U.toUpperCase(),Y=String.fromCharCode(parseInt(H,16));z&&s(Y)?I+=Y:I+="%"+H,C+=2;continue}}I+=A[C]}return I}function j(A){let z="";for(let I=0;I<A.length;I++){let C=A[I];if(C==="%"&&I+2<A.length){let U=A.slice(I+1,I+3);if(i(U)){let H=U.toUpperCase(),Y=String.fromCharCode(parseInt(H,16));Y!=="."&&s(Y)?z+=Y:z+="%"+H,I+=2;continue}}if(a(C))z+=C;else{let U=A.charCodeAt(I);if(U<128)z+=V(U)?C:u[U];else if(U<55296||U>57343)z+=m(U);else if(U<=56319&&I+1<A.length){let H=A.charCodeAt(I+1);H>=56320&&H<=57343?(z+=m(65536+(U-55296<<10)+(H-56320)),I++):z+=m(65533)}else z+=m(65533)}}return z}function N(A,z=!1){let I="",C=z&&A[0]!=="/";for(let U=0;U<A.length;U++){let H=A[U];if(H==="%"&&U+2<A.length){let Y=A.slice(U+1,U+3);if(i(Y)){I+="%"+Y.toUpperCase(),U+=2;continue}}if(H==="/"&&(C=!1),a(H)&&(H!==":"||!C))I+=H;else{let Y=A.charCodeAt(U);if(Y<128)I+=u[Y];else if(Y<55296||Y>57343)I+=m(Y);else if(Y<=56319&&U+1<A.length){let X=A.charCodeAt(U+1);X>=56320&&X<=57343?(I+=m(65536+(Y-55296<<10)+(X-56320)),U++):I+=m(65533)}else I+=m(65533)}}return I}function T(A,z){let I="";for(let C=0;C<A.length;C++){let U=A[C];if(U==="%"&&C+2<A.length){let H=A.slice(C+1,C+3);if(i(H)){I+="%"+H.toUpperCase(),C+=2;continue}}if(z(U))I+=U;else{let H=A.charCodeAt(C);if(H<128)I+=u[H];else if(H<55296||H>57343)I+=m(H);else if(H<=56319&&C+1<A.length){let Y=A.charCodeAt(C+1);Y>=56320&&Y<=57343?(I+=m(65536+(H-55296<<10)+(Y-56320)),C++):I+=m(65533)}else I+=m(65533)}}return I}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 I=0;I<A.length;I++){let C=A[I];if(C==="%"&&I+2<A.length){let U=A.slice(I+1,I+3);if(i(U)){let H=U.toUpperCase(),Y=String.fromCharCode(parseInt(H,16));s(Y)?z+=Y:z+="%"+H,I+=2;continue}}if(c(C))z+=C;else{let U=A.charCodeAt(I);if(U<128)z+=V(U)?C:u[U];else if(U<55296||U>57343)z+=m(U);else if(U<=56319&&I+1<A.length){let H=A.charCodeAt(I+1);H>=56320&&H<=57343?(z+=m(65536+(U-55296<<10)+(H-56320)),I++):z+=m(65533)}else z+=m(65533)}}return z}function M(A){let z="";for(let I=0;I<A.length;I++){if(A[I]==="%"&&I+2<A.length){let C=A.slice(I+1,I+3);if(i(C)){z+="%"+C.toUpperCase(),I+=2;continue}}z+=escape(A[I])}return z}function L(A){let z=[];if(A.userinfo!==void 0&&(z.push(q(A.userinfo)),z.push("@")),A.host!==void 0){let I=A.host;if(!o(I)){let C=v(I);C.isIPV6!==!0&&C.isIPVFuture!==!0&&(I=P(I,!0),C=v(I)),C.isIPV6===!0||C.isIPVFuture===!0?I=`[${C.escapedHost}]`:I=R(I,!1)}z.push(I)}if(typeof A.port=="number"||typeof A.port=="string"){let I=String(A.port);if(!n(I))throw new TypeError("URI port is malformed.");z.push(":"),z.push(I)}return z.length?z.join(""):void 0}t.exports={nonSimpleDomain:g,recomposeAuthority:L,reescapeHostDelimiters:R,normalizePercentEncoding:P,normalizePathEncoding:j,serializePathEncoding:N,normalizeQueryFragmentEncoding:F,encodeUserinfo:q,encodeQuery:Z,encodeFragment:D,escapePreservingEscapes:M,removeDotSegments:_,isIPv4:o,isUUID:r,normalizeIPv6:v,stringArrayToHexStripped:d}})),yL=ue(((e,t)=>{let{isUUID:r}=wE(),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("?"),S=x===-1?$.resourceName:$.resourceName.slice(0,x);$.path=S&&S!=="/"?S: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 S=$.path.match(o);if(S&&S[0]===$.path){let R=x.scheme||$.scheme||"urn";$.nid=S[1].toLowerCase(),$.nss=S[2];let P=_(`${R}:${x.nid||$.nid}`);$.path=void 0,P&&($=P.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 S=x.scheme||$.scheme||"urn",R=$.nid.toLowerCase(),P=_(`${S}:${x.nid||R}`);P&&($=P.serialize($,x));let j=$,N=$.nss;return j.path=`${R||x.nid}:${N}`,x.skipEscape=!0,j}function f($,x){let S=$;return S.uuid=S.nss,S.nss=void 0,!x.tolerant&&(!S.uuid||!r(S.uuid))&&(S.error=S.error||"UUID is not valid."),S}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},k={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(k,null);function _($){return $&&(k[$]||k[$.toLowerCase()])||void 0}t.exports={wsIsSecure:s,SCHEMES:k,isValidSchemeName:i,getSchemeHandler:_}})),bL=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}=wE(),{SCHEMES:p,getSchemeHandler:h}=yL(),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,I){let C=I?Object.assign({scheme:"null"},I):{scheme:"null"},{parsed:U,malformedAuthorityOrPort:H,malformedPercentEncoding:Y,malformedSchemeSpecific:X,malformedHost:fe,malformedScheme:ye}=Z(A,C),{parsed:W,malformedAuthorityOrPort:ee,malformedPercentEncoding:re,malformedSchemeSpecific:de,malformedHost:ce,malformedScheme:pe}=Z(z,C);if(H||ee||Y||re||X||de||fe||ce||ye||pe)throw new Error(U.error||W.error||"URI is malformed.");let Pe=k(U,W,C,!0),Je=h(I&&I.scheme||Pe.scheme),Ze=Pe.host,Ye=Ze!==void 0&&Ze!==""&&(d(Ze)||r(Ze).isIPV6);q(Pe,I||{},Je,Ye);let Qe=Ze&&Ze.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(Ze);if(Pe.error&&!Qe)throw new Error(Pe.error);return C.skipEscape=!0,$(Pe,C)}function k(A,z,I,C){let U={};return C||(A=D($(A,I),I),z=D($(z,I),I)),I=I||{},!I.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,I){let C=M(A,I),U=M(z,I);return C!==void 0&&U!==void 0&&C===U}function $(A,z){let I={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=[];I.scheme&&(I.scheme=y(I.scheme));let H=h(C.scheme||I.scheme);H&&H.serialize&&H.serialize(I,C);let Y=I.userinfo!==void 0||I.host!==void 0||I.port!==void 0,X=!C.skipEscape&&I.scheme===void 0&&!Y;I.path!==void 0&&(C.skipEscape?I.path=i(I.path):I.path=a(I.path,X)),C.reference!=="suffix"&&I.scheme&&(I.scheme=y(I.scheme),U.push(I.scheme,":"));let fe=n(I);if(fe!==void 0&&(C.reference!=="suffix"&&U.push("//"),U.push(fe),I.path&&I.path[0]!=="/"&&U.push("/")),I.path!==void 0){let ye=I.path;!C.absolutePath&&(!H||!H.absolutePath)&&(ye=o(ye)),X&&(ye=a(ye,!0)),fe===void 0&&ye[0]==="/"&&ye[1]==="/"&&(ye="/%2F"+ye.slice(2)),U.push(ye)}return I.query!==void 0&&U.push("?",l(I.query)),I.fragment!==void 0&&U.push("#",u(I.fragment)),U.join("")}let x=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,S=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,R=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function P(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 j(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 j(A[3])||z!==void 0&&!N(z)&&j(z)||j(A[6])||j(A[7])||j(A[8])}function q(A,z,I,C){if(!z.unicodeSupport&&(!I||!I.unicodeSupport)&&A.host&&!N(A.host)&&(z.domainHost||I&&I.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 I=Object.assign({},z),C={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},U=!1,H=!1,Y=!1,X=!1,fe=!1,ye=!1,W=!1;I.reference==="suffix"&&(I.scheme?A=I.scheme+":"+A:A="//"+A);let ee=A.match(S);ee!==null&&ee[1].indexOf("\\")!==-1&&(C.error="URI authority must not contain a literal backslash.",U=!0);let re=A.match(R);if(re!==null){let ce=re[1],pe=ce.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):ce.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 Pe=unescape(C.scheme);g.test(Pe)?C.scheme=Pe.toLowerCase():(C.error=C.error||b,ye=!0)}H=T(de),H&&(C.error=C.error||"URI contains malformed percent-encoding."),isNaN(C.port)&&(C.port=de[5]);let ce=P(C,de);if(ce!==void 0&&(C.error=C.error||ce,U=!0),C.host)if(d(C.host)===!1){let Pe=N(C.host),Je=C.host.indexOf("[")!==-1||C.host.indexOf("]")!==-1,Ze=r(C.host);W=Ze.isIPV6||Ze.isIPVFuture===!0,fe=Je&&(!Pe||Ze.error===!0),C.host=W?Ze.host:Ze.host.toLowerCase(),fe&&(C.error=C.error||"URI host is malformed.",U=!0)}else W=!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",I.reference&&I.reference!=="suffix"&&I.reference!==C.reference&&(C.error=C.error||"URI is not a "+I.reference+" reference.");let pe=h(I.scheme||C.scheme);if(fe||(X=q(C,I,pe,W)),A.indexOf("%")!==-1&&C.host!==void 0&&!fe){let Pe=W?C.host:i(C.host,!0);W||(Pe=i(Pe.toLowerCase())),C.host=m(Pe,W)}(!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,I),pe===p.urn&&C.nid===void 0&&(Y=!0))}else C.error=C.error||"URI can not be parsed.";return{parsed:C,malformedAuthorityOrPort:U,malformedPercentEncoding:H,malformedSchemeSpecific:Y,malformedHost:X,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:I,malformedAuthorityOrPort:C,malformedPercentEncoding:U,malformedSchemeSpecific:H,malformedHost:Y,malformedScheme:X}=Z(A,z);return{normalized:C||U||H||Y||X?A:$(I,z),malformedAuthorityOrPort:C,malformedPercentEncoding:U,malformedSchemeSpecific:H,malformedHost:Y,malformedScheme:X}}function M(A,z){if(typeof A!="string"&&typeof A!="object")return;let I;try{I=typeof A=="string"?A:$(A,z)}catch{return}let{normalized:C,malformedAuthorityOrPort:U,malformedPercentEncoding:H,malformedSchemeSpecific:Y,malformedHost:X,malformedScheme:fe}=F(I,z);return U||H||Y||X||fe?void 0:C}let L={SCHEMES:p,normalize:w,resolve:v,resolveComponent:k,equal:_,serialize:$,parse:D};t.exports=L,t.exports.default=L,t.exports.fastUri=L})),wL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=bL();t.code='require("ajv/dist/runtime/uri").default',e.default=t})),Sk=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=hc();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=cm(),n=gc(),i=gE(),s=ty(),a=qe(),c=ey(),l=Yg(),u=He(),m=gL(),d=wL(),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,I,C,U,H,Y,X,fe,ye,W,ee,re,de,ce,pe,Pe,Je,Ze,Ye,Qe,Ct,vt,bn;let Gt=M.strict,On=(L=M.code)===null||L===void 0?void 0:L.optimize,Wn=On===!0||On===void 0?1:On||0,Bn=(z=(A=M.code)===null||A===void 0?void 0:A.regExp)!==null&&z!==void 0?z:f,dr=(I=M.uriResolver)!==null&&I!==void 0?I:d.default;return{strictSchema:(U=(C=M.strictSchema)!==null&&C!==void 0?C:Gt)!==null&&U!==void 0?U:!0,strictNumbers:(Y=(H=M.strictNumbers)!==null&&H!==void 0?H:Gt)!==null&&Y!==void 0?Y:!0,strictTypes:(fe=(X=M.strictTypes)!==null&&X!==void 0?X:Gt)!==null&&fe!==void 0?fe:"log",strictTuples:(W=(ye=M.strictTuples)!==null&&ye!==void 0?ye:Gt)!==null&&W!==void 0?W:"log",strictRequired:(re=(ee=M.strictRequired)!==null&&ee!==void 0?ee:Gt)!==null&&re!==void 0?re:!1,code:M.code?{...M.code,optimize:Wn,regExp:Bn}:{optimize:Wn,regExp:Bn},loopRequired:(de=M.loopRequired)!==null&&de!==void 0?de:y,loopEnum:(ce=M.loopEnum)!==null&&ce!==void 0?ce:y,meta:(pe=M.meta)!==null&&pe!==void 0?pe:!0,messages:(Pe=M.messages)!==null&&Pe!==void 0?Pe:!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:(Qe=M.validateSchema)!==null&&Qe!==void 0?Qe:!0,validateFormats:(Ct=M.validateFormats)!==null&&Ct!==void 0?Ct:!0,unicodeRegExp:(vt=M.unicodeRegExp)!==null&&vt!==void 0?vt:!0,int32range:(bn=M.int32range)!==null&&bn!==void 0?bn:!0,uriResolver:dr}}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=j(M.logger);let z=M.validateFormats;M.validateFormats=!1,this.RULES=(0,i.getRules)(),k.call(this,g,M,"NOT SUPPORTED"),k.call(this,b,M,"DEPRECATED","warn"),this._metaOpts=R.call(this),M.formats&&x.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),M.keywords&&S.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(X,fe){await I.call(this,X.$schema);let ye=this._addSchema(X,fe);return ye.validate||C.call(this,ye)}async function I(X){X&&!this.getSchema(X)&&await z.call(this,{$ref:X},!0)}async function C(X){try{return this._compileSchemaEnv(X)}catch(fe){if(!(fe instanceof n.default))throw fe;return U.call(this,fe),await H.call(this,fe.missingSchema),C.call(this,X)}}function U({missingSchema:X,missingRef:fe}){if(this.refs[X])throw new Error(`AnySchema ${X} is loaded but ${fe} cannot be resolved`)}async function H(X){let fe=await Y.call(this,X);this.refs[X]||await I.call(this,fe.$schema),this.refs[X]||this.addSchema(fe,X,L)}async function Y(X){let fe=this._loading[X];if(fe)return fe;try{return await(this._loading[X]=A(X))}finally{delete this._loading[X]}}}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 I;if(typeof M=="object"){let{schemaId:C}=this.opts;if(I=M[C],I!==void 0&&typeof I!="string")throw new Error(`schema ${C} must be string`)}return L=(0,c.normalizeId)(L||I),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 I="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(I);else throw new Error(I)}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,I=>q.call(this,I)),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?I=>q.call(this,I,z):I=>z.type.forEach(C=>q.call(this,I,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(I=>I.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,I)=>z+L+I)}$dataMetaSchema(M,L){let A=this.RULES.all;M=JSON.parse(JSON.stringify(M));for(let z of L){let I=z.split("/").slice(1),C=M;for(let U of I)C=C[U];for(let U in A){let H=A[U];if(typeof H!="object")continue;let{$data:Y}=H.definition,X=C[U];Y&&X&&(C[U]=F(X))}}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,I=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 H=this._cache.get(M);if(H!==void 0)return H;A=(0,c.normalizeId)(C||A);let Y=c.getSchemaRefs.call(this,M,A);return H=new s.SchemaEnv({schema:M,schemaId:U,meta:L,baseId:A,localRefs:Y}),this._cache.set(H.schema,H),I&&!A.startsWith("#")&&(A&&this._checkUnique(A),this.refs[A]=H),z&&this.validateSchema(M,!0),H}_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 k(M,L,A,z="error"){for(let I in M){let C=I;C in L&&this.logger[z](`${A}: option ${I}. ${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 S(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 R(){let M={...this.opts};for(let L of p)delete M[L];return M}let P={log(){},warn(){},error(){}};function j(M){if(M===!1)return P;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 I=L?.post;if(A&&I)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:C}=this,U=I?C.post:C.rules.find(({type:Y})=>Y===A);if(U||(U={type:A,rules:[]},C.rules.push(U)),C.keywords[M]=!0,!L)return;let H={keyword:M,definition:{...L,type:(0,l.getJSONTypes)(L.type),schemaType:(0,l.getJSONTypes)(L.schemaType)}};L.before?Z.call(this,U,H,L.before):U.rules.push(H),C.all[M]=H,(z=L.implements)===null||z===void 0||z.forEach(Y=>this.addKeyword(Y))}function Z(M,L,A){let z=M.rules.findIndex(I=>I.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]}}})),vL=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})),zk=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;let t=gc(),r=xr(),o=qe(),n=$r(),i=ty(),s=He(),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 k();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 k(){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 S=m.scopeValue("schema",b.code.source===!0?{ref:x,code:(0,o.stringify)(x)}:{ref:x}),R=m.name("valid"),P=u.subschema({schema:x,dataTypes:[],schemaPath:o.nil,topSchemaRef:S,errSchemaPath:d},R);u.mergeEvaluated(P),u.ok(R)}}};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():k();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)},S=>{p.if((0,o._)`!(${S} instanceof ${h.ValidationError})`,()=>p.throw(S)),_(S),g||p.assign(x,!1)}),u.ok(x)}function k(){u.result((0,r.callValidateCode)(u,m,w),()=>$(m),()=>_(m))}function _(x){let S=(0,o._)`${x}.errors`;p.assign(n.default.vErrors,(0,o._)`${n.default.vErrors} === null ? ${S} : ${n.default.vErrors}.concat(${S})`),p.assign(n.default.errors,(0,o._)`${n.default.vErrors}.length`)}function $(x){var S;if(!h.opts.unevaluated)return;let R=(S=d?.validate)===null||S===void 0?void 0:S.evaluated;if(h.props!==!0)if(R&&!R.dynamicProps)R.props!==void 0&&(h.props=s.mergeEvaluated.props(p,R.props,h.props));else{let P=p.var("props",(0,o._)`${x}.evaluated.props`);h.props=s.mergeEvaluated.props(p,P,h.props,o.Name)}if(h.items!==!0)if(R&&!R.dynamicItems)R.items!==void 0&&(h.items=s.mergeEvaluated.items(p,R.items,h.items));else{let P=p.var("items",(0,o._)`${x}.evaluated.items`);h.items=s.mergeEvaluated.items(p,P,h.items,o.Name)}}}e.callRef=l,e.default=a})),vE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vL(),r=zk(),o=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",t.default,r.default];e.default=o})),$L=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})),xL=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})),_L=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'})),kL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=He(),o=_L(),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})),SL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=xr(),r=He(),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})),zL=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})),RL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=xr(),r=qe(),o=He(),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 k=`required property "${v}" is not defined at "${m.schemaEnv.baseId+m.errSchemaPath}" (strictRequired)`;(0,o.checkStrictMode)(m,k,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})),IL=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})),Rk=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=bE();t.code='require("ajv/dist/runtime/equal").default',e.default=t})),PL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Yg(),r=qe(),o=He(),n=Rk(),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`),k=a.let("j");s.setParams({i:v,j:k}),a.assign(p,!0),a.if((0,r._)`${v} > 1`,()=>(b()?y:w)(v,k))}function b(){return h.length>0&&!h.some(v=>v==="object"||v==="array")}function y(v,k){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(k,(0,r._)`${x}[${_}]`),s.error(),a.assign(p,!1).break()}).code((0,r._)`${x}[${_}] = ${v}`)})}function w(v,k){let _=(0,o.useFunc)(a,n.default),$=a.name("outer");a.label($).for((0,r._)`;${v}--;`,()=>a.for((0,r._)`${k} = ${v}; ${k}--;`,()=>a.if((0,r._)`${_}(${c}[${v}], ${c}[${k}])`,()=>{s.error(),a.assign(p,!1).break($)})))}}};e.default=i})),jL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=He(),o=Rk(),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})),EL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=He(),o=Rk(),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})),$E=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=$L(),r=xL(),o=kL(),n=SL(),i=zL(),s=RL(),a=IL(),c=PL(),l=jL(),u=EL(),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})),xE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;let t=qe(),r=He(),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})),_E=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;let t=qe(),r=He(),o=xr(),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,k=v===b.minItems&&(v===b.maxItems||b[a]===!1);if(y.strictTuples&&!k){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})),TL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=_E(),r={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:o=>(0,t.validateTuple)(o,"items")};e.default=r})),CL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=He(),o=xr(),n=xE(),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})),AL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=He(),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,k=>{n.subschema({keyword:"contains",dataProp:k,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})),Ik=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=qe(),r=He(),o=xr();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})),OL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=He(),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})),kE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=xr(),r=qe(),o=$r(),n=He(),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"?(k(_,$,!1),a.if((0,r.not)($),()=>{s.reset(),w(_)})):(k(_,$),f||a.if((0,r.not)($),()=>a.break()))}}function k(_,$,x){let S={keyword:"additionalProperties",dataProp:_,dataPropType:n.Type.Str};x===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),s.subschema(S,$)}}};e.default=i})),NL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=hc(),r=xr(),o=He(),n=kE(),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})),ML=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=xr(),r=qe(),o=He(),n=He(),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(k=>(0,o.alwaysValidSchema)(m,c[k]));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 k of f)h&&w(k),m.allErrors?v(k):(a.var(g,!0),v(k),a.if(g))}function w(k){for(let _ in h)new RegExp(k).test(_)&&(0,o.checkStrictMode)(m,`property ${_} matches pattern ${k} (use allowMatchingProperties)`)}function v(k){a.forIn("key",l,_=>{a.if((0,r._)`${(0,t.usePattern)(s,k)}.test(${_})`,()=>{let $=p.includes(k);$||s.subschema({keyword:"patternProperties",schemaProp:k,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})),DL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=He(),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})),qL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:xr().validateUnion,error:{message:"must match a schema in anyOf"}};e.default=t})),UL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=He(),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})),LL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=He(),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})),FL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=He(),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})),VL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=He(),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})),SE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=xE(),r=TL(),o=_E(),n=CL(),i=AL(),s=Ik(),a=OL(),c=kE(),l=NL(),u=ML(),m=DL(),d=qL(),f=UL(),p=LL(),h=FL(),g=VL();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})),ZL=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)(k(),_()));function k(){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){k();return}if(b===!0)return;let[y,w,v]=_(b);y===n&&o.pass($());function k(){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 S=x instanceof RegExp?(0,t.regexpCode)(x):m.code.formats?(0,t._)`${m.code.formats}${(0,t.getProperty)(c)}`:void 0,R=i.scopeValue("formats",{key:c,ref:x,code:S});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,t._)`${R}.validate`]:["string",x,R]}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})),zE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=[ZL().default];e.default=t})),RE=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=vE(),r=$E(),o=SE(),n=zE(),i=RE(),s=[t.default,r.default,(0,o.default)(),n.default,i.metadataVocabulary,i.contentVocabulary];e.default=s})),WL=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={}))})),Pk=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=WL(),o=ty(),n=gc(),i=He(),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 k in v)c.elseIf((0,t._)`${g} === ${k}`),c.assign(h,y(v[k]));c.else(),a.error(!1,{discrError:r.DiscrError.Mapping,tag:g,tagName:p}),c.endIf()}function y(v){let k=c.name("valid"),_=a.subschema({keyword:"oneOf",schemaProp:v},k);return a.mergeEvaluated(_,t.Name),k}function w(){var v;let k={},_=x(m),$=!0;for(let P=0;P<f.length;P++){let j=f[P];if(j?.$ref&&!(0,i.schemaHasRulesButRef)(j,d.self.RULES)){let T=j.$ref;if(j=o.resolveRef.call(d.self,d.schemaEnv.root,d.baseId,T),j instanceof o.SchemaEnv&&(j=j.schema),j===void 0)throw new n.default(d.opts.uriResolver,d.baseId,T)}let N=(v=j?.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(j)),S(N,P)}if(!$)throw new Error(`discriminator: "${p}" must be required`);return k;function x({required:P}){return Array.isArray(P)&&P.includes(p)}function S(P,j){if(P.const)R(P.const,j);else if(P.enum)for(let N of P.enum)R(N,j);else throw new Error(`discriminator: "properties/${p}" must have "const" or "enum"`)}function R(P,j){if(typeof P!="string"||P in k)throw new Error(`discriminator: "${p}" values must be unique strings`);k[P]=j}}}};e.default=s})),BL=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}})),PE=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=Sk(),o=IE(),n=Pk(),i=BL(),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=hc();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=cm();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return m.default}});var d=gc();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})),jE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicAnchor=void 0;let t=qe(),r=$r(),o=ty(),n=zk(),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})),EE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicRef=void 0;let t=qe(),r=$r(),o=zk(),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})),HL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=jE(),r=He(),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})),JL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=EE(),r={keyword:"$recursiveRef",schemaType:"string",code:o=>(0,t.dynamicRef)(o,o.schema)};e.default=r})),TE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=jE(),r=EE(),o=HL(),n=JL(),i=[t.default,r.default,o.default,n.default];e.default=i})),GL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ik(),r={keyword:"dependentRequired",type:"object",schemaType:"object",error:t.error,code:o=>(0,t.validatePropertyDeps)(o)};e.default=r})),KL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ik(),r={keyword:"dependentSchemas",type:"object",schemaType:"object",code:o=>(0,t.validateSchemaDeps)(o)};e.default=r})),XL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=He(),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})),CE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=GL(),r=KL(),o=XL(),n=[t.default,r.default,o.default];e.default=n})),YL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=He(),o=$r(),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})),QL=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qe(),r=He(),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})),AE=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=YL(),r=QL(),o=[t.default,r.default];e.default=o})),e3=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"}]}}}}})),t3=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:"#"}}}}})),n3=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:"#"}}}})),r3=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:{}}}}})),o3=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"}}}})),i3=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}}}})),s3=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:[]}}}})),a3=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=e3(),r=t3(),o=n3(),n=r3(),i=o3(),s=i3(),a=s3(),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})),c3=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=Sk(),o=IE(),n=TE(),i=CE(),s=AE(),a=Pk(),c=a3(),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=hc();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=cm();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var p=gc();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})})),l3=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vE(),r=$E(),o=SE(),n=TE(),i=CE(),s=AE(),a=zE(),c=RE(),l=[n.default,t.default,r.default,(0,o.default)(!0),a.default,c.metadataVocabulary,c.contentVocabulary,i.default,s.default];e.default=l})),u3=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}}}})),m3=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"}}}}})),d3=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"}}}})),f3=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"}}}})),p3=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"}}}})),h3=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"}}}})),g3=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}}}})),y3=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:[]}}}})),b3=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=u3(),r=m3(),o=d3(),n=f3(),i=p3(),s=h3(),a=g3(),c=y3(),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})),w3=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=Sk(),o=l3(),n=Pk(),i=b3(),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=hc();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=cm();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var m=gc();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})),v3=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(P,j){return{validate:P,compare:j}}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:R,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(P){return P%4===0&&(P%100!==0||P%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(P){let j=o.exec(P);if(!j)return!1;let N=+j[1],T=+j[2],q=+j[3];return T>=1&&T<=12&&q>=1&&q<=(T===2&&r(N)?29:n[T])}function s(P,j){if(P&&j)return P>j?1:P<j?-1:0}let a=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(P){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||P&&!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(P,j){if(!(P&&j))return;let N=new Date("2020-01-01T"+P).valueOf(),T=new Date("2020-01-01T"+j).valueOf();if(N&&T)return N-T}function u(P,j){if(!(P&&j))return;let N=a.exec(P),T=a.exec(j);if(N&&T)return P=N[1]+N[2]+N[3],j=T[1]+T[2]+T[3],P>j?1:P<j?-1:0}let m=/t|\s/i;function d(P){let j=c(P);return function(T){let q=T.split(m);return q.length===2&&i(q[0])&&j(q[1])}}function f(P,j){if(!(P&&j))return;let N=new Date(P).valueOf(),T=new Date(j).valueOf();if(N&&T)return N-T}function p(P,j){if(!(P&&j))return;let[N,T]=P.split(m),[q,Z]=j.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(P){return h.test(P)&&g.test(P)}let y=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function w(P){return y.lastIndex=0,y.test(P)}let v=-(2**31),k=2**31-1;function _(P){return Number.isInteger(P)&&P<=k&&P>=v}function $(P){return Number.isInteger(P)}function x(){return!0}let S=/[^\\]\\Z/;function R(P){if(S.test(P))return!1;try{return new RegExp(P),!0}catch{return!1}}})),$3=ue((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;let t=PE(),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 k=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(k))}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})),x3=ue(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});let r=v3(),o=$3(),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})),OE=PE(),_3=c3(),k3=w3(),S3=Fd(x3(),1),z3=S3.default;function kk(e){let t=new e({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return z3(t),t}var ny=class{_ajv;_ajvDraft7;_ajv2019;_userAjv;constructor(e){this._userAjv=e!==void 0,this._ajv=e}get ajv(){return this._ajv??=kk(k3.Ajv2020)}_engineFor(e){if(this._userAjv)return this.ajv;let t=pz(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??=kk(_3.Ajv2019):this._ajvDraft7??=kk(OE.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)}}},l7=OE.Ajv;import jk from"node:process";var ZE=Symbol.for("mcp.completable");function Tk(e){return!!e&&typeof e=="object"&&ZE in e}function I3(e){return e[ZE]?.complete}var yc=15e3,P3=2**31-1;function um(e,t){if(!Number.isFinite(e)||e<1)return;let r=setInterval(t,Math.min(e,P3));return r.unref?.(),r}var WE,Ck=class{static{WE=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??yc}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(It(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=tr(e)||nr(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=nr(e)?e.error.code:void 0,i=n!==void 0&&(this._dispatchWindowOpen||n===ge.MissingRequiredClientCapability)?pk[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=um(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 j3(e){return e instanceof Ck?WE(e):void 0}function ry(e){return e.replaceAll(/[\\"]/g,String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g," ")}function NE(e,t,r,o){let n=`Bearer error="${ry(e)}", error_description="${ry(t)}"`;return r.length>0&&(n+=`, scope="${ry(r.join(" "))}"`),o&&(n+=`, resource_metadata="${ry(o)}"`),n}function BE(e,t){let{requiredScopes:r=[],resourceMetadataUrl:o}=t??{};if(!(e instanceof rm)){let n=new rm(gs.ServerError,"Internal Server Error");return Response.json(n.toResponseObject(),{status:500})}switch(e.code){case gs.InvalidToken:{let n=NE(e.code,e.message,r,o);return Response.json(e.toResponseObject(),{status:401,headers:{"WWW-Authenticate":n}})}case gs.InsufficientScope:{let n=NE(e.code,e.message,r,o);return Response.json(e.toResponseObject(),{status:403,headers:{"WWW-Authenticate":n}})}case gs.ServerError:return Response.json(e.toResponseObject(),{status:500});default:return Response.json(e.toResponseObject(),{status:400})}}function HE(e){let t=new URL(e);return t.pathname=E3(e),t.hash="",t.href}function E3(e){let t=T3(e.pathname);return`/.well-known/oauth-protected-resource${t==="/"?"":t}`}function T3(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function C3(e){return typeof e=="object"&&e!==null&&"setScopeChallengeResolver"in e&&typeof e.setScopeChallengeResolver=="function"}function A3(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 O3(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())A3(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 Ak(e,t,r){for(let o of e){let n=await r({request:o,...t!==void 0&&{authInfo:t}});if(n!==void 0)return O3(n)}}function Ok(e){if(e?.resourceMetadataUrl!==void 0)return e.resourceMetadataUrl;if(e?.resource?.protocol==="https:"||e?.resource?.protocol==="http:")return HE(e.resource)}function Nk(e,t){return BE(new rm(gs.InsufficientScope,e.errorDescription??"Insufficient scope"),{requiredScopes:[...e.scopes],resourceMetadataUrl:t})}var N3=8,M3=6e5;function D3(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??N3,roundTimeoutMs:e?.roundTimeoutMs??M3,legacyShim:e?.legacyShim??!0}}function JE(e,t,r){if(r===null||typeof r!="object"||typeof r.method!="string")throw new ze(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=Ej(o);if(n===void 0)throw new ze(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 q3(){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 Ek(e,t){if(e==="tools/call")return{content:[{type:"text",text:t}],isError:!0};throw new ze(ge.InternalError,t)}var U3=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 Ek(e,iE(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 ze(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:k,required:_}=JE(e,w,v);if(k.method!=="roots/list"&&k.params===void 0)throw new ze(ge.InternalError,`Handler for ${e} returned an input request '${w}' of kind '${k.method}' without params`);if(om(_,g)!==void 0)return Ek(e,`Cannot request input '${w}' (${k.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,k])}let y=aE(a);try{let w={relatedRequestId:o.mcpReq.id,timeout:s,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:y.signal},v=await Promise.all(b.map(async([k,_])=>{try{return[k,await this._dispatchLeg(_,w)]}catch($){throw y.abort($),$}}));f=Object.fromEntries(v)}catch(w){if(a.aborted)throw w;return Ek(e,`Fulfilling input required by '${e}' failed: ${w instanceof Error?w.message:String(w)}`)}finally{y.dispose()}}else await sE(oE,a);let p={...o,mcpReq:{...o.mcpReq,inputResponses:f,droppedInputResponseKeys:void 0,requestState:am(d)}};if(d!==void 0){let g=await this._host.verifyRequestState(d,p,e);g!==void 0&&(p=gk(p,g))}let h=await t(r,p);if(!ho(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:q3()}),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)}}},L3=new Set(["tools/call","prompts/get","resources/read"]),GE,KE,XE;function YE(e,t){GE(e,t)}function oy(e,t){KE(e,t)}function iy(e){return XE(e)}var QE=class extends yk{_clientCapabilities;_clientVersion;static{GE=(e,t)=>{t.clientCapabilities!==void 0&&(e._clientCapabilities=t.clientCapabilities),t.clientInfo!==void 0&&(e._clientVersion=t.clientInfo)},KE=(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())},XE=e=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_boundFromTransport=!1;_legacyInputRequiredShim(){return this._legacyShim??=new U3({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 ny,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=D3(t?.inputRequired),t?.cacheHints!==void 0){for(let[r,o]of Object.entries(t.cacheHints))o!==void 0&&ck(o,`cacheHints['${r}']`);this._cacheHints=t.cacheHints}this.setRequestHandler("initialize",r=>this._oninitialize(r)),this.setNotificationHandler("notifications/initialized",()=>this.oninitialized?.()),Lg(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=j3(e)?.revision;t!==void 0&&!this._servedModernEra()&&Sn.includes(t)&&Lg(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=Hg(ui,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?.[oi],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(ui.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=bk(this._capabilities,e),!t&&this._capabilities.logging&&this._registerLoggingHandler()}_wrapHandler(e,t){if(e!=="tools/call"){let r=this._cacheHints?.[e],o=L3.has(e);return r===void 0&&!o?async(n,i)=>{let s=await t(n,i);if(ho(s))throw new ze(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(ho(s)){if(!o)throw new ze(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:Fg(s,r)}}return async(r,o)=>{let n=fo(this._negotiatedProtocolVersion),i=n.validateRequest("tools/call",r);if(!i.ok)throw new ze(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(ho(s))return s;let a=rk(s),c=n.validateResult("tools/call",a);if(!c.ok)throw new ze(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&&po(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 ze(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=gk(o,m))}let a;try{a=await t(r,s)}catch(m){throw m instanceof ze&&m.code===ge.UrlElicitationRequired&&n?new ze(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(!ho(a))return a;if(!n){if(!this._inputRequiredServing.legacyShim)throw new ze(ge.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??ls}, 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 ze(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}=JE(e,d,f),g=om(h,m);if(g!==void 0)throw new im({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 ze(ge.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[Mr]: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=Cj(this._supportedProtocolVersions),o=r.includes(t)?t:r[0]??ls;return this._negotiatedProtocolVersion=o,this.transport?.setProtocolVersion?.(o),{protocolVersion:o,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:Lg(this._supportedProtocolVersions),capabilities:F3(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 ze(ge.InvalidParams,"The last message must contain only tool_result content if any is present");if(!u)throw new ze(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 ze(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 ze(ge.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(a){throw a instanceof ze?a:new ze(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 F3(e){return{...e}}function V3(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 Z3(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 fi=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 DE;try{let r=ws(t.inputSchema,"input");return this._toolInputSchemaJson[e]=r,r}catch{return}}}constructor(e,t){this.server=new QE(e,t),this._maxToolInputElements=Z3(t?.maxToolInputElements),t?.capabilities?.tools&&this.setToolRequestHandlers(),t?.capabilities?.resources&&this.setResourceRequestHandlers(),t?.capabilities?.prompts&&this.setPromptRequestHandlers()}async connect(e){return C3(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?W3(e,t.inputSchema):DE,annotations:t.annotations,icons:t.icons,execution:t.execution,_meta:t._meta};return t.outputSchema&&(r.outputSchema=ws(t.outputSchema,"output")),r})})),this.server.setRequestHandler("tools/call",async(e,t)=>{let r=this._registeredTools[e.params.name];if(!r)throw new ze(ge.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new ze(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),ho(n)?n:this.server.projectCallToolResult(n,r.outputSchemaJson)}catch(o){if(o instanceof ze&&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&&V3(t,this._maxToolInputElements)>this._maxToolInputElements)throw new ze(ge.InvalidParams,`Invalid arguments for tool ${r}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!e.inputSchema)return;let o=await ps(e.inputSchema,t??{});if(!o.success)throw new ze(ge.InvalidParams,`Input validation error: Invalid arguments for tool ${r}: ${o.error}`);return o.data}async validateToolOutput(e,t,r){if(!e.outputSchema||ho(t)||t.isError)return;if(t.structuredContent===void 0)throw new ze(ge.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);let o=await ps(e.outputSchema,t.structuredContent);if(!o.success)throw new ze(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 dk(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return fk(e),this.handleResourceCompletion(e,e.params.ref);default:throw new ze(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 ze(ge.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new ze(ge.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return lm;let o=VE(FE(r.argsSchema)?.[e.params.argument.name]);if(!Tk(o))return lm;let n=I3(o);return n?LE(await n(e.params.argument.value,e.params.context)):lm}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 lm;throw new ze(ge.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=r.resourceTemplate.completeCallback(e.params.argument.name);return o?LE(await o(e.params.argument.value,e.params.context)):lm}_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 ze(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 ze(ge.InvalidParams,`Resource ${r} disabled`);return Fg(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 ze(ge.InvalidParams,`Resource template ${n.resourceTemplate.uriTemplate} disabled`);return Fg(await n.readCallback(r,i,t),n.cacheHint)}}throw new Vg(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?rE(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 ze(ge.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new ze(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&&ck(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:UE(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=UE(e,c,l)),m.enabled!==void 0&&(u.enabled=m.enabled),this.sendPromptListChanged()}};if(this._registeredPrompts[e]=u,o){let m=FE(o);m&&Object.values(m).some(d=>Tk(VE(d)))&&this.setCompletionRequestHandler()}return u}_createRegisteredTool(e,t,r,o,n,i,s,a,c,l,u){_k(e);let m=u,d,f={title:t,description:r,inputSchema:o,outputSchema:n,get outputSchemaJson(){return d??=qE(f.outputSchema)},set outputSchemaJson(p){d=p},annotations:i,icons:s,execution:a,scopeChallenge:c,_meta:l,handler:u,executor:ME(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"&&_k(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=ME(f.inputSchema,m)),p.outputSchema!==void 0&&(f.outputSchema=p.outputSchema,f.outputSchemaJson=qE(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,Gg(i),Gg(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,Gg(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 ME(e,t){if(e){let o=t;return async(n,i)=>o(n,i)}let r=t;return async(o,n)=>r(n)}var DE={type:"object",properties:{}};function W3(e,t){let r=ws(t,"input"),o=Zg(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 qE(e){if(e!==void 0)try{return ws(e,"output")}catch{return}}function UE(e,t,r){if(t){let o=r;return async(n,i)=>{let s=await ps(t,n??{});if(!s.success)throw new ze(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 LE(e){return{completion:{values:e.map(String).slice(0,100),total:e.length,hasMore:e.length>100}}}var lm={completion:{values:[],hasMore:!1}};function FE(e){let t=e;if(t.shape&&typeof t.shape=="object")return t.shape}function B3(e){return e?.type==="optional"}function VE(e){return B3(e)?e.def?.innerType??e:e}var tT=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 nT(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 rT(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 oT(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 H3(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 bc=1024;function eT(e,t,r){return Response.json({jsonrpc:"2.0",error:{code:t,message:r},id:e},{status:200})}function sy(e,t){return{method:e.method,params:{...e.params,_meta:{...e.params?._meta,[ri]:t}}}}function iT(e){let t=fo(sm).validateRequest("subscriptions/listen",e);return t.ok?t.value.params?.notifications:void 0}function sT(e){let{bus:t,onerror:r}=e,o=e.maxSubscriptions??bc,n=e.keepAliveMs??yc,i=new Set;function s(a,c,l,u){if(i.size>=o)return r?.(new Error(`subscriptions/listen refused: subscription limit reached (${o})`)),eT(a.id,-32603,"Subscription limit reached");let m=iT(a);if(m===void 0)return eT(a.id,-32602,"Invalid params: 'notifications' is required and must be a valid SubscriptionFilter");let d=oT(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(S){r?.(S instanceof Error?S:new Error(String(S)))}},k=(x,S)=>{v(`event: message
81
+ data: ${JSON.stringify({jsonrpc:"2.0",method:x,params:S})}
82
+
83
+ `)},_=x=>{if(!g){x&&v(`event: message
84
+ data: ${JSON.stringify({jsonrpc:"2.0",id:f,result:{resultType:"complete",_meta:{[ri]:f,[br]:u}}})}
85
+
86
+ `),g=!0;try{b?.()}catch(S){r?.(S instanceof Error?S:new Error(String(S)))}y!==void 0&&clearInterval(y),w?.(),i.delete(_);try{h.close()}catch{}}},$=new ReadableStream({start(x){h=x;let S=sy({method:"notifications/subscriptions/acknowledged",params:{notifications:d}},f);if(k(S.method,S.params),Object.keys(d).length===0){_(!0);return}b=t.subscribe(R=>{if(g||!rT(d,R))return;let P=sy(H3(R),f);k(P.method,P.params)}),y=um(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 J3=new Set(["notifications/tools/list_changed","notifications/prompts/list_changed","notifications/resources/list_changed","notifications/resources/updated"]),aT=class{_subs=new Map;_serverCapabilities;_serverInfo;constructor(e=bc,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=iT(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=oT(t,this._serverCapabilities);return this._subs.set(e.id,r),sy({method:"notifications/subscriptions/acknowledged",params:{notifications:r}},e.id)}cancel(e){return this._subs.delete(e)}routeOutbound(e){if(!J3.has(e.method))return"passthrough";let t=e.params?.uri,r=typeof t=="string"?t:void 0,o=G3(e.method,r),n=[];for(let[i,s]of this._subs)rT(s,o)&&n.push(sy({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:{[ri]:t,...this._serverInfo!==void 0&&{[br]:this._serverInfo}}}});return this._subs.clear(),e}};function G3(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 cT=Symbol("swallowsErrorsAfterClose"),K3=class{_readBuffer;_started=!1;_closed=!1;constructor(e=jk.stdin,t=jk.stdout,r){this._stdin=e,this._stdout=t,this._readBuffer=new $k({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[cT]&&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[cT]=!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=xk(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)})}},lT=3e3,X3=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(tr(e)||nr(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(It(e))this._pendingRequests.add(e.id);else if(Dr(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 Y3(e){let t=e.params;if(e.method==="initialize"&&!Wg(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(!bs(t))return{kind:"legacy",reason:"no-claim"};let r=vr(t),o=(r===void 0?[]:hs(r))[0];if(o!==void 0)return{kind:"invalid-envelope",issue:o};let n=pc(t);return n===void 0||!Sn.includes(n)?{kind:"unsupported-revision",requested:n??"unknown"}:{kind:"modern",revision:n,classification:{era:"modern",revision:n}}}function uT(e,t={}){let r=t.legacy??"serve",o=t.transport??new K3,n={phase:"opening"},i,s=!1,a=()=>s||n.phase==="closed",c=x=>{try{t.onerror?.(x)}catch{}},l=(x,S,R,P)=>o.send({jsonrpc:"2.0",id:x,error:{code:S,message:R,...P!==void 0&&{data:P}}}).catch(j=>c(_r(j))),u=new aT(t.maxSubscriptions??bc),m=x=>{if(!Dr(x))return;let S=u.routeOutbound(x);if(S!=="passthrough"){for(let R of S)o.send({jsonrpc:"2.0",...R}).catch(P=>c(_r(P)));return"handled"}},d=async x=>{if(It(x)&&x.method==="subscriptions/listen"){let S=vr(x.params),R=bs(x.params)?(S===void 0?[]:hs(S))[0]:{key:"_meta",problem:"the per-request envelope is required on protocol revision 2026-07-28"},P=pc(x.params),j;if(R!==void 0)j={jsonrpc:"2.0",id:x.id,error:{code:-32602,message:`Invalid _meta envelope: ${R.key}: ${R.problem}`}};else if(P===void 0||!Sn.includes(P)){let N=new ys({supported:[...Sn],requested:P??"unknown"});j={jsonrpc:"2.0",id:x.id,error:{code:N.code,message:N.message,data:N.data}}}else j=u.serve(x);return await o.send("error"in j?j:{jsonrpc:"2.0",method:j.method,params:j.params}).catch(N=>c(_r(N))),!0}if(Dr(x)&&x.method==="notifications/cancelled"){let S=x.params?.requestId;if(S!==void 0&&u.cancel(S))return!0}return!1},f=(x,S,R)=>{let P=Bg({kind:"legacy",reason:S,...R!==void 0&&{requestedVersion:R}},Sn);return P===void 0?Promise.resolve():(c(new Error(`Rejected 2025-era request on a modern-only stdio connection (${P.cell}): ${P.message}`)),l(x.id,P.code,P.message,P.data))},p=x=>{s||x===i||_()},h=async(x,S)=>{let R=await e({era:x}),P=R instanceof fi?R.server:R;x==="modern"&&(Jg(P,S),oy(P,Sn),u.setServerCapabilities(P.getCapabilities(),iy(P)));let j=new X3(o,()=>p(j),x==="modern"?m:void 0);return await R.connect(j),{product:R,channel:j}},g=x=>x.product.close().catch(S=>c(_r(S))),b=async x=>{i=x.channel;try{await x.channel.whenRequestsAnswered(lT)||c(new Error(`Discarded the probe instance with requests still unanswered after ${lT}ms; continuing with the fallback`)),await x.product.close()}catch(S){c(_r(S))}finally{i=void 0}},y=async x=>{if(n.phase==="closed")return;if(n.phase==="pinned"){if(n.era==="modern"&&It(x)&&x.method==="initialize"&&!Wg(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(!It(x)&&!Dr(x)){c(new Error("Discarded a JSON-RPC response received before the connection negotiated an era"));return}let S=Y3(x);switch(S.kind){case"invalid-envelope":{let R=`Invalid _meta envelope for protocol revision 2026-07-28: ${S.issue.key}: ${S.issue.problem}`;It(x)?await l(x.id,ge.InvalidParams,R,{envelope:S.issue}):c(new Error(`Discarded a notification with a malformed envelope: ${R}`));return}case"unsupported-revision":if(It(x)){let R=new ys({supported:[...Sn],requested:S.requested});c(R),await l(x.id,R.code,R.message,R.data)}else c(new Error(`Discarded a notification claiming unsupported protocol revision ${S.requested}`));return;case"modern":if(It(x)&&x.method==="server/discover"){if(n.phase==="probe"){n.instance.channel.deliver(x,{classification:S.classification});return}let R=await h("modern",S.revision);if(a()){await g(R);return}n={phase:"probe",instance:R},R.channel.deliver(x,{classification:S.classification});return}if(n.phase==="probe"){if(Dr(x)){n.instance.channel.deliver(x,{classification:S.classification});return}n={phase:"pinned",era:"modern",instance:n.instance}}else{let R=await h("modern",S.revision);if(a()){await g(R);return}n={phase:"pinned",era:"modern",instance:R}}if(await d(x)||a())return;n.instance.channel.deliver(x,{classification:S.classification});return;case"legacy":{if(r==="reject"){It(x)&&await f(x,S.reason,S.requestedVersion);return}if(n.phase==="probe"){if(await b(n.instance),a())return;n={phase:"opening"}}let R=await h("legacy");if(a()){await g(R);return}n={phase:"pinned",era:"legacy",instance:R},n.instance.channel.deliver(x);return}}},w=[],v=!1,k=async()=>{if(!v){v=!0;try{for(;w.length>0;){let x=w.shift();try{await y(x)}catch(S){It(x)&&await l(x.id,ge.InternalError,"Internal server error"),c(_r(S))}}}finally{v=!1}}},_=async()=>{if(s||n.phase==="closed")return;s=!0;let x=n;n={phase:"closed"};for(let S of u.teardownAll())await o.send(S).catch(R=>c(_r(R)));(x.phase==="probe"||x.phase==="pinned")&&await x.instance.product.close().catch(S=>c(_r(S))),await o.close().catch(S=>c(_r(S)))};o.onmessage=x=>{w.push(x),k()},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(S=>c(_r(S)))};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 aW}from"node:crypto";import{existsSync as Db,readFileSync as Mb,statSync as cW}from"node:fs";import{createServer as lW}from"node:http";import{extname as uW,join as Zc,normalize as mW,sep as dW}from"node:path";import{fileURLToPath as MN}from"node:url";async function Q3(e,t,r){let o=new Ck({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 Dk=4*1024*1024,Mk=100;function dT(e){return`Payload Too Large: Request body must not exceed ${e} bytes`}function fT(e){if(e===void 0)return Dk;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 pT(e,t=Dk){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 e5=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??ku,this._keepAliveMs=e.keepAliveMs??yc,this._maxRequestBodySize=fT(e.maxRequestBodySize)}startKeepAlive(e,t){if(this._closed)return;let r=um(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 Ak(e.filter(o=>It(o)),t,this._scopeChallengeResolver);return r===void 0?void 0:Nk(r,Ok(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(!vk(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 pT(e,this._maxRequestBodySize);if(g.tooLarge){let b=dT(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>Mk)return this.onerror?.(new Error(`Invalid Request: Batch must not exceed ${Mk} messages`)),this.createJsonErrorResponse(400,-32600,`Invalid Request: Batch must not exceed ${Mk} messages`);let i;try{i=Array.isArray(n)?n.map(g=>fs.parse(g)):[fs.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=>mk(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=>It(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=>mk(g)),u=l?l.params.protocolVersion:e.headers.get("mcp-protocol-version")??Gp;if(this._enableJsonResponse)return new Promise(g=>{this._streamMapping.set(c,{resolveJson:g,cleanup:()=>{this._streamMapping.delete(c)}});for(let b of i)It(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)It(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;It(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((tr(e)||nr(e))&&(r=e.id),r===void 0){if(tr(e)||nr(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(tr(e)||nr(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 pi(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 go(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 ay(e,t=null){return go(e.httpStatus,e.code,e.message,e.data,t)}function mm(e){return e instanceof Error?e:new Error(String(e))}function dm(e=null){return go(500,-32603,"Internal server error",void 0,e)}function mT(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 t5(e,t,r,o){return async(n,i)=>{if(n.method.toUpperCase()!=="POST")return go(405,-32e3,"Method not allowed.");try{let s=await e({era:"legacy",...i?.authInfo!==void 0&&{authInfo:i.authInfo},requestInfo:n}),a=new e5({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||wk(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?.(mm(s))}catch{}return dm(pi(i?.parsedBody))}}}function hT(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 n5(e,t,r=!0,o=Dk){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 pT(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:tE({httpMethod:n,...hT(e),...i!==void 0&&{body:i}}),body:i,parsedBody:s,forwardRequest:a}}function qk(e,t={}){let{legacy:r,onerror:o,responseMode:n}=t,i=fT(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 tT(c),u=nT(l),m=sT({bus:l,maxSubscriptions:t.maxSubscriptions??bc,keepAliveMs:t.keepAliveMs??yc,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:t5(e,c,t.keepAliveMs,i);async function f(b,y,w){let v=b.classification.revision;if(v===void 0||!Sn.includes(v)){let j=new ys({supported:[...Sn],requested:v??"unknown"});return c(j),go(400,j.code,j.message,j.data,pi(b.message))}let k=Qj({httpMethod:y.method,...hT(y)},b);if(k!==void 0)return c(new Error(`Rejected inbound request (${k.cell}): ${k.message}`)),ay(k,pi(b.message));let _=b.messageKind==="request"?vr(b.message.params):void 0,$=_?.[Mr];if(b.messageKind==="request"){let j=jj(b.message.method);if(j!==void 0){let N=om(j,$);if(N!==void 0){let T=new im({requiredCapabilities:N});return c(T),go(Yj(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}),S=x instanceof fi?x.server:x;if(mT(S),b.messageKind==="request"&&b.message.method==="subscriptions/listen"){let j=S.getCapabilities(),N=iy(S);return x.close().catch(c),m.serve(b.message,y.signal,j,N)}if(b.messageKind==="request"&&b.message.method==="tools/call"&&x instanceof fi){let j=b.message.params,N=typeof j?.name=="string"?j.name:void 0,T=N===void 0?void 0:x.toolInputSchemaJson(N);if(T!==void 0){let q=Zg(T);if(q.declarations!==void 0&&q.declarations.length>0){let Z=Xj(q.declarations,j?.arguments,y.headers);if(Z!==void 0)return x.close().catch(c),c(new Error(`Rejected inbound request (${Z.cell}): ${Z.message}`)),ay(Z,b.message.id)}}}if(b.messageKind==="request"&&x instanceof fi)try{let j=await Ak([b.message],w,N=>x.resolveScopeChallenge(N));if(j!==void 0)return x.close().catch(c),Nk(j,Ok(w))}catch(j){return x.close().catch(c),c(mm(j)),dm(b.message.id)}mT(S),Jg(S,v),oy(S,Sn),_!==void 0&&YE(S,{clientInfo:_[us],clientCapabilities:$});let R=S.onclose;s.add(S);let P=()=>{s.delete(S),S.onclose===P&&(S.onclose=R),R?.()};S.onclose=P;try{let j=await Q3(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(()=>{S.close().catch(()=>{})}),j}catch(j){return j instanceof Oe&&j.code===Ue.ConnectionClosed?new Response(null,{status:499}):(await S.close().catch(()=>{}),s.delete(S),c(mm(j)),dm(pi(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 k=Bg(b,Sn);return k===void 0?new Response(null,{status:202}):(c(new Error(`Rejected 2025-era request on a modern-only endpoint (${k.cell}): ${k.message}`)),ay(k,pi(v)))}async function h(b,y){let w=y?.authInfo;if(b.method.toUpperCase()==="POST"&&!vk(b.headers.get("content-type")))return c(new Error("Unsupported Media Type: Content-Type must be application/json")),go(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let v=await n5(b,y?.parsedBody,!0,i);if(v.step==="unreadable-body")return go(400,-32700,"Parse error: the request body could not be read");if(v.step==="body-too-large")return go(413,-32e3,dT(i));if(v.step==="no-json-body")return d!==void 0?d(v.forwardRequest,{...w!==void 0&&{authInfo:w}}):go(400,-32700,"Parse error: the request body is not valid JSON");let{outcome:k,body:_,parsedBody:$,forwardRequest:x}=v;try{switch(k.kind){case"reject":return c(new Error(`Rejected inbound request (${k.cell}): ${k.message}`)),ay(k,pi(_));case"modern":return await f(k,b,w);case"legacy":return await p(k,x,w,$)}}catch(S){return c(mm(S)),dm(pi(_))}}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(mm(w)),dm(pi(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 vs=["tile","sprite","sheet","icon","family","overlay","object","map","font"],Uk=["tone","full","channel"],gT=["cycle","pingpong","wave","sparkle"];function wc(e){return e.iconMode??(e.palette.entries.some(t=>t.role)?"tone":"full")}function yT(e){return{...e,chars:[...e.chars],advances:{...e.advances}}}function r5(e){return{...e,at:[e.at[0],e.at[1]],anchor:[e.anchor[0],e.anchor[1]],flags:[...e.flags]}}function bT(e){return{tile:e.tile,entries:e.entries.map(t=>({...t,anchor:[t.anchor[0],t.anchor[1]]}))}}function qr(e,t={}){return{name:e,hidden:!1,locked:!1,reference:!1,...t}}function wT(e){let t=new Uint16Array(e.width*e.height).fill(e.bg),r=e.family?[qr("ground"),qr("band")]:e.map?[qr("floor",{map:{kind:"tiles"}})]:[qr("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?vT(e.family):null,overlay:e.overlay?$T(e.overlay):null,footprint:null,variantOf:null,densityOf:null,map:e.map?bT(e.map):null,marks:[],iconMode:null,font:e.font?yT(e.font):null}}function vT(e){return{...e,geometry:{...e.geometry,bands:e.geometry.bands.map(t=>({...t}))},detached:[...e.detached],terrain:e.terrain.slice()}}function $T(e){return{...e,anchor:e.anchor?[e.anchor[0],e.anchor[1]]:null,spread:[e.spread[0],e.spread[1]]}}function o5(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 xT(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 _T(e){return e.ticks.some(t=>t!==10)||e.tags.length>0||e.views.length>0||e.pivot!==null||e.ground!==null||xT(e).length>0}function i5(e){return{...e,sel:e.sel?e.sel.slice():null,mirror:e.mirror?{...e.mirror}:null,brush:e.brush?{...e.brush}:null}}function Ur(e){return{...e,layers:e.layers.map(t=>({...t})),cels:o5(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,i5(r)])),home:{...e.home},family:e.family?vT(e.family):null,overlay:e.overlay?$T(e.overlay):null,footprint:e.footprint?r5(e.footprint):null,map:e.map?bT(e.map):null,notes:e.notes.map(t=>({...t})),marks:e.marks.map(t=>({...t})),font:e.font?yT(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 Nt(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 kr(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)Nt(e,n,{})}function s5(e){return e.layers.flatMap((t,r)=>t.hidden||t.reference?[]:[r])}function be(e,t=0){return ST(e,t,s5(e))}function kT(e,t=0){let r=e.layers.flatMap((o,n)=>o.reference&&!o.hidden?[n]:[]);return r.length?ST(e,t,r):null}function ST(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 ly(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 Lk(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 cy=e=>Object.keys(e).sort();function zn(e){let t=cy(e.ctx),r=cy(e.stamps),o=cy(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:cy(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,a5(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]),..._T(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:xT(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=ly(`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 uy(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(Lk(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:c5(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 a5(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 c5(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 zT(e){let t=Object.keys(e.ctx);if(_T(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=ly(`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 vc(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 Bt=["black","white","light","dark","darkest"];function fm(e){return Bt.includes(e)}var RT=256,Fk=new Set(["."," ","|"]),hi=/^[A-Za-z][A-Za-z0-9_-]*$/,l5=/^#?([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 u5(e,t,r){return"#"+[e,t,r].map(o=>o.toString(16).padStart(2,"0")).join("")}function gi(e){let t=l5.exec(e.trim());return t?"#"+t[1].toLowerCase():null}function $s(e){if(!e.name||!hi.test(e.name))throw new ot(`palette name '${e.name}' must match ${hi}`);if(e.entries.length===0)throw new ot(`palette '${e.name}' has no entries`);if(e.entries.length>RT)throw new ot(`palette '${e.name}' has ${e.entries.length} entries; the limit is ${RT}`);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(Fk.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(!hi.test(o.name))throw new ot(`entry name '${o.name}' must match ${hi}`);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&&!fm(o.role))throw new ot(`entry '${o.name}': role '${o.role}' must be one of ${Bt.join(", ")}`);t.add(o.key),r.add(o.name)}for(let[o,n]of Object.entries(e.ramps)){if(!hi.test(o))throw new ot(`ramp name '${o}' must match ${hi}`);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 xs(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 m5(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 Vk(e,t){let r=xs(t.length),o=new Set,n=t.map((i,s)=>({key:r[s],name:m5(i.name??"",`c${s}`,o),hex:i.hex}));return $s({name:e,entries:n,ramps:{}})}function d5(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"&&hi.test(o.name)?o.name:t??"palette";if(Array.isArray(o.colors))return Vk(n,o.colors.map((a,c)=>{let l=typeof a=="string"?gi(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"||!fm(l.role)))throw new ot(`entries[${c}]: role must be one of ${Bt.join(", ")}`);let u=l.role,m=typeof l.hex=="string"?gi(l.hex):u?$c[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 $s({name:n,entries:i,ramps:s})}function f5(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=gi(i);if(!s)throw new ot(`line ${n+1}: '${i}' is not a hex colour`);r.push({hex:s})}),Vk(t,r)}function p5(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&&hi.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:u5(l,u,m),name:c[4]??""})}return Vk(o,n)}function Zk(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 d5(t,n);if(i==="hex")return f5(t,n);if(i==="gpl")return p5(t,n);throw new ot(`unknown palette format '.${i}' (use .json, .hex or .gpl)`)}function yo(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 $c={black:"#000000",white:"#ffffff",light:"#cccccc",dark:"#6e6e6e",darkest:"#282828"};function my(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=gi(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||!fm(m[1]))return{row:n,col:i.indexOf(c[2]),message:`palette row: '${c[2]}' should be role=${Bt.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:$s({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}},h5=/^-?\d+$/,g5=/^(-?\d+),(-?\d+)$/,y5=/^(\d+)x(\d+)$/,b5=/^@cell\((\d+),(\d+)\)$/,w5=/^@cell\(([a-z][a-z0-9_]*)\)$/,v5=/^([A-Za-z_][A-Za-z0-9_-]*)=/,$5=/^[a-z][a-z0-9_-]*$/,x5=1<<20;function _5(e,t,r,o){let n,i=(s,a)=>{let c=Number(s);if(Math.abs(c)>x5)throw new O(t,a,`number ${s} is out of range`);return c};if(n=v5.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 h5.test(e)?{t:"int",v:i(e,r),line:t,col:r}:(n=g5.exec(e))?{t:"point",x:i(n[1],r),y:i(n[2],r),line:t,col:r}:(n=y5.exec(e))?{t:"size",w:i(n[1],r),h:i(n[2],r),line:t,col:r}:(n=b5.exec(e))?{t:"cell",cx:i(n[1],r),cy:i(n[2],r),line:t,col:r}:(n=w5.exec(e))?{t:"cell",cx:-1,cy:-1,name:n[1],line:t,col:r}:{t:"word",v:e,line:t,col:r}}function k5(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"||!$5.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=S5(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:k5(g),line:c,col:d+1}),s=b,l=a.length;break}n.push(_5(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 S5(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 Lr=["S","N","E","W","SE","SW","NE","NW"];function pm(e){return{E:"W",W:"E",SE:"SW",SW:"SE",NE:"NW",NW:"NE"}[e]??null}function hm(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),kr(e,s=>s,s=>s>=t?s+r:s)}function Bk(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),kr(e,o=>o,o=>o>t?o-1:Math.min(o,e.frameCount-1))}function Hk(e,t){return r=>r===e?t:e<r&&r<=t?r-1:t<=r&&r<e?r+1:r}function PT(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=Hk(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)}kr(e,i=>i,n)}function z5(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 yi(e,t){return e.views.find(r=>r.from<=t&&t<=r.to)??null}function jT(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;)hm(e,t.to+1,1,()=>new Uint16Array(e.width*e.height).fill(65535),[10]),t.to++;for(;t.to-t.from+1>o;)Bk(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]=z5(i[r.from+n],e.width,e.height)})}}function rr(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)=>Lr.indexOf(i.name)-Lr.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 Fr(e){return e.loop!=="pingpong"||e.frames.length<3?e.frames:[...e.frames,...e.frames.slice(1,-1).reverse()]}function or(e,t){return Fr(t).reduce((r,o)=>r+e.ticks[o],0)}function Vr(e,t,r){let o=Fr(t),n=or(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++)xc(o,n*4,r);return{width:e,height:t,data:o}}function xc(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 R5=(()=>{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 I5(e,t=0,r=e.length){let o=4294967295;for(let n=t;n<r;n++)o=R5[(o^e[n])&255]^o>>>8;return(o^4294967295)>>>0}function P5(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 Gk=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)}},ET=[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],j5=[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],TT=[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],E5=[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 Jk(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 CT(e,t){let r=e.length-1;for(;e[r]>t;)r--;return r}function T5(e){let t=new Gk;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=CT(ET,l);Jk(t,257+m),t.bits(l-ET[m],j5[m]);let d=CT(TT,u);t.code(d,5),t.bits(u-TT[d],E5[d]);for(let f=0;f<l;f++)a(c+f);c+=l}else Jk(t,e[c]),a(c),c++}return Jk(t,256),t.finish()}function Kk(e){let t=T5(e),r=new Uint8Array(t.length+6);return r[0]=120,r[1]=1,r.set(t,2),xc(r,t.length+2,P5(e)),r}function gm(e,t){let r=new Uint8Array(12+t.length);xc(r,0,t.length);for(let o=0;o<4;o++)r[4+o]=e.charCodeAt(o);return r.set(t,8),xc(r,8+t.length,I5(r,4,8+t.length)),r}function C5(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 A5(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);xc(c,0,t),xc(c,4,r),c[8]=8,c[9]=a?3:6;let l=[Uint8Array.from([137,80,78,71,13,10,26,10]),gm("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(gm("PLTE",m));let f=-1;d.forEach((p,h)=>{p!==255&&(f=h)}),f>=0&&l.push(gm("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,k=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-A5(w,v,k)&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(gm("IDAT",Kk(u)),gm("IEND",new Uint8Array(0))),C5(l)}var Xk="#ff0000";function wo(e){let t=String.fromCodePoint(e);return/^[A-Za-z0-9]$/.test(t)?t:`U+${e.toString(16).toUpperCase().padStart(4,"0")}`}function AT(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 ym(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 dy(e,t){let r=e.font.cols;return[t%r*e.cellW,Math.floor(t/r)*e.cellH]}function fy(e,t,r=0,o){let n=o??be(e,r),[i,s]=dy(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 OT(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 O5(e,t,r){let o=e.font,n=o.chars[t];if(o.advances[n]!==void 0)return o.advances[n];let i=OT(fy(e,t,0,r),e.cellW,e.cellH);return i?i[2]+1:Math.ceil(e.cellW/2)}function py(e){let t=be(e,0);return e.font.chars.map((r,o)=>({cp:r,cell:dy(e,o),advance:O5(e,o,t),box:OT(fy(e,o,0,t),e.cellW,e.cellH)}))}var bo=class extends Error{};function hy(e,t,r=Xk){if(!e.font)throw new bo(`'${e.name}' is not a font`);let o=it(r),n=t.map(it),i=py(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=fy(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 bo(`${e.name}: glyph ${wo(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 gy(e,t,r,o=256){if(!e.font)throw new bo(`'${e.name}' is not a font`);let n=e.font,i=t.map(it),s=py(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[k,_,$,x]=y.box,S=fy(e,w,0,a);for(let R=_;R<=x;R++)for(let P=k;P<=$;P++){let j=S[R*e.cellW+P];if(j===65535)continue;let N=i[j];g.data.set([N[0],N[1],N[2],255],((v[1]+R-_)*p+v[0]+P-k)*4)}b.push(`char id=${y.cp} x=${v[0]} y=${v[1]} width=${$-k+1} height=${x-_+1} xoffset=${k} yoffset=${_} xadvance=${y.advance+n.spacing} page=0 chnl=15`)}),b.push("kernings count=0"),{fnt:b.join(`
121
+ `)+`
122
+ `,img:g}}function Yk(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 bm(e,t,r,o,n){return{name:e,colours:{black:"#000000",white:"#ffffff",light:Yk(t,n,.6),dark:Yk(r,n,.5),darkest:Yk(o,n,.4)}}}var NT=[{name:"grey",colours:{...$c}},bm("moss",95,115,140,.45),bm("ember",38,18,352,.65),bm("tide",185,205,228,.5),bm("dusk",290,265,240,.35),bm("sand",48,32,18,.5)];function MT(e,t){let r={...$c};for(let[o,n]of Object.entries(t)){if(!Bt.includes(o))throw new Error(`theme '${e}': unknown role '${o}' (roles: ${Bt.join(", ")})`);let i=typeof n=="string"?gi(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 Qk(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 DT(e){return e.entries.some(t=>t.role)}var qT={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 UT={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 LT={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 FT={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 ZT={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 WT={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 BT={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 yy=(1n<<64n)-1n,Z5=6364136223846793005n,dt=class{state=0n;inc=1n;constructor(t,r=54){this.inc=(BigInt(r)<<1n|1n)&yy,this.state=0n,this.nextU32(),this.state=this.state+(BigInt(t)&yy)&yy,this.nextU32()}nextU32(){let t=this.state;this.state=t*Z5+this.inc&yy;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 by(e){return e.nextU32()%2147483647+1}function wy(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},W5=[[1,0,-1],[2,1,-1],[4,1,0],[8,1,1],[16,0,1],[32,-1,1],[64,-1,0],[128,-1,-1]],HT=["in","out","outer","inner","horiz","vert","vround","hround","fillet","diag","diagcap","diagside","outerdiag","diagfill"],B5=["diag","diagcap","diagside","outerdiag","diagfill"],YT=["nw","ne","sw","se"],bi=e=>e==="face"||e==="side"||e==="corner",Sr=class extends Error{};function H5(e,t,r){let[o,n]=t.split("@"),i=HT.includes(o)?o:e.kinds?.[o];if(!i||!HT.includes(i))throw new Sr(`scheme ${e.name}: unknown quadrant kind '${o}'`);let s=n===void 0?r:YT.indexOf(n);if(s<0)throw new Sr(`scheme ${e.name}: '${t}' faces no corner (nw, ne, sw, se)`);return{kind:o,base:i,face:s}}function _s(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 Sr(`scheme ${e.name}: '${m.name}' is not a usable variant name`);if(t.has(m.name))throw new Sr(`scheme ${e.name}: variant '${m.name}' twice`);if(m.quads.length!==4)throw new Sr(`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 Sr(`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)=>H5(e,d,f))),c=e.pieces.map(m=>{let d=t.get(m);if(d===void 0)throw new Sr(`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 Sr(`scheme ${e.name}: no piece has the ${f.kind}@${YT[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 Sr(`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 vo=new Map([qT,UT,BT,ZT,LT,WT,FT,VT].map(e=>[e.name,_s(e)]));function vy(e){return vo.get(e)}function JT(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 GT(e,t,r){if(e.neighbours==="corners"||t)return e.byKey.get(JT(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 J5(...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 G5(e,t,r,o){if(t===null)return null;let n=e.alts.get(t);return n?n[J5(r,o,64206)%n.length]:t}function $o(e){return e.variants.flatMap((t,r)=>t.key===null?[]:[r])}var K5=(e,t)=>e.neighbours==="corners"?t.cols+1:t.cols;function wi(e,t,r="not",o=!0){let n=K5(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(GT(e,!0,d));continue}let u=0;for(let[d,f,p]of W5)s(l+f,c+p)&&(u|=d);let m=GT(e,s(l,c),u);a.push(o?G5(e,m,l,c):m)}return a}var KT=e=>e.bands.reduce((t,r)=>t+r.w,0);function X5(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 eS(e,t,r,o,n){return QT(e,t,r,o,n)}function QT(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 Y5(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 XT(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 eS(e,t,r,o,0)}}function Q5(e,t,r,o,n,i,s=0,a=0){let[c,l]=X5(t,r,e.face,o,n,i.inset),u=c-s,m=l-a;if(B5.includes(e.base)){let h=2*(KT(i)+i.radius),g=y=>Y5(e.base,u+2*i.inset,m+2*i.inset,y,t-2*i.inset,t)&&(e.base!=="outerdiag"||QT("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(XT(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,XT(e.base,u,m,h,d))return g;return i.bands.length}let f=2*(KT(i)+i.radius);if(eS(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,eS(e.base,u,m,p,f))return h;return i.bands.length}var eF=(e,t,r)=>(r>=e/2?2:0)|(t>=e/2?1:0);function eC(e,t,r,o){let n=new Int8Array(r*r),i=o.jitter&&o.jitter.px>0?tF(r,o.jitter.px,o.jitter.seed):null;for(let s=0;s<r;s++)for(let a=0;a<r;a++){let c=eF(r,a,s);n[s*r+a]=Q5(e.quadSpecs[t][c],r,c,a,s,o,i?i.u[s]:0,i?i.v[a]:0)}return n}function tF(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 tC(e,t){return e.inset?Math.floor(t*e.inset[0]/e.inset[1]):0}function nF(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 rF(e){return e.views.length?[...new Set(e.views.filter(t=>!t.mirror).map(t=>t.from))]:[0]}function wm(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 oF(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:rC(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 nC(e,t){let r=e.palette,o=r.entries.map(T=>nF(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,k=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=rF(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),k.set(M,(k.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 I=Z(F+A,V+z);if(I===65535||I===M||$.get(I)!==L)continue;let C=o[I]-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,I=Math.floor(A/i);for(let[C,U]of[[1,0],[-1,0],[0,1],[0,-1]]){let H=z+C,Y=I+U;if(e.wrap)H=(H+i)%i,Y=(Y+s)%s;else if(H<0||Y<0||H>=i||Y>=s)continue;let X=Y*i+H;!D[X]&&q[X]===F&&(D[X]=1,L.push(X))}}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 S=Math.hypot(m,d),R=f>0?S/f:0,P=Math.max(3,Math.floor(a/100)),j=[...v.values()].map(T=>[...T].filter(q=>(k.get(q)??0)>=P).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||R<.1?null:{x:m/S,y:d/S,strength:R},cluster:p?h/p/Math.sqrt(a/x.length):null,steps:j.length?j.reduce((T,q)=>T+q,0)/j.length:null,material:N,...oF(be(e,x[0]),i,s)}}var Rn={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 iF(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 rC(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 xo=e=>Math.round(e*10)/10,tS=e=>Math.round(e*100)/100;function nS(e,t,r){let o=t.filter(u=>wm(u.doc,e)||wm(e,u.doc)).map(u=>u.name),n=t.filter(u=>u.doc!==e&&!o.includes(u.name)),i=nC(e,r.ink),s=n.map(u=>({name:u.name,m:nC(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=rC([...w,y]);if(b){let[_,$]=iF([...w,y]),x=y<_?_-y:y>$?y-$:0,S=_===$?p(_):`${p(_)}..${p($)}`;a.push({name:m,value:y,limit:`\xB1 ${p(f)} of the set's ${S}`,pass:x<=f,detail:`${p(y)} against the set's middle half ${S} (with ${w.length} others)`});return}let k=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:k<=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(xo(u)),!1,!0),c("outline","outline share",u=>u.outline,r.maxOutline,u=>String(tS(u))),c("cluster","cluster size",u=>u.cluster,r.maxCluster,u=>String(tS(u)),!0),c("steps","ramp steps",u=>u.steps,r.maxSteps,u=>String(xo(u)),!1,!1,!0),r.icon&&(c("stroke","stroke weight",u=>u.stroke,r.icon.maxStroke,u=>String(xo(u))),c("fill","box fill",u=>u.fill,r.icon.maxFill,u=>String(tS(u))),i.centre)){let u=i.centre;a.push({name:"optical centre",value:xo(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 ${xo(u.x)},${xo(u.y)}, ${xo(u.off)} px from the canvas centre ${xo((e.width-1)/2)},${xo((e.height-1)/2)}`})}let l=r.light&&Rn[r.light]?Rn[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(Rn).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 oC=(e,t)=>(e%t+t)%t;function Et(e,t,r){return e.wrap?oC(r,e.height)*e.width+oC(t,e.width):t<0||r<0||t>=e.width||r>=e.height?-1:r*e.width+t}function xy(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 oS(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=xy(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?iC(r,o):vm(r)}function _c(e,t){let r=e.length?[e[0]]:[];for(let n=1;n<e.length;n++){let i=xy(e[n-1],e[n]);for(let s=1;s<i.length;s++)r.push(i[s])}let o=vm(r);return t?iC(o,new Set):o}function iC(e,t){if(e.length<3)return vm(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]),vm(r)}function vm(e){return e.filter((t,r)=>r===0||t[0]!==e[r-1][0]||t[1]!==e[r-1][1])}function $y(e,t){let r=Math.floor(e/t);return r*t>e?r--:(r+1)*t<=e&&r++,r}function sC(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([$y(2*u+i,2*i),$y(2*m+i,2*i)])}return _c(vm(s),t)}function _y(e,t,r){let o=oS([...e,e[0]],r);if(!t)return rS(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=-$y(-u,m);p<=$y(d,f);p++)n.push([p,a])}}return rS(n)}function _o(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 vi(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 rS(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 rS(e){let t=new Set;return e.filter(([r,o])=>t.has(`${r},${o}`)?!1:(t.add(`${r},${o}`),!0))}function ky(e,t,r,o,n,i){let s=Et(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=Et(e,d+p,f+h);g>=0&&e.pixels[g]===c&&(!a||a[g])&&(e.pixels[g]=o,u.push(g))}}}var kc=Object.keys(Rn);function Sy(e){let t=e&&Rn[e]?Rn[e]:Rn.nw;return Object.entries(Rn).find(([,r])=>r[0]===-t[0]&&r[1]===-t[1])[0]}function zy(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]=Rn[o]??[1,1];return{x:a-1+d*m,y:i-(u>>1)+f*m,w:l,h:u}}var Ry=e=>vi(e.x,e.y,e.x+e.w-1,e.y+e.h-1,!0);function aC(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=>Zr(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 Ln(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=>sF(n,i))]:[]}}}function sF(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 Hr=e=>[Math.max(1,Math.floor(e.width/e.cellW)),Math.max(1,Math.floor(e.height/e.cellH))];function Un(e){if(e.footprint)return e.footprint;let[t,r]=Hr(e);return{cols:t,rows:r,at:[0,0],anchor:[0,r-1],flags:Array.from({length:r},()=>".".repeat(t))}}function $m(e,t,r){let o=e.flags[r]?.[t]??".";return{block:o==="b"||o==="x",roof:o==="r"||o==="x"}}var xm=(e,t,r)=>t>=e.at[0]&&r>=e.at[1]&&t<e.at[0]+e.cols&&r<e.at[1]+e.rows;function Wr(e,t,r){return{x:t-e.anchor[0],y:r-e.anchor[1],w:e.cols,h:e.rows}}function Br(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 Sc(e,t){let r=e.layers[t]?.map?.kind,o=Br(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=Wr(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 aF(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 cF(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(ks(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(ks(a,c,t,7170425),e.filter(g=>g.name!==d))),n.set(u,d),d};return(a,c,l)=>s(a,c,l)}var iS=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)}},Iy=(e,t)=>!e.variants[t].on&&e.variants[t].quads.every(r=>r==="in"||r.startsWith("in@"));function cC(e,t){if(e.frameCount<2)return 0;let r=rr(e)[0];return Fr(r).length?Vr(e,r,t):0}function Ht(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 iS(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=cC(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 I=A+z;if(!(I<0||I>=c))for(let C=0;C<F;C++){let U=L+C;if(U<0||U>=a)continue;let H=q[(V+z)*Z+D+C];H!==65535&&(m[I*a+U]=H)}}},w=new Map,v=q=>{let Z=cC(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===Ss)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},k=new Set,_=q=>{let Z=t.family(q);return!Z.length&&!k.has(q)&&(k.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=ks(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]},S=[];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(H=>H.family);if(!z.length){t.get(D.family)&&p.push(`layer ${q.name}: '${D.family}' is not a family`);return}let I=et(z[0].family),C=wi(I,aF(e,Z,I),D.border??"same"),U=D.mix?cF(D.mix,D.seed??1,i,s):null;C.forEach((H,Y)=>{let X=Y%i,fe=Math.floor(Y/i);if(H===null&&!D.outside)return;if(U&&H!==null&&Iy(I,H)){let de=U(X,fe,pe=>pe<0||C[pe]===null||!Iy(I,C[pe])),ce=t.get(de);if(!ce){p.push(`layer ${q.name}: mix= names '${de}', which is not drawn`);return}if(ce.width!==n||ce.height!==n){p.push(`layer ${q.name}: mix= tile '${de}' is ${ce.width}x${ce.height}, not ${n}x${n}`);return}y(b(ce),ce.width,0,0,n,n,X*n,fe*n),d[Y]={asset:de,variant:I.variants[H].name,edge:!1,...D.outside?{base:!0}:{},...D.walkable?{walkable:!0}:{}},f[Y]=H;return}let ye=x(z,X,fe,Z),W=mt(ye.family),[ee,re]=H===null?W.outside:W.cells[H];if(H!==null&&bi(I.variants[H].on)&&!D.outside)y(v(ye),ye.width,ee*n,re*n,n,n,X*n,fe*n);else if(H!==null&&I.variants[H].on&&!D.outside){let de=So(I,n,ye.family.geometry)[H],ce=b(ye);for(let pe=0;pe<n;pe++)for(let Pe=0;Pe<n;Pe++){if(aS(ye.family.geometry,de[pe*n+Pe]))continue;let Je=ce[(re*n+pe)*ye.width+ee*n+Pe];Je!==65535&&(m[(fe*n+pe)*a+X*n+Pe]=Je)}}else y(b(ye),ye.width,ee*n,re*n,n,n,X*n,fe*n);d[Y]={asset:ye.name,variant:H===null?"outside":I.variants[H].name,edge:H!==null&&!Iy(I,H),...D.outside?{base:!0}:{},...D.walkable?{walkable:!0}:{}},f[Y]=H});return}if(D.kind==="tiles"){for(let z=0;z<V.length;z++){let I=V[z];if(I===65535)continue;let C=o.entries[I],U=z%i,H=Math.floor(z/i),Y=C.exact&&t.get(C.name)?[t.get(C.name)]:_(C.name);if(!Y.length)continue;let X=Wr(C,U,H);if(C.variant){let W=x(Y,U,H,Z),ee=W.family?et(W.family).byName.get(C.variant):void 0;if(ee===void 0){p.push(`${C.name} has no variant '${C.variant}'`);continue}let[re,de]=mt(W.family).cells[ee];y(b(W),W.width,re*n,de*n,n,n,X.x*n,X.y*n),X.x>=0&&X.y>=0&&X.x<i&&X.y<s&&(d[X.y*i+X.x]={asset:W.name,variant:C.variant,edge:!Iy(et(W.family),ee)});continue}let fe=x(Y,U,H,Z),ye=Un(fe);y(b(fe),fe.width,0,0,fe.width,fe.height,(X.x-ye.at[0])*n,(X.y-ye.at[1])*n);for(let W=X.y;W<X.y+X.h;W++)for(let ee=X.x;ee<X.x+X.w;ee++)ee>=0&&W>=0&&ee<i&&W<s&&(d[W*i+ee]={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=lF(e,D),L=u.of(F),A=new Map;for(let z=0;z<M.length;z++){if(!M[z])continue;let I=z%i,C=Math.floor(z/i),U=cS(F,I,C,l);if(U===null)continue;let H=A.get(U)??A.set(U,be(F,U)).get(U);lS(F,U,I,C,n,(Y,X,fe)=>{Y>=0&&X>=0&&Y<a&&X<c&&(m[X*a+Y]=L[fe])},H)}});let R=m.slice();if(!r.groundOnly){for(let q of Br(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?Un(V):{cols:Z.cols,rows:Z.rows,at:[0,0],anchor:Z.anchor,flags:[]},M=Wr(Z,q.x,q.y);S.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}`)}S.sort((q,Z)=>q.base-Z.base||q.layer-Z.layer||q.x-Z.x||q.y-Z.y)}let P=S.filter(q=>q.doc&&e.layers[q.layer].map.shadow);if(P.length){let q=aC(u.entries,[...g].map(Z=>({palette:Z.palette,map:u.of(Z)})));for(let Z of P){let D=e.layers[Z.layer].map.shadow,V=zy(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 Ry(V)){let A=Z.px+M,z=Z.py+L;if(A<0||z<0||A>=a||z>=c)continue;let I=m[z*a+A];I!==65535&&(m[z*a+A]=F<0?q[I]:F)}}}let j=new Int32Array(a*c).fill(-1),N=new Int32Array(a*c).fill(-1),T=(q,Z)=>{let D=S[q];if(!D.doc)return;let V=b(D.doc),[F,M]=Hr(D.doc);for(let L=0;L<M;L++)for(let A=0;A<F;A++)if(!(Z&&!$m(D.fp,A,L).roof))for(let z=0;z<D.doc.cellH;z++)for(let I=0;I<D.doc.cellW;I++){let C=A*D.doc.cellW+I,U=L*D.doc.cellH+z,H=V[U*D.doc.width+C];if(H===65535)continue;let Y=D.px+C,X=D.py+U;Y<0||X<0||Y>=a||X>=c||(m[X*a+Y]=H,(Z?N:j)[X*a+Y]=q)}};return S.forEach((q,Z)=>T(Z,!1)),S.forEach((q,Z)=>T(Z,!0)),{px:m,w:a,h:c,t:n,variants:f,cols:i,rows:s,palette:u.entries,ground:R,top:d,objects:S,roofOwner:N,artOwner:j,problems:p}}function lF(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 uF=e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)];function $i(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=>uF(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 k=((f*r+w)*i+p*r+v)*4;a[k]=y[0],a[k+1]=y[1],a[k+2]=y[2],a[k+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 mF(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 Br(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(dF(c)):c.frameCount>1&&i(sS(c)));return n}var sS=e=>{let t=rr(e)[0];return Math.max(1,or(e,t))},dF=e=>e.overlay.mode==="sparkle"?sS(e)+e.overlay.rest:sS(e);function lC(e,t,r={}){let o=r.tickRate??60,n=mF(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?Ht(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:$i(u,{...r,tick:l}),delay:1}),a=u.px,c=l}}return s.length>1?s:[]}function Py(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 uC(e,t,r=Ht(e,t)){let o=e.map,n=a=>String(Number(a.toFixed(2))),i=zs({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=Br(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 mC(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=Br(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=Wr(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 dC(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 Br(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=Wr(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 fF={seam:1,edgeRun:4,motif:10,window:4,lattice:.3,latticeContrast:18};function pF(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 hF(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 fC(e,t,r={},o=Ht(e,t)){let n={...fF,...r},i=D=>String(Number(D.toFixed(2))),s=[],a=o.cols,c=o.rows,l=zs({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=pF(o),m=new Uint8Array(a*c);for(let D=0;D<c;D++)for(let V=0;V<a;V++)m[D*a+V]=hF(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=Y=>D?[Y,M]:[M,Y],[I,C]=z(L);if(A<F&&f(...z(A))&&u[z(A)[1]*a+z(A)[0]]===u[C*a+I])continue;let H=A-L;if(f(I,C)&&H>n.edgeRun){let Y=o.top[C*a+I];d.push({cells:Array.from({length:H},(X,fe)=>z(L+fe)),name:`${Y.asset}.${Y.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 I=(D+A)*a+V+z;m[I]||!o.top[I]||F.set(u[I],(F.get(u[I])??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 k=new Map;for(let[D,V]of v){let F=o.top[V*a+D],M=`${F.asset}${F.variant?`.${F.variant}`:""}`;k.set(M,(k.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,S=[...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 (${[...k].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:S,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: ${[...k].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(gF(o,t,m,n));let R=[],P=new Map;o.objects.forEach((D,V)=>{let F=e.map.entries[D.entry],M=Wr(F,D.x,D.y),L=[];for(let H=M.y;H<M.y+M.h;H++)for(let Y=M.x;Y<M.x+M.w;Y++)L.push([Y,H]);let A=`${D.name} at ${D.x},${D.y}`;if(!D.doc){R.push({label:`${A}: no such asset`,cells:L});return}let z=L.filter(([H,Y])=>H<0||Y<0||H>=a||Y>=c);z.length&&R.push({label:`${A}: off the map`,cells:L.filter(H=>!z.includes(H))});let I=Un(D.doc);(I.cols!==F.cols||I.rows!==F.rows||I.anchor[0]!==F.anchor[0]||I.anchor[1]!==F.anchor[1])&&R.push({label:`${A}: placed as ${F.cols}x${F.rows} anchor ${F.anchor.join(",")}, its footprint is now ${I.cols}x${I.rows} anchor ${I.anchor.join(",")} (place it again)`,cells:L});let C=[],U=[];for(let[H,Y]of L){if(H<0||Y<0||H>=a||Y>=c)continue;let X=Y*a+H;P.has(X)?C.push([H,Y]):P.set(X,V);let fe=o.top[X];fe?!fe.walkable&&(fe.variant==="outside"||fe.edge&&fe.base)&&U.push([H,Y]):U.push([H,Y])}if(C.length&&R.push({label:`${A}: overlaps ${o.objects[P.get(C[0][1]*a+C[0][0])].name}`,cells:C}),U.length){let H=o.top[U[0][1]*a+U[0][0]];R.push({label:`${A}: stands on ${H?H.variant==="outside"?`${H.asset}'s outside ground`:`the edge tile ${H.asset}.${H.variant}`:"nothing"} (${U.length} of ${L.length} cells)`,cells:U})}}),s.push({id:"footprint",score:R.length,limit:0,pass:R.length===0,shown:String(R.length),limitText:"0",groups:R,detail:R.length?R.slice(0,6).map(D=>D.label).join("; "):`${o.objects.length} objects, every footprint on plain ground`});let j=[],N=o.t;o.objects.forEach((D,V)=>{if(!D.doc)return;let[F,M]=Hr(D.doc),L=be(D.doc,0),A=[];for(let z=0;z<M;z++)for(let I=0;I<F;I++){if(xm(D.fp,I,z)||$m(D.fp,I,z).roof)continue;let C=!1;for(let U=0;U<D.doc.cellH&&!C;U++)for(let H=0;H<D.doc.cellW;H++)if(L[(z*D.doc.cellH+U)*D.doc.width+I*D.doc.cellW+H]!==65535){C=!0;break}C&&A.push([Math.floor(D.px/N)+I,Math.floor(D.py/N)+z])}A.length&&j.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];j.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:j.length,limit:0,pass:j.length===0,shown:String(j.length),limitText:"0",groups:j,detail:j.length?j.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 gF(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=>yC(z.hex)),d=z=>{let I=z;for(let C=0;C<8;C++){let U=t.get(I)?.variantOf;if(!U||!t.get(U))break;I=U}return I},f=Array.from({length:i*s},()=>null),p=Array.from({length:i*s},()=>null),h=new Int32Array(a),g=z=>z.sort((I,C)=>I-C)[z.length>>1];for(let z=0;z<s;z++)for(let I=0;I<i;I++){let C=z*i+I,U=e.top[C];if(!U||U.edge||r[C])continue;let H=[],Y=[],X=[];for(let de=0;de<n;de++)for(let ce=0;ce<n;ce++){let pe=e.ground[(z*n+de)*e.w+I*n+ce];if(h[de*n+ce]=pe===65535?-1:pe,pe!==65535){let Pe=m[pe];H.push(Pe[0]),Y.push(Pe[1]),X.push(Pe[2])}}if(H.length<a*.9)continue;let fe=[g(H),g(Y),g(X)],ye=new Uint8Array(a);for(let de=0;de<a;de++){if(h[de]<0)continue;let ce=m[h[de]];Math.hypot(ce[0]-fe[0],ce[1]-fe[1],ce[2]-fe[2])>=o.latticeContrast&&(ye[de]=1)}let W=[],ee=new Uint8Array(a);for(let de=0;de<a;de++){if(!ye[de]||ee[de])continue;let ce=[de];ee[de]=1;let pe=n,Pe=n,Je=-1,Ze=-1,Ye=0,Qe=0;for(let Ct=0;Ct<ce.length;Ct++){let vt=ce[Ct],bn=vt%n,Gt=vt/n|0;pe=Math.min(pe,bn),Je=Math.max(Je,bn),Pe=Math.min(Pe,Gt),Ze=Math.max(Ze,Gt),Ye+=bn,Qe+=Gt;for(let On=-1;On<=1;On++)for(let Wn=-1;Wn<=1;Wn++){let Bn=bn+Wn,dr=Gt+On;if(Bn<0||dr<0||Bn>=n||dr>=n)continue;let Hn=dr*n+Bn;ye[Hn]&&!ee[Hn]&&(ee[Hn]=1,ce.push(Hn))}}ce.length<c||Je-pe+1>u||Ze-Pe+1>u||W.push({at:Math.floor(Qe/ce.length)*n+Math.floor(Ye/ce.length),weight:ce.length,pts:ce})}if(f[C]=`${d(U.asset)}.${U.variant??""}`,!W.length)continue;let re=W.reduce((de,ce)=>de+ce.weight,0);for(let de of W)de.weight/=re;p[C]=W}let b=z=>{let I=new Float64Array(a);for(let C of z){let U=C.at%n,H=C.at/n|0;for(let Y=-l;Y<=l;Y++)for(let X=-l;X<=l;X++){let fe=U+X,ye=H+Y;fe>=0&&ye>=0&&fe<n&&ye<n&&(I[ye*n+fe]=Math.max(I[ye*n+fe],C.weight))}}return I},y=new Map;for(let z=0;z<f.length;z++){let I=f[z];if(!I)continue;let C=y.get(I);if(C||y.set(I,C={cells:0,shown:new Float64Array(a),count:new Int32Array(a)}),C.cells++,!p[z])continue;let U=b(p[z]);for(let H=0;H<a;H++)U[H]>0&&(C.shown[H]+=U[H],C.count[H]++)}let w=8,v=null;for(let[z,I]of y){if(I.cells<w)continue;let C=0;for(let H=1;H<a;H++)I.shown[H]>I.shown[C]&&(C=H);let U=I.shown[C]/I.cells;(!v||U>v.share)&&(v={ground:z,share:U,n:I.count[C],cells:I.cells,at:C})}let k=z=>`${Math.round(z*100)}%`,_=`\u2264 ${k(o.lattice)}`,$={id:"lattice",limit:o.lattice,limitText:_};if(!v||v.n===0){let z=[...y.values()].reduce((I,C)=>I+(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=[],S=new Map,R=new Int32Array(a),P=v.at%n,j=v.at/n|0;for(let z=0;z<f.length;z++){if(f[z]!==v.ground||!p[z])continue;let I=p[z].filter(U=>Math.abs(U.at%n-P)<=l&&Math.abs((U.at/n|0)-j)<=l);if(!I.length)continue;x.push([z%i,Math.floor(z/i)]);let C=e.top[z].asset;S.set(C,(S.get(C)??0)+1);for(let U of I)for(let H of U.pts)R[H]++}let N=n,T=n,q=-1,Z=-1,D=R.reduce((z,I)=>Math.max(z,I),0);for(let z=0;z<a;z++)if(R[z]>=D*.75){let I=z%n,C=z/n|0;N=Math.min(N,I),q=Math.max(q,I),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 ${k(v.share*v.cells/v.n)} of their marking, on average)`:"",A=`a mark at ${M} of the cell (${[...S].map(([z,I])=>`${z} \xD7${I}`).join(", ")}) comes back on the tile pitch`;return{...$,score:Number(v.share.toFixed(3)),pass:F,shown:k(v.share),groups:F?[]:[{label:A,cells:x}],detail:`${F?`the mark most often at one spot: at ${M} of the cell (${[...S].map(([z,I])=>`${z} \xD7${I}`).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 pC(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+=Zr(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 hC(e,t=0){let[r,o]=Hr(e),n=Un(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,...$m(n,a.cx,a.cy),footprint:xm(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 gC(e,t,r,o=2){let n=Ht(t,r),i=e?.map&&e.width===t.width&&e.height===t.height?Ht(e,r):null,s=n.t,a=n.cols,c=n.rows,l=[];for(let P=0;P<c;P++)for(let j=0;j<a;j++){let N=!i;for(let T=0;T<s&&!N;T++)for(let q=0;q<s;q++){let Z=(P*s+T)*n.w+j*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([j,P])}let u=(P,j)=>{let N=P.map.entries[j.entry];return`${P.layers[j.layer].name}|${N.name}${N.variant?`.${N.variant}`:""}`},m=e?.map?Br(e).map(P=>({k:u(e,P),p:P})):[],d=Br(t).map(P=>({k:u(t,P),p:P})),f=m.filter(P=>!d.some(j=>j.k===P.k&&j.p.x===P.p.x&&j.p.y===P.p.y)),p=d.filter(P=>!m.some(j=>j.k===P.k&&j.p.x===P.p.x&&j.p.y===P.p.y)),h=[];for(let P of[...f]){let j=p.findIndex(T=>T.k===P.k);if(j<0)continue;let N=p[j];h.push(`moved: ${P.k.split("|")[1]} ${P.p.x},${P.p.y} \u2192 ${N.p.x},${N.p.y} (layer ${P.k.split("|")[0]})`),p.splice(j,1),f.splice(f.indexOf(P),1)}for(let P of f)h.push(`taken away: ${P.k.split("|")[1]} at ${P.p.x},${P.p.y} (layer ${P.k.split("|")[0]})`);for(let P of p)h.push(`placed: ${P.k.split("|")[1]} at ${P.p.x},${P.p.y} (layer ${P.k.split("|")[0]})`);t.layers.forEach((P,j)=>{if(P.map?.kind!=="terrain"||!e?.map)return;let N=e.layers.findIndex(V=>V.name===P.name);if(N<0){h.push(`terrain layer ${P.name} added`);return}let T=t.cels[j][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 ${P.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(P=>P[0]),y=l.map(P=>P[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},k=$i(n,{scale:o,region:v,marks:l}),_=i?$i(i,{scale:o,region:v,marks:l}):null,$=8,x=k.width*2+$,S=k.height,R=new Uint8Array(x*S*4);for(let P=0;P<S;P++)for(let j=0;j<x;j++){let N=(P*x+j)*4,T=j<k.width?_:j>=k.width+$?k:null,q=j<k.width?j:j-k.width-$;if(!T){R[N]=30,R[N+1]=31,R[N+2]=36,R[N+3]=255;continue}let Z=(P*k.width+q)*4;R[N]=T.data[Z],R[N+1]=T.data[Z+1],R[N+2]=T.data[Z+2],R[N+3]=255}return{cells:l,text:g,img:{width:x,height:S,data:R}}}function jy(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 uS(e,t){let r=Math.floor(e/t);return r*t>e?r--:(r+1)*t<=e&&r++,r}function _m(e){let t=Math.floor(Math.sqrt(e));for(;t*t>e;)t--;for(;(t+1)*(t+1)<=e;)t++;return t}function Rs(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 Mt(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 zc(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 Ey(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 xi(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 km(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 js=[30,31,36],bC=[120,126,136],zm=[216,219,224],Es=[204,204,204],Rc=[238,238,238],wC=[255,79,216],_i=[255,0,200],yF=[[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 vC(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 Rm(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 bF={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 Jr(e,t,r,o,n,i){for(let s of o){let a=yF[s.charCodeAt(0)-48]??bF[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 Is=(e,t)=>e.length*4*t-t;function _C(e,t,r,o,n,i=1){return Jr(e,t,r,o,n,i),Is(o,i)}function Gr(e,t){return Qk(e.palette,t).entries.map(r=>it(r.hex))}function Im(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,_i);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,_i)}}}function ki(e,t=0,r){let o=be(e,t),n=Gr(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 kC(e){return Math.max(1,Math.min(16,Math.floor(192/Math.max(e.width,e.height))))}function SC(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 $C(e,t){return[e[0]+t[0]>>1,e[1]+t[1]>>1,e[2]+t[2]>>1]}function Oy(e,t={}){let r=t.scale??kC(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+Is("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,js);let g=be(e,t.frame??0),b=kT(e,t.frame??0),y=t.underlay??null,w=Gr(e,t.theme),v=Math.max(2,r>>1),k=e.width*r,_=e.height*r;for(let x=0;x<l;x++)for(let S=0;S<c;S++){let R=s+S,P=a+x,j=g[P*e.width+R],N=b?b[P*e.width+R]:65535;for(let T=0;T<r;T++)for(let q=0;q<r;q++){let Z;if(j!==65535)Z=w[j];else if(Z=(((R*r+q)/v|0)+((P*r+T)/v|0))%2?Es:Rc,N!==65535)Z=$C(w[N],Z);else if(y){let D=(Math.floor((P*r+T)*y.height/_)*y.width+Math.floor((R*r+q)*y.width/k))*4;y.data[D+3]>=128&&(Z=$C([y.data[D],y.data[D+1],y.data[D+2]],Z))}ht(h,d+S*r+q,m+x*r+T,Z)}}if(o){for(let x=0;x<=c;x++){let S=(s+x)%8===0?80:30;for(let R=0;R<p;R++)vC(h,d+x*r,m+R,S)}for(let x=0;x<=l;x++){let S=(a+x)%8===0?80:30;for(let R=0;R<f+1;R++)(R%r!==0||R===f)&&vC(h,d+R,m+x*r,S)}}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 S=0;S<p;S++)Rm(h,d+(x-s)*r,m+S,wC,180);for(let x=e.cellH;x<e.height;x+=e.cellH)if(x>a&&x<a+l)for(let S=0;S<f;S++)Rm(h,d+S,m+(x-a)*r,wC,180)}if(t.marks?.length){let x=t.marks.filter(([S,R])=>S>=s&&R>=a&&S<s+c&&R<a+l).map(([S,R])=>[S-s,R-a]);x.length&&Im(h,d,m,r,x,c,l)}if(n){for(let x=0;x<=c;x++){let S=s+x,R=S%8===0;!R&&r<4||(gn(h,d+x*r,m-(R?6:3),1,R?6:3,R?zm:bC),R&&x<c&&Jr(h,d+x*r+2,2,String(S),zm,i))}for(let x=0;x<=l;x++){let S=a+x,R=S%8===0;if(!(!R&&r<4)&&(gn(h,d-(R?6:3),m+x*r,R?6:3,1,R?zm:bC),R&&x<l)){let P=String(S);Jr(h,d-8-Is(P,i),m+x*r+2,P,zm,i)}}}return h}function Ny(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,js);let c=be(e,t),l=Gr(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 k=0;k<f;k++)for(let _=0;_<f;_++){let $=y===65535?((w+_>>2)+(v+k>>2))%2?Es:Rc:l[y];ht(a,m+w+_,d+v+k,$)}}};return u(8,8,1),u(8+3*n+8,8,s),r.marks?.length&&Im(a,8+3*n+8+s*n,8+s*i,s,r.marks,n,i),a}function zC(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=Et(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 Pm(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 Ty=[255,214,10];function My(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 RC(e,t,r={}){let o=Pm(e,t),n=r.scale??kC(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?Is(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,js);let b=(w,v,k,_,$)=>{let x=v<w.frameCount?be(w,v):new Uint16Array(w.width*w.height).fill(65535),S=Gr(w),R=Math.max(2,n>>1);for(let P=0;P<w.height;P++)for(let j=0;j<w.width;j++){let N=x[P*w.width+j];for(let T=0;T<n;T++)for(let q=0;q<n;q++){let Z=N===65535?(((j*n+q)/R|0)+((P*n+T)/R|0))%2?Es:Rc:S[N];ht(g,k+j*n+q,_+P*n+T,Z),$&&Rm(g,k+j*n+q,_+P*n+T,js,190)}}},y=(w,v,k,_,$,x)=>{for(let S of o){if(S.f!==w||S.x>=_||S.y>=$)continue;let R=v+S.x*n,P=k+S.y*n;if(x||n<4){for(let N=0;N<n;N++)for(let T=0;T<n;T++)x?ht(g,R+T,P+N,_i):Rm(g,R+T,P+N,_i,150);continue}let j=n>=8?2:1;for(let N=0;N<n;N++)for(let T=0;T<j;T++)ht(g,R+N,P+T,_i),ht(g,R+N,P+n-1-T,_i),ht(g,R+T,P+N,_i),ht(g,R+n-1-T,P+N,_i)}};return f.forEach((w,v)=>{let k=i+v*h;m&&Jr(g,i,k+2,String(w+1),zm,2);let _=p+i;e&&(b(e,w,_,k,!1),y(w,_,k,e.width,e.height,!1));let $=_+c+i;b(t,w,$,k,!1),y(w,$,k,t.width,t.height,!1);for(let x of t.notes){let S=Math.max($,$+x.x*n-1),R=Math.max(k,k+x.y*n-1),P=Math.min($+s-1,$+(x.x+x.w)*n),j=Math.min(k+a-1,k+(x.y+x.h)*n);for(let N=S;N<=P;N++)(N-S>>1)%2===0&&(ht(g,N,R,Ty),ht(g,N,j,Ty));for(let N=R;N<=j;N++)(N-R>>1)%2===0&&(ht(g,S,N,Ty),ht(g,P,N,Ty))}if(u===3){let x=$+s+i;b(t,w,x,k,!0),y(w,x,k,t.width,t.height,!0)}}),g}var wF=[88,94,102];function jm(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?Gr(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?wF: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=Gr(b.doc,t.theme),v=n+i-b.doc.height;for(let k=0;k<b.doc.height;k++)for(let _=0;_<b.doc.width;_++){let $=y[k*b.doc.width+_];$!==65535&&(c[(v+k)*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,js);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 k=0;k<r;k++)ht(g,f+y*r+k,f+h+b*r+v,w)}return t.marks?.length&&e[0]&&Im(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/Bt.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,js);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=Gr(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 k=y===65535?(((b*o+v)/m|0)+((g*o+w)/m|0))%2?Es:Rc:h[y];ht(l,p+b*o+v,n+g*o+w,k)}}Bt.forEach((g,b)=>gn(l,p+b*a,n+s+4,a,6,it(d.colours[g])))}),l}var Sm=[64,220,230],vF=[255,110,70],PC=[58,60,68],xC=[216,219,224],Cy=[150,156,166],jC=e=>`${Math.round(e*100)}%`;function EC(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 TC=(e,t)=>t.scale??Math.max(2,Math.min(8,Math.floor(96/Math.max(e.width,e.height))));function mS(e,t){let r=rr(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 $F(e,t){let r=Fr(e);if(r.length<2)return null;let o=r.indexOf(e.frames[t]);return r[(o-1+r.length)%r.length]}function Dy(e,t={}){let r=TC(e,t),o=mS(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(Is(h.name,a),Is(h.mirror?"MIRROR":h.loop,a),Is(`${or(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,js);let f=Gr(e,t.theme),p=Math.max(2,r>>1);return o.forEach((h,g)=>{let b=s+g*m;Jr(d,s,b+c,h.name,xC,a),Jr(d,s,b+c*2,h.mirror?"MIRROR":h.loop,Cy,a),Jr(d,s,b+c*3,`${or(e,h)}T`,Cy,a),h.frames.forEach((y,w)=>{let v=s+l+w*(n+s);Jr(d,v,b,`${y+1} ${e.ticks[y]}T`,xC,a);let k=be(e,y),_=$F(h,w),$=_!==null&&_!==y?be(e,_):null;for(let x=0;x<e.height;x++)for(let S=0;S<e.width;S++){let R=x*e.width+S,P=k[R];for(let j=0;j<r;j++)for(let N=0;N<r;N++){let T=v+S*r+N,q=b+c+x*r+j;if(P!==65535){ht(d,T,q,f[P]);continue}ht(d,T,q,(((S*r+N)/p|0)+((x*r+j)/p|0))%2?Es:Rc),$&&$[R]!==65535&&Rm(d,T,q,vF,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,Sm);if(!e.wrap&&e.pivot){let[x,S]=e.pivot,R=v+x*r,P=b+c+S*r;for(let j=-1;j<=r;j++)ht(d,R+j,P-1,Sm),ht(d,R+j,P+r,Sm),ht(d,R-1,P+j,Sm),ht(d,R+r,P+j,Sm)}_!==null&&_!==y&&Jr(d,v,b+c+i+4,`${_+1}>${y+1} ${jC(EC(e,_,y))}`,Cy,a)})}),d}function CC(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 mS(e,t)){let i=or(e,n),s=Fr(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} ${jC(EC(e,l,u))}`).join(", ")}`:""))}return o.join(`
129
+ `)}function qy(e,t={}){let r=t.scale??(e.wrap?Math.max(1,Math.min(4,Math.floor(72/e.width))):TC(e,t)),o=t.tickRate??60,n=mS(e,t),i=e.wrap?3:1,s=e.width*r*i,a=e.height*r*i,c=8,l=Gr(e,t.theme),u=(b,y)=>y?u(y,b%y):b,m=1;for(let b of n){let y=Math.max(1,or(e,b));m=Math.min(o*60,m/u(m,y)*y)}let d=new Set([0]);for(let b of n){let y=Fr(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,PC),n.forEach((k,_)=>{let $=g(Vr(e,k,b)),x=c+_*(s+c);for(let S=0;S<e.height*i;S++)for(let R=0;R<e.width*i;R++){let P=$[S%e.height*e.width+R%e.width];P!==65535&&gn(v,x+R*r,c+S*r,r,r,l[P])}}),{img:v,delay:Math.max(1,f(w)-f(b))}})}function Ay(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=Qk(o.palette,t.theme).entries.map(l=>({name:l.name,hex:l.hex})),s=n.map(l=>DC(l,i)),a,c=null;if(o.family){let l=et(o.family),u=t.cols??t.terrain?.cols??Ps.cols,m=t.rows??t.terrain?.rows??Ps.rows;c=t.terrain??Si(l,u,m,t.seed??Ps.seed),a=zo(o,c,t.frame??UC(o,r))}else{let l=o.width;a=NC(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?Vr(o,rr(o)[0],r):0))}return MC(a,s,r,o.family?o:null),{base:o,img:a,colours:i.map(l=>it(l.hex)),overlays:s,terrain:c}}function AC(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?Es:Rc:e.colours[s])}return o}function Uy(e,t={}){return AC(Ay(e,t,t.tick??0),t.scale??2)}function OC(e,t={}){let r=Ay(e,t,t.tick??0),{img:o,base:n}=r,i={...o,px:o.px.slice()};n.family&&!t.terrain&&Vy(i,n,0);let s=zs(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??Ps.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=et(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 Ly(e,t={}){let r=t.tickRate??60,o=Ay(e,t,0),n=qC(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?Ay(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:AC(m,i),delay:1}),c=m.img.px,l=u}}return a}function xF(e,t,r={}){let o=e.family,n=et(o),i=o.tile,s=r.frame??0,a=Gr(e,r.theme),c=dS(n,t),l=zo(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?Es: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 Fy(e,t={}){let r=e.family,o=et(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,PC);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);Jr(d,b,y,h.name.length>l/4?h.name.slice(0,Math.floor(l/4)):h.name,f.has(h.name)?_F:p.has(h.name)?kF:Cy,1);let w=xF(e,g,t);for(let v=0;v<w.height;v++)for(let k=0;k<w.width;k++){let _=(v*w.width+k)*4;gn(d,b+k*i,y+c+v*i,i,i,[w.data[_],w.data[_+1],w.data[_+2]])}}),d}var _F=[120,220,230],kF=[240,190,90];var LC=e=>{let[t,r,o]=it(e);return 299*t+587*r+114*o};function FC(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=LC(t.entries[i].hex),c=LC(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)=>FC(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:FC(e,r)}]]);function pS(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 Em(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 Zy(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 hS(e,t,r,o="mode",n={},i=0){let s=Math.min(i,t.frameCount-1),a=pS(be(t,s),t.width,t.height,r,t.palette,o,n),c=Zy(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 fS=[40,42,48];function ZC(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:ki(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=hS(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:ki(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([fS[0],fS[1],fS[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&&Im(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 Pn=["palette","orphans","jaggies","banding","outline","seam","coverage","readability","revert","repetition","lattice","anim","views","fit","variant","footprint","draworder","density","consistency","font","margin","pieces"];function Hy(e){return Pn.includes(e)}function GC(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 By={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 Tm(e,t,r,o){let n=By[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 ko(e){let[t,r,o]=it(e);return .299*t+.587*r+.114*o}function Zr(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 yC(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 SF(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 In=[[1,0],[0,1],[-1,0],[0,-1]],Cs=[[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}),Ts=e=>e.wrap||e.kind==="family"||e.kind==="overlay";function zF(e,t,r){let o=e.doc.palette,n=e.doc.kind==="icon"?wc(e.doc):null,i=DT(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 KC(e,t,r){let o=1/0;for(let n of km(e,t)){let i=n.ramp.indexOf(r);i>=0&&(o=Math.min(o,Math.abs(i-n.at)))}return o}function RF(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 Cs){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 IF(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(In.some(([h,g])=>e.get(d+h,f+g)===m))continue;let p=RF(e,u,3);if(!(p>2)){if(t.texture){let h=new Map;for(let[b,y]of In){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&&KC(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 PF(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 WC(e,t,r){let o=e.get(t,r);return Cs.filter(([n,i])=>e.get(t+n,r+i)===o).map(([n,i])=>[t+n,r+i])}var Cm=(e,t)=>e[0]===t[0]&&e[1]===t[1];function BC(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?Cm(a,m):f(m,c):p=c?Cm(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 jF(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 Cs){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(Cm(u,s)&&l.length>1&&Cm(g,l[1]))break;m=c(h[0]-p[0],h[1]-p[1]),u=g,l.push(u)}l.length>1&&Cm(l[l.length-1],s)&&l.pop(),r.push(l)}return r}function EF(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]=WC(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=WC(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 yS(e,t,r,o){return t!==65535&&r!==65535&&!o.has(t)&&!o.has(r)&&KC(e.doc.palette,t,r)===1}function TF(e,t,r,o){let n=e.get(t,r),i=!1;for(let[s,a]of Cs){let c=e.get(t+s,r+a);if(!(c===n||o.has(c)&&!o.has(n))){if(!yS(e,n,c,o))return!1;i=!0}}return i}function CF(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=bS(e,r.style),n=0,i=Ts(e.doc)?PF(e.px):-1,s=[];for(let k=0;k<e.px.length;k++){let _=e.px[k];if(_===65535||_===i)continue;let[$,x]=nn(e,k),S=In.filter(([q,Z])=>e.get($+q,x+Z)===_);if(S.length!==2)continue;let R=S.find(([,q])=>q===0),P=S.find(([q])=>q===0);if(!R||!P||e.get($+R[0]+P[0],x+P[1])===_)continue;let j=e.get($+P[0]-R[0],x+P[1])===_||e.get($+R[0],x-P[1])===_,N=e.get($+R[0],x+P[1]),T=!o.has(_)&&In.every(([q,Z])=>e.get($+q,x+Z)!==65535);j&&T&&(yS(e,_,N,o)||o.has(N)&&Cs.some(([q,Z])=>yS(e,_,e.get($+q,x+Z),o)))?n++:j&&s.push([$,x])}let a=0;{let k=$=>e.at($[0],$[1]),_=new Set(s.map(k));for(let $ of s){if(!_.has(k($)))continue;a++;let x=[$];for(_.delete(k($));x.length;){let[S,R]=x.pop();for(let[P,j]of In){let N=e.at(S+P,R+j);_.has(N)&&(_.delete(N),x.push(nn(e,N)))}}}}let c=new Map,l=k=>{for(let _ of k)c.set(_.map($=>e.at($[0],$[1])).sort(($,x)=>$-x).join(","),_)};for(let k of EF(e,6))if(e.get(k[0][0],k[0][1])!==i){if(k.every(([_,$])=>TF(e,_,$,o))){n++;continue}l(BC(k,e.w,e.h,e.wrap))}if(!Ts(e.doc))for(let k of jF(e))l(BC(k,e.w,e.h,!1));let u=[...c.values()].flat(),m=[],d=[];if(!Ts(e.doc)){let k=(_,$)=>e.get(_,$)!==65535;for(let _=0;_<e.h;_++)for(let $=0;$<e.w;$++){let x=In.filter(([S,R])=>k($+S,_+R));if(k($,_)){if(x.length!==1)continue;let[S,R]=[$+x[0][0],_+x[0][1]],P=In.filter(([N,T])=>k(S+N,R+T)).length,j=Cs.filter(([N,T])=>k($+N,_+T)).length;P>=3&&j<=3&&m.push([$,_])}else if(x.length===4)d.push([$,_]);else if(x.length===3){let S=In.find(([R,P])=>!k($+R,_+P));k($-2*S[0],_-2*S[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 AF(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);In.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 In){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 bS(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||ko(r.entries[s].hex)<ko(r.entries[i].hex))&&(i=s);return new Set(i>=0?[i]:[])}function OF(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 NF(e,t,r){if(Ts(e.doc))return ct("banding","tiles have no silhouette to band along");let o=e.doc.palette,n=AF(e),i=bS(e,r.style),s=o.entries.map(y=>ko(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,k]=nn(e,y);In.forEach(([_,$],x)=>{let S=e.at(v+_,k+$);if(S<0)return;let R=e.px[S];if(R===65535||R===w||i.has(R)||n[S]!==n[y]+1)return;let P=a?OF(o,w,R):0;if(P<0)return;let j=Math.sign(s[R]-s[w]);if(!j)return;l.has(P)||l.set(P,{count:In.map(()=>[0,0]),edges:[]});let N=l.get(P);N.count[x][j>0?0:1]++,N.edges.push({p:[v,k],sign:j})})}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),k=Math.sign(v[0]),_=k!==0&&v.every($=>Math.sign($)===k)?Math.min(...v.map(Math.abs)):0;(_>f.score||f.ramp<0)&&(f={score:_,ramp:y,sign:k,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 XC(e){let t=[];for(let r=0;r<e.px.length;r++){if(e.px[r]===65535)continue;let[o,n]=nn(e,r);In.some(([i,s])=>e.get(o+i,n+s)===65535)&&t.push(r)}return t}function MF(e,t,r){if(Ts(e.doc))return ct("outline","tiles have no silhouette");let o=XC(e);if(!o.length)return ct("outline","nothing drawn");let n=bS(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 Ic=e=>e.length?e.reduce((t,r)=>t+r,0)/e.length:0,HC=e=>{let t=Ic(e);return Math.sqrt(Ic(e.map(r=>(r-t)*(r-t))))};function Am(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=(Ic(a)-Ic(c))/(HC(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(Ic(d)-Ic(f))/(HC(f)+2);return{jump:l,line:p}}function DF(e,t=0){let r=be(e,t),{width:o,height:n}=e,i=e.palette.entries.map(p=>ko(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=Am(c,l,s,a,o),f=Am(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 qF(e,t,r){if(e.doc.family){let c=e.doc,{cols:l,rows:u,seed:m}=Ps,d=zo(c,Si(et(c.family),l,u,m),r.frame??0),f=Vy(d,c,r.frame??0),p=zs(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=DF(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 UF(e,t){let r=e.family,o=et(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 LF(e,t,r){let o=e.doc;if(o.family)return UF(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 FF(e,t,r){if(Ts(e.doc))return ct("readability","tiles are ground, not figures");let n=e.doc.palette.entries.map(y=>Zr(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=>Zr(x.hex)),v=(x,S)=>{let R=y[(S%u.height+u.height)%u.height*u.width+(x%u.width+u.width)%u.width];return R===65535?null:w[R]},k=[],_=0;for(let x of XC(e)){let[S,R]=nn(e,x),P=-1;for(let[j,N]of In){if(e.get(S+j,R+N)!==65535)continue;let T=v(S+j,R+N);T!==null&&(P=Math.max(P,Math.abs(n[e.px[x]]-T)))}P<0||(_++,P<l&&k.push([S,R]))}c=_?1-k.length/_:1;let $=Number(t.min);s.push({name:"edge contrast",value:c,limit:`\u2265 ${$}`,pass:c>=$,detail:`${_-k.length} of ${_} edge px differ from '${u.name}' by \u0394L* \u2265 ${l}`}),k.length&&a.push({label:`edge too close to the ground '${u.name}' (\u0394L* < ${l})`,pts:k})}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=>!wm(y.doc,e.doc)&&!wm(e.doc,y.doc));if(d.length){let y=e.px.map(k=>k===65535?0:1),w={name:"",iou:0};for(let k of d){let _=be(k.doc,Math.min(r.frame??0,k.doc.frameCount-1)),$=0,x=0;for(let R=0;R<_.length;R++){let P=y[R],j=_[R]!==65535?1:0;P&&j&&$++,(P||j)&&x++}let S=x?$/x:0;(S>w.iou||!w.name)&&(w={name:k.name,iou:S})}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(k=>!d.includes(k)).map(k=>k.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 VF(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 ZF(e,t=0,r=By.repetition.all.contrast,o=By.repetition.all.max){let n=be(e,t),{width:i,height:s}=e,a=e.palette.entries.map(d=>Zr(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 P=0;P<b;P++){let j=(w+P)%f;for(let N=0;N<p;N++)y[N]+=h(j,N)}let v=0;for(let P=0;P<p;P++)v+=y[P]/=b;v/=p;let k=0;for(let P=0;P<p;P++)k+=(y[P]-v)**2;let _=Math.sqrt(k/p),$=v-l,x=Math.abs($)*Math.sqrt(b/g),S=Math.max(o,r*_*Math.sqrt(b/g/p)),R=x/S;R>m+1e-9&&(m=R,u={score:x,axis:d,from:w,width:b,delta:$,spread:_,limit:S})}if(f<4)break}}return u}function WF(e,t,r){if(!e.wrap)return ct("repetition","not a wrap (tile) document");let o=Number(t.max),n=ZF(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 k=0;k<a;k++){let _=(n.from+v)%s;c.push(n.axis==="rows"?[k,_]:[_,k])}let l=new Map;for(let v of e.px)l.set(v,(l.get(v)??0)+1);let u=[...l].sort((v,k)=>k[1]-v[1]||v[0]-k[0])[0][0],m=v=>v===65535?0:Zr(e.doc.palette.entries[v].hex),d=c.filter(([v,k])=>{let _=e.get(v,k);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 Tt=e=>`${Ke(e*100,1)}%`;function BF(e,t){let r=e.doc;if(r.frameCount<2)return ct("anim","one frame");let o=rr(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=Ts(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,k="";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 I=s(L),C=s(A),U=0,H=0;for(let X=0;X<I.length;X++)(I[X]!==65535||C[X]!==65535)&&H++,I[X]!==C[X]&&U++;let Y=H?U/H:0;if(h.push({s:N.name,a:L,b:A,v:Y,seam:z}),Y<l||Y>u){let X=Y<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}: ${Tt(Y)} of the pixels change; ${X}`,pts:c(A,fe=>I[fe]!==C[fe]),frame:A})}if(!n){let X=a(L),fe=a(A),ye=Math.max(X,fe)?Math.abs(X-fe)/Math.max(X,fe):0;ye>v&&(v=ye,k=`${N.name} ${L+1}\u2192${A+1}`),ye>f&&p.push({label:`${N.name} ${L+1}\u2192${A+1}: the silhouette ${fe>X?"grows":"shrinks"} by ${Tt(ye)}`,pts:c(A,W=>I[W]===65535!=(C[W]===65535)),frame:A})}}if(n)continue;let Z=T.map(L=>{let A=0,z=0;return s(L).forEach((I,C)=>{I!==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 I=0;I<r.width;I++)if(A[z*r.width+I]!==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((I,C,U)=>Math.abs(C-V)>Math.abs(Z[I]-V)?U:I,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],I=>A[I]!==65535&&z[I]===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 I=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]&&I[C]!==65535),frame:L})}})}let _=h.filter(N=>!N.seam),$=Math.min(..._.map(N=>N.v)),x=Math.max(..._.map(N=>N.v)),S=h.filter(N=>N.seam),R=[{name:"frame diff",value:x,limit:`${Tt(l)}\u2013${Tt(u)}`,pass:$>=l&&x<=u,detail:`pairs change ${Tt($)}..${Tt(x)} of their pixels`}];if(S.length){let N=S.filter(q=>q.v<l||q.v>u),T=N[0]??S[0];R.push({name:"loop seam",value:T.v,limit:`${Tt(l)}\u2013${Tt(u)}`,pass:!N.length,detail:`${T.s} ${T.a+1}\u2192${T.b+1} changes ${Tt(T.v)}`})}n||(R.push({name:"pivot drift",value:g,limit:`\u2264 ${m} px`,pass:g<=m,detail:`${Ke(g,1)} px${b?` (${b})`:""}`}),R.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"}`}),R.push({name:"area jump",value:v,limit:`\u2264 ${Tt(f)}`,pass:v<=f,detail:`${Tt(v)}${k?` (${k})`:""}`}));let P=h.reduce((N,T)=>Math.max(l-T.v,T.v-u)>Math.max(l-N.v,N.v-u)?T:N,h[0]),j=R.some(N=>!N.pass);return at("anim",{status:j?"fail":"pass",score:P.v,shown:Tt(P.v),limit:`${Tt(l)}\u2013${Tt(u)}`,groups:p,parts:R,detail:`${o.map(N=>N.name).join(", ")}: `+R.map(N=>`${N.name} ${N.detail}${N.pass?"":` (limit ${N.limit})`}`).join("; ")})}function HF(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(pm(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:Tt(s.v),limit:`\u2265 ${Tt(n)}`,detail:i.map(a=>`${a.a}/${a.b} differ by ${Tt(a.v)}`).join(", ")+(s.v<n?`; ${s.a} and ${s.b} look too alike`:"")})}function JF(e,t){let r=e.doc,[o,n]=Hr(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]);xm(i,m,u)&&!d.length&&s.push({label:`footprint cell ${m},${u} is empty`,pts:a(m,u)}),!xm(i,m,u)&&d.length&&!$m(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 GF(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=pC(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 KF(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=hS(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:Tt(c.share),limit:`\u2264 ${Tt(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 (${Tt(c.share)})`})}var gS=e=>()=>ct(e,"a map check (on map documents)");function XF(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=nS(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 YF(e,t){let r=e.doc;if(!r.font)return ct("font","not a glyph sheet");let o=r.font,n=py(r),i=[],s=[],a=(_,$)=>{let x=[];for(let S=0;S<r.cellW;S++)e.get(_.cell[0]+S,_.cell[1]+$)!==65535&&x.push([_.cell[0]+S,_.cell[1]+$]);return x},c=_=>{let $=new Map;for(let x of _)$.set(x,($.get(x)??0)+1);return[...$].sort((x,S)=>S[1]-x[1]||S[0]-x[0])[0]?.[0]},l=(_,$)=>{let x=n.filter(j=>j.box&&_.includes(String.fromCodePoint(j.cp)));if(x.length<2)return null;let S=x.map(j=>o.baseline-j.box[1]+1),R=c(S),P=x.filter((j,N)=>S[N]!==R);return P.length&&(s.push(`${$} ${R}: ${P.map(j=>`${wo(j.cp)} ${o.baseline-j.box[1]+1}`).join(", ")}`),i.push({label:`${$} is not ${R}`,pts:P.flatMap(j=>a(j,j.box[1]))})),R},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(_=>`${wo(_.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(_=>`${wo(_.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 S=Math.max(_.advance,0);S<r.cellW;S++)e.get(_.cell[0]+S,_.cell[1]+x)!==65535&&$.push([_.cell[0]+S,_.cell[1]+x]);return $})}));let h=n.filter(_=>!_.box&&!/\s/u.test(String.fromCodePoint(_.cp)));h.length&&(s.push(`not drawn: ${h.map(_=>wo(_.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),k=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${k?`, ${k} empty`:""}; cap height ${u??"\u2014"}, x-height ${m??"\u2014"}, baseline row ${o.baseline}, line ${o.line}${y>0?` of at most ${y}`:""})`})}function YC(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 QF(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 YC(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 eV(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 YC(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 Cs){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 Wy={palette:zF,orphans:IF,jaggies:CF,banding:NF,outline:MF,seam:qF,coverage:LF,readability:FF,revert:VF,repetition:WF,anim:BF,views:HF,fit:JF,variant:GF,footprint:gS("footprint"),lattice:gS("lattice"),draworder:gS("draworder"),density:KF,consistency:XF,font:YF,margin:QF,pieces:eV},tV=new Set(["font","consistency","coverage","anim","views","footprint","draworder","lattice"]);function nV(e,t,r){let o=Br(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=nS(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 rV(e,t,r){if(!r.world)return t.map(c=>ct(c,"a map is checked with the project's assets"));let o=Tm("repetition","map",r.style,e.name),n=Tm("seam","map",r.style,e.name),i=Tm("lattice","map",r.style,e.name),s=Ht(e,r.world),a=fC(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=Tm(c,"map",r.style,e.name);if(l.off===!0)return ct(c,"turned off in the style guide");if(c==="consistency")return nV(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 JC(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 QC(e,t=Pn,r={}){if(e.map)return rV(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,SF(e,a)).get(a);return t.map(a=>{let c=Tm(a,e.kind,r.style,e.name);if(c.off===!0)return ct(a,By[a][e.kind]?.off===!0?`not checked on a ${e.kind}`:"turned off in the style guide");if(tV.has(a)||o.length===1&&e.frameCount===1)return Wy[a](s(o[0]),c,r);if(o.length===1){let l=Wy[a](s(o[0]),c,{...r,frame:o[0]});return l.status==="skip"?l:JC(a,[{f:o[0],r:l}],n)}return JC(a,o.map(l=>({f:l,r:Wy[a](s(l),c,{...r,frame:l})})),n)})}function zi(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 Ss="ground",Pc="band",eA=new Map;function et(e){if(e.def){let r=JSON.stringify(e.def),o=eA.get(r);if(o)return o;let n=_s(e.def);return eA.set(r,n),n}let t=vy(e.scheme);if(!t)throw new Error(`unknown scheme '${e.scheme}'`);return t}function wS(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=>wS(et(e),e.mapCols,e.mapRows);function Om(e,t){let r=mt(e);if(t==="inside")return r.inside;if(t==="outside")return r.outside;let o=et(e).byName.get(t);return o===void 0?null:r.cells[o]}var Jy=new Map;function So(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=Jy.get(o);return n||(n=e.variants.map((i,s)=>eC(e,s,t,r)),Jy.size>64&&Jy.clear(),Jy.set(o,n)),n}function aS(e,t){return t<0||t<e.bands.length&&e.bands[t].fill==="outside"}var oV=(e,t)=>t>=0&&t<e.bands.length;function iV(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 tA(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 nA=new WeakMap;function sV(e,t,r,o){let n=nA.get(o);return n||(n=o.map(i=>Uint8Array.from(i,s=>aS(r,s)?1:0)),nA.set(o,n)),n}function vS(e){let t=e.family;if(!t)return;let r=et(t),o=t.tile,n=o/2,i=e.width,s=mt(t),a=So(r,o,t.geometry),c=e.layers.findIndex(d=>d.name===Ss),l=e.layers.findIndex(d=>d.name===Pc),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=tA(e,d,s.inside[0],s.inside[1],o),h=tA(e,d,s.outside[0],s.outside[1],o),g=sV(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 k=0;k<o;k++){let _=(w*o+k)*i+y*o;for(let $=0;$<o;$++){let x=k*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[k,_]=s.cells[y];iV(f,i,k*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 oA(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 zo(e,t,r=0){let o=e.family,n=et(o),i=o.tile,s=mt(o),a=be(e,r),c=wi(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=oA(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 NC(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 ks(...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 Si(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],k=u[(h+1)*c+p+1],_=Math.floor(((y*(a-g)+w*g)*(a-b)+(v*(a-g)+k*g)*b)/(a*a)),$=2*f-(n-1),x=2*d-(i-1),S=Math.floor($*$*256/((n-1)*(n-1)||1)+x*x*256/((i-1)*(i-1)||1)),R=f===0||d===0||f===n-1||d===i-1;m[d*n+f]=!R&&(_-128)*2+150-S>0?1:0}return{cols:t,rows:r,cells:m}}function As(e,t){let r=new Array(e.variants.length).fill(0);for(let o of wi(e,t,"not",!1))o!==null&&r[o]++;return r}function dS(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 Gy(e,t,r,o,n=1){let i=e.neighbours==="corners",s=i?t+1:t,a=i?r+1:r,c=$o(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=dS(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=As(e,g),y=!0,w=new Map(c.map($=>[$,d($).reduce((x,S)=>x+S,0)]));for(let $ of u([...c]).sort((x,S)=>w.get(S)-w.get(x))){let x=d($);for(;b[$]<n;){let S=u(Array.from({length:f*p},(N,T)=>T)),R=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},P=new Map(S.map(N=>[N,R(N)]));S.sort((N,T)=>P.get(N)-P.get(T));let j=!1;for(let N of S){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=As(e,g);if(D[$]>b[$]&&c.every(V=>V===$||D[V]>=Math.min(n,b[V]))){b=D,j=!0;break}g.cells.set(Z)}if(!j){y=!1;break}}}if(y)return g;let v=$=>{let x=As(e,$);return c.reduce((S,R)=>S+Math.min(n,x[R]),0)},k=c.length*n,_=v(g);for(let $=0;$<60&&_<k;$++){let x=0,S=-1,R=l.nextInt(g.cells.length);for(let P=0;P<g.cells.length;P++){let j=(R+P)%g.cells.length;g.cells[j]^=1;let N=v(g);g.cells[j]^=1,N-_>x&&(x=N-_,S=j)}if(S<0){let P=l.nextInt(g.cells.length);g.cells[P]^=1,_=v(g);continue}g.cells[S]^=1,_+=x}if(_>=k)return g}return null}function Vy(e,t,r=0){let o=t.family;if(!o)return 0;let n=et(o),i=e.t,s=e.w/i,a=e.variants.flatMap((m,d)=>m!==null&&bi(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 zs(e,t){let{w:r,h:o,t:n}=e,i=t.palette.entries.map(d=>ko(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=Am(s,a,r,o,n),m=Am(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 Ps={cols:12,rows:10,seed:1};function rA(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 iA(e,t){let r=e.family,o=et(r),n=r.tile,i=mt(r),s={cols:r.mapCols,rows:r.mapRows,cells:r.terrain},a=wi(o,s),c=e.layers.findIndex(h=>h.name===Pc),l=e.layers.findIndex(h=>h.name===Ss),u=So(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=>oA(g,f,y%r.mapCols,i.mapRow+Math.floor(y/r.mapCols),n);if(o.variants.forEach((y,w)=>{let v=a.flatMap((P,j)=>P===w?[j]:[]);if(!v.length){h===0&&y.key!==null&&d.push(y.name);return}let k=P=>!!y.on||oV(r.geometry,u[w][P]),_=v.map(b),$=rA(_,k);if(h===0&&m.set(w,{tile:v[$],of:v.length}),c<0)return;let x=e.cels[c][h],[S,R]=i.cells[w];for(let P=0;P<n;P++)for(let j=0;j<n;j++)x[(R*n+P)*f+S*n+j]=k(P*n+j)?_[$][P*n+j]: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 S=x%r.mapCols,R=Math.floor(x/r.mapCols);for(let P=-1;P<=1;P++)for(let j=-1;j<=1;j++){let N=S+j,T=R+P;if(N>=0&&T>=0&&N<r.mapCols&&T<r.mapRows&&r.terrain[T*r.mapCols+N])return[]}return[x]}),k=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"?k:v]]){if(!x.length)continue;let S=x.map(b),R=S[rA(S,()=>!0)];for(let P=0;P<n;P++)_.set(R.subarray(P*n,P*n+n),($[1]*n+P)*f+$[0]*n)}}}return r.detached=o.variants.map(h=>h.name).filter(h=>p.has(h)),{chosen:m,missing:d}}var sA=e=>{let t=rr(e)[0];return e.overlay?.mode==="pingpong"?{...t,loop:"pingpong"}:t};function aV(e){let t=e.overlay,r=Math.max(1,or(e,sA(e)));return t.mode==="sparkle"?r+t.rest:r}function cS(e,t,r,o){let n=e.overlay;if(ks(n.seed,t,r)%n.every!==0)return null;let i=sA(e),s=Math.max(1,or(e,i));if(n.mode==="cycle"||n.mode==="pingpong")return Vr(e,i,o);if(n.mode==="wave")return Vr(e,i,o+Math.floor((t+r)*s/8));let a=s+n.rest,c=(o+ks(n.seed,t,r,7)%a)%a;return c<s?Vr(e,i,c):null}function lS(e,t,r,o,n,i,s){let a=e.overlay,c=s??be(e,t),l=ks(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 MC(e,t,r,o){let n=o?.family?et(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=cS(i,m,d,r);if(p===null)return;let h=c.get(p)??c.set(p,be(i,p)).get(p);lS(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 DC(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 qC(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,or(e,rr(e)[0])));for(let s of t)s.overlay&&i(aV(s));return n}function UC(e,t){if(e.frameCount<2)return 0;let r=rr(e)[0];return Fr(r).length?Vr(e,r,t):0}function aA(){return{mode:"cycle",on:"outside",anchor:null,spread:[0,0],every:1,rest:60,seed:1}}function Ft(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 cV(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 Ky(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 cA(e,t,r,o,n={}){let i=Ft(e,t),s=r;if(n.brush){let a=cV(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=Ky(e,t,s));for(let[a,c]of s)lA(i,a,c,o)}function yn(e,t,r,o){let n=Ft(e,t);for(let[i,s,a]of o?Ky(e,t,r):r)lA(n,i,s,a)}function lA(e,t,r,o){let n=Et(e,t,r);n>=0&&(!e.mask||e.mask[n])&&(e.pixels[n]=o)}var zr=2;function jc(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+Ec(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 '${Ec(t)}'`)}cellOrigin(t){if(!this.cell)return{dx:0,dy:0,text:""};if(this.cell.name!==void 0){let s=t.family?Om(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 Ec(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=yi(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}),Ro=(e,t,r=!0)=>le((o,n)=>cA(o,n,e,t,{brush:r,mirror:!0}));function Pt(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 Io(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 Pt(r.value,t.palette,r.line,r.vcol)}var xS=(e,t,r)=>t||r?e.map(([o,n])=>[o+t,n+r]):e;function lV(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 uV={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 (${vs.join(", ")})`);if(!vs.includes(o.v))throw new O(o.line,o.col,`unknown kind '${o.v}' (kinds: ${vs.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??zr,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"?jc("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?Pt(b.value,d,b.line,b.vcol):{index:65535,name:"none"},w=r.opts.get("scheme")??(n==="family"&&s?.scheme?jc("scheme",s.scheme,e):void 0),v=r.opts.get("map"),k,_,$,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 S=a.w,R=a.h,P="",j=r.opts.get("tile");if(j&&n!=="map")throw new O(j.line,j.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> (${[...vo.keys()].join(", ")})`);let T=r.opts.get("def"),q=null,Z=T||t.scheme?.(w.value)?void 0:vy(w.value);if(!Z){try{let M=T?JSON.parse(T.value):t.scheme?.(w.value)??null;q=M?lV(M):null,q&&(Z=_s(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: ${[...vo.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=wS(Z,D,V);S=F.cols*a.w,R=F.rows*a.h,p=a.w,h=a.h,k={scheme:Z.name,tile:a.w,geometry:{inset:tC(Z,a.w),radius:0,bands:[]},detached:[],mapCols:D,mapRows:V,terrain:new Uint8Array,def:q},P=` 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(j){if(!/^\d+$/.test(j.value)||Number(j.value)<4||Number(j.value)>256)throw new O(j.line,j.vcol,"tile= must be the cell size in pixels, 4..256");T=Number(j.value)}p=1,h=1,_={tile:T,entries:[]},P=` 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?{...jc("chars",s.chars,e),quoted:!/^[0-9U+,\-]+$/.test(s.chars)}:void 0),q=T?ym(T.value,T.quoted):ym("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:{}},S=D*a.w,R=V*a.h,p=a.w,h=a.h,P=` chars=${AT(q)} cols=${D} baseline=${$.baseline} line=${$.line} spacing=${$.spacing}`}let N=_?`new map ${i.v} ${a.w}x${a.h}${P} 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}${P}`:`new ${n} ${i.v} ${a.w}x${a.h}${P} palette=${d.name} wrap=${f?"on":"off"} cell=${p}x${h} bg=${y.name}`;return{text:l>=2?`${N} <<
132
+ ${Jt(my(d))}>>`:N,op:{k:"new",kind:n,name:i.v,width:S,height:R,cellW:p,cellH:h,wrap:f,palette:d,bg:y.index,...k?{family:k}:{},..._?{map:_}:{},...$?{font:$}:{},...n==="overlay"?{overlay:aA()}:{}}}}},mV={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=Io(o,r);return{text:`px${n.text} ${i.map(ir).join(" ")} c=${s.name}`,op:Ro(xS(i,n.dx,n.dy),s.index)}}},dV={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=Io(o,r),a=o.choice("pp",["on","off"],"on");return{text:`line${n.text} ${i.map(ir).join(" ")} c=${s.name} pp=${a}`,op:Ro(oS(xS(i,n.dx,n.dy),a==="on"),s.index)}}},fV={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=Io(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:Ro(_o(i.x+n.dx,i.y+n.dy,s.w,s.h,c==="fill"),a.index,c==="outline")}}},pV={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=Io(o,r),u=o.flag(["outline","fill"],"outline"),m=vi(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:Ro(m,l.index,u==="outline")}}},hV={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=Io(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 Ky(m,d,[[s,a]]))ky(Ft(m,d),f,p,c.index,l==="global",u==="8"?8:4)})}}},gV={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
+ ${Jt(s.rows.map(d=>d.text))}>>`,op:le((d,f)=>yn(d,f,m,!0))}}};function Jt(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 yV={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}}}},bV={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}}}},$S=["pencil","eraser"],wV={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 (${$S.join(", ")})`);if(!$S.includes(i.v))throw new O(i.line,i.col,`stroke: unknown tool '${i.v}' (tools: ${$S.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=xS(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(ir).join(" ")}`,op:Ro(_c(c,!1),65535)}}let l=Io(o,r),u=o.choice("pp",["on","off"],"on");return{text:`stroke${n.text} pencil c=${l.name} pp=${u} ${s.map(ir).join(" ")}`,op:Ro(_c(c,u==="on"),l.index)}}},vV={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=gi(s.value),!c||!s.value.startsWith("#")))throw new O(s.line,s.vcol,"hex= must be a colour like #a4552e");if(a&&!fm(a.value)&&!(n.v==="set"&&a.value==="none"))throw new O(a.line,a.vcol,`role= must be one of ${Bt.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 k=l.entries.map(($,x)=>{if(x!==v)return $;let S={key:$.key,name:$.name,hex:c??$.hex},R=a?a.value:$.role;return R&&R!=="none"?{...S,role:R}:S});return{text:`palette set ${l.entries[v].name}${c?` hex=${c}`:""}${a?` role=${a.value}`:""}`,op:le($=>{$.palette={...l,entries:k}})}}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??=$c[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||Fk.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=xs(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}})}}},$V=/^n[1-9]\d*$/,xV={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(!$V.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}]})}}},_V={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 ir(e){return`${e[0]},${e[1]}`}var Kr=new Map;function Te(e){Kr.set(e.name,e)}for(let e of[uV,mV,dV,fV,pV,hV,gV,wV,vV,xV,_V,yV,bV])Te(e);function Ri(e,t){let r=Kr.get(e.name);if(!r)throw new O(e.line,e.col,`unknown command '${e.name}' (commands: ${[...Kr.keys()].join(", ")})`);return r.normalise(e,t)}function Os(e,t,r=""){if(t.k==="new"){let o=wT(t);return vS(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&&jT(e),e.family&&vS(e);else throw new Error("applyOp: undo is applied by replay");return e}var _S=(e,t)=>t?_S(t,e%t):e;function Xy(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/_S(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)=>_S(c,l.weight),0)||1;return s.map(c=>({name:c.name,weight:c.weight/a}))}function Yy(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 uA(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 kV=/^[A-Za-z][A-Za-z0-9_-]*$/,yA=new Set(["add","set","remove","rename","move","merge"]),SV=e=>e?"on":"off";function mA(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 dA(e,t){if(!kV.test(t.v)||yA.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 fA(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]),kr(e,o=>r.get(o)??0,o=>o)}function pA(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 zV(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 RV={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(!yA.has(s.v)){i.done(),a();let u=mA(r,s);return{text:`layer ${s.v}`,op:le((m,d)=>Nt(m,d,{layer:u}))}}if(s.v==="add"){let u=i.take("word","a name for the new layer");if(i.done(),dA(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=IV(i,r,t),d=PV(m),a(["above","below","flag","terrain","outside","walkable","overlay","on","border","mix","seed","variants","shadow","shadowdir"])):a(["above","below","flag"]);let f=pA(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(qr(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),fA(h,b)})}}let c=i.take("word","a layer name"),l=mA(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=bA(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=wA(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=vA(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 k={...v.layers[l].map,...b};k.walkable||delete k.walkable,k.border||delete k.border,w&&(delete k.mix,delete k.seed),v.layers[l].map=k})}}a(["hidden","locked","reference"]);let f=zV(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}=${SV(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(),dA(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=pA(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),fA(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])}hA(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=>hA(u,l))}}};function bA(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:Pt(s,t.palette,n?.line??e.cmd.line,n?.vcol??e.cmd.col).name,c=e.choice("shadowdir",kc,o?.dir??(i?.dir&&kc.includes(i.dir)?i.dir:Sy(r.defaults?.light)));return{c:a,dir:c}}function wA(e){let t=e.choice("border",["same","terrain","not"],"same");return t==="same"?void 0:t}function vA(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=Yy(r),i=o?.value==="named"?n:Xy(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=uA(e,t);return{mix:i,seed:s,text:`mix=${i.map(a=>`${a.name}:${a.weight}`).join(",")} variants=named seed=${s}`}}function IV(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=wA(e),u=vA(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=bA(e,t,r);return c?{kind:"objects",shadow:c}:{kind:"objects"}}return{kind:"tiles"}}function PV(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 hA(e,t){e.layers.splice(t,1),e.cels.splice(t,1),kr(e,r=>r>t?r-1:r===t?Math.max(0,t-1):r,r=>r)}var jV=new Set(["add","remove","move","set"]);function kS(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 SS(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 Nm(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 gA(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 Qy(e,t,r,o){let n=yi(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 EV={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=kS(r,o.take("int","a frame number"),e,"a frame number");return o.done(),i("frame <n>"),{text:`frame ${m}`,op:le((d,f)=>Nt(d,f,{frame:m-1}))}}let s=o.take("word","a frame number, or add, set, remove or move");if(!jV.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=Nm(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=gA(d),p=h=>!yi(r,h)?.mirror;return m.from===m.to&&Qy(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"?kS(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?SS(r,f):d?SS(r,d):Me(r,t.by).frame+1;f&&Qy(r,h-1,f,"frame add link=");let g=o.opts.get("ticks"),b=g?gA(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,k=_=>p?new Uint16Array(v).fill(65535):f?w.cels[_][h-1]:w.cels[_][h-1].slice();hm(w,m-1,1,k,[b??w.ticks[h-1]])})}}let a=kS(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 Qy(r,a-1,e,"frame remove"),{text:`frame remove ${a}`,op:le(m=>Bk(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=SS(r,c),u=Hk(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 yi(r,a-1)?.mirror&&Qy(r,a-1,e,"frame move"),{text:`frame move ${a} to=${l}`,op:le(m=>PT(m,a-1,l-1))}}};Te(RV);Te(EV);var $A=["add","sub","and"];function zS(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=Et(r,n,i);s>=0&&(o[s]=1)}return o}function TV(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 CV(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=Et(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=Et(s,f+h,p+g);b>=0&&!a[b]&&t[b]===l&&(a[b]=1,m.push(b))}}return a}var xA="rect, ellipse, lasso, wand, colour, layer, all, none or invert",AV={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"],$A),n=o.cellOrigin(r),i=o.take("word",xA),s=o.flag($A,"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)=>Nt(f,p,{sel:TV(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)=>Nt(m,d,{sel:null}))}:i.v==="all"?{text:`select${n.text} all`,op:le((m,d)=>Nt(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;Nt(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=zS(r,_o(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=zS(r,vi(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=zS(r,_y(m.map(u),!0,!1));return l(`lasso ${m.map(ir).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)=>CV(g,Ft(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=Pt(m.value,r.palette,m.line,m.vcol);return l(`colour c=${d.name}`,(f,p)=>{let h=Ft(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 (${xA})`)}}},OV={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)=>Nt(r,o,{sel:null}))}}},NV={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=Ft(r,o);for(let i=0;i<n.pixels.length;i++)(!n.mask||n.mask[i])&&(n.pixels[i]=65535)})}}};Te(AV);Te(OV);Te(NV);var _A=(e,t)=>(e%t+t)%t;function eb(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 IS(e,t,r){let o=Ft(e,t,!1),n=eb(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=Et(o,a,c);u<0||(o.pixels[u]=l,s&&(s[u]=1))}n.mask&&Nt(e,t,{sel:s.some(a=>a)?s:null})}function PS(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 jS=e=>`${e.sel?" sel":""}${e.wrap?" wrap":""}`,MV={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=PS(o,r,t.by,!0);return{text:`shift ${n.x},${n.y}${jS(i)}`,op:le((s,a)=>{let c=eb(s,a);IS(s,a,i.wrap?(l,u)=>[c.x+_A(l-c.x+n.x,c.w),c.y+_A(u-c.y+n.y,c.h)]:(l,u)=>[l+n.x,u+n.y])})}}},DV={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=PS(o,r,t.by,!1);return{text:`flip ${n.v}${jS(i)}`,op:le((s,a)=>{let c=eb(s,a);IS(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])})}}},qV={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=PS(o,r,t.by,!1);return{text:`rotate ${n.v}${jS(i)}`,op:le((s,a)=>{let c=eb(s,a),l=c.x+Math.floor((c.w-c.h)/2),u=c.y+Math.floor((c.h-c.w)/2);IS(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 kA(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 RS=e=>e%2===0?String(e/2):`${(e-1)/2}.5`,UV={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)=>Nt(g,b,{mirror:null}))}}if(i&&c)throw new O(c.line,c.col,"mirror: give live or from=, not both");let l=s?kA(s):null,u=a?kA(a):null;if(i)return l===null&&u===null&&(l=r.width-1),{text:`mirror ${[l!==null?`x=${RS(l)}`:"",u!==null?`y=${RS(u)}`:""].filter(Boolean).join(" ")} live`,op:le((b,y)=>Nt(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"}=${RS(p)} from=${d}`,op:le((g,b)=>{let y=Ft(g,b),w=y.pixels.slice();for(let v=0;v<w.length;v++){let k=v%g.width,_=(v-k)/g.width,$=m?k:_;if(h?2*$>=p:2*$<=p)continue;let x=Et(y,m?p-k:k,m?_:p-_);x>=0&&(!y.mask||y.mask[x])&&(y.pixels[x]=w[v])}})}}};Te(MV);Te(DV);Te(qV);Te(UV);var LV={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=Io(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(ir).join(" ")} c=${s.name} pp=${a}`,op:Ro(sC(c,a==="on"),s.index)}}},FV={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=Io(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(ir).join(" ")} c=${s.name} ${a}`,op:Ro(_y(c,a==="fill",!0),s.index,a==="outline")}}};function tb(e){if(e===1)return[[0]];let t=tb(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 rb={checker:[[0,1],[1,0]],bayer2:tb(2),bayer4:tb(4),bayer8:tb(8),hlines:[[0],[1]],vlines:[[0,1]]},nb=Object.keys(rb);function ES(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 zA(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 VV={name:"dither",summary:`dither <x,y> <W>x<H> a=<colour> b=<colour> [pattern=${nb.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=zA(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 Pt(h.value,r.palette,h.line,h.vcol)},a=s("a"),c=s("b"),l=o.choice("pattern",nb,"bayer4"),u=o.opts.get("level"),m=u?Rs(u):{num:1,den:2,text:"0.5"},d=rb[l],f=_o(i.x+n.dx,i.y+n.dy,i.w,i.h,!0).map(([p,h])=>[p,h,ES(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))}}},SA=["down","up","right","left","radial"],ZV={name:"gradient",summary:`gradient <x,y> <W>x<H> ramp=<ramp|a,b,c> [dir=${SA.join("|")}] [steps=<n>] [pattern=none|${nb.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=zA(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=xi(s,r.palette),c=o.choice("dir",SA,"down"),l=o.opts.get("steps"),u=l?Mt(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",...nb],"none"),d=Array.from({length:u},(k,_)=>a.idx[uS(2*_*(a.idx.length-1)+(u-1),2*(u-1))]),f=m==="none"?null:rb[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=(k,_)=>{switch(c){case"down":return[_-h,i.h-1];case"up":return[h+i.h-1-_,i.h-1];case"right":return[k-p,i.w-1];case"left":return[p+i.w-1-k,i.w-1];default:return[_m(4*((2*k-g)**2+(2*_-b)**2)),_m(4*y)||1]}},v=_o(p,h,i.w,i.h,!0).map(([k,_])=>{let[$,x]=w(k,_);if(x<=0)return[k,_,d[0]];let S=$*(u-1),R=Math.min(u-1,uS(S,x)),P=S-R*x;if(R===u-1)return[k,_,d[R]];let j=f?ES(f,k,_,P,x):2*P>=x;return[k,_,d[j?R+1:R]]});return{text:`gradient${n.text} ${i.text} ramp=${a.text} dir=${c} steps=${u} pattern=${m}`,op:le((k,_)=>yn(k,_,v,!1))}}},WV={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(Pt(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(LV);Te(FV);Te(VV);Te(ZV);Te(WV);var Mm=[[0,-1],[1,0],[0,1],[-1,0]],BV=[...Mm,[1,-1],[1,1],[-1,1],[-1,-1]];function RA(e,t,r,o){let n=Et(e,r,o);return n<0?65535:t[n]}var HV={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?jc("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=Pt(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"?BV:Mm;return{text:`outline c=${s.name} mode=${a} corners=${c}${l?` from=${l.value}`:""}`,op:le((d,f)=>{let p=Ft(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(([_,$])=>RA(p,h,y+_,w+$)!==65535==(a==="outer"))&&(p.pixels[b]=s.index)}})}}},TS={n:[0,-1],ne:[1,-1],e:[1,0],se:[1,1],s:[0,1],sw:[-1,1],w:[-1,0],nw:[-1,-1]},JV={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 TS?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(TS),n??"nw"),s=o.opts.get("ramp"),a=s&&s.value!=="all"?xi(s,r.palette):null,c=o.opts.get("edge"),l=c?Mt(c,1,8):1,[u,m]=TS[i];return{text:`shade light=${i} ramp=${a?a.text:"all"} edge=${l}`,op:le((d,f)=>{let p=Ft(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:km(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 k=y%d.width,_=(y-k)/d.width,$=(j,N)=>{for(let T=1;T<=l;T++){let q=RA(p,h,k+j*T,_+N*T);if(q===65535||!v.ramp.includes(q))return!0}return!1},x=(j,N)=>j!==0&&$(j,0)||N!==0&&$(0,N),S=x(u,m),R=x(-u,-m);if(S===R)continue;let P=v.at+(S?1:-1);P>=0&&P<v.ramp.length&&(p.pixels[y]=v.ramp[P])}})}}},GV={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?Mt(i,1,64):1,a=o.choice("keep",["none","texture"],"none");return{text:`clean orphans size=${s} keep=${a}`,op:le((c,l)=>KV(c,Ft(c,l),s,a==="texture"))}}};function KV(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 Mm){let w=Et(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 Mm){let w=Et(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 Mm){let y=Et(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&&km(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 XV={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",kc,s?.dir&&kc.includes(s.dir)?s.dir:Sy(t.defaults?.light)),c=o.opts.get("c")??(s?.c&&s.c!=="darker"?jc("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=Pt(c.value,r.palette,c.line,c.vcol);if(!i){let m=Me(r,t.by).frame;if(i=zy(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=Ft(m,d),p=be(m,Me(m,d).frame);for(let[h,g]of Ry(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(HV);Te(XV);Te(JV);Te(GV);var sr=(e,t)=>(e%t+t)%t;function Ns(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 Tc(e,t){let r=e.opts.get("seed");return r?Mt(r,0,2147483647):t.newSeed()}function Dm(e,t){return e.choice("wrap",["on","off"],t.wrap?"on":"off")==="on"}function qm(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 CS(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=xi(o,t.palette),i=e.opts.get("weights"),s=i?Ey(i,n.idx.length):n.idx.map(()=>1);return{ramp:n,weights:s}}function AS(e,t){return(r,o)=>t?[e.x+sr(r,e.w),e.y+sr(o,e.h)]:r<0||o<0||r>=e.w||o>=e.h?null:[e.x+r,e.y+o]}var YV={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=Ns(o,r,"noise");o.done();let{ramp:i,weights:s}=CS(o,r,e),a=o.opts.get("cluster"),c=Math.max(1,Math.floor(r.cellW/24)),[l,u]=a?zc(a,1,64):[c,3*c],m=o.opts.get("density"),d=m?Rs(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 S=Pt(f.value,r.palette,f.line,f.vcol);p=S.index,h=S.name}let g=Dm(o,r),b=Tc(o,t),y=i.idx.map((S,R)=>S===p?0:s[R]);if(y.every(S=>S===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 S=0;S<n.h;S++)for(let R=0;R<n.w;R++)w.push([n.x+R,n.y+S,p]);let v=new dt(b,1),k=AS(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 S=0;x<_&&S<_*4+16;S++){let R=v.range(l,u),P=i.idx[qm(v,y)],j=[[v.nextInt(n.w),v.nextInt(n.h)]],N=(q,Z)=>`${sr(q,n.w)},${sr(Z,n.h)}`,T=new Set([N(...j[0])]);for(let q=0;j.length<R&&q<R*8;q++){let[Z,D]=j[v.nextInt(j.length)],[V,F]=[[1,0],[-1,0],[0,1],[0,-1]][v.nextInt(4)],M=Z+V,L=D+F;!k(M,L)||T.has(N(M,L))||(T.add(N(M,L)),j.push([M,L]))}for(let[q,Z]of j){let D=k(q,Z);if(!D)continue;w.push([D[0],D[1],P]);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((S,R)=>yn(S,R,w,!1))}}},QV={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=Ns(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 k=i.value.split(",");c=k.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=${k.join(",")}`}else{let k=Pt(s.value,r.palette,s.line,s.vcol);c=[{w:1,h:1,px:Uint16Array.of(k.index)}],a=`c=${k.name}`}let l=o.opts.get("count");if(!l)throw new O(e.line,e.col,"scatter: missing count=<n>");let u=Mt(l,1,1e4),m=o.opts.get("minDist"),d=m?Mt(m,0,4096):0,f=o.choice("flip",["on","off"],"off")==="on",p=Dm(o,r),h=Tc(o,t),g=new dt(h,2),b=[],y=(k,_)=>{let $=Math.abs(k[0]-_[0]),x=Math.abs(k[1]-_[1]);return p&&($=Math.min($,n.w-$),x=Math.min(x,n.h-x)),$*$+x*x};for(let k=0;b.length<u&&k<u*30;k++){let _=[g.nextInt(n.w),g.nextInt(n.h)];b.some($=>y(_,$)<d*d)||b.push(_)}let w=AS(n,p),v=[];for(let[k,_]of b){let $=c[g.nextInt(c.length)],x=f&&g.nextInt(2)===1;for(let S=0;S<$.h;S++)for(let R=0;R<$.w;R++){let P=$.px[S*$.w+(x?$.w-1-R:R)];if(P===65535)continue;let j=w(k-($.w>>1)+R,_-($.h>>1)+S);j&&v.push([j[0],j[1],P])}}return{text:`scatter${n.text} ${a} count=${u} minDist=${d} flip=${f?"on":"off"} wrap=${p?"on":"off"} seed=${h}`,op:le((k,_)=>yn(k,_,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=Pt(r.value,t.palette,r.line,r.vcol);return{index:o.index,text:o.name}}var e8={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=Ns(o,r,"voronoi");o.done();let{ramp:i,weights:s}=CS(o,r,e),a=o.opts.get("cells");if(!a)throw new O(e.line,e.col,"voronoi: missing cells=<n>");let c=Mt(a,1,Math.max(1,Math.min(4096,n.w*n.h))),l=IA(o,r),u=o.opts.get("relax"),m=u?Mt(u,0,8):1,d=Dm(o,r),f=Tc(o,t),p=new dt(f,3),h=_m(Math.floor(n.w*n.h*36/(100*c))),g=(x,S,R)=>{let P=S-x;if(!d)return P;let j=sr(P,R);return j*2>R?j-R:j},b=(x,S,R)=>{let P=g(R[0],x,n.w),j=g(R[1],S,n.h);return P*P+j*j},y=[];for(let x=0;y.length<c&&x<c*50;x++){let S=[p.nextInt(n.w),p.nextInt(n.h)];x<c*40&&y.some(R=>b(S[0],S[1],R)<h*h)||y.push(S)}let w=new Int32Array(n.w*n.h),v=()=>{for(let x=0;x<n.h;x++)for(let S=0;S<n.w;S++){let R=0,P=1/0;y.forEach((j,N)=>{let T=b(S,x,j);T<P&&(P=T,R=N)}),w[x*n.w+S]=R}};v();for(let x=0;x<m;x++){let S=new Array(y.length).fill(0),R=new Array(y.length).fill(0),P=new Array(y.length).fill(0);for(let j=0;j<n.h;j++)for(let N=0;N<n.w;N++){let T=w[j*n.w+N];S[T]+=g(y[T][0],N,n.w),R[T]+=g(y[T][1],j,n.h),P[T]++}y=y.map((j,N)=>{if(!P[N])return j;let T=j[0]+Math.floor((2*S[N]+P[N])/(2*P[N])),q=j[1]+Math.floor((2*R[N]+P[N])/(2*P[N]));return d?[sr(T,n.w),sr(q,n.h)]:[Math.max(0,Math.min(n.w-1,T)),Math.max(0,Math.min(n.h-1,q))]}),v()}let k=y.map(()=>i.idx[qm(p,s)]),_=AS(n,d),$=[];for(let x=0;x<n.h;x++)for(let S=0;S<n.w;S++){let R=w[x*n.w+S],P=!1;if(l.index!==null)for(let[j,N]of[[1,0],[-1,0],[0,1],[0,-1]]){let T=_(S+j,x+N);if(T&&w[(T[1]-n.y)*n.w+(T[0]-n.x)]<R){P=!0;break}}$.push([n.x+S,n.y+x,P?l.index:k[R]])}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,S)=>yn(x,S,$,!1))}}},t8={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=Ns(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}=CS(o,r,e),m=IA(o,r),d=o.opts.get("offset"),f=d?Mt(d,0,a-1):a>>1,p=Tc(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[qm(h,u)]),w=[];for(let v=0;v<n.h;v++)for(let k=0;k<n.w;k++){let _=Math.floor(v/c),$=k+(_%2?f:0),x=n.w%a===0?Math.floor($/a)%(n.w/a):Math.floor($/a),S=v%c===c-1||$%a===a-1;S&&m.index===null||w.push([n.x+k,n.y+v,S?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,k)=>yn(v,k,w,!1))}}};Te(YV);Te(QV);Te(e8);Te(t8);function jA(e,t){let r=t.defaults?.light&&t.defaults.light in Rn?t.defaults.light:"nw",o=e.choice("light",Object.keys(Rn),r);return{name:o,dir:Rn[o]}}function EA(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=xi(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 TA(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=Pt(n.value,t.palette,n.line,n.vcol);return{index:i.index,text:i.name}}var CA=e=>Math.max(8,Math.min(e.cellW,e.cellH));function AA(e,t,r,o,n){let i=e.opts.get("gap"),s=i?Mt(i,0,16):1,a=Dm(e,t),c=Tc(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?Mt(l,0,2147483647):c;return{box:o,wrap:a,gap:s,density:n,seed:c,edges:u}}var OA=e=>`gap=${e.gap} wrap=${e.wrap?"on":"off"}${e.wrap?` edges=${e.edges}`:""} seed=${e.seed}`,ob=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 NA(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?sr(q,u)*l+sr(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 ob(u,l),cols:new ob(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],I=A-T.lum[L],C=z-T.luma[L];T.lum[L]=A,T.luma[L]=z;let U=L%l,H=Math.floor(L/l);T.rows.add(H,U,I,C),T.cols.add(U,H,I,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,k=(T,q,Z,D=0)=>{let V=new dt(T,i+(q?0:16)+32*D),F=(I,C)=>{if(a){let U=[sr(I[0],l),sr(I[1],u)];return!q&&f(U,C)?null:U}return I[0]<0||I[1]<0||I[0]+C.w>l||I[1]+C.h>u?null:I},M=I=>F(a?[V.nextInt(l),V.nextInt(u)]:[V.nextInt(l-I.w+1),V.nextInt(u-I.h+1)],I),L=[];for(let I=0;Z.covered<m&&I<64+3*m;I++){let C=n(V);if(C.w>l||C.h>u)continue;let U=null,H=1/0;for(let Y=0;Y<8;Y++){let X=M(C);if(!X||!b(Z,X,C))continue;let fe=w(Z,X,C)[1];fe<H&&(H=fe,U=X)}U&&(g(Z,U,C,!0),L.push({at:U,s:C}))}let A=.8,z=()=>{for(let I=0;I<8;I++){let C=!1;for(let U of L){if(y(Z)[0]<=A)return;g(Z,U.at,U.s,!1);let H=U.at,Y=w(Z,U.at,U.s),X=[];for(let ye=-2;ye<=2;ye++)for(let W=-2;W<=2;W++)(W||ye)&&X.push(F([U.at[0]+W,U.at[1]+ye],U.s));for(let ye=0;ye<8;ye++)X.push(M(U.s));for(let ye of X){if(!ye||!b(Z,ye,U.s))continue;let W=w(Z,ye,U.s);v(W,Y)&&(Y=W,H=ye)}let fe=U.s;for(let ye of U.s.alts??[]){if(ye===U.s)continue;let W=w(Z,H,ye);v(W,Y)&&(Y=W,fe=ye)}(H!==U.at||fe!==U.s)&&(C=!0),U.at=H,U.s=fe,g(Z,U.at,U.s,!0)}if(!C)break}};z();for(let I=0;I<8&&Z.covered<m+(m>>2)&&y(Z)[0]>A;I++){let C=n(V),U=y(Z),H=null,Y=U,X=l*u<=1024;for(let fe=0;fe<(X?l*u:64);fe++){let ye=X?F([fe%l,Math.floor(fe/l)],C):M(C);if(!ye||!b(Z,ye,C))continue;let W=w(Z,ye,C);v(W,Y)&&(Y=W,H=ye)}H&&(g(Z,H,C,!0),L.push({at:H,s:C}),z())}return{placed:L,cost:y(Z)}},_=l*u<=400?4:l*u<=1024?3:2,$=(T,q,Z)=>{let D=k(T,q,Z());for(let V=1;V<_&&D.cost[0]>.8;V++){let F=k(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 S=[],R=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&&R.set(F,V)}let P=new Map;for(let T of t.c)P.set(T,(P.get(T)??0)+1);let j=[...P].sort((T,q)=>q[1]-T[1]||T[0]-q[0])[0]?.[0]??-1,N=new Set;for(let[T,q]of R){if(q===j||j<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&&!R.has(M)&&t.c[M]===q&&N.add(M)}}for(let T of[...N].sort((q,Z)=>q-Z))S.push([s.x+T%l,s.y+Math.floor(T/l),j]);for(let[T,q]of R)S.push([s.x+T%l,s.y+Math.floor(T/l),q]);return S}function MA(e,t,r){let o=e.palette.entries.map(l=>Zr(l.hex)),n=e.palette.entries.map(l=>ko(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 n8(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 PA=[[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1],[0,-1],[1,-1]];function r8(e,t,r,o){let n=n8(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 k=0,_=0;for(let[$,x]of PA)a(v+$,w+x)||(k+=$,_+=x);l[w*e+v]=k*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 k=[-1,1].filter($=>u(v+$,w)),_=[-1,1].filter($=>u(v,w+$));k.length===1&&_.length===1&&!a(v+k[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 k=w*e+v;c[k]===o.body&&(m&&PA.some(([_,$])=>!a(v+_,w+$))||f.push({k,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 k=w.length>1||w.every(_=>{let $=_%e,x=Math.floor(_/e),S=p.map(([P,j])=>a($+P,x+j)?c[(x+j)*e+$+P]:-1),R=S.filter(P=>P===o.body).length;return R>=2&&S.filter(P=>P!==o.body&&P!==o.lit).length<R});for(let _=0;k&&_<t;_++)for(let $=0;$<e;$++)if(d($,_)&&!p.some(([x,S])=>d($+x,_+S))){k=!1;break}return k||w.forEach((_,$)=>{c[_]=v[$]}),k},g=w=>{let v=w%e,k=Math.floor(w/e),[_,$]=s!==0?[i===0?1:-i,0]:[0,1];return d(v+_,k+$)?(k+$)*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 o8=(e,t)=>Math.max(2,Math.min(e,e-1-(e>>2)+t)),i8={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=Ns(o,r,"pebbles");o.done();let i=EA(o,r,e,3),s=i.idx.slice(1,-1),a=o.opts.get("weights"),c=a?Ey(a,s.length):s.map(()=>1),l=CA(r),u=o.opts.get("size"),m=Math.max(3,Math.floor((l+4)/9)),[d,f]=u?zc(u,3,64):[m,Math.max(m+1,Math.floor((2*l+4)/9))],p=o.opts.get("density"),h=p?Rs(p):{num:3,den:10,text:"0.3"},g=jA(o,t),b=TA(o,r,"cast",null),y=AA(o,r,t,n,h),w=S=>{let R=S.range(d,f),P=o8(R,S.nextInt(2)),j=qm(S,c),N=q=>v(r8(R,P,g.dir,{dark:i.idx[q],body:i.idx[q+1],lit:i.idx[q+2]})),T=N(j);T.alts=c.flatMap((q,Z)=>q>0?[Z===j?T:N(Z)]:[]);for(let q of T.alts)q.alts=T.alts;return T},v=S=>{if(b.index===null)return S;let R=new Set(S.px.map(([V,F])=>`${V},${F}`)),[P,j]=g.dir,T=[...S.px.map(([V,F])=>[V-P,F-j,b.index]).filter(([V,F])=>!R.has(`${V},${F}`)),...S.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:k,L:_,Y:$}=MA(r,t.by,n),x=NA(y,k,_,$,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} ${OA(y)}`,op:le((S,R)=>yn(S,R,x,!1))}}};function s8(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,k]of xy([p,t-1],[p+b,t-y]))u.push([v,k,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 a8={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=Ns(o,r,"tufts");o.done();let i=EA(o,r,e,3),s=CA(r),a=o.opts.get("size"),c=Math.max(3,Math.floor((s+2)/6)),[l,u]=a?zc(a,3,64):[c,Math.max(c+1,Math.floor((s+2)/4))],m=o.opts.get("blades"),[d,f]=m?zc(m,1,9):s<20?[2,3]:s<32?[3,4]:[3,5],p=o.opts.get("density"),h=p?Rs(p):{num:2,den:10,text:"0.2"},g=jA(o,t),b=TA(o,r,"foot",i.idx[0]),y=AA(o,r,t,n,h),{under:w,L:v,Y:k}=MA(r,t.by,n),$=NA(y,w,v,k,x=>{let S=x.range(d,f),R=x.range(l,u),P=Array.from({length:S},()=>x.nextInt(2)),j=[R-1,R,R+1].filter(N=>N>=l&&N<=u).map(N=>s8(S,N,P,g.dir,i.idx,b.index));for(let N of j)N.alts=j;return j[j.length>2?1:R>l?j.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} ${OA(y)}`,op:le((x,S)=>yn(x,S,$,!1))}}};Te(i8);Te(a8);var c8=/^[a-z][a-z0-9_-]*$/,l8=new Set(["save","remove"]),u8={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(!c8.test(d.v)||l8.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((k,_)=>[k.key,_])),b=h.rows.map(k=>[...k.text].map((_,$)=>{if(_==="."||_===" ")return 65535;let x=g.get(_);if(x===void 0)throw new O(k.line,k.col+$,`stamp: '${_}' is not a key in palette '${r.palette.name}'`);return x})),y=Math.max(0,...b.map(k=>k.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((k,_)=>k.forEach(($,x)=>{v[_*y+x]=$})),{text:`stamp save ${d.v} <<
137
+ ${Jt(h.rows.map(k=>k.text))}>>`,op:le(k=>{k.stamps={...k.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=Ft(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 k=Et(b,f.x+n.dx+v,f.y+n.dy+w);k>=0&&(!b.mask||b.mask[k])&&(y[w*p.w+v]=b.pixels[k])}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&&Nt(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))}}},m8={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)=>Nt(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)=>Nt(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)=>Nt(a,c,{brush:i.v===1?null:{shape:s,size:i.v}}))}}};Te(u8);Te(m8);var d8=/^[a-z][a-z0-9_]*$/,UA=new Set(["new","fork","undo","redo","note","def"]),DA=8;function f8(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 p8(e){return e.includes(`
140
+ `)?`{
141
+ ${e.split(`
142
+ `).map(t=>t?` ${t}`:"").join(`
143
+ `)}
144
+ }`:`{ ${e} }`}function qA(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 OS(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(qA(n,r));let a=r.get(i);if(a===void 0)throw new Error(`unknown parameter '$${i}'`);if(!s)return a;let c=qA(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 h8={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 '${Ec(n[0])}' after the body`);let i=o.map(Ec).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(Kr.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=>!d8.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=f8(r.text);if(!l.trim())throw new O(r.line,r.col,"def: the body is empty");let u;try{u=OS({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(UA.has(d.name))throw new O(r.line,r.col,`def ${a}: '${d.name}' cannot be used in a macro`);if(!Kr.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(",")}) ${p8(l)}`,op:{k:"fn",run:d=>{d.macros={...d.macros,[a]:{params:c,body:l}}}}}}},g8={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(Ec(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>DA)throw new O(e.line,e.col,`call ${n.v}: macros call each other more than ${DA} deep`);let l=o.opts.get("seed"),u=l?Mt(l,0,2147483647):null,m=0,d;try{d=OS(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=Ur(r),h=[];for(let b of f.commands){if(UA.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()),by(new dt(u,1e3+m++))),undoTarget:()=>({error:"not in a macro"}),redoTarget:()=>({error:"not in a macro"})};try{let w=Ri(b,y);p=Os(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)Os(b,w,y)}}}}};Te(h8);Te(g8);var y8=/^[A-Za-z][A-Za-z0-9_-]*$/,b8=new Set(["add","set","remove","all"]),LA=["cycle","pingpong"];function NS(e,t){if(e.flags.length)throw new O(e.flags[0].line,e.flags[0].col,`${t}: unexpected '${e.flags[0].v}'`)}function ib(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 Nm(e,o,t.cmd)}var w8={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"]);NS(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(!y8.test(i.v)||b8.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=Nm(r,o.rest()[0],e);ib(o,"tag add",["loop"]);let m=o.choice("loop",LA,"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 ib(o,"tag remove",[]),{text:`tag remove ${i.v}`,op:le(u=>{u.tags=u.tags.filter(m=>m.name!==i.v)})};ib(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",LA,"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 FA(e){if(!Lr.includes(e.v))throw new O(e.line,e.col,`view: '${e.v}' is not a direction (${Lr.join(", ")})`);return e.v}var v8={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"]);NS(o,"view");let n=o.take("word","a direction, or remove");if(n.v==="remove"){let u=o.take("word","a direction");o.done(),ib(o,"view remove",[]);let m=FA(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=FA(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(!Lr.includes(a.value))throw new O(a.line,a.vcol,`mirror= must be a direction (${Lr.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(pm(i)!==l.name)throw new O(a.line,a.vcol,`view ${i} faces the other way from ${pm(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;hm(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 $8(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 x8(e,t,r){for(let o=r.from-1;o<r.to;o++){let n=yi(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 _8={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"]);NS(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=Nm(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>)");x8(r,e,i);let s=$8(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())}})}}},k8={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]]})}}},S8={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[w8,v8,_8,k8,S8])Te(e);function z8(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 WA(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 Ms(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 Vt(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 Cc=(e,t)=>e.layers.findIndex(r=>r.name===t);function ZA(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 BA(e,t,r,o){let n=e.opts.get("from"),i=mt(r),s=et(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:Om(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)`);Ms(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=ce=>ce==="outside"||ce==="inside"?ce:F.palette.entries[ce].name;for(let ce of L.bands)if(typeof ce.fill=="number"&&!t.palette.entries.some(pe=>pe.name===A(ce.fill)))throw new O(n.line,n.vcol,`family band: '${n.value}' uses ${A(ce.fill)}, which palette '${t.palette.name}' does not have`);let z=`${L.bands.map(ce=>`${ce.w}:${A(ce.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}`:""}`,I=M.detached,C=Math.min(F.frameCount,t.frameCount),U=Cc(F,Pc),H=new Set(I),Y=mt(M),X=new Set(s.variants.map((ce,pe)=>s.sources[pe]&&!H.has(ce.name)?`${Y.cells[pe][0]},${Y.cells[pe][1]}`:"").filter(Boolean)),fe=(ce,pe,Pe)=>U>=0?F.cels[U][ce][Pe*F.width+pe]:65535,ye=[];for(let ce=0;ce<i.mapRow;ce++)for(let pe=0;pe<l/a;pe++){if(X.has(`${pe},${ce}`))continue;let Pe=!1;for(let Je=0;Je<C&&!Pe;Je++)for(let Ze=0;Ze<a&&!Pe;Ze++)for(let Ye=0;Ye<a;Ye++)if(fe(Je,pe*a+Ye,ce*a+Ze)!==65535){Pe=!0;break}Pe&&ye.push([pe,ce])}let W=[];for(let ce=0;ce<C;ce++)for(let pe=0;pe<a;pe++){let Pe="";for(let[Je,Ze]of ye)for(let Ye=0;Ye<a;Ye++){let Qe=fe(ce,Je*a+Ye,Ze*a+pe);if(Qe===65535){Pe+=".";continue}let Ct=t.palette.entries.findIndex(vt=>vt.name===F.palette.entries[Qe].name);if(Ct<0)throw new O(n.line,n.vcol,`family band: '${n.value}' uses ${F.palette.entries[Qe].name}, which palette '${t.palette.name}' does not have`);Pe+=u.get(Ct)}W.push(Pe)}let ee=`band from=${n.value} ${z} detached=${I.length?I.join(","):"none"} frames=${C} cells=${ye.length?ye.map(([ce,pe])=>f(ce,pe)).join(","):"none"}${ye.length?` <<
145
+ ${Jt(W)}>>`:""}`,re=pn(`family ${ee}`);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"),BA(de,t,r,o)}Ms(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]:Pt(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=Vt(e,"radius",0,b,0),w=Vt(e,"inset",0,b-1,0),k=e.opts.get("fillet")?Vt(e,"fillet",1,b,1):void 0,_=Vt(e,"jitter",0,b,0),$=_?Vt(e,"seed",1,2147483647,1):0,x=e.opts.get("detached")?.value??"none",S=x==="none"?[]:x.split(",");for(let F of S)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 R=Vt(e,"frames",1,t.frameCount,1),P=e.opts.get("cells"),j=[];if(P&&P.value!=="none")for(let F of P.value.split(",")){let M=p(F);if(!M)throw new O(P.line,P.vcol,`family band from=: '${F}' is not a cell of the sheet (a variant, inside, outside or <cx>:<cy>)`);j.push(M)}let N=P?j.length*a:l,T=P?j.length?R*a:0:R*c,q=d?.rows??[];if(q.length!==T||q.some(F=>F.text.length!==N)){let F=d??P;throw new O(F.line,F.col,`family band from=: the rows must be ${R} frame${R===1?"":"s"} of ${N}x${P?a:c}${P?` (the ${j.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,...k!==void 0?{fillet:k}:{},..._?{jitter:{px:_,seed:$}}:{}};return{text:`band from=${n.value} ${g.join(" ")} radius=${y} inset=${w}${k!==void 0?` fillet=${k}`:""}${_?` jitter=${_} seed=${$}`:""} detached=${x} frames=${R}${P?` cells=${P.value}`:""}${q.length?` <<
146
+ ${Jt(q.map(F=>F.text))}>>`:""}`,run:F=>{let M=F.family;M.geometry=V,M.detached=s.variants.map(z=>z.name).filter(z=>S.includes(z));let L=Cc(F,Pc);if(L<0)return;let A=new Set;for(let z=0;z<R;z++){let I=F.cels[L][z];if(!A.has(I)){if(A.add(I),!P){for(let C=0;C<c;C++)for(let U=0;U<l;U++)I[C*l+U]=D[z*c+C][U];continue}I.fill(65535,0,c*l),j.forEach(([C,U],H)=>{for(let Y=0;Y<a;Y++)for(let X=0;X<a;X++)I[(U*a+Y)*l+C*a+X]=D[z*a+Y][H*a+X]})}}}}}function R8(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 k,_;if(w[2]==="outside"||w[2]==="inside")k=w[2],_=w[2];else{let $=Pt(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)");k=$.index,_=$.name}i.push({w:v,fill:k}),s.push(`${v}:${_}`)}let a=!!et(r).fillets;Ms(e,"family band",a?["radius","inset","draw","fillet","jitter","seed"]:["radius","inset","draw","jitter","seed"]);let c=r.tile/2,l=Vt(e,"radius",0,c,0),u=Vt(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?Vt(e,"fillet",1,c,r.geometry.fillet??Math.min(c,d||1)):void 0,p=Vt(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")?Vt(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=Cc(b,Pc);if(!m||w<0)return;let v=et(y),k=y.tile,_=mt(y),$=So(v,k,g),x=v.pieces.map(R=>v.byName.get(R)).filter(R=>!bi(v.variants[R].on)),S=new Set;for(let R of b.cels[w])if(!S.has(R)){S.add(R);for(let P of x){let[j,N]=_.cells[P];for(let T=0;T<k;T++)for(let q=0;q<k;q++){let Z=$[P][T*k+q],D=Z>=0&&Z<i.length?i[Z].fill:"inside";R[(N*k+T)*b.width+j*k+q]=typeof D=="number"?D:65535}}}}}}function I8(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(),Ms(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=Vt(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=Vt(e,"frame",1,h.frameCount,1);let g=be(h,u-1),b=h.palette.entries.map(w=>{let v=t.palette.entries.findIndex(k=>k.name===w.name);return v<0&&(v=t.palette.entries.findIndex(k=>k.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},(k,_)=>{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]=Om(r,n.v);return{text:`texture ${n.v}${a?` from=${a.value} frame=${u}`:""} <<
147
+ ${Jt(l)}>>`,run:(h,g)=>{let b=Cc(h,Ss);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 P8={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}=z8(e,t),n=new we(e,["radius","inset","fillet","jitter","draw","from","frame","seed","copies","fill","textures","detached","frames","cells"]);WA(n);let i=n.take("word","band, texture, detach, attach, coverage or cut"),s=et(o);if(i.v==="band"&&n.opts.get("from")){let a=BA(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=R8(n,r,o,t);return{text:`family ${a.text}`,op:le(c=>a.run(c))}}if(i.v==="texture"){let a=I8(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(),Ms(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(),Ms(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")?Vt(n,"seed",1,2147483647,1):t.newSeed(),l=Vt(n,"copies",1,8,1),u=n.choice("fill",["on","off"],"off")==="on",m=Gy(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=Cc(d,"template");g<0&&(d.layers.unshift(qr("template",{reference:!0})),d.cels.unshift(Array.from({length:d.frameCount},()=>new Uint16Array(d.width*d.height).fill(65535))),kr(d,v=>v+1,v=>v),g=0);let b=Cc(d,Ss),y=So(s,h,f.geometry),w=f.geometry;for(let v=0;v<d.frameCount;v++){let k=ZA(d,v,p.inside[0],p.inside[1],h),_=ZA(d,v,p.outside[0],p.outside[1],h),$=zo(d,m,v),x=d.cels[g][v];if($.variants.forEach((S,R)=>{let P=R%f.mapCols,j=p.mapRow+Math.floor(R/f.mapCols);for(let N=0;N<h;N++)for(let T=0;T<h;T++){let q=S===null?-1:y[S][N*h+T],Z=q>=0&&q<w.bands.length?w.bands[q].fill:null,D=typeof Z=="number"?Z:q<0||Z==="outside"?_:k;x[(j*h+N)*d.width+P*h+T]=D}}),u&&b>=0){let S=d.cels[b][v];for(let R=0;R<$.h;R++)for(let P=0;P<$.w;P++)S[(p.mapRow*h+R)*d.width+P]=$.px[R*$.w+P]}}})}}if(i.v==="cut"){if(n.done(),Ms(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=As(s,c),u=$o(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=>{iA(m,a)})}}throw new O(i.line,i.col,"family: expected band, texture, detach, attach, coverage or cut")}},j8=/^(-?\d+),(-?\d+)$/,E8={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"]);WA(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",[...gT],i.mode),a=o.choice("on",["outside","inside","all"],i.on),c=i.anchor,l=o.opts.get("anchor");if(l){let g=j8.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=Vt(o,"every",1,1e3,i.every),f=Vt(o,"rest",0,1e5,i.rest),p=Vt(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[P8,E8])Te(e);function Ds(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 Ii(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 LS(e,t,r){let o=e.opts.get("layer");if(o)return Ii(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 Um(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 FS=(e,t)=>{let r=e.opts.get("seed");return r?Um(r,1,2147483647):t.newSeed()},Ac=(e,t,r)=>t>=0&&r>=0&&t<e.width&&r<e.height,MS=["rect","ellipse","brush","fill","paint","clear"],T8={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=Ds(e,t),o=new we(e,["size"],["erase"]),n=o.take("word","a terrain layer"),i=Ii(r,n,["terrain"]),s=o.take("word",MS.join(", "));if(!MS.includes(s.v))throw new O(s.line,s.col,`terrain: expected ${MS.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"?_o(f.x,f.y,p.w,p.h,!0):vi(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?Um(l,1,32):1,h=-Math.floor((p-1)/2);for(let[g,b]of _c(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(ir).join(" ")} size=${p}`}else if(s.v==="fill"){let f=o.take("point","a start x,y");if(o.done(),!Ac(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=>ky({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)Ac(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)Ac(f,h,g)&&(p[g*f.width+h]=c)})}}};function KA(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 qS(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=Un(c);return{cols:l.cols,rows:l.rows,anchor:l.anchor}}function XA(e){return`cells=${e.cols}x${e.rows} anchor=${e.anchor[0]},${e.anchor[1]}`}function Oc(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 YA(e,t,r,o,n,i,s){let a=Wr({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}=Sc(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 C8={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=Ds(e,t),o=new we(e,["layer","cells","anchor"]),n=o.take("word","an asset name"),i=KA(n),s=o.take("point","the cell x,y for its anchor");o.done();let a=LS(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=qS(o,t,i.name,i.variant,n,c);YA(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} ${XA(l)}`,op:le(m=>{m.cels[a][0][s.y*m.width+s.x]=Oc(m,u)})}}};function QA(e,t,r,o){let n=e.opts.get("layer"),i=n?[LS(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}=Sc(t,s),l=Ac(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 A8={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=Ds(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=QA(o,r,t.by,n);return YA(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})}}},O8={name:"remove",summary:"remove <x,y> [layer=<layer>] (takes away what is placed on that cell)",normalise(e,t){let r=Ds(e,t),o=new we(e,["layer"]),n=o.take("point","a cell x,y with something placed on it");o.done();let i=QA(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 HA(e){let t=e.layers.find(r=>r.name==="band");t&&(t.locked=!1)}function N8(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,k=m(v,u)??m(v,_=>_.weight);return s.set(d,k.name),l.set(k.name,l.get(k.name)+1),k.name})}var M8={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=Ds(e,t),o=new we(e,["cells","anchor","mix","seed","variants"],["replace"]),n=o.take("word","a tiles layer"),i=Ii(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?KA(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"),S=o.take("size","a size WxH");if(S.w<1||S.h<1)throw new O(S.line,S.col,"tiles fill: the box must be at least 1x1");u={x:x.x,y:x.y,w:S.w,h:S.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?Yy(a):null,p=f?d?.value==="named"?f:Xy(f,t):null,h=qS(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 S=qS(o,t,x.name,null,a,"tiles"),R=t.asset?.(x.name);if(S.cols!==1||S.rows!==1||R&&R.kind!=="tile")throw new O(a.line,a.vcol,`mix= takes one-cell tiles; '${x.name}' is ${R&&R.kind!=="tile"?`a ${R.kind}`:`${S.cols}x${S.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}=Sc(r,i),y=[];for(let x=Math.max(0,u.y);x<Math.min(r.height,u.y+u.h);x++)for(let S=Math.max(0,u.x);S<Math.min(r.width,u.x+u.w);S++){let R=g[x*r.width+S];if(R<0){y.push(x*r.width+S);continue}let P=b[R],j=r.map.entries[P.entry];m&&j.cols===1&&j.rows===1&&P.x===S&&P.y===x&&y.push(x*r.width+S)}let w=`${u.x},${u.y} ${u.w}x${u.h} ${XA(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(S=>{let R=Oc(S,x),P=S.cels[i][0];for(let j of y)P[j]=R})}}let v=FS(o,t),k=new Set(y),_=x=>{if(x<0||k.has(x))return null;let S=g[x];return S<0?null:r.map.entries[b[S].entry].name},$=N8(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 S=new Map,R=j=>S.get(j)??S.set(j,Oc(x,{name:j,variant:null,...h,exact:!0})).get(j),P=x.cels[i][0];y.forEach((j,N)=>{P[j]=R($[N])})})}}};function VS(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 D8={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=Ds(e,t),o=new we(e,["width"]),n=o.take("word","a terrain layer (a path family)"),i=Ii(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?Um(a,1,8):1,l=VS(s);return{text:`road ${n.v} ${s.map(ir).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++)Ac(u,d+h,f+p)&&(m[(f+p)*u.width+d+h]=1)})}}},eO=/^(\d+)x(\d+):(\d+),(\d+)$/;function q8(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 j of i)if(!/^[a-z][a-z0-9_-]*$/.test(j))throw new O(n.line,n.col,`'${j}' 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=LS(o,r,t.by),c=o.opts.get("count");if(!c)throw new O(e.line,e.col,"scatter: missing count=<n>");let l=Um(c,1,1e4),u=o.opts.get("minDist"),m=u?Um(u,0,512):1,d=o.opts.get("on"),f=d?Ii(r,{v:d.value,line:d.line,col:d.vcol},["terrain"]):-1,p=o.opts.get("off"),h=p?Ii(r,{v:p.value,line:p.line,col:p.vcol},["terrain"]):-1,g=o.opts.get("fp"),b;if(g){let j=g.value.split("/");if(j.length!==i.length)throw new O(g.line,g.vcol,"fp= needs one footprint per asset, like 2x2:0,1/1x1:0,0");b=j.map(N=>{let T=eO.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(j=>{let N=t.asset?.(j);if(!N)throw new O(n.line,n.col,`no asset '${j}' to scatter`);let T=Un(N);return{cols:T.cols,rows:T.rows,anchor:T.anchor}});let y=FS(o,t),w=s?s.p.x:0,v=s?s.p.y:0,k=s?s.s.w:r.width,_=s?s.s.h:r.height,$=new dt(y,23719),x={...r,cels:r.cels.map((j,N)=>N===a?[j[0].slice()]:j),map:{tile:r.map.tile,entries:r.map.entries.map(j=>({...j}))}},S=f>=0?r.cels[f][0]:null,R=h>=0?r.cels[h][0]:null,P=[];for(let j=0;P.length<l&&j<l*40;j++){let N=$.nextInt(i.length),T=b[N],q=w+$.nextInt(k),Z=v+$.nextInt(_),D=Wr({name:i[N],variant:null,...T},q,Z);if(D.x<w||D.y<v||D.x+D.w>w+k||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(S&&S[M*r.width+L]!==1||R&&R[M*r.width+L]===1){V=!1;break}if(!V||P.some(M=>Math.max(Math.abs(M.x-q),Math.abs(M.y-Z))<m))continue;let{grid:F}=Sc(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]=Oc(x,{name:i[N],variant:null,...T}),P.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(j=>`${j.cols}x${j.rows}:${j.anchor[0]},${j.anchor[1]}`).join("/")} seed=${y}`,op:le(j=>{for(let N of P)j.cels[a][0][N.y*j.width+N.x]=Oc(j,{name:i[N.k],variant:null,...b[N.k]})})}}function ZS(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 JA(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 U8(e,t,r,o=2){let n=JA(e,t,4,r),i=JA(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 ZS(s,e,t,2,!0),s}function US(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 DS=["island","village","dungeon"];function WS(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,k,_])=>b<w+k+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,k,_]=f[p];for(let[$,x]of VS([[h+(b>>1),g+(y>>1)],[w+(k>>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=U8(t,r,i,e==="village"?1:2);if(e==="island")return[s,...Array.from({length:n-1},()=>new Uint8Array(t*r))];let a=US(s,t,r,2);ZS(a,t,r,1,!0);let c=new Uint8Array(t*r),l=US(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 L8(e,t,r,o){let[n,i,s]=WS(e,t,r,o,3);return e==="village"?i.map((a,c)=>a&&!s[c]?1:0):US(n,t,r,1)}var F8=/^([a-z][a-z0-9_-]*)(?::(\d+))?$/;function V8(e,t,r,o,n){let i=new dt(n,2846),s=e.width,a=e.height,c=new Uint8Array(s*a),{grid:l}=Sc(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=Wr({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 k=y.x-1;k<=y.x+y.w;k++){let _=k>=y.x&&k<y.x+y.w&&v>=y.y&&v<y.y+y.h;if(_&&(!o[v*s+k]||c[v*s+k])){w=!1;break}if(!_&&Ac(e,k,v)&&c[v*s+k]){w=!1;break}}if(w){for(let v=y.y;v<y.y+y.h;v++)for(let k=y.x;k<y.x+y.w;k++)c[v*s+k]=1;m.push({x:g,y:b,k:f});break}}return m}var Z8={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=Ds(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",DS.join(", "));if(!DS.includes(i.v))throw new O(i.line,i.col,`map gen: expected ${DS.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(_=>Ii(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 $=F8.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 S=t.asset?.(x);return!!S&&!S.map&&!S.family&&!S.overlay}).map(x=>({name:x,count:1})))}let f=FS(o,t),p=WS(i.v,r.width,r.height,f,l.length),h=_=>l.forEach(($,x)=>{_.cels[$][0].set(Uint16Array.from(p[x],S=>S?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=Ii(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=eO.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=Un($);return{cols:x.cols,rows:x.rows,anchor:x.anchor}});let v=d.map((_,$)=>({..._,fp:w[$]})),k=V8(r,b,v,L8(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 k)_.cels[b][0][$.y*_.width+$.x]=Oc(_,{name:v[$.k].name,variant:null,...v[$.k].fp})})}}},W8=new Set([".","b","r","x"]),B8={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]=Hr(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(!W8.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]}})}}},H8={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,HA(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,HA(s))})}}};for(let e of[T8,M8,C8,A8,O8,D8,Z8,B8,H8])Te(e);var GA=Kr.get("scatter");Te({name:"scatter",summary:`${GA.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?q8(e,t,t.doc):GA.normalise(e,t)}});var J8={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 S of["from","blob"])if(o.opts.get(S))throw new O(o.opts.get(S).line,o.opts.get(S).col,`import: asset= takes no ${S}=`);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?jy(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:k}=b;if(v<1||k<1||y+v>h.width||w+k>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(S=>S.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:k},(S,R)=>Array.from({length:v},(P,j)=>{let N=x[(w+R)*h.width+y+j];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${k}`}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
+ ${Jt(l)}>>`,op:le((h,g)=>{let b=Me(h,g),y=h.cels[b.layer][b.frame];d.forEach((w,v)=>{let k=n.y+v;if(!(k<0||k>=h.height))for(let _=0;_<f;_++){let $=n.x+_;$<0||$>=h.width||(y[k*h.width+$]=w[_]??65535)}})})}}};function BS(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 G8(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,Em(s,r,o,t)).get(s))});for(let n of Object.values(e.stamps))n.px=Em(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 K8={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=>G8(i,n.v))}}},X8={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=Mt(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[J8,K8,X8])Te(e);var Y8={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:vc(a)}]})}}};Te(Y8);function tO(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 Q8(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 e9={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=tO(e,Be(e,t)),o=new we(e,["advance"]),n=Q8(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: ${wo(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 ${wo(n)}${l!==null?` advance=${l}`:""}${s?` <<
153
+ ${Jt(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]=dy(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)})}}},t9={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=tO(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})})}}},n9={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=${Uk.join("|")}`);let n=o.choice("mode",[...Uk],"full");return{text:`icon mode=${n}`,op:le(i=>{i.iconMode=n})}}};for(let e of[e9,t9,n9])Te(e);var ft=class extends Error{},r9=[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],o9=[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],i9=[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],s9=[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],a9=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function Lm(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 c9(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=Lm(u,288),d=Lm(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[a9[$]]=c(3);let k=Lm(v,19),_=new Uint8Array(b+y);for(let $=0;$<b+y;){let x=l(k);if(x<16)_[$++]=x;else{let S=0,R=0;if(x===16){if(!$)throw new ft("bad compressed data (repeat with nothing before)");R=_[$-1],S=3+c(2)}else x===17?S=3+c(3):S=11+c(7);if($+S>b+y)throw new ft("bad compressed data (too many lengths)");_.fill(R,$,$+S),$+=S}}h=Lm(_.subarray(0,b),b),g=Lm(_.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=r9[y]+c(o9[y]),v=l(g);if(v>=30)throw new ft("bad compressed data (distance code)");let k=i9[v]+c(s9[v]);if(k>s)throw new ft("bad compressed data (distance too far back)");a(w);for(let _=0;_<w;_++,s++)i[s]=i[s-k]}}else throw new ft("bad compressed data (block type 3)");if(f)return i.slice(0,s)}}function GS(e){if(e.length<2||(e[0]&15)!==8||(e[0]<<8|e[1])%31)throw new ft("not zlib data");return c9(e,2)}var HS=(e,t)=>(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0;function Xr(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 $=HS(e,r),x=String.fromCharCode(e[r+4],e[r+5],e[r+6],e[r+7]),S=e.subarray(r+8,r+8+$);if(S.length<$)throw new ft(`PNG chunk ${x} is cut short`);if(x==="IHDR")o=HS(S,0),n=HS(S,4),i=S[8],s=S[9],a=S[12];else if(x==="PLTE")c=S;else if(x==="tRNS")l=S;else if(x==="IDAT")u.push(S);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=GS(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 S=8/i,R=$[Math.floor(x/S)],P=8-i*(x%S+1);return R>>P&(1<<i)-1},k=$=>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)],S=p.subarray($*(g+1)+1,($+1)*(g+1));for(let R=0;R<g;R++){let P=R>=h?b[R-h]:0,j=y[R],N=R>=h?y[R-h]:0,T=S[R];if(x===1)T+=P;else if(x===2)T+=j;else if(x===3)T+=P+j>>1;else if(x===4){let q=P+j-N,Z=Math.abs(q-P),D=Math.abs(q-j),V=Math.abs(q-N);T+=Z<=D&&Z<=V?P:D<=V?j:N}else if(x!==0)throw new ft(`PNG filter ${x} is not known`);b[R]=T&255}for(let R=0;R<o;R++){let P=($*o+R)*4,j,N,T,q=255;if(s===3){let Z=v(b,R);j=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[R*m*2]<<8|b[R*m*2+1]:v(b,R*m);j=N=T=k(v(b,R*m)),s===4?q=v(b,R*m+1):_(0)===Z&&(q=0)}else j=v(b,R*m),N=v(b,R*m+1),T=v(b,R*m+2),s===6?q=v(b,R*m+3):l&&i===8&&l[1]===j&&l[3]===N&&l[5]===T&&(q=0);w[P]=j,w[P+1]=N,w[P+2]=T,w[P+3]=q}y.set(b)}return{width:o,height:n,data:w}}var nO=128;function l9(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 ar(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]<nO){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,k],_)=>{let $=l9(u,m,d,w,v,k);$<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 JS=e=>e.toString(16).padStart(2,"0");function rO(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]<nO)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=xs(i.length),a=i.map((c,l)=>({key:s[l],name:`c${l}`,hex:`#${JS(c>>16)}${JS(c>>8&255)}${JS(c&255)}`}));return $s({name:e,entries:a,ramps:{}})}function KS(e,t){return e.entries.map(r=>r.role&&t?.[r.role]?t[r.role]:r.hex)}function sb(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 Po(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 Fm=.8,Vm=.85;function sO(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 XS(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 oO(e,t,r){let o=sO(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,...XS(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=XS(o,h,i);g.m>p.m&&(p={p:h,...g})}return{pitch:p.p,offset:p.o,score:p.m}}function iO(e,t,r){let o=sO(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=XS(o,r,n);return{pitch:r,offset:s.o,score:s.m}}function u9(e,t,r){if(r){let c=iO(e,"x",e.width/r.cols),l=iO(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=oO(e,"x",t?.x),n=oO(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 m9(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 d9(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,k=v+g.pitch,_=Math.ceil(v+g.pitch*w),$=Math.floor(k-g.pitch*w-1e-9);return _=Math.max(0,_),$=Math.min(y-1,$),$<_&&(_=$=Math.min(y-1,Math.max(0,Math.floor((v+k)/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,k]=s(t.y,t.j0+g,o,.25),_=[[],[],[],[]];for(let $=v;$<=k;$++)for(let x=y;x<=w;x++)for(let S=0;S<4;S++)_[S].push(n[($*r+x)*4+S]);for(let $=0;$<4;$++)i.data[(g*t.cols+b)*4+$]=Math.round(m9(_[$]))}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 k=n[w+v];p+=(k-f[v]/d)**2,h+=(k-a[y*3+v]/c[y])**2}}return{img:i,r2:p>0?1-h/p:1}}function f9(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 aO(e,t,r={}){let o=u9(e,r.hint,r.cells),{img:n,r2:i}=d9(e,o),s=ar(n,t),a=r.layout?f9(n,r.layout):null,c=[];return i<Fm&&c.push(`block R\xB2 ${i.toFixed(2)} is below ${Fm}`),a!==null&&a<Vm&&c.push(`material match ${a.toFixed(2)} is below ${Vm}`),{fit:o,px:s.px,r2:i,material:a,inexact:s.inexact,worst:s.worst,reroll:c}}var dO=/^[a-z][a-z0-9_-]*$/,cO=/^[0-9a-f]{64}$/,p9=/^(\d+)x(\d+)$/,lO=["from","prompt","provider","model","quality","cost"];function fO(e,t,r,o){e.layers.splice(t,0,qr(r,o)),e.cels.splice(t,0,Array.from({length:e.frameCount},()=>new Uint16Array(e.width*e.height).fill(65535))),kr(e,n=>n>=t?n+1:n,n=>n)}function uO(e,t){let r=p9.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 pO(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 mO(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 h9={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"&&mO(e,"generate"),o?.t==="word"&&o.v==="import"&&mO(e,"import");let n=new we(e,["blob","image","at","size","layout",...lO]),i=n.take("word","a layer name (or generate / import)");if(n.done(),!dO.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(!cO.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]=uO(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")?pO(n.opts.get("at")):[0,0],[d,f]=n.opts.get("size")?uO(n.opts.get("size"),"size="):[r.width,r.height],p=n.opts.get("layout");if(p&&!cO.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=lO.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&&(fO(y,0,i.v,{reference:!0}),w=0),y.layers[w]={...y.layers[w],underlay:g}})}}},g9={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(!dO.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")?pO(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=aO(y,r.palette,{hint:{x:d.iw/d.w,y:d.ih/d.h},...l?{}:{cells:{cols:d.w,rows:d.h}},layout:w}),k=r.palette.entries.map(x=>x.key);p=Array.from({length:v.fit.rows},(x,S)=>Array.from({length:v.fit.cols},(R,P)=>{let j=v.px[S*v.fit.cols+P];return j===65535?".":k[j]}).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
+ ${Jt(p)}>>`,op:le(y=>{fO(y,y.layers.length,m,{});let w=y.cels[y.layers.length-1];for(let v of w)b.forEach((k,_)=>k.forEach(($,x)=>{let S=h[0]+x,R=h[1]+_;S>=0&&R>=0&&S<y.width&&R<y.height&&(v[R*y.width+S]=$)}))})}}};for(let e of[h9,g9])Te(e);function YS(){return[...Kr.values()].map(e=>e.summary).join(`
155
+ `)}var QS=/^(?:undo|redo) group=(\S+)$/;function e1(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=QS.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 qs(e){let t=e1(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 y9(e){return e==="human"||e.startsWith("human:")?"h":"g"}function b9(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 w9(e,t,r=null,o){let n=e1(e).filter(s=>s.id!==o),i=qs(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 v9(e,t,r=null,o){let n=e1(e).filter(c=>c.id!==o),i=new Map(n.map(c=>[c.id,c])),s=qs(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 $9=/^note .* id=n(\d+)$/;function x9(e){let t=0;for(let r of e){let o=$9.exec(r.cmd);o&&(t=Math.max(t,Number(o[1])))}return`n${t+1}`}function t1(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:()=>by(new dt(n,wy(e?.name??"doc"))),undoTarget:(u,m)=>w9(t,u,m??null,r),redoTarget:(u,m)=>v9(t,u,m??null,r),noteId:()=>x9(t)}}var Pi=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)&&!QS.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,qs(t)),doc:r?Ur(r):null}))}get size(){return this.snaps.length}replay(t,r){let o=qs(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?Ur(n.doc):null;for(let s=n.n;s<t.length;s++){let a=t[s];if(o.has(a.group)&&!QS.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=Ri(l[0],t1(i,[],a.group,r,a.seq,a.by));i=Os(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?Ur(i):null}))}return i}};function hO(e,t,r){return(r??new Pi).replay(e,t)}function _9(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 n1(e,t,r){let{commands:o,errors:n}=pn(t),i=e.doc?Ur(e.doc):null,s=[...e.entries],a=e.cache??new Pi,c=b9(e.entries,y9(r.by)),l=(e.entries[e.entries.length-1]?.seq??0)+1,u=[],m=[];for(let d of o)try{let f=Ri(d,t1(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"?hO(s,r.palettes,a):Os(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:_9(e.doc,i),saves:m}}var ji=class e{doc=null;done=[];palettes;cache=new Pi;constructor(t){this.palettes=t}static resume(t,r,o){let n=new e(t);return n.doc=r?Ur(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=t1(this.doc,this.done,t.group,this.palettes,t.seq,t.by),i=Ri(r[0],n);return i.text!==t.cmd&&gO(t.cmd)&&(i=Ri(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"?hO(this.done,this.palettes,this.cache):Os(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}}},Nc=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=ji.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?Ur(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?Ur(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 Zm(e,t){let r=new ji(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 gO=e=>e.startsWith("new ")&&!e.includes(`
156
+ `);function Rr(e){return e[0]&&gO(e[0].cmd)?1:zr}function k9(e=zr){return JSON.stringify({pclaw:"tape",lang:e})}function r1(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 ab(e){return[k9(Rr(e)),...e.map(r1)].join(`
157
+ `)+`
158
+ `}function yO(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!==zr)throw new Error(`tape language version ${r.lang} is not supported (this build reads 1 and ${zr})`);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&&Rr(o)!==r.lang)throw new Error(`tape header says language ${r.lang} but its first line is written in language ${Rr(o)}`);return o}function bO(e,t){if(!e.length||Rr(e)===zr)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=Ri(o[0],{lang:zr,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 S9(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 wO(e){let t=Object.entries(e??{}).map(([r,o])=>MT(r,o??{}));return[...NT.filter(r=>!t.some(o=>o.name===r.name)),...t]}function jo(e,t=24){let r=e?.drawScale;return typeof r=="number"&&Number.isInteger(r)&&r>=1&&r<=16?r:t>=48?1:2}function Eo(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 Us(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 Wm(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 vO(e,t,r,o,n,i={}){let{style:s,problems:a}=S9(o,n);i.setChecks&&(s.checks=z9(s.checks??{},i.setChecks));let c=Us(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:Wm(e,t,r,o,i.set).map(u=>({name:u.name,doc:u.doc})),...t.map||t.variantOf||t.densityOf?{world:Ln(r)}:{},peers:(i.peers?r.filter(u=>i.peers.includes(u.name)&&cb(u.doc)===cb(t)):I9(e,t,r)).map(u=>({name:u.name,doc:u.doc})),...i.expect?{expect:i.expect}:{}},problems:a}}function z9(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 R9=e=>!e.wrap&&!e.family&&!e.overlay&&!e.map&&!e.font&&e.kind!=="icon";function I9(e,t,r){let o=cb(t);return o==="other"?[]:r.filter(n=>n.name!==e&&cb(n.doc)===o&&!n.doc.densityOf&&!t.densityOf)}function cb(e){return e.wrap&&!e.family?"tile":R9(e)?"figure":e.kind==="icon"?"icon":"other"}var o1=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 P9(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 Ls(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 o1;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),P9(c,h,Math.max(2,a))}),c.push(59),c.done()}var i1=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=ly(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)}},s1=(e,t)=>Math.max(1,Math.round(e*1e3/t)),a1=(e,t)=>Math.max(1,Math.round(e*t/1e3));function c1(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 i1;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(s1(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(Kk(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 Bm(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=Lk(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,k={ms:y,cels:[]};for(let _=0;_<v;_++){let $=t,x=i(),S=o();if(S===8196){let R=o(),P=o();o(),o(),o(),o(),r(),t+=3;let j=s();d.layers.push({name:j,visible:!!(R&1),reference:!!(R&64),type:P}),P===2&&i()}else if(S===8197){let R=o(),P=n(),j=n();r();let N=o();if(n(),t+=5,N===1)k.cels.push({layer:R,x:P,y:j,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):GS(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);k.cels.push({layer:R,x:P,y:j,w:T,h:q,px:D})}}else if(S===8217){let R=i(),P=i(),j=i();for(t+=8;d.palette.length<R;)d.palette.push({r:0,g:0,b:0,a:255});for(let N=P;N<=j;N++){let T=o(),q={r:r(),g:r(),b:r(),a:r()};T&1&&(q.name=s()),d.palette[N]=q}}else if((S===4||S===17)&&!d.palette.length){let R=o(),P=0;for(let j=0;j<R;j++){P+=r();let N=r();N===0&&(N=256);for(let T=0;T<N;T++,P++){let q=S===17?4:1;d.palette[P]={r:Math.min(255,r()*q),g:Math.min(255,r()*q),b:Math.min(255,r()*q),a:255}}}}else if(S===8216){let R=o();t+=8;for(let P=0;P<R;P++){let j=o(),N=o(),T=r();t+=12,d.tags.push({name:s(),from:j,to:N,dir:T})}}t=$+x}d.frames.push(k),t=h+g}return d}function Hm(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 k=e.palette[v]??{r:0,g:0,b:0,a:255};f[w*4]=k.r,f[w*4+1]=k.g,f[w*4+2]=k.b,f[w*4+3]=k.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 $O={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 xO={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 _O={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 kO={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 SO={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 zO={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 RO=["loose","atlas","sheet","tiled","godot","aseprite-json","aseprite"],bt=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"],EO=["sprite","x","y","w","h","cropX","cropY","frameW","frameH","pivotX","pivotY"],m1=["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"],Mc=["asset","n","view","cx","cy","variant","sides","corners","shape","name","d","page","stem"],PO=["lone","end","straight","corner","tee","cross"],N9=["ne","se","sw","nw"];function zt(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 bt(`unknown placeholder {${n}} (known: ${r.join(", ")})`);let i=t[n];if(i===void 0)throw new bt(`placeholder {${n}} has no value here`);return String(i)})}function Fs(e){let t=`profile '${e?.name??"?"}'`;if(!e||typeof e!="object")throw new bt("a profile is a JSON object");if(!/^[a-z][a-z0-9_-]*$/.test(e.name??""))throw new bt(`${t}: name uses a-z, 0-9, _ and -`);if(!RO.includes(e.layout))throw new bt(`${t}: layout must be one of ${RO.join(", ")}`);let r=e.names??{};for(let[o,n]of Object.entries(r))o!=="start"&&zt(String(n),Object.fromEntries(Mc.map(i=>[i,""])),Mc);for(let[o,n]of Object.entries(e.autotile??{})){for(let i of[n.template,...Object.values(n.names??{})])i&&zt(i,Object.fromEntries(Mc.map(s=>[s,""])),Mc);if(n.sides&&!/^(?=.*n)(?=.*e)(?=.*s)(?=.*w)[nesw]{4}$/.test(n.sides))throw new bt(`${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()!==[...N9].sort().join()||n.corners.split(",").length!==4))throw new bt(`${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(!PO.includes(i))throw new bt(`${t}: autotile.${o}.shapes.${i} is not a shape (${PO.join(", ")})`);zt(String(s),Object.fromEntries(Mc.map(a=>[a,""])),Mc)}}for(let o of Object.keys(e.roles??{}))if(!Bt.includes(o))throw new bt(`${t}: roles.${o} is not a role (${Bt.join(", ")})`);for(let[o,n]of Object.entries(e.roles??{}))if(!/^#[0-9a-fA-F]{6}$/.test(String(n)))throw new bt(`${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 bt(`${t}: colours: '${o}' is not an entry name (or <palette>.<entry>)`);if(!/^#[0-9a-fA-F]{6}$/.test(String(n))){if(!Bt.includes(String(n)))throw new bt(`${t}: colours.${o} must be #rrggbb or a role (${Bt.join(", ")})`);if(!e.roles?.[n])throw new bt(`${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 bt(`${t}: density.levels lists sizes like 1, 2, 4`);for(let o of e.records?.columns??[])if(!IO.includes(o))throw new bt(`${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 bt(`${t}: fonts.format is strip, bmfont, both or sheet`);if(e.fonts.separator&&!/^#[0-9a-fA-F]{6}$/.test(e.fonts.separator))throw new bt(`${t}: fonts.separator must be #rrggbb`);if(e.fonts.maxLine!==void 0&&(!Number.isInteger(e.fonts.maxLine)||e.fonts.maxLine<1))throw new bt(`${t}: fonts.maxLine is a line height in pixels`)}if(e.snippets)for(let o of Object.values(e.snippets.templates??{}))zt(o,Object.fromEntries(m1.map(n=>[n,""])),m1);return e}var TO=new Map([SO,_O,zO,kO,xO,$O].map(e=>[e.name,Fs(e)])),M9=e=>e.toLowerCase(),D9=(e,t)=>e.views.find(r=>r.mirror===t)?.name??null;function q9(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 U9(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 zt(s,i);if(r==="inside"||r==="outside")return`${t.name}_${r}`;let a=n?.template||n?.shapes?q9(r,n.sides,n.corners):null;if(a){let c=n.shapes?.[a.shape]??n.template;if(c)return zt(c,{...i,...a})}return`${t.name}_${r}`}var CO=e=>!e.family&&!e.map&&(e.kind==="object"||e.kind==="tile")&&(e.width>e.cellW||e.height>e.cellH||!!e.footprint);function Dc(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 db=e=>e.fonts?.format??"strip";function d1(e,t,r){if(e.kind==="icon"&&wc(e)!=="tone")return e.palette.entries.map(n=>n.hex);let o=KS(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 f1(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)!Dc(e,u)||u.map||u.font&&db(e)!=="sheet"||o&&u.variantOf&&r.has(u.variantOf)&&Dc(e,r.get(u.variantOf))||n.push([u,...o?i.filter(m=>m.variantOf===u.name&&Dc(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,k,_,$,x={})=>{let S=d(h)?g(w):null,R=S===null?y:zt(a.frame,{asset:y,n:S,stem:y});c.push({name:R,doc:f,frame:w,x:v,y:k,w:_,h:$,n:S,view:null,mirror:null,cell:null,ticks:f.ticks[w],group:m.name,...x})};if(f.family){let y=mt(f.family),w=et(f.family),v=f.family.tile,k=[["inside",y.inside],["outside",y.outside],...w.variants.map((_,$)=>[_.name,y.cells[$]])];for(let _=0;_<h;_++)for(let[$,[x,S]]of k)b(U9(e,m,$),_,x*v,S*v,v,v,{cell:$});return}if(CO(f)&&e.oversized==="split"){let[y,w]=Hr(f);for(let v=0;v<h;v++)for(let k=0;k<w;k++)for(let _=0;_<y;_++)b(zt(a.piece,{asset:m.name,cx:_,cy:k}),v,_*f.cellW,k*f.cellH,f.cellW,f.cellH,{cell:`${_}_${k}`});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 k=w-v.from,_=s+(u.length>1?p*h:0)+k;c.push({name:zt(a.view,{asset:m.name,view:M9(v.name),n:_}),doc:f,frame:w,x:0,y:0,w:f.width,h:f.height,n:_,view:v.name,mirror:y?D9(f,v.name):null,cell:null,ticks:f.ticks[w],group:m.name})}return}for(let y=0;y<h;y++)b(zt(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 bt(`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 AO(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=>Zy(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:pS(u,t.w*l,t.h*l,l/r,t.doc.palette,m,d),how:"reduced"}}return{px:Em(i(be(t.doc,t.frame),t.doc.width,1),t.w,t.h,r),how:"scaled"}}var L9=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)},F9=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},OO=e=>e.density?.levels??[1];function p1(e,t,r){let o=e.density?.plain??1;return r===o?t:t+zt(e.density?.suffix??"@{d}x",{d:r})}var V9=e=>{let t=/^(.*?)(\.[^./]+)$/.exec(e);return t?[t[1],t[2]]:[e,""]},To=(e,t,r)=>{let[o,n]=V9(t);return p1(e,o,r)+n};function Z9(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 fb(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 jO(e,t,r,o,n){let i=t.it,s=i.doc,a=CO(s)?Un(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"?wc(s):""}return null}var W9=e=>e===null?"":typeof e=="number"?String(e):/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e;function l1(e,t,r,o,n,i){let s=e.records,a=s.columns??EO;if(s.format==="csv"){let l=t.map(u=>a.map(m=>W9(jO(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=jO(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 B9(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 NO(e,t,r={}){let o=Fs(e),n=r.tickRate??60,i=b=>s1(b,n),s=new Map,a=[],c=(b,y)=>s.set(b,typeof y=="string"?L9(y):y),l=f1(o,t),u=new Map,m=b=>{let y=u.get(b);if(!y){y=d1(b,o.roles,o.colours);let w=new Map;b.palette.entries.forEach((v,k)=>{let _=y[k].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(sb(b,y,w,m(v))),f=OO(o),p=new Map,h=(b,y)=>{let w=AO(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 k=h(v,y),_=v.w*y,$=v.h*y,[x,S,R,P]=w?Z9(k,_,$):[0,0,_,$];return{it:v,px:k,x:0,y:0,w:R,h:P,cropX:x,cropY:S,frameW:_,frameH:$}});if(o.layout==="loose")for(let b of f){let y=g(l,b,!1);for(let w of y)c(To(o,zt(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(To(o,o.records.file??`sprites.${o.records.format}`,b),l1(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),[k,_]=B9(v,(o.page?.width??256)*w,b),$=new Uint16Array(k*_).fill(65535),x=sb($,k,_,[]);for(let P of v){if(!P.w)continue;let j=sb(P.px,P.frameW,P.frameH,m(P.it.doc));for(let N=0;N<P.h;N++)x.data.set(j.data.subarray(((P.cropY+N)*P.frameW+P.cropX)*4,((P.cropY+N)*P.frameW+P.cropX+P.w)*4),((P.y+N)*k+P.x)*4)}let S=To(o,zt(o.page?.file??"{page}.png",{page:y}),w);c(S,Le(x));let R=o.records??{format:"csv"};c(To(o,zt(R.file??`{page}.${R.format}`,{page:y}),w),l1({...o,records:R},v,S,w,[k,_],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,k=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)),S=Math.max(...$.map(D=>D.frameH)),R=o.page?.padding??0,P=$.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);P=$.map(F=>(Math.floor(F.it.y/v.family.tile)+F.it.frame*V)*k+Math.floor(F.it.x/v.family.tile))}let j=Math.max(...P.map(D=>Math.floor(D/k)))+1,N=k*(x+R)-R||1,T=j*(S+R)-R||1,q=new Uint16Array(N*T).fill(65535);$.forEach((D,V)=>{D.x=P[V]%k*(x+R),D.y=Math.floor(P[V]/k)*(S+R),D.w=D.frameW,D.h=D.frameH,fb(q,N,D.px,D.frameW,0,0,D.frameW,D.frameH,D.x,D.y)});let Z=To(o,zt(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(To(o,`${y}.json`,_),JSON.stringify(V,null,1)+`
163
+ `)}else o.records&&c(To(o,zt(o.records.file??`{asset}.${o.records.format}`,{asset:y,page:y}),_),l1(o,$,Z,_,[N,T],i))}}}else if(o.layout==="aseprite")for(let b of t.filter(y=>Dc(o,y)&&!y.map)){c(`${b.name}.aseprite`,c1(b,n,m(b)));for(let y of t.filter(w=>w.densityOf?.of===b.name))c(`${p1(o,b.name,y.densityOf.d)}.aseprite`,c1(y,n,KS(y.palette,o.roles)))}else o.layout==="tiled"?K9(o,t,l,c,d,i,r.world,a):X9(o,t,l,c,d,n,a);if(db(o)!=="sheet")for(let b of t.filter(y=>y.font&&Dc(o,y))){try{if(db(o)!=="bmfont"){let y=hy(b,m(b),o.fonts?.separator??Xk);c(`${b.name}.png`,Le(y.img)),c(`${b.name}.txt`,y.chars+`
164
+ `)}if(db(o)!=="strip"){let y=gy(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 bo?new bt(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,H9(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 H9(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=Un(c),m=a.map(d=>d.ticks);i.push(zt(l,{asset:s,name:a[0].name,kind:c.kind,mode:c.kind==="icon"?wc(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:""},m1))}return(n.header?n.header+`
165
+ `:"")+i.join(n.join??`
166
+ `)+(n.footer?`
167
+ `+n.footer:"")+`
168
+ `}var jn=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function J9(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 G9(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;fb(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 K9(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=G9(d,m),p=et(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 k=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="${jn(v.name)}"/>`,` <property name="variant" value="${jn(v.cell)}"/>`," </properties>",...k," </tile>")}for(let v of d.filter(k=>k.frame>0))b.push(` <tile id="${f.id.get(v)}">`," <properties>",` <property name="name" value="${jn(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="${jn(m.name)}" type="${y}" tile="-1">`,` <wangcolor name="${jn(m.name)}" color="#ff0000" tile="-1" probability="1"/>`,...p.variants.flatMap((v,k)=>v.key===null||v.on?[]:[` <wangtile tileid="${f.id.get(d.find(_=>_.cell===v.name&&_.frame===0))}" wangid="${J9(p.neighbours,v.key).join(",")}"/>`]).filter((v,k)=>k>=0)," </wangset>"," </wangsets>"]:[];o(`${m.name}.tsx`,['<?xml version="1.0" encoding="UTF-8"?>',`<tileset version="1.10" tiledversion="1.10.2" name="${jn(m.name)}" tilewidth="${h}" tileheight="${h}" tilecount="${f.cols*(f.h/h)}" columns="${f.cols}">`,` <image source="${jn(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(AO(e,d,1,t).px,d.w,d.h,d.doc)),[` <tile id="${f}">`," <properties>",` <property name="name" value="${jn(d.name)}"/>`," </properties>",` <image width="${d.w}" height="${d.h}" source="tiles/${jn(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&&Dc(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(S=>S.doc.name===_&&S.frame===$);return x<0?0:p+x},b=m.map.tile,y=m.width,w=m.height,v=[],k=1;m.layers.forEach((_,$)=>{let x=_.map;if(!x||x.kind==="overlay")return;let S={...m,layers:m.layers.map((N,T)=>({...N,hidden:T!==$}))},R=Ht(S,s);if(x.kind==="objects"){v.push(` <objectgroup id="${$+1}" name="${jn(_.name)}"${_.hidden?' visible="0"':""}>`);for(let N of R.objects.filter(T=>T.layer===$&&T.doc)){let T=m.map.entries[N.entry];v.push(` <object id="${k++}" name="${jn(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="${jn(N.fp.flags.join("/"))}"/>`," </properties>"," </object>")}v.push(" </objectgroup>");return}let P=R.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)}),j=Array.from({length:w},(N,T)=>P.slice(T*y,T*y+y).join(",")).join(`,
171
+ `);v.push(` <layer id="${$+1}" name="${jn(_.name)}" width="${y}" height="${w}"${_.hidden?' visible="0"':""}>
172
+ <data encoding="csv">
173
+ ${j}
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="${k}">`,...d.map(_=>` <tileset firstgid="${_.first}" source="${jn(_.source)}"/>`),...v,"</map>",""].join(`
176
+ `))}}var u1=[[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 X9(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=et(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)fb(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`,S=x.slice(0,-2);if(l.frameCount>1){w.push(`${S}/animation_separation = Vector2i(${f.cols-1}, 0)`);for(let j=0;j<l.frameCount;j++)w.push(`${S}/animation_frame_${j}/duration = ${(l.ticks[j]/i).toFixed(4)}`)}w.push(`${x} = 0`,`${x}/custom_data_0 = "${$.name}"`);let R=m.byName.get($.cell),P=R===void 0?null:m.variants[R];if(P&&P.key!==null&&!P.on){w.push(`${x}/terrain_set = 0`,`${x}/terrain = 0`);let j=y===1?u1.filter(([N])=>N&(pt.NE|pt.SE|pt.SW|pt.NW)):y===2?u1.filter(([N])=>N&(pt.N|pt.E|pt.S|pt.W)):u1;for(let[N,T]of j)P.key&N&&w.push(`${x}/terrains_peering_bit/${T} = 0`)}}let[v,k,_]=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)}, ${(k/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 lb=(e,t)=>{let r=e.get(t);if(!r)throw new bt(`no file '${t}'`);return F9(r)},Ei=(e,t)=>{let r=e.get(t);if(!r)throw new bt(`no image '${t}'`);return Xr(r)},ub=e=>e.includes("/")?e.slice(0,e.lastIndexOf("/")+1):"";function Y9(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 Q9(e,t){let r=e.records??{format:"csv"};if(r.format==="json")return JSON.parse(t).sprites;let o=Y9(t),n=r.header===!1?r.columns??EO:o.shift()??[];return o.map(i=>Object.fromEntries(n.map((s,a)=>[s,i[a]??""])))}function eZ(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=Po(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 mb=(e,t,r,o)=>{let n=To(e,r,o);return t.has(n)?n:null};function tZ(e,t,r){let o=Fs(e),n=[],i=[],s=OO(o),a=f1(o,r);if(o.layout==="loose"){let c=o.image??"{name}.png";for(let u of s)for(let m of a){let d=mb(o,t,zt(c,{name:m.name,asset:m.group}),u);d&&n.push({name:m.name,d:u,img:Ei(t,d)})}let l=new Set(s.flatMap(u=>a.map(m=>To(o,zt(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:Ei(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=mb(o,t,zt(l.file??`{page}.${l.format}`,{page:c}),u),d=mb(o,t,zt(o.page?.file??"{page}.png",{page:c}),u);if(!m||!d)continue;let f=Ei(t,d);for(let p of Q9({...o,records:l},lb(t,m)))n.push({name:String(p.sprite),d:u,img:eZ(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=mb(o,t,zt(o.image??"{asset}.png",{asset:c,name:c}),l);if(!u)continue;let m=Ei(t,u);for(let d of rZ(o,a.filter(f=>f.group===c),l))n.push({name:d.name,d:l,img:Po(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(lb(t,c));if(!l.meta?.image)continue;let u=Ei(t,ub(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:Po(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=lb(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?Ei(t,ub(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?Ei(t,ub(c)+y):p?Po(p,g%d*u,Math.floor(g/d)*m,u,m):null;w&&n.push({name:nZ(b),d:1,img:w})}}else if(o.layout==="godot")for(let c of[...t.keys()].sort()){if(!c.endsWith(".tres"))continue;let l=lb(t,c),u=/path="res:\/\/([^"]+)"/.exec(l)?.[1],m=/texture_region_size = Vector2i\((\d+), (\d+)\)/.exec(l);if(!u||!m)continue;let d=Ei(t,ub(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 k=v===0?p[3]:a.find(_=>w&&_.doc===w.doc&&_.cell===w.cell&&_.frame===v)?.name;k&&n.push({name:k,d:1,img:Po(d,(h+v*(Number(b?.[1]??0)+1))*f,g*f,f,f)})}}}return{images:n,notes:i}}var nZ=e=>e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");function rZ(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 MO(e,t,r){let o=Fs(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=>p1(o,y.densityOf?.of??"",y.densityOf?.d??0)===d);if(!f){i.push(`${m}: no asset named '${d}'`);continue}let p=Hm(Bm(t.get(m))),h=d1(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((k,_)=>{if(k.hidden||k.reference)return;let $=p.rgba[_][w];if(!$)return;let x=ar({width:p.width,height:p.height,data:$},f.palette,h);g+=x.inexact;for(let S=0;S<v.length;S++)x.px[S]!==65535&&(v[S]=x.px[S])}),v});n.set(f.name,{frames:b,inexact:g,images:b.length})}return{assets:n,unknown:[],notes:i}}let{images:s,notes:a}=tZ(o,t,r);i.push(...a);let c=f1(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=ar(m.img,d.doc.palette,d1(d.doc,o.roles,o.colours));h.inexact+=g.inexact,h.images++;let b=f===d.doc?g.px:Zy(g.px,d.doc.palette,f.palette),y=h.frames[Math.min(d.frame,f.frameCount-1)];if(fb(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),k=w.from+(d.frame-v.from);if(k<=w.to){let _=h.frames[k];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 DO(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 qO="pixelclaw-manifest",h1=["planned","drafted","checked","reviewed","approved","exported"],UO=["S","N","E","W"],Jm=/^[a-z][a-z0-9_-]*$/,oZ=/^(\d+)x(\d+)$/,iZ=/^#[0-9a-fA-F]{6}$/,sZ=new Set(["name","kind","size","set","description","palette","scheme","inside","outside","band","frames","ticks","views","mirror","cells","height","variantOf","recolourOf","uses","flat","chars"]),LO=new Set(["format","version","theme","sets","export","assets","scenes"]),FO=new Set(["name","description","uses","map"]);function Yr(e){let t=oZ.exec(e);return t&&Number(t[1])>0&&Number(t[2])>0?[Number(t[1]),Number(t[2])]:null}function Vs(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))LO.has(u)||o(u,`unknown field '${u}' (fields: ${[...LO].join(", ")})`);n.format!==qO&&o("format",`must be "${qO}"`),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))Jm.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))sZ.has(y)||o(d(y),`unknown field '${y}'`);(typeof f.name!="string"||!Jm.test(f.name))&&o(d("name"),"a name uses a-z, 0-9, _ and -, starting with a letter");let p=f.kind;vs.includes(p)||o(d("kind"),`one of ${vs.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"&&!Jm.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=>UO.includes(y))||new Set(f.views).size!==f.views.length)&&o(d("views"),`directions from ${UO.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 ym(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"&&!iZ.test(f.flat)&&!Jm.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))FO.has(h)||o(f(h),`unknown field '${h}' (fields: ${[...FO].join(", ")})`);if(typeof p.name!="string"||!Jm.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 ZO(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 Zs(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 WO(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 g1=[[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]],Gm=(e,t=.68)=>[Math.round(e[0]*t),Math.round(e[1]*t),Math.round(e[2]*t)];function Ir(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 aZ(e,t,r,o,n,i){Ir(e,t,r,o,1,i),Ir(e,t,r+n-1,o,1,i),Ir(e,t,r,1,n,i),Ir(e,t+o-1,r,1,n,i)}function BO(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 HO(e,t,r,o,n,i,s=0,a=0){let c=wi(t,r),l=So(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&&bi(t.variants[u].on)){i.outside&&Ir(e,d,f,o,o,i.outside);let p=t.variants[u];p.on==="face"?Ir(e,d,f,o,Math.max(1,o/2),Gm(i.band)):p.quads.forEach((h,g)=>{h!=="out"&&Ir(e,d+(g&1?o/2:0),f+(g&2?o/2:0),o/2,o/2,Gm(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&&Ir(e,d+h,f+p,1,1,y)}}),c}function cZ(e){let t=$o(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 JO(e,t){let[r,o]=t.size??cZ(e),n=null;for(let f=0;f<4&&!n;f++)n=Gy(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=BO(t.band,t.tile,t.inset??0),a=HO(i,e,n,t.tile,s,{inside:t.inside,outside:t.outside,band:Gm(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=As(e,n),d=$o(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, ${$o(e).length-d.length} of ${$o(e).length} variants
180
+
181
+ ${u.join(`
182
+ `)}
183
+ `}}function GO(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,S)=>[x.name,t.colour(x,S)])),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(S=>S.name===x.outside))?.outside??c[0]?.name??null,m=u?a.get(u):[60,60,60];Ir(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,S)=>{let R=t.scheme(x.scheme??"");if(!R)return;let P={cols:r,rows:o,cells:new Uint8Array(R.neighbours==="corners"?(r+1)*(o+1):r*o)},j=R.neighbours==="corners"?r+1:r;if(R.name==="path"||R.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<j;F++)P.cells[(F<V?Z:D)*j+F]=1;for(let F=Math.min(Z,D);F<=Math.max(Z,D);F++)P.cells[F*j+V]=1}else{let Z=Si(R,Math.ceil(r*.6),Math.ceil(o*.7),(t.seed??1)+S*7),D=R.neighbours==="corners"?Z.cols+1:Z.cols,V=S%2?r-Z.cols:0,F=S>=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<P.cells.length/j&&L+V<j&&(P.cells[(M+F)*j+L+V]=1)}let N=x.inside&&a.has(x.inside)?a.get(x.inside):a.get(x.name),T=BO(x.band,n);HO(s,R,P,n,T,{inside:N,outside:null,band:Gm(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,S)=>x.kind===S.kind?0:x.kind==="object"?-1:1),y=[];for(let x of b){let[S,R]=Yr(x.size)??[n,n],P=Math.max(1,Math.ceil(S/n)),j=Math.max(1,Math.ceil(R/n)),N=[];for(let z=0;z+j<=o;z++)for(let I=0;I+P<=r;I++){let C=!0;for(let U=-1;U<=j&&C;U++)for(let H=-1;H<=P&&C;H++){let Y=I+H,X=z+U;if(Y<0||X<0||Y>=r||X>=o)continue;(H>=0&&U>=0&&H<P&&U<j?!g[X*r+Y]:g[X*r+Y]===2)&&(C=!1)}C&&N.push(z*r+I)}if(!N.length)continue;let T=N[i.nextInt(N.length)],q=T%r,Z=Math.floor(T/r),D=x.cells?Math.min(j,Yr(x.cells)[1]):j;for(let z=0;z<j;z++)for(let I=0;I<P;I++)g[(Z+z)*r+q+I]=2,z>=j-D&&(h[(Z+z)*r+q+I]=p(x.name).toUpperCase());let V=Math.min(R,x.height??R),F=x.kind==="sprite"?Math.max(4,Math.round(S*2/3)):S,M=q*n+Math.floor((P*n-F)/2),L=(Z+j)*n-V-(x.kind==="sprite"?1:0),A=a.get(x.name);Ir(s,M,L,F,V,A),aZ(s,M,L,F,V,Gm(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 S=0;S<v.width;S++){let R=(Math.floor(x/w)*s.width+Math.floor(S/w))*4,P=(x*v.width+S)*4;v.data.set(s.data.subarray(R,R+4),P)}for(let x of y){let S=Math.max(1,w-1),R=x.name.length*4*S-S,P=Math.max(S,Math.min(v.width-R-2*S,x.x*w+Math.floor((x.w*w-R)/2))),j=Math.max(S,x.y*w-7*S);Ir(v,P-S,j-S,R+2*S,7*S,[24,24,28]),_C(v,P,j,x.name,[236,236,236],S)}let k=[...d].map(([x,S])=>b.some(R=>R.name===x)?` ${S.toUpperCase()} ${x} stands here`:` ${S} ${x}`),_=Array.from({length:o},(x,S)=>`${String(S).padStart(3)}: ${h.slice(S*r,S*r+r).join("")}`),$=[...new Set(e.assets.map(Zs))];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
+ ${k.join(`
189
+ `)}
190
+ `}}var KO=["draw","change","new"];var lZ=/^r\d+$/,uZ=/^[a-z][a-z0-9_-]*$/;function Km(e,t){if(!t||typeof t!="object"||typeof t.id!="string"||!lZ.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"||!uZ.test(t.asset)?"a request names an asset (a-z, 0-9, _ and -)":KO.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 ${KO.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"seen":return o(r.state==="open","only an open request is handed to an agent")??(r.seen.some(n=>n.by===t.by)?`${t.by} has seen ${t.id} already`:null);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 mZ(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,seen:[],events:[]});return}let r=e.get(t.id);if(t.type==="seen"){r.seen.push({by:t.by,at:t.at});return}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,r.seen=[];break;case"cancel":r.state="cancelled";break}}function y1(e){let t=new Map,r=[];return e.forEach((o,n)=>{let i=Km(t,o);i?r.push(`record ${n+1}: ${i}`):mZ(t,o)}),{requests:t,problems:r}}function XO(e){let t=0;for(let r of e.keys())t=Math.max(t,Number(r.slice(1)));return`r${t+1}`}function En(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 YO(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 dZ="{name}_{n}";function Xm(e,t="imported"){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"_").replace(/^[^a-z]+/,"").replace(/_+$/,"")||t}function QO(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()||dZ;r=e.map((i,s)=>Xm(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 mN,writeFileSync as _Z}from"node:fs";import{join as dN}from"node:path";import{createHash as fZ}from"node:crypto";import{existsSync as Pr,mkdirSync as pb,readFileSync as Qr,readdirSync as Ym,realpathSync as pZ,rmSync as nN,writeFileSync as Ws}from"node:fs";import{basename as rN,dirname as hZ,join as Ge,resolve as eN,sep as gZ}from"node:path";var b1="pixelclaw-project",w1=200,Q=class extends Error{};function Tn(e){return fZ("sha256").update(e).digest("hex")}function Qm(e,t){Ws(e,JSON.stringify(t,null,2)+`
191
+ `)}function hb(e,t){if(Pr(Ge(e,"project.json")))throw new Q(`${e} is already a project`);let r=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop().replace(/\.pclaw$/,""),o={format:b1,version:1,name:t.name??r,tickRate:60,defaultPalette:t.palettes[0]?.name??null,grid:t.grid??24,style:{},profiles:[]};pb(Ge(e,"palettes"),{recursive:!0}),pb(Ge(e,"assets"),{recursive:!0});for(let n of t.palettes)Ws(Ge(e,"palettes",`${n.name}.json`),yo(n));return Qm(Ge(e,"project.json"),o),$t(e)}function $t(e){let t=Ge(e,"project.json");if(!Pr(t))throw new Q(`${e} is not a PixelClaw project (no project.json); create one with 'pixelclaw new ${e}'`);let r=JSON.parse(Qr(t,"utf8"));if(r.format!==b1)throw new Q(`${t}: not a ${b1} file`);let o=new Map,n=Ge(e,"palettes");if(Pr(n))for(let i of Ym(n).sort()){if(!/\.(json|hex|gpl)$/i.test(i))continue;let s;try{s=Zk(i,Qr(Ge(n,i),"utf8"))}catch(a){throw new Q(`palettes/${i}: ${a.message}`)}if(o.has(s.name))throw new Q(`palettes/${i}: a palette named '${s.name}' is already loaded`);o.set(s.name,s)}return{dir:e,json:r,palettes:o}}function Co(e){return{get:t=>e.palettes.get(t),defaultName:e.json.defaultPalette??void 0,scheme:t=>yZ(e.dir,t)}}function yZ(e,t){let r=Ge(e,"schemes");if(Pr(r))for(let o of Ym(r).filter(n=>n.endsWith(".json")).sort())try{let n=JSON.parse(Qr(Ge(r,o),"utf8"));if(n.name===t)return n}catch{}}function Bs(e,t){if(!t||/[\\/]/.test(t)||t.startsWith("."))throw new Q(`'${t}' is not an asset name`);return Ge(e.dir,"assets",t)}function tN(e){let t=[],r=e;for(;;)try{return Ge(pZ(r),...t.reverse())}catch{let o=hZ(r);if(o===r)return e;t.push(rN(r)),r=o}}function bZ(e,t){let r=tN(eN(e.dir)),o=tN(eN(t));return o===r||o.startsWith(r+gZ)}function ed(e,t,r){if(!bZ(e,t))throw new Q(`${r}: '${t}' is outside the project folder, and the worker stays inside it`)}function Ti(e){let t=Ge(e.dir,"assets");return Pr(t)?Ym(t).filter(r=>Pr(Ge(t,r,"tape.jsonl"))).sort():[]}function Ao(e,t){return Pr(Ge(Bs(e,t),"tape.jsonl"))}function td(e,t){return nd(e,t).entries}function nd(e,t){let r=Ge(Bs(e,t),"tape.jsonl");if(!Pr(r))throw new Q(`no asset '${t}' in ${e.dir}`);let o=Qr(r);return{bytes:o,entries:yO(o.toString("utf8"))}}function oN(e,t){return JSON.parse(Qr(Ge(Bs(e,t),"asset.json"),"utf8"))}var wZ=/^fork (\S+) \S+ at=(\d+)$/;function gb(e){for(let t of e){let r=wZ.exec(t.cmd);if(r)return{from:r[1],at:Number(r[2])}}return null}function vZ(e,t){let r=gb(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:Rr(t),commands:t.length,groups:new Set(t.map(o=>o.group)).size},state:{sha256:Tn(zn(e))},checkpoints:{every:w1,files:bb(t.length)}}}function yb(e){try{return Zk(rN(e),Qr(e,"utf8"))}catch(t){throw new Q(`${e}: ${t.message}`)}}function iN(e,t){if(!Number.isInteger(t)||t<4||t>256)throw new Q("grid must be the cell size in pixels, 4..256");e.json.grid=t,Qm(Ge(e.dir,"project.json"),e.json)}function sN(e,t){for(let r of t)if(e.palettes.has(r.name))throw new Q(`the project already has a palette named '${r.name}'`);pb(Ge(e.dir,"palettes"),{recursive:!0});for(let r of t)Ws(Ge(e.dir,"palettes",`${r.name}.json`),yo(r)),e.palettes.set(r.name,r);!e.json.defaultPalette&&t[0]&&(e.json.defaultPalette=t[0].name,Qm(Ge(e.dir,"project.json"),e.json))}function v1(e){return Le(ki(e))}var $Z="PCLAWCKPT 1";function bb(e){let t=[];for(let r=w1;r<=e;r+=w1)t.push(`${String(r).padStart(6,"0")}.gwc`);return t}function wb(e,t){return Tn(Buffer.from(e.slice(0,t).map(r1).join(`
192
+ `),"utf8"))}function xZ(e,t,r){let o=Buffer.from(`${$Z} ${t} ${wb(e,t)}
193
+ `,"utf8"),n=r?zn(r):new Uint8Array(0);return Buffer.concat([o,n])}function $1(e,t){let r=Ge(Bs(e,t),"checkpoints");if(!Pr(r))return[];let o=[];for(let n of Ym(r).filter(i=>i.endsWith(".gwc")).sort()){let i=Qr(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 aN(e,t,r){let o=$1(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!==wb(r,n.n)||n.body.length===0))try{return{n:n.n,doc:uy(n.body)}}catch{}return null}function vb(e,t,r,o=!1){let n=t.doc;if(!n)throw new Q("nothing to save: the tape has no document");let i=Bs(e,n.name),s=Ge(i,"checkpoints");pb(s,{recursive:!0}),Ws(Ge(i,"tape.jsonl"),ab(t.entries)),Qm(Ge(i,"asset.json"),vZ(n,t.entries)),Ws(Ge(i,"preview.png"),v1(n));let a=new Set(bb(t.entries.length));for(let c of Ym(s))c.endsWith(".gwc")&&(o||!a.has(c))&&nN(Ge(s,c),{force:!0});if(r)for(let c of a){if(Pr(Ge(s,c)))continue;let l=Number(c.slice(0,6));Ws(Ge(s,c),xZ(t.entries,l,r(l)))}return i}var cN="reads.json";function lN(e){try{return JSON.parse(Qr(Ge(e.dir,cN),"utf8"))}catch{return{}}}function uN(e,t){Qm(Ge(e.dir,cN),t)}var x1=".pixelclaw.lock";function rd(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function Ci(e){let t=Ge(e,x1);if(!Pr(t))return null;try{let r=JSON.parse(Qr(t,"utf8"));return r.pid!==process.pid&&rd(r.pid)?r:null}catch{return null}}function _1(e,t){let r=Ci(e);if(r)throw new Q(`another pixelclaw server (pid ${r.pid}) owns ${e}; watch it at ${r.url.replace(/\?.*$/,"")}`);Ws(Ge(e,x1),JSON.stringify({pid:process.pid,url:t.replace(/\?.*$/,"")})+`
194
+ `)}function $b(e){let t=Ge(e,x1);try{JSON.parse(Qr(t,"utf8")).pid===process.pid&&nN(t,{force:!0})}catch{}}var id=["split","png","strip","bmfont"];function od(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 xb(e,t,r,o){mN(o,{recursive:!0});let n=[],i=(s,a)=>{let c=dN(o,s);mN(dN(c,".."),{recursive:!0}),_Z(c,a),n.push(c)};if(r==="split"){if(e.map||e.family||e.overlay)throw new Q(`'${e.name}' is a ${e.kind}; split takes an oversized tile or object`);if(e.width%e.cellW||e.height%e.cellH)throw new Q(`'${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}=hC(e);for(let c of s)i(`${e.name}/${c.name}.png`,Le(od(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 Q(`'${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=hy(e,s);i(`${e.name}.png`,Le(a.img)),i(`${e.name}.txt`,a.chars+`
196
+ `)}else{let a=gy(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 bo?new Q(a.message):a}return n}if(e.map){let s=Ht(e,Ln(t));i(`${e.name}.png`,Le(od(s.px,s.w,s.h,s.palette)))}else i(`${e.name}.png`,Le(od(be(e,0),e.width,e.height,e.palette.entries)));return n}var Hs=/^human:[A-Za-z0-9_.-]{1,32}$/;import{existsSync as kN,mkdirSync as AZ,readFileSync as OZ,writeFileSync as SN}from"node:fs";import{join as fd}from"node:path";import{existsSync as Js,mkdirSync as fN,readFileSync as Oo,readdirSync as kb,statSync as S1,writeFileSync as I1}from"node:fs";import{basename as Fn,extname as z1,isAbsolute as kZ,join as on,relative as P1,resolve as R1}from"node:path";function ad(e){let t=new Map,r=on(e,"schemes");if(!Js(r))return t;for(let o of kb(r).filter(n=>n.endsWith(".json")).sort())try{let n=JSON.parse(Oo(on(r,o),"utf8"));t.set(n.name,n)}catch(n){throw new Q(`schemes/${o}: ${n.message}`)}return t}function cd(e){let t=new Map(TO),r=[],o=on(e.dir,"profiles");Js(o)&&r.push(...kb(o).filter(n=>n.endsWith(".json")).sort().map(n=>on(o,n)));for(let n of e.json.profiles??[])r.push(kZ(n)?n:on(e.dir,n));for(let n of r)try{let i=Fs(JSON.parse(Oo(n,"utf8")));t.set(i.name,i)}catch(i){throw new Q(`${P1(e.dir,n)||n}: ${i.message}`)}return t}function pN(e,t){if(t.endsWith(".json")&&Js(R1(t)))return Fs(JSON.parse(Oo(R1(t),"utf8")));let r=cd(e),o=r.get(t);if(!o)throw new Q(`no profile '${t}' (profiles: ${[...r.keys()].join(", ")})`);return o}function SZ(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 Q(`no asset '${i}'`);n(i)}return e.filter(i=>o.has(i.name)).map(i=>i.doc)}var hN="exported.json";function j1(e){try{return JSON.parse(Oo(on(e.dir,hN),"utf8"))}catch{return{}}}function zZ(e,t,r,o,n){let i=j1(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:vc(l)};let c=Object.fromEntries(Object.keys(i).sort().map(l=>[l,i[l]]));I1(on(e.dir,hN),JSON.stringify(c,null,2)+`
197
+ `)}function Sb(e,t,r,o={}){let n=pN(e,r),i=SZ(t,o.names),s=NO(n,i,{tickRate:e.json.tickRate,world:Ln(t)}),a=o.dest??on(e.dir,"exports",n.name),c=[];for(let[l,u]of s.files){let m=on(a,l);fN(on(m,".."),{recursive:!0}),I1(m,u),c.push(m)}return o.at&&zZ(e,i,n.name,a,o.at),{dir:a,files:c,images:s.items.length,notes:s.notes}}function RZ(e){let t=new Map,r=o=>{for(let n of kb(o).sort()){let i=on(o,n);S1(i).isDirectory()?r(i):t.set(P1(e,i).split("\\").join("/"),Oo(i))}};return r(e),t}function Ai(e,t,r){let o=Tn(t),n=on(e.dir,"blobs");fN(n,{recursive:!0});let i=on(n,`${o}${r}`);return Js(i)||I1(i,t),o}var _b=(e,t)=>e.toLowerCase().replace(/[^a-z0-9_-]+/g,"_").replace(/^[^a-z]+/,"")||t;function qc(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
+ ${Jt(my(e.palette))}>>`],i=[];e.layers.forEach((a,c)=>{let l=_b(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
+ ${Jt(BS(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 ${_b(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 ld(e,t,r){if(r.files)return k1(e,r,r.files);let o=R1(r.path);if(!Js(o))throw new Q(`no file or folder '${r.path}'`);let n={create:[],same:[],differ:[],notes:[]};if(!r.profile&&S1(o).isDirectory()){let d=kb(o).filter(f=>/\.(png|aseprite|ase)$/i.test(f)).sort().map(f=>({name:f,bytes:new Uint8Array(Oo(on(o,f)))}));if(!d.length)throw new Q(`no .png or .aseprite files in ${r.path}`);return k1(e,r,d)}if(r.slice)return k1(e,r,[{name:Fn(o),bytes:new Uint8Array(Oo(o))}]);if(r.profile){let d=pN(e,r.profile),f=S1(o).isDirectory()?RZ(o):new Map([[Fn(o),Oo(o)]]),p=t.map(b=>b.doc),h=MO(d,f,p);n.notes.push(...h.notes);let g=DO(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=sd(e,r,[b.img],b.name),w=ar(b.img,y),v=Ai(e,f.get([...f.keys()].find(k=>k.includes(b.name))??"")??new Uint8Array,".png");n.create.push({name:b.name,inexact:w.inexact,worst:w.worst,tape:qc({name:_b(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=Oo(o),s=z1(o).toLowerCase(),a=_b(r.as??Fn(o,s),"imported"),c=Ai(e,i,s);if(s===".aseprite"||s===".ase"){let d=Hm(Bm(i)),f=d.rgba.flatMap(y=>y.flatMap(w=>w?[{width:d.width,height:d.height,data:w}]:[])),p=sd(e,r,f,a),h=0,g=0,b=d.rgba.map(y=>y.map(w=>{if(!w)return null;let v=ar({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:Fn(o),tape:qc({name:a,kind:r.kind??"sprite",palette:p,width:d.width,height:d.height,layers:d.layers,cels:b,ticks:d.ms.map(y=>a1(y,e.json.tickRate)),tags:d.tags,views:d.views,from:Fn(o),blob:c})}),n}if(s!==".png")throw new Q(`import reads .png and .aseprite files (or a folder with a profile), not '${s}'`);let l=Xr(i),u=sd(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 Q(`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 k=ar(Po(l,v*d,w*f,d,f),u);k.px.every(_=>_===65535)||(b+=k.inexact,y=Math.max(y,k.worst),g.push(k.px))}return n.create.push({name:a,inexact:b,worst:y,kind:r.kind??"sprite",size:`${d}x${f}`,from:Fn(o),tape:qc({name:a,kind:r.kind??"sprite",palette:u,width:d,height:f,layers:[{name:"main"}],cels:[g],from:Fn(o),blob:c})}),n}let m=ar(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:Fn(o),tape:qc({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:Fn(o),blob:c})}),n}function k1(e,t,r){let o={create:[],same:[],differ:[],notes:[]},n=[];for(let a of r){let c=z1(a.name).toLowerCase(),l=Xm(Fn(a.name,z1(a.name))),u=Ai(e,a.bytes,c);if(c===".aseprite"||c===".ase"){n.push({file:a.name,ase:a.bytes,from:Fn(a.name),base:l,blob:u});continue}if(c!==".png")throw new Q(`import reads .png and .aseprite files, not '${a.name}'`);let m=Xr(a.bytes);if(!t.slice){n.push({file:a.name,img:m,from:Fn(a.name),base:l,blob:u});continue}let d=YO(m.width,m.height,t.slice);if(!d.length)throw new Q(`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=Po(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:`${Fn(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=sn(e).manifest;if(!l)throw new Q("no valid manifest.json to take names from");a=l.assets.filter(u=>(!t.set||(u.set??u.kind)===t.set)&&!Js(on(e.dir,"assets",u.name))).map(u=>u.name)}let c=QO(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 Q(`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(Xm(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]=Xm(t.as));let c=i.find((l,u)=>i.indexOf(l)!==u);if(c)throw new Q(`names: '${c}' comes out twice (put {n}, or {col} and {row}, in the pattern)`)}let s=sn(e).manifest;return n.forEach((a,c)=>{let l=i[c],u=Cn(s,l)?.kind,m=t.kind??(u&&["sprite","tile","object","icon","sheet"].includes(u)?u:"sprite");if(a.ase){let g=Hm(Bm(a.ase)),b=g.rgba.flatMap(_=>_.flatMap($=>$?[{width:g.width,height:g.height,data:$}]:[])),y=sd(e,t,b,l),w=0,v=0,k=g.rgba.map(_=>_.map($=>{if(!$)return null;let x=ar({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:qc({name:l,kind:m,palette:y,width:g.width,height:g.height,layers:g.layers,cels:k,ticks:g.ms.map(_=>a1(_,e.json.tickRate)),tags:g.tags,views:g.views,from:a.from,blob:a.blob})});return}let d=a.img,f=sd(e,t,[d],l),p=ar(d,f),h=qc({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 Uc(e,t,r){let o=e.project;if(!t.path&&!t.files)throw new Q("import: give a path or files");let n=ld(o,e.assetDocs(),{...t,path:t.path??""});if(t.profile)throw new Q("importIntoProject takes images, not a profile export");for(let u of n.create)if(Js(on(o.dir,"assets",u.name))&&!t.replace)throw new Q(`an asset '${u.name}' already exists (choose other names, or replace)`);let i=sn(o),s=[],a=[...n.notes];if(t.manifest!==!1)if(i.manifest){for(let u of n.create)Cn(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=Vs(u,Lc(o));if(!m.manifest)throw new Q(`the manifest entries would have problems: ${m.errors.map(d=>`${d.path}: ${d.message}`).join("; ")}`)}}else{if(t.manifest===!0||i.exists)throw new Q(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 Q(`${u.name}: ${m.errors.map(d=>`${d.line}:${d.col} ${d.message}`).join("; ")}`)}s.length&&Oi(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:!!Cn(sn(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 sd(e,t,r,o){if(t.build){let s=rO(o.replace(/_/g,"-"),r);return $s({...s,entries:s.entries.map((a,c)=>({...a,key:xs(s.entries.length)[c]}))})}let n=t.palette??e.json.defaultPalette,i=n?e.palettes.get(n):void 0;if(!i)throw new Q(n?`no palette '${n}' in the project`:"say which palette to quantise to (palette), or build one from the image (build)");return i}function zb(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 jZ,existsSync as EZ,readFileSync as TZ}from"node:fs";import{join as vN}from"node:path";import{randomBytes as IZ}from"node:crypto";var gN=300*1e3,Zre=120*1e3,yN=500,PZ=/^mark\s+(approved|rejected|reviewed)\b\s*(.*)$/,Rb=class{epoch=IZ(3).toString("hex");seq=0;log=[];waiters=new Set;active=new Map;timers=new Set;consumed=0;quiet=0;closed=!1;onPresence=()=>{};workerRunning=()=>!1;clock;stamp;constructor(t=Date.now,r=()=>new Date().toISOString().replace(/\.\d{3}Z$/,"Z")){this.clock=t,this.stamp=r}cursor(){return`${this.epoch}:${this.seq}`}attach(t){this.consumed=t.length}push(t){this.log.push({...t,seq:++this.seq}),this.log.length>yN&&this.log.splice(0,this.log.length-yN);for(let r of[...this.waiters])r.wake()}syncRequests(t,r){t.length<this.consumed&&(this.consumed=0);for(let o of t.slice(this.consumed))o.type==="request"?this.push({kind:"request",id:o.id,asset:o.asset,note:o.note,by:o.by,at:o.at,next:"work"}):(o.type==="reply"||o.type==="cancel")&&this.push({kind:o.type,id:o.id,asset:r.get(o.id)?.asset??"",note:o.text??"",by:o.by,at:o.at,next:"work"});this.consumed=t.length}marks(t,r,o,n){if(!(this.quiet||!Hs.test(r)))for(let i of o){let s=PZ.exec(i.cmd);if(!s)continue;let a=s[2].trim();try{let c=JSON.parse(a);typeof c=="string"&&(a=c)}catch{}this.push({kind:s[1],id:null,asset:t,note:a,by:r,at:n,next:"changes"})}}withoutMarkEvents(t){this.quiet++;try{return t()}finally{this.quiet--}}since(t){if(!t)return null;let r=/^([0-9a-f]+):(\d+)$/.exec(t);if(!r||r[1]!==this.epoch||Number(r[2])>this.seq)return null;let o=Number(r[2]);return this.log.filter(n=>n.seq>o)}async wait(t){let o=(this.since(t.cursor)??t.initial()).filter(a=>a.by!==t.by);if(o.length||this.closed)return{events:o,cursor:this.cursor(),timedOut:!1};let n=this.since(t.cursor)?t.cursor:this.cursor();this.touch(t.by);let i,s;return await new Promise(a=>{s={by:t.by,via:t.via,since:this.stamp(),wake:()=>{c().length&&a()},stop:a};let c=()=>(this.since(n)??[]).filter(l=>l.by!==t.by);this.waiters.add(s),this.timers.add(i=setTimeout(a,t.timeoutMs)),i.unref?.(),t.signal?.addEventListener("abort",()=>a(),{once:!0}),t.signal?.aborted&&a(),this.onPresence()}),clearTimeout(i),this.timers.delete(i),this.waiters.delete(s),this.touch(t.by),o=(this.since(n)??[]).filter(a=>a.by!==t.by),{events:o,cursor:this.cursor(),timedOut:o.length===0}}touch(t){this.active.set(t,this.clock());let r=setTimeout(()=>{this.timers.delete(r),this.onPresence()},gN+1e3);r.unref?.(),this.timers.add(r),this.onPresence()}presence(){let t=this.clock(),r=[...this.active].filter(([,i])=>t-i<=gN).map(([i,s])=>({by:i,at:new Date(s).toISOString().replace(/\.\d{3}Z$/,"Z")})),o=[...this.waiters].map(({by:i,via:s,since:a})=>({by:i,via:s,since:a})),n=this.workerRunning();return{listening:o.length>0||r.length>0||n,waiters:o,agents:r,worker:n}}close(){this.closed=!0;for(let t of this.timers)clearTimeout(t);this.timers.clear();for(let t of[...this.waiters])t.stop()}};function bN(e){return[...e.values()].filter(t=>t.state==="open"&&t.seen.length===0).sort((t,r)=>Number(t.id.slice(1))-Number(r.id.slice(1))).map(t=>{let r=t.events.filter(o=>o.type==="reply").at(-1);return{seq:0,kind:r?"reply":"request",id:t.id,asset:t.asset,note:r?.text??t.note,by:r?.by??t.by,at:r?.at??t.at,next:"work"}})}function Ib(e,t,r={}){if(!e.length)return`no new events
203
+ next cursor: ${t}`;let o=[`${e.length} event${e.length===1?"":"s"}:`];for(let n of e){let i=n.id?`${n.kind} ${n.id} (${n.asset})`:`${n.kind} ${n.asset}`;o.push(` ${i} from ${n.by} at ${n.at}${n.note?`: "${n.note}"`:""}`),o.push(n.next==="work"?` next: work${n.kind==="cancel"?' (action "list"; stop if you hold it)':n.id?` (claim it: work id=${n.id})`:""}`+(r.cli&&n.kind!=="cancel"&&n.id?`; without MCP: pixelclaw work ${r.cli} claim ${n.id}`:""):` next: changes (read what the person did to ${n.asset})`)}return o.push(`next cursor: ${t}`),o.join(`
204
+ `)}var $N="requests.jsonl";function Fc(e){let t=vN(e.dir,$N);if(!EZ(t))return[];let r=[];for(let o of TZ(t,"utf8").split(`
205
+ `))if(o.trim())try{r.push(JSON.parse(o))}catch{}return r}function gt(e){return y1(Fc(e)).requests}function eo(e,t){let r=gt(e),o=Km(r,t);if(o)throw new Q(o);return jZ(vN(e.dir,$N),JSON.stringify(t)+`
206
+ `),y1([...Fc(e)]).requests.get(t.id)}function Gs(e,t,r){let o=e.project,n=e.stamp();if(r.action==="reply")return eo(o,{type:"reply",id:r.id,by:t,at:n,text:String(r.text??"")});if(r.action==="cancel")return eo(o,{type:"cancel",id:r.id,by:t,at:n,...r.text?{text:r.text}:{}});let i=gt(o),s=XO(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=sn(o);if(!p.manifest)throw new Q(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(Cn(p.manifest,f?.name))throw new Q(`'${f.name}' is already in the manifest`);if(f?.name&&Ao(o,f.name))throw new Q(`an asset '${f.name}' already exists`);let h={...p.manifest,assets:[...p.manifest.assets,f]},g=Vs(h,Lc(o));if(!g.manifest)throw new Q(`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=Km(i,b);if(y)throw new Q(y);return Oi(o,h),e.planChanged(),eo(o,b)}let l=sn(o).manifest;if(r.kind==="draw"){if(!Cn(l,r.asset))throw new Q(`'${r.asset}' is not planned in ${dd}`);if(Ao(o,r.asset))throw new Q(`'${r.asset}' is drawn already: ask for changes instead`);let f=c(r.asset,"draw");if(f)throw new Q(`${f.id} already asks for '${r.asset}' (${f.state})`);return eo(o,{type:"request",id:s,asset:r.asset,kind:"draw",note:a,by:t,at:n})}if(!Ao(o,r.asset))throw new Q(`'${r.asset}' is not drawn yet: ask for it to be drawn instead`);if(!a)throw new Q("say what should change");let u={type:"request",id:s,asset:r.asset,kind:"change",note:a,by:t,at:n},m=Km(i,u);if(m)throw new Q(m);let d=e.hub.withoutMarkEvents(()=>e.run({asset:r.asset,commands:`mark rejected ${tn(a)}`,by:t}));if(!d.ok)throw new Q(d.errors.map(f=>f.message).join("; "));return eo(o,{...u,mark:d.added.at(-1)?.seq})}function to(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==="open"&&e.seen.length?`seen by ${e.seen.map(o=>o.by).join(", ")}`:e.state;return`${e.id} ${t}${e.note?`: "${e.note}"`:""} (from ${e.by} at ${e.at}; ${r})`}function ud(e){let t=e.action??"request";if(t==="reply"||t==="cancel"){if(!e.id||!/^r\d+$/.test(e.id))throw new Q(`${t}: give the request's id (like r3)`);if(t==="reply"){if(!e.text?.trim())throw new Q("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 Q(`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 Q("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 Q("a request's kind is draw, change or add");if(!e.asset)throw new Q(`${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 md(e,t,r){let o=gt(e.project),n=!1;for(let i of new Set(t)){let s=o.get(i);!s||s.state!=="open"||s.seen.some(a=>a.by===r)||(eo(e.project,{type:"seen",id:i,by:r,at:e.stamp()}),n=!0)}n&&e.requestsChanged()}var CZ=3600;async function Pb(e,t){let r=Math.max(0,Math.min(CZ,t.timeoutS))*1e3,o=await e.hub.wait({cursor:t.cursor,initial:()=>bN(gt(e.project)),timeoutMs:r,by:t.by,via:t.via,signal:t.signal});return o.events.length&&await e.enqueue(()=>md(e,o.events.filter(n=>(n.kind==="request"||n.kind==="reply")&&n.id).map(n=>n.id),t.by)),o}function xN(e){let t=[...gt(e.project).values()].filter(o=>o.state==="open"),r=e.hub.presence();return!t.length||r.waiters.length||r.worker?"":`${t.length} open request${t.length===1?"":"s"} and no agent is listening for ${t.length===1?"it":"them"}. Take ${t.length===1?"it":"them"} with work, and keep \`pixelclaw await <project>\` running in the background (or call await_requests) so people's next requests reach you.`}function wN(e,t){return[...e.values()].filter(r=>r.state==="claimed"&&r.claimedBy===t).at(-1)}function Ks(e,t,r,o=jb){let n=e.project,i=gt(n),s=e.stamp();if(e.hub.touch(t),r.action==="list")return md(e,En(i).filter(u=>u.state==="open").map(u=>u.id),t),{request:null,message:""};if(r.action==="next"){let u=r.id?void 0:wN(i,t);if(u)return{request:u,message:`you already have ${u.id}; finish it (done or blocked) before taking another`};let m=r.id?i.get(r.id):En(i).find(d=>d.state==="open");return m?{request:eo(n,{type:"claim",id:m.id,by:t,at:s}),message:`claimed ${m.id}`}:{request:null,message:r.id?`no request ${r.id}`:"no open requests"}}let a=r.id??wN(i,t)?.id;if(!a)throw new Q(`no claimed request to post ${r.action} on (give id)`);let c=i.get(a);if(r.action==="done"&&c&&c.state==="claimed"&&c.claimedBy===t){if(!Ao(n,c.asset))throw new Q(`${a} is not done: ${c.asset} is not drawn yet. Draw it, or ${o.blocked(a)} if you cannot`);let u=e.checks(c.asset).results.filter(m=>m.status==="fail");if(u.length)throw new Q(`${a} is not done: ${c.asset} fails ${u.length} check${u.length===1?"":"s"}:
207
+ `+u.map(m=>` ${m.id}${m.score!==null?` ${m.shown}`:""}${m.limit?` (limit ${m.limit})`:""}${m.detail?`: ${m.detail}`:""}`).join(`
208
+ `)+`
209
+ Fix ${u.length===1?"it":"them"} (check shows the pixels) and finish again, or ${o.blocked(a)} if you cannot.`)}return{request:eo(n,{type:r.action,id:a,by:t,at:s,text:r.text}),message:`${a}: ${r.action}`}}var jb={done:(e,t)=>`work(action="done", text=<${t}>)`,blocked:()=>'work(action="blocked", text=<one clear question>)',next:"call work for the next"};function Vc(e){return/^[A-Za-z0-9_./:@%+=,~-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function _N(e){let t=Vc(e);return{done:(r,o)=>`\`pixelclaw work ${t} done ${r} "<${o}>"\``,blocked:r=>`\`pixelclaw work ${t} block ${r} "<one clear question>"\``,next:`run \`pixelclaw work ${t} claim\` for the next`}}function Eb(e,t,r=jb){let o=[to(t)],n=Cn(sn(e.project).manifest,t.asset);n&&o.push(`plan: ${t.asset} is a ${n.kind} ${n.size}${n.set?` in set ${n.set}`:""}${n.description?`: ${n.description}`:""}${n.height?` (drawn height ${n.height} px)`:""}`);let i=Ni(e).assets.find(s=>s.name===t.asset);return i&&o.push(`status: ${i.status} \u2192 ${i.next}${i.failing.length?`; failing: ${i.failing.join(", ")}`:""}${i.flags.length?`; ${i.flags.join("; ")}`:""}`),t.kind==="draw"||t.kind==="new"?o.push(`Draw it: run with \`new ${n?.kind??"sprite"} ${t.asset}\` (the manifest fills in its size and palette), look, check, fix; then ${r.done(t.id,"what you drew")}.`):o.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 ${r.done(t.id,"what changed")}.`),t.events.some(s=>s.type==="reply")&&o.push(`The person answered: "${t.events.filter(s=>s.type==="reply").at(-1).text}"`),o.push(`If you cannot go on without the person, ${r.blocked(t.id)}.`),o.join(`
210
+ `)}var dd="manifest.json";function Lc(e){let t;try{t=[...cd(e).keys()]}catch{t=void 0}return{palettes:[...e.palettes.keys()],schemes:[...vo.keys(),...ad(e.dir).keys()],profiles:t}}function sn(e){let t=fd(e.dir,dd);if(!kN(t))return{exists:!1,manifest:null,errors:[]};let r;try{r=JSON.parse(OZ(t,"utf8"))}catch(o){return{exists:!0,manifest:null,errors:[{path:"",message:`manifest.json is not JSON: ${o.message}`}]}}return{exists:!0,...Vs(r,Lc(e))}}function Oi(e,t){let r=Vs(t,Lc(e));return r.manifest?(SN(fd(e.dir,dd),JSON.stringify(t,null,2)+`
211
+ `),{exists:!0,...r}):{exists:kN(fd(e.dir,dd)),...r}}function Cn(e,t){return e?.assets.find(r=>r.name===t)}function zN(e,t){let r=e.json.style??{},o=e.json.grid??24;return{asset:(n,i)=>{let s=Cn(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=Cn(t,n);return i?.kind==="map"?(i.uses??[]).filter(s=>["object","sprite"].includes(Cn(t,s)?.kind??"")):[]}}}function NZ(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 Ni(e,t={}){let r=e.project,o=sn(r),n=o.manifest,i=j1(r),s=new Set(e.assets()),a=[...(n?.assets??[]).map(p=>({...p,planned:!0})),...[...s].filter(p=>!Cn(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?Zs(p):"unplanned";if(t.set&&h!==t.set)continue;let g=null,b=null,y=[],w=[],v=null,k=[];if(s.has(p.name))try{let R=e.state(p.name);g=R.doc,b=R.entries.at(-1)?.seq??null;let P=e.checks(p.name).results;w=P.filter(j=>j.status!=="skip").map(j=>({id:j.id,status:j.status,shown:j.shown})),y=P.filter(j=>j.status==="fail").map(j=>j.id),v=y.length===0}catch(R){k.push(`does not load: ${R.message}`)}let _=g?vc(g):null,$=i[p.name]??null,x=b!==null?e.state(p.name).entries.at(-1):void 0,S=WO({exists:!!g,checksPass:v,marks:g?.marks??[],art:_,exportedArt:$?.art??null});if(g&&p.planned){let R=Yr(p.size),P=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&&k.push(`planned as a ${p.kind}, drawn as a ${g.kind}`),R&&(P[0]!==R[0]||P[1]!==R[1])&&k.push(`planned ${p.size}, drawn ${P[0]}x${P[1]}`)}g?.notes.length&&k.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:S.status,next:S.next,flags:[...k,...S.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?NZ(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,...ZO(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=[...gt(r).values()],d=Object.fromEntries(h1.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 E1(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 Tb(e,t={}){let r=[],o=En(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; without MCP, \`pixelclaw work <project> claim\`):`);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}"`:a.seen.length?`seen by ${a.seen.map(u=>u.by).join(", ")}`:"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: ${h1.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(E1(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(E1(l))}}else{for(let a of e.sets){r.push("",`${a.name}${a.description?` (${a.description})`:""}:`);for(let c of a.assets)r.push(E1(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(`
212
+ `)}function MZ(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 g1[r%g1.length]}function DZ(e){let t=ad(e.dir);return r=>vo.get(r)??(t.has(r)?_s(t.get(r)):void 0)}function Cb(e,t={}){let r=e.project,o=sn(r);if(!o.manifest)throw new Q(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=fd(r.dir,"templates");AZ(i,{recursive:!0});let s=[],a=(h,g)=>{SN(fd(i,h),g),s.push(h)},c=r.json.grid??24,[l,u]=Eo(r.json.style,c),m=DZ(r),d=new Map(n.assets.map((h,g)=>[h.name,g])),f=h=>MZ(r,h,d.get(h.name)??0),p=GO(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,k)=>{let _=v?n.assets.find($=>$.name===v):void 0;return _?f(_):k},w=JO(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 LZ}from"node:child_process";import{randomBytes as FZ}from"node:crypto";import{appendFileSync as EN,chmodSync as VZ,existsSync as ZZ,mkdirSync as WZ,mkdtempSync as BZ,readFileSync as A1,rmSync as TN,writeFileSync as CN}from"node:fs";import{tmpdir as HZ}from"node:os";import{basename as JZ,join as cr}from"node:path";import{fileURLToPath as GZ}from"node:url";import{readFileSync as IN}from"node:fs";import{join as PN}from"node:path";var pd={enabled:!1,command:["claude"],args:[],cap:5,maxSessions:10,stall:10},RN=["--model","--fallback-model","--effort"],qZ=["--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 jN(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(!RN.includes(o))return`worker.args may hold only ${RN.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(qZ.includes(r))return`worker.command may not pass ${r}: the worker's tools and reach are fixed (docs/worker.md)`}return null}function Xs(e){let t={};try{let i=JSON.parse(IN(PN(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,pd.command);return{enabled:t.enabled===!0,command:n.length?n:pd.command,args:r(t.args,[]),cap:o(t.cap,pd.cap,0,1e3),maxSessions:Math.floor(o(t.maxSessions,pd.maxSessions,1,100)),stall:o(t.stall,pd.stall,.001,240)}}var Ab="worker-spend.jsonl";function UZ(e){try{return IN(PN(e,Ab),"utf8").split(`
213
+ `).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 hd(e){return Math.round(UZ(e).reduce((t,r)=>t+r.cost,0)*1e6)/1e6}var C1=".pixelclaw-worker.lock",AN=cr("logs","worker.log"),T1="claude";function KZ(){let e=GZ(new URL(".",import.meta.url));for(let t of[cr(e,"skill","SKILL.md"),cr(e,"..","..","skill","SKILL.md")])if(ZZ(t))return A1(t,"utf8");return""}var XZ=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.
214
+
215
+ 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.
216
+
217
+ Follow the PixelClaw skill (in your instructions). Loop:
218
+ 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).
219
+ 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.
220
+ 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.
221
+ 4. Call \`work\` again. Stop when it says there are no open requests.`,YZ=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.`,QZ=["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"],eW=["--tools","","--disallowedTools",QZ.join(","),"--allowedTools","mcp__pixelclaw","--permission-mode","dontAsk","--setting-sources","user","--strict-mcp-config"];function tW(e){return`${e?`${e.trim()}
222
+
223
+ `:""}# Every PixelClaw command
224
+
225
+ One line each, from the editor itself (the MCP server's instructions explain them; this is the full list):
226
+
227
+ ${YS()}
228
+ `}function nW(e){return[...e.command,"-p",e.resume?YZ(e.resume.minutes):XZ(e.dir),...e.resume?["--resume",e.resume.session]:[],"--output-format","stream-json","--verbose","--mcp-config",e.mcpConfig,...eW,"--max-budget-usd",e.budget.toFixed(2),"--append-system-prompt",tW(e.skill),...e.args]}var Ob={input:15,cacheWrite:18.75,cacheRead:1.5,output:75};function rW(e){let t=r=>typeof r=="number"&&Number.isFinite(r)&&r>0?r:0;return(t(e.input_tokens)*Ob.input+t(e.cache_creation_input_tokens)*Ob.cacheWrite+t(e.cache_read_input_tokens)*Ob.cacheRead+t(e.output_tokens)*Ob.output)/1e6}function O1(e){try{let t=JSON.parse(A1(cr(e,C1),"utf8"));return rd(t.pid)?t:null}catch{return null}}var gd=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e,jr=e=>`$${e.toFixed(2)}`;function oW(e){let t;try{t=JSON.parse(e)}catch{return{text:e.trim()?gd(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: ${gd(i.text.trim().replace(/\s+/g," "),300)}`]:i.type==="tool_use"?[`\u2192 ${String(i.name).replace(/^mcp__pixelclaw__/,"")} ${gd(JSON.stringify(i.input??{}),160)}`]:[]);return{text:n.length?n.join(`
229
+ `):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: ${gd(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?`, ${jr(r)}`:""})`,...r!==void 0?{cost:r}:{}}}return{text:null}}var Nb=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(`
230
+ `)).map(n=>`${r} ${n}`);try{WZ(cr(this.w.project.dir,"logs"),{recursive:!0}),EN(cr(this.w.project.dir,AN),o.join(`
231
+ `)+`
232
+ `)}catch{}this.w.workerLog(o)}start(t){let r=this.w.project.dir,o=Xs(r);if(!o.enabled)throw new Q('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=jN(o);if(n)throw new Q(n);if(this.run)throw new Q("a worker is already running for this project");let i=O1(r);if(i)throw new Q(`a worker is already running for this project (pid ${i.pid}, started by ${i.by} at ${i.startedAt})`);let s=hd(r);if(s>=o.cap-.005)throw new Q(`the worker has spent ${jr(s)} of its ${jr(o.cap)} cap on this project (${Ab}); raise worker.cap in project.json to go on`);let a=this.w.stamp();return CN(cr(r,C1),JSON.stringify({pid:process.pid,by:t,startedAt:a})+`
233
+ `),this.stopping=null,this.token=FZ(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(()=>{TN(cr(r,C1),{force:!0}),this.run=null,this.child=null,this.token=null}),this.run}stop(t){if(!this.run)throw new Q("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=Xs(o),i=0,s="",a=()=>hd(o);this.log([`run started by ${t}: cap ${jr(n.cap)} (${jr(a())} spent before), at most ${n.maxSessions} sessions, stall ${n.stall} min, command ${n.command.map(m=>JZ(m)).join(" ")}`]);let c=()=>En(gt(this.w.project)).filter(m=>m.state==="open"||m.state==="claimed"&&m.claimedBy===T1),l=()=>JSON.stringify([...gt(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 EN(cr(o,Ab),JSON.stringify({at:this.w.stamp(),run:r,session:m,cost:Math.round(p*1e6)/1e6,...f.cost===null?{estimated:!0}:{}})+`
234
+ `),this.w.setWorker({spent:a()}),this.log([`session ${m}: ${jr(p)}${f.cost===null?" (no cost reported: estimated from its tokens, at the dearest rates)":""}; ${jr(a())} of ${jr(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 (${jr(a())} of ${jr(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 ${jr(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=()=>[...gt(this.w.project).values()].find(g=>g.state==="claimed"&&g.claimedBy===T1);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?(eo(this.w.project,{type:"blocked",id:h.id,by:T1,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=BZ(cr(HZ(),"pixelclaw-worker-")),a=cr(s,"mcp.json");CN(a,JSON.stringify({mcpServers:{pixelclaw:{type:"http",url:i.url,headers:{Authorization:`Bearer ${this.token}`}}}}),{mode:384}),VZ(a,384);let c=nW({command:t.command,args:t.args,dir:n,mcpConfig:a,budget:r,skill:KZ(),...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=LZ(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 $=oW(_);$.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(`
235
+ `))>=0;)w(h.slice(0,$)),h=h.slice($+1)}),b.stderr.setEncoding("utf8").on("data",_=>{for(let $ of _.split(`
236
+ `))$.trim()&&this.log([`stderr: ${gd($.trim(),300)}`])});let v=!1,k=(_,$)=>{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 ${_}`]),TN(s,{recursive:!0,force:!0}),u({cost:f?null:m,estimate:[...p.values()].reduce((x,S)=>x+rW(S),0),session:d,stalled:f}))};b.on("error",_=>k(null,_)),b.on("close",_=>k(_))})}};function ON(e,t=200){try{return A1(cr(e,AN),"utf8").split(`
237
+ `).filter(Boolean).slice(-t)}catch{return[]}}import{createHash as iW}from"node:crypto";var sW="258EAFA5-E914-47DA-95CA-C5AB0DC85B11",N1=1<<20,D1=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(M1(1,Buffer.from(t,"utf8")))}close(t=1e3){if(this.closed)return;let r=Buffer.alloc(2);r.writeUInt16BE(t),this.socket.end(M1(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(N1))return this.close(1009);a=Number(m),c=10}if(!s)return this.close(1002);if(a>N1)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(M1(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)>N1)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 M1(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 NN(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
238
+ Connection: close\r
239
+ \r
240
+ `),null;let n=iW("sha1").update(r+sW).digest("base64");return t.write(`HTTP/1.1 101 Switching Protocols\r
241
+ Upgrade: websocket\r
242
+ Connection: Upgrade\r
243
+ Sec-WebSocket-Accept: ${n}\r
244
+ \r
245
+ `),new D1(t)}var DN={".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 fW(){let e=[process.env.PIXELCLAW_UI_DIR,MN(new URL("./ui/",import.meta.url)),MN(new URL("../../ui/dist/",import.meta.url))];for(let t of e)if(t&&Db(Zc(t,"index.html")))return t;return null}function yd(e,t){if(!e)return!1;let r=Buffer.from(e),o=Buffer.from(t);return r.length===o.length&&aW(r,o)}var Dt={"X-Content-Type-Options":"nosniff","Referrer-Policy":"no-referrer","X-Frame-Options":"DENY"},pW="default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; connect-src 'self'; frame-ancestors 'none'";function qN(e,t,r,o){e.writeHead(t,{...Dt,"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store"}),e.end(`<!doctype html><meta charset="utf-8"><title>${r}</title>
246
+ <body style="font:15px system-ui;background:#16171b;color:#d8dbe0;padding:3em;max-width:40em">
247
+ <h1 style="font-size:20px">PixelClaw: ${r}</h1>${o}</body>`)}var hW=256*1024;async function gW(e,t){let r=o=>({type:"result",id:t.id,ok:!1,errors:[{line:0,col:0,message:o}]});return typeof t.by!="string"||!Hs.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>hW?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 Q?r(o.message):r(`internal error: ${o.message}`)}})}async function yW(e,t){return typeof t.by!="string"||!Hs.test(t.by)?{type:"answer",id:t.id,ok:!1,error:"a page writes as human:<name>"}:e.enqueue(()=>{try{let r=Gs(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 Q?r.message:`internal error: ${r.message}`}}})}function bW(e,t){let r=e.doc(t);if(r.map){let n=Ht(r,Ln(e.assetDocs()));return Le(od(n.px,n.w,n.h,n.palette))}if(r.frameCount<=1||r.family)return Le(ki(r));let o=ut(r.width*r.frameCount,r.height);for(let n=0;n<r.frameCount;n++){let i=ki(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 UN=32*1024*1024;function q1(e,t){return new Promise((r,o)=>{let n=[],i=0;e.on("data",s=>{if(i+=s.length,i>t){o(new Q("too large")),e.destroy();return}n.push(s)}),e.on("end",()=>r(Buffer.concat(n))),e.on("error",o)})}var wW=["new","run","seeds","export","import","review","plan","request","reply","cancel","work"];async function LN(e){let t=e.host??"127.0.0.1",r=fW(),o=new Set,n=0,i=()=>[`127.0.0.1:${n}`,`localhost:${n}`,`[::1]:${n}`],s=y=>{let w=JSON.stringify(y);for(let v of o)v.send(w)},a=e.writer.on(s),c=e.mcp?qk(()=>e.mcp({confined:!1}),{onerror:()=>{}}):null,l=e.mcp?qk(()=>e.mcp({confined:!0}),{onerror:()=>{}}):null,u=(y,w,v)=>{y.writeHead(w,{...Dt,"Content-Type":"application/json","Cache-Control":"no-store"}),y.end(JSON.stringify(v)+`
248
+ `)},m=async(y,w,v)=>{let k=String(y.headers.authorization??""),_=k.startsWith("Bearer ")?k.slice(7):v.searchParams.get("token"),$=e.worker?.mcpToken()??null,x=c?yd(_,e.token)?c:$&&yd(_,$)?l:null:null;if(!x){w.writeHead(c?401:404,{...Dt,"Content-Type":"text/plain"}).end(c?`token required
249
+ `:`not found
250
+ `);return}let S=y.method==="POST"?await q1(y,8*1024*1024):void 0,R=new Headers;for(let[q,Z]of Object.entries(y.headers))typeof Z=="string"?R.set(q,Z):Array.isArray(Z)&&R.set(q,Z.join(", "));let P=new AbortController;w.on("close",()=>P.abort());let j=await x.fetch(new Request(v,{method:y.method,headers:R,body:S?new Uint8Array(S):void 0,signal:P.signal})),N={};if(j.headers.forEach((q,Z)=>{N[Z]=q}),w.writeHead(j.status,N),!j.body){w.end();return}let T=j.body.getReader();try{for(;;){let{done:q,value:Z}=await T.read();if(q)break;w.write(Z)}}catch{}w.end()},d=y=>{let w=String(y.headers.authorization??"");return w.startsWith("Bearer ")&&yd(w.slice(7),e.token)},p=lW((y,w)=>{if(!i().includes(String(y.headers.host))){w.writeHead(421,Dt).end(`wrong host
251
+ `);return}let v=new URL(y.url??"/",`http://${y.headers.host}`),k=yd(v.searchParams.get("token"),e.token);if(v.pathname==="/mcp"){m(y,w,v).catch(S=>{w.headersSent?w.end():u(w,500,{error:S.message})});return}if(v.pathname==="/api/import"&&y.method==="POST"){if(!k){u(w,401,{error:"token required"});return}q1(y,UN).then(async S=>{let R=JSON.parse(S.toString("utf8"));if(typeof R.by!="string"||!Hs.test(R.by))throw new Q("a page writes as human:<name>");if(!Array.isArray(R.files)||!R.files.length)throw new Q("no files");let P=R.files.map(N=>({name:String(N.name),bytes:new Uint8Array(Buffer.from(String(N.data),"base64"))})),j=await e.writer.enqueue(()=>Uc(e.writer,{...R.options??{},files:P},R.by));u(w,200,j)}).catch(S=>u(w,S instanceof Q||S instanceof SyntaxError?400:500,{error:S.message}));return}if(v.pathname==="/api/cli"&&y.method==="POST"){if(!k&&!d(y)){u(w,401,{error:"token required"});return}if(!e.runCli){u(w,501,{error:"this server cannot run CLI commands"});return}q1(y,UN).then(async S=>{let R=JSON.parse(S.toString("utf8"));if(!Array.isArray(R.argv)||!R.argv.every(T=>typeof T=="string")||typeof R.cwd!="string")throw new Q("argv and cwd are needed");let P=R.argv;if(!wW.includes(P[0]??""))throw new Q(`'${P[0]}' is not sent through the server`);let j=R.cwd,N=await e.writer.enqueue(()=>{let T=e.runCli(P,e.writer,j);return e.writer.requestsChanged(),e.writer.planChanged(),T});u(w,200,N)}).catch(S=>u(w,S instanceof Q||S instanceof SyntaxError?400:500,{error:S.message}));return}if(y.method!=="GET"&&y.method!=="HEAD"){w.writeHead(405,Dt).end();return}if(v.pathname==="/api/await"){if(!k&&!d(y)){u(w,401,{error:"token required"});return}let S=v.searchParams.get("as")??"claude";if(!/^[A-Za-z0-9_.:-]{1,32}$/.test(S)){u(w,400,{error:"as is a short name (letters, digits, . _ : -)"});return}let R=Number(v.searchParams.get("timeout")??600);if(!Number.isFinite(R)||R<0){u(w,400,{error:"timeout is seconds"});return}let P=new AbortController;w.on("close",()=>P.abort()),Pb(e.writer,{cursor:v.searchParams.get("since")??void 0,timeoutS:R,by:S,via:v.searchParams.get("via")==="mcp"?"mcp":"cli",signal:P.signal}).then(j=>{!w.writableEnded&&!P.signal.aborted&&u(w,200,j)},j=>{w.writableEnded||u(w,500,{error:j.message})});return}if(v.pathname==="/api/presence"){if(!k&&!d(y)){u(w,401,{error:"token required"});return}u(w,200,e.writer.hub.presence());return}if(v.pathname==="/api/worker"){if(!k){u(w,401,{error:"token required"});return}u(w,200,{status:e.writer.workerStatus(),log:ON(e.writer.project.dir)});return}let _=/^\/api\/strip\/([a-z][a-z0-9_-]*)\.png$/.exec(v.pathname);if(_){if(!k){u(w,401,{error:"token required"});return}e.writer.enqueue(()=>bW(e.writer,_[1])).then(S=>{w.writeHead(200,{...Dt,"Content-Type":"image/png","Cache-Control":"no-store"}),w.end(S)},()=>{w.writeHead(404,{...Dt,"Content-Type":"text/plain"}).end(`not found
252
+ `)});return}if(v.pathname==="/"||v.pathname==="/index.html"){if(!k){qN(w,401,"token required",`<p>This view needs the link with its token, as printed when the server
253
+ started (<code>pixelclaw: watch at http://127.0.0.1:${n}/?token=\u2026</code>). Ask the agent for the
254
+ link, or look in the server's log.</p>`);return}if(!r){qN(w,503,"UI not built","<p>The watch view has not been built. Run <code>pnpm build</code> in the repo.</p>");return}w.writeHead(200,{...Dt,"Content-Security-Policy":pW,"Content-Type":DN[".html"],"Cache-Control":"no-store"}),w.end(Mb(Zc(r,"index.html")));return}if(v.pathname==="/api/state"){if(!k){w.writeHead(401,{...Dt,"Content-Type":"application/json"}).end(`{"error":"token required"}
255
+ `);return}w.writeHead(200,{...Dt,"Content-Type":"application/json","Cache-Control":"no-store"}),w.end(JSON.stringify(e.writer.snapshot()));return}if(v.pathname==="/api/plan"){if(!k){w.writeHead(401,{...Dt,"Content-Type":"application/json"}).end(`{"error":"token required"}
256
+ `);return}e.writer.enqueue(()=>Ni(e.writer)).then(S=>{w.writeHead(200,{...Dt,"Content-Type":"application/json","Cache-Control":"no-store"}),w.end(JSON.stringify(S))},S=>{w.writeHead(500,{...Dt,"Content-Type":"application/json"}).end(JSON.stringify({error:S.message})+`
257
+ `)});return}let $=/^\/api\/preview\/([a-z][a-z0-9_-]*)\.png$/.exec(v.pathname);if($){let S=Zc(e.writer.project.dir,"assets",$[1],"preview.png");if(!k||!Db(S)){w.writeHead(k?404:401,{...Dt,"Content-Type":"text/plain"}).end(k?`not found
258
+ `:`token required
259
+ `);return}w.writeHead(200,{...Dt,"Content-Type":"image/png","Cache-Control":"no-store"}),w.end(Mb(S));return}let x=/^\/api\/blob\/([0-9a-f]{64})\.png$/.exec(v.pathname);if(x){let S=Zc(e.writer.project.dir,"blobs",`${x[1]}.png`);if(!k||!Db(S)){w.writeHead(k?404:401,{...Dt,"Content-Type":"text/plain"}).end(k?`not found
260
+ `:`token required
261
+ `);return}w.writeHead(200,{...Dt,"Content-Type":"image/png","Cache-Control":"private, max-age=86400, immutable"}),w.end(Mb(S));return}if(r&&v.pathname.startsWith("/assets/")){let S=mW(Zc(r,decodeURIComponent(v.pathname)));if(S.startsWith(Zc(r,"assets")+dW)&&Db(S)&&cW(S).isFile()){w.writeHead(200,{...Dt,"Content-Type":DN[uW(S)]??"application/octet-stream","Cache-Control":"public, max-age=31536000, immutable"}),w.end(Mb(S));return}}w.writeHead(404,{...Dt,"Content-Type":"text/plain"}).end(`not found
262
+ `)});p.on("upgrade",(y,w)=>{let v=new URL(y.url??"/",`http://${y.headers.host}`);if(!i().includes(String(y.headers.host))||v.pathname!=="/ws"){w.end(`HTTP/1.1 404 Not Found\r
263
+ Connection: close\r
264
+ \r
265
+ `);return}if(!yd(v.searchParams.get("token"),e.token)){w.end(`HTTP/1.1 401 Unauthorized\r
266
+ Connection: close\r
267
+ \r
268
+ `);return}let k=NN(y,w);k&&(o.add(k),k.onclose=()=>o.delete(k),k.onmessage=_=>{let $;try{$=JSON.parse(_)}catch{return}if($.type==="ping")k.send(JSON.stringify({type:"pong"}));else if($.type==="run")gW(e.writer,$).then(x=>k.send(JSON.stringify(x)));else if($.type==="request")yW(e.writer,$).then(x=>k.send(JSON.stringify(x)));else if($.type==="worker"){let x=(S,R)=>k.send(JSON.stringify({type:"answer",id:$.id,ok:S,...R?{error:R}:{}}));if(typeof $.by!="string"||!Hs.test($.by))x(!1,"a page writes as human:<name>");else if(!e.worker)x(!1,"this server runs no worker");else try{$.action==="stop"?e.worker.stop($.by):e.worker.start($.by).catch(()=>{}),x(!0)}catch(S){x(!1,S.message)}}},k.send(JSON.stringify({type:"hello",snapshot:e.writer.snapshot()})))});let h=e.port===0?1:Math.max(1,e.tries??20),g;for(let y=0;y<h;y++)try{await new Promise((w,v)=>{p.once("error",v),p.listen(e.port===0?0:e.port+y,t,()=>{p.off("error",v),w()})}),g=void 0;break}catch(w){if(g=w,w.code!=="EADDRINUSE")break}if(g)throw a(),g;return n=p.address().port,{url:`http://127.0.0.1:${n}/?token=${e.token}`,port:n,token:e.token,clients:()=>o.size,close:()=>new Promise(y=>{a(),e.writer.hub.close(),c?.close();for(let w of o)w.close(1001);p.close(()=>y()),p.closeAllConnections()})}}function vW(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 qb(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}: ${vW(c.pts)}`)}for(let a of r)s.push(` note: ${a}`);return s.join(`
269
+ `)}function Ub(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(`
270
+ `)}import{existsSync as $W,mkdirSync as Ys,readFileSync as xW,writeFileSync as _W}from"node:fs";import{join as no}from"node:path";function kW(e){let t=r=>r.length?r.map(o=>`- ${o}`).join(`
271
+ `):"- (none)";return`# Review: ${e.project}
272
+
273
+ You are reviewing pixel art for a game, with fresh eyes. Judge only what you see in this folder.
274
+
275
+ ## What is here
276
+
277
+ - \`assets/<name>.png\`: each asset enlarged with a pixel grid and rulers (numbers every 8 pixels,
278
+ from 0 at the top left), for reading coordinates.
279
+ - \`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)`}.
280
+ - \`tiles/<name>.3x3.png\`: each tile repeated 3x3, at 1x and 4x, as it will cover the ground.
281
+ - \`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`}.
282
+ - \`anim/<name>.png\`: each animated asset's frames, one row per sequence (a direction or a named
283
+ loop), each frame with its length in game ticks (${e.tickRate} a second) and the frame before it
284
+ tinted red underneath; \`anim/<name>.gif\` plays them at the game's speed.
285
+ - \`maps/<name>.png\`: each autotile set laid out as a small map at the game's draw scale (${e.scale}x),
286
+ the way the game will place its tiles; \`maps/<name>.gif\` plays it (at 1x) when anything moves, and
287
+ \`maps/<name>.tiles.txt\` says which tile is at each column and row of the map.
288
+ - \`sets/<name>.png\`: every tile of each autotile set, each in the middle of the neighbours that
289
+ call for it (the neighbours dimmed), named.
290
+ - \`scenes/<map>.png\`: each scene (a place built from the tiles and objects) whole, at 1x;
291
+ \`scenes/<map>.screen<n>.png\`: screens of it at the game's draw scale (${e.scale}x), what a player
292
+ sees, \`scenes/<map>.screens.txt\` says which cells each shows; \`scenes/<map>.cells.txt\` maps every cell (a letter per
293
+ ground it shows, a capital where an object stands).
294
+ - \`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.":""}
295
+
296
+ Tiles:
297
+ ${t(e.tiles)}
298
+
299
+ Sprites:
300
+ ${t(e.sprites)}
301
+
302
+ Animated:
303
+ ${t(e.animated)}
304
+
305
+ Autotile sets (judge them on their maps):
306
+ ${t(e.families)}
307
+
308
+ Scenes:
309
+ ${t(e.maps)}
310
+
311
+ ## How to judge
312
+
313
+ Look at the game-scale images first, as a player would, then at the enlarged ones for detail.
314
+ Score each part from 1 (poor) to 5 (excellent) and say why in a sentence or two:
315
+
316
+ 1. **Readability.** At 1x on its ground, does each sprite read at a glance: its shape, what it
317
+ is${e.brief?" (is it what brief.md says it is?)":""}, its front? Is its edge clear of the ground?
318
+ 2. **Cohesion.** Do the pieces look like one set: the same light direction, outline rule,
319
+ shading depth, level of detail and palette use?
320
+ 3. **Seams and repetition.** Do the tiles join without visible lines at their edges? Does the
321
+ 3x3 show stripes, a grid, or a mark that repeats too obviously?
322
+ 4. **Style-guide fit.** Does the art follow the style guide and use only the palette?
323
+ 5. **Defects.** Stray pixels, jagged lines (uneven steps), doubled corners, pillow shading
324
+ (shading that follows the outline on every side), muddy or flat areas, broken outlines.
325
+ 6. **Animation.** Does the motion read (a walk, a shimmer)? Does a figure slide, float or jump
326
+ from frame to frame? Does each loop join its end to its start without a hitch? Do the
327
+ directions of a figure look like one figure, and different enough to tell apart?
328
+ 7. **Autotiling.** On each map, does the edge between the two grounds read as one natural edge
329
+ (a shore, a border), with convincing outer and inner corners? Does the map show the tile grid
330
+ (lines or blocks every tile), or the same corner piece repeating too obviously?
331
+ 8. **Scenes.** At game scale, does each scene read as one coherent place? Do the buildings,
332
+ trees and props sit on their ground (bases meeting it, sizes that agree, one light), in a
333
+ sensible order front to back? Does any stretch of ground or edge repeat so that the grid shows?
334
+
335
+ ## How to report
336
+
337
+ End with a list of defects, one per line, each pinned to pixels in the asset's own coordinates
338
+ (x from the left, y from the top, as the rulers show), in this form:
339
+
340
+ \`\`\`
341
+ <asset> <x>,<y> "what is wrong and what to do"
342
+ <asset> <x>,<y> <w>x<h> "for a region"
343
+ \`\`\`
344
+
345
+ For a scene, point at the cell by its column and row (as \`cells.txt\` numbers them):
346
+
347
+ \`\`\`
348
+ <scene> cell <col>,<row> "what is wrong and what to do"
349
+ \`\`\`
350
+
351
+ For a map, point at the tile by its column and row on the map (from 0 at the top left; each
352
+ tile is the set's tile size at 1x), and at the pixel inside that tile:
353
+
354
+ \`\`\`
355
+ <set> map <col>,<row> <x>,<y> "what is wrong and what to do"
356
+ \`\`\`
357
+
358
+ Only list what you can point at. If an asset is fine, say so.
359
+ `}function Lb(e,t={}){let r=e.assetDocs(),o=sn(e.project).manifest,n=t.assets??r.map($=>$.name);if(t.set){if(!o)throw new Q(`set '${t.set}': the project has no valid manifest.json`);let $=o.assets.filter(x=>Zs(x)===t.set).map(x=>x.name);if(!$.length)throw new Q(`no set '${t.set}' in the manifest (sets: ${[...new Set(o.assets.map(Zs))].join(", ")})`);if(n=(t.assets??$).filter(x=>$.includes(x)&&r.some(S=>S.name===x)),!n.length)throw new Q(`nothing in set '${t.set}' is drawn yet`)}let i=n.map($=>{let x=r.find(S=>S.name===$);if(!x)throw new Q(`no asset '${$}' to review`);return x});if(!i.length)throw new Q("no assets to review");let s=e.stamp().slice(0,10),a=no(e.project.dir,"reviews",`${s}-${t.name??t.set??"all"}`);Ys(no(a,"assets"),{recursive:!0});let c=[],l=($,x)=>{_W(no(a,$),x),c.push($)},u=e.project.json.style,m=jo(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(Oy($.doc,{scale:Math.max(4,Math.min(16,Math.floor(256/Math.max($.doc.width,$.doc.height))))}))),l(`assets/${$.name}.game.png`,Le(jm([{doc:$.doc}],{scale:m}))));d.length&&Ys(no(a,"tiles"),{recursive:!0});for(let $ of d)l(`tiles/${$.name}.3x3.png`,Le(Ny($.doc)));g.length&&Ys(no(a,"scenes"),{recursive:!0});for(let $ of g){let x=Us($.name,r,u),S=Wm($.name,$.doc,r,u).slice(0,7).map(P=>P.doc),R=$.doc.views.length?$.doc.views.map(P=>({doc:$.doc,frame:P.from})):[{doc:$.doc}];l(`scenes/${$.name}.png`,Le(jm([...R,...S.map(P=>({doc:P}))],{ground:x?.doc??null,scale:m})))}f.length&&(Ys(no(a,"maps"),{recursive:!0}),Ys(no(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(Uy($.doc,x)));let S=Ly($.doc,{...x,scale:1,tickRate:e.project.json.tickRate??60});S.length>1&&l(`maps/${$.name}.gif`,Ls(S,{delta:!0}));let R=et($.doc.family),P=zo($.doc,Si(R,x.cols,x.rows,x.seed),0),j=Array.from({length:x.rows},(N,T)=>`${String(T).padStart(2)}: `+Array.from({length:x.cols},(q,Z)=>{let D=P.variants[T*x.cols+Z];return D==null?"-":R.variants[D].name}).join(" "));l(`maps/${$.name}.tiles.txt`,`The tile at each column and row of maps/${$.name}.png ('-': the plain outside ground).
360
+
361
+ ${j.join(`
362
+ `)}
363
+ `),l(`sets/${$.name}.png`,Le(Fy($.doc,{scale:1})))}h.length&&Ys(no(a,"scenes"),{recursive:!0});for(let $ of h){let x=Ln(r),S=Ht($.doc,x);l(`scenes/${$.name}.png`,Le($i(S,{scale:1}))),l(`scenes/${$.name}.cells.txt`,`The cells of scenes/${$.name}.png (${S.t} px each at 1x).
364
+
365
+ ${dC($.doc,S)}
366
+ `);let[R,P]=Eo(u,e.project.json.grid),j=S.top.map((M,L)=>M&&M.variant!=="outside"?L:-1).filter(M=>M>=0),N=j.map(M=>M%S.cols),T=j.map(M=>Math.floor(M/S.cols)),q=j.length?{x0:Math.min(...N),y0:Math.min(...T),x1:Math.max(...N),y1:Math.max(...T)}:{x0:0,y0:0,x1:S.cols-1,y1:S.rows-1},Z=Math.ceil(R/S.t),D=Math.ceil(P/S.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=Py(S,L,M,R,P);l(`scenes/${$.name}.screen${++V}.png`,Le($i(S,{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(`
367
+ `)}
368
+ `)}let b=i.filter($=>$.doc.frameCount>1&&!$.doc.family&&!$.doc.map),y=e.project.json.tickRate??60;b.length&&Ys(no(a,"anim"),{recursive:!0});for(let $ of b)l(`anim/${$.name}.png`,Le(Dy($.doc))),l(`anim/${$.name}.gif`,Ls(qy($.doc,{tickRate:y})));let w=new Map;for(let $ of i){if($.doc.map)continue;let x=new Set;for(let S=0;S<$.doc.frameCount;S++)for(let R of be($.doc,S))x.add(R);$.doc.palette.entries.forEach((S,R)=>{x.has(R)&&w.set(S.name,S.hex+(S.role?` (role: ${S.role})`:""))})}l("palette.md",`# Palette
369
+
370
+ The colours the art uses:
371
+
372
+ ${[...w].map(([$,x])=>`- ${$}: ${x}`).join(`
373
+ `)}
374
+ `);let v=o?i.flatMap($=>{let x=o.assets.find(S=>S.name===$.name);return x?[x]:[]}):[];o&&v.length&&l("brief.md",`# Brief
375
+
376
+ ${o.theme.trim()}
377
+
378
+ ## The pieces
379
+
380
+ ${v.map($=>`- **${$.name}** (${$.kind}, ${$.size}${$.height?`, about ${$.height} px tall`:""})${$.description?`: ${$.description}`:""}`).join(`
381
+ `)}
382
+ `);let k=no(e.project.dir,"style.md"),_=$W(k)?xW(k,"utf8"):null;return _&&l("style.md",_),l("rubric.md",kW({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 sM}from"node:fs";import{join as aM}from"node:path";import{mkdirSync as SW,writeFileSync as lr}from"node:fs";import{join as ur}from"node:path";var Qs=["render","grid","tile3x3","diff","game","recolour","anim","map","family","density"];function FN(e){return Qs.includes(e)}function Fb(e){return jy(e)}function zW(e,t){if(t.scale!==void 0&&(!Number.isInteger(t.scale)||t.scale<1||t.scale>64))throw new Q("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 Q(`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 Q("region size must be at least 1x1");if(!e.wrap&&(r.x+r.w>e.width||r.y+r.h>e.height))throw new Q(`region runs past the ${e.width}x${e.height} canvas`)}}function bd(e,t,r,o,n){if(zW(e,r),SW(o,{recursive:!0}),t==="diff"&&e.map&&r.mapDoc){let c=gC(n??null,e,r.mapDoc.world,r.scale??r.mapDoc.drawScale),l=Le(c.img),u=ur(o,`${e.name}.diff.png`);return lr(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=RC(n??null,e,{scale:r.scale}),l=Le(c),u=ur(o,`${e.name}.diff.png`);lr(u,l);let m=My(n??null,e,Pm(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=zC(e,c,r.frame),u=ur(o,`${e.name}.grid${c?`.${c.x}-${c.y}-${c.w}x${c.h}`:""}.txt`);return lr(u,l),{mode:t,kind:"text",text:l,path:u}}if(t==="map"&&r.mapDoc)return RW(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=Uy(e,c),u=Le(l),m=ur(o,`${e.name}.map.png`);lr(m,u);let d=OC(e,c),f,p=Ly(e,c);return p.length>1&&(f=ur(o,`${e.name}.map.gif`),lr(f,Ls(p,{delta:!0})),d+=`
383
+ 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 Q("the density view needs the base asset and its copies");let{base:c,copies:l,...u}=r.density,m=ZC(c,l,{...u,frame:r.frame,scale:r.scale}),d=Le(m.img),f=ur(o,`${e.name}.density.png`);return lr(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 Q(`'${e.name}' is not a family (the family view shows each variant among its neighbours)`);let c=Fy(e,{scale:r.scale,frame:r.frame,theme:r.theme}),l=Le(c),u=ur(o,`${e.name}.family.png`);return lr(u,l),{mode:t,kind:"image",png:l,width:c.width,height:c.height,path:u,text:IW(e)}}if(t==="anim"){let c=Dy(e,{scale:r.scale,theme:r.theme}),l=Le(c),u=ur(o,`${e.name}.anim.png`);lr(u,l);let m=ur(o,`${e.name}.anim.gif`);lr(m,Ls(qy(e,{theme:r.theme,tickRate:r.tickRate})));let d=`${CC(e,{tickRate:r.tickRate})}
384
+ 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"?Oy(e,{scale:r.scale,frame:r.frame,marks:r.marks,theme:r.theme,underlay:r.underlay,...r.region?{region:r.region}:{}}):t==="tile3x3"?Ny(e,r.frame,{marks:r.marks,theme:r.theme,...r.scale?{scale:r.scale}:{}}):t==="game"?jm([...(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=ur(o,`${e.name}.${t}${t==="render"&&r.region?`.${r.region.x}-${r.region.y}-${r.region.w}x${r.region.h}`:""}.png`);return lr(a,s),{mode:t,kind:"image",png:s,width:i.width,height:i.height,path:a}}function RW(e,t,r){let o=t.mapDoc,n=o.doc,i=Ht(n,o.world),s=o.region?{...o.region}:void 0,a="";if(o.camera){let g=Py(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 Q(`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=$i(i,l),m=Le(u),d=o.camera?".camera":s?`.${s.x}-${s.y}-${s.w}x${s.h}`:"",f=ur(r,`${e.name}.map${d}.png`);lr(f,m);let p=o.note??uC(n,o.world,i);!o.note&&n.width<=80&&(p+=`
385
+ ${mC(n)}`),p+=`
386
+ 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=lC(n,o.world,{...l,tickRate:t.tickRate});g.length>1&&(h=ur(r,`${e.name}.map${d}.gif`),lr(h,Ls(g,{delta:!0})),p+=`
387
+ 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 IW(e){let t=e.family,r=et(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(`
388
+ `)}import{appendFileSync as PW,existsSync as U1,mkdirSync as jW,readFileSync as L1,statSync as EW}from"node:fs";import{basename as VN,isAbsolute as ZN,join as Wb,resolve as WN}from"node:path";var wd=new Map;function F1(e,t){if(!/^[0-9a-f]{64}$/.test(t))return;let r=Wb(e.dir,"blobs",`${t}.png`);if(!U1(r))return;let o=EW(r).mtimeMs,n=wd.get(r);if(n&&n.mtime===o)return n.img;let i=Xr(L1(r));return wd.set(r,{mtime:o,img:i}),wd.size>16&&wd.delete(wd.keys().next().value),i}function BN(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 TW(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 HN="https://api.openai.com/v1",CW={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 Q("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(`${HN}/images/edits`,{method:"POST",headers:{Authorization:`Bearer ${o}`},body:l})}else s=await n(`${HN}/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 Q(`underlay generate: the request failed: ${BN(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 Q(`underlay generate: OpenAI answered ${s.status}: ${BN(u,o).slice(0,400)}`)}let a=await s.json(),c=a.data?.[0]?.b64_json;if(!c)throw new Q("underlay generate: the answer held no image");return{png:new Uint8Array(Buffer.from(c,"base64")),...a.usage?{usage:a.usage}:{}}}};function AW(e){let[t,r]=e.size,o=new dt(wy(`${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),k=Math.floor(w),_=y-v,$=w-k,x=_*_*(3-2*_),S=$*$*(3-2*$),R=u(v,k)*(1-x)+u(v+1,k)*x,P=u(v,k+1)*(1-x)+u(v+1,k+1)*x;return R*(1-S)+P*S};for(let y=0;y<s;y++)for(let w=0;w<i;w++){let v;if(n){let k=(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[k],n.data[k+1],n.data[k+2]]}else v=[o.nextInt(256),o.nextInt(256),o.nextInt(256)];if(a.length){let k=P=>(a[P][0]-v[0])**2+(a[P][1]-v[1])**2+(a[P][2]-v[2])**2,_=a.reduce((P,j,N)=>k(N)<k(P)?N:P,0),$=e.palette.entries[_].name,x=Object.values(e.palette.ramps).find(P=>P.includes($)),S=P=>{let j=x?.[x.indexOf($)+P],N=j?e.palette.entries.findIndex(T=>T.name===j):-1;return N>=0?N:_},R=m(w/2,y/2)*.5+o.nextInt(1e3)/1e3*.5;v=a[R>.66?S(1):R<.3?S(-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))),k=Math.min(s-1,Math.max(0,Math.floor((y+.5-h)/f)));for(let _=0;_<3;_++)g[(y*t+w)*3+_]=c[(k*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 k=0,_=0;for(let $=-1;$<=1;$++)for(let x=-1;x<=1;x++){let S=w+x,R=y+$;S<0||R<0||S>=t||R>=r||(k+=g[(R*t+S)*3+v],_++)}b.data[(y*t+w)*4+v]=Math.max(0,Math.min(255,Math.round(k/_+o.nextInt(7)-3)))}b.data[(y*t+w)*4+3]=255}return b}var OW={name:"fake",defaults:{model:"draft",quality:"medium"},async generate(e){return{png:Le(AW(e))}}},JN=new Map([CW,OW].map(e=>[e.name,e])),NW={"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:{}}}},MW=.25;function DW(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?TW(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 qW(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 UW=Wb("logs","underlay-costs.jsonl");function Vb(e,t){let r=Wb(e.dir,UW);jW(Wb(r,".."),{recursive:!0}),PW(r,JSON.stringify(t)+`
389
+ `)}var LW=[[1024,1024],[1536,1024],[1024,1536]];function FW(e){if(!e)return[1536,1024];let t=e[0]/e[1];return LW.reduce((r,o)=>Math.abs(Math.log(o[0]/o[1]/t))<Math.abs(Math.log(r[0]/r[1]/t))?o:r)}function VW(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 ZW(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 WW(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 Q(`${r}: at= is a point x,y`);if(n&&(!s||Number(s[1])<1||Number(s[2])<1))throw new Q(`${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 Zb=/^\s*underlay\s+(generate|import)\b/;function No(e){return e.split(/\r?\n/).some(t=>Zb.test(t))}async function Bb(e,t,r){let o=t.split(/\r?\n/),n=!1,i=e.json.underlay??{},s={...NW,...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)&&!Zb.test(c)){n=!0;continue}if(!Zb.test(c))continue;let l=pn(c),u=`line ${a+1}`;if(l.errors.length)throw new Q(`${u}: ${l.errors[0].message}`);if(l.commands.length!==1)throw new Q(`${u}: put underlay ${Zb.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 Q(`${u}: underlay: unexpected '${z.t}'`);let p=f.shift();if(r.confined&&p==="generate")throw new Q(`${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 Q(`${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=WW(d,r.doc,u),w=null,v=null,k=d.get("layout");if(k&&k!=="none"){let z=ZN(k)?k:WN(e.dir,k);if(r.confined&&/\.png$/i.test(k)&&ed(e,z,`${u}: layout`),/\.png$/i.test(k)&&U1(z)){let I=L1(z);w=Xr(I),v=Ai(e,I,".png")}else{if(w=r.doc?ZW(r.doc,k,y??void 0):null,!w)throw new Q(`${u}: layout=${k} is neither a PNG file in the project nor a layer of the asset`);v=Ai(e,Le(w),".png")}}if(p==="import"){let z=f[0];if(!z||f.length>1)throw new Q(`${u}: underlay import <file.png>`);let I=ZN(z)?z:WN(e.dir,z);if(r.confined&&ed(e,I,`${u}: underlay import`),!U1(I))throw new Q(`${u}: underlay import: no file ${z}`);let C=L1(I),U;try{U=Xr(C)}catch(Y){throw new Q(`${u}: underlay import: ${VN(z)}: ${Y.message}`)}let H=Ai(e,C,".png");o[a]=`underlay ${g} blob=${H} image=${U.width}x${U.height}${b}${v?` layout=${v}`:""} from=${tn(VN(z))}`;continue}let _=f[0];if(!_||f.length>1)throw new Q(`${u}: underlay generate "<prompt>" (the prompt in quotes)`);let $=d.get("provider")??i.provider??"openai",x=JN.get($);if(!x)throw new Q(`${u}: no provider '${$}' (providers: ${[...JN.keys()].join(", ")})`);let S=d.get("model")??($===(i.provider??"openai")?i.model:void 0)??x.defaults.model,R=d.get("quality")??i.quality??x.defaults.quality,P=d.get("image")??i.size,j=P?(()=>{let z=/^(\d+)x(\d+)$/.exec(P);if(!z)throw new Q(`${u}: image= is the size to ask for, like 1536x1024`);return[Number(z[1]),Number(z[2])]})():FW(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):MW;if(!Number.isFinite(T)||T<0)throw new Q(`${u}: cap= is US dollars, like 0.25`);let q=`${j[0]}x${j[1]}`,Z=DW($,S,R,q,s,{image:w?j:null,prompt:_}),D={at:r.now,provider:$,model:S,quality:R,size:q,layout:v,prompt:_,estimate:Z,cap:T};if(Z===null)throw Vb(e,{...D,ok:!1,error:"no price for this model, quality and size"}),new Q(`${u}: no price for ${S} at ${R} ${q}, so the cost cap cannot be checked; add it to project.json underlay.prices`);if(Z>T)throw Vb(e,{...D,ok:!1,error:"over the cap"}),new Q(`${u}: ${S} at ${R} ${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:j,model:S,quality:R,layout:w?Le(VW(w,j[0],j[1])):null,...r.doc?{grid:[y.w,y.h],palette:r.doc.palette}:{},layoutImage:w},r)}catch(z){throw Vb(e,{...D,ok:!1,error:z.message}),z}let F;try{F=Xr(V.png)}catch(z){throw new Q(`${u}: the provider's image does not decode: ${z.message}`)}let M=Ai(e,V.png,".png"),L=qW(S,V.usage,s),A=L??Z;Vb(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=${S} quality=${R} cost=${A.toFixed(4).replace(/0+$/,"").replace(/\.$/,"")||"0"}`}return o.join(`
390
+ `)}import{readFileSync as JW,statSync as GW}from"node:fs";import{homedir as KW}from"node:os";import{join as oM}from"node:path";import{existsSync as Wc,mkdirSync as GN,readFileSync as Jb,readdirSync as BW,renameSync as KN,rmSync as iie,writeFileSync as Hb}from"node:fs";import{dirname as Z1,join as mr}from"node:path";import{fileURLToPath as HW}from"node:url";var W1="PCLAWSTATE 1",Gb=".cache",V1=null;function XN(){if(V1)return V1;let e=HW(import.meta.url),t=mr(Z1(e),"..","..","core"),r=[];if(e.endsWith(".ts")&&Wc(mr(t,"src")))for(let n of["src","schemes"]){let i=mr(t,n);if(Wc(i))for(let s of BW(i).sort())/\.(ts|json)$/.test(s)&&r.push(mr(i,s))}else r.push(e);let o=r.map(n=>`${n.slice(t.length)}
391
+ ${Tn(Jb(n))}`);return V1=Tn(Buffer.from(o.join(`
392
+ `),"utf8"))}function vd(e,t,r){let o=r===1?[...e.palettes.values()].map(yo).join(`
393
+ `):"";return Tn(Buffer.concat([Buffer.from(`${XN()}
394
+ ${o}
395
+ `,"utf8"),t]))}function B1(e,t){return mr(e.dir,Gb,"state",`${t}.gwc`)}function YN(e,t,r){let o=B1(e,t);if(!Wc(o))return null;try{let n=Jb(o),i=n.indexOf(10);return i<0||n.subarray(0,i).toString("utf8")!==`${W1} ${r}`?null:uy(n.subarray(i+1))}catch{return null}}function QN(e,t){let r=B1(e,t);if(!Wc(r))return null;let o=Jb(r),n=o.indexOf(10),i=n>0?new RegExp(`^${W1} ([0-9a-f]{64})$`).exec(o.subarray(0,n).toString("utf8")):null;return i?{key:i[1],body:o.subarray(n+1)}:null}function H1(e,t,r,o){let n=B1(e,t);try{let i=mr(e.dir,Gb);GN(Z1(n),{recursive:!0}),Wc(mr(i,".gitignore"))||Hb(mr(i,".gitignore"),`*
396
+ `);let s=`${n}.${process.pid}.tmp`;Hb(s,Buffer.concat([Buffer.from(`${W1} ${r}
397
+ `,"utf8"),o])),KN(s,n)}catch{}}function eM(e,t){return mr(e.dir,Gb,"checks",`${t}.json`)}function tM(e){return Tn(Buffer.from(JSON.stringify([XN(),e]),"utf8"))}function nM(e,t,r){try{let o=JSON.parse(Jb(eM(e,t),"utf8"));return o.key===r?o.out:null}catch{return null}}function rM(e,t,r,o){let n=eM(e,t);try{let i=mr(e.dir,Gb);GN(Z1(n),{recursive:!0}),Wc(mr(i,".gitignore"))||Hb(mr(i,".gitignore"),`*
398
+ `);let s=`${n}.${process.pid}.tmp`;Hb(s,JSON.stringify({key:r,out:o})),KN(s,n)}catch{}}var $d=1<<18,Bc=class extends Q{},Hc=class extends Q{asset;constructor(t){super(`asset '${t}' already exists; set replace to start its tape again`),this.asset=t}};function XW(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 YW=/^(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/,J1=e=>e.flatMap(t=>t.t==="word"?[t.v]:[]);function iM(e,t){let r=[];e.some(n=>YW.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])<Fm?`block R\xB2 ${i[1]} < ${Fm}`:"",i[2]!=="none"&&Number(i[2])<Vm?`material match ${i[2]} < ${Vm}`:""].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 QW=()=>new Date().toISOString().replace(/\.\d{3}Z$/,"Z"),ea=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;hub=new Rb;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??QW,this.checkCache=r.checkCache??!0,this.hub.attach(Fc(t)),this.hub.workerRunning=()=>this.worker.running,this.hub.onPresence=()=>this.emit({type:"presence",presence:this.hub.presence()})}requestsChanged(){this.hub.syncRequests(Fc(this.project),gt(this.project)),this.emit({type:"requests",requests:[...gt(this.project).values()]})}workerStatus(){let t=Xs(this.project.dir);return{enabled:t.enabled,...this.worker,...this.worker.running?{}:{spent:hd(this.project.dir),cap:t.cap}}}setWorker(t){this.worker={...this.worker,...t},this.emit({type:"worker",status:this.workerStatus()}),this.emit({type:"presence",presence:this.hub.presence()})}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.hub.attach(Fc(t)),this.emit({type:"hello",snapshot:this.snapshot()})}setGrid(t){iN(this.project,t),this.emit({type:"hello",snapshot:this.snapshot()})}addPalettes(t){sN(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}=nd(this.project,t),i=vd(this.project,o,Rr(n));this.keys.set(t,i);let s=n.length?YN(this.project,t,i):null;if(s){this.timeline(t).seed(n,n.length,s);let l={doc:s,entries:n,cache:new Pi};return this.states.set(t,l),l}let a=aN(this.project,t,n),c;if(a){let l=ji.resume(Co(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 Q(`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=Zm(n,Co(this.project));if(l.problems.length)throw new Q(`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&&H1(this.project,t,i,zn(c.doc)),this.states.set(t,c),c}timeline(t){let r=this.timelines.get(t);return r||this.timelines.set(t,r=new Nc(Co(this.project))),r}doc(t){let{doc:r}=this.state(t);if(!r)throw new Q(`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 Q(`asset '${t}': ${o.problem}`);return o.doc}async runAsync(t,r={},o={}){if(!No(t.commands))return this.run(t);let n=null,i=t.asset;if(i&&Ao(this.project,i))try{n=this.doc(i)}catch{n=null}let s=await Bb(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=vb(this.project,i.state,p=>{let h=l.docAt(i.state.entries,p);if(h.problem)throw new Q(`asset '${o}': ${h.problem}`);return h.doc},n);this.writePalettes(c);let m=vd(this.project,Buffer.from(ab(i.state.entries),"utf8"),Rr(i.state.entries));this.keys.set(o,m),H1(this.project,o,m,zn(i.state.doc)),this.states.set(o,i.state),this.versions.set(o,++this.clock),this.live=o,this.freshStyle();let d=iM(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}),this.hub.marks(o,t.by,i.added,this.stamp());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?iM(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 Q(`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 Q("seeds: seeds are whole numbers from 1");if(o.length>64)throw new Q("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}
399
+ ${a}`:a,by:t.by},{checks:t.checks});if(!c.ok){if(c.errors.some(f=>/no option 'seed'/.test(f.message)))throw new Q(`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 Q(`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=>XW(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(zn(m.doc)),Buffer.from(zn(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(`
400
+ `)[0].includes(` from=${r} `)))return null;let i=this.doc(t),s=qs(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(`
401
+ `)}batch(t,r=!1){let o=pn(t.commands),n=o.commands[0],i=n?.name==="new",s=n?.name==="fork",a=i||s?J1(n.args)[1]:void 0,c=t.asset??a;if(!c){if(o.errors.length)return{ok:!1,errors:o.errors};throw new Bc("say which asset to draw on (or start the commands with 'new')")}if(a&&t.asset&&a!==t.asset)throw new Q(`the commands create '${a}' but the asset is '${t.asset}'`);let l={doc:null,entries:[]},u=Ao(this.project,c),m=i||s;if(u){if(m&&!t.replace)throw new Hc(c);m||(l=r?{...this.state(c),cache:new Pi}:this.state(c))}else if(!m&&!o.errors.length)throw new Q(`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=zN(this.project,sn(this.project).manifest),p=n1(l,t.commands,{by:t.by,at:this.now(),palettes:Co(this.project),assets:d,assetNames:()=>this.assets(),defaults:f,images:h=>F1(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 Q(`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&&yo(i)!==yo(n))throw new Q(`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=J1(t.args)[0];if(!r)return{doc:null,entries:[]};if(!Ao(this.project,r))throw new Q(`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 Q(`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=lN(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]??gb(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 uN(this.project,o),s}freshStyle(){let t=oM(this.project.dir,"project.json"),r;try{let n=GW(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(JW(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:gb(o)?.from??null}]:[]}catch{return[]}})}themes(){return wO(this.project.json.themes)}themeNamed(t){let r=this.themes().find(o=>o.name===t);if(!r)throw new Q(`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 Q(`frame ${r.frame+1} does not exist (frames 1..${n.frameCount})`);let i=sn(this.project).manifest,s=Cn(i,t),a=s?s.set??s.kind:null,c=s&&i?{peers:i.assets.filter(k=>(k.set??k.kind)===a&&k.name!==t).map(k=>k.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(k=>k.name!==t),{name:t,doc:o,forkOf:l.find(k=>k.name===t)?.forkOf??null}]:l,{ctx:m,problems:d}=vO(t,n,u,this.project.json.style,k=>this.project.palettes.get(k),{...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=k=>`${k}:${this.versions.get(k)??0}`,h=m.world?u.map(k=>k.name):[t,...m.ground?[m.ground.name]:[],...(m.set??[]).map(k=>k.name),...(m.peers??[]).map(k=>k.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(k=>this.keys.has(k))?tM([this.project.json.style,i,[...new Set(h)].sort().map(k=>[k,this.keys.get(k)]),u.map(k=>k.name),[...this.project.palettes.values()].map(yo),d]):null,w=y?nM(this.project,t,y):null;if(w)return this.checkMemo.set(t,{key:g,out:w}),w;let v={results:QC(n,r.checks??Pn,{...m,budget:r.budget,focus:r.focus}),problems:d};return f&&this.checkMemo.set(t,{key:g,out:v}),y&&rM(this.project,t,y,v),v}view(t,r,o={},n,i){let s=n??oM(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=SC(a,d=>F1(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 GC(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=Us(t,d,c,o.ground);if(o.ground&&!f)throw new Q(`no asset '${o.ground}' to use as ground`);let p=o.with?o.with.map(y=>({name:y,doc:this.doc(y)})):Wm(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)=>Lr.indexOf(y.name)-Lr.indexOf(w.name)).flatMap(y=>y===g?[]:[y.from])];l.game={ground:f?.doc??null,with:p.map(y=>y.doc),scale:jo(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 Q(`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=jo(c,this.project.json.grid)),r==="diff"&&a.map&&(l.mapDoc={doc:a,world:Ln(this.assetDocs()),screen:Eo(c,this.project.json.grid),drawScale:jo(c,this.project.json.grid)}),r==="map"&&(a.map||a.kind==="object"||a.footprint)){let d=this.assetDocs(),p={world:Ln(d),region:o.region,camera:o.camera,screen:Eo(c,this.project.json.grid),drawScale:jo(c,this.project.json.grid)};if(a.map)l.mapDoc={doc:a,...p};else{if(o.camera)throw new Q("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 Q(`'${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)??Us(t,p,c,void 0)??p[0];if(!h)throw new Q(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 bd(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 bd(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):Us(t,o,i,void 0)??o.find(y=>y.doc.family);if(!s)throw new Q(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=Un(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=n1({doc:null,entries:[]},h.join(`
402
+ `),{by:"scene",palettes:Co(this.project),assets:y=>o.find(w=>w.name===y)?.doc});if(!g.ok)throw new Q(`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=qs(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 Ti(this.project)}snapshot(){this.freshStyle();let t=this.assets().map(r=>({name:r,entries:this.states.get(r)?.entries??td(this.project,r)}));return{project:{name:this.project.json.name,dir:this.project.dir,home:KW(),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(),presence:this.hub.presence()}}};var jt="claude",eB="pixelclaw",tB=`PixelClaw is a pixel art editor you drive with a small command language. All art is indexed colour (every pixel is a palette entry).
403
+
404
+ 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.
405
+
406
+ 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.
407
+
408
+ 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>.
409
+
410
+ Commands (one per line, or ';' between them; '#' comments). Full reference: docs/commands.md in the PixelClaw repo.
411
+ new tile|sprite|sheet|icon|object|font <name> <W>x<H> [palette=<p>] [wrap=on|off] [cell=WxH] [bg=<colour>]
412
+ px <x,y> [<x,y>...] c=<colour>
413
+ line <x,y> <x,y> [<x,y>...] c=<colour> [pp=on|off] pixel-perfect lines and polylines
414
+ curve <x,y> <ctrl> [<ctrl>] <x,y> c=<colour> quadratic or cubic Bezier, pixel-perfect
415
+ 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]
416
+ fill <x,y> c=<colour> [mode=contiguous|global] [conn=4|8]
417
+ paint <x,y> << rows of palette keys; '.' leaves a pixel, a space clears it
418
+ ..kk..
419
+ >>
420
+ stroke pencil c=<colour> [pp=on|off] <x,y> <x,y>... a freehand drag; stroke eraser <x,y>...
421
+ 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
422
+ 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>
423
+ 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>
424
+ select rect|ellipse|lasso|wand|colour|layer|all|none|invert ... [add|sub|and]; deselect your selection clips your drawing
425
+ clear | shift <dx,dy> [wrap] | flip h|v | rotate 90|180|270 the selection, or your whole layer
426
+ mirror x=11.5 [y=..] live (later strokes mirrored) | mirror off | mirror x=11.5 from=left (copy once)
427
+ dither <x,y> <W>x<H> a= b= [pattern=checker|bayer2|bayer4|bayer8|hlines|vlines] [level=0.25]
428
+ gradient <x,y> <W>x<H> ramp=<ramp> [dir=down|up|right|left|radial] [steps=n] [pattern=none|checker|bayer4..]
429
+ ramp <name> = <darkest> ... <lightest> | palette lock|unlock | palette save as=<new palette>
430
+ 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]
431
+ noise [<x,y> <W>x<H>] ramp=<r> [weights=6,2,1] [cluster=1..3] [density=0.15] [base=<c>|keep] [seed=n]
432
+ scatter [box] stamp=<s>[,<s>]|c=<colour> count=<n> [minDist=<n>] [flip=on] [seed=n]
433
+ voronoi [box] cells=<n> ramp=<r> [gap=<colour>] [relax=1] [seed=n] bricks [box] size=8x4 ramp=<r> [gap=<colour>] [seed=n]
434
+ 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
435
+ 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
436
+ 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=)
437
+ 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
438
+ def tuft(x,y) { px $x,$y $x+1,$y-1 c=moss2 } call tuft 5,18
439
+ 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
440
+ note <x,y> [<W>x<H>] "text" | note done <id>
441
+ undo [group=<g>] [by=<author>] | redo [group=<undo group>]
442
+ fork <from> <to> [at=<n>] (as the first command of a run on a new asset: a branch of <from>)
443
+ Underlays (an image under the art, never exported) and snap:
444
+ underlay generate "<prompt>" [layout=templates/mockup.png|<layer>] [image=1536x1024] [provider=openai|fake] [model=] [quality=low|medium|high] [cap=<usd>] [layer=mockup]
445
+ 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
446
+ 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
447
+ 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)
448
+ import <x,y> asset=<name> region=<x,y,WxH> [layer=<layer>] copy a region of another asset (cut a tile from a snapped scene)
449
+ Fonts and icons:
450
+ 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
451
+ glyph A [advance=<n>|auto] << rows >> (letters and digits as themselves; other characters as U+0021 or "!") font set baseline= line= spacing=
452
+ icon mode=tone|full|channel how an icon is exported (tone: roles recoloured by the game; full: as drawn; channel: pure-RGB masks)
453
+ Autotile families (a sheet of every variant of a scheme: blob47, blob47-round, wang16-corner, path, bridge8, single, face, lane):
454
+ 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)
455
+ family texture inside|outside from=<tile asset> [frame=<n>] copy a seamless tile into the inside or outside texture
456
+ 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)
457
+ 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)
458
+ 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
459
+ 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)
460
+ 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)
461
+ 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]
462
+ 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=)
463
+ 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) >>
464
+ 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
465
+ Maps (cells of tile px holding names; a map redraws itself when a tile changes):
466
+ 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)
467
+ tiles <tiles layer> fill <tile> [<x,y> <W>x<H>] [replace] a one-cell tile on every empty cell (the floor in one line)
468
+ 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)
469
+ 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
470
+ place <asset>|<family>.<variant> <x,y> [layer=] by its anchor cell; footprints may not overlap | move <x,y> <x,y> | remove <x,y>
471
+ 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=]
472
+ 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.
473
+ 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.
474
+
475
+ 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.
476
+
477
+ 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.
478
+
479
+ 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.
480
+
481
+ 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).
482
+
483
+ 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.`,Xe=e=>({type:"text",text:e}),Er=e=>({content:[Xe(e)],isError:!0});function An(e){if(e instanceof Q||e instanceof SyntaxError)return Er(`error: ${e.message}`);throw e}function G1(e,t=""){let[r,...o]=e.cmd.split(`
484
+ `);return[`#${e.seq} ${e.by} ${e.group} ${r}${t}`,...o.map(n=>` ${n}`)].join(`
485
+ `)}function xd(e){return e.kind==="text"?[Xe(e.text),Xe(`saved ${e.path}`)]:[...e.text?[Xe(e.text)]:[],{type:"image",data:Buffer.from(e.png).toString("base64"),mimeType:"image/png"},Xe(`${e.mode}: ${e.width}x${e.height} px, saved ${e.path}`)]}function nB(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 ${Eo(r.json.style,o).join("x")}; draw scale ${jo(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: ${[...vo.values()].map(a=>`${a.name} (${a.variants.length})`).join(", ")}`);let i=ad(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: ${[...cd(r).values()].map(a=>`${a.name} (${a.layout})`).join(", ")}`)}catch(a){n.push(`export profiles: ${a.message}`)}let s=Ti(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(`
486
+ `)}function rB(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 cM(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=>G1(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=>rB(i,n.has(i.id)))),o.push(`diff ${e.from>0?`#${e.from}`:"(nothing)"} \u2192 #${e.to}: ${My(e.before,e.after,Pm(e.before,e.after))}`),o.join(`
487
+ `)}function K1(e,t,r={}){let o=e.writer,n=(s,a)=>{r.confined&&ed(o.project,s,a)},i=new fi({name:eB,version:t},{capabilities:{tools:{}},instructions:tB});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:ae.object({path:ae.string().optional().describe("A project folder to open (conventionally named *.pclaw)"),create:ae.boolean().optional().describe("Create the project at path if it does not exist"),name:ae.string().optional().describe("The new project's name (with create)"),palettes:ae.array(ae.string()).optional().describe("Palette files to add to the project"),grid:ae.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 Q("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(yb)),{content:[Xe(nB(o,e.url()))]}}catch(a){return An(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:ae.object({asset:ae.string().describe("The asset to draw on (or to create, with a leading `new` command)"),commands:ae.string().describe("One or more lines of the command language"),view:ae.enum(Qs).optional().describe("Also return this view of the result"),replace:ae.boolean().optional().describe("With a leading `new` for an existing asset: start its tape again"),dry:ae.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(No(s.commands))return Er("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:jt,replace:s.replace});if(!u.ok)return Er(u.errors.map(f=>`${f.line}:${f.col}: error: ${f.message}`).join(`
488
+ `)+`
489
+ ${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(`
490
+ `)[0]}`)),m.push(u.warnings.length?`warnings: ${u.warnings.join("; ")}`:"warnings: none"),u.doc&&m.push(zi(u.results));let d=[Xe(m.join(`
491
+ `))];return s.view&&u.doc&&!["render","grid","tile3x3"].includes(s.view)?Er(`error: a dry run shows render, grid or tile3x3 (not ${s.view})`):(s.view&&u.doc&&d.push(...xd(bd(u.doc,s.view,{frame:Me(u.doc,jt).frame,tickRate:o.project.json.tickRate??60},aM(o.project.dir,"views","dry")))),{content:d})}let a=await o.runAsync({asset:s.asset,commands:s.commands,by:jt,replace:s.replace},{},{confined:r.confined});if(!a.ok)return Er(a.errors.map(u=>`${u.line}:${u.col}: error: ${u.message}`).join(`
492
+ `)+`
493
+ ${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=>G1(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(zi(o.checks(a.asset,{budget:$d,focus:Me(a.doc,jt).frame}).results));let l=[Xe(c.join(`
494
+ `))];if(s.view&&a.doc){let u=o.view(a.asset,s.view,{frame:Me(a.doc,jt).frame});o.showEye(a.asset,u),l.push(...xd(u))}return{content:l}}catch(a){return An(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:ae.object({asset:ae.string(),mode:ae.enum(Qs).default("render"),scale:ae.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:ae.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:ae.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:ae.number().int().min(0).optional().describe("diff only: compare with the document after this command number (default: before the latest group)"),frame:ae.number().int().min(1).optional().describe("render, grid, tile3x3, game, recolour: the frame to show (default: the frame you are drawing on)"),marks:ae.string().optional().describe('render, tile3x3, game: circle the pixels checks flag in magenta: "failing", or check names ("orphans,jaggies")'),theme:ae.string().optional().describe("render, tile3x3, game: show role entries under this preview theme"),themes:ae.array(ae.string()).optional().describe("recolour: the themes to show (default: the first six)"),ground:ae.string().optional().describe("game: the ground tile (default: the style guide's, else the first tile)"),with:ae.array(ae.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:ae.string().optional().describe(`map: the map's size in tiles, "16x12" (default 12x10)`),seed:ae.number().int().min(1).optional().describe("map: the random island's seed (default 1)")})},s=>o.enqueue(()=>{try{let a=s.region?Fb(s.region):void 0;if(a===null)return Er('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),jt).frame,l=oB(s.marks);if(l===null)return Er(`error: marks must be "failing" or check names (${Pn.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 Er('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:xd(f)}}catch(a){return An(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:ae.object({asset:ae.string(),line:ae.string().describe("One generator command; any seed= in it is replaced"),before:ae.string().optional().describe("Commands run first in the same batch (a selection, a clear)"),count:ae.number().int().min(1).max(64).optional().describe("How many seeds (default 8)"),from:ae.number().int().min(1).optional().describe("The first seed (default 1); seeds from..from+count-1"),seeds:ae.array(ae.number().int().min(1)).max(64).optional().describe("These seeds instead"),checks:ae.array(ae.enum(Pn)).optional().describe("Rank by these checks only (default all)"),apply:ae.boolean().optional().describe("Run the best seed for real"),view:ae.enum(Qs).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:jt,count:s.count,from:s.from,seeds:s.seeds,checks:s.checks});if(!a.ok)return Er(a.errors.map(u=>`${u.line}:${u.col}: error: ${u.message}`).join(`
495
+ `));let c=[Ub(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}
496
+ ${u.line}`:u.line,by:jt});if(!m.ok)return Er(m.errors.map(d=>`${d.line}:${d.col}: error: ${d.message}`).join(`
497
+ `));if(c.push("",`applied seed ${u.seed} as group ${m.group}; ${m.changed} px changed`),m.doc&&c.push(zi(o.checks(s.asset,{budget:$d}).results)),l.push(Xe(c.join(`
498
+ `))),s.view&&m.doc){let d=o.view(s.asset,s.view,{frame:Me(m.doc,jt).frame});o.showEye(s.asset,d),l.push(...xd(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:[Xe(c.join(`
499
+ `))]}}catch(a){return An(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:ae.object({asset:ae.string(),from:ae.number().int().optional().describe("First command number"),to:ae.number().int().optional().describe("Last command number"),last:ae.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:[Xe([u,...c.entries.map(m=>G1(m,l.has(m.group)?" (undone)":""))].join(`
500
+ `))]}}catch(a){return An(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:ae.object({asset:ae.string().optional().describe("Only this asset (default: every asset)"),since:ae.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(jt,{asset:s.asset,since:s.since});if(a.length===0)return{content:[Xe(`No changes since you last looked${s.asset?` at ${s.asset}`:""}.`)]};let c=[Xe(`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(Xe(l.after.map&&u.kind==="image"?cM(l).replace(/\ndiff [^\n]*$/,`
501
+ diff ${l.from>0?`#${l.from}`:"(nothing)"} \u2192 #${l.to}: ${u.text??""}`):cM(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(Xe(`diff image: ${u.width}x${u.height} px, saved ${u.path}`)))}return{content:c}}catch(a){return An(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: ${Pn.join(", ")}.`,annotations:{readOnlyHint:!0},inputSchema:ae.object({asset:ae.string().optional().describe("The asset to check (default: every asset, one summary line each)"),checks:ae.array(ae.enum(Pn)).optional().describe("Only these checks (default: all)"),frame:ae.number().int().min(1).optional().describe("Only this frame (default: every frame; flagged pixels name their frame)"),ground:ae.string().optional().describe("readability: the ground tile (default: the style guide's, else the first tile)"),ref:ae.string().optional().describe("revert: the reference asset the art must not simply copy"),set:ae.array(ae.string()).optional().describe("readability: the assets its silhouette must differ from (default: same kind and size)"),image:ae.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}: ${zi(o.checks(f,{checks:s.checks}).results).replace(/^checks: /,"")}`}catch(p){return`${f}: cannot check: ${p.message}`}});return{content:[Xe(d.length?d.join(`
502
+ `):"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=[Xe(qb(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),jt).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(...xd(f))}return{content:u}}catch(a){return An(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:ae.object({profile:ae.string().optional().describe("A profile name (see project) or a profile .json path (default png)"),assets:ae.array(ae.string()).optional().describe("The assets to export (default: all)"),asset:ae.string().optional().describe("With format: the asset"),format:ae.enum(id).optional(),dest:ae.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 Q("format= exports one asset: give asset");let l=xb(o.doc(s.asset),o.assetDocs(),s.format,s.dest??aM(o.project.dir,"exports",s.format));return{content:[Xe(`${s.format}: wrote ${l.length} files
503
+ ${l.map(u=>` ${u}`).join(`
504
+ `)}`)]}}let a=Sb(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:[Xe(`${s.profile??"png"}: ${a.images} images, wrote ${a.files.length} files into ${a.dir}
505
+ ${c.map(l=>` ${l}`).join(`
506
+ `)}${a.notes.length?`
507
+ notes:
508
+ ${a.notes.map(l=>` ${l}`).join(`
509
+ `)}`:""}`)]}}catch(a){return An(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:ae.object({path:ae.string().describe("A .png or .aseprite file, a folder of them, or (with profile) the folder an export wrote"),profile:ae.string().optional(),as:ae.string().regex(/^[a-z][a-z0-9_-]*$/).optional().describe("The new asset's name (one file; default: the file's)"),kind:ae.enum(["sprite","tile","object","icon","sheet"]).optional(),palette:ae.string().optional(),build:ae.boolean().optional(),grid:ae.string().regex(/^\d+x\d+$/).optional(),cells:ae.boolean().optional(),slice:ae.string().regex(/^\d+x\d+$/).optional().describe("Cut the sheet into assets of this cell size"),offset:ae.string().regex(/^\d+,\d+$/).optional(),gap:ae.string().regex(/^\d+,\d+$/).optional(),pattern:ae.string().optional(),names:ae.array(ae.string().regex(/^[a-z][a-z0-9_-]*$/)).optional(),namesFrom:ae.enum(["manifest"]).optional(),set:ae.string().optional().describe("The manifest set for new entries (and for namesFrom)"),wrap:ae.boolean().optional().describe("Tiles: on a wrapping canvas"),manifest:ae.boolean().optional().describe("Add manifest entries for the new assets (default: when there is a manifest)"),replace:ae.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=Uc(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},jt);return{content:[Xe(u.text||"nothing to import")]}}let c=ld(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:jt,replace:s.replace});if(!m.ok)throw new Q(`${u.name}: ${m.errors.map(d=>`${d.line}:${d.col} ${d.message}`).join("; ")}`);l.push(u.name)}return{content:[Xe(zb(c,l)||"nothing to import")]}}catch(a){return An(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:ae.object({action:ae.enum(["request","reply","cancel"]).optional().describe("Default request"),kind:ae.enum(["draw","change","add"]).optional(),asset:ae.string().optional().describe("draw, change: the asset"),note:ae.string().optional().describe("change: what should change; draw, add: anything to know"),entry:ae.record(ae.string(),ae.unknown()).optional().describe('add: the manifest entry, e.g. { "name": "crate", "kind": "sprite", "size": "16x16", "set": "props", "description": "\u2026" }'),id:ae.string().regex(/^r\d+$/).optional().describe("reply, cancel: the request"),text:ae.string().optional().describe("reply: the answer; cancel: why")})},s=>o.enqueue(()=>{try{let a=Gs(o,jt,ud(s));return o.requestsChanged(),{content:[Xe(to(a))]}}catch(a){return An(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:ae.object({action:ae.enum(["next","progress","done","blocked","list"]).optional(),id:ae.string().regex(/^r\d+$/).optional().describe("A request id (default: the next open one, or the one you claimed)"),text:ae.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"){r.confined||o.hub.touch(jt);let u=En(gt(o.project));return r.confined||md(o,u.filter(m=>m.state==="open").map(m=>m.id),jt),{content:[Xe(u.length?u.map(m=>to(m)).join(`
510
+ `):"no open requests")]}}let c=a==="next"?Ks(o,jt,{action:a,id:s.id}):Ks(o,jt,{action:a,id:s.id,text:s.text??""});if(o.requestsChanged(),!c.request)return{content:[Xe(`${c.message}. Carry on with the plan (call plan for what is left).`)]};let l=c.request;if(a!=="next"){let u=En(gt(o.project)).filter(m=>m.state==="open").length;return{content:[Xe(`${c.message}${a==="progress"?"":`. ${u?`${u} open request${u===1?"":"s"} left: call work for the next.`:"No open requests left."}`}`)]}}return{content:[Xe(`${c.message}
511
+ ${Eb(o,l,jb)}`)]}}catch(a){return An(a)}})),r.confined||i.registerTool("await_requests",{title:"Wait for requests and feedback",description:"Wait until a person files, answers or withdraws a request, or approves or rejects an asset in the dashboard, then return what happened (with the next step: `work` claims a request, `changes` reads a change). Returns empty when the timeout passes. Pass back the returned cursor as `cursor` so nothing is missed or repeated; with none, requests still open and unseen are returned. While you are waiting the dashboard shows that an agent is listening, and the requests handed to you are marked seen. A model is not woken by anything else, so for long waits between tasks run `pixelclaw await <project>` in the background instead (its exit wakes you).",inputSchema:ae.object({timeout:ae.number().int().min(1).max(120).optional().describe("Seconds to wait (default 30, at most 120)"),cursor:ae.string().optional().describe("The cursor the last call returned")})},async(s,a)=>{try{let c=await Pb(o,{cursor:s.cursor,timeoutS:Math.min(120,s.timeout??30),by:jt,via:"mcp",signal:a?.signal});return{content:[Xe(Ib(c.events,c.cursor))]}}catch(c){return An(c)}}),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:ae.object({assets:ae.array(ae.string()).optional().describe("The assets to review (default: all, or the set's)"),set:ae.string().optional().describe("A set from the manifest: its assets (drawn so far) are reviewed"),name:ae.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:ae.string().regex(/^\d+x\d+$/).optional().describe("Families: the map's size in tiles (default 16x12)"),seed:ae.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=Lb(o,{assets:s.assets,set:s.set,name:s.name,map:{cols:a,rows:c,seed:s.seed}});return{content:[Xe(`review bundle: ${l.dir}
512
+ ${l.files.length} files: ${l.files.join(", ")}
513
+ Give the folder to a fresh agent: "Review the art in ${l.dir} by following rubric.md in it."`)]}}catch(a){return An(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:ae.object({set:ae.string().optional().describe("Only this set"),manifest:ae.record(ae.string(),ae.unknown()).optional().describe("Write this manifest (validated)"),templates:ae.boolean().optional().describe("Draw the flat templates from the manifest"),seed:ae.number().int().min(1).optional().describe("Templates: the layout's seed (default 1)"),order:ae.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 l=Oi(o.project,s.manifest);if(!l.manifest)return Er(`the manifest was not written; ${l.errors.length} problem${l.errors.length===1?"":"s"}:
514
+ ${l.errors.map(u=>` ${u.path||"(top)"}: ${u.message}`).join(`
515
+ `)}`);a.push(Xe(`wrote manifest.json: ${l.manifest.assets.length} assets`)),o.planChanged()}if(s.templates){let l=Cb(o,{seed:s.seed});a.push(Xe(`templates in ${l.dir}: ${l.files.join(", ")}`)),a.push({type:"image",data:sM(`${l.dir}/mockup@2x.png`).toString("base64"),mimeType:"image/png"}),a.push(Xe(sM(`${l.dir}/mockup.txt`,"utf8")))}r.confined||(o.hub.touch(jt),md(o,[...gt(o.project).values()].filter(l=>l.state==="open").map(l=>l.id),jt)),a.push(Xe(Tb(Ni(o,{set:s.set}),{order:s.order})));let c=xN(o);return c&&a.push(Xe(c)),a.push(Xe(`the dashboard (for the person): ${e.url()}&tab=dashboard`)),{content:a}}catch(a){return An(a)}})),i}function oB(e){if(!e)return;if(e.trim()==="failing")return"failing";let t=e.split(",").map(r=>r.trim()).filter(Boolean);return t.every(r=>Pn.includes(r))?t:null}import{createHash as iB}from"node:crypto";import{chmodSync as lM,existsSync as sB,mkdirSync as aB,readFileSync as uM,realpathSync as cB,rmSync as mM,statSync as lB,writeFileSync as uB}from"node:fs";import{homedir as mB}from"node:os";import{join as X1,resolve as Q1}from"node:path";function dM(){let e=process.env.PIXELCLAW_STATE_DIR;if(e)return Q1(e);let t=process.env.XDG_RUNTIME_DIR;return t?X1(t,"pixelclaw"):X1(mB(),".pixelclaw","run")}function ez(e){try{return cB(e)}catch{return Q1(e)}}function tz(e){return X1(dM(),iB("sha256").update(ez(e)).digest("hex").slice(0,24)+".json")}var Y1=process.platform!=="win32";function nz(e,t){let r=dM();aB(r,{recursive:!0,mode:448}),Y1&&lM(r,448);let o=tz(e);mM(o,{force:!0}),uB(o,JSON.stringify({pid:process.pid,dir:ez(e),...t})+`
516
+ `,{mode:384}),Y1&&lM(o,384)}function rz(e){let t=tz(e);try{JSON.parse(uM(t,"utf8")).pid===process.pid&&mM(t,{force:!0})}catch{}}function dB(e){let t=tz(e);if(!sB(t))return null;try{if(Y1&&(lB(t).mode&63)!==0)return null;let r=JSON.parse(uM(t,"utf8"));return typeof r.token=="string"&&typeof r.url=="string"&&rd(r.pid)?r:null}catch{return null}}function Jc(e){let t=Ci(ez(e))??Ci(Q1(e));if(!t)return null;let r=dB(e);return!r||r.pid!==t.pid?null:{base:new URL(t.url).origin,token:r.token,pid:t.pid,dir:r.dir}}function fM(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="http:"&&t.protocol!=="https:")return null;let r=t.searchParams.get("token");return r?{base:t.origin,token:r,pid:null,dir:null}:null}var hM="0.2.0",oz=7417;function gM(e,t,r,o){if(pB(hB(e,"project.json")))return $t(e);if(!t)throw new Q(`${e} is not a PixelClaw project (no project.json); pass create: true to make one`);return o(`pixelclaw: created an empty project at ${e}`),hb(e,{name:r,palettes:[]})}async function iz(e){let t=e.log??(h=>process.stderr.write(h+`
517
+ `)),r=e.token??fB(16).toString("hex"),o=pM(e.project),n=new ea(gM(o,!0,void 0,t)),i,s={writer:n,url:()=>i.url,open(h,g){let b=pM(h);if(b===n.project.dir)return;if(a.running())throw new Q("the worker is running on this project; stop it before opening another");let y=gM(b,g.create,g.name,t);_1(b,i.url),nz(b,{url:i.url.replace(/\?.*$/,""),token:r}),$b(n.project.dir),rz(n.project.dir),n.setProject(y),t(`pixelclaw: now serving ${b}`)}},a=new Nb(n,()=>({url:`http://127.0.0.1:${i.port}/mcp`}));i=await LN({writer:n,token:r,port:e.port??oz,mcp:h=>K1(s,hM,h),worker:a,runCli:e.runCli});try{_1(o,i.url),nz(o,{url:i.url.replace(/\?.*$/,""),token:r})}catch(h){throw $b(o),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(),$b(n.project.dir),rz(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=uT(()=>K1(s,hM),{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 JB}from"node:path";import{cpSync as yM,existsSync as Gc,mkdirSync as gB,readFileSync as _d,readdirSync as yB}from"node:fs";import{homedir as bB}from"node:os";import{dirname as wB,join as Vn,relative as vB}from"node:path";import{fileURLToPath as $B}from"node:url";var bM={out:e=>process.stdout.write(e),err:e=>process.stderr.write(e),stdin:()=>_d(0,"utf8"),now:()=>new Date().toISOString().replace(/\.\d{3}Z$/,"Z")},Kc=`pixelclaw: a pixel art editor driven by commands
518
+
519
+ pixelclaw new <project> [--name <name>] [--palette <file.json|.hex|.gpl>]... [--grid <px>]
520
+ Create a project folder. The first palette becomes the default. --grid is the tile size
521
+ (default 24): new maps, the camera (16x9 cells) and the draw scale (1x from 48 px) follow it.
522
+ pixelclaw new <project> <kind> <name> <W>x<H> [palette=..] [wrap=on|off] [cell=WxH] [bg=..] [--replace]
523
+ Create an asset (kinds: tile, sprite, sheet, icon, object, map, \u2026). Same as running a 'new' command.
524
+ pixelclaw run <project> (<script.pclaw> | - | -e "<commands>") [--asset <name>] [--replace] [--by <author>] [--view <mode>]
525
+ Apply commands as one undo group. Any error applies nothing. --dry applies them to a copy,
526
+ prints the checks and keeps nothing.
527
+ A script that starts with 'new' creates the asset (--replace starts its tape again).
528
+ underlay generate|import lines are resolved first (an image provider, the key from
529
+ OPENAI_API_KEY, a cost cap per call, logs/underlay-costs.jsonl; or a PNG file).
530
+ pixelclaw seeds <project> <asset> <generator line> [--count 8] [--from 1 | --seeds 3,7,9] [--checks a,b] [--before "<commands>"] [--apply]
531
+ Try the line (noise, scatter, voronoi, bricks, map gen, family coverage, \u2026) with each seed as a
532
+ dry run and rank the seeds by the checks; --apply runs the best one.
533
+ 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>]
534
+ [--marks failing|<check>,...] [--theme <name>] [--themes a,b,c] [--ground <tile>] [--with <asset>]... [--size CxR] [--seed N] [--camera x,y]
535
+ Write views (default: <project>/views/<asset>.<mode>.png|txt). The grid is also printed.
536
+ diff shows what the latest group changed; game shows a sprite on its ground at 1x and the
537
+ draw scale beside its set; recolour shows role art under preview themes; map puts a family
538
+ on a random island (--size, --seed; overlays --with) with the seam score; family shows each
539
+ variant among its neighbours; all is render, grid and tile3x3. --marks circles the pixels
540
+ checks flag. map of a map document: the whole map at 1x, --region x,y,WxH (cells) or
541
+ --camera x,y (the engine's screen around a cell) at game scale; of an object: on its ground.
542
+ pixelclaw check <project> [<asset>...] [--checks a,b] [--frame N] [--ground <tile>] [--ref <asset>] [--marks]
543
+ Run the quality checks against the style guide (project.json style): scores, pass or fail,
544
+ and the flagged pixels. Exits 1 if any check fails. --marks writes the render (tile3x3 for
545
+ tiles) with the flagged pixels circled.
546
+ pixelclaw review <project> [<asset>...] [--set <manifest set>] [--name <name>] [--size CxR] [--seed N]
547
+ Write a blind review bundle under <project>/reviews/<date>-<name>/ (rubric.md inside; brief.md
548
+ from the manifest). --set reviews a manifest set's drawn assets.
549
+ pixelclaw plan <project> [--set <set>] [--order set|scene] [--json] [--manifest <file.json>] [--templates [--seed N]]
550
+ The asset plan (manifest.json) and each asset's status: planned, drafted, checked, reviewed,
551
+ approved, exported; requests from people first; what is left and what is failing (by set, or
552
+ scene by scene with what each still needs). --manifest writes a manifest (checked first);
553
+ --templates draws the flat templates (mockup screen, coverage maps) into templates/.
554
+ 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>]
555
+ Ask for work as the dashboard does: draw a planned asset, change a drawn one (also writes
556
+ mark rejected "<note>" on its tape), or add a new asset (its manifest entry, validated first).
557
+ Without a kind, lists the requests still open, claimed or blocked (open ones say seen by
558
+ <agent> once an agent has been handed them). While a server runs it is sent to that server.
559
+ pixelclaw reply <project> <id> "<answer>" [--by <author>] answer a blocked request (it opens again)
560
+ pixelclaw cancel <project> <id> ["<why>"] [--by <author>] withdraw a request
561
+ pixelclaw work <project> list | claim [<id>] | progress [<id>] "<note>" | block [<id>] "<question>" | done [<id>] "<what changed>" [--by <agent>]
562
+ An agent's side of the request queue, for a session without PixelClaw's MCP tools (the MCP
563
+ work tool does the same): list hands over the open requests (the cards say seen by
564
+ <agent>), claim takes the next open one or <id> and prints what is asked, progress posts a
565
+ note the person sees, block stops it with one clear question, done finishes it with what
566
+ changed (only when the asset passes its checks). After claim the id may be left out. Any
567
+ error applies nothing. --by names the agent (default claude). With a server running these
568
+ go through it, so the dashboard's cards move live and the agent shows as listening.
569
+ pixelclaw work <project> start [--port N] (also: pixelclaw work <project> [--port N])
570
+ Work the request queue with a headless Claude Code session (claude -p with the PixelClaw MCP
571
+ server and the skill) until it is empty or the budget cap is reached. Runs only when
572
+ project.json has "worker": { "enabled": true } (it spends money; cap, command and args are
573
+ settings there; docs/worker.md). Never two at once; with a server running, use its
574
+ dashboard's Start Claude button instead. The log is logs/worker.log (shown in the dashboard).
575
+ pixelclaw skill install [--dest <dir> | --project <dir>]
576
+ Install the Claude Code skill (workflows, house rules, the blind-review hand-off) into
577
+ ~/.claude/skills/pixelclaw (or <dir>/.claude/skills/pixelclaw). skill path prints where it is.
578
+ pixelclaw export <project> [<asset>...] [--profile <name|file.json>] [--out <dir>]
579
+ Write assets through an export profile (default png): built-in png, atlas, tiled, godot,
580
+ aseprite-json, aseprite, or the project's profiles/*.json (docs/profiles.md). Without assets,
581
+ all; a map brings what it draws. Default folder: <project>/exports/<profile>/.
582
+ pixelclaw export <project> <asset> --format split|png|strip|bmfont [--out <dir>]
583
+ split: an oversized asset as one-cell pieces plus a stamp; png: a map at 1x or a first frame;
584
+ strip: a font as a glyph strip (red separator columns) plus its characters; bmfont: a font as .fnt + page.
585
+ pixelclaw import <project> <file.png|file.aseprite|folder> [--profile <name>] [--as <name>] [--kind <kind>]
586
+ [--palette <name> | --build] [--grid WxH [--cells]] [--slice WxH [--offset x,y] [--gap x,y]]
587
+ [--pattern '{name}_{n}' | --names a,b,c | --names-from manifest] [--set <set>] [--wrap] [--no-manifest] [--by <author>] [--replace]
588
+ A PNG or .aseprite file becomes a new asset quantised to a palette (--build: one made from
589
+ the image); --grid slices a sheet into frames (--cells: one image with that cell grid);
590
+ --slice cuts a sheet into separate assets, one per non-empty cell, named by a pattern, a
591
+ list, or the manifest's planned entries (of --set) in order. A folder imports every PNG and
592
+ .aseprite in it. New assets get manifest entries (in --set) and every check is run. With
593
+ --profile, a folder an export wrote is read back by name and compared with the project;
594
+ images no asset exports become new assets.
595
+ pixelclaw upgrade <project> [<asset>...]
596
+ Rewrite language 1 tapes in the current language: the palette goes into the 'new'
597
+ line. Each is replayed before and after; it is written only if the pixels are the same.
598
+ pixelclaw verify <project> [<asset>...]
599
+ Replay every tape and compare with asset.json, preview.png and checkpoints.
600
+ pixelclaw await <project-folder | watch-url> [--timeout <seconds>, default 600] [--since <cursor>] [--as <name>] [--json]
601
+ Wait on the running server for what people ask in the dashboard (a request, a reply, a
602
+ withdrawn request, or an approval, rejection or review mark), print the events with their
603
+ next step (work claims a request; changes reads a change) and a cursor, then EXIT. Run it in
604
+ the background and restart it with --since <cursor> after each exit: its exit is what wakes
605
+ an agent. Exit 0 with events, 3 on timeout, 1 if no server can be reached. Requests handed
606
+ over are recorded as seen by --as (default claude). Works with serve --no-mcp.
607
+ pixelclaw serve --project <project> [--port 7417] [--no-mcp]
608
+ Own the project: MCP on stdin/stdout for the agent, and the live watch view on
609
+ http://127.0.0.1:<port>/?token=... (printed to stderr). Creates the project if needed.
610
+
611
+ While a server runs (pixelclaw serve): commands that write (new, run, seeds --apply, export,
612
+ import, review, plan --manifest/--templates, request, reply, cancel, work) are sent to it over HTTP,
613
+ found through the project's lock and a token file only you can read, so they go through its
614
+ writer and a connected dashboard updates live. Read-only commands read the files. If the server
615
+ cannot be reached the command runs directly. upgrade still needs the server stopped.
616
+
617
+ Command reference: docs/commands.md
618
+ `,Se=class extends Error{};function Zn(e,t){return e.writer??new ea(t,{now:e.now})}function wt(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 Se(`${s} needs a value`);n.set(a,[...n.get(a)??[],c])}else if(r.includes(a))n.set(a,[""]);else throw new Se(`unknown option ${s}`)}else o.push(s)}return{pos:o,flags:n}}var $e=(e,t)=>e.flags.get(t)?.at(-1);function sz(e,t,r){for(let o of r)e.err(`${t}:${o.line}:${o.col}: error: ${o.message}
619
+ `);e.err(`${r.length} error${r.length===1?"":"s"}; nothing was applied.
620
+ `)}function xB(e,t,r){let o=(r.flags.get("palette")??[]).map(yb),n=$e(r,"grid");if(n!==void 0&&(!/^\d+$/.test(n)||Number(n)<4||Number(n)>256))throw new Se("new: --grid is the tile size in pixels, 4..256");let i=hb(t,{name:$e(r,"name"),palettes:o,...n!==void 0?{grid:Number(n)}:{}});e.out(`created project '${i.json.name}' at ${t}
621
+ `);for(let s of i.palettes.values())e.out(` palette ${s.name}: ${s.entries.length} entries${s.name===i.json.defaultPalette?" (default)":""}
622
+ `);return 0}function _B(e,t){return new ea(e).state(t)}function Mo(e){let t=Ci(e.dir);if(t)throw new Q(`a pixelclaw server (pid ${t.pid}) owns ${e.dir} and the command could not be sent to it (its token file must be readable by you); send commands through it (MCP: run, export, import, request; or its dashboard), or stop it first`)}function az(e,t,r,o,n){let i=Zn(e,t);if(n.dry)return kB(e,i,r,o,n);Mo(t);let s;try{s=i.run({asset:n.asset,commands:r,by:n.by,replace:n.replace})}catch(a){if(a instanceof Bc)return e.err(`error: say which asset with --asset <name> (or start the script with 'new')
623
+ `),{code:1};if(a instanceof Hc)return e.err(`error: asset '${a.asset}' already exists; use --replace to start its tape again
624
+ `),{code:1};throw a}if(!s.ok)return sz(e,o,s.errors),{code:1};if(!s.doc)return e.out(`nothing to do
625
+ `),{code:0};if(s.added.length===0)return e.out(`${s.asset}: no commands
626
+ `),{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
627
+ `),e.out(` tape: ${s.commands} commands in ${s.groups} group${s.groups===1?"":"s"}; preview: ${Vn(s.dir,"preview.png")}
628
+ `);for(let a of s.warnings)e.out(` warning: ${a}
629
+ `);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})
630
+ `),e.out(` ${zi(i.checks(s.asset,{budget:$d}).results)}
631
+ `),{code:0,doc:s.doc}}function kB(e,t,r,o,n){if(No(r))throw new Se("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 Bc)return e.err(`error: say which asset with --asset <name> (or start the script with 'new')
632
+ `),{code:1};if(s instanceof Hc)return e.err(`error: asset '${s.asset}' already exists; use --replace to try starting its tape again
633
+ `),{code:1};throw s}if(!i.ok)return sz(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
634
+ `);for(let s of i.warnings)e.out(` warning: ${s}
635
+ `);return i.doc&&e.out(` ${zi(i.results)}
636
+ `),{code:0,doc:i.doc??void 0}}function SB(e,t){let[r,o,...n]=t.pos;if(!r||!o||!n.length)throw new Se("seeds: give a project, an asset and a generator line");let i=$t(r),s=p=>{let h=$e(t,p);if(h===void 0)return;let g=Number(h);if(!Number.isInteger(g)||g<1)throw new Se(`--${p} must be a whole number from 1`);return g},a=$e(t,"checks")?.split(",");for(let p of a??[])if(!Hy(p))throw new Se(`unknown check '${p}' (checks: ${Pn.join(", ")})`);let c=$e(t,"seeds")?.split(",").map(Number),l=Zn(e,i),u=$e(t,"by")??"claude",m=$e(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 sz(e,"<line>",d.errors),1;if(e.out(Ub(o,d.trials)+`
637
+ `),!t.flags.has("apply")||!d.trials[0])return 0;let f=d.trials[0];return az(e,i,m?`${m}
638
+ ${f.line}`:f.line,"<seeds>",{asset:o,replace:!1,by:u}).code}function zB(e,t,r){let o=$t(t),n="new "+r.pos.slice(1).join(" ");return az(e,o,n,"<new>",{replace:r.flags.has("replace"),by:$e(r,"by")??"claude"}).code}function RB(e,t){let[r,o]=t.pos;if(!r)throw new Se("run: give a project folder");let n=$t(r),i,s,a=t.flags.get("e");if(a){if(o)throw new Se("run: give a script or -e, not both");i=a.join(`
639
+ `),s="<-e>"}else if(o==="-")i=e.stdin(),s="<stdin>";else if(o){if(!Gc(o))throw new Se(`run: no such script ${o}`);i=_d(o,"utf8"),s=o}else throw new Se('run: give a script file, - for stdin, or -e "<commands>"');let c=az(e,n,i,s,{asset:$e(t,"asset"),replace:t.flags.has("replace"),by:$e(t,"by")??"claude",dry:t.flags.has("dry")});return c.code===0&&c.doc&&t.flags.has("view")?$M(e,n,c.doc,t.flags.get("view"),t):c.code}var an={new:[["name","palette","by","grid"],["replace"]],run:[["asset","by","e","view","scale","region","out","frame","marks","theme","themes","ground","with","size","seed","camera"],["replace","dry"]],seeds:[["count","from","seeds","checks","before","by"],["apply"]],export:[["format","out","profile"],[]],import:[["profile","as","kind","palette","grid","by","slice","offset","gap","pattern","names","names-from","set"],["build","cells","replace","wrap","no-manifest"]],review:[["name","set","size","seed"],[]],plan:[["set","manifest","seed","order"],["json","templates"]],request:[["note","by","kind","size","set","description","height"],[]],reply:[["by"],[]],cancel:[["by"],[]],work:[["by","port"],[]]},Kb=["list","claim","progress","block","done"];function wM(e){if(e[0]!=="work")return!1;let t;try{t=wt(e.slice(1),...an.work)}catch{return!0}return t.pos[1]===void 0||t.pos[1]==="start"}var Ise=an.run[0];async function vM(e,t=bM){if(e[0]!=="run")return e;let r;try{r=wt(e.slice(1),...an.run)}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(`
640
+ `):n==="-"?t.stdin():n&&Gc(n)?_d(n,"utf8"):null;if(s===null||!No(s)&&n!=="-")return e;let a=$t(o);No(s)&&!Jc(o)&&Mo(a);let c=s;if(No(s)){let u=Zn(t,a),m=$e(r,"asset"),d=null;if(m&&Ti(a).includes(m))try{d=u.doc(m)}catch{d=null}c=await Bb(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 $M(e,t,r,o,n){let i=o.length?o:["render"];i.includes("all")&&(i=["render","grid","tile3x3"]);for(let $ of i)if(!FN($))throw new Se(`unknown view '${$}' (views: ${Qs.join(", ")}, all)`);let s=$e(n,"scale"),a=s===void 0?void 0:Number(s);if(a!==void 0&&(!Number.isInteger(a)||a<1||a>64))throw new Se("--scale must be an integer 1..64");let c=$e(n,"region"),l=c?Fb(c):void 0;if(l===null)throw new Se('--region must look like 8,0,12x10 or "8,0 12x10"');if(l&&(l.w<1||l.h<1))throw new Se("--region size must be at least 1x1");let u=$e(n,"camera"),m=u?/^(\d+),(\d+)$/.exec(u):null;if(u&&!m)throw new Se("--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 Se(`--region runs past the ${r.width}x${r.height} canvas`);let f=$e(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 Se(`--frame must be 1..${r.frameCount}`);let h=$e(n,"marks"),g=h===void 0?void 0:h==="failing"?"failing":h.split(",").map($=>$.trim());if(Array.isArray(g)&&!g.every(Hy))throw new Se(`--marks takes failing or check names (${Pn.join(", ")})`);let b=$e(n,"size"),y=b?/^(\d+)x(\d+)$/.exec(b):null;if(b&&!y)throw new Se("--size must look like 16x12 (tiles)");let w=y?{cols:Number(y[1]),rows:Number(y[2])}:void 0,v=$e(n,"seed"),k=v===void 0?void 0:Number(v);if(k!==void 0&&(!Number.isInteger(k)||k<1))throw new Se("--seed must be a whole number from 1");let _=Zn(e,t);for(let $ of i){let x=$e(n,"out")??Vn(t.dir,"views"),S=_.view(r.name,$,{scale:a,region:l,frame:p,marks:g,theme:$e(n,"theme"),themes:$e(n,"themes")?.split(","),ground:$e(n,"ground"),with:n.flags.get("with"),size:w,seed:k,camera:d},x);S.kind==="text"?(e.out(S.text),e.out(`wrote ${S.path}
641
+ `)):e.out(`${S.text?S.text+`
642
+ `:""}wrote ${S.path} (${S.width}x${S.height})
643
+ `)}return 0}function IB(e,t){let[r,...o]=t.pos;if(!r)throw new Se("check: give a project folder");let n=$t(r),i=Zn(e,n),s=$e(t,"checks")?.split(",").map(u=>u.trim());if(s&&!s.every(Hy))throw new Se(`--checks takes check names (${Pn.join(", ")})`);let a=$e(t,"frame"),c=a===void 0?void 0:Number(a)-1;if(c!==void 0&&(!Number.isInteger(c)||c<0))throw new Se("--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:$e(t,"ground"),ref:$e(t,"ref")}),f=m.filter(p=>p.status==="fail").map(p=>p.id);if(f.length&&l++,e.out(qb(u,m,d,c)+`
644
+ `),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}
645
+ `)}}return l?1:0}function PB(e,t){let[r,...o]=t.pos;if(!r)throw new Se("review: give a project folder");let n=$e(t,"size"),i=n?/^(\d+)x(\d+)$/.exec(n):null;if(n&&!i)throw new Se("--size must look like 16x12 (tiles)");let s=$e(t,"seed")===void 0?void 0:Number($e(t,"seed"));if(s!==void 0&&(!Number.isInteger(s)||s<1))throw new Se("--seed must be a whole number from 1");let a={...i?{cols:Number(i[1]),rows:Number(i[2])}:{},...s?{seed:s}:{}},c=Lb(Zn(e,$t(r)),{assets:o.length?o:void 0,set:$e(t,"set"),name:$e(t,"name"),map:a});return e.out(`wrote ${c.files.length} files to ${c.dir}
646
+ ${c.files.map(l=>` ${l}
647
+ `).join("")}Hand the folder to a fresh reviewer: "Review the art in ${c.dir} by following rubric.md."
648
+ `),0}function jB(e,t){let[r,o,n,...i]=t.pos;if(!r)throw new Se("request: give a project folder");if(i.length)throw new Se(`request: unexpected argument '${i[0]}'`);let s=$t(r);if(!o){let u=En(gt(s));return e.out(u.length?u.map(m=>to(m)+`
649
+ `).join(""):`no open requests
650
+ `),0}if(!["draw","change","add"].includes(o))throw new Se(`request: the kind is draw, change or add (not '${o}')`);if(!n)throw new Se(`request ${o}: give the asset${o==="add"?"'s name":""}`);if(o!=="add"){for(let u of["kind","size","set","description","height"])if($e(t,u)!==void 0)throw new Se(`request ${o}: --${u} is for add`)}let a;if(o==="add"){let u=$e(t,"height");if(u!==void 0&&!/^\d+$/.test(u))throw new Se("--height is a number of pixels");a={name:n,kind:$e(t,"kind"),size:$e(t,"size"),...$e(t,"set")?{set:$e(t,"set")}:{},...$e(t,"description")?{description:$e(t,"description")}:{},...u?{height:Number(u)}:{}}}Mo(s);let c=Zn(e,s),l=Gs(c,$e(t,"by")??"claude",ud({action:"request",kind:o,asset:n,note:$e(t,"note"),entry:a}));return c.requestsChanged(),e.out(`${to(l)}
651
+ `),0}function EB(e,t,r){let[o,n,i,...s]=r.pos;if(!o||!n)throw new Se(`${t}: give a project folder and a request id`);if(s.length)throw new Se(`${t}: put the text in quotes (unexpected '${s[0]}')`);let a=$t(o);Mo(a);let c=Zn(e,a),l=Gs(c,$e(r,"by")??"claude",ud({action:t,id:n,text:i}));return c.requestsChanged(),e.out(`${to(l)}
652
+ `),0}function TB(e,t){let[r,o,...n]=t.pos;if(!r||!o)throw new Se(`work: ${CB}`);if(o==="start")throw new Se("work start: run it from the pixelclaw command, not through a server");if(!Kb.includes(o))throw new Se(`work: the action is ${Kb.join(", ")} or start (not '${o}')`);if($e(t,"port")!==void 0)throw new Se("work: --port is for work start");let i=n[0]&&/^r\d+$/.test(n[0])?n.shift():void 0,[s,...a]=n;if(a.length)throw new Se(`work ${o}: put the text in quotes (unexpected '${a[0]}')`);if(o==="list"&&(i||s!==void 0))throw new Se("work list takes no id or text");if(o==="claim"&&s!==void 0)throw new Se(`work claim: unexpected '${s}' (give a request id like r3, or none for the next open one)`);if(["progress","block","done"].includes(o)&&!s?.trim())throw new Se(`work ${o}: say ${o==="progress"?"what you are doing":o==="block"?"the one question for the person":"what changed"} (in quotes)`);let c=$t(r);Mo(c);let l=Zn(e,c),u=$e(t,"by")??"claude",m=_N(r);if(o==="list"){Ks(l,u,{action:"list"});let p=En(gt(c));return e.out(p.length?p.map(h=>to(h)+`
653
+ `).join("")+`Take one: \`pixelclaw work ${Vc(r)} claim [<id>]\`
654
+ `:`no open requests
655
+ `),0}let d=o==="claim"?Ks(l,u,{action:"next",id:i},m):Ks(l,u,{action:o==="block"?"blocked":o,id:i,text:s},m);if(l.requestsChanged(),!d.request)return e.out(`${d.message}
656
+ `),0;if(o==="claim")return e.out(`${d.message}
657
+ ${Eb(l,d.request,m)}
658
+ `),0;let f=En(gt(c)).filter(p=>p.state==="open").length;return e.out(`${d.message}
659
+ ${to(d.request)}
660
+ ${o==="progress"?"":f?`${f} open request${f===1?"":"s"} left: ${m.next}.
661
+ `:`No open requests left.
662
+ `}`),0}var CB='work <project> (list | claim [<id>] | progress [<id>] "<note>" | block [<id>] "<question>" | done [<id>] "<what changed>") [--by <agent>], or work <project> start [--port N]';function AB(e,t){let[r]=t.pos;if(!r)throw new Se("plan: give a project folder");let o=Zn(e,$t(r)),n=$e(t,"manifest");if(n){let a;try{a=JSON.parse(_d(n,"utf8"))}catch(l){throw new Q(`${n}: ${l.message}`)}let c=Oi(o.project,a);if(!c.manifest)return e.err(`error: the manifest was not written; ${c.errors.length} problem${c.errors.length===1?"":"s"}:
663
+ ${c.errors.map(l=>` ${l.path||"(top)"}: ${l.message}
664
+ `).join("")}`),1;e.out(`wrote ${Vn(o.project.dir,"manifest.json")}: ${c.manifest.assets.length} assets
665
+ `)}if(t.flags.has("templates")){let a=$e(t,"seed")===void 0?void 0:Number($e(t,"seed")),c=Cb(o,{seed:a});e.out(`wrote ${c.files.length} templates to ${c.dir}
666
+ ${c.files.map(l=>` ${l}
667
+ `).join("")}`)}let i=$e(t,"order");if(i!==void 0&&i!=="set"&&i!=="scene")throw new Se("--order is set or scene");let s=Ni(o,{set:$e(t,"set")});return e.out(t.flags.has("json")?JSON.stringify(s,null,2)+`
668
+ `:Tb(s,{order:i})+`
669
+ `),s.manifest.errors.length?1:0}function OB(){let e=wB($B(import.meta.url));for(let t of[Vn(e,"skill"),Vn(e,"..","..","skill")])if(Gc(Vn(t,"SKILL.md")))return t;throw new Q("the skill is not in this build (no skill/SKILL.md)")}function NB(e,t){let[r]=t.pos;if(r!=="install"&&r!=="path")throw new Se("skill: install [--dest <dir> | --project <dir>], or path");let o=OB();if(r==="path")return e.out(o+`
670
+ `),0;let n=$e(t,"project"),i=$e(t,"dest")??(n?Vn(n,".claude","skills","pixelclaw"):Vn(bB(),".claude","skills","pixelclaw"));gB(i,{recursive:!0}),yM(o,i,{recursive:!0});let s=Vn(o,"..","docs","commands.md");!Gc(Vn(o,"commands.md"))&&Gc(s)&&yM(s,Vn(i,"commands.md"));let a=yB(i,{recursive:!0}).map(String).filter(c=>c.includes(".")).sort();return e.out(`installed the PixelClaw skill in ${i} (${a.join(", ")})
671
+ Claude Code finds it as /pixelclaw; connect the tools with:
672
+ claude mcp add pixelclaw -- npx pixelclaw serve --project <your project>.pclaw
673
+ `),0}function MB(e,t){let[r,o,...n]=t.pos;if(!r||!o)throw new Se("view: give a project folder and an asset name");let i=$t(r),{doc:s}=_B(i,o);if(!s)throw new Q(`asset '${o}' has an empty tape`);return $M(e,i,s,n,t)}function DB(e,t){let[r,o]=t.pos;if(!r||!o)throw new Se("export: give a project folder and an asset name");let n=$e(t,"format");if(!id.includes(n))throw new Se(`--format must be one of ${id.join(", ")}`);let i=$t(r);Mo(i);let s=Zn(e,i),a=xb(s.doc(o),s.assetDocs(),n,$e(t,"out")??Vn(i.dir,"exports",n));return e.out(`${n}: wrote ${a.length} files
674
+ ${a.map(c=>` ${c}
675
+ `).join("")}`),0}function qB(e,t){let[r,...o]=t.pos;if(!r)throw new Se("export: give a project folder");let n=$t(r);Mo(n);let i=Zn(e,n),s=$e(t,"profile")??"png",a=Sb(n,i.assetDocs(),s,{names:o.length?o:void 0,dest:$e(t,"out"),at:e.now()});return e.out(`${s}: ${a.images} images, wrote ${a.files.length} files into ${a.dir}
676
+ ${a.notes.map(c=>` note: ${c}
677
+ `).join("")}`),0}function UB(e,t){let[r,o]=t.pos;if(!r||!o)throw new Se("import: give a project folder and a file or folder");let n=$t(r);Mo(n);let i=Zn(e,n),s=(g,b,y,w)=>{let v=$e(t,g);if(v!==void 0){if(!b.test(v))throw new Se(`--${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=$e(t,"names-from");if(m!==void 0&&m!=="manifest")throw new Se("--names-from takes manifest");let d=$e(t,"by")??"claude",f={as:$e(t,"as"),kind:$e(t,"kind"),palette:$e(t,"palette"),build:t.flags.has("build"),grid:a,cells:t.flags.has("cells")};if(!$e(t,"profile")){let g=Uc(i,{path:o,...f,slice:c?{cell:c,offset:l,gap:u}:void 0,pattern:$e(t,"pattern"),names:$e(t,"names")?.split(","),namesFrom:m,set:$e(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")+`
678
+ `),0}let p=ld(n,i.assetDocs(),{path:o,profile:$e(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 Q(`${g.name}: ${b.errors.map(y=>`${y.line}:${y.col} ${y.message}`).join("; ")}`);h.push(g.name)}return e.out((zb(p,h)||"nothing to import")+`
679
+ `),p.differ.length?1:0}function LB(e,t){let[r,...o]=t.pos;if(!r)throw new Se("upgrade: give a project folder");let n=$t(r);Mo(n);let i=Co(n),s=0,a=[];for(let c of o.length?o:Ti(n)){let l=td(n,c),u;try{u=bO(l,i)}catch(h){e.out(`FAIL ${c}: ${h.message}
680
+ `),s++;continue}if(!u){e.out(`ok ${c}: already language ${zr}
681
+ `);continue}let m=Zm(l,i),d=Zm(u,i);if(!(!m.problems.length&&!d.problems.length&&m.doc&&d.doc&&Buffer.compare(zn(m.doc),zn(d.doc))===0)){e.out(`FAIL ${c}: the upgraded tape does not replay to the same document; left as it was
682
+ `),s++;continue}let p=new Nc(i);vb(n,{doc:d.doc,entries:u},h=>p.docAt(u,h).doc,!0),e.out(`ok ${c}: language 1 \u2192 ${zr}, the same pixels (${u.length} commands)
683
+ `),a.push(c)}return a.length?Math.max(s?1:0,xM(e,{...t,pos:[r,...a]})):s?1:0}function xM(e,t){let[r,...o]=t.pos;if(!r)throw new Se("verify: give a project folder");let n=$t(r),i=o.length?o:Ti(n),s=0;for(let a of i){let c=[],l;try{l=td(n,a)}catch(b){e.out(`FAIL ${a}: ${b.message}
684
+ `),s++;continue}let u=$1(n,a),m=new Map(u.filter(b=>b.n>0).map(b=>[b.n,b])),d=()=>{let b=new ji(Co(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!==wb(l,v.n)?c.push(`checkpoint ${v.file} was made from another tape`):(!b.doc||Buffer.compare(Buffer.from(zn(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=zn(p.doc);Tn(b)!==Tn(zn(h.doc))&&c.push("two replays differ");let y=Tn(b),w=oN(n,a),v=zT(p.doc),k=w.state.sha256!==y&&v!==null&&w.state.sha256===Tn(v);w.state.sha256!==y&&!k&&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 _=Vn(Bs(n,a),"preview.png");Gc(_)?Buffer.compare(Buffer.from(v1(p.doc)),_d(_))!==0&&c.push("preview.png differs from the replayed document"):c.push("preview.png is missing");for(let R of u)R.n<0?c.push(`checkpoint ${R.file} is not a checkpoint file`):R.n>l.length?c.push(`checkpoint ${R.file} is past the end of the tape`):R.file!==`${String(R.n).padStart(6,"0")}.gwc`&&c.push(`checkpoint ${R.file} holds command ${R.n}`);let $=QN(n,a),x=$?.key===vd(n,nd(n,a).bytes,Rr(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 S=bb(l.length).filter(R=>!u.some(P=>P.file===R));S.length&&c.push(`checkpoint${S.length===1?"":"s"} missing: ${S.join(", ")}`),g=`${l.length} commands, ${new Set(l.map(R=>R.group)).size} groups, state ${y.slice(0,12)}${k?" (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}
685
+ ${c.map(b=>` ${b}
686
+ `).join("")}`)):e.out(`ok ${a}: ${g}
687
+ `)}return e.out(s?`${s} of ${i.length} assets failed
688
+ `:`${i.length} asset${i.length===1?"":"s"} verified in ${vB(process.cwd(),n.dir)||"."}
689
+ `),s?1:0}function Xb(e,t=bM){let[r,...o]=e;try{switch(r){case"new":{let n=wt(o,...an.new);if(!n.pos[0])throw new Se("new: give a project folder");return n.pos.length===1?xB(t,n.pos[0],n):zB(t,n.pos[0],n)}case"run":return RB(t,wt(o,...an.run));case"seeds":return SB(t,wt(o,...an.seeds));case"view":return MB(t,wt(o,["scale","region","out","frame","marks","theme","themes","ground","with","size","seed","camera"],[]));case"export":{let n=wt(o,...an.export);return $e(n,"format")?DB(t,n):qB(t,n)}case"import":return UB(t,wt(o,...an.import));case"check":return IB(t,wt(o,["checks","frame","ground","ref"],["marks"]));case"review":return PB(t,wt(o,...an.review));case"plan":return AB(t,wt(o,...an.plan));case"request":return jB(t,wt(o,...an.request));case"reply":case"cancel":return EB(t,r,wt(o,...an.reply));case"work":return TB(t,wt(o,...an.work));case"skill":return NB(t,wt(o,["dest","project"],[]));case"verify":return xM(t,wt(o,[],[]));case"upgrade":return LB(t,wt(o,[],[]));case void 0:case"help":case"-h":case"--help":return t.out(Kc),r===void 0?1:0;default:throw new Se(`unknown command '${r}'`)}}catch(n){if(n instanceof Se)return t.err(`error: ${n.message}
690
+
691
+ ${Kc}`),2;if(n instanceof Q)return t.err(`error: ${n.message}
692
+ `),1;throw n}}import{request as FB}from"node:http";import{realpathSync as VB}from"node:fs";import{resolve as kd}from"node:path";var ZB=3;function cz(e,t,r,o,n){return new Promise((i,s)=>{let a=o===void 0?void 0:Buffer.from(JSON.stringify(o)),c=FB(new URL(r,e.base),{method:t,signal:n,headers:{Authorization:`Bearer ${e.token}`,...a?{"Content-Type":"application/json","Content-Length":a.length}:{}}},l=>{let u=[];l.on("data",m=>u.push(m)),l.on("end",()=>i({status:l.statusCode??0,body:Buffer.concat(u).toString("utf8")})),l.on("error",s)});c.on("error",s),c.end(a)})}function WB(e,t){switch(e){case"new":return t.pos.length>=2;case"run":return!t.flags.has("dry");case"seeds":return t.flags.has("apply");case"plan":return t.flags.has("manifest")||t.flags.has("templates");case"work":return Kb.includes(t.pos[1]??"");default:return!0}}async function _M(e,t){let r=an[e[0]??""];if(!r)return null;let o;try{o=wt(e.slice(1),...r)}catch{return null}let n=o.pos[0];if(!n||!WB(e[0],o))return null;let i=Jc(kd(n));if(!i)return null;let s;try{s=await cz(i,"POST","/api/cli",{argv:e,cwd:process.cwd()})}catch{return null}let a;try{a=JSON.parse(s.body)}catch{return null}return s.status===501?null:s.status!==200?(t.err(`error: the server refused it: ${a.error??s.status}
693
+ `),1):(a.stdout&&t.out(a.stdout),a.stderr&&t.err(a.stderr),a.code??1)}function lz(e,t,r){let o=an[e[0]??""];if(!o)return{code:2,stdout:"",stderr:`error: '${e[0]}' is not sent through the server
694
+ `};let n;try{n=wt(e.slice(1),...o).pos[0]}catch{}let i=u=>{try{return VB(u)}catch{return kd(u)}};if(n!==void 0&&i(kd(r,n))!==i(t.project.dir))return{code:1,stdout:"",stderr:`error: this server owns ${t.project.dir}, not ${n}
695
+ `};let s="",a="",c={out:u=>{s+=u},err:u=>{a+=u},stdin:()=>"",now:()=>t.stamp(),writer:t},l=process.cwd();process.chdir(r);try{return{code:Xb(e,c),stdout:s,stderr:a}}catch(u){return{code:1,stdout:s,stderr:a+`error: ${u.message}
696
+ `}}finally{process.chdir(l)}}function BB(e){if(/^https?:\/\//.test(e)){let r=fM(e);if(!r)throw new Se("await: the watch URL needs its ?token=\u2026");return r}let t=Jc(kd(e));if(!t){let r=!0;try{$t(e)}catch{r=!1}throw new Se(r?`await: no pixelclaw server is running for ${e} (start one: pixelclaw serve ${e}), or its token file is not readable by this user`:`await: ${e} is not a PixelClaw project folder or a watch URL`)}return t}var HB="await <project-folder | watch-url> [--timeout <seconds>] [--since <cursor>] [--as <name>] [--json]";async function kM(e,t){let r=wt(e,["timeout","since","as"],["json"]);if(r.pos.length!==1)throw new Se(`await: ${HB}`);let o=Number($e(r,"timeout")??600);if(!Number.isFinite(o)||o<0)throw new Se("await: --timeout is seconds");let n=$e(r,"as")??"claude",i=BB(r.pos[0]),s=new URLSearchParams({timeout:String(o),as:n}),a=$e(r,"since");a&&s.set("since",a);let c;try{c=await cz(i,"GET",`/api/await?${s}`)}catch(u){return t.err(`error: could not reach the server at ${i.base}: ${u.message}
697
+ `),1}let l;try{l=JSON.parse(c.body)}catch{l={error:`unexpected answer (${c.status})`}}return c.status!==200||!l.events||!l.cursor?(t.err(`error: ${l.error??`the server answered ${c.status}`}
698
+ `),1):(t.out(r.flags.has("json")?JSON.stringify({events:l.events,cursor:l.cursor,timedOut:l.timedOut})+`
699
+ `:Ib(l.events,l.cursor,{cli:/^https?:\/\//.test(r.pos[0])?"<project>":Vc(r.pos[0])})+`
700
+ `),l.events.length?0:ZB)}async function SM(e){let t=0;try{t=[...gt($t(e)).values()].filter(n=>n.state==="open").length}catch{return""}if(!t)return"";let r=`${t} open request${t===1?"":"s"}`,o=Jc(kd(e));if(!o)return`${r}, and no server is running: start \`pixelclaw serve ${e}\`, then keep \`pixelclaw await ${e}\` running in the background so an agent hears of them.
701
+ `;try{let n=await cz(o,"GET","/api/presence"),i=JSON.parse(n.body);if(i.waiters?.length||i.worker)return""}catch{return""}return`${r} and no agent is listening for them. Keep \`pixelclaw await ${e}\` running in the background (its exit wakes you), and take them with the MCP work tool (without MCP: \`pixelclaw work ${Vc(e)} claim\`).
702
+ `}var zM={out:e=>process.stdout.write(e),err:e=>process.stderr.write(e)};async function GB(e){try{let t=wt(e,["project","port","token"],["no-mcp"]),r=$e(t,"project")??t.pos[0];if(!r)throw new Se("serve: give a project folder with --project <dir>");if(t.pos.length>($e(t,"project")?0:1))throw new Se(`serve: unexpected argument '${t.pos.at(-1)}'`);let o=$e(t,"port"),n=o===void 0?oz:Number(o);if(!Number.isInteger(n)||n<0||n>65535)throw new Se("--port must be 0..65535");return await(await iz({project:r,port:n,mcp:!t.flags.has("no-mcp"),token:$e(t,"token"),runCli:lz})).closed,0}catch(t){if(t instanceof Se)return process.stderr.write(`error: ${t.message}
703
+
704
+ ${Kc}`),2;if(t instanceof Q)return process.stderr.write(`error: ${t.message}
705
+ `),1;throw t}}async function KB(e){try{let t=wt(e,["port"],[]),r=t.pos[1]==="start"?[t.pos[0],...t.pos.slice(2)]:t.pos,[o]=r;if(!o||r.length>1)throw new Se("work start: give one project folder");let n=JB(o),i=Xs(n);if(!i.enabled)throw new Q(`the worker is off for ${n}: 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 ${i.cap}; see docs/worker.md)`);let s=Ci(n);if(s)throw new Q(`a pixelclaw server (pid ${s.pid}) owns ${n}: start the worker from its dashboard (Start Claude) instead`);let a=O1(n);if(a)throw new Q(`a worker is already running for ${n} (pid ${a.pid}, started by ${a.by} at ${a.startedAt})`);let c=$e(t,"port"),l=c===void 0?0:Number(c);if(!Number.isInteger(l)||l<0||l>65535)throw new Se("--port must be 0..65535");let u=await iz({project:n,port:l,mcp:!1,runCli:lz}),m;try{m=await u.worker.start("cli")}finally{await u.close()}return process.stderr.write(`pixelclaw: worker stopped: ${m}
706
+ `),0}catch(t){if(t instanceof Se)return process.stderr.write(`error: ${t.message}
707
+
708
+ ${Kc}`),2;if(t instanceof Q)return process.stderr.write(`error: ${t.message}
709
+ `),1;throw t}}async function RM(e){if(process.stdout.on("error",t=>{throw t.code==="EPIPE"&&process.exit(0),t}),wM(e)&&process.exit(await KB(e.slice(1))),e[0]==="serve"){let t=await GB(e.slice(1));process.exit(t)}try{if(e[0]==="await")return await kM(e.slice(1),zM);let t=e[0]==="run"?await vM(e):e,r=await _M(t,zM);if(r!==null)return r;let o=Xb(t);return t[0]==="plan"&&t[1]&&!t.includes("--json")&&o!==2&&process.stdout.write(await SM(t[1])),o}catch(t){if(t instanceof Se)return process.stderr.write(`error: ${t.message}
710
+
711
+ ${Kc}`),2;if(t instanceof Q)return process.stderr.write(`error: ${t.message}
712
+ `),1;throw t}}process.exitCode=await RM(process.argv.slice(2));