'use client'; 'use strict';var reactQuery=require('@tanstack/react-query'),react=require('react'),c=require('deepmerge'),D=require('is-plain-obj'),ofetch=require('ofetch'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var c__default=/*#__PURE__*/_interopDefault(c);var D__default=/*#__PURE__*/_interopDefault(D);var h=new Set([408,409,425,429,500,502,503,504]);function m(e,t){if(e=e instanceof URL?decodeURI(e.toString()):e,!t)return e;for(let[r,n]of Object.entries(t))e=e.replaceAll(`{${r}}`,String(n));return e}function V(e,t,r){return e.slice(t,r)}function l(e){if(e instanceof ofetch.FetchError)return !!(e.status&&h.has(e.status))}function j(e,t){return l(t)===!1?!1:e<3}function i({queryKey:[e,t={}],signal:r,pageParam:n,meta:u},a=ofetch.ofetch){if(!e)throw new Error(`Query key is missing url: "${e}, ${t}"`);if(t&&typeof t!="object")throw new Error(`Query options is not an object: "${e}, ${t}"`);return e=m(e,t.path),typeof n=="number"&&(t={...t,query:{...t.query,page:n}}),a(e,{signal:r,retry:!1,...t,queryMeta:u})}function F({queryKey:e,...t},r=i){return async n=>await r({queryKey:[e[0],c__default.default(e[1]??{},n??{},{arrayMerge:(u,a)=>a,isMergeableObject:D__default.default})],...t})}function $(e){return (t,{mutationFn:r})=>r({path:{[e]:t}})}function v(e,{mutationFn:t}){return t(e)}function A(e,{mutationFn:t}){let r=new FormData;for(let n of Array.isArray(e)?e:[e])r.append(n.name,n);return t({body:r})}var Q=react.createContext({}),_=({children:e,...t})=>jsxRuntime.jsx(Q.Provider,{value:t,children:e}),o=e=>{let{queryFn:t,mutationFn:r,inherit:n}=react.useContext(Q),u=reactQuery.useQueryClient(e);return react.useMemo(()=>{let a=u?.getDefaultOptions();return {queryFn:n&&a?.queries?.queryFn||t||i,mutationFn:n&&a?.mutations?.mutationFn||r||F}},[n,r,u,t])};function ne(e,t){let{queryFn:r}=o(t),n=react.useMemo(()=>({queryFn:r,...e}),[e,r]);return reactQuery.useQuery(n,t)}function Fe(e,t){let{mutationFn:r,queryFn:n}=o(t),u=react.useMemo(()=>{let[a,y={}]=e.mutationKey;y.method??="POST";let T=r({queryKey:[a,y],meta:e.meta},n);return {...e,mutationFn:s=>e.mutationFn?e.mutationFn(s,{mutationKey:[a,y],mutationFn:T,queryFn:n}):T({body:s}),mutationKey:[a,y]}},[r,e,n]);return reactQuery.useMutation(u,t)}function Ee(e,t){let{queryFn:r}=o(t),n=react.useMemo(()=>({queryFn:r,...e}),[e,r]);return reactQuery.useInfiniteQuery(n,t)}function Pe(e){return e}exports.FetchQueryProvider=_;exports.fetchMutateFilesFn=A;exports.fetchMutateFn=F;exports.fetchMutateOptionsFn=v;exports.fetchMutatePathFn=$;exports.fetchQueryFn=i;exports.fetchQueryOptions=Pe;exports.fetchRetryFn=j;exports.shouldRetryFetch=l;exports.sliceKey=V;exports.useFetchInfiniteQuery=Ee;exports.useFetchMutation=Fe;exports.useFetchQuery=ne;exports.useFetchQueryDefaults=o;