1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[88105],{46139:(e,t,s)=>{s.d(t,{W:()=>l});let l={free:{tagline:"For individuals exploring AI automation",items:[{label:"100K tokens/month",included:!0},{label:"Chat & Studio",included:!0},{label:"3 integrations",included:!0},{label:"2 active missions",included:!0},{label:"Policies",included:!1},{label:"SSO / SAML",included:!1},{label:"IAM & RBAC",included:!1},{label:"Signing server",included:!1}]},starter:{tagline:"For small teams getting started",items:[{label:"1M tokens/month",included:!0},{label:"Chat, Studio & Missions",included:!0},{label:"10 integrations",included:!0},{label:"Unlimited missions",included:!0},{label:"Layer 1 policies (tool guard)",included:!0},{label:"SSO / SAML",included:!1},{label:"IAM & RBAC",included:!1},{label:"Signing server",included:!1}]},professional:{tagline:"For growing teams with governance needs",items:[{label:"10M tokens/month",included:!0},{label:"Full platform access",included:!0},{label:"Unlimited integrations",included:!0},{label:"Unlimited missions",included:!0},{label:"All 3 policy layers",included:!0},{label:"Full IAM, RBAC & audit",included:!0},{label:"SSO / SAML / MFA",included:!1},{label:"Signing server",included:!1}]},enterprise:{tagline:"For orgs that need full control",isContactUs:!0,items:[{label:"Custom token volume",included:!0},{label:"Full platform access",included:!0},{label:"Unlimited everything",included:!0},{label:"Custom agent contracts",included:!0},{label:"All 3 policy layers + custom",included:!0},{label:"Full IAM, RBAC & audit",included:!0},{label:"SSO / SAML / MFA / SCIM",included:!0},{label:"Signing server integration",included:!0}]}}},70253:(e,t,s)=>{s.d(t,{H:()=>d,y:()=>i});var l=s(54568),a=s(97862),r=s(27541),n=s(7620);function i(e){let{permission:t,anyOf:s,feature:i,redirectTo:d="/",children:o}=e,c=(0,r.useRouter)(),m=(0,a.TU)(null!=t?t:""),u=(0,a.XZ)(null!=s?s:[]),x=(0,a.xp)(null!=i?i:""),p=i?x:t?m:!s||u;return((0,n.useEffect)(()=>{p||c.replace(d)},[p,d,c]),p)?(0,l.jsx)(l.Fragment,{children:o}):null}function d(e,t){var s;return e.feature?(0,a.as)(t,e.feature):(null==(s=e.anyOf)?void 0:s.length)?e.anyOf.some(e=>t.includes(e)):!e.permission||t.includes(e.permission)}},88105:(e,t,s)=>{s.r(t),s.d(t,{default:()=>y});var l=s(54568),a=s(70253),r=s(88186),n=s(18544),i=s(46139),d=s(25703),o=s(60844),c=s(74717),m=s(32064),u=s(12598),x=s(6438),p=s(7620);let g=new Intl.NumberFormat("en-US"),b=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(e/100),h=e=>new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),f=e=>{var t;return!!e&&(null==(t=i.W[e])?void 0:t.isContactUs)===!0};function y(){var e;let[t,s]=(0,p.useState)(!0),[i,y]=(0,p.useState)(null),[j,N]=(0,p.useState)([]),[v,k]=(0,p.useState)(null),[w,C]=(0,p.useState)(!1),[S,A]=(0,p.useState)([]),[P,F]=(0,p.useState)(!1),[M,U]=(0,p.useState)(null),[T,I]=(0,p.useState)("monthly"),[B,D]=(0,p.useState)(!1),[O,L]=(0,p.useState)(!1),W=(0,p.useCallback)(async()=>{var e,t,l,a,r,i,d;s(!0);try{let[s,d,o]=await Promise.all([n.apiService.getBillingStatus().catch(()=>null),n.apiService.getBillingInvoices().catch(()=>null),n.apiService.getUsagePlan().catch(()=>null)]);s?y(s):(null==o?void 0:o.plan)&&y({subscription:{id:null!=(e=o.plan.id)?e:"",status:"active",planName:o.plan.name,planDisplayName:o.plan.displayName,billingCycle:"monthly",priceCents:null!=(t=o.plan.monthlyPriceCents)?t:0,currentPeriodStart:new Date().toISOString(),currentPeriodEnd:new Date().toISOString()},usage:{overageTokens:0,estimatedOverageCostCents:0,usedTokens:0,limitTokens:null!=(l=o.plan.monthlyTokenLimit)?l:0,percentUsed:0,status:"ok",...o.usage},planFeeCents:null!=(a=o.plan.monthlyPriceCents)?a:0,overageCents:0,totalCents:null!=(r=o.plan.monthlyPriceCents)?r:0}),d&&N(Array.isArray(d)?d:null!=(i=d.invoices)?i:[])}catch(e){k(null!=(d=e.message)?d:"Failed to load billing data")}finally{s(!1)}},[]);(0,p.useEffect)(()=>{W()},[W]);let Z=async()=>{if(C(!0),!(S.length>0)){F(!0);try{let e=await fetch("/api/usage/plans/public").then(e=>e.ok?e.json():[]),t=(Array.isArray(e)?e:[]).map(e=>{var t,s,l;return{id:e.id,name:e.name,displayName:e.displayName,monthlyPriceCents:null!=(t=e.monthlyPriceCents)?t:0,yearlyPriceCents:null!=(s=e.yearlyPriceCents)?s:0,monthlyTokenLimit:null!=(l=e.monthlyTokenLimit)?l:0}});A(t)}catch(e){}finally{F(!1)}}},_=async()=>
1{if(M){D(!0);try{let e=S.find(e=>e.name===M);try{await n.apiService.changeBillingPlan({planName:M,billingCycle:T})}catch(t){if(!(null==e?void 0:e.id))throw Error("Plan not found");await n.apiService.changeUsagePlan({usagePlanId:e.id,billingCycle:T})}C(!1),U(null),await W()}catch(t){var e;k(null!=(e=t.message)?e:"Failed to change plan")}finally{D(!1)}}},E=async()=>{L(!0);try{let e=await n.apiService.createBillingPortal({returnUrl:window.location.href});(null==e?void 0:e.url)&&(window.location.href=e.url)}catch(t){var e;k(null!=(e=t.message)?e:"Failed to open payment portal")}finally{L(!1)}},R=null==i?void 0:i.subscription,z=null==i?void 0:i.usage,H=R&&"none"!==R.status,X=z?Math.min(z.percentUsed,100):0,K=z?z.percentUsed>=100?"bg-red-500":z.percentUsed>=80?"bg-amber-500":"bg-emerald-500":"bg-primary",V=(0,p.useMemo)(()=>{var e;if(!R)return null;let t={active:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400",trialing:"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-400",past_due:"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400",canceled:"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400",incomplete:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400"};return(0,l.jsx)("span",{className:(0,d.cn)("inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold capitalize",null!=(e=t[R.status])?e:t.incomplete),children:R.status.replace("_"," ")})},[R]);return t?(0,l.jsx)("div",{className:"flex items-center justify-center py-32",children:(0,l.jsx)(o.A,{className:"w-7 h-7 text-primary animate-spin"})}):(0,l.jsx)(a.y,{permission:"settings:profile:manage",redirectTo:"/settings",children:(0,l.jsxs)("div",{className:"space-y-6",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h1",{className:"text-3xl font-bold tracking-tight text-foreground",children:"Billing"}),(0,l.jsx)("p",{className:"text-base text-muted-foreground mt-1",children:"Manage your subscription, payment method, and invoices"})]}),v&&(0,l.jsxs)("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4 text-base text-red-700 dark:border-red-800 dark:bg-red-950/30 dark:text-red-400",children:[v,(0,l.jsx)("button",{type:"button",onClick:()=>k(null),className:"ml-2 font-medium underline",children:"Dismiss"})]}),(0,l.jsxs)(r.Zp,{children:[(0,l.jsx)(r.aR,{className:"pb-3 px-6 pt-6",children:(0,l.jsx)(r.ZB,{className:"text-lg font-semibold",children:"Current Plan"})}),(0,l.jsx)(r.Wu,{className:"px-6 pb-6 pt-2",children:H?(0,l.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("span",{className:"text-2xl font-bold text-foreground",children:null!=(e=R.planDisplayName)?e:R.planName}),V,(0,l.jsx)("span",{className:"inline-flex rounded-full bg-muted px-2.5 py-0.5 text-xs font-medium text-muted-foreground capitalize",children:R.billingCycle})]}),(0,l.jsx)("p",{className:"text-3xl font-bold tracking-tight text-foreground",children:f(R.planName)?"Custom":(0,l.jsxs)(l.Fragment,{children:[b(R.priceCents),(0,l.jsxs)("span",{className:"text-base font-normal text-muted-foreground",children:["/","yearly"===R.billingCycle?"yr":"mo"]})]})}),(0,l.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Next renewal: ",h(R.currentPeriodEnd)]})]})}):(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-lg font-semibold text-foreground",children:"No active subscription"}),(0,l.jsx)("p",{className:"text-base text-muted-foreground mt-1",children:"Select a plan to get started"})]}),(0,l.jsx)("button",{type:"button",onClick:Z,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-5 py-2.5 text-base font-semibold text-primary-foreground shadow-sm transition-colors hover:bg-primary/90",children:"Choose Plan"})]})})]}),z&&(0,l.jsx)(r.Zp,{className:(0,d.cn)("border-l-4","exceeded"===z.status?"border-l-red-500 bg-red-50/50 dark:bg-red-950/10":"warning"===z.status?"border-l-amber-500 bg-amber-50/50 dark:bg-amber-950/10":"border-l-emerald-500"),children:(0,l.jsxs)(r.Wu,{className:"p-5",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-3",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:["ok"!==z.status&&(0,l.jsx)(c.A,{className:(0,d.cn)("h-4 w-4 shrink-0","exceeded"===z.status?"text-red-500":"text-amber-500")}),(0,l.jsx)("span",{className:"text-base font-semibold text-foreground",children:"Usage This Period"}),(0,l.jsxs)("span",{className:"text-base text-muted-foreground",children:["â ",g.format(z.usedTokens)," / ",g.format(z.limitTokens)," tokens"]})]}),"exceeded"===z.status&&z.overageTokens>0&&(0,l.jsxs)("span",{className:"text-xs text-red-600 dark:text-red-400 font-medium",children:["Overage: ",g.format(z.overageTokens)," tokens"]})]}),(0,l.jsx)("div",{className:"h-2.5 w-full rounded-full bg-muted",children:(0,l.jsx)("div",{className:(0,d.cn)("h-2.5 rounded-full transition-all",K),style:{width:"".concat(Math.max(X,+(z.usedTokens>0)),"%")}
1})}),(0,l.jsxs)("div",{className:"mt-1.5 flex justify-between text-xs text-muted-foreground",children:[(0,l.jsxs)("span",{children:[Math.round(z.percentUsed),"% used"]}),(0,l.jsxs)("span",{children:[g.format(Math.max(0,z.limitTokens-z.usedTokens))," remaining"]})]})]})}),i&&H&&(0,l.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-5",children:[(0,l.jsx)(r.Zp,{children:(0,l.jsxs)(r.Wu,{className:"p-6",children:[(0,l.jsx)("p",{className:"text-base font-medium text-muted-foreground",children:"Plan Fee"}),(0,l.jsx)("p",{className:"text-3xl font-bold text-foreground tracking-tight mt-2",children:b(i.planFeeCents)})]})}),(0,l.jsx)(r.Zp,{children:(0,l.jsxs)(r.Wu,{className:"p-6",children:[(0,l.jsx)("p",{className:"text-base font-medium text-muted-foreground",children:"Overage"}),(0,l.jsx)("p",{className:"text-3xl font-bold text-foreground tracking-tight mt-2",children:b(i.overageCents)})]})}),(0,l.jsx)(r.Zp,{children:(0,l.jsxs)(r.Wu,{className:"p-6",children:[(0,l.jsx)("p",{className:"text-base font-medium text-muted-foreground",children:"Total This Period"}),(0,l.jsx)("p",{className:"text-3xl font-bold text-primary tracking-tight mt-2",children:b(i.totalCents)})]})})]}),(0,l.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,l.jsx)("button",{type:"button",onClick:Z,className:"inline-flex items-center gap-2 rounded-lg border border-border bg-card px-5 py-2.5 text-base font-semibold text-foreground shadow-sm transition-colors hover:bg-muted",children:"Change Plan"}),H&&(0,l.jsxs)("button",{type:"button",onClick:E,disabled:O,className:"inline-flex items-center gap-2 rounded-lg border border-border bg-card px-5 py-2.5 text-base font-semibold text-foreground shadow-sm transition-colors hover:bg-muted disabled:opacity-50",children:[O&&(0,l.jsx)(o.A,{className:"h-4 w-4 animate-spin"}),"Manage Payment",(0,l.jsx)(m.A,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]}),(0,l.jsxs)(r.Zp,{children:[(0,l.jsx)(r.aR,{className:"pb-3 px-6 pt-6",children:(0,l.jsx)(r.ZB,{className:"text-lg font-semibold",children:"Invoice History"})}),(0,l.jsx)(r.Wu,{className:"px-6 pb-6 pt-2",children:0===j.length?(0,l.jsx)("div",{className:"py-12 text-center text-base text-muted-foreground",children:"No invoices yet."}):(0,l.jsx)("div",{className:"overflow-x-auto",children:(0,l.jsxs)("table",{className:"w-full text-base",children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{className:"border-b border-border/40",children:[(0,l.jsx)("th",{className:"py-3 px-3 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Date"}),(0,l.jsx)("th",{className:"py-3 px-3 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Amount"}),(0,l.jsx)("th",{className:"py-3 px-3 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Status"}),(0,l.jsx)("th",{className:"py-3 px-3 text-right text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"\xa0"})]})}),(0,l.jsx)("tbody",{children:j.map(e=>{var t;let s={paid:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-400",open:"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-400",draft:"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400",void:"bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-500",uncollectible:"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400"};return(0,l.jsxs)("tr",{className:"border-b border-border/20 last:border-0 hover:bg-muted/30 transition-colors",children:[(0,l.jsx)("td",{className:"py-3 px-3 font-medium text-foreground",children:h(e.date)}),(0,l.jsx)("td",{className:"py-3 px-3 text-foreground tabular-nums",children:b(e.amountCents)}),(0,l.jsx)("td",{className:"py-3 px-3",children:(0,l.jsx)("span",{className:(0,d.cn)("inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold capitalize",null!=(t=s[e.status])?t:s.draft),children:e.status})}),(0,l.jsx)("td",{className:"py-3 px-3 text-right",children:e.hostedUrl&&(0,l.jsxs)("a",{href:e.hostedUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-base font-medium text-primary hover:underline",children:["View",(0,l.jsx)(m.A,{className:"h-3.5 w-3.5"})]})})]},e.id)})})]})})})]}),w&&(0,l.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,l.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>C(!1)}),(0,l.jsxs)("div",{className:"relative z-10 w-full max-w-3xl mx-4 max-h-[90vh] overflow-y-auto rounded-2xl border border-border bg-card shadow-2xl",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between border-b border-border p-6",children:[(0,l.jsx)("h2",{className:"text-xl font-bold text-foreground",children:"Change Plan"}),(0,l.jsx)("button",{type:"button",onClick:()=>C(!1),className:"flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground",children:(0,l.jsx)(u.A,{className:"h-5 w-5"})})]}),(0,l.jsxs)("div",{className:"p-6",children:[(0,l.jsx)("div",{className:"flex items-center justify-center gap-1.5 mb-6",children:["monthly","yearly"].map(e=>(0,l.jsxs)("button",{type:"button",onClick:()=>I(e),className:(0,d.cn)("rounded-lg border px-4 py-2 text-base font-medium transition-colors capitalize",T===e?"border-primary bg-primary/10 text-primary":"border-border/40 bg-card text-muted-foreground hover:text-foreground hover:bg-muted"),children:[e,"yearly"===e&&(0,l.jsx)("span",{className:"ml-1.5 text-xs text-emerald-600 dark:text-emerald-400 font-semibold",children:"Save ~17%"})]},e))}),P?(0,l.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,l.jsx)(o.A,{className:"w-6 h-6 text-primary animate-spin"})}):0===S.length?(0,l.jsx)("p",{className:"py-12 text-center text-base text-muted-foreground",children:"No plans available. Contact support to change your plan."}):(0,l.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:S.map(e=>{let t="yearly"===T?e.yearlyPriceCents:e.monthlyPriceCents,s=f(e.name),a=(null==R?void 0:R.planName)===e.name&&(null==R?void 0:R.billingCycle)===T,r=M===e.name;return(0,l.jsxs)("button",{type:"button",onClick:()=>U(e.name),disabled:a,className:(0,d.cn)("relative flex flex-col rounded-xl border-2 p-5 text-left transition-all",r&&!a?"border-primary bg-primary/5 shadow-md":a?"border-border/40 bg-muted/50 opacity-70 cursor-default":"border-border/40 hover:border-primary/40 hover:shadow-sm"),children:[a&&(0,l.jsxs)("span",{className:"absolute top-3 right-3 inline-flex items-center gap-1 rounded-full bg-primary/15 px-2 py-0.5 text-xs font-semibold uppercase text-primary",children:[(0,l.jsx)(x.A,{className:"h-3 w-3"})," Current"]}),(0,l.jsx)("span",{className:"text-lg font-bold text-foreground",children:e.displayName}),(0,l.jsx)("span",{className:"mt-2 text-2xl font-bold text-foreground tracking-tight",children:s?"Custom"
1:(0,l.jsxs)(l.Fragment,{children:[b(t),(0,l.jsxs)("span",{className:"text-sm font-normal text-muted-foreground",children:["/","yearly"===T?"yr":"mo"]})]})}),(0,l.jsx)("span",{className:"mt-2 text-xs text-muted-foreground",children:s?"Custom token volume":"".concat(g.format(e.monthlyTokenLimit)," tokens/month")}),e.features&&e.features.length>0&&(0,l.jsx)("ul",{className:"mt-3 space-y-1",children:e.features.map(e=>(0,l.jsxs)("li",{className:"flex items-start gap-1.5 text-xs text-muted-foreground",children:[(0,l.jsx)(x.A,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 mt-0.5"}),e]},e))})]},e.name)})})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-3 border-t border-border p-6",children:[(0,l.jsx)("button",{type:"button",onClick:()=>C(!1),className:"rounded-lg border border-border px-4 py-2 text-base font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:"Cancel"}),(0,l.jsxs)("button",{type:"button",onClick:_,disabled:!M||B||(null==R?void 0:R.planName)===M&&(null==R?void 0:R.billingCycle)===T,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-5 py-2 text-base font-semibold text-primary-foreground shadow-sm hover:bg-primary/90 disabled:opacity-50 transition-colors",children:[B&&(0,l.jsx)(o.A,{className:"h-4 w-4 animate-spin"}),f(M)?"Talk to us":"Confirm Change"]})]})]})]})]})})}},97862:(e,t,s)=>{s.d(t,{TU:()=>d,XZ:()=>o,as:()=>n,cN:()=>m,xp:()=>c});var l=s(7620),a=s(1460);let r={chat:["chat:"],studio:["studio:","studio_kinds:"],work:["work:"],agents:["agents:"],scripts:["scripts:"],dashboards:["dashboards:"],missions:["missions:"],marketplace:["agents:","missions:","marketplace:"],executions:["missions:","executions:"],approvals:["approvals:"],integrations:["integrations:","connectors:"],apps:["integrations:","apps:"],knowledge:["knowledge:"],media:["media:"],memory:["memory:"],notifications:["notifications:","notification-channels:"],usage:["usage:"],audit:["audit:"],settings:["settings:","org:"],security:["security:"],compliance:["compliance:","security:"]};function n(e,t){var s;let l="".concat(t,":");if(e.some(e=>e.startsWith(l)))return!0;for(let l of null!=(s=r[t])?s:[])if(e.some(e=>e.startsWith(l)))return!0;return!1}function i(){var e,t;let{userData:s}=(0,a.As)();return null!=(t=null==s||null==(e=s.user)?void 0:e.permissions)?t:[]}function d(e){return i().includes(e)}function o(e){let t=i();return e.some(e=>t.includes(e))}function c(e){return n(i(),e)}function m(){let e=i();return(0,l.useMemo)(()=>({permissions:e,has:t=>e.includes(t),hasAny:t=>t.some(t=>e.includes(t)),hasAll:t=>t.every(t=>e.includes(t)),hasMenu:t=>n(e,t)}),[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.