Scripts/resources/[sna]/sna-sync/nui/fetch.client-5aab1c76.js

2 lines
52 KiB
JavaScript
Raw Normal View History

2024-12-29 20:01:18 +00:00
var Le=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var y=(e,t,r)=>(Le(e,t,"read from private field"),r?r.call(e):t.get(e)),V=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},q=(e,t,r,n)=>(Le(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);var Q=(e,t,r)=>(Le(e,t,"access private method"),r);import{S as Vt,s as qt,g as Xt,n as mt,e as Yt,r as f,$ as C,h as Jt,i as Zt,j as yt,o as Et}from"./index-f45b8810.js";var B,N,D,H,ne,ve,le,Re,ht,Qt=(ht=class extends Vt{constructor(r,n){super();V(this,ne);V(this,le);V(this,B,void 0);V(this,N,void 0);V(this,D,void 0);V(this,H,void 0);q(this,N,void 0),q(this,B,r),this.setOptions(n),this.bindMethods(),Q(this,ne,ve).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const n=this.options;this.options=y(this,B).defaultMutationOptions(r),qt(n,this.options)||y(this,B).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,D),observer:this}),(a=y(this,D))==null||a.setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=y(this,D))==null||r.removeObserver(this)}onMutationUpdate(r){Q(this,ne,ve).call(this),Q(this,le,Re).call(this,r)}getCurrentResult(){return y(this,N)}reset(){q(this,D,void 0),Q(this,ne,ve).call(this),Q(this,le,Re).call(this)}mutate(r,n){var a;return q(this,H,n),(a=y(this,D))==null||a.removeObserver(this),q(this,D,y(this,B).getMutationCache().build(y(this,B),this.options)),y(this,D).addObserver(this),y(this,D).execute(r)}},B=new WeakMap,N=new WeakMap,D=new WeakMap,H=new WeakMap,ne=new WeakSet,ve=function(){var n;const r=((n=y(this,D))==null?void 0:n.state)??Xt();q(this,N,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},le=new WeakSet,Re=function(r){mt.batch(()=>{var n,a,i,o,l,u,c,b;y(this,H)&&this.hasListeners()&&((r==null?void 0:r.type)==="success"?((a=(n=y(this,H)).onSuccess)==null||a.call(n,r.data,y(this,N).variables,y(this,N).context),(o=(i=y(this,H)).onSettled)==null||o.call(i,r.data,null,y(this,N).variables,y(this,N).context)):(r==null?void 0:r.type)==="error"&&((u=(l=y(this,H)).onError)==null||u.call(l,r.error,y(this,N).variables,y(this,N).context),(b=(c=y(this,H)).onSettled)==null||b.call(c,void 0,r.error,y(this,N).variables,y(this,N).context))),this.listeners.forEach(h=>{h(y(this,N))})})},ht);function _t(e,t){return typeof e=="function"?e(...t):!!e}function Bn(e,t){const r=Yt(t),[n]=f.useState(()=>new Qt(r,e));f.useEffect(()=>{n.setOptions(e)},[n,e]);const a=f.useSyncExternalStore(f.useCallback(o=>n.subscribe(mt.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=f.useCallback((o,l)=>{n.mutate(o,l).catch(er)},[n]);if(a.error&&_t(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function er(){}function zn(e,t,r){let[n,a]=f.useState(e||t),i=f.useRef(e!==void 0),o=e!==void 0;f.useEffect(()=>{let c=i.current;c!==o&&console.warn(`WARN: A component changed from ${c?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}.`),i.current=o},[o]);let l=o?e:n,u=f.useCallback((c,...b)=>{let h=(v,...g)=>{r&&(Object.is(l,v)||r(v,...g)),o||(l=v)};typeof c=="function"?(console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"),a((g,...E)=>{let T=c(o?l:g,...E);return h(T,...b),o?g:T})):(o||a(c),h(c,...b))},[o,l,r]);return[l,u]}function tr(e,t=-1/0,r=1/0){return Math.min(Math.max(e,t),r)}const ge={prefix:String(Math.round(Math.random()*1e10)),current:0},Pt=C.createContext(ge),rr=C.createContext(!1);let nr=!!(typeof window<"u"&&window.document&&window.document.createElement),Ce=new WeakMap;function ar(e=!1){let t=f.useContext(Pt),r=f.useRef(null);if(r.current===null&&!e){var n,a;let i=(n=C.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)===null||n===void 0||(a=n.ReactCurrentOwner)===null||a===void 0?void 0:a.current;if(i){let o=Ce.get(i);o=