import{r as R,b as P,j as i,a as f}from"./app-DC5MhnUn.js";import{B as v}from"./Button-0WBbxq06.js";function E({className:u="",only:r}){const[c,h]=R.useState(!1),{url:p}=P(),d=()=>{h(!0);const a=()=>{h(!1)};try{const s=p||window.location.pathname+window.location.search;let e=s;const o={};if(s&&s.includes("?")){const t=s.split("?");e=t[0],new URLSearchParams(t[1]).forEach((n,g)=>{o[g]=n})}else s?e=s:(e=window.location.pathname,new URLSearchParams(window.location.search).forEach((m,n)=>{o[n]=m}));const l={preserveState:!1,preserveScroll:!0,onSuccess:a,onError:a,onFinish:a},w=r&&Array.isArray(r)&&r.length>0?{...l,only:r}:l;f.get(e,o,w)}catch(s){console.error("Error refreshing:",s);const e={onFinish:a};r&&Array.isArray(r)&&r.length>0&&(e.only=r),f.reload(e)}};return i.jsxs(v,{variant:"ghost",size:"sm",onClick:d,isLoading:c,className:u,children:[!c&&i.jsx("svg",{className:"mr-2 h-4 w-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"})}),"Refresh"]})}export{E as R};
