const redeemApps=[ {id:'chatgpt', name:'ChatGPT', plugin:'chatgpt'}, {id:'claude', name:'Claude', plugin:'claude'} ]; function redeemSkus(plugin){ const rows=(cache.skus||[]).filter(s=>s && (s.plugin||'')===plugin); if(rows.length) return rows; const fallback={ chatgpt:[ ['ChatGPT Go','oai.chatgpt.go'],['ChatGPT Plus','oai.chatgpt.plus'],['ChatGPT Pro','oai.chatgpt.pro'], ['ChatGPT Pro Lite','oai.chatgpt.prolite'],['ChatGPT Pro Max','oai.chatgpt.promax'] ], claude:[['Claude Pro','com.anthropic.claude.pro'],['Claude Max','com.anthropic.claude.max']] }; return (fallback[plugin]||[]).map(x=>({title:x[0], sku:x[1], plugin:plugin})); } function skuPeriods(sku){ const offers=(sku&&sku.offers)||[]; const found=[...new Set(offers.map(o=>String(o.billing_period||'').toUpperCase()).filter(v=>/^P\d+[MY]$/.test(v)))]; if(!found.length) return ['P1M']; return found.sort((a,b)=>a.endsWith('M')&&b.endsWith('Y')?-1:a.endsWith('Y')&&b.endsWith('M')?1:a.localeCompare(b)); } function viewRedeem(){ const state=window._redeem||{app:'chatgpt'}; window._redeem=state; const app=redeemApps.some(a=>a.id===state.app)?state.app:'chatgpt'; state.app=app; const skus=redeemSkus(app==='claude'?'claude':'chatgpt'); if(!skus.some(s=>s.sku===state.sku)) state.sku=skus[0]?skus[0].sku:''; const radios=skus.map(s=>'').join(''); const selected=skus.find(s=>s.sku===state.sku)||skus[0]||{}; const periods=skuPeriods(selected); if(!periods.includes(state.period)) state.period=periods.includes('P1M')?'P1M':periods[0]; const periodRadios=periods.map(p=>'').join(''); const fields=app==='claude' ? ''+ '
'+esc(state.out||'')+'