"use strict";var core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),React=require("react"),index=require("../../../constants/index.js"),classes=require("../common/classes.js"),styles=require("../common/styles.js"),helpers=require("../../../../../helpers.js"),useSellingPlanChange=require("./useSellingPlanChange.js"),useSellingPlanOptions=require("./useSellingPlanOptions.js"),useSellingSubscription=require("./useSellingSubscription.js"),useSubscriptionVisibility=require("./useSubscriptionVisibility.js"),useDynamicProduct=require("../../../hooks/useDynamicProduct.js"),useCheckProductsSubscriptionExistence=require("./useCheckProductsSubscriptionExistence.js");const DEFAULT_DIRECTION="ltr",useProductSubscriptionContentData=({setting:e,styles:s,builderProps:i})=>{let t=core.useProduct(),{defaultValue:n,selectedSellingPlan:r,setSelectedSellingPlan:u}=useSellingSubscription.useSellingSubscription(e),l=useSellingPlanOptions.useSellingPlanOptions(e),{selectedValue:c,handleSellingPlanChange:o}=useSellingPlanChange.useSellingPlanChange({defaultValue:n,selectedSellingPlan:r,setSelectedSellingPlan:u,sellingPlanOptions:l}),a=React.useRef(null),p=React.useId(),S=useSubscriptionVisibility.useSubscriptionVisibility({setting:e}),d=system.createStyle(styles.getSubscriptionStyles(s)),b=system.createStyle(styles.getSubscriptionWrapperStyles(s?.align)),g=system.createClass(classes.getWrapperClasses()),y=system.createClass(classes.getContainerClasses()),P=`product-subscription-${helpers.extractProductID(t?.baseID??"")}`,m=helpers.extractProductID(t?.baseID??""),C=`subscription-type-selection-${p}`,h=e?.sellingType===index.SubscriptionEnum.ONE_TIME,E=e?.sellingType===index.SubscriptionEnum.SUBSCRIPTION,I=h?index.SubscriptionEnum.ONE_TIME:index.SubscriptionEnum.SUBSCRIPTION,{isDynamicProduct:x}=useDynamicProduct.useDynamicProduct(),{sellingTitleDirection:q,sellingTitleOneTimeDirection:D}=s??{},O=I===index.SubscriptionEnum.ONE_TIME?D??"ltr":q??"ltr";useCheckProductsSubscriptionExistence.useCheckProductsSubscriptionExistence({productId:t?.id,elementUid:i?.uid,isSubscription:E,hasNoSellingPlanOptions:S.hasNoSellingPlanOptions,isDynamicProduct:x});let T=e=>{S.shouldShowRadio&&S.selectedType!==e&&S.setSubscriptionSellingType(e)};return{componentRef:a,componentId:P,wrapperClasses:g,subscriptionWrapperStyles:b,visibility:S,productId:m,renderType:I,radioGroupName:C,direction:O,containerClasses:y,subscriptionStyles:d,selectedValue:c,sellingPlanOptions:l,handleSellingPlanChange:o,onSelectType:T,isDynamicProduct:x}};exports.useProductSubscriptionContentData=useProductSubscriptionContentData;
