import{useMemo as e,useEffect as r}from"react";import{useProduct as t,useProductStore as o,usePageStore as n}from"@gem-sdk/core";import{extractProductID as s}from"../../../helpers.js";import{DEFAULT_BUYER_CONSENT_CHECKED_VALUE as m}from"../common/constants.js";let c=()=>{let c=t(),l=o(e=>e.uid),u=!!c?.requiresSellingPlan,i=n(e=>e.buyerConsentChecked),C=n(e=>e.setBuyerConsentChecked),d=n(e=>e.getBuyerConsentChecked),h=s(c?.baseID??""),k=i?.[h],p=e(()=>{let e=u?h:`${h}_${l}`;return e},[u,h,l]),y=i?.[p]??m,a=e=>{let r=d();C({...r,[p]:e})};return r(()=>{void 0!==k&&a(k)},[k]),r(()=>{0===Object.keys(i??{}).length&&a(m)},[i]),{checked:y,setChecked:a}};export{c as useBuyerConsentChecked};
