{"version":3,"file":"ThentyOrderButton.DSYNqSWM.mjs","names":["useRef","useState","_jsx","__esmMin","init_ssg_sandbox_shims","window","_e","de","init_jsx_runtime","c","init_npm_react_18_3_1","init_framer_BWzg2IRg","addPropertyControls","ControlType","thentyAuth","init_ThentyShared","useThenty","init_thenty_sdk_min","standardButtonPropertyControls","StandardButton","ThentyOrderButton","props","text","productId","newTab","ref","authorization","siteMeta","isLoading","setIsLoading","onClick","params","responseBody","err","init_ThentyOrderButton"],"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":"A,mRAKG,SAAwBoB,EAAkBC,EAAM,CAAC,GAAK,CAACC,OAAKC,YAAUC,UAAQH,EAAYI,EAAIzB,EAAO,IAAI,EAAO,CAAC0B,gBAAcC,YAAUX,EAAU,EAAO,CAACY,EAAUC,GAAc5B,EAAS,EAAK,EAAQ6B,MAAY,CAAoB,GAAnBD,EAAa,EAAI,EAAK,CAACH,EAAc,CAAC,GAAGC,GAAU,sBAAsB,CAACtB,EAAO,SAAS,KAAK,IAAIsB,GAAU,sBAAsB,UAAUJ,IAAY,MAAO,CAAM,QAAQ,MAAM,wDAAwD,EAAG,MAAO,CAAC,IAAIQ,EAAO,GAAM1B,GAAQ,WAAW,WAAU0B,EAAO,+BAA+B1B,EAAO,UAAU,YAAYS,EAAW,aAAa,mBAAmBS,IAAYQ,IAAS,MAAM,KAAKL,GAAe,eAAe,GAAG,CAAC,CAAC,KAAKM,GAAc,CAACH,EAAa,EAAK,EAAExB,EAAO,KAAK2B,EAAa,aAAaR,EAAO,SAAS,OAAO,CAAE,CAAC,CAAC,CAAC,MAAMS,GAAK,CAACJ,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