{"version":3,"file":"ThentyOrderButton.DdtFPnlK.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,IAAI,EAAO,CAAC,gBAAc,YAAU,EAAU,EAAO,CAAC,EAAU,GAAcC,EAAS,EAAK,EAAQ,MAAY,CAAoB,GAAnB,EAAa,EAAI,EAAK,CAAC,EAAc,CAAC,GAAG,GAAU,sBAAsB,CAAC,EAAO,SAAS,KAAK,IAAI,GAAU,sBAAsB,UAAU,IAAY,MAAO,MAAM,QAAQ,MAAM,wDAAwD,EAAG,MAAO,CAAC,IAAI,EAAO,GAAM,GAAQ,WAAW,WAAU,EAAO,+BAA+B,EAAO,UAAU,YAAY,EAAW,aAAa,mBAAmB,IAAY,IAAS,MAAM,KAAK,GAAe,eAAe,GAAG,CAAC,CAAC,KAAK,GAAc,CAAC,EAAa,EAAK,EAAE,EAAO,KAAK,EAAa,aAAa,EAAO,SAAS,OAAO,CAAE,CAAC,CAAC,CAAC,MAAM,GAAK,CAAC,EAAa,EAAK,EAAK,EAAI,eAAc,EAAO,SAAS,KAAK,EAAI,aAAc,CAAC,CAAE,EAAE,OAAoB,EAAK,EAAe,CAAK,MAAI,GAAG,EAAc,UAAQ,SAAS,CAAI,CAAC,CAAE,qBAL16B,IAAoD,IAAmC,IAAqK,IAAqE,EAK0mB,EAAkB,YAAY,sBAAsB,EAAoB,EAAkB,CAAC,KAAK,CAAC,KAAK,EAAY,OAAO,YAAY,cAAc,aAAa,WAAW,EAAE,UAAU,CAAC,KAAK,EAAY,OAAO,YAAY,oBAAoB,MAAM,YAAY,EAAE,OAAO,CAAC,KAAK,EAAY,QAAQ,aAAa,EAAK,EAK5wC,GAAG,EAA+B,CAAC,CAAC,CAAC,CAAC"}