"use strict";var React=require("react"),core=require("@gem-sdk/core"),index=require("../../../constants/index.js"),useSellingPlanOptions=require("./useSellingPlanOptions.js"),useSubscriptionSellingType=require("../../../hooks/useSubscriptionSellingType.js");const useSubscriptionVisibility=({setting:e})=>{let i=core.useProductStore(e=>e.setSubscriptionSellingType),{isOneTime:n,subscriptionSellingType:s}=useSubscriptionSellingType.useSubscriptionSellingType(),u=useSellingPlanOptions.useSellingPlanOptions(e),l=core.useProduct(),t=React.useMemo(()=>l?.requiresSellingPlan,[l?.requiresSellingPlan]),r=React.useMemo(()=>n?index.SubscriptionEnum.ONE_TIME:index.SubscriptionEnum.SUBSCRIPTION,[n]);React.useEffect(()=>{s||(e?.sellingType===index.SubscriptionEnum.ONE_TIME?i(index.SubscriptionEnum.ONE_TIME):i(e?.sellingType??index.SubscriptionEnum.SUBSCRIPTION))},[i,e?.sellingType,s]);let o=!t&&u&&u.length>0,S=e?.sellingType===index.SubscriptionEnum.SUBSCRIPTION&&(!u||0===u.length),c=e?.sellingType===index.SubscriptionEnum.ONE_TIME&&t,p=(!u||0===u.length)&&!t;return{selectedType:r,shouldShowRadio:o,isOneTimeHidden:c,requiresSellingPlan:t,isOnetimeOnly:p,hasNoSellingPlanOptions:S,setSubscriptionSellingType:i}};exports.useSubscriptionVisibility=useSubscriptionVisibility;
