1 | System.register(["@urql/core","jotai","wonka"],function(q){"use strict";var d,m,p,w;return{setters:[function(b){d=b.createClient},function(b){m=b.atom},function(b){p=b.pipe,w=b.subscribe}],execute:function(){q({atomWithMutation:E,atomWithQuery:g,atomWithSubscription:k});const b=(()=>{try{return process.env.JOTAI_URQL_DEFAULT_URL}catch{return}})()||"/graphql",P=q("clientAtom",m(d({url:b}))),T=l=>"data"in l&&!l.error;function g(l,y=s=>s(P)){const s=m(n=>{const e=l(n);if(e.pause)return null;const u=y(n);let t=null;const a=()=>new Promise(i=>{t=i}),c=m(a());let o=null;const A=i=>{if(!t&&!o)throw new Error("setting result without mount");t&&(t(i),t=null),o&&o(i)};let r=null,f;const h=i=>{r&&(clearTimeout(f),r.unsubscribe()),r=p(u.query(e.query,e.variables,{...e.requestPolicy&&{requestPolicy:e.requestPolicy},...e.context,...i}),w(A)),o||(f=setTimeout(()=>{r&&(r.unsubscribe(),r=null)},1e3))};return h(),c.onMount=i=>(o=i,r?clearTimeout(f):h(),()=>{o=null,r&&(r.unsubscribe(),r=null)}),{resultAtom:c,makePending:a,startQuery:h}});return m(n=>{const e=n(s);if(!e)return null;const{resultAtom:u}=e,t=n(u);if(!T(t))throw t.error;return t},(n,e,u)=>{switch(u.type==="reexecute"&&(console.warn("DEPRECATED [atomWithQuery] use refetch instead of reexecute"),u.type="refetch"),u.type){case"refetch":{const t=n(s);if(!t)throw new Error("query is paused");const{resultAtom:a,makePending:c,startQuery:o}=t;e(a,c()),o(u.opts);return}}})}function E(l,y=s=>s(P)){const s=m(new Promise(()=>{}));return m(n=>n(s),async(n,e,u)=>{e(s,new Promise(()=>{}));const t=y(n),a=l(n);return t.mutation(a,u.variables,u.context).toPromise().then(c=>{var o;if((o=u.callback)==null||o.call(u,c),c.error)throw c.error;e(s,c)})})}const W=l=>"data"in l&&!l.error;function k(l,y=s=>s(P)){const s=m(n=>{const e=l(n);if(e.pause)return null;const u=y(n);let t=null;const a=()=>new Promise(i=>{t=i}),c=m(a());let o=null;const A=i=>{t&&(t(i),t=null),o&&o(i)};let r=null,f;const h=()=>{r&&(clearTimeout(f),r.unsubscribe()),r=p(u.subscription(e.query,e.variables,e.context),w(A)),o||(f=setTimeout(()=>{r&&(r.unsubscribe(),r=null)},1e3))};return h(),c.onMount=i=>(o=i,r?clearTimeout(f):h(),()=>{o=null,r&&(r.unsubscribe(),r=null)}),{resultAtom:c,makePending:a,startSub:h}});return m(n=>{const e=n(s);if(!e)return null;const{resultAtom:u}=e,t=n(u);if(!W(t))throw t.error;return t},(n,e,u)=>{switch(u.type){case"refetch":{const t=n(s);if(!t)throw new Error("query is paused");const{resultAtom:a,makePending:c,startSub:o}=t;e(a,c()),o();return}}})}}}});
|