import{useMemo as e,useEffect as l}from"react";import{useProductStore as i,useProduct as n}from"@gem-sdk/core";import{SubscriptionEnum as s}from"../../../constants/index.js";import{useSellingPlanOptions as r}from"./useSellingPlanOptions.js";import{useSubscriptionSellingType as t}from"../../../hooks/useSubscriptionSellingType.js";let o=({setting:o})=>{let p=i(e=>e.setSubscriptionSellingType),{isOneTime:g,subscriptionSellingType:S}=t(),T=r(o),m=n(),I=e(()=>m?.requiresSellingPlan,[m?.requiresSellingPlan]),u=e(()=>g?s.ONE_TIME:s.SUBSCRIPTION,[g]);l(()=>{S||(o?.sellingType===s.ONE_TIME?p(s.ONE_TIME):p(o?.sellingType??s.SUBSCRIPTION))},[p,o?.sellingType,S]);let y=!I&&T&&T.length>0,E=o?.sellingType===s.SUBSCRIPTION&&(!T||0===T.length),O=o?.sellingType===s.ONE_TIME&&I,N=(!T||0===T.length)&&!I;return{selectedType:u,shouldShowRadio:y,isOneTimeHidden:O,requiresSellingPlan:I,isOnetimeOnly:N,hasNoSellingPlanOptions:E,setSubscriptionSellingType:p}};export{o as useSubscriptionVisibility};
