PageSourceSearch

https://www.thevoyage.ai/assets/contextual-usage-pack-BBnYBN58.js

js thevoyage.ai collected 2026-09-24 13:29:55 UTC 8,062 bytes, 1 lines download raw bytes

1import{a as e}from"./chunk-BEqpzyXh.js";import{n as t}from"./createLucideIcon-CEDU0v2w.js";import{t as n}from"./link-74wx8yzR.js";import{t as r}from"./jsx-runtime-DOlcsXOY.js";import{t as i}from"./useRouteContext-COlOpbq6.js";import{n as a}from"./QueryClientProvider-B6pbwhdK.js";import{t as o}from"./useMutation-BTQ4SbQ2.js";import{t as s}from"./useQuery-B8WmauR7.js";import{a as c,n as l}from"./analytics-Bu3-liUf.js";import{t as u}from"./axios-DxGdMZ80.js";import{t as d}from"./button-D1RyJpAF.js";import{_ as f,d as p,g as m,r as h,u as g}from"./use-subscription-status-BuJ4iNC-.js";function _(e,t,n){try{let r=`voyage.pack-event.${e}.${t}`;if(localStorage.getItem(r))return;localStorage.setItem(r,`1`),n()}catch{}}function v(e,t){t.filter(e=>e.status===`PAID`||e.status===`REFUNDED`).sort((e,t)=>(e.paidAt??e.createdAt).localeCompare(t.paidAt??t.createdAt)).forEach((t,n)=>{t.status===`PAID`&&(_(e,`paid.${t.id}`,()=>c(l.usagePackOrderConfirmed,{sku:t.sku,surface:`web`})),n>0&&_(e,`repeat.${t.id}`,()=>c(l.usagePackRepeatPurchase,{sku:t.sku,surface:`web`})))})}function y(e,t,n){let r=t===`usage_pack`||t===`report_included`?`assessment_3`:t===`purchased_reply`?`text_reply_30`:null;r&&_(e,`consumed.${r}`,()=>c(l.usagePackFirstConsumption,{sku:r,source:t,surface:n}))}function b(e,t,n){n&&t.some(e=>e.status===`PAID`)&&_(e,`subscription`,()=>c(l.usagePackSubscriptionConverted,{surface:`web`}))}var x=[`consumer`,`usage-packs`];function S(e){return e===`assessment_3`||e===`text_reply_30`}function C(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Invalid usage pack response`);return e}function w(e){if(typeof e!=`number`||!Number.isSafeInteger(e)||e<0)throw Error(`Invalid usage pack amount`);return e}function T(e){let t=C(e);if(!S(t.sku))throw Error(`Invalid usage pack SKU`);return{sku:t.sku,usdCents:w(t.usdCents),assessmentUnits:w(t.assessmentUnits),textReplyUnits:w(t.textReplyUnits),includedRepliesPerAssessment:w(t.includedRepliesPerAssessment)}}function E(e){let t=C(e);if(t.identity!==`registered`&&t.identity!==`anonymous`)throw Error(`Invalid usage pack identity`);if(!Array.isArray(t.catalog)||!Array.isArray(t.orders))throw Error(`Invalid usage pack catalog or orders`);let n=C(t.balances),r=Object.fromEntries(Object.entries(C(n.reportTextReplyUnits)).map(([e,t])=>[e,w(t)])),i=t.orders.map(e=>{let t=C(e);if(typeof t.id!=`string`||typeof t.purchaseIntentId!=`string`||t.stripeCheckoutSessionId!==null&&typeof t.stripeCheckoutSessionId!=`string`||![`PENDING`,`PAID`,`PAYMENT_FAILED`,`EXPIRED`,`REFUNDED`].includes(String(t.status))||typeof t.currency!=`string`||typeof t.createdAt!=`string`)throw Error(`Invalid usage pack order`);let n=T({...t,usdCents:t.amountCents});return{...n,id:t.id,purchaseIntentId:t.purchaseIntentId,stripeCheckoutSessionId:t.stripeCheckoutSessionId,status:t.status,currency:t.currency,amountCents:n.usdCents,createdAt:t.createdAt,paidAt:typeof t.paidAt==`string`?t.paidAt:null,refundedAt:typeof t.refundedAt==`string`?t.refundedAt:null}});return{identity:t.identity,salesEnabled:t.salesEnabled===!0,catalog:t.catalog.map(T),balances:{assessmentUnits:w(n.assessmentUnits),textReplyUnits:w(n.textReplyUnits),reportTextReplyUnits:r},orders:i}}async function D(){return E((await u.get(`/user/usage-packs`)).data)}function O(e,t){return t?e.find(e=>e.stripeCheckoutSessionId===t):void 0}var k=(e,t)=>`voyage.pack-intent.${e}.${t}`;function A(e,t){let n=k(e,t),r=window.localStorage.getItem(n);if(r)return r;let i=crypto.randomUUID();return window.localStorage.setItem(n,i),i}function j(e,t,n){let r=k(e,t);try{window.localStorage.getItem(r)===n&&window.localStorage.removeItem(r)}catch{}}function M(e){return e===`assessment_3`?`3 health checks`:`30 chat replies`}function N(e){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e/100)}var P=e(t(),1);function F({sessionId:e,poll:t=!1}={}){let{user:n}=i({from:`__root__`}),r=!n||n.isAnonymous,a=s({queryKey:[...x,n?.id??`signed-out`],queryFn:D,enabled:!r,staleTime:t?0:5*6e4,gcTime:30*6e4,refetchInterval:t?t=>{let n=O(t.state.data?.orders??[],e);return n&&n.status!==`PENDING`?!1:2e3}:!1});return(0,P.useEffect)(()=>{n&&!r&&a.data&&(v(n.id,a.data.orders),I(n.id,a.data))},[n,r,a.data]),{query:a,isAnonymous:r,userId:r?void 0:n.id}}function I(e,t){for(let n of t?.orders??[])n.status!==`PENDING`&&j(e,n.sku,n.purchaseIntentId)}function L(){let{user:e}=i({from:`__root__`}),t=a();return o({mutationFn:n=>{if(!e||e.isAnonymous)throw Error(`Sign in to purchase a pack`);let r=typeof n==`string`?n:n.sku;return I(e.id,t.getQueryData([...x,e.id])),c(l.usagePackCheckoutStarted,{sku:r,surface:`web`}),g(r,typeof n==`string`?A(e.id,r):n.intentId)},onSuccess:e=>m(e.url)})}var R=r();function z({order:e,returnPath:t}){let r=L();return(0,R.jsxs)(`div`,{role:`status`,className:`rounded-2xl border border-surface-border bg-surface-cream p-4 text-sm text-text-secondary`,children:[(0,R.jsx)(`p`,{children:`You have a checkout awaiting confirmation. Resume it if you haven’t paid, or check its status before buying another pack.`}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,R.jsx)(d,{disabled:r.isPending,loading:r.isPending,onClick:()=>{t&&f(t),r.mutate({sku:e.sku,intentId:e.purchaseIntentId})},children:`Resume checkout`}),(0,R.jsx)(n,{className:`underline`,to:`/subscribe/success`,search:{kind:`usage_pack`,session_id:e.stripeCheckoutSessionId??void 0},children:`Check payment status`})]}),r.isError&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3`,children:`We couldn’t reopen this checkout. Check payment status if you’ve already paid; your original purchase request is still saved.`})]})}function B({at:e}){return!e||!Number.isFinite(Date.parse(e))?null:(0,R.jsxs)(`p`,{className:`text-xs text-text-secondary`,children:[`Next free allowance:`,` `,new Date(e).toLocaleStr
1ing(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`}),`.`]})}function V({kind:e,returnPath:t}){let{query:n,userId:r}=F(),{subscribed:i,query:a}=h(),o=L(),s=e===`triage`?`assessment_3`:e===`chat`?`text_reply_30`:null,u=n.data?.catalog.find(e=>e.sku===s),m=n.data?.orders.find(e=>e.status===`PENDING`),g=!!(r&&u&&n.data?.salesEnabled&&a.data&&!i&&!m),_=(0,P.useRef)(null);return(0,P.useEffect)(()=>{let t=`${r}:${s}`;!g||_.current===t||(_.current=t,c(l.usagePackOfferEligible,{sku:s,surface:e===`triage`?`assessment_limit`:`chat_limit`}))},[g,r,s,e]),!r||!s||i||!n.data?.salesEnabled||!a.data?null:m?(0,R.jsx)(z,{order:m,returnPath:t??p()}):u?(0,R.jsxs)(`section`,{"aria-label":`One-time pack`,className:`rounded-2xl border border-surface-border bg-surface-cream p-5`,children:[(0,R.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-[0.12em] text-brand-coral-text`,children:`A little more Voyage`}),(0,R.jsx)(`h3`,{className:`mt-2 font-heading text-[25px] text-text-primary`,children:s===`assessment_3`?`Health Check`:`Voyage Chat`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-text-secondary`,children:s===`assessment_3`?`${u.assessmentUnits} health checks to help you understand symptoms and what to do next. Each report includes ${u.includedRepliesPerAssessment} follow-up answers.`:`${u.textReplyUnits} replies from Voyage. Bring your questions, photos, and follow-ups. One completed response uses one reply.`}),(0,R.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-text-secondary`,children:[`One payment. No automatic renewal. Unused`,` `,s===`assessment_3`?`assessments`:`replies`,` do not expire. Available on the Voyage website.`]}),(0,R.jsxs)(d,{className:`mt-4 h-11 w-full rounded-full`,disabled:o.isPending,loading:o.isPending,onClick:()=>{f(t??p()),o.mutate(u.sku)},children:[`Get `,s===`assessment_3`?`Health Check`:`Voyage Chat`,` ·`,` `,N(u.usdCents)]}),o.isError&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-text-secondary`,children:`We couldn’t open checkout. Please try again; your purchase request is saved.`})]}):null}export{F as a,M as c,b as d,L as i,N as l,B as n,x as o,z as r,O as s,V as t,y as u};

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.