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