@graffiti-garden/api 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import"./chunk-YVLJX3HV.js";var ge=class{};var ht={type:"object",properties:{value:{type:"object"},channels:{type:"array",items:{type:"string"}},allowed:{type:"array",items:{type:"string"},nullable:!0},url:{type:"string"},actor:{type:"string"}},additionalProperties:!1,required:["value","channels","actor","url"]},fr={...ht,required:["value","channels"]};var ve=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorForbidden",Object.setPrototypeOf(this,e.prototype)}},$e=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,e.prototype)}},F=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,e.prototype)}},he=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorSchemaMismatch",Object.setPrototypeOf(this,e.prototype)}},_e=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorTooLarge",Object.setPrototypeOf(this,e.prototype)}},xe=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotAcceptable",Object.setPrototypeOf(this,e.prototype)}},ye=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorCursorExpired",Object.setPrototypeOf(this,e.prototype)}};function $r(e){return typeof e=="string"?e:e.url}function hr(e,t){return!Array.isArray(e.allowed)||typeof t?.actor=="string"&&(e.actor===t.actor||e.allowed.includes(t.actor))}function _r(e,t,r){if(r===e.actor)return e;let n=e.allowed&&r?[r]:void 0,i=e.channels.filter(o=>t.includes(o));return{...e,allowed:n,channels:i}}function xr(e,t){let[r,n]=e.toLowerCase().split(";")[0].split("/");return!r||!n?!1:t.some(i=>{let[o,a]=i.toLowerCase().split(";")[0].split("/");return!o||!a?!1:(o===r||o==="*")&&(a===n||a==="*")})}var te;async function yr(e){if(!te){let{default:t}=await import("./ajv-Z3ABRV2J.js");te=new t({strict:!1})}try{return te.compile(e)}catch(t){throw new F(t instanceof Error?t.message:String(t))}}var _t=Object.freeze({status:"aborted"});function p(e,t,r){function n(c,l){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,l);let s=a.prototype,g=Object.keys(s);for(let v=0;v<g.length;v++){let $=g[v];$ in c||(c[$]=s[$].bind(c))}}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function a(c){var l;let s=r?.Parent?new o:this;n(s,c),(l=s._zod).deferred??(l.deferred=[]);for(let g of s._zod.deferred)g();return s}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var S=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};var re={};function w(e){return e&&Object.assign(re,e),re}function ke(e,t){return typeof t=="bigint"?t.toString():t}function ie(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function B(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var be=Symbol("evaluating");function h(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==be)return n===void 0&&(n=be,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function xt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function yt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}var oe="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var bt=ie(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function ze(e){if(J(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(J(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function A(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(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 Se(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ie={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]};function we(e,t){if(!ze(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(o,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=yt(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return xt(this,"shape",o),o}});return A(e,i)}function O(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 M(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function V(e){return typeof e=="string"?e:e?.message}function j(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=V(e.inst?._zod.def?.error?.(e))??V(t?.error?.(e))??V(r.customError?.(e))??V(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function ae(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var je=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ke,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ue=p("$ZodError",je),L=p("$ZodError",je,{Parent:Error});var zt=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new S;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map(l=>j(l,o,w())));throw oe(c,i?.callee),c}return a.value},K=zt(L),St=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(i?.Err??e)(a.issues.map(l=>j(l,o,w())));throw oe(c,i?.callee),c}return a.value},W=St(L),It=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new S;return o.issues.length?{success:!1,error:new(e??Ue)(o.issues.map(a=>j(a,i,w())))}:{success:!0,data:o.value}},C=It(L),wt=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>j(a,i,w())))}:{success:!0,data:o.value}},R=wt(L);var jt="(?:(?:\\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])))",Ut=new RegExp(`^${jt}$`);var Oe=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ze=/^-?\d+$/,De=/^-?\d+(?:\.\d+)?$/;var U=p("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Pt={number:"number",bigint:"bigint",object:"date"};var Te=p("$ZodCheckGreaterThan",(e,t)=>{U.init(e,t);let r=Pt[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var Ne=p("$ZodCheckNumberFormat",(e,t)=>{U.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Ie[t.format];e._zod.onattach.push(a=>{let c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=o,r&&(c.pattern=Ze)}),e._zod.check=a=>{let c=a.value;if(r){if(!Number.isInteger(c)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),c>o&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}});var Ee=p("$ZodCheckStringFormat",(e,t)=>{var r,n;U.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})});var Me={major:4,minor:3,patch:5};var x=p("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Me;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(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)=>{let s=O(a),g;for(let v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(s)continue;let $=a.issues.length,k=v._zod.check(a);if(k instanceof Promise&&l?.async===!1)throw new S;if(g||k instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await k,a.issues.length!==$&&(s||(s=O(a,$)))});else{if(a.issues.length===$)continue;s||(s=O(a,$))}}return g?g.then(()=>a):a},o=(a,c,l)=>{if(O(a))return a.aborted=!0,a;let s=i(c,n,l);if(s instanceof Promise){if(l.async===!1)throw new S;return s.then(g=>e._zod.parse(g,l))}return e._zod.parse(s,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let s=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return s instanceof Promise?s.then(g=>o(g,a,c)):o(s,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new S;return l.then(s=>i(s,n,c))}return i(l,n,c)}}h(e,"~standard",()=>({validate:i=>{try{let o=C(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return R(e,i).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Y=p("$ZodString",(e,t)=>{x.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Oe(e._zod.bag),e._zod.parse=(r,n)=>{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}}),ce=p("$ZodStringFormat",(e,t)=>{Ee.init(e,t),Y.init(e,t)});var Fe=p("$ZodURL",(e,t)=>{ce.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}});var ue=p("$ZodNumber",(e,t)=>{x.init(e,t),e._zod.pattern=e._zod.bag.pattern??De,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),Ve=p("$ZodNumberFormat",(e,t)=>{Ne.init(e,t),ue.init(e,t)});var Je=p("$ZodUnknown",(e,t)=>{x.init(e,t),e._zod.parse=r=>r});function Le(e,t,r){e.issues.length&&t.issues.push(...M(r,e.issues)),t.value[r]=e.value}var Be=p("$ZodArray",(e,t)=>{x.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let a=0;a<i.length;a++){let c=i[a],l=t.element._zod.run({value:c,issues:[]},n);l instanceof Promise?o.push(l.then(s=>Le(s,r,a))):Le(l,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function q(e,t,r,n,i){if(e.issues.length){if(i&&!(r in n))return;t.issues.push(...M(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Zt(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Se(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Dt(e,t,r,n,i,o){let a=[],c=i.keySet,l=i.catchall._zod,s=l.def.type,g=l.optout==="optional";for(let v in t){if(c.has(v))continue;if(s==="never"){a.push(v);continue}let $=l.run({value:t[v],issues:[]},n);$ instanceof Promise?e.push($.then(k=>q(k,r,v,t,g))):q($,r,v,t,g)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var Ke=p("$ZodObject",(e,t)=>{if(x.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...c};return Object.defineProperty(t,"shape",{value:l}),l}})}let n=ie(()=>Zt(t));h(e._zod,"propValues",()=>{let c=t.shape,l={};for(let s in c){let g=c[s]._zod;if(g.values){l[s]??(l[s]=new Set);for(let v of g.values)l[s].add(v)}}return l});let i=J,o=t.catchall,a;e._zod.parse=(c,l)=>{a??(a=n.value);let s=c.value;if(!i(s))return c.issues.push({expected:"object",code:"invalid_type",input:s,inst:e}),c;c.value={};let g=[],v=a.shape;for(let $ of a.keys){let k=v[$],E=k._zod.optout==="optional",ee=k._zod.run({value:s[$],issues:[]},l);ee instanceof Promise?g.push(ee.then($t=>q($t,c,$,s,E))):q(ee,c,$,s,E)}return o?Dt(g,s,c,l,n.value,e):g.length?Promise.all(g).then(()=>c):c}});function Ce(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let i=e.filter(o=>!O(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(a=>j(a,n,w())))}),t)}var We=p("$ZodUnion",(e,t)=>{x.init(e,t),h(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),h(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),h(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),h(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>B(o.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(r)return n(i,o);let a=!1,c=[];for(let l of t.options){let s=l._zod.run({value:i.value,issues:[]},o);if(s instanceof Promise)c.push(s),a=!0;else{if(s.issues.length===0)return s;c.push(s)}}return a?Promise.all(c).then(l=>Ce(l,i,e,o)):Ce(c,i,e,o)}});var Xe=p("$ZodTuple",(e,t)=>{x.init(e,t);let r=t.items;e._zod.parse=(n,i)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let a=[],c=[...r].reverse().findIndex(g=>g._zod.optin!=="optional"),l=c===-1?0:r.length-c;if(!t.rest){let g=o.length>r.length,v=o.length<l-1;if(g||v)return n.issues.push({...g?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:o,inst:e,origin:"array"}),n}let s=-1;for(let g of r){if(s++,s>=o.length&&s>=l)continue;let v=g._zod.run({value:o[s],issues:[]},i);v instanceof Promise?a.push(v.then($=>X($,n,s))):X(v,n,s)}if(t.rest){let g=o.slice(r.length);for(let v of g){s++;let $=t.rest._zod.run({value:v,issues:[]},i);$ instanceof Promise?a.push($.then(k=>X(k,n,s))):X($,n,s)}}return a.length?Promise.all(a).then(()=>n):n}});function X(e,t,r){e.issues.length&&t.issues.push(...M(r,e.issues)),t.value[r]=e.value}function Re(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var qe=p("$ZodOptional",(e,t)=>{x.init(e,t),e._zod.optin="optional",e._zod.optout="optional",h(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),h(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${B(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>Re(o,r.value)):Re(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var Ye=p("$ZodNullable",(e,t)=>{x.init(e,t),h(e._zod,"optin",()=>t.innerType._zod.optin),h(e._zod,"optout",()=>t.innerType._zod.optout),h(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${B(r.source)}|null)$`):void 0}),h(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)});var He=p("$ZodCustom",(e,t)=>{U.init(e,t),x.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>Ge(o,r,n,e));Ge(i,r,n,e)}});function Ge(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(ae(i))}}var et;var se=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.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 n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function tt(){return new se}(et=globalThis).__zod_globalRegistry??(et.__zod_globalRegistry=tt());var le=globalThis.__zod_globalRegistry;function rt(e,t){return new e({type:"string",...b(t)})}function nt(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(t)})}function it(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(t)})}function ot(e){return new e({type:"unknown"})}function de(e,t){return new Te({check:"greater_than",...b(t),value:e,inclusive:!0})}function me(e){return de(0,e)}function at(e,t,r){let n=b(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}var z=p("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");x.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>K(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>C(e,r,n),e.parseAsync=async(r,n)=>W(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>R(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>A(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),fe=p("ZodMiniString",(e,t)=>{Y.init(e,t),z.init(e,t)});function Z(e){return rt(fe,e)}var ct=p("ZodMiniStringFormat",(e,t)=>{ce.init(e,t),fe.init(e,t)});var Kt=p("ZodMiniURL",(e,t)=>{Fe.init(e,t),ct.init(e,t)});function y(e){return nt(Kt,e)}var ut=p("ZodMiniNumber",(e,t)=>{ue.init(e,t),z.init(e,t)});var Wt=p("ZodMiniNumberFormat",(e,t)=>{Ve.init(e,t),ut.init(e,t)});function st(e){return it(Wt,e)}var Xt=p("ZodMiniUnknown",(e,t)=>{Je.init(e,t),z.init(e,t)});function qt(){return ot(Xt)}var Yt=p("ZodMiniArray",(e,t)=>{Be.init(e,t),z.init(e,t)});function D(e,t){return new Yt({type:"array",element:e,...b(t)})}var Ht=p("ZodMiniObject",(e,t)=>{Ke.init(e,t),z.init(e,t),h(e,"shape",()=>t.shape)});function I(e,t){return new Ht({type:"object",shape:e,catchall:qt(),...b(t)})}function pe(e,t){return we(e,t)}var Qt=p("ZodMiniUnion",(e,t)=>{We.init(e,t),z.init(e,t)});function lt(e,t){return new Qt({type:"union",options:e,...b(t)})}var er=p("ZodMiniTuple",(e,t)=>{Xe.init(e,t),z.init(e,t)});function _(e,t,r){let n=t instanceof x,i=n?r:t,o=n?t:null;return new er({type:"tuple",items:e,rest:o,...b(i)})}var tr=p("ZodMiniOptional",(e,t)=>{qe.init(e,t),z.init(e,t)});function P(e){return new tr({type:"optional",innerType:e})}var rr=p("ZodMiniNullable",(e,t)=>{Ye.init(e,t),z.init(e,t)});function Q(e){return new rr({type:"nullable",innerType:e})}var nr=p("ZodMiniCustom",(e,t)=>{He.init(e,t),z.init(e,t)});function ir(e,t){return at(nr,e??(()=>!0),t)}function dt(e,t={}){let r=ir(n=>n instanceof e,t);return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var gt=I({value:I({}),channels:D(Z()),allowed:P(Q(D(y())))}),al=pe(gt,{url:y(),actor:y()}),ft=lt([I({url:y()}),y()]),T=I({actor:y()}),N=P(Q(T)),vt=I({data:dt(Blob),allowed:P(Q(D(y())))}),cl=pe(vt,{actor:y()}),sr=I({types:P(D(Z())),maxBytes:P(st().check(me()))});async function*lr(e){for(;;){let t=await e.next();if(t.done){let{cursor:r,continue:n}=t.value;return{cursor:r,continue:(...i)=>{let o=_([N]).parse(i);return n(...o)}}}else yield t.value}}async function*dr(e){for(;;){let t=await e.next();if(t.done){let{cursor:r,continue:n}=t.value;return{cursor:r,continue:(...i)=>{let o=_([N]).parse(i);return n(...o)}}}else yield t.value}}var pt=class{constructor(t){this.graffiti=t;this.sessionEvents=this.graffiti.sessionEvents}sessionEvents;login=(...t)=>{let r=_([P(y())]).parse(t);return this.graffiti.login(...r)};logout=(...t)=>{let r=_([T]).parse(t);return this.graffiti.logout(...r)};handleToActor=(...t)=>{let r=_([Z()]).parse(t);return this.graffiti.handleToActor(...r)};actorToHandle=(...t)=>{let r=_([y()]).parse(t);return this.graffiti.actorToHandle(...r)};async post(t,r){let n=_([gt,T]).parse([t,r]);return await this.graffiti.post(...n)}get=(...t)=>{let r=_([ft,I({}),N]).parse(t);return this.graffiti.get(...r)};delete=(...t)=>{let r=_([ft,T]).parse(t);return this.graffiti.delete(...r)};postMedia=(...t)=>{let r=_([vt,T]).parse(t);return this.graffiti.postMedia(...r)};getMedia=(...t)=>{let r=_([y(),sr,N]).parse(t);return this.graffiti.getMedia(...r)};deleteMedia=(...t)=>{let r=_([y(),T]).parse(t);return this.graffiti.deleteMedia(...r)};discover=(...t)=>{let r=_([D(Z()),I({}),N]).parse(t),n=this.graffiti.discover(...r);return lr(n)};continueDiscover=(...t)=>{let r=_([Z(),N]).parse(t),n=this.graffiti.continueDiscover(...r);return dr(n)}};export{ge as Graffiti,ye as GraffitiErrorCursorExpired,ve as GraffitiErrorForbidden,F as GraffitiErrorInvalidSchema,xe as GraffitiErrorNotAcceptable,$e as GraffitiErrorNotFound,he as GraffitiErrorSchemaMismatch,_e as GraffitiErrorTooLarge,sr as GraffitiMediaAcceptSchema,cl as GraffitiMediaSchema,ht as GraffitiObjectJSONSchema,al as GraffitiObjectSchema,ft as GraffitiObjectUrlSchema,N as GraffitiOptionalSessionSchema,vt as GraffitiPostMediaSchema,fr as GraffitiPostObjectJSONSchema,gt as GraffitiPostObjectSchema,pt as GraffitiRuntimeTypes,T as GraffitiSessionSchema,yr as compileGraffitiObjectSchema,hr as isActorAllowedGraffitiObject,xr as isMediaAcceptable,_r as maskGraffitiObject,$r as unpackObjectUrl};
1
+ import"./chunk-YVLJX3HV.js";var ge=class{};var _t={type:"object",properties:{value:{type:"object"},channels:{type:"array",items:{type:"string"}},allowed:{type:"array",items:{type:"string"},nullable:!0},url:{type:"string"},actor:{type:"string"}},additionalProperties:!1,required:["value","channels","actor","url"]},mr={..._t,required:["value","channels"]};var ve=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorForbidden",Object.setPrototypeOf(this,e.prototype)}},$e=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,e.prototype)}},G=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,e.prototype)}},he=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorSchemaMismatch",Object.setPrototypeOf(this,e.prototype)}},_e=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorTooLarge",Object.setPrototypeOf(this,e.prototype)}},xe=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotAcceptable",Object.setPrototypeOf(this,e.prototype)}},ye=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorCursorExpired",Object.setPrototypeOf(this,e.prototype)}};function vr(e){return typeof e=="string"?e:e.url}function $r(e,t){return!Array.isArray(e.allowed)||typeof t?.actor=="string"&&(e.actor===t.actor||e.allowed.includes(t.actor))}function hr(e,t,r){if(r===e.actor)return e;let n=e.allowed&&r?[r]:void 0,i=e.channels.filter(o=>t.includes(o));return{...e,...n?{allowed:n}:{},channels:i}}function _r(e,t){let[r,n]=e.toLowerCase().split(";")[0].split("/");return!r||!n?!1:t.some(i=>{let[o,a]=i.toLowerCase().split(";")[0].split("/");return!o||!a?!1:(o===r||o==="*")&&(a===n||a==="*")})}var te;async function xr(e){if(!te){let{default:t}=await import("./ajv-Z3ABRV2J.js");te=new t({strict:!1})}try{return te.compile(e)}catch(t){throw new G(t instanceof Error?t.message:String(t))}}var xt=Object.freeze({status:"aborted"});function f(e,t,r){function n(c,l){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,l);let s=a.prototype,g=Object.keys(s);for(let v=0;v<g.length;v++){let $=g[v];$ in c||(c[$]=s[$].bind(c))}}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function a(c){var l;let s=r?.Parent?new o:this;n(s,c),(l=s._zod).deferred??(l.deferred=[]);for(let g of s._zod.deferred)g();return s}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var S=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};var re={};function w(e){return e&&Object.assign(re,e),re}function ke(e,t){return typeof t=="bigint"?t.toString():t}function ie(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function B(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var be=Symbol("evaluating");function h(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==be)return n===void 0&&(n=be,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function yt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function bt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}var oe="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var kt=ie(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function ze(e){if(J(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(J(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function E(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(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 Se(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ie={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]};function we(e,t){if(!ze(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(o,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=bt(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return yt(this,"shape",o),o}});return E(e,i)}function O(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 A(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function V(e){return typeof e=="string"?e:e?.message}function j(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=V(e.inst?._zod.def?.error?.(e))??V(t?.error?.(e))??V(r.customError?.(e))??V(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function ae(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var je=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ke,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ue=f("$ZodError",je),M=f("$ZodError",je,{Parent:Error});var St=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new S;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map(l=>j(l,o,w())));throw oe(c,i?.callee),c}return a.value},K=St(M),It=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(i?.Err??e)(a.issues.map(l=>j(l,o,w())));throw oe(c,i?.callee),c}return a.value},W=It(M),wt=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new S;return o.issues.length?{success:!1,error:new(e??Ue)(o.issues.map(a=>j(a,i,w())))}:{success:!0,data:o.value}},L=wt(M),jt=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>j(a,i,w())))}:{success:!0,data:o.value}},R=jt(M);var Ut="(?:(?:\\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])))",Pt=new RegExp(`^${Ut}$`);var Oe=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ze=/^-?\d+$/,De=/^-?\d+(?:\.\d+)?$/;var U=f("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Ot={number:"number",bigint:"bigint",object:"date"};var Te=f("$ZodCheckGreaterThan",(e,t)=>{U.init(e,t);let r=Ot[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var Ne=f("$ZodCheckNumberFormat",(e,t)=>{U.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Ie[t.format];e._zod.onattach.push(a=>{let c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=o,r&&(c.pattern=Ze)}),e._zod.check=a=>{let c=a.value;if(r){if(!Number.isInteger(c)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),c>o&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}});var Ee=f("$ZodCheckStringFormat",(e,t)=>{var r,n;U.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})});var Me={major:4,minor:3,patch:5};var _=f("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Me;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(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)=>{let s=O(a),g;for(let v of c){if(v._zod.def.when){if(!v._zod.def.when(a))continue}else if(s)continue;let $=a.issues.length,k=v._zod.check(a);if(k instanceof Promise&&l?.async===!1)throw new S;if(g||k instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await k,a.issues.length!==$&&(s||(s=O(a,$)))});else{if(a.issues.length===$)continue;s||(s=O(a,$))}}return g?g.then(()=>a):a},o=(a,c,l)=>{if(O(a))return a.aborted=!0,a;let s=i(c,n,l);if(s instanceof Promise){if(l.async===!1)throw new S;return s.then(g=>e._zod.parse(g,l))}return e._zod.parse(s,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let s=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return s instanceof Promise?s.then(g=>o(g,a,c)):o(s,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new S;return l.then(s=>i(s,n,c))}return i(l,n,c)}}h(e,"~standard",()=>({validate:i=>{try{let o=L(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return R(e,i).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Y=f("$ZodString",(e,t)=>{_.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Oe(e._zod.bag),e._zod.parse=(r,n)=>{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}}),ce=f("$ZodStringFormat",(e,t)=>{Ee.init(e,t),Y.init(e,t)});var Ge=f("$ZodURL",(e,t)=>{ce.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}});var ue=f("$ZodNumber",(e,t)=>{_.init(e,t),e._zod.pattern=e._zod.bag.pattern??De,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),Ve=f("$ZodNumberFormat",(e,t)=>{Ne.init(e,t),ue.init(e,t)});var Je=f("$ZodUnknown",(e,t)=>{_.init(e,t),e._zod.parse=r=>r});function Le(e,t,r){e.issues.length&&t.issues.push(...A(r,e.issues)),t.value[r]=e.value}var Be=f("$ZodArray",(e,t)=>{_.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let a=0;a<i.length;a++){let c=i[a],l=t.element._zod.run({value:c,issues:[]},n);l instanceof Promise?o.push(l.then(s=>Le(s,r,a))):Le(l,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function q(e,t,r,n,i){if(e.issues.length){if(i&&!(r in n))return;t.issues.push(...A(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Dt(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Se(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Tt(e,t,r,n,i,o){let a=[],c=i.keySet,l=i.catchall._zod,s=l.def.type,g=l.optout==="optional";for(let v in t){if(c.has(v))continue;if(s==="never"){a.push(v);continue}let $=l.run({value:t[v],issues:[]},n);$ instanceof Promise?e.push($.then(k=>q(k,r,v,t,g))):q($,r,v,t,g)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var Ke=f("$ZodObject",(e,t)=>{if(_.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...c};return Object.defineProperty(t,"shape",{value:l}),l}})}let n=ie(()=>Dt(t));h(e._zod,"propValues",()=>{let c=t.shape,l={};for(let s in c){let g=c[s]._zod;if(g.values){l[s]??(l[s]=new Set);for(let v of g.values)l[s].add(v)}}return l});let i=J,o=t.catchall,a;e._zod.parse=(c,l)=>{a??(a=n.value);let s=c.value;if(!i(s))return c.issues.push({expected:"object",code:"invalid_type",input:s,inst:e}),c;c.value={};let g=[],v=a.shape;for(let $ of a.keys){let k=v[$],N=k._zod.optout==="optional",ee=k._zod.run({value:s[$],issues:[]},l);ee instanceof Promise?g.push(ee.then(ht=>q(ht,c,$,s,N))):q(ee,c,$,s,N)}return o?Tt(g,s,c,l,n.value,e):g.length?Promise.all(g).then(()=>c):c}});function Re(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let i=e.filter(o=>!O(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(a=>j(a,n,w())))}),t)}var We=f("$ZodUnion",(e,t)=>{_.init(e,t),h(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),h(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),h(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),h(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>B(o.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(r)return n(i,o);let a=!1,c=[];for(let l of t.options){let s=l._zod.run({value:i.value,issues:[]},o);if(s instanceof Promise)c.push(s),a=!0;else{if(s.issues.length===0)return s;c.push(s)}}return a?Promise.all(c).then(l=>Re(l,i,e,o)):Re(c,i,e,o)}});var Xe=f("$ZodTuple",(e,t)=>{_.init(e,t);let r=t.items;e._zod.parse=(n,i)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let a=[],c=[...r].reverse().findIndex(g=>g._zod.optin!=="optional"),l=c===-1?0:r.length-c;if(!t.rest){let g=o.length>r.length,v=o.length<l-1;if(g||v)return n.issues.push({...g?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:o,inst:e,origin:"array"}),n}let s=-1;for(let g of r){if(s++,s>=o.length&&s>=l)continue;let v=g._zod.run({value:o[s],issues:[]},i);v instanceof Promise?a.push(v.then($=>X($,n,s))):X(v,n,s)}if(t.rest){let g=o.slice(r.length);for(let v of g){s++;let $=t.rest._zod.run({value:v,issues:[]},i);$ instanceof Promise?a.push($.then(k=>X(k,n,s))):X($,n,s)}}return a.length?Promise.all(a).then(()=>n):n}});function X(e,t,r){e.issues.length&&t.issues.push(...A(r,e.issues)),t.value[r]=e.value}function Ce(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var qe=f("$ZodOptional",(e,t)=>{_.init(e,t),e._zod.optin="optional",e._zod.optout="optional",h(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),h(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${B(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>Ce(o,r.value)):Ce(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var Ye=f("$ZodNullable",(e,t)=>{_.init(e,t),h(e._zod,"optin",()=>t.innerType._zod.optin),h(e._zod,"optout",()=>t.innerType._zod.optout),h(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${B(r.source)}|null)$`):void 0}),h(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)});var He=f("$ZodCustom",(e,t)=>{U.init(e,t),_.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>Fe(o,r,n,e));Fe(i,r,n,e)}});function Fe(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(ae(i))}}var et;var se=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.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 n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function tt(){return new se}(et=globalThis).__zod_globalRegistry??(et.__zod_globalRegistry=tt());var le=globalThis.__zod_globalRegistry;function rt(e,t){return new e({type:"string",...b(t)})}function nt(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(t)})}function it(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(t)})}function ot(e){return new e({type:"unknown"})}function de(e,t){return new Te({check:"greater_than",...b(t),value:e,inclusive:!0})}function me(e){return de(0,e)}function at(e,t,r){let n=b(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}var z=f("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");_.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>K(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>L(e,r,n),e.parseAsync=async(r,n)=>W(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>R(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>E(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),pe=f("ZodMiniString",(e,t)=>{Y.init(e,t),z.init(e,t)});function Z(e){return rt(pe,e)}var ct=f("ZodMiniStringFormat",(e,t)=>{ce.init(e,t),pe.init(e,t)});var Wt=f("ZodMiniURL",(e,t)=>{Ge.init(e,t),ct.init(e,t)});function y(e){return nt(Wt,e)}var ut=f("ZodMiniNumber",(e,t)=>{ue.init(e,t),z.init(e,t)});var Xt=f("ZodMiniNumberFormat",(e,t)=>{Ve.init(e,t),ut.init(e,t)});function st(e){return it(Xt,e)}var qt=f("ZodMiniUnknown",(e,t)=>{Je.init(e,t),z.init(e,t)});function Yt(){return ot(qt)}var Ht=f("ZodMiniArray",(e,t)=>{Be.init(e,t),z.init(e,t)});function D(e,t){return new Ht({type:"array",element:e,...b(t)})}var Qt=f("ZodMiniObject",(e,t)=>{Ke.init(e,t),z.init(e,t),h(e,"shape",()=>t.shape)});function I(e,t){return new Qt({type:"object",shape:e,catchall:Yt(),...b(t)})}function fe(e,t){return we(e,t)}var er=f("ZodMiniUnion",(e,t)=>{We.init(e,t),z.init(e,t)});function lt(e,t){return new er({type:"union",options:e,...b(t)})}var tr=f("ZodMiniTuple",(e,t)=>{Xe.init(e,t),z.init(e,t)});function x(e,t,r){let n=t instanceof _,i=n?r:t,o=n?t:null;return new tr({type:"tuple",items:e,rest:o,...b(i)})}var rr=f("ZodMiniOptional",(e,t)=>{qe.init(e,t),z.init(e,t)});function P(e){return new rr({type:"optional",innerType:e})}var nr=f("ZodMiniNullable",(e,t)=>{Ye.init(e,t),z.init(e,t)});function Q(e){return new nr({type:"nullable",innerType:e})}var ir=f("ZodMiniCustom",(e,t)=>{He.init(e,t),z.init(e,t)});function or(e,t){return at(ir,e??(()=>!0),t)}function dt(e,t={}){let r=or(n=>n instanceof e,t);return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var vt=I({value:I({}),channels:D(Z()),allowed:P(Q(D(y())))}),ol=fe(vt,{url:y(),actor:y()}),pt=lt([I({url:y()}),y()]),T=I({actor:y()}),F=P(Q(T)),$t=I({data:dt(Blob),allowed:P(Q(D(y())))}),al=fe($t,{actor:y()}),lr=I({types:P(D(Z())),maxBytes:P(st().check(me()))});async function*ft(e){for(;;){let t=await e.next();if(t.done){let{cursor:r,continue:n}=t.value;return{cursor:r,continue:(...i)=>{let o=x([F]).parse(i);return n(...o)}}}else yield t.value}}var gt=class{constructor(t){this.graffiti=t;this.sessionEvents=this.graffiti.sessionEvents}sessionEvents;login=(...t)=>{let r=x([P(y())]).parse(t);return this.graffiti.login(...r)};logout=(...t)=>{let r=x([T]).parse(t);return this.graffiti.logout(...r)};handleToActor=(...t)=>{let r=x([Z()]).parse(t);return this.graffiti.handleToActor(...r)};actorToHandle=(...t)=>{let r=x([y()]).parse(t);return this.graffiti.actorToHandle(...r)};post=(...t)=>{let r=x([vt,T]).parse(t);return this.graffiti.post(...r)};get=(...t)=>{let r=x([pt,I({}),F]).parse(t);return this.graffiti.get(r[0],r[1],r[2])};delete=(...t)=>{let r=x([pt,T]).parse(t);return this.graffiti.delete(...r)};postMedia=(...t)=>{let r=x([$t,T]).parse(t);return this.graffiti.postMedia(...r)};getMedia=(...t)=>{let r=x([y(),lr,F]).parse(t);return this.graffiti.getMedia(...r)};deleteMedia=(...t)=>{let r=x([y(),T]).parse(t);return this.graffiti.deleteMedia(...r)};discover=(...t)=>{let r=x([D(Z()),I({}),F]).parse(t),n=this.graffiti.discover(r[0],r[1],r[2]);return ft(n)};continueDiscover=(...t)=>{let r=x([Z(),F]).parse(t),n=this.graffiti.continueDiscover(...r);return ft(n)}};export{ge as Graffiti,ye as GraffitiErrorCursorExpired,ve as GraffitiErrorForbidden,G as GraffitiErrorInvalidSchema,xe as GraffitiErrorNotAcceptable,$e as GraffitiErrorNotFound,he as GraffitiErrorSchemaMismatch,_e as GraffitiErrorTooLarge,lr as GraffitiMediaAcceptSchema,al as GraffitiMediaSchema,_t as GraffitiObjectJSONSchema,ol as GraffitiObjectSchema,pt as GraffitiObjectUrlSchema,F as GraffitiOptionalSessionSchema,$t as GraffitiPostMediaSchema,mr as GraffitiPostObjectJSONSchema,vt as GraffitiPostObjectSchema,gt as GraffitiRuntimeTypes,T as GraffitiSessionSchema,xr as compileGraffitiObjectSchema,$r as isActorAllowedGraffitiObject,_r as isMediaAcceptable,hr as maskGraffitiObject,vr as unpackObjectUrl};
2
2
  //# sourceMappingURL=index.js.map