1 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4681607c-1c81-5c4d-9622-2fb0bf57da00")}catch(e){}}(); 3(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`e5562179835c32ffe550d671740078b14d817c08`}}catch{}})();import{h as e,nt as t,st as n,t as r}from"./jsx-runtime-C84qV8ig.js";import{o as i}from"./lib-D3vx63RG.js";import{t as a}from"./compiler-runtime-8pZOvhkd.js";import{t as o}from"./clsx-DAvcGpWD.js";import{n as s}from"./elements-Cua40kWP.js";import{s as c}from"./UserContext-DmiukG3Y.js";import{p as l}from"./lazyWithBoundary-BdZwBmhO.js";import{t as u}from"./useAIUsageState-DN0U5KhI.js";import{t as d}from"./bolt-mini-DmnJZhAI.js";var f=n(t(),1),p=a(),m=l([{credits:250,description:`Great for a few more edits`,id:`250`,isFeatured:!1,lookupKey:`ai-credits-250`,price:`$12`},{credits:1e3,description:`Best for active weekly editing`,id:`1000`,isFeatured:!0,lookupKey:`ai-credits-1000`,price:`$39`},{credits:2500,description:`For bigger launches`,id:`2500`,isFeatured:!1,lookupKey:`ai-credits-2500`,price:`$79`}]);Object.fromEntries(m.map(e=>[e.id,e]));var h=r(),g=`add-credits-popover`;function _(){let t=(0,p.c)(36),{pathname:n,search:r}=e(),[a,l]=i(),{activeOrganizationId:_}=c(),C;t[0]===_?C=t[1]:(C={organizationId:_},t[0]=_,t[1]=C);let{refreshUsage:w}=u(C),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(!1),[k,A]=(0,f.useState)(m.find(S)?.id??m[0].id),j;t[2]===k?j=t[3]:(j=m.find(e=>e.id===k)??m[0],t[2]=k,t[3]=j);let M=j,N,P;t[4]!==w||t[5]!==a||t[6]!==l?(N=()=>{a.get(`credits`)===`1`&&(async()=>{let e=a.get(`creditSessionId`);e!=null&&(await fetch(`/api/ai-credits/sync`,{body:JSON.stringify({checkoutSessionId:e}),headers:{"Content-Type":`application/json`},method:`POST`}).catch(x))?.ok===!1&&console.error(`Failed to sync Stripe AI credit purchase`),await w(),l(b,{replace:!0})})()},P=[w,a,l],t[4]=w,t[5]=a,t[6]=l,t[7]=N,t[8]=P):(N=t[7],P=t[8]),(0,f.useEffect)(N,P);let F;t[9]!==_||t[10]!==M||t[11]!==D||t[12]!==n||t[13]!==r?(F=async()=>{if(_==null||D)return;E(null),O(!0);let e=new URLSearchParams(r);e.set(`credits`,`1`);let t=`${n}?${e.toString()}`,i=await fetch(`/api/ai-credits/checkout`,{body:JSON.stringify({cancelPath:`${n}${r}`,organizationId:_,packId:M.id,successPath:t}),headers:{"Content-Type":`application/json`},method:`POST`}).catch(y);if(i==null){E(`Failed to start checkout.`),O(!1);return}let a=await i.json().catch(v);if(!i.ok||a?.url==null){E(a?.error??`Failed to start Stripe checkout for credits.`),O(!1);return}window.location.assign(a.url)},t[9]=_,t[10]=M,t[11]=D,t[12]=n,t[13]=r,t[14]=F):F=t[14];let I=F,L;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={opacity:0,rotate:0,scale:0},t[15]=L):L=t[15];let R;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(R={duration:.4,scale:{bounce:.5,type:`spring`,visualDuration:.4}},t[16]=R):R=t[16];let z;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,h.jsx)(s,{"aria-label":`Close add credits dialog`,className:`close-x`,initial:L,popoverTarget:g,popoverTargetAction:`hide`,transition:R,type:`button`,whileHover:{scale:1.1},whileInView:{opacity:1,rotate:45,scale:1},whileTap:{scale:.6}}),t[17]=z):z=t[17];let B=_==null||D,V;t[18]===I?V=t[19]:(V=()=>{I()},t[18]=I,t[19]=V);let H=D?`Redirectingâ¦`:`Continue - ${M.credits} Credits for ${M.price}`,U;t[20]!==H||t[21]!==B||t[22]!==V?(U=(0,h.jsx)(`button`,{className:`btn-primary add-credits-popover__featured-button`,disabled:B,onClick:V,type:`button`,children:H}),t[20]=H,t[21]=B,t[22]=V,t[23]=U):U=t[23];let W;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,h.jsx)(`div`,{className:`add-credits-popover__divider`}),t[24]=W):W=t[24];let G;t[25]===M?G=t[26]:(G=m.map(e=>{let t=e.id===M.id;return(0,h.jsxs)(`button`,{"aria-label":`${e.credits} credits for ${e.price}. ${e.description}.`,className:o(`add-credits-package`,{"is-featured":t}),onClick:()=>{A(e.id)},type:`button`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`add-credits-package__icon`,children:(0,h.jsx)(d,{})}),(0,h.jsxs)(`span`,{className:`add-credits-package__credits`,children:[e.credits,` Credits`]}),(0,h.jsx)(`span`,{className:`add-credits-package__price`,children:e.price})]},e.id)}),t[25]=M,t[26]=G);let K;t[27]===G?K=t[28]:(K=(0,h.jsx)(`div`,{className:`add-credits-popover__packages`,children:G}),t[27]=G,t[28]=K);let q;t[29]===T?q=t[30]:(q=T?(0,h.jsx)(`div`,{className:`footnote-wrap`,children:(0,h.jsx)(`p`,{className:`add-credits-popover__footnote`,children:T})}):null,t[29]=T,t[30]=q);let J;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,h.jsx)(`div`,{className:`footnote-wrap`,children:(0,h.jsx)(`p`,{className:`add-credits-popover__footnote`,children:`One-time top-up. Monthly credits still reset as usual.`})}),t[31]=J):J=t[31];let Y;return t[32]!==U||t[33]!==K||t[34]!==q?(Y=(0,h.jsxs)(`div`,{className:`popover-modal add-credits-modal dark-ui`,id:g,popover:`auto`,children:[z,(0,h.jsxs)(`div`,{className:`add-credits-popover`,children:[U,W,K,q,J]})]}),t[32]=U,t[33]=K,t[34]=q,t[35]=Y):Y=t[35],Y}function v(){return null}function y(){return null}function b(e){return e.delete(`credits`),e.delete(`creditSessionId`),e}function x(){return null}function S(e){return e.isFeatured===!0}export{_ as n,g as t}; 4//# debugId=4681607c-1c81-5c4d-9622-2fb0bf57da00
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.