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