import{s as e,f as g}from"./index-CyXUjyDM.js";import{c}from"./lucide-BsOfcLnq.js";function y(){const i=c(()=>e.currentUser);function a(n,r){return c(()=>{if(!e.currentUser?.preferences)return r;const s=e.currentUser.preferences[n];return s!==void 0?s:r})}async function u(n,r){if(!e.currentUser){console.warn("Cannot set preference: no user logged in");return}e.currentUser.preferences||(e.currentUser.preferences={});const s=JSON.parse(JSON.stringify(r)),t={...e.currentUser.preferences,[n]:s};e.currentUser.preferences=t;try{await g.updateUser(e.currentUser.user_id,{preferences:t})}catch(f){console.error("Failed to update user preferences:",f)}}function o(n,r){const s=`${n}.${r}`;return c(()=>e.currentUser?.preferences?e.currentUser.preferences[`itemsListing.${s}`]||{}:{})}async function p(n,r,s,t){const U=`itemsListing.${`${n}.${r}`}`,d={...o(n,r).value,[s]:t};await u(U,d)}return{currentUser:i,getPreference:a,setPreference:u,getItemsListingPreferences:o,setItemsListingPreference:p}}export{y as u};
