1import{Q as be,Y as xe,r as k,c as m,w as ge,o as he,G as _e,S as u,J as n,I as U,K as s,X as i,W as p,j as y,V as l,U as r,F as h,Z as L,a0 as B,H as j}from"./vendor-core-BXbNC1oJ.js";import{S as v,G as we}from"./SettingsRow-CEjvb0j0.js";import{S as M}from"./SettingsCard-BDvsmfkG.js";import{_ as Ce,c as ke,a as _}from"./_plugin-vue_export-helper-DeaGEAu3.js";import{A as Se,aa as Pe,af as Ue,g as De,ag as Fe,K as E,ah as Te,ai as Le,aj as Be}from"./main-CTluKosS.js";import{u as Me}from"./featureFlags-D-y8jz_0.js";import{u as Ne,s as Y}from"./index-Bfn_wroP.js";import{q,t as Ie,u as Ve,v as Ae}from"./desktopDeepLink-By92AL15.js";import"./index-B2aZD4kB.js";import"./onboarding-DLWqg9qi.js";import"./naive-ui-uezjBets.js";import"./vendor-utils-DKuW2T68.js";import"./analytics-BAV65Dpj.js";import"./env-MvOdH_iN.js";import"./loader-circle-KuQW9MGi.js";import"./preload-helper-fwxmMx4o.js";import"./vendor-livekit-w_4IrL6H.js";import"./vendor-sentry-9vP2hbkd.js";import"./acceptLanguage-D3Gg3e8c.js";import"./appOrigin-BaJgmYZD.js";import"./vendor-product-analytics-BqLDAa5u.js";try{let b=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},f=new b.Error().stack;f&&(b._sentryDebugIds=b._sentryDebugIds||{},b._sentryDebugIds[f]="cc7eb123-8b17-4550-87a8-40cc65c8a9e3",b._sentryDebugIdIdentifier="sentry-dbid-cc7eb123-8b17-4550-87a8-40cc65c8a9e3")}catch{}const $e={class:"plans-credits-view mx-auto flex w-full max-w-[816px] flex-col gap-24"},je={class:"text-[14px] font-normal leading-[18px] text-[var(--sys-text-secondary)]"},Ee={key:0,class:"flex items-center gap-6"},ze={class:"text-[14px] font-medium text-violet-600"},We={key:1,class:"text-[14px] font-medium text-[var(--sys-text-primary)]"},Re={class:"text-[14px] font-normal text-[var(--sys-text-secondary)]"},Ke={class:"flex w-full flex-wrap items-center justify-end gap-8 max-sm:justify-start"},Oe={class:"overflow-x-auto"},Ge={class:"w-full min-w-[480px]"},He={class:"border-b border-[var(--sys-border-medium)]"},Ye={class:"px-20 py-12 text-left text-sm font-medium text-[var(--sys-text-secondary)]"},qe={class:"px-12 md:px-16 py-12 text-left text-sm font-medium text-[var(--sys-text-secondary)]"},Je={class:"px-12 md:px-16 py-12 text-right text-sm font-medium text-[var(--sys-text-secondary)]"},Qe={class:"px-20 py-16"},Xe={class:"text-md text-[var(--sys-text-primary)]"},Ze={class:"px-12 md:px-16 py-16"},et={class:"text-md text-[var(--sys-text-secondary)] whitespace-nowrap"},tt={class:"px-12 md:px-16 py-16 text-right"},at={class:"flex items-center justify-end gap-4"},st={class:"px-12 md:px-20 py-16 text-right"},rt=["onClick"],ot={key:1,class:"text-md text-[var(--sys-text-tertiary)]"},lt={key:0},nt={colspan:"4",class:"px-20 py-40 text-center text-md text-[var(--sys-text-secondary)]"},it={key:0,class:"flex items-center justify-end"},ct={class:"flex items-center gap-12"},dt={class:"flex items-center gap-8"},ut={key:1,class:"text-sm text-[var(--sys-text-tertiary)] px-8"},pt={__name:"PlansCreditsView",setup(b){const f=ke("PlansCreditsView"),{t:a}=be({useScope:"local",messages:{en:{legacy:{messageLine1:"You're currently on a pay-per-use plan.",messageLine2:"Upgrade to a subscription to save on every task."},planSummary:{title:"Current Plan",tier:"Tier",freePlan:"Free Plan",price:"Price",willExpireAt:"Will expire at",renewalDate:"Renewal Date"},creditsSummary:{title:"Credits",totalBalance:"Total Balance"},actions:{upgradeToPro:"Upgrade to Pro",upgrade:"Upgrade",manageSubscription:"Manage Subscription",topUp:"Top-up Now",invoice:"Invoice",view:"View"},table:{transactions:"Transactions",date:"Date",amount:"Amount",sessionWithId:"Session {id}",noTransactions:"No transactions yet"},pagination:{previous:"Previous",next:"Next"},labels:{activityCredits:"Activity Credits",dailyCredits:"Daily Bonus Credits",monthlyCredits:"Monthly Credits",additionalCredits:"Additional Credits",freeCredits:"Free Credits",fallbackCreditsSuffix:" Credits",free:"Free"},errors:{portalUrlNotFound:"Failed to get portal URL",portalFailed:"Failed to open subscription management. Please try again.",popupBlocked:"Please allow pop-ups to open your invoices."}},ja:{legacy:{messageLine1:"ç¾å¨ã¯å¾é課éãã©ã³ãå©ç¨ä¸ã§ãã",messageLine2:"ãµãã¹ã¯ãªãã·ã§ã³ã¸ã¢ããã°ã¬ã¼ãããã¨åã¿ã¹ã¯ã§ç¯ç´ã§ãã¾ãã"},planSummary:{title:"ç¾å¨ã®ãã©ã³",tier:"ãã©ã³",freePlan:"ç¡æãã©ã³",price:"æé",willExpireAt:"æå¹æé",renewalDate:"æ´æ°æ¥"},creditsSummary:{title:"ã¯ã¬ã¸ãã",totalBalance:"åè¨æ®é«"},actions:{upgradeToPro:"Pro ã«ã¢ããã°ã¬ã¼ã",upgrade:"ã¢ããã°ã¬ã¼ã",manageSubscription:"ãµãã¹ã¯ã管ç",topUp:"ãã£ã¼ã¸",invoice:"è«æ±æ¸",view:"表示"},table:{transactions:"åå¼",date:"æ¥ä»",amount:"éé¡",sessionWithId:"ã»ãã·ã§ã³ {id}",noTransactions:"åå¼å±¥æ´ã¯ã¾ã ããã¾ãã"},pagination:{previous:"åã¸",next:"次ã¸"},labels:{activityCredits:"ã¢ã¯ãã£ããã£ã¯ã¬ã¸ãã",dailyCredits:"ãã¤ãªã¼ãã¼ãã¹ã¯ã¬ã¸ãã",monthlyCredits:"ææ¬¡ã¯ã¬ã¸ãã",additionalCredits:"追å ã¯ã¬ã¸ãã",freeCredits:"ç¡æã¯ã¬ã¸ãã",fallbackCreditsSuffix:" ã¯ã¬ã¸ãã",free:"ç¡æ"},errors:{portalUrlNotFound:"ãã¼ã¿ã«URLã®åå¾ã«å¤±æãã¾ãã",portalFailed:"ãµãã¹ã¯ãªãã·ã§ã³ç®¡çãéãã¾ããã§ãããããä¸åº¦ã試ããã ããã",popupBlocked:"è«æ±æ¸ãéãã«ã¯ãããã¢ããã許å¯ãã¦ãã ããã"}}}}),J=xe(),c=Se(),Q=Ne(),N=k([]),S=k(!1),D=k(!1),F=k(10),I=k(0),z=k(0),x=m(()=>Math.floor(I.value/F.value)+1),T=m(()=>Math.ceil(z.value/F.value)||1),X=m(()=>{const e=[],t=T.value;if(t<=5)for(let d=1;d<=t;
1d++)e.push(d);else{const d=x.value;let g=Math.max(1,d-2),C=Math.min(t,d+2);C-g<4&&(g===1?C=Math.min(t,g+5-1):g=Math.max(1,C-5+1)),g>1&&(e.push(1),g>2&&e.push("..."));for(let $=g;$<=C;$++)e.push($);C<t&&(C<t-1&&e.push("..."),e.push(t))}return e}),w=m(()=>c.creditsSummary),Z=m(()=>w.value?.wallet_balances||{}),ee={activity:a("labels.activityCredits"),daily:a("labels.dailyCredits"),monthly:a("labels.monthlyCredits"),addon:a("labels.additionalCredits"),free:a("labels.freeCredits")},te=m(()=>{const e=Z.value,o=[],t=["activity","daily","monthly","addon","free"];for(const d of t)d in e&&e[d]!==void 0&&e[d]!==null&&o.push({key:d,label:ee[d]||d.charAt(0).toUpperCase()+d.slice(1)+a("labels.fallbackCreditsSuffix"),value:e[d]});return o}),ae=(e,o="USD")=>e?Fe(e,o):a("labels.free"),se=m(()=>{const e=c.subscription,o=ae(e?.amount,e?.currency);return e?.interval?`${o} / ${e.interval}`:o}),re=m(()=>c.subscription?.cancel_at_period_end?a("planSummary.willExpireAt"):a("planSummary.renewalDate")),oe=m(()=>W(c.subscription?.current_period_end)),W=e=>{if(!e)return"--";try{return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return"--"}},R=e=>Number(e).toLocaleString(),le=m(()=>Pe({value:w.value?.has_debt?w.value?.debt_amount||"0":w.value?.total_balance||"0",hasDebt:w.value?.has_debt})),K=e=>e.type==="grant"||parseFloat(e.amount||"0")>0,P=async()=>{try{S.value=!0;const e=await Y({url:"/v2/credits/transactions",method:"get",params:{limit:F.value,offset:I.value}});N.value=e.transactions||[],z.value=e.total||0,f.info("Transactions fetched successfully",{data:e})}catch(e){f.error("Failed to fetch transactions",{error:e})}finally{S.value=!1}},ne=Ue(()=>{P()}),V=e=>{e<1||e>T.value||e===x.value||(I.value=(e-1)*F.value,P())},ie=e=>{J.push(`/chat/${e}`)},ce=()=>{q({source:"profile_legacy"}),E.openDialog({source:"settings"})},de=()=>{q({source:"profile"}),E.openDialog({source:"profile",displayMode:"all"})},A=Me(),O=m(()=>A.hasSubscriptionManagement),G=async()=>{try{const e=await Y({url:"/v2/subscriptions/customer-portal",method:"post",data:{returnUrl:window.location.href},showHttpError:!1});if(e?.portalUrl)return e.portalUrl;window.$toast?.error(a("errors.portalUrlNotFound")),f.error("Portal URL not found in response",{data:e})}catch(e){f.error("Failed to create customer portal session",{error:e}),window.$toast?.error(a("errors.portalFailed"))}return null},ue=async()=>{const e=window.open("about:blank","_blank");if(!e){window.$toast?.error(a("errors.popupBlocked"));return}e.opener=null,D.value=!0;try{const o=await G();o?e.location.href=o:e.close()}finally{D.value=!1}},pe=async()=>{D.value||await ue()},me=async()=>{if(Ve(),await A.fetch(),O.value)Le.openDialog();else{const e=await G();e&&(Ae(),window.location.href=e)}},ye=m(()=>c.isFreeUser?a("actions.upgrade"):a("actions.manageSubscription")),fe=()=>{c.isFreeUser?de():me()},ve=()=>{const e="profile";Ie({source:e}),Te.openDialog({source:e})};ge(()=>E.isOpen.value,(e,o=!1)=>{o&&!e&&(Be.isOpen.value||(c.refreshAfterPayment(),P()))});const H=async()=>{!O.value&&document.visibilityState==="visible"&&(await c.refreshAll(),await P(),f.info("Page visible after portal return, refreshed data"))};return he(()=>{c.creditsSummary||c.refreshAll(),P(),A.fetch(),document.addEventListener("visibilitychange",H)}),_e(()=>{document.removeEventListener("visibilitychange",H),ne()}),(e,o)=>(n(),u("div",$e,[s(Q).isLegacyUser?(n(),U(M,{key:0},{default:i(()=>[p(v,{padding:"lg"},{label:i(()=>[r("span",je,[y(l(s(a)("legacy.messageLine1")),1),o[2]||(o[2]=r("br",null,null,-1)),y(" "+l(s(a)("legacy.messageLine2")),1)])]),default:i(()=>[p(_,{color:"violet",class:"shrink-0",onClick:ce},{default:i(()=>[y(l(s(a)("actions.upgradeToPro")),1)]),_:1})]),_:1})]),_:1})):(n(),u(h,{key:1},[p(M,{title:s(a)("planSummary.title")},{default:i(()=>[s(c).hasInitialized?(n(),u(h,{key:1},[p(v,{label:s(a)("planSummary.tier")},{default:i(()=>[s(c).isPaidUser&&s(c).currentPlanName?(n(),u("div",Ee,[p(s(De),{size:16,class:"shrink-0 text-violet-600"}),r("span",ze,l(s(c).currentPlanName),1)])):(n(),u("span",We,l(s(c).currentPlanName||s(a)("planSummary.freePlan")),1))]),_:1},8,["label"]),p(v,{label:s(a)("planSummary.price"),value:se.value},null,8,["label","value"]),p(v,null,{label:i(()=>[r("span",{class:j(["text-[16px] font-medium leading-[20px] tracking-[-0.16px]",s(c).subscription?.cancel_at_period_end?"text-warning-500":"text-[var(--sys-text-primary)]"])},l(re.value),3)]),default:i(()=>[r("span",Re,l(oe.value),1)]),_:1}),p(v,{padding:"sm","stack-on-mobile":""},{default:i(()=>
1[r("div",Ke,[s(c).isPaidUser?(n(),U(_,{key:0,type:"secondary",class:"shrink-0",onClick:ve},{default:i(()=>[y(l(s(a)("actions.topUp")),1)]),_:1})):L("",!0),s(c).isPaidUser?(n(),U(_,{key:1,type:"secondary",class:"shrink-0",loading:D.value,onClick:pe},{default:i(()=>[y(l(s(a)("actions.invoice")),1)]),_:1},8,["loading"])):L("",!0),p(_,{type:"primary-black",class:"shrink-0",onClick:fe},{default:i(()=>[y(l(ye.value),1)]),_:1})])]),_:1})],64)):(n(),u(h,{key:0},B(3,t=>p(v,{key:t},{label:i(()=>o[3]||(o[3]=[r("span",{class:"h-12 w-64 animate-pulse rounded bg-[var(--sys-bg-overlay-minus-1)]"},null,-1)])),default:i(()=>[o[4]||(o[4]=r("span",{class:"h-12 w-80 animate-pulse rounded bg-[var(--sys-bg-overlay-minus-1)]"},null,-1))]),_:2},1024)),64))]),_:1},8,["title"]),p(M,{title:s(a)("creditsSummary.title")},{default:i(()=>[(n(!0),u(h,null,B(te.value,t=>(n(),U(v,{key:t.key,label:t.label,value:R(t.value||"0")},null,8,["label","value"]))),128)),p(v,{label:s(a)("creditsSummary.totalBalance")},{default:i(()=>[r("span",{class:j(["text-[14px] font-medium",w.value?.has_debt?"text-error-600":"text-[var(--sys-text-primary)]"])},l(le.value),3)]),_:1},8,["label"])]),_:1},8,["title"]),p(M,{divided:!1},{default:i(()=>[r("div",Oe,[r("table",Ge,[r("thead",null,[r("tr",He,[r("th",Ye,l(s(a)("table.transactions")),1),r("th",qe,l(s(a)("table.date")),1),r("th",Je,l(s(a)("table.amount")),1),o[5]||(o[5]=r("th",{class:"px-12 md:px-16 py-12"},null,-1))])]),r("tbody",null,[(n(!0),u(h,null,B(N.value,t=>(n(),u("tr",{key:t.id,class:"border-b border-[var(--sys-border-medium)] last:border-b-0 hover:bg-[var(--sys-bg-overlay-minus-1)]"},[r("td",Qe,[r("span",Xe,l(t.description||(t.session_id?s(a)("table.sessionWithId",{id:t.session_id}):"--")),1)]),r("td",Ze,[r("span",et,l(W(t.created_at)),1)]),r("td",tt,[r("div",at,[r("span",{class:j(["text-md font-normal whitespace-nowrap",K(t)?"text-success-600":"text-error-600"])},l(K(t)?"+":"-")+l(R(Math.abs(parseFloat(t.amount||"0")))),3)])]),r("td",st,[t.session_id?(n(),u("button",{key:0,type:"button",class:"ml-auto flex items-center gap-2 text-sm font-medium text-[var(--sys-text-secondary)] transition-colors hover:text-[var(--sys-text-primary)]",onClick:d=>ie(t.session_id)},[y(l(s(a)("actions.view"))+" ",1),p(s(we),{size:14,weight:"bold"})],8,rt)):(n(),u("span",ot,"--"))])]))),128)),N.value.length===0?(n(),u("tr",lt,[r("td",nt,l(s(a)("table.noTransactions")),1)])):L("",!0)])])])]),_:1}),T.value>1?(n(),u("div",it,[r("div",ct,[p(_,{size:"sm",secondary:"",disabled:x.value===1||S.value,onClick:o[0]||(o[0]=t=>V(x.value-1))},{default:i(()=>[y(l(s(a)("pagination.previous")),1)]),_:1},8,["disabled"]),r("div",dt,[(n(!0),u(h,null,B(X.value,t=>(n(),u(h,{key:t},[t!=="..."?(n(),U(_,{key:0,size:"sm",class:"min-w-36",type:t===x.value?"primary-black":"",disabled:S.value,onClick:d=>V(t)},{default:i(()=>[y(l(t),1)]),_:2},1032,["type","disabled","onClick"])):(n(),u("span",ut,"..."))],64))),128))]),p(_,{size:"sm",secondary:"",disabled:x.value===T.value||S.value,onClick:o[1]||(o[1]=t=>V(x.value+1))},{default:i(()=>[y(l(s(a)("pagination.next")),1)]),_:1},8,["disabled"])])])):L("",!0)],64))]))}},Nt=Ce(pt,[["__scopeId","data-v-18b4e435"]]);export{Nt as default}; 2//# sourceMappingURL=PlansCreditsView-DYMpHpQs.js.map
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.