1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[75632],{21299:function(e,t,a){a.d(t,{h:function(){return h}});var s=a(20715),r=a(89113),n=a(19639),i=a(17938),o=a(81514),l=a(83454),d=a(49084),c=a(13206),u=a(5526),m=a(75072),f=a(7929),p=a(59593);let x=(0,f.J)("pk_live_51LyBrMGwFIvxsGdBkNZMN4SA8Dri7C688YLMyAdkqa6M0RmUtemznZ8iaAZsRI7u2Ob3QvGtwyiWPgMeNS9nr5RA00YedTQMD6"),h=[{amount:5,credits:250,popular:!1},{amount:10,credits:500,popular:!0},{amount:25,credits:1250,popular:!1}],g=({defaultAmount:e=null,suggestedCredits:t=0,requiredCredits:a=0,compact:f=!1})=>{let{t:g}=(0,n.Z)("common"),[b,y]=(0,r.useState)(()=>(function(e,t){if(e&&h.some(t=>t.amount===e))return e;if(t>0){let e=h.find(e=>e.credits>=t);return(e||h[h.length-1]).amount}let a=h.find(e=>e.popular);return(a||h[0]).amount})(e,t)),[j,N]=(0,r.useState)(""),[v,w]=(0,r.useState)(!1),[k,S]=(0,r.useState)(!1);(0,r.useEffect)(()=>{e&&h.some(t=>t.amount===e)&&(y(e),S(!1),N(""))},[e]);let C=k?parseFloat(j)||0:b||0,$=(0,r.useMemo)(()=>C>0?Math.floor(50*C):0,[C]),Z=(0,r.useMemo)(()=>a&&!(a<=0)&&$?Math.floor($/a):0,[$,a]),I=e=>{y(e),S(!1),N("")},M=e=>{N(e.target.value),y(null)},R=e=>!e||e<=0?g("credits.validation.required"):e<1?g("credits.validation.minimum"):e>500?g("credits.validation.maximum"):null,_=async()=>{let e=k?parseFloat(j):b,t=R(e);if(t){m.Am.error(t);return}(0,p.j)("checkout_start",{type:"credits",amount:e,credits:Math.floor(50*e)}),w(!0);try{let t=await fetch("/api/credits/purchase",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:e})}),a=await t.json();if(!t.ok)throw Error(a.message||"Failed to create purchase session");let s=a.data?.url;if("string"==typeof s&&s.startsWith("https://checkout.stripe.com/")){window.location.assign(s);return}let r=await x;if(!r)throw Error("Stripe failed to load.");let{error:n}=await r.redirectToCheckout({sessionId:a.data.sessionId});if(n)throw Error(n.message)}catch(e){console.error("Purchase error:",e),m.Am.error(e.message||g("credits.error"))}finally{w(!1)}};return(0,s.jsxs)("div",{className:f?"space-y-4":"space-y-6",children:[!f&&(0,s.jsx)("div",{className:"bg-blue-50 p-3 rounded-lg",children:(0,s.jsxs)("p",{className:"text-sm text-blue-700",children:[g("credits.exchangeRate"),": ",g("credits.rateDisplay",{rate:50})]})}),(0,s.jsxs)("div",{className:f?"space-y-3":"space-y-4",children:[!f&&(0,s.jsx)(l._,{className:"text-base font-medium",children:g("credits.selectAmount")}),(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",role:"radiogroup","aria-label":g("credits.selectAmount"),children:h.map(e=>{let t=b===e.amount&&!k,r=a>0?Math.floor(e.credits/a):0;return(0,s.jsxs)("button",{type:"button",role:"radio","aria-checked":t,onClick:()=>I(e.amount),className:`relative p-3 rounded-lg border-2 transition-all ${t?"border-blue-500 bg-blue-50":"border-gray-200 bg-white hover:border-gray-300"}`,children:[e.popular&&(0,s.jsx)(d.C,{className:"absolute -top-2 -right-2 bg-green-500 text-white text-xs",children:g("pricing.popular",null,{default:"Popular"})}),(0,s.jsxs)("div",{className:"text-left",children:[(0,s.jsxs)("div",{className:"font-medium",children:["$",e.amount]}),(0,s.jsx)("div",{className:"text-sm text-gray-600",children:g("credits.creditsCountShort",{count:e.credits.toLocaleString()})}),r>0&&(0,s.jsx)("div",{className:"text-xs font-semibold text-emerald-600 mt-0.5",children:g("pricing.estimatedGenerationsShort",{count:r},{default:`â ${r} runs`})})]}),t&&(0,s.jsx)(c.Z,{className:"absolute top-2 right-2 h-4 w-4 text-blue-500"})]},e.amount)})}),(0,s.jsx)("button",{type:"button",onClick:()=>S(!k),className:`w-full p-3 rounded-lg border-2 transition-all ${k?"border-blue-500 bg-blue-50":"border-gray-200 bg-white hover:border-gray-300"}`,children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{children:g("credits.customAmount")}),k&&(0,s.jsx)(c.Z,{className:"h-4 w-4 text-blue-500"})]})}),k&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(l._,{htmlFor:"custom-amount",children:g("credits.amount")}),(0,s.jsx)(o.I,{id:"custom-amount",type:"number",min:"1",max:"500",step:"0.01",value:j,onChange:M,placeholder:g("credits.enterAmount")})]})]}),C>0&&(0,s.jsxs)("div",{className:`bg-gray-50 rounded-lg space-y-2 ${f?"p-3":"p-4"}`,children:[(0,s.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,s.jsxs)("span",{children:[g("credits.amount"),":"]}),(0,s.jsxs)("span",{children:["$",C.toFixed(2)]})]}),(0,s.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,s.jsxs)("span",{children:[g("credits.credits"),":"]}),(0,s.jsxs)("span",{className:"font-medium",children:[$.toLocaleStr
1ing(),Z>0&&(0,s.jsxs)("span",{className:"text-emerald-600 ml-1.5 font-normal",children:["(",g("pricing.estimatedGenerations",{count:Z},{default:`â ${Z} generations`}),")"]})]})]}),(0,s.jsx)("div",{className:"border-t pt-2",children:(0,s.jsxs)("div",{className:"flex justify-between font-medium",children:[(0,s.jsxs)("span",{children:[g("credits.total"),":"]}),(0,s.jsxs)("span",{children:["$",C.toFixed(2)]})]})})]}),(0,s.jsx)(i.z,{onClick:_,disabled:!C||C<=0||v,className:"w-full",size:f?"default":"lg",children:v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.Z,{className:"mr-2 h-4 w-4 animate-spin"}),g("credits.processing")]}):Z>0?g("pricing.purchaseWithRuns",{credits:$.toLocaleString(),runs:`â ${Z} ${1===Z?"generation":"generations"}`,defaultValue:`Purchase ${$.toLocaleString()} Credits (â ${Z} ${1===Z?"generation":"generations"})`}):g("credits.purchaseButton",{credits:$.toLocaleString()})})]})};t.Z=g},72449:function(e,t,a){a.d(t,{Z:function(){return p}});var s=a(20715),r=a(89113),n=a(22698),i=a(29026),o=a(19639),l=a(17938),d=a(15160),c=a(96449);let u=e=>fetch(e).then(e=>e.json()),m="resume-checkout-dismissed";function f(){try{return window.sessionStorage.getItem(m)}catch(e){return null}}function p({className:e=""}){let{status:t}=(0,n.useSession)(),{t:a}=(0,o.Z)("common"),[p,x]=(0,r.useState)(f),{data:h}=(0,i.ZP)("authenticated"===t?"/api/credits/pending-checkout":null,u,{revalidateOnFocus:!1}),g=h?.data;if(!g||g.purchaseId===p)return null;let b=()=>{try{window.sessionStorage.setItem(m,g.purchaseId)}catch(e){}x(g.purchaseId)};return(0,s.jsxs)("div",{className:`flex flex-wrap items-center gap-3 rounded-lg border border-amber-300 bg-amber-50 p-3 ${e}`,children:[(0,s.jsx)(d.Z,{className:"h-5 w-5 shrink-0 text-amber-600","aria-hidden":"true"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-amber-900",children:a("credits.resume.title",null,{default:"You have an unfinished credits purchase"})}),(0,s.jsx)("p",{className:"text-sm text-amber-800",children:a("credits.resume.description",{credits:g.credits.toLocaleString(),amount:g.amount},{default:`${g.credits} credits for $${g.amount} â your payment link is still active.`})})]}),(0,s.jsx)(l.z,{asChild:!0,size:"sm",className:"shrink-0 bg-amber-600 text-white hover:bg-amber-700",children:(0,s.jsx)("a",{href:g.url,children:a("credits.resume.cta",null,{default:"Resume payment"})})}),(0,s.jsx)("button",{type:"button",onClick:b,"aria-label":a("credits.resume.dismiss",null,{default:"Dismiss"}),className:"rounded p-1 text-amber-700 transition-colors hover:bg-amber-100",children:(0,s.jsx)(c.Z,{className:"h-4 w-4"})})]})}},49084:function(e,t,a){a.d(t,{C:function(){return o}});var s=a(20715);a(89113);var r=a(64831),n=a(6814);let i=(0,r.j)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function o({className:e,variant:t,...a}){return(0,s.jsx)("div",{className:(0,n.cn)(i({variant:t}),e),...a})}},76206:function(e,t,a){a.d(t,{$N:function(){return x},Be:function(){return h},Vq:function(){return l},cN:function(){return p},cZ:function(){return m},fK:function(){return f},hg:function(){return d}});var s=a(20715),r=a(89113),n=a(36918),i=a(96449),o=a(6814);let l=n.fC,d=n.xz,c=n.h_;n.x8;let u=r.forwardRef(({className:e,...t},a)=>(0,s.jsx)(n.aV,{ref:a,className:(0,o.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));u.displayName=n.aV.displayName;let m=r.forwardRef(({className:e,children:t,...a},r)=>(0,s.jsxs)(c,{children:[(0,s.jsx)(u,{}),(0,s.jsxs)(n.VY,{ref:r,className:(0,o.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rou
1nded-lg",e),...a,children:[t,(0,s.jsxs)(n.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,s.jsx)(i.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));m.displayName=n.VY.displayName;let f=({className:e,...t})=>(0,s.jsx)("div",{className:(0,o.cn)("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});f.displayName="DialogHeader";let p=({className:e,...t})=>(0,s.jsx)("div",{className:(0,o.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});p.displayName="DialogFooter";let x=r.forwardRef(({className:e,...t},a)=>(0,s.jsx)(n.Dx,{ref:a,className:(0,o.cn)("text-lg font-semibold leading-none tracking-tight",e),...t}));x.displayName=n.Dx.displayName;let h=r.forwardRef(({className:e,...t},a)=>(0,s.jsx)(n.dk,{ref:a,className:(0,o.cn)("text-sm text-muted-foreground",e),...t}));h.displayName=n.dk.displayName},81514:function(e,t,a){a.d(t,{I:function(){return i}});var s=a(20715),r=a(89113),n=a(6814);let i=r.forwardRef(({className:e,type:t,...a},r)=>(0,s.jsx)("input",{type:t,className:(0,n.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...a}));i.displayName="Input"},83454:function(e,t,a){a.d(t,{_:function(){return d}});var s=a(20715),r=a(89113),n=a(93892),i=a(64831),o=a(6814);let l=(0,i.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=r.forwardRef(({className:e,...t},a)=>(0,s.jsx)(n.f,{ref:a,className:(0,o.cn)(l(),e),...t}));d.displayName=n.f.displayName},59593:function(e,t,a){a.d(t,{j:function(){return r}});let s="/api/analytics/track";function r(e,t={}){try{"function"==typeof window.gtag&&window.gtag("event",e,t)}catch(e){}try{let a=JSON.stringify({event:e,properties:t,timestamp:new Date().toISOString(),url:window.location.pathname});if("function"==typeof navigator.sendBeacon){let e=new Blob([a],{type:"application/json"});navigator.sendBeacon(s,e)}else fetch(s,{method:"POST",body:a,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{})}catch(e){}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.