"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),system=require("@gem-sdk/system"),styles=require("../common/styles.js"),classes=require("../common/classes.js"),helpers=require("../common/helpers.js"),core=require("@gem-sdk/core"),PostPurchaseCheckbox=require("./PostPurchaseCheckbox.js"),useBuyerConsentChecked=require("../hooks/useBuyerConsentChecked.js");const COMPONENT_ID_PREFIX="buyer-consent-product",BuyerConsent=({styles:e,builderProps:s,setting:t,builderAttrs:r,style:l,children:c})=>{let{isEditMode:n}=core.useRenderMode(),o=core.useProduct(),{checked:a,setChecked:i}=useBuyerConsentChecked.useBuyerConsentChecked(),u=core.usePageStore(e=>e.subscriptionVisible),{description:y,policyLabel:d,policyLink:m,align:h}=t??{},C=o?.id?`buyer-consent-product-${s?.uid}-${o.id}`:void 0,x=helpers.getComponentTag(m),j=system.createStyle(styles.getWrapperStyles({styles:e})),k=system.createClass(classes.getWrapperClassName({align:h,uid:s?.uid})),p=system.createStyle(styles.getContainerStyles({styles:e})),g=system.createClass(classes.getCheckboxContainerClassName()),b=system.createStyle(styles.getTextStyle({styles:e})),P=system.createClass(classes.getLinkComponentClassName()),R=system.createStyle(classes.getLinkComponentStyles()),S=e=>{i(e.target.checked)},q=!n&&!u?.[o?.id??""]?.length;return q?null:jsxRuntime.jsxs("div",{...r,style:{...l},children:[jsxRuntime.jsx("div",{"data-id":s?.uid,style:j,className:k,children:jsxRuntime.jsxs("label",{htmlFor:C,dir:e?.direction??"ltr",style:p,className:g,children:[jsxRuntime.jsx(PostPurchaseCheckbox.default,{id:C,name:C,type:"checkbox",checked:a,onChange:S}),jsxRuntime.jsxs("bdo",{dir:e?.direction??"ltr",style:b,children:[y," ",jsxRuntime.jsx(x,{target:"_blank",rel:"noreferrer",href:m,className:P,style:R,children:d})]})]})}),core.filterToolbarPreview(c,!0)]})};exports.default=BuyerConsent;
