@graffiti-garden/wrapper-synchronize 1.0.4 → 1.0.7
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/package.json +3 -3
- package/src/index.spec.ts +11 -6
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 At={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"]},Gr={...At,required:["value","channels"]};a();c();u();var W=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,e.prototype)}},q=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 Re(e,t){return!Array.isArray(e.allowed)||typeof t?.actor=="string"&&(e.actor===t.actor||e.allowed.includes(t.actor))}function Fe(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}}a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();var Mt=Object.freeze({status:"aborted"});function I(e,t,r){function n(l,m){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:m,constr:s,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,m);let d=s.prototype,h=Object.keys(d);for(let _=0;_<h.length;_++){let f=h[_];f in l||(l[f]=d[f].bind(l))}}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function s(l){var m;let d=r?.Parent?new o:this;n(d,l),(m=d._zod).deferred??(m.deferred=[]);for(let h of d._zod.deferred)h();return d}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:l=>r?.Parent&&l instanceof r.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var D=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};var be={};function N(e){return e&&Object.assign(be,e),be}a();c();u();a();c();u();a();c();u();function Ge(e,t){return typeof t=="bigint"?t.toString():t}function ze(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function se(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var Ve=Symbol("evaluating");function S(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Ve)return n===void 0&&(n=Ve,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Lt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ct(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}var Ie="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Rt=ze(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Je(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 X(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 Be(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ke={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(!Je(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 s in t)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=Ct(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Lt(this,"shape",o),o}});return X(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 le(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 we(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var qe=(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,Ge,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Xe=I("$ZodError",qe),Y=I("$ZodError",qe,{Parent:Error});var Vt=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new D;if(s.issues.length){let l=new(i?.Err??e)(s.issues.map(m=>A(m,o,N())));throw Ie(l,i?.callee),l}return s.value},de=Vt(Y),Gt=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let l=new(i?.Err??e)(s.issues.map(m=>A(m,o,N())));throw Ie(l,i?.callee),l}return s.value},me=Gt(Y),Jt=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??Xe)(o.issues.map(s=>A(s,i,N())))}:{success:!0,data:o.value}},H=Jt(Y),Bt=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(s=>A(s,i,N())))}:{success:!0,data:o.value}},Q=Bt(Y);a();c();u();a();c();u();a();c();u();var Kt="(?:(?:\\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])))",Wt=new RegExp(`^${Kt}$`);var He=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Qe=/^-?\d+$/,et=/^-?\d+(?:\.\d+)?$/;var M=I("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),qt={number:"number",bigint:"bigint",object:"date"};var tt=I("$ZodCheckGreaterThan",(e,t)=>{M.init(e,t);let r=qt[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 rt=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]=Ke[t.format];e._zod.onattach.push(s=>{let l=s._zod.bag;l.format=t.format,l.minimum=i,l.maximum=o,r&&(l.pattern=Qe)}),e._zod.check=s=>{let l=s.value;if(r){if(!Number.isInteger(l)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?s.issues.push({input:l,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}):s.issues.push({input:l,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}}l<i&&s.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>o&&s.issues.push({origin:"number",input:l,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}});var nt=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 ot={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=ot;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=(s,l,m)=>{let d=F(s),h;for(let _ of l){if(_._zod.def.when){if(!_._zod.def.when(s))continue}else if(d)continue;let f=s.issues.length,k=_._zod.check(s);if(k instanceof Promise&&m?.async===!1)throw new D;if(h||k instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await k,s.issues.length!==f&&(d||(d=F(s,f)))});else{if(s.issues.length===f)continue;d||(d=F(s,f))}}return h?h.then(()=>s):s},o=(s,l,m)=>{if(F(s))return s.aborted=!0,s;let d=i(l,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=(s,l)=>{if(l.skipChecks)return e._zod.parse(s,l);if(l.direction==="backward"){let d=e._zod.parse({value:s.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(h=>o(h,s,l)):o(d,s,l)}let m=e._zod.parse(s,l);if(m instanceof Promise){if(l.async===!1)throw new D;return m.then(d=>i(d,n,l))}return i(m,n,l)}}S(e,"~standard",()=>({validate:i=>{try{let o=H(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Q(e,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),pe=I("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??He(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}}),Se=I("$ZodStringFormat",(e,t)=>{nt.init(e,t),pe.init(e,t)});var lt=I("$ZodURL",(e,t)=>{Se.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 je=I("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=e._zod.bag.pattern??et,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}}),dt=I("$ZodNumberFormat",(e,t)=>{rt.init(e,t),je.init(e,t)});var mt=I("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=r=>r});function at(e,t,r){e.issues.length&&t.issues.push(...le(r,e.issues)),t.value[r]=e.value}var ft=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 s=0;s<i.length;s++){let l=i[s],m=t.element._zod.run({value:l,issues:[]},n);m instanceof Promise?o.push(m.then(d=>at(d,r,s))):at(m,r,s)}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(...le(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Yt(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=Be(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Ht(e,t,r,n,i,o){let s=[],l=i.keySet,m=i.catchall._zod,d=m.def.type,h=m.optout==="optional";for(let _ in t){if(l.has(_))continue;if(d==="never"){s.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 s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var pt=I("$ZodObject",(e,t)=>{if(P.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let l=t.shape;Object.defineProperty(t,"shape",{get:()=>{let m={...l};return Object.defineProperty(t,"shape",{value:m}),m}})}let n=ze(()=>Yt(t));S(e._zod,"propValues",()=>{let l=t.shape,m={};for(let d in l){let h=l[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,s;e._zod.parse=(l,m)=>{s??(s=n.value);let d=l.value;if(!i(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value={};let h=[],_=s.shape;for(let f of s.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,l,f,d,z))):fe(w,l,f,d,z)}return o?Ht(h,d,l,m,n.value,e):h.length?Promise.all(h).then(()=>l):l}});function ut(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(s=>A(s,n,N())))}),t)}var vt=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=>se(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 s=!1,l=[];for(let m of t.options){let d=m._zod.run({value:i.value,issues:[]},o);if(d instanceof Promise)l.push(d),s=!0;else{if(d.issues.length===0)return d;l.push(d)}}return s?Promise.all(l).then(m=>ut(m,i,e,o)):ut(l,i,e,o)}});function ct(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var gt=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(`^(${se(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=>ct(o,r.value)):ct(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var ht=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(`^(${se(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 $t=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=>st(o,r,n,e));st(i,r,n,e)}});function st(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(we(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 yt;var Pe=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 xt(){return new Pe}(yt=globalThis).__zod_globalRegistry??(yt.__zod_globalRegistry=xt());var Ue=globalThis.__zod_globalRegistry;a();c();u();function bt(e,t){return new e({type:"string",...U(t)})}function kt(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...U(t)})}function zt(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...U(t)})}function It(e){return new e({type:"unknown"})}function Oe(e,t){return new tt({check:"greater_than",...U(t),value:e,inclusive:!0})}function De(e){return Oe(0,e)}function wt(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)=>H(e,r,n),e.parseAsync=async(r,n)=>me(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Q(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)=>X(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Ze=I("ZodMiniString",(e,t)=>{pe.init(e,t),Z.init(e,t)});function Te(e){return bt(Ze,e)}var St=I("ZodMiniStringFormat",(e,t)=>{Se.init(e,t),Ze.init(e,t)});var mr=I("ZodMiniURL",(e,t)=>{lt.init(e,t),St.init(e,t)});function T(e){return kt(mr,e)}var jt=I("ZodMiniNumber",(e,t)=>{je.init(e,t),Z.init(e,t)});var fr=I("ZodMiniNumberFormat",(e,t)=>{dt.init(e,t),jt.init(e,t)});function Pt(e){return zt(fr,e)}var pr=I("ZodMiniUnknown",(e,t)=>{mt.init(e,t),Z.init(e,t)});function vr(){return It(pr)}var gr=I("ZodMiniArray",(e,t)=>{ft.init(e,t),Z.init(e,t)});function te(e,t){return new gr({type:"array",element:e,...U(t)})}var hr=I("ZodMiniObject",(e,t)=>{pt.init(e,t),Z.init(e,t),S(e,"shape",()=>t.shape)});function L(e,t){return new hr({type:"object",shape:e,catchall:vr(),...U(t)})}function Ne(e,t){return We(e,t)}var $r=I("ZodMiniUnion",(e,t)=>{vt.init(e,t),Z.init(e,t)});function Ut(e,t){return new $r({type:"union",options:e,...U(t)})}var _r=I("ZodMiniOptional",(e,t)=>{gt.init(e,t),Z.init(e,t)});function V(e){return new _r({type:"optional",innerType:e})}var yr=I("ZodMiniNullable",(e,t)=>{ht.init(e,t),Z.init(e,t)});function ge(e){return new yr({type:"nullable",innerType:e})}var xr=I("ZodMiniCustom",(e,t)=>{$t.init(e,t),Z.init(e,t)});function br(e,t){return wt(xr,e??(()=>!0),t)}function Ot(e,t={}){let r=br(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 Sr=L({value:L({}),channels:te(Te()),allowed:V(ge(te(T())))}),Xp=Ne(Sr,{url:T(),actor:T()}),Yp=Ut([L({url:T()}),T()]),jr=L({actor:T()}),Hp=V(ge(jr)),Pr=L({data:Ot(Blob),allowed:V(ge(te(T())))}),Qp=Ne(Pr,{actor:T()}),ev=L({types:V(te(Te())),maxBytes:V(Pt().check(De()))});a();c();u();var Ae=function(e,t){return Ae=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])},Ae(e,t)};function Ur(e,t){Ae(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(s){s(o)})}return new(r||(r=Promise))(function(o,s){function l(h){try{d(n.next(h))}catch(_){s(_)}}function m(h){try{d(n.throw(h))}catch(_){s(_)}}function d(h){h.done?o(h.value):i(h.value).then(l,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,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(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 ne(e){return this instanceof ne?(this.v=e,this):new ne(e)}function Or(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(f){n[f]&&(i[f]=function(k){return new Promise(function(z,w){o.push([f,k,z,w])>1||l(f,k)})})}function l(f,k){try{m(n[f](k))}catch(z){_(o[0][3],z)}}function m(f){f.value instanceof ne?Promise.resolve(f.value.v).then(d,h):_(o[0][2],f)}function d(f){l("next",f)}function h(f){l("throw",f)}function _(f,k){f(k),o.shift(),o.length&&l(o[0][0],o[0][1])}}var Nt=(function(e){Ur(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),pv=(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})(),vv=(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})(),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){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 Me(e){e!=null&&typeof e.then=="function"&&e.then(ye,ye)}var Ee=0,Zt=1,R=2,$e=3,Le=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>=Le?G(e).then(function(i){return{value:i,done:!0}}):{value:n,done:r}})}function Ce(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))re(e);else try{for(var i=B(e.pushes),o=i.next();!o.done;o=i.next()){var s=o.value;s.resolve()}}catch(l){r={error:l}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}function re(e){var t,r;if(!(e.state>=$e)){e.state<R&&Ce(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,s=e.pending===void 0?G(e):e.pending.then(function(){return G(e)});o.resolve(C(e,s))}}catch(l){t={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}e.pushes=[],e.nexts=[]}}function Tt(e){e.state>=Le||(e.state<$e&&re(e),e.state=Le)}function Dr(e,t){if(Me(t),e.pushes.length>=_e)throw new Nt("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),Tt(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,s={},l=n.catch(function(m){if(o)throw m});return s.then=function(m,d){return o=!1,Promise.prototype.then.call(n,m,d)},s.catch=function(m){return o=!1,Promise.prototype.catch.call(n,m)},s.finally=n.finally.bind(n),e.pending=r.then(function(){return l}).catch(function(m){e.err=m,Tt(e)}),s}function Zr(e){var t=Ce.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 Tr(e){if(!(e.state>=Zt)){e.state=Zt;var t=Dr.bind(null,e),r=Zr(e);e.execution=new Promise(function(n){return n(e.executor(t,r))}),e.execution.catch(function(){return Ce(e)})}}var he=new WeakMap,K=(function(){function e(t,r){he.set(this,{executor:t,buffer:r,err:void 0,state:Ee,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:ye,onstop:ye})}return e.prototype.next=function(t){Me(t);var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");if(r.nexts.length>=_e)throw new Nt("No more than "+_e+" pending calls to next are allowed on a single repeater.");if(r.state<=Ee&&Tr(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 re(r),C(r,G(r));return new Promise(function(s){return r.nexts.push({resolve:s,value:t})})},e.prototype.return=function(t){Me(t);var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");return re(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<=Ee||r.state>=R||typeof r.buffer<"u"&&!r.buffer.empty?(re(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=Nr,e.merge=Er,e.zip=Ar,e.latest=Mr,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 Or(this,arguments,function(){return E(this,function(f){switch(f.label){case 0:return t.yieldValues?[4,ne(d)]:[3,3];case 1:return[4,f.sent()];case 2:f.sent(),f.label=3;case 3:return t.returnValues?[4,ne(d)]:[3,5];case 4:return[2,f.sent()];case 5:return[2]}})})})())};try{for(var s=B(e),l=s.next();!l.done;l=s.next()){var m=l.value;o(m)}}catch(d){r={error:d}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i}function Nr(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,s,l,m,d,h;return E(this,function(_){switch(_.label){case 0:if(!r.length)return i(),[2];s=!1,i.then(function(){o(),s=!0}),_.label=1;case 1:_.trys.push([1,,5,7]),m=void 0,d=0,h=function(){var f,k,z,w,j,ie;return E(this,function(oe){switch(oe.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(),l===void 0&&(l=O)):d===f&&(d++,o(O))},function(O){return i(O)})}catch(O){j={error:O}}finally{try{z&&!z.done&&(ie=k.return)&&ie.call(k)}finally{if(j)throw j.error}}return[4,new Promise(function(O){return o=O})];case 1:return m=oe.sent(),m===void 0?[3,3]:[4,n(m.value)];case 2:oe.sent(),oe.label=3;case 3:return[2]}})},_.label=2;case 2:return s?[3,4]:[5,h()];case 3:return _.sent(),[3,2];case 4:return[2,l&&l.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 Er(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,s,l,m=this;return E(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2];o=[],s=!1,i.then(function(){var h,_;s=!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 s?[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?(l=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,l&&l.value];case 3:return i(),[7];case 4:return[2]}})})})}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,s,l,m;return E(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2,[]];s=!1,i.then(function(){o(),s=!0}),d.label=1;case 1:d.trys.push([1,,6,8]),d.label=2;case 2:return s?[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 l=d.sent(),l===void 0?[2]:(m=l.map(function(h){return h.value}),l.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 Mr(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,s,l,m,d,h=this;return E(this,function(_){switch(_.label){case 0:if(!r.length)return i(),[2,[]];s=[],l=!1,i.then(function(){var f,k;o();try{for(var z=B(s),w=z.next();!w.done;w=z.next()){var j=w.value;j()}}catch(ie){f={error:ie}}finally{try{w&&!w.done&&(k=z.return)&&k.call(z)}finally{if(f)throw f.error}}l=!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 l?[3,4]:(Promise.resolve(f.next()).then(function(j){return s[k](j)},function(j){return i(j)}),[4,new Promise(function(j){return s[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 Et=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:t}=await import("./ajv-UZKI6BMI.js");return new t({strict:!1})})()),this.ajv_}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 s=new K(async(l,m)=>{let d=Lr(await this.ajv,n),h=_=>{if(_?.tombstone)o.has(_.object.url)&&l(_);else if(_&&t(_.object)&&(this.options.omniscient||Re(_.object,i))){let f=JSON.parse(JSON.stringify(_.object));this.options.omniscient||(f=Fe(f,r,i?.actor)),d(f)&&(l({object:f}),o.add(f.url))}};this.callbacks.add(h),await m,this.callbacks.delete(h)});return(async function*(){for await(let l of s)yield l})()}synchronizeDiscover(t,r,n){function i(o){return o.channels.some(s=>t.includes(s))}return this.synchronize(i,t,r,n)}synchronizeGet(t,r,n){let i=ae(t);function o(s){return s.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:s=>r.objectStreamContinue(i(s)),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)}};function Lr(e,t){try{return e.compile(t)}catch(r){throw new q(r instanceof Error?r.message:String(r))}}export{Et as GraffitiSynchronize};
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@repeaterjs/repeater/repeater.js:
|