{"version":3,"file":"V4PackageData.CSYsqEn2.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/6PfHJkSxDNsVzov6WagY/ObY2tYgktOoBACCRmMxg/V4PackageData.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";const url=\"https://www.runescape.com/api/v1/members-benefits?storeId=rs:membership\";const jsonRequest=fetch(url).then(response=>response.arrayBuffer()).then(raw=>new TextDecoder(\"iso-8859-1\").decode(raw)).then(decoded=>JSON.parse(decoded)).then(json=>json.packages.reduce((acc,{packageGroup,price=\"...\",savingPrice=\"...\",subscriptionQuantityPrice=\"...\"})=>{acc[packageGroup]={price,savingPrice,subscriptionQuantityPrice};return acc;},{}));const defaultValuess={price:\"...\",savingPrice:\"...\",subscriptionQuantityPrice:\"...\"};const defaultPackageGroups={rs1m:{...defaultValuess},rs6m:{...defaultValuess},rs12m:{...defaultValuess}};/**\n * Retrieve a key from the JSON, using state to avoid extra network calls.\n */function useApi(packageGroup,property){const[packageGroups,setPackageGroups]=useState(defaultPackageGroups);useEffect(()=>void jsonRequest.then(setPackageGroups),[]);return packageGroups[packageGroup][property];}export function withRs1mPrice(Component){return function(props){const apiData=useApi(\"rs1m\",\"price\");return /*#__PURE__*/_jsx(Component,{...props,text:apiData});};}export function withRs1mSavingPrice(Component){return function(props){const apiData=useApi(\"rs1m\",\"savingPrice\");return /*#__PURE__*/_jsx(Component,{...props,text:apiData});};}export function withRs1mSubscriptionQuantityPrice(Component){return function(props){const apiData=useApi(\"rs1m\",\"subscriptionQuantityPrice\");return /*#__PURE__*/_jsx(Component,{...props,text:apiData});};}export function withRs6mPrice(Component){return function(props){const apiData=useApi(\"rs6m\",\"price\");return /*#__PURE__*/_jsx(Component,{...props,text:apiData});};}export function withRs6mSavingPrice(Component){return function(props){const apiData=useApi(\"rs6m\",\"savingPrice\");return /*#__PURE__*/_jsx(Component,{...props,text:apiData});};}export function withRs6mSubscriptionQuantityPrice(Component){return function(props){const apiData=useApi(\"rs6m\",\"subscriptionQuantityPrice\");return /*#__PURE__*/_jsx(Component,{...props,text:apiData});};}export function withRs12mPrice(Component){return function(props){const apiData=useApi(\"rs12m\",\"price\");return /*#__PURE__*/_jsx(Component,{...props,text:apiData});};}export function withRs12mSavingPrice(Component){return function(props){const apiData=useApi(\"rs12m\",\"savingPrice\");return /*#__PURE__*/_jsx(Component,{...props,text:apiData});};}export function withRs12mSubscriptionQuantityPrice(Component){return function(props){const apiData=useApi(\"rs12m\",\"subscriptionQuantityPrice\");return /*#__PURE__*/_jsx(Component,{...props,text:apiData});};}// These versions set the price, subscriptionPrice, and subscriptionQuantityPrice properites on a component\nfunction useApiAllProperties(packageGroup){const[packageGroups,setPackageGroups]=useState(defaultPackageGroups);useEffect(()=>void jsonRequest.then(setPackageGroups),[]);return packageGroups[packageGroup];}export function withRs12mAllProperties(Component){return function(props){const apiData=useApiAllProperties(\"rs12m\");return /*#__PURE__*/_jsx(Component,{...props,price:apiData[\"price\"],subscriptionQuantityPrice:apiData[\"subscriptionQuantityPrice\"],savingPrice:apiData[\"savingPrice\"]});};}export function withRs6mSAllProperties(Component){return function(props){const apiData=useApiAllProperties(\"rs6m\");return /*#__PURE__*/_jsx(Component,{...props,price:apiData[\"price\"],subscriptionQuantityPrice:apiData[\"subscriptionQuantityPrice\"],savingPrice:apiData[\"savingPrice\"]});};}export function withRs1mAllProperties(Component){return function(props){const apiData=useApiAllProperties(\"rs1m\");return /*#__PURE__*/_jsx(Component,{...props,price:apiData[\"price\"],subscriptionQuantityPrice:apiData[\"subscriptionQuantityPrice\"],savingPrice:apiData[\"savingPrice\"]});};}export function withRs12mSavingPercentage(Component){return function(props){const apiData=useApiAllProperties(\"rs12m\");const price1m=useApi(\"rs1m\",\"price\");const num1m=parseFloat(price1m.replace(/[^0-9.]/g,\"\"));const num12m=parseFloat(apiData.subscriptionQuantityPrice.replace(/[^0-9.]/g,\"\"));const saving=(num1m-num12m)/num1m*100;return /*#__PURE__*/_jsx(Component,{...props,price:apiData[\"price\"],subscriptionQuantityPrice:apiData[\"subscriptionQuantityPrice\"],savingPrice:`${Math.round(saving)}%`});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withRs1mAllProperties\":{\"type\":\"reactHoc\",\"name\":\"withRs1mAllProperties\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs12mSavingPercentage\":{\"type\":\"reactHoc\",\"name\":\"withRs12mSavingPercentage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs6mSavingPrice\":{\"type\":\"reactHoc\",\"name\":\"withRs6mSavingPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs12mSubscriptionQuantityPrice\":{\"type\":\"reactHoc\",\"name\":\"withRs12mSubscriptionQuantityPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs6mPrice\":{\"type\":\"reactHoc\",\"name\":\"withRs6mPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs1mPrice\":{\"type\":\"reactHoc\",\"name\":\"withRs1mPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs6mSAllProperties\":{\"type\":\"reactHoc\",\"name\":\"withRs6mSAllProperties\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs12mAllProperties\":{\"type\":\"reactHoc\",\"name\":\"withRs12mAllProperties\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs1mSubscriptionQuantityPrice\":{\"type\":\"reactHoc\",\"name\":\"withRs1mSubscriptionQuantityPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs1mSavingPrice\":{\"type\":\"reactHoc\",\"name\":\"withRs1mSavingPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs12mPrice\":{\"type\":\"reactHoc\",\"name\":\"withRs12mPrice\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRs6mSubscriptionQuantityPrice\":{\"type\":\"reactHoc\",\"name\":\"withRs6mSubscriptionQuantityPrice\",\"annotations\":{\"framerContractVersion\":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