@ram_28/kf-ai-sdk 1.0.12 → 1.0.13
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/auth.cjs +1 -1
- package/dist/auth.mjs +15 -15
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +1745 -736
- package/dist/kanban.cjs +2 -2
- package/dist/kanban.mjs +835 -469
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +1 -1
- package/dist/useQuery-BScHEo7x.cjs +1 -0
- package/dist/useQuery-KpZFg80c.js +748 -0
- package/package.json +1 -1
package/dist/table.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),O=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),O=require("./useQuery-BScHEo7x.cjs"),Q=require("./client-C15j4O5B.cjs"),_=require("./useFilter-D-bCDo6Z.cjs");function $(t){var N,m,P,k,z,T,F,M,w,E;const[o,p]=a.useState({query:""}),[n,y]=a.useState({field:((m=(N=t.initialState)==null?void 0:N.sorting)==null?void 0:m.field)||null,direction:((k=(P=t.initialState)==null?void 0:P.sorting)==null?void 0:k.direction)||null}),[i,c]=a.useState({pageNo:((T=(z=t.initialState)==null?void 0:z.pagination)==null?void 0:T.pageNo)||1,pageSize:((M=(F=t.initialState)==null?void 0:F.pagination)==null?void 0:M.pageSize)||10}),s=_.useFilter({initialConditions:(w=t.initialState)==null?void 0:w.filters,initialOperator:((E=t.initialState)==null?void 0:E.filterOperator)||"And"}),u=a.useMemo(()=>{const e={};return o.query&&(e.Search=o.query),s.payload&&(e.Filter=s.payload),e},[o.query,s.payload]),b=a.useMemo(()=>{const e={...u};return n.field&&n.direction&&(e.Sort=[{[String(n.field)]:n.direction==="asc"?"ASC":"DESC"}]),t.enablePagination&&(e.Page=i.pageNo,e.PageSize=i.pageSize),e},[u,n,i,t.enablePagination]),{data:l,isLoading:L,isFetching:R,error:x,refetch:q}=O.useQuery({queryKey:["table",t.source,b],queryFn:async()=>{try{const e=await Q.api(t.source).list(b);return t.onSuccess&&t.onSuccess(e.Data),e}catch(e){throw t.onError&&t.onError(e),e}},staleTime:0,gcTime:0}),{data:g,isLoading:A,isFetching:D,error:G,refetch:C}=O.useQuery({queryKey:["table-count",t.source,u],queryFn:async()=>{try{return await Q.api(t.source).count(u)}catch(e){throw t.onError&&t.onError(e),e}},staleTime:0,gcTime:0}),K=a.useMemo(()=>(l==null?void 0:l.Data)||[],[l]),S=a.useMemo(()=>(g==null?void 0:g.Count)||0,[g]),d=a.useMemo(()=>Math.ceil(S/i.pageSize),[S,i.pageSize]),j=a.useCallback(e=>{y(r=>{if(r.field===e){if(r.direction==="asc")return{field:e,direction:"desc"};if(r.direction==="desc")return{field:null,direction:null}}return{field:e,direction:"asc"}})},[]),I=a.useCallback(()=>{y({field:null,direction:null})},[]),B=a.useCallback((e,r)=>{y({field:e,direction:r})},[]),H=a.useCallback(e=>{p({query:e}),c(r=>({...r,pageNo:1}))},[]),J=a.useCallback(()=>{p({query:""})},[]),f=i.pageNo<d,h=i.pageNo>1,U=a.useCallback(()=>{f&&c(e=>({...e,pageNo:e.pageNo+1}))},[f]),V=a.useCallback(()=>{h&&c(e=>({...e,pageNo:e.pageNo-1}))},[h]),W=a.useCallback(e=>{const r=Math.max(1,Math.min(e,d));c(Z=>({...Z,pageNo:r}))},[d]),X=a.useCallback(e=>{c(r=>({...r,pageSize:e,pageNo:1}))},[]),Y=a.useCallback(async()=>{const[e]=await Promise.all([q(),C()]);return e.data||{Data:[]}},[q,C]);return{rows:K,totalItems:S,isLoading:L||A,isFetching:R||D,error:x||G,search:{query:o.query,setQuery:H,clear:J},sort:{field:n.field,direction:n.direction,toggle:j,clear:I,set:B},filter:s,pagination:{currentPage:i.pageNo,pageSize:i.pageSize,totalPages:d,totalItems:S,canGoNext:f,canGoPrevious:h,goToNext:U,goToPrevious:V,goToPage:W,setPageSize:X},refetch:Y}}exports.useTable=$;
|
package/dist/table.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState as m, useMemo as c, useCallback as i } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { u as A } from "./useQuery-KpZFg80c.js";
|
|
3
3
|
import { a as D } from "./client-CfvLiGfP.js";
|
|
4
4
|
import { u as v } from "./useFilter-CXFqEHyI.js";
|
|
5
5
|
function ae(t) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Te=e=>{throw TypeError(e)};var he=(e,t,s)=>t.has(e)||Te("Cannot "+s);var r=(e,t,s)=>(he(e,t,"read from private field"),s?s.call(e):t.get(e)),d=(e,t,s)=>t.has(e)?Te("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),o=(e,t,s,i)=>(he(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),y=(e,t,s)=>(he(e,t,"access private method"),s);const Ge=require("react");require("./jsx-runtime-BYECrxsp.cjs");function Xe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const C=Xe(Ge);var oe=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ye={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},T,Q,xe,et=(xe=class{constructor(){d(this,T,Ye);d(this,Q,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&r(this,Q)&&e!==r(this,T)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:r(this,T),provider:e}),o(this,T,e),process.env.NODE_ENV!=="production"&&o(this,Q,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&o(this,Q,!0),r(this,T).setTimeout(e,t)}clearTimeout(e){r(this,T).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&o(this,Q,!0),r(this,T).setInterval(e,t)}clearInterval(e){r(this,T).clearInterval(e)}},T=new WeakMap,Q=new WeakMap,xe),se=new et;function tt(e){setTimeout(e,0)}var Z=typeof window>"u"||"Deno"in globalThis;function re(){}function Fe(e){return typeof e=="number"&&e>=0&&e!==1/0}function st(e,t){return Math.max(e+(t||0)-Date.now(),0)}function $(e,t){return typeof e=="function"?e(t):e}function R(e,t){return typeof e=="function"?e(t):e}function rt(e){return JSON.stringify(e,(t,s)=>le(s)?Object.keys(s).sort().reduce((i,n)=>(i[n]=s[n],i),{}):s)}var it=Object.prototype.hasOwnProperty;function ie(e,t){if(e===t)return e;const s=Me(e)&&Me(t);if(!s&&!(le(e)&&le(t)))return t;const n=(s?e:Object.keys(e)).length,c=s?t:Object.keys(t),h=c.length,a=s?new Array(h):{};let v=0;for(let p=0;p<h;p++){const g=s?p:c[p],f=e[g],S=t[g];if(f===S){a[g]=f,(s?p<n:it.call(e,g))&&v++;continue}if(f===null||S===null||typeof f!="object"||typeof S!="object"){a[g]=S;continue}const b=ie(f,S);a[g]=b,b===f&&v++}return n===h&&v===n?e:a}function ne(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Me(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function le(e){if(!_e(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!_e(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function _e(e){return Object.prototype.toString.call(e)==="[object Object]"}function Pe(e,t,s){if(typeof s.structuralSharing=="function")return s.structuralSharing(e,t);if(s.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return ie(e,t)}catch(i){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${i}`),i}return ie(e,t)}return t}function nt(e){return e}function Se(e,t){return typeof e=="function"?e(...t):!!e}var x,M,A,De,ot=(De=class extends oe{constructor(){super();d(this,x);d(this,M);d(this,A);o(this,A,t=>{if(!Z&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){r(this,M)||this.setEventListener(r(this,A))}onUnsubscribe(){var t;this.hasListeners()||((t=r(this,M))==null||t.call(this),o(this,M,void 0))}setEventListener(t){var s;o(this,A,t),(s=r(this,M))==null||s.call(this),o(this,M,t(i=>{typeof i=="boolean"?this.setFocused(i):this.onFocus()}))}setFocused(t){r(this,x)!==t&&(o(this,x,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){var t;return typeof r(this,x)=="boolean"?r(this,x):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},x=new WeakMap,M=new WeakMap,A=new WeakMap,De),at=new ot;function je(){let e,t;const s=new Promise((n,c)=>{e=n,t=c});s.status="pending",s.catch(()=>{});function i(n){Object.assign(s,n),delete s.resolve,delete s.reject}return s.resolve=n=>{i({status:"fulfilled",value:n}),e(n)},s.reject=n=>{i({status:"rejected",reason:n}),t(n)},s}var ut=tt;function ct(){let e=[],t=0,s=a=>{a()},i=a=>{a()},n=ut;const c=a=>{t?e.push(a):n(()=>{s(a)})},h=()=>{const a=e;e=[],a.length&&n(()=>{i(()=>{a.forEach(v=>{s(v)})})})};return{batch:a=>{let v;t++;try{v=a()}finally{t--,t||h()}return v},batchCalls:a=>(...v)=>{c(()=>{a(...v)})},schedule:c,setNotifyFunction:a=>{s=a},setBatchNotifyFunction:a=>{i=a},setScheduler:a=>{n=a}}}var Oe=ct(),B,_,q,Le,ht=(Le=class extends oe{constructor(){super();d(this,B,!0);d(this,_);d(this,q);o(this,q,t=>{if(!Z&&window.addEventListener){const s=()=>t(!0),i=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",i)}}})}onSubscribe(){r(this,_)||this.setEventListener(r(this,q))}onUnsubscribe(){var t;this.hasListeners()||((t=r(this,_))==null||t.call(this),o(this,_,void 0))}setEventListener(t){var s;o(this,q,t),(s=r(this,_))==null||s.call(this),o(this,_,t(this.setOnline.bind(this)))}setOnline(t){r(this,B)!==t&&(o(this,B,t),this.listeners.forEach(i=>{i(t)}))}isOnline(){return r(this,B)}},B=new WeakMap,_=new WeakMap,q=new WeakMap,Le),lt=new ht;function ft(e){return(e??"online")==="online"?lt.isOnline():!0}function dt(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ft(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}var E,u,G,m,D,z,F,P,X,V,H,L,U,j,J,l,W,fe,de,pe,be,ye,ve,ge,Ae,Ue,ke=(Ue=class extends oe{constructor(t,s){super();d(this,l);d(this,E);d(this,u);d(this,G);d(this,m);d(this,D);d(this,z);d(this,F);d(this,P);d(this,X);d(this,V);d(this,H);d(this,L);d(this,U);d(this,j);d(this,J,new Set);this.options=s,o(this,E,t),o(this,P,null),o(this,F,je()),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(r(this,u).addObserver(this),Ne(r(this,u),this.options)?y(this,l,W).call(this):this.updateResult(),y(this,l,be).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return me(r(this,u),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return me(r(this,u),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,y(this,l,ye).call(this),y(this,l,ve).call(this),r(this,u).removeObserver(this)}setOptions(t){const s=this.options,i=r(this,u);if(this.options=r(this,E).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof R(this.options.enabled,r(this,u))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");y(this,l,ge).call(this),r(this,u).setOptions(this.options),s._defaulted&&!ne(this.options,s)&&r(this,E).getQueryCache().notify({type:"observerOptionsUpdated",query:r(this,u),observer:this});const n=this.hasListeners();n&&Qe(r(this,u),i,this.options,s)&&y(this,l,W).call(this),this.updateResult(),n&&(r(this,u)!==i||R(this.options.enabled,r(this,u))!==R(s.enabled,r(this,u))||$(this.options.staleTime,r(this,u))!==$(s.staleTime,r(this,u)))&&y(this,l,fe).call(this);const c=y(this,l,de).call(this);n&&(r(this,u)!==i||R(this.options.enabled,r(this,u))!==R(s.enabled,r(this,u))||c!==r(this,j))&&y(this,l,pe).call(this,c)}getOptimisticResult(t){const s=r(this,E).getQueryCache().build(r(this,E),t),i=this.createResult(s,t);return bt(this,i)&&(o(this,m,i),o(this,z,this.options),o(this,D,r(this,u).state)),i}getCurrentResult(){return r(this,m)}trackResult(t,s){return new Proxy(t,{get:(i,n)=>(this.trackProp(n),s==null||s(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&r(this,F).status==="pending"&&r(this,F).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(i,n))})}trackProp(t){r(this,J).add(t)}getCurrentQuery(){return r(this,u)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=r(this,E).defaultQueryOptions(t),i=r(this,E).getQueryCache().build(r(this,E),s);return i.fetch().then(()=>this.createResult(i,s))}fetch(t){return y(this,l,W).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),r(this,m)))}createResult(t,s){var Ie;const i=r(this,u),n=this.options,c=r(this,m),h=r(this,D),a=r(this,z),p=t!==i?t.state:r(this,G),{state:g}=t;let f={...g},S=!1,b;if(s._optimisticResults){const w=this.hasListeners(),ee=!w&&Ne(t,s),k=w&&Qe(t,i,s,n);(ee||k)&&(f={...f,...dt(g.data,t.options)}),s._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:N,errorUpdatedAt:K,status:O}=f;b=f.data;let Y=!1;if(s.placeholderData!==void 0&&b===void 0&&O==="pending"){let w;c!=null&&c.isPlaceholderData&&s.placeholderData===(a==null?void 0:a.placeholderData)?(w=c.data,Y=!0):w=typeof s.placeholderData=="function"?s.placeholderData((Ie=r(this,H))==null?void 0:Ie.state.data,r(this,H)):s.placeholderData,w!==void 0&&(O="success",b=Pe(c==null?void 0:c.data,w,s),S=!0)}if(s.select&&b!==void 0&&!Y)if(c&&b===(h==null?void 0:h.data)&&s.select===r(this,X))b=r(this,V);else try{o(this,X,s.select),b=s.select(b),b=Pe(c==null?void 0:c.data,b,s),o(this,V,b),o(this,P,null)}catch(w){o(this,P,w)}r(this,P)&&(N=r(this,P),b=r(this,V),K=Date.now(),O="error");const ae=f.fetchStatus==="fetching",ue=O==="pending",ce=O==="error",Re=ue&&ae,Ce=b!==void 0,I={status:O,fetchStatus:f.fetchStatus,isPending:ue,isSuccess:O==="success",isError:ce,isInitialLoading:Re,isLoading:Re,data:b,dataUpdatedAt:f.dataUpdatedAt,error:N,errorUpdatedAt:K,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>p.dataUpdateCount||f.errorUpdateCount>p.errorUpdateCount,isFetching:ae,isRefetching:ae&&!ue,isLoadingError:ce&&!Ce,isPaused:f.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:ce&&Ce,isStale:we(t,s),refetch:this.refetch,promise:r(this,F),isEnabled:R(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const w=te=>{I.status==="error"?te.reject(I.error):I.data!==void 0&&te.resolve(I.data)},ee=()=>{const te=o(this,F,I.promise=je());w(te)},k=r(this,F);switch(k.status){case"pending":t.queryHash===i.queryHash&&w(k);break;case"fulfilled":(I.status==="error"||I.data!==k.value)&&ee();break;case"rejected":(I.status!=="error"||I.error!==k.reason)&&ee();break}}return I}updateResult(){const t=r(this,m),s=this.createResult(r(this,u),this.options);if(o(this,D,r(this,u).state),o(this,z,this.options),r(this,D).data!==void 0&&o(this,H,r(this,u)),ne(s,t))return;o(this,m,s);const i=()=>{if(!t)return!0;const{notifyOnChangeProps:n}=this.options,c=typeof n=="function"?n():n;if(c==="all"||!c&&!r(this,J).size)return!0;const h=new Set(c??r(this,J));return this.options.throwOnError&&h.add("error"),Object.keys(r(this,m)).some(a=>{const v=a;return r(this,m)[v]!==t[v]&&h.has(v)})};y(this,l,Ae).call(this,{listeners:i()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&y(this,l,be).call(this)}},E=new WeakMap,u=new WeakMap,G=new WeakMap,m=new WeakMap,D=new WeakMap,z=new WeakMap,F=new WeakMap,P=new WeakMap,X=new WeakMap,V=new WeakMap,H=new WeakMap,L=new WeakMap,U=new WeakMap,j=new WeakMap,J=new WeakMap,l=new WeakSet,W=function(t){y(this,l,ge).call(this);let s=r(this,u).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(re)),s},fe=function(){y(this,l,ye).call(this);const t=$(this.options.staleTime,r(this,u));if(Z||r(this,m).isStale||!Fe(t))return;const i=st(r(this,m).dataUpdatedAt,t)+1;o(this,L,se.setTimeout(()=>{r(this,m).isStale||this.updateResult()},i))},de=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(r(this,u)):this.options.refetchInterval)??!1},pe=function(t){y(this,l,ve).call(this),o(this,j,t),!(Z||R(this.options.enabled,r(this,u))===!1||!Fe(r(this,j))||r(this,j)===0)&&o(this,U,se.setInterval(()=>{(this.options.refetchIntervalInBackground||at.isFocused())&&y(this,l,W).call(this)},r(this,j)))},be=function(){y(this,l,fe).call(this),y(this,l,pe).call(this,y(this,l,de).call(this))},ye=function(){r(this,L)&&(se.clearTimeout(r(this,L)),o(this,L,void 0))},ve=function(){r(this,U)&&(se.clearInterval(r(this,U)),o(this,U,void 0))},ge=function(){const t=r(this,E).getQueryCache().build(r(this,E),this.options);if(t===r(this,u))return;const s=r(this,u);o(this,u,t),o(this,G,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Ae=function(t){Oe.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(r(this,m))}),r(this,E).getQueryCache().notify({query:r(this,u),type:"observerResultsUpdated"})})},Ue);function pt(e,t){return R(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ne(e,t){return pt(e,t)||e.state.data!==void 0&&me(e,t,t.refetchOnMount)}function me(e,t,s){if(R(t.enabled,e)!==!1&&$(t.staleTime,e)!=="static"){const i=typeof s=="function"?s(e):s;return i==="always"||i!==!1&&we(e,t)}return!1}function Qe(e,t,s,i){return(e!==t||R(i.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&we(e,s)}function we(e,t){return R(t.enabled,e)!==!1&&e.isStaleByTime($(t.staleTime,e))}function bt(e,t){return!ne(e.getCurrentResult(),t)}var yt=C.createContext(void 0),Be=e=>{const t=C.useContext(yt);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},qe=C.createContext(!1),ze=()=>C.useContext(qe);qe.Provider;function vt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var gt=C.createContext(vt()),Ve=()=>C.useContext(gt),He=(e,t,s)=>{const i=s!=null&&s.state.error&&typeof e.throwOnError=="function"?Se(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||i)&&(t.isReset()||(e.retryOnMount=!1))},Je=e=>{C.useEffect(()=>{e.clearReset()},[e])},Ke=({result:e,errorResetBoundary:t,throwOnError:s,query:i,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&i&&(n&&e.data===void 0||Se(s,[e.error,i])),We=e=>{if(e.suspense){const s=n=>n==="static"?n:Math.max(n??1e3,1e3),i=e.staleTime;e.staleTime=typeof i=="function"?(...n)=>s(i(...n)):s(i),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},$e=(e,t)=>e.isLoading&&e.isFetching&&!t,Ze=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ee=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function mt(e,t,s){var S,b,N,K;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const i=ze(),n=Ve(),c=Be(),h=c.defaultQueryOptions(e);(b=(S=c.getDefaultOptions().queries)==null?void 0:S._experimental_beforeQuery)==null||b.call(S,h);const a=c.getQueryCache().get(h.queryHash);process.env.NODE_ENV!=="production"&&(h.queryFn||console.error(`[${h.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),h._optimisticResults=i?"isRestoring":"optimistic",We(h),He(h,n,a),Je(n);const v=!c.getQueryCache().get(h.queryHash),[p]=C.useState(()=>new t(c,h)),g=p.getOptimisticResult(h),f=!i&&e.subscribed!==!1;if(C.useSyncExternalStore(C.useCallback(O=>{const Y=f?p.subscribe(Oe.batchCalls(O)):re;return p.updateResult(),Y},[p,f]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),C.useEffect(()=>{p.setOptions(h)},[h,p]),Ze(h,g))throw Ee(h,p,n);if(Ke({result:g,errorResetBoundary:n,throwOnError:h.throwOnError,query:a,suspense:h.suspense}))throw g.error;if((K=(N=c.getDefaultOptions().queries)==null?void 0:N._experimental_afterQuery)==null||K.call(N,h,g),h.experimental_prefetchInRender&&!Z&&$e(g,i)){const O=v?Ee(h,p,n):a==null?void 0:a.promise;O==null||O.catch(re).finally(()=>{p.updateResult()})}return h.notifyOnChangeProps?g:p.trackResult(g)}function Et(e,t){return mt(e,ke)}exports.QueryObserver=ke;exports.Subscribable=oe;exports.ensurePreventErrorBoundaryRetry=He;exports.ensureSuspenseTimers=We;exports.fetchOptimistic=Ee;exports.getHasError=Ke;exports.hashKey=rt;exports.keepPreviousData=nt;exports.noop=re;exports.notifyManager=Oe;exports.replaceEqualDeep=ie;exports.shallowEqualObjects=ne;exports.shouldSuspend=Ze;exports.shouldThrowError=Se;exports.useClearResetErrorBoundary=Je;exports.useIsRestoring=ze;exports.useQuery=Et;exports.useQueryClient=Be;exports.useQueryErrorResetBoundary=Ve;exports.willFetch=$e;
|