@graffiti-garden/wrapper-synchronize 1.0.4 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/cjs/index.js +1 -30
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +2 -21
- package/dist/esm/index.js.map +2 -2
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/package.json +4 -5
- package/src/index.spec.ts +11 -6
- package/src/index.ts +2 -34
package/dist/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as g,c as j,d as O}from"./chunk-YB7WCAZH.js";g();O();j();g();O();j();var re={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"]},de={...re,required:["value","channels"]};var D=class Q extends Error{constructor(r){super(r),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,Q.prototype)}},X=class K extends Error{constructor(r){super(r),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,K.prototype)}};function N(t){return typeof t=="string"?t:t.url}function Y(t,r){return!Array.isArray(t.allowed)||typeof r?.actor=="string"&&(t.actor===r.actor||t.allowed.includes(r.actor))}function Z(t,r,e){if(e===t.actor)return t;let n=t.allowed&&e?[e]:void 0,o=t.channels.filter(i=>r.includes(i));return{...t,allowed:n,channels:o}}g();O();j();var R=function(t,r){return R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o])},R(t,r)};function ne(t,r){R(t,r);function e(){this.constructor=t}t.prototype=r===null?Object.create(r):(e.prototype=r.prototype,new e)}function G(t,r,e,n){function o(i){return i instanceof e?i:new e(function(u){u(i)})}return new(e||(e=Promise))(function(i,u){function c(f){try{a(n.next(f))}catch(h){u(h)}}function l(f){try{a(n.throw(f))}catch(h){u(h)}}function a(f){f.done?i(f.value):o(f.value).then(c,l)}a((n=n.apply(t,r||[])).next())})}function b(t,r){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,u;return u={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(a){return function(f){return l([a,f])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return e.label++,{value:a[1],done:!1};case 5:e.label++,o=a[1],a=[0];continue;case 7:a=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){e.label=a[1];break}if(a[0]===6&&e.label<i[1]){e.label=i[1],i=a;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(a);break}i[2]&&e.ops.pop(),e.trys.pop();continue}a=r.call(t,e)}catch(f){a=[6,f],o=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function E(t){var r=typeof Symbol=="function"&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function k(t){return this instanceof k?(this.v=t,this):new k(t)}function ie(t,r,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(t,r||[]),o,i=[];return o={},u("next"),u("throw"),u("return"),o[Symbol.asyncIterator]=function(){return this},o;function u(s){n[s]&&(o[s]=function(d){return new Promise(function(p,y){i.push([s,d,p,y])>1||c(s,d)})})}function c(s,d){try{l(n[s](d))}catch(p){h(i[0][3],p)}}function l(s){s.value instanceof k?Promise.resolve(s.value.v).then(a,f):h(i[0][2],s)}function a(s){c("next",s)}function f(s){c("throw",s)}function h(s,d){s(d),i.shift(),i.length&&c(i[0][0],i[0][1])}}var ee=(function(t){ne(r,t);function r(e){var n=t.call(this,e)||this;return Object.defineProperty(n,"name",{value:"RepeaterOverflowError",enumerable:!1}),typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf(n,n.constructor.prototype):n.__proto__=n.constructor.prototype,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(n,n.constructor),n}return r})(Error),be=(function(){function t(r){if(r<0)throw new RangeError("Capacity may not be less than 0");this._c=r,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return this._q.length>=this._c},enumerable:!1,configurable:!0}),t.prototype.add=function(r){if(this.full)throw new Error("Buffer full");this._q.push(r)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t})(),we=(function(){function t(r){if(r<1)throw new RangeError("Capacity may not be less than 1");this._c=r,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(r){for(;this._q.length>=this._c;)this._q.shift();this._q.push(r)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t})(),Se=(function(){function t(r){if(r<1)throw new RangeError("Capacity may not be less than 1");this._c=r,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(r){this._q.length<this._c&&this._q.push(r)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t})();function F(t){t!=null&&typeof t.then=="function"&&t.then(B,B)}var J=0,$=1,S=2,q=3,V=4,T=1024,B=function(){};function x(t){var r=t.err,e=Promise.resolve(t.execution).then(function(n){if(r!=null)throw r;return n});return t.err=void 0,t.execution=e.then(function(){},function(){}),t.pending===void 0?e:t.pending.then(function(){return e})}function w(t,r){var e=t.state>=q;return Promise.resolve(r).then(function(n){return!e&&t.state>=V?x(t).then(function(o){return{value:o,done:!0}}):{value:n,done:e}})}function _(t,r){var e,n;if(!(t.state>=S))if(t.state=S,t.onnext(),t.onstop(),t.err==null&&(t.err=r),t.pushes.length===0&&(typeof t.buffer>"u"||t.buffer.empty))A(t);else try{for(var o=E(t.pushes),i=o.next();!i.done;i=o.next()){var u=i.value;u.resolve()}}catch(c){e={error:c}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}}function A(t){var r,e;if(!(t.state>=q)){t.state<S&&_(t),t.state=q,t.buffer=void 0;try{for(var n=E(t.nexts),o=n.next();!o.done;o=n.next()){var i=o.value,u=t.pending===void 0?x(t):t.pending.then(function(){return x(t)});i.resolve(w(t,u))}}catch(c){r={error:c}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(r)throw r.error}}t.pushes=[],t.nexts=[]}}function U(t){t.state>=V||(t.state<q&&A(t),t.state=V)}function oe(t,r){if(F(r),t.pushes.length>=T)throw new ee("No more than "+T+" pending calls to push are allowed on a single repeater.");if(t.state>=S)return Promise.resolve(void 0);var e=t.pending===void 0?Promise.resolve(r):t.pending.then(function(){return r});e=e.catch(function(l){t.state<S&&(t.err=l),U(t)});var n;if(t.nexts.length){var o=t.nexts.shift();o.resolve(w(t,e)),t.nexts.length?n=Promise.resolve(t.nexts[0].value):typeof t.buffer<"u"&&!t.buffer.full?n=Promise.resolve(void 0):n=new Promise(function(l){return t.onnext=l})}else typeof t.buffer<"u"&&!t.buffer.full?(t.buffer.add(e),n=Promise.resolve(void 0)):n=new Promise(function(l){return t.pushes.push({resolve:l,value:e})});var i=!0,u={},c=n.catch(function(l){if(i)throw l});return u.then=function(l,a){return i=!1,Promise.prototype.then.call(n,l,a)},u.catch=function(l){return i=!1,Promise.prototype.catch.call(n,l)},u.finally=n.finally.bind(n),t.pending=e.then(function(){return c}).catch(function(l){t.err=l,U(t)}),u}function ae(t){var r=_.bind(null,t),e=new Promise(function(n){return t.onstop=n});return r.then=e.then.bind(e),r.catch=e.catch.bind(e),r.finally=e.finally.bind(e),r}function se(t){if(!(t.state>=$)){t.state=$;var r=oe.bind(null,t),e=ae(t);t.execution=new Promise(function(n){return n(t.executor(r,e))}),t.execution.catch(function(){return _(t)})}}var M=new WeakMap,P=(function(){function t(r,e){M.set(this,{executor:r,buffer:e,err:void 0,state:J,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:B,onstop:B})}return t.prototype.next=function(r){F(r);var e=M.get(this);if(e===void 0)throw new Error("WeakMap error");if(e.nexts.length>=T)throw new ee("No more than "+T+" pending calls to next are allowed on a single repeater.");if(e.state<=J&&se(e),e.onnext(r),typeof e.buffer<"u"&&!e.buffer.empty){var n=w(e,e.buffer.remove());if(e.pushes.length){var o=e.pushes.shift();e.buffer.add(o.value),e.onnext=o.resolve}return n}else if(e.pushes.length){var i=e.pushes.shift();return e.onnext=i.resolve,w(e,i.value)}else if(e.state>=S)return A(e),w(e,x(e));return new Promise(function(u){return e.nexts.push({resolve:u,value:r})})},t.prototype.return=function(r){F(r);var e=M.get(this);if(e===void 0)throw new Error("WeakMap error");return A(e),e.execution=Promise.resolve(e.execution).then(function(){return r}),w(e,x(e))},t.prototype.throw=function(r){var e=M.get(this);if(e===void 0)throw new Error("WeakMap error");return e.state<=J||e.state>=S||typeof e.buffer<"u"&&!e.buffer.empty?(A(e),e.err==null&&(e.err=r),w(e,x(e))):this.next(Promise.reject(r))},t.prototype[Symbol.asyncIterator]=function(){return this},t.race=ue,t.merge=ce,t.zip=fe,t.latest=le,t})();function I(t,r){var e,n,o=[],i=function(a){a!=null&&typeof a[Symbol.asyncIterator]=="function"?o.push(a[Symbol.asyncIterator]()):a!=null&&typeof a[Symbol.iterator]=="function"?o.push(a[Symbol.iterator]()):o.push((function(){return ie(this,arguments,function(){return b(this,function(s){switch(s.label){case 0:return r.yieldValues?[4,k(a)]:[3,3];case 1:return[4,s.sent()];case 2:s.sent(),s.label=3;case 3:return r.returnValues?[4,k(a)]:[3,5];case 4:return[2,s.sent()];case 5:return[2]}})})})())};try{for(var u=E(t),c=u.next();!c.done;c=u.next()){var l=c.value;i(l)}}catch(a){e={error:a}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}return o}function ue(t){var r=this,e=I(t,{returnValues:!0});return new P(function(n,o){return G(r,void 0,void 0,function(){var i,u,c,l,a,f;return b(this,function(h){switch(h.label){case 0:if(!e.length)return o(),[2];u=!1,o.then(function(){i(),u=!0}),h.label=1;case 1:h.trys.push([1,,5,7]),l=void 0,a=0,f=function(){var s,d,p,y,m,C;return b(this,function(z){switch(z.label){case 0:s=a;try{for(d=(m=void 0,E(e)),p=d.next();!p.done;p=d.next())y=p.value,Promise.resolve(y.next()).then(function(v){v.done?(o(),c===void 0&&(c=v)):a===s&&(a++,i(v))},function(v){return o(v)})}catch(v){m={error:v}}finally{try{p&&!p.done&&(C=d.return)&&C.call(d)}finally{if(m)throw m.error}}return[4,new Promise(function(v){return i=v})];case 1:return l=z.sent(),l===void 0?[3,3]:[4,n(l.value)];case 2:z.sent(),z.label=3;case 3:return[2]}})},h.label=2;case 2:return u?[3,4]:[5,f()];case 3:return h.sent(),[3,2];case 4:return[2,c&&c.value];case 5:return o(),[4,Promise.race(e.map(function(s){return s.return&&s.return()}))];case 6:return h.sent(),[7];case 7:return[2]}})})})}function ce(t){var r=this,e=I(t,{yieldValues:!0});return new P(function(n,o){return G(r,void 0,void 0,function(){var i,u,c,l=this;return b(this,function(a){switch(a.label){case 0:if(!e.length)return o(),[2];i=[],u=!1,o.then(function(){var f,h;u=!0;try{for(var s=E(i),d=s.next();!d.done;d=s.next()){var p=d.value;p()}}catch(y){f={error:y}}finally{try{d&&!d.done&&(h=s.return)&&h.call(s)}finally{if(f)throw f.error}}}),a.label=1;case 1:return a.trys.push([1,,3,4]),[4,Promise.all(e.map(function(f,h){return G(l,void 0,void 0,function(){var s,d;return b(this,function(p){switch(p.label){case 0:p.trys.push([0,,6,9]),p.label=1;case 1:return u?[3,5]:(Promise.resolve(f.next()).then(function(y){return i[h](y)},function(y){return o(y)}),[4,new Promise(function(y){i[h]=y})]);case 2:return s=p.sent(),s===void 0?[3,4]:s.done?(c=s,[2]):[4,n(s.value)];case 3:p.sent(),p.label=4;case 4:return[3,1];case 5:return[3,9];case 6:return d=f.return,d?[4,f.return()]:[3,8];case 7:d=p.sent(),p.label=8;case 8:return[7];case 9:return[2]}})})}))];case 2:return a.sent(),[2,c&&c.value];case 3:return o(),[7];case 4:return[2]}})})})}function fe(t){var r=this,e=I(t,{returnValues:!0});return new P(function(n,o){return G(r,void 0,void 0,function(){var i,u,c,l;return b(this,function(a){switch(a.label){case 0:if(!e.length)return o(),[2,[]];u=!1,o.then(function(){i(),u=!0}),a.label=1;case 1:a.trys.push([1,,6,8]),a.label=2;case 2:return u?[3,5]:(Promise.all(e.map(function(f){return f.next()})).then(function(f){return i(f)},function(f){return o(f)}),[4,new Promise(function(f){return i=f})]);case 3:return c=a.sent(),c===void 0?[2]:(l=c.map(function(f){return f.value}),c.some(function(f){return f.done})?[2,l]:[4,n(l)]);case 4:return a.sent(),[3,2];case 5:return[3,8];case 6:return o(),[4,Promise.all(e.map(function(f){return f.return&&f.return()}))];case 7:return a.sent(),[7];case 8:return[2]}})})})}function le(t){var r=this,e=I(t,{yieldValues:!0,returnValues:!0});return new P(function(n,o){return G(r,void 0,void 0,function(){var i,u,c,l,a,f=this;return b(this,function(h){switch(h.label){case 0:if(!e.length)return o(),[2,[]];u=[],c=!1,o.then(function(){var s,d;i();try{for(var p=E(u),y=p.next();!y.done;y=p.next()){var m=y.value;m()}}catch(C){s={error:C}}finally{try{y&&!y.done&&(d=p.return)&&d.call(p)}finally{if(s)throw s.error}}c=!0}),h.label=1;case 1:return h.trys.push([1,,5,7]),Promise.all(e.map(function(s){return s.next()})).then(function(s){return i(s)},function(s){return o(s)}),[4,new Promise(function(s){return i=s})];case 2:return l=h.sent(),l===void 0?[2]:(a=l.map(function(s){return s.value}),l.every(function(s){return s.done})?[2,a]:[4,n(a.slice())]);case 3:return h.sent(),[4,Promise.all(e.map(function(s,d){return G(f,void 0,void 0,function(){var p;return b(this,function(y){switch(y.label){case 0:if(l[d].done)return[2,l[d].value];y.label=1;case 1:return c?[3,4]:(Promise.resolve(s.next()).then(function(m){return u[d](m)},function(m){return o(m)}),[4,new Promise(function(m){return u[d]=m})]);case 2:return p=y.sent(),p===void 0?[2,l[d].value]:p.done?[2,p.value]:(a[d]=p.value,[4,n(a.slice())]);case 3:return y.sent(),[3,1];case 4:return[2]}})})}))];case 4:return[2,h.sent()];case 5:return o(),[4,Promise.all(e.map(function(s){return s.return&&s.return()}))];case 6:return h.sent(),[7];case 7:return[2]}})})})}var te=class{ajv_;graffiti;callbacks=new Set;options;login;logout;sessionEvents;postMedia;getMedia;deleteMedia;actorToHandle;handleToActor;get ajv(){return this.ajv_||(this.ajv_=(async()=>{let{default:r}=await import("./ajv-UZKI6BMI.js");return new r({strict:!1})})()),this.ajv_}constructor(r,e){this.options=e??{},this.graffiti=r,this.login=r.login.bind(r),this.logout=r.logout.bind(r),this.sessionEvents=r.sessionEvents,this.postMedia=r.postMedia.bind(r),this.getMedia=r.getMedia.bind(r),this.deleteMedia=r.deleteMedia.bind(r),this.actorToHandle=r.actorToHandle.bind(r),this.handleToActor=r.handleToActor.bind(r)}synchronize(r,e,n,o,i=new Set){let u=new P(async(c,l)=>{let a=he(await this.ajv,n),f=h=>{if(h?.tombstone)i.has(h.object.url)&&c(h);else if(h&&r(h.object)&&(this.options.omniscient||Y(h.object,o))){let s=JSON.parse(JSON.stringify(h.object));this.options.omniscient||(s=Z(s,e,o?.actor)),a(s)&&(c({object:s}),i.add(s.url))}};this.callbacks.add(f),await l,this.callbacks.delete(f)});return(async function*(){for await(let c of u)yield c})()}synchronizeDiscover(r,e,n){function o(i){return i.channels.some(u=>r.includes(u))}return this.synchronize(o,r,e,n)}synchronizeGet(r,e,n){let o=N(r);function i(u){return u.url===o}return this.synchronize(i,[],e,n,new Set([o]))}synchronizeAll(r,e){return this.synchronize(()=>!0,[],r,e)}async synchronizeDispatch(r,e=!1){for(let n of this.callbacks)n(r);e&&await new Promise(n=>setTimeout(n,0))}get=async(...r)=>{try{let e=await this.graffiti.get(...r);return this.synchronizeDispatch({object:e}),e}catch(e){throw e instanceof D&&this.synchronizeDispatch({tombstone:!0,object:{url:N(r[0])}}),e}};post=async(...r)=>{let e=await this.graffiti.post(...r);return await this.synchronizeDispatch({object:e},!0),e};delete=async(...r)=>{let e={tombstone:!0,object:{url:N(r[0])}};try{let n=await this.graffiti.delete(...r);return await this.synchronizeDispatch(e,!0),n}catch(n){throw n instanceof D&&await this.synchronizeDispatch(e,!0),n}};objectStreamContinue(r){let e=this;return(async function*(){for(;;){let n=await r.next();if(n.done){let{continue:o,cursor:i}=n.value;return{continue:u=>e.objectStreamContinue(o(u)),cursor:i}}n.value.error||e.synchronizeDispatch(n.value),yield n.value}})()}objectStream(r){let e=this.objectStreamContinue(r);return(async function*(){for(;;){let n=await e.next();if(n.done)return n.value;(n.value.error||!n.value.tombstone)&&(yield n.value)}})()}discover=(...r)=>{let e=this.graffiti.discover(...r);return this.objectStream(e)};continueDiscover=(...r)=>{let e=this.graffiti.continueDiscover(...r);return this.objectStreamContinue(e)}};function he(t,r){try{return t.compile(r)}catch(e){throw new X(e instanceof Error?e.message:String(e))}}export{te as GraffitiSynchronize};
|
|
1
|
+
import{b as a,c as u,d as c}from"./chunk-YB7WCAZH.js";a();c();u();a();c();u();a();c();u();a();c();u();var Lt={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"]},Jr={...Lt,required:["value","channels"]};a();c();u();var W=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,e.prototype)}},oe=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,e.prototype)}};a();c();u();function ae(e){return typeof e=="string"?e:e.url}function Fe(e,t){return!Array.isArray(e.allowed)||typeof t?.actor=="string"&&(e.actor===t.actor||e.allowed.includes(t.actor))}function Ve(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}}var be;async function Ge(e){if(!be){let{default:t}=await import("./ajv-UZKI6BMI.js");be=new t({strict:!1})}try{return be.compile(e)}catch(t){throw new oe(t instanceof Error?t.message:String(t))}}a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();var Ct=Object.freeze({status:"aborted"});function I(e,t,r){function n(s,m){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:m,constr:l,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,m);let d=l.prototype,h=Object.keys(d);for(let _=0;_<h.length;_++){let f=h[_];f in s||(s[f]=d[f].bind(s))}}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function l(s){var m;let d=r?.Parent?new o:this;n(d,s),(m=d._zod).deferred??(m.deferred=[]);for(let h of d._zod.deferred)h();return d}return Object.defineProperty(l,"init",{value:n}),Object.defineProperty(l,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(l,"name",{value:e}),l}var D=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};var ke={};function N(e){return e&&Object.assign(ke,e),ke}a();c();u();a();c();u();a();c();u();function Be(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 le(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var Je=Symbol("evaluating");function S(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Je)return n===void 0&&(n=Je,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Rt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ft(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}var we="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Vt=Ie(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ke(e){if(ce(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(ce(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function q(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function U(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 We(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var qe={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 Xe(e,t){if(!Ke(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 l in t)if(Object.getOwnPropertyDescriptor(o,l)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=Ft(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Rt(this,"shape",o),o}});return q(e,i)}function F(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 se(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ue(e){return typeof e=="string"?e:e?.message}function A(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=ue(e.inst?._zod.def?.error?.(e))??ue(t?.error?.(e))??ue(r.customError?.(e))??ue(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Se(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var Ye=(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,Be,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},He=I("$ZodError",Ye),X=I("$ZodError",Ye,{Parent:Error});var Jt=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},l=t._zod.run({value:r,issues:[]},o);if(l instanceof Promise)throw new D;if(l.issues.length){let s=new(i?.Err??e)(l.issues.map(m=>A(m,o,N())));throw we(s,i?.callee),s}return l.value},de=Jt(X),Bt=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},l=t._zod.run({value:r,issues:[]},o);if(l instanceof Promise&&(l=await l),l.issues.length){let s=new(i?.Err??e)(l.issues.map(m=>A(m,o,N())));throw we(s,i?.callee),s}return l.value},me=Bt(X),Kt=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 D;return o.issues.length?{success:!1,error:new(e??He)(o.issues.map(l=>A(l,i,N())))}:{success:!0,data:o.value}},Y=Kt(X),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(l=>A(l,i,N())))}:{success:!0,data:o.value}},H=Wt(X);a();c();u();a();c();u();a();c();u();var qt="(?:(?:\\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])))",Xt=new RegExp(`^${qt}$`);var et=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var tt=/^-?\d+$/,rt=/^-?\d+(?:\.\d+)?$/;var M=I("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Yt={number:"number",bigint:"bigint",object:"date"};var nt=I("$ZodCheckGreaterThan",(e,t)=>{M.init(e,t);let r=Yt[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 it=I("$ZodCheckNumberFormat",(e,t)=>{M.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=qe[t.format];e._zod.onattach.push(l=>{let s=l._zod.bag;s.format=t.format,s.minimum=i,s.maximum=o,r&&(s.pattern=tt)}),e._zod.check=l=>{let s=l.value;if(r){if(!Number.isInteger(s)){l.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?l.issues.push({input:s,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}):l.issues.push({input:s,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}}s<i&&l.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>o&&l.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}});var ot=I("$ZodCheckStringFormat",(e,t)=>{var r,n;M.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=()=>{})});a();c();u();a();c();u();var ut={major:4,minor:3,patch:5};var P=I("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ut;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=(l,s,m)=>{let d=F(l),h;for(let _ of s){if(_._zod.def.when){if(!_._zod.def.when(l))continue}else if(d)continue;let f=l.issues.length,k=_._zod.check(l);if(k instanceof Promise&&m?.async===!1)throw new D;if(h||k instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await k,l.issues.length!==f&&(d||(d=F(l,f)))});else{if(l.issues.length===f)continue;d||(d=F(l,f))}}return h?h.then(()=>l):l},o=(l,s,m)=>{if(F(l))return l.aborted=!0,l;let d=i(s,n,m);if(d instanceof Promise){if(m.async===!1)throw new D;return d.then(h=>e._zod.parse(h,m))}return e._zod.parse(d,m)};e._zod.run=(l,s)=>{if(s.skipChecks)return e._zod.parse(l,s);if(s.direction==="backward"){let d=e._zod.parse({value:l.value,issues:[]},{...s,skipChecks:!0});return d instanceof Promise?d.then(h=>o(h,l,s)):o(d,l,s)}let m=e._zod.parse(l,s);if(m instanceof Promise){if(s.async===!1)throw new D;return m.then(d=>i(d,n,s))}return i(m,n,s)}}S(e,"~standard",()=>({validate:i=>{try{let o=Y(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return H(e,i).then(l=>l.success?{value:l.data}:{issues:l.error?.issues})}},vendor:"zod",version:1}))}),pe=I("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??et(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}}),je=I("$ZodStringFormat",(e,t)=>{ot.init(e,t),pe.init(e,t)});var mt=I("$ZodURL",(e,t)=>{je.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 Pe=I("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=e._zod.bag.pattern??rt,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}}),ft=I("$ZodNumberFormat",(e,t)=>{it.init(e,t),Pe.init(e,t)});var pt=I("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=r=>r});function ct(e,t,r){e.issues.length&&t.issues.push(...se(r,e.issues)),t.value[r]=e.value}var vt=I("$ZodArray",(e,t)=>{P.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 l=0;l<i.length;l++){let s=i[l],m=t.element._zod.run({value:s,issues:[]},n);m instanceof Promise?o.push(m.then(d=>ct(d,r,l))):ct(m,r,l)}return o.length?Promise.all(o).then(()=>r):r}});function fe(e,t,r,n,i){if(e.issues.length){if(i&&!(r in n))return;t.issues.push(...se(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Qt(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=We(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function er(e,t,r,n,i,o){let l=[],s=i.keySet,m=i.catchall._zod,d=m.def.type,h=m.optout==="optional";for(let _ in t){if(s.has(_))continue;if(d==="never"){l.push(_);continue}let f=m.run({value:t[_],issues:[]},n);f instanceof Promise?e.push(f.then(k=>fe(k,r,_,t,h))):fe(f,r,_,t,h)}return l.length&&r.issues.push({code:"unrecognized_keys",keys:l,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var gt=I("$ZodObject",(e,t)=>{if(P.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let s=t.shape;Object.defineProperty(t,"shape",{get:()=>{let m={...s};return Object.defineProperty(t,"shape",{value:m}),m}})}let n=Ie(()=>Qt(t));S(e._zod,"propValues",()=>{let s=t.shape,m={};for(let d in s){let h=s[d]._zod;if(h.values){m[d]??(m[d]=new Set);for(let _ of h.values)m[d].add(_)}}return m});let i=ce,o=t.catchall,l;e._zod.parse=(s,m)=>{l??(l=n.value);let d=s.value;if(!i(d))return s.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),s;s.value={};let h=[],_=l.shape;for(let f of l.keys){let k=_[f],z=k._zod.optout==="optional",w=k._zod.run({value:d[f],issues:[]},m);w instanceof Promise?h.push(w.then(j=>fe(j,s,f,d,z))):fe(w,s,f,d,z)}return o?er(h,d,s,m,n.value,e):h.length?Promise.all(h).then(()=>s):s}});function lt(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=>!F(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(l=>A(l,n,N())))}),t)}var ht=I("$ZodUnion",(e,t)=>{P.init(e,t),S(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),S(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),S(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),S(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=>le(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 l=!1,s=[];for(let m of t.options){let d=m._zod.run({value:i.value,issues:[]},o);if(d instanceof Promise)s.push(d),l=!0;else{if(d.issues.length===0)return d;s.push(d)}}return l?Promise.all(s).then(m=>lt(m,i,e,o)):lt(s,i,e,o)}});function st(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var $t=I("$ZodOptional",(e,t)=>{P.init(e,t),e._zod.optin="optional",e._zod.optout="optional",S(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${le(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=>st(o,r.value)):st(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var _t=I("$ZodNullable",(e,t)=>{P.init(e,t),S(e._zod,"optin",()=>t.innerType._zod.optin),S(e._zod,"optout",()=>t.innerType._zod.optout),S(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${le(r.source)}|null)$`):void 0}),S(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 yt=I("$ZodCustom",(e,t)=>{M.init(e,t),P.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=>dt(o,r,n,e));dt(i,r,n,e)}});function dt(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(Se(i))}}a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();var bt;var Ue=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 kt(){return new Ue}(bt=globalThis).__zod_globalRegistry??(bt.__zod_globalRegistry=kt());var Oe=globalThis.__zod_globalRegistry;a();c();u();function zt(e,t){return new e({type:"string",...U(t)})}function It(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...U(t)})}function wt(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...U(t)})}function St(e){return new e({type:"unknown"})}function De(e,t){return new nt({check:"greater_than",...U(t),value:e,inclusive:!0})}function Ze(e){return De(0,e)}function jt(e,t,r){let n=U(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();var Z=I("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");P.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>de(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Y(e,r,n),e.parseAsync=async(r,n)=>me(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>H(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)=>q(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Te=I("ZodMiniString",(e,t)=>{pe.init(e,t),Z.init(e,t)});function Ne(e){return zt(Te,e)}var Pt=I("ZodMiniStringFormat",(e,t)=>{je.init(e,t),Te.init(e,t)});var pr=I("ZodMiniURL",(e,t)=>{mt.init(e,t),Pt.init(e,t)});function T(e){return It(pr,e)}var Ut=I("ZodMiniNumber",(e,t)=>{Pe.init(e,t),Z.init(e,t)});var vr=I("ZodMiniNumberFormat",(e,t)=>{ft.init(e,t),Ut.init(e,t)});function Ot(e){return wt(vr,e)}var gr=I("ZodMiniUnknown",(e,t)=>{pt.init(e,t),Z.init(e,t)});function hr(){return St(gr)}var $r=I("ZodMiniArray",(e,t)=>{vt.init(e,t),Z.init(e,t)});function ee(e,t){return new $r({type:"array",element:e,...U(t)})}var _r=I("ZodMiniObject",(e,t)=>{gt.init(e,t),Z.init(e,t),S(e,"shape",()=>t.shape)});function L(e,t){return new _r({type:"object",shape:e,catchall:hr(),...U(t)})}function Ee(e,t){return Xe(e,t)}var yr=I("ZodMiniUnion",(e,t)=>{ht.init(e,t),Z.init(e,t)});function Dt(e,t){return new yr({type:"union",options:e,...U(t)})}var xr=I("ZodMiniOptional",(e,t)=>{$t.init(e,t),Z.init(e,t)});function V(e){return new xr({type:"optional",innerType:e})}var br=I("ZodMiniNullable",(e,t)=>{_t.init(e,t),Z.init(e,t)});function ge(e){return new br({type:"nullable",innerType:e})}var kr=I("ZodMiniCustom",(e,t)=>{yt.init(e,t),Z.init(e,t)});function zr(e,t){return jt(kr,e??(()=>!0),t)}function Zt(e,t={}){let r=zr(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}a();c();u();a();c();u();a();c();u();var Pr=L({value:L({}),channels:ee(Ne()),allowed:V(ge(ee(T())))}),Yp=Ee(Pr,{url:T(),actor:T()}),Hp=Dt([L({url:T()}),T()]),Ur=L({actor:T()}),Qp=V(ge(Ur)),Or=L({data:Zt(Blob),allowed:V(ge(ee(T())))}),ev=Ee(Or,{actor:T()}),tv=L({types:V(ee(Ne())),maxBytes:V(Ot().check(Ze()))});a();c();u();var Me=function(e,t){return Me=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Me(e,t)};function Dr(e,t){Me(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function J(e,t,r,n){function i(o){return o instanceof r?o:new r(function(l){l(o)})}return new(r||(r=Promise))(function(o,l){function s(h){try{d(n.next(h))}catch(_){l(_)}}function m(h){try{d(n.throw(h))}catch(_){l(_)}}function d(h){h.done?o(h.value):i(h.value).then(s,m)}d((n=n.apply(e,t||[])).next())})}function E(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,l;return l={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function s(d){return function(h){return m([d,h])}}function m(d){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=d[0]&2?i.return:d[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,d[1])).done)return o;switch(i=0,o&&(d=[d[0]&2,o.value]),d[0]){case 0:case 1:o=d;break;case 4:return r.label++,{value:d[1],done:!1};case 5:r.label++,i=d[1],d=[0];continue;case 7:d=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(d[0]===6||d[0]===2)){r=0;continue}if(d[0]===3&&(!o||d[1]>o[0]&&d[1]<o[3])){r.label=d[1];break}if(d[0]===6&&r.label<o[1]){r.label=o[1],o=d;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(d);break}o[2]&&r.ops.pop(),r.trys.pop();continue}d=t.call(e,r)}catch(h){d=[6,h],i=0}finally{n=o=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function B(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function re(e){return this instanceof re?(this.v=e,this):new re(e)}function Zr(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,o=[];return i={},l("next"),l("throw"),l("return"),i[Symbol.asyncIterator]=function(){return this},i;function l(f){n[f]&&(i[f]=function(k){return new Promise(function(z,w){o.push([f,k,z,w])>1||s(f,k)})})}function s(f,k){try{m(n[f](k))}catch(z){_(o[0][3],z)}}function m(f){f.value instanceof re?Promise.resolve(f.value.v).then(d,h):_(o[0][2],f)}function d(f){s("next",f)}function h(f){s("throw",f)}function _(f,k){f(k),o.shift(),o.length&&s(o[0][0],o[0][1])}}var At=(function(e){Dr(t,e);function t(r){var n=e.call(this,r)||this;return Object.defineProperty(n,"name",{value:"RepeaterOverflowError",enumerable:!1}),typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf(n,n.constructor.prototype):n.__proto__=n.constructor.prototype,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(n,n.constructor),n}return t})(Error),vv=(function(){function e(t){if(t<0)throw new RangeError("Capacity may not be less than 0");this._c=t,this._q=[]}return Object.defineProperty(e.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return this._q.length>=this._c},enumerable:!1,configurable:!0}),e.prototype.add=function(t){if(this.full)throw new Error("Buffer full");this._q.push(t)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},e})(),gv=(function(){function e(t){if(t<1)throw new RangeError("Capacity may not be less than 1");this._c=t,this._q=[]}return Object.defineProperty(e.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.add=function(t){for(;this._q.length>=this._c;)this._q.shift();this._q.push(t)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},e})(),hv=(function(){function e(t){if(t<1)throw new RangeError("Capacity may not be less than 1");this._c=t,this._q=[]}return Object.defineProperty(e.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.add=function(t){this._q.length<this._c&&this._q.push(t)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},e})();function Le(e){e!=null&&typeof e.then=="function"&&e.then(ye,ye)}var Ae=0,Nt=1,R=2,$e=3,Ce=4,_e=1024,ye=function(){};function G(e){var t=e.err,r=Promise.resolve(e.execution).then(function(n){if(t!=null)throw t;return n});return e.err=void 0,e.execution=r.then(function(){},function(){}),e.pending===void 0?r:e.pending.then(function(){return r})}function C(e,t){var r=e.state>=$e;return Promise.resolve(t).then(function(n){return!r&&e.state>=Ce?G(e).then(function(i){return{value:i,done:!0}}):{value:n,done:r}})}function Re(e,t){var r,n;if(!(e.state>=R))if(e.state=R,e.onnext(),e.onstop(),e.err==null&&(e.err=t),e.pushes.length===0&&(typeof e.buffer>"u"||e.buffer.empty))te(e);else try{for(var i=B(e.pushes),o=i.next();!o.done;o=i.next()){var l=o.value;l.resolve()}}catch(s){r={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}function te(e){var t,r;if(!(e.state>=$e)){e.state<R&&Re(e),e.state=$e,e.buffer=void 0;try{for(var n=B(e.nexts),i=n.next();!i.done;i=n.next()){var o=i.value,l=e.pending===void 0?G(e):e.pending.then(function(){return G(e)});o.resolve(C(e,l))}}catch(s){t={error:s}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}e.pushes=[],e.nexts=[]}}function Et(e){e.state>=Ce||(e.state<$e&&te(e),e.state=Ce)}function Tr(e,t){if(Le(t),e.pushes.length>=_e)throw new At("No more than "+_e+" pending calls to push are allowed on a single repeater.");if(e.state>=R)return Promise.resolve(void 0);var r=e.pending===void 0?Promise.resolve(t):e.pending.then(function(){return t});r=r.catch(function(m){e.state<R&&(e.err=m),Et(e)});var n;if(e.nexts.length){var i=e.nexts.shift();i.resolve(C(e,r)),e.nexts.length?n=Promise.resolve(e.nexts[0].value):typeof e.buffer<"u"&&!e.buffer.full?n=Promise.resolve(void 0):n=new Promise(function(m){return e.onnext=m})}else typeof e.buffer<"u"&&!e.buffer.full?(e.buffer.add(r),n=Promise.resolve(void 0)):n=new Promise(function(m){return e.pushes.push({resolve:m,value:r})});var o=!0,l={},s=n.catch(function(m){if(o)throw m});return l.then=function(m,d){return o=!1,Promise.prototype.then.call(n,m,d)},l.catch=function(m){return o=!1,Promise.prototype.catch.call(n,m)},l.finally=n.finally.bind(n),e.pending=r.then(function(){return s}).catch(function(m){e.err=m,Et(e)}),l}function Nr(e){var t=Re.bind(null,e),r=new Promise(function(n){return e.onstop=n});return t.then=r.then.bind(r),t.catch=r.catch.bind(r),t.finally=r.finally.bind(r),t}function Er(e){if(!(e.state>=Nt)){e.state=Nt;var t=Tr.bind(null,e),r=Nr(e);e.execution=new Promise(function(n){return n(e.executor(t,r))}),e.execution.catch(function(){return Re(e)})}}var he=new WeakMap,K=(function(){function e(t,r){he.set(this,{executor:t,buffer:r,err:void 0,state:Ae,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:ye,onstop:ye})}return e.prototype.next=function(t){Le(t);var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");if(r.nexts.length>=_e)throw new At("No more than "+_e+" pending calls to next are allowed on a single repeater.");if(r.state<=Ae&&Er(r),r.onnext(t),typeof r.buffer<"u"&&!r.buffer.empty){var n=C(r,r.buffer.remove());if(r.pushes.length){var i=r.pushes.shift();r.buffer.add(i.value),r.onnext=i.resolve}return n}else if(r.pushes.length){var o=r.pushes.shift();return r.onnext=o.resolve,C(r,o.value)}else if(r.state>=R)return te(r),C(r,G(r));return new Promise(function(l){return r.nexts.push({resolve:l,value:t})})},e.prototype.return=function(t){Le(t);var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");return te(r),r.execution=Promise.resolve(r.execution).then(function(){return t}),C(r,G(r))},e.prototype.throw=function(t){var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");return r.state<=Ae||r.state>=R||typeof r.buffer<"u"&&!r.buffer.empty?(te(r),r.err==null&&(r.err=t),C(r,G(r))):this.next(Promise.reject(t))},e.prototype[Symbol.asyncIterator]=function(){return this},e.race=Ar,e.merge=Mr,e.zip=Lr,e.latest=Cr,e})();function xe(e,t){var r,n,i=[],o=function(d){d!=null&&typeof d[Symbol.asyncIterator]=="function"?i.push(d[Symbol.asyncIterator]()):d!=null&&typeof d[Symbol.iterator]=="function"?i.push(d[Symbol.iterator]()):i.push((function(){return Zr(this,arguments,function(){return E(this,function(f){switch(f.label){case 0:return t.yieldValues?[4,re(d)]:[3,3];case 1:return[4,f.sent()];case 2:f.sent(),f.label=3;case 3:return t.returnValues?[4,re(d)]:[3,5];case 4:return[2,f.sent()];case 5:return[2]}})})})())};try{for(var l=B(e),s=l.next();!s.done;s=l.next()){var m=s.value;o(m)}}catch(d){r={error:d}}finally{try{s&&!s.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}return i}function Ar(e){var t=this,r=xe(e,{returnValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,l,s,m,d,h;return E(this,function(_){switch(_.label){case 0:if(!r.length)return i(),[2];l=!1,i.then(function(){o(),l=!0}),_.label=1;case 1:_.trys.push([1,,5,7]),m=void 0,d=0,h=function(){var f,k,z,w,j,ne;return E(this,function(ie){switch(ie.label){case 0:f=d;try{for(k=(j=void 0,B(r)),z=k.next();!z.done;z=k.next())w=z.value,Promise.resolve(w.next()).then(function(O){O.done?(i(),s===void 0&&(s=O)):d===f&&(d++,o(O))},function(O){return i(O)})}catch(O){j={error:O}}finally{try{z&&!z.done&&(ne=k.return)&&ne.call(k)}finally{if(j)throw j.error}}return[4,new Promise(function(O){return o=O})];case 1:return m=ie.sent(),m===void 0?[3,3]:[4,n(m.value)];case 2:ie.sent(),ie.label=3;case 3:return[2]}})},_.label=2;case 2:return l?[3,4]:[5,h()];case 3:return _.sent(),[3,2];case 4:return[2,s&&s.value];case 5:return i(),[4,Promise.race(r.map(function(f){return f.return&&f.return()}))];case 6:return _.sent(),[7];case 7:return[2]}})})})}function Mr(e){var t=this,r=xe(e,{yieldValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,l,s,m=this;return E(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2];o=[],l=!1,i.then(function(){var h,_;l=!0;try{for(var f=B(o),k=f.next();!k.done;k=f.next()){var z=k.value;z()}}catch(w){h={error:w}}finally{try{k&&!k.done&&(_=f.return)&&_.call(f)}finally{if(h)throw h.error}}}),d.label=1;case 1:return d.trys.push([1,,3,4]),[4,Promise.all(r.map(function(h,_){return J(m,void 0,void 0,function(){var f,k;return E(this,function(z){switch(z.label){case 0:z.trys.push([0,,6,9]),z.label=1;case 1:return l?[3,5]:(Promise.resolve(h.next()).then(function(w){return o[_](w)},function(w){return i(w)}),[4,new Promise(function(w){o[_]=w})]);case 2:return f=z.sent(),f===void 0?[3,4]:f.done?(s=f,[2]):[4,n(f.value)];case 3:z.sent(),z.label=4;case 4:return[3,1];case 5:return[3,9];case 6:return k=h.return,k?[4,h.return()]:[3,8];case 7:k=z.sent(),z.label=8;case 8:return[7];case 9:return[2]}})})}))];case 2:return d.sent(),[2,s&&s.value];case 3:return i(),[7];case 4:return[2]}})})})}function Lr(e){var t=this,r=xe(e,{returnValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,l,s,m;return E(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2,[]];l=!1,i.then(function(){o(),l=!0}),d.label=1;case 1:d.trys.push([1,,6,8]),d.label=2;case 2:return l?[3,5]:(Promise.all(r.map(function(h){return h.next()})).then(function(h){return o(h)},function(h){return i(h)}),[4,new Promise(function(h){return o=h})]);case 3:return s=d.sent(),s===void 0?[2]:(m=s.map(function(h){return h.value}),s.some(function(h){return h.done})?[2,m]:[4,n(m)]);case 4:return d.sent(),[3,2];case 5:return[3,8];case 6:return i(),[4,Promise.all(r.map(function(h){return h.return&&h.return()}))];case 7:return d.sent(),[7];case 8:return[2]}})})})}function Cr(e){var t=this,r=xe(e,{yieldValues:!0,returnValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,l,s,m,d,h=this;return E(this,function(_){switch(_.label){case 0:if(!r.length)return i(),[2,[]];l=[],s=!1,i.then(function(){var f,k;o();try{for(var z=B(l),w=z.next();!w.done;w=z.next()){var j=w.value;j()}}catch(ne){f={error:ne}}finally{try{w&&!w.done&&(k=z.return)&&k.call(z)}finally{if(f)throw f.error}}s=!0}),_.label=1;case 1:return _.trys.push([1,,5,7]),Promise.all(r.map(function(f){return f.next()})).then(function(f){return o(f)},function(f){return i(f)}),[4,new Promise(function(f){return o=f})];case 2:return m=_.sent(),m===void 0?[2]:(d=m.map(function(f){return f.value}),m.every(function(f){return f.done})?[2,d]:[4,n(d.slice())]);case 3:return _.sent(),[4,Promise.all(r.map(function(f,k){return J(h,void 0,void 0,function(){var z;return E(this,function(w){switch(w.label){case 0:if(m[k].done)return[2,m[k].value];w.label=1;case 1:return s?[3,4]:(Promise.resolve(f.next()).then(function(j){return l[k](j)},function(j){return i(j)}),[4,new Promise(function(j){return l[k]=j})]);case 2:return z=w.sent(),z===void 0?[2,m[k].value]:z.done?[2,z.value]:(d[k]=z.value,[4,n(d.slice())]);case 3:return w.sent(),[3,1];case 4:return[2]}})})}))];case 4:return[2,_.sent()];case 5:return i(),[4,Promise.all(r.map(function(f){return f.return&&f.return()}))];case 6:return _.sent(),[7];case 7:return[2]}})})})}var Mt=class{graffiti;callbacks=new Set;options;login;logout;sessionEvents;postMedia;getMedia;deleteMedia;actorToHandle;handleToActor;constructor(t,r){this.options=r??{},this.graffiti=t,this.login=t.login.bind(t),this.logout=t.logout.bind(t),this.sessionEvents=t.sessionEvents,this.postMedia=t.postMedia.bind(t),this.getMedia=t.getMedia.bind(t),this.deleteMedia=t.deleteMedia.bind(t),this.actorToHandle=t.actorToHandle.bind(t),this.handleToActor=t.handleToActor.bind(t)}synchronize(t,r,n,i,o=new Set){let l=new K(async(s,m)=>{let d=await Ge(n),h=_=>{if(_?.tombstone)o.has(_.object.url)&&s(_);else if(_&&t(_.object)&&(this.options.omniscient||Fe(_.object,i))){let f=JSON.parse(JSON.stringify(_.object));this.options.omniscient||(f=Ve(f,r,i?.actor)),d(f)&&(s({object:f}),o.add(f.url))}};this.callbacks.add(h),await m,this.callbacks.delete(h)});return(async function*(){for await(let s of l)yield s})()}synchronizeDiscover(t,r,n){function i(o){return o.channels.some(l=>t.includes(l))}return this.synchronize(i,t,r,n)}synchronizeGet(t,r,n){let i=ae(t);function o(l){return l.url===i}return this.synchronize(o,[],r,n,new Set([i]))}synchronizeAll(t,r){return this.synchronize(()=>!0,[],t,r)}async synchronizeDispatch(t,r=!1){for(let n of this.callbacks)n(t);r&&await new Promise(n=>setTimeout(n,0))}get=async(...t)=>{try{let r=await this.graffiti.get(...t);return this.synchronizeDispatch({object:r}),r}catch(r){throw r instanceof W&&this.synchronizeDispatch({tombstone:!0,object:{url:ae(t[0])}}),r}};post=async(...t)=>{let r=await this.graffiti.post(...t);return await this.synchronizeDispatch({object:r},!0),r};delete=async(...t)=>{let r={tombstone:!0,object:{url:ae(t[0])}};try{let n=await this.graffiti.delete(...t);return await this.synchronizeDispatch(r,!0),n}catch(n){throw n instanceof W&&await this.synchronizeDispatch(r,!0),n}};objectStreamContinue(t){let r=this;return(async function*(){for(;;){let n=await t.next();if(n.done){let{continue:i,cursor:o}=n.value;return{continue:l=>r.objectStreamContinue(i(l)),cursor:o}}n.value.error||r.synchronizeDispatch(n.value),yield n.value}})()}objectStream(t){let r=this.objectStreamContinue(t);return(async function*(){for(;;){let n=await r.next();if(n.done)return n.value;(n.value.error||!n.value.tombstone)&&(yield n.value)}})()}discover=(...t)=>{let r=this.graffiti.discover(...t);return this.objectStream(r)};continueDiscover=(...t)=>{let r=this.graffiti.continueDiscover(...t);return this.objectStreamContinue(r)}};export{Mt as GraffitiSynchronize};
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@repeaterjs/repeater/repeater.js:
|