jetstream v2 in zig stream.waow.tech
Something went wrong. Try again.
12var p=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),$=e=>({get value(){let t=e();return p(this,"value",t)}}),T=Array.isArray,x=e=>typeof e=="object"&&e!==null&&!T(e),j=$(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});var _=(e,t)=>e?{ok:!1,code:"join",left:e,right:t}:t,k=(e,t)=>({ok:!1,code:"prepend",key:e,tree:t}),b=e=>({ok:!0,value:e}),A=0,h=1,R=2,B=(e,t)=>{let{ok:n,msg:s,...r}=e;return{...r,path:t}},N=(e,t=[],n=[])=>{for(;;)switch(e.code){case"join":{N(e.left,t.slice(),n),e=e.right;continue}case"prepend":{t.push(e.key),e=e.tree;continue}default:return n.push(B(e,t)),n}},P=e=>{let t=0;for(;;)switch(e.code){case"join":{t+=P(e.left),e=e.right;continue}case"prepend":{e=e.tree;continue}default:return t+1}};var z=e=>{let t="",n=0;for(;;){switch(e.code){case"join":{n+=P(e.right),e=e.left;continue}case"prepend":{t+=`.${e.key}`,e=e.tree;continue}}break}let s=e.msg(),r=`${e.code} at ${t||"."} (${s})`;return n>0&&(r+=` (+${n} other issue(s))`),r},v=class extends Error{name="ValidationError";#e;constructor(t){super(),this.#e=t}get message(){return z(this.#e)}get issues(){return N(this.#e)}};var O=(e,t,n)=>{let s=A;n?.strict&&(s|=R);let r=e["~run"](t,s);if(r===void 0)return t;if(r.ok)return r.value;throw new v(r)},C=(e,t=[],n=[])=>{for(;;)switch(e.code){case"join":{C(e.left,t.slice(),n),e=e.right;continue}case"prepend":{t.push(e.key),e=e.tree;continue}default:return n.push({message:e.msg(),path:t.length>0?t:void 0}),n}},S=e=>({version:1,vendor:"@atcute/lexicons",validate(t){let n=e["~run"](t,A);return n===void 0?{value:t}:n.ok?{value:n.value}:{issues:C(n)}}});var G={ok:!1,code:"invalid_type",expected:"string",msg(){return"expected string"}},M={kind:"schema",type:"string",format:null,"~run"(e,t){if(typeof e!="string")return G},get"~standard"(){return p(this,"~standard",S(this))}},y=()=>M;var E=(e,t)=>({kind:"schema",type:"optional",wrapped:e,default:t,"~run"(n,s){if(n===void 0){if(t===void 0)return;let r=typeof t=="function"?t():t;return b(r)}return e["~run"](n,s)},get"~standard"(){return p(this,"~standard",S(this))}}),Y=e=>e.type==="optional";var w={ok:!1,code:"invalid_type",expected:"object",msg(){return"expected object"}},D={ok:!1,code:"missing_value",msg(){return"missing value"}},F=(e,t,n)=>{t==="__proto__"?Object.defineProperty(e,t,{value:n}):e[t]=n},L=e=>{let t=$(()=>{let n=[];for(let s in e){let r=e[s];n.push({key:s,schema:r,optional:Y(r),missing:k(s,D)})}return n});return{kind:"schema",type:"object",get shape(){let n=t.value,s={};for(let r of n)s[r.key]=r.schema;return p(this,"shape",s)},get"~run"(){let n=t.value,s=n.length,r=()=>{let a=[["$ok",b],["$joinIssues",_],["$prependPath",k]],o="let $iss,$out;";for(let i=0;i<s;i++){let l=n[i],f=l.key,c=JSON.stringify(f),d=`_${i}`;if(o+=`{const $val=$in[${c}];`,l.optional?o+="if($val!==undefined){":o+=`if($val!==undefined||${c} in $in){`,o+=`const $res=${d}$schema["~run"]($val,$flags);if($res!==undefined)if($res.ok)${f!=="__proto__"?`($out??={...$in})[${c}]=$res.value`:`Object.defineProperty($out??={...$in},${c},{value:$res.value})`};else if((($iss=$joinIssues($iss,$prependPath(${c},$res))),$flags&${h}))return $iss;}`,l.optional){let g=l.schema,U=g.wrapped,m=g.default;if(a.push([`${d}$schema`,U]),m!==void 0){let I=typeof m=="function"?`${d}$default()`:`${d}$default`;a.push([`${d}$default`,m]),o+=f!=="__proto__"?`else($out??={...$in})[${c}]=${I};`:`else Object.defineProperty($out??={...$in},${c},{value:${I}});`}}else a.push([`${d}$schema`,l.schema]),a.push([`${d}$missing`,l.missing]),o+=`else if((($iss=$joinIssues($iss,${d}$missing)),$flags&${h}))return $iss;`;o+="}"}return o+="if($iss!==undefined)return $iss;if($out!==undefined)return $ok($out);",new Function(`[${a.map(([i])=>i).join(",")}]`,`return function matcher($in,$flags){${o}}`)(a.map(([,i])=>i))};if(j.value){let a=r();return p(this,"~run",(u,i)=>x(u)?a(u,i):w)}return p(this,"~run",(a,o)=>{if(!x(a))return w;let u,i;for(let l=0;l<s;l++){let f=n[l],c=f.key,d=a[c];if(!f.optional&&d===void 0&&!(c in a)){if(u=_(u,f.missing),o&h)return u;continue}let g=f.schema["~run"](d,o);if(g!==void 0){if(g.ok)i===void 0&&(i={...a}),F(i,c,g.value);else if(u=_(u,k(c,g)),o&h)return u}}if(u!==void 0)return u;if(i!==void 0)return b(i)})},get"~standard"(){return p(this,"~standard",S(this))}}};var K=L({handle:y(),displayName:E(y()),avatar:E(y())}),q=e=>O(K,e);export{q as parseIdentityProfile};