{"version":3,"file":"ThentyOrderButton.C2CKIPjJ.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/Wja1LZe8PzXN5E2W5XW6/zQUvEWyOHaqM5qa4QsWQ/ThentyOrderButton.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useRef,useState}from\"react\";import{StandardButton,standardButtonPropertyControls,useThenty}from\"https://framerusercontent.com/modules/diyk5889JEo4mM5y5sJr/k488EAt1FhWtVFD0n6vD/ThentyShared.js\";import{thentyAuth}from\"https://cdn.thenty.io/beta/thenty-sdk.min.js\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 300\n * @framerDisableUnlink\n */export default function ThentyOrderButton(props){const{text,productId,newTab}=props;const ref=useRef(null);const{authorization,siteMeta}=useThenty();const[isLoading,setIsLoading]=useState(false);const onClick=()=>{setIsLoading(true);if(!authorization){if(siteMeta?.sign_up_redirect_path){window.location.href=`/${siteMeta?.sign_up_redirect_path}?planID=${productId}`;return;}else{console.error(\"No login redirect patch configured in thenty dashboard\");}return;}let params=\"\";if(window?.Rewardful?.referral){params=`?rewardfulClientReferenceId=${window.Rewardful.referral}`;}thentyAuth.fetchGeneric(`/payments/order/${productId}${params}`,\"GET\",null,authorization?.authorization?.key).then(responseBody=>{setIsLoading(false);window.open(responseBody.redirect_url,newTab?\"_blank\":\"_self\");}).catch(err=>{setIsLoading(false);if(err.redirect_url){window.location.href=err.redirect_url;}});};return /*#__PURE__*/_jsx(StandardButton,{ref:ref,...props,onClick:onClick,children:text});}ThentyOrderButton.displayName=\"Thenty Order Button\";addPropertyControls(ThentyOrderButton,{text:{type:ControlType.String,placeholder:\"Button Text\",defaultValue:\"Subscribe\"},productId:{type:ControlType.String,placeholder:\"Thenty Product ID\",title:\"Product ID\"},newTab:{type:ControlType.Boolean,defaultValue:false},// discountCode: {\n//     type: ControlType.String,\n//     placeholder: \"Stripe Discount Code\",\n//     title: \"Discount\",\n// },\n...standardButtonPropertyControls({})});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ThentyOrderButton\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"300\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"kRAKG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,OAAK,YAAU,UAAQ,EAAY,EAAIA,EAAO,KAAK,CAAM,CAAC,gBAAc,YAAU,GAAW,CAAM,CAAC,EAAU,GAAcC,EAAS,GAAM,CAAO,MAAY,CAAoB,GAAnB,EAAa,GAAK,CAAI,CAAC,EAAc,CAAC,GAAG,GAAU,sBAAsB,CAAC,EAAO,SAAS,KAAK,IAAI,GAAU,sBAAsB,UAAU,IAAY,YAAa,QAAQ,MAAM,yDAAyD,CAAE,OAAQ,IAAI,EAAO,GAAM,GAAQ,WAAW,WAAU,EAAO,+BAA+B,EAAO,UAAU,YAAY,EAAW,aAAa,mBAAmB,IAAY,IAAS,MAAM,KAAK,GAAe,eAAe,IAAI,CAAC,KAAK,GAAc,CAAC,EAAa,GAAM,CAAC,EAAO,KAAK,EAAa,aAAa,EAAO,SAAS,QAAQ,EAAG,CAAC,MAAM,GAAK,CAAC,EAAa,GAAM,CAAI,EAAI,eAAc,EAAO,SAAS,KAAK,EAAI,eAAgB,EAAG,OAAoB,EAAK,EAAe,CAAK,MAAI,GAAG,EAAc,UAAQ,SAAS,EAAK,CAAC,sBALx6B,IAAoD,IAAmC,IAAqK,IAAqE,CAKymB,EAAkB,YAAY,sBAAsB,EAAoB,EAAkB,CAAC,KAAK,CAAC,KAAK,EAAY,OAAO,YAAY,cAAc,aAAa,YAAY,CAAC,UAAU,CAAC,KAAK,EAAY,OAAO,YAAY,oBAAoB,MAAM,aAAa,CAAC,OAAO,CAAC,KAAK,EAAY,QAAQ,aAAa,GAAM,CAK7wC,GAAG,EAA+B,EAAE,CAAC,CAAC,CAAC"}