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