@dvina/sdk 5.0.66 → 5.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  import { UIMessage, DefaultChatTransport } from 'ai';
2
- import { D as DvinaSdk, C as ChatMessage, a as ChatMessageConnection } from '../_generated_sdk-BPW4mjon.js';
3
- import '../types-0oS5PBdX.js';
2
+ import { D as DvinaSdk, C as ChatMessage, a as ChatMessageConnection } from '../_generated_sdk-C7xP5IfU.js';
3
+ import '../types-DlNXHZQK.js';
4
4
  import 'graphql';
5
- import '../connection-DUW_YI69.js';
5
+ import '../connection-CajDqrlQ.js';
6
6
  import 'dexie';
7
7
  import '../error-B-z8CPkV.js';
8
8
  import '../billing/index.js';
@@ -39,6 +39,11 @@ type DvinaMessageMetadata = {
39
39
  inResponseToId?: string | null;
40
40
  /** The user inputs this reply consumes together; durable wake-ups use this to avoid answering a batch twice. */
41
41
  answeredUserMessageIds?: string[];
42
+ /**
43
+ * On a user message whose reply the reader deleted while keeping it: when a turn had handled it. It is answered for
44
+ * good: deleting a reply tidies the chat, never asks again (a new answer is a new message).
45
+ */
46
+ handledAt?: string;
42
47
  /** The part of the replied-to message the user answered, as the reply's quote shows it. */
43
48
  inResponseToExcerpt?: string;
44
49
  /** Task chat a supervisor message refers to. */
@@ -161,6 +166,11 @@ type DvinaDataParts = {
161
166
  privacy: {
162
167
  maskedValueCount: number;
163
168
  matchedTypes: string[];
169
+ /** What the model did not see, by kind: the value, or its masked form when masked for good. Older notes have none. */
170
+ maskedValues?: {
171
+ type: string;
172
+ text: string;
173
+ }[];
164
174
  };
165
175
  /** Context the model reads with the user's message but the UI does not show; persisted with the message. */
166
176
  context: {
@@ -242,8 +252,9 @@ type DvinaDataParts = {
242
252
  taskCount?: number;
243
253
  /**
244
254
  * A call Dvina made because the user asked for it ("call me when…"): its reason line and how it went. A ring
245
- * that was answered is the call itself; one missed, declined or held (quiet hours, the day's cap, the user in
246
- * the app) is a quiet line with "Call back" and "Don't call me for this again".
255
+ * that was answered is the call itself; one missed, declined or held (quiet hours, no phone that can ring…) is a
256
+ * quiet line with "Call back" and "Don't call me for this again". `Shown` is only on old lines (a call held while
257
+ * the user was in the app, until 2026-11-12).
247
258
  */
248
259
  incoming?: {
249
260
  /** The call-kind schedule it came from: "Don't call me for this again" cancels it. */
@@ -251,7 +262,7 @@ type DvinaDataParts = {
251
262
  attemptId: string;
252
263
  reason: string;
253
264
  outcome: 'Answered' | 'Declined' | 'Missed' | 'Notified' | 'Shown';
254
- /** Why it did not ring (`quiet-hours`, `daily-cap`, `in-app`…); absent when it rang. */
265
+ /** Why it did not ring (`quiet-hours`, `no-device`…; old lines: `daily-cap`, `in-app`); absent when it rang. */
255
266
  held?: string;
256
267
  /** Its schedule paused after this one (three missed calls in a row). */
257
268
  turnedOff?: boolean;
@@ -279,12 +290,6 @@ type DvinaDataParts = {
279
290
  agentId?: string;
280
291
  agentName?: string;
281
292
  };
282
- /**
283
- * A task's one-line badge on a supervisor message: the message that started it (`delegate`), relayed a user
284
- * message to it (`relay`) or presents its result (`result`); `candidate` is an older "which one?" offer's task,
285
- * drawn as nothing since that question is asked by its card above the composer (2026-11-02). In a chat, a task's latest delegate/relay badge is live and follows the task. An earlier one
286
- * is frozen: it shows the `previous` state of the task's next badge, or its own `state` at `at`.
287
- */
288
293
  /**
289
294
  * A long conversation's checkpoint (agents `Checkpoint`), kept on the reply whose turn wrote it: the summary the
290
295
  * chat's model wrote of the turns before it, and the newest of them as text. The model reads the chat from it on;
@@ -305,12 +310,6 @@ type DvinaDataParts = {
305
310
  'dlp-blocked': {
306
311
  rules: string[];
307
312
  };
308
- /** Older replies: a user reply the supervisor passed to a task chat (now `task-badge`). */
309
- 'task-follow-up': {
310
- chatId: string;
311
- /** The task chat message the reply was passed as; the task's reply answers it (`metadata.inResponseToId`). */
312
- messageId?: string;
313
- };
314
313
  /** A task chat's live progress line in the user's language, updated in place after each step. */
315
314
  narration: {
316
315
  text: string;
@@ -511,8 +510,35 @@ type DvinaMessageLinks = {
511
510
  inResponseToId?: string | null;
512
511
  referencedChatId?: string | null;
513
512
  };
514
- /** replyTargetSteps over the messages in hand: `links` reads one by id (undefined when it is not there). */
513
+ /**
514
+ * replyTargetSteps over the messages in hand: `links` reads one by id (undefined when it is not there).
515
+ * @deprecated Kept for SDK consumers; the app no longer reads a reply's task itself. Send the reply with
516
+ * `metadata.inResponseToId` (and `inResponseToTaskChatId` when it names a task): the API routes it (TaskChats.replyTarget).
517
+ */
515
518
  declare function replyTargetIn(message: DvinaUIMessage | undefined, links: (messageId: string) => DvinaMessageLinks | null | undefined): string | undefined;
519
+ /**
520
+ * Whether a tool part's output was replaced by a later version of it (`callProviderMetadata.dvina.updated`, written
521
+ * by the task's One Chat writes): the app marks it "Updated". Only tool parts carry call metadata.
522
+ */
523
+ declare function wasUpdated(part: object): boolean;
524
+ /** A task's state, in Claude's few words (task core v2 plan §3a). */
525
+ type DvinaTaskState = 'starting' | 'working' | 'waiting' | 'ready' | 'done' | 'stopped';
526
+ /** The lifecycle columns of a task's Chat row its state is read from (dates as the API or the SDK hold them). */
527
+ type DvinaTaskRow = {
528
+ busyAt?: Date | string | null;
529
+ idleAt?: Date | string | null;
530
+ idleOutcome?: string | null;
531
+ queuedAt?: Date | string | null;
532
+ waitingOn?: unknown;
533
+ };
534
+ /**
535
+ * A task's state from its own rows only, the one rule the API and the app both read it by: its Chat's lifecycle and
536
+ * its TaskJob's status. `jobStatus` is `null` when the task is known to have no TaskJob, `undefined` while that is not
537
+ * known yet (the app before its jobs load). Every run of a task has its TaskJob, so with none running an old row's busy
538
+ * or queued mark (a run cut before task core v2, a turn parked after its last try) is not a run: the task reads as
539
+ * ended. A failure reads as done; its note says what happened.
540
+ */
541
+ declare function taskStateOf(chat: DvinaTaskRow, jobStatus: string | null | undefined): DvinaTaskState;
516
542
 
517
543
  type DvinaChatTransportOptions = {
518
544
  /** API origin including protocol, e.g. `https://api.dvina.ai`. */
@@ -545,7 +571,7 @@ declare function createDvinaChatTransport(options: DvinaChatTransportOptions): D
545
571
  declare function createDvinaTemporaryChatTransport(options: DvinaChatTransportOptions): DefaultChatTransport<DvinaUIMessage>;
546
572
 
547
573
  /** The chat actions of the SDK, as the functions below call them. */
548
- type DvinaChatActionsSdk = Pick<DvinaSdk, 'sendChatMessageWhileRunning' | 'chatNextPrompt' | 'stopChat' | 'grantChatApproval' | 'respondChatApproval' | 'answerChatQuestion' | 'startChatDay'>;
574
+ type DvinaChatActionsSdk = Pick<DvinaSdk, 'sendChatMessageWhileRunning' | 'chatNextPrompt' | 'stopChat' | 'respondChatApproval' | 'answerChatQuestion' | 'answerChatToolCall' | 'startChatDay'>;
549
575
  /**
550
576
  * Sends a user message while the chat's turn runs: the server stores it at once (every device shows it) and answers it
551
577
  * with the chat's next turn, without cutting the running reply off. Sending it again under the same id changes nothing,
@@ -560,23 +586,27 @@ declare function postDvinaChatMessage(sdk: DvinaChatActionsSdk, chatId: string,
560
586
  declare function fetchDvinaNextPrompt(sdk: DvinaChatActionsSdk, chatId: string): Promise<string | null>;
561
587
  /** Stops the chat's running turn on the server; streaming clients then finish normally. */
562
588
  declare function stopDvinaChat(sdk: DvinaChatActionsSdk, chatId: string): Promise<void>;
563
- /**
564
- * Lets a task do this tool from now on without asking (its later approvals for the tool pass on the server); the
565
- * approval waiting now is still answered as usual. Only the caller's own task chats, only tools that ask.
566
- */
567
- declare function grantDvinaTaskApproval(sdk: DvinaChatActionsSdk, taskChatId: string, toolName: string): Promise<void>;
568
589
  /** What became of an answer given outside the chat: sent, or the chat no longer waited for it (answered elsewhere). */
569
590
  type DvinaAnswerOutcome = 'sent' | 'answered-elsewhere';
570
591
  /**
571
- * Answers a chat's waiting approval from outside the chat (a notification), as the chat's own card does; `always`
572
- * also allows the tool for the chat from now on. The turn continues on the server.
592
+ * Answers a chat's waiting approval from outside the chat (a notification), as the chat's own card does. The turn
593
+ * continues on the server.
573
594
  */
574
595
  declare function respondDvinaApproval(sdk: DvinaChatActionsSdk, chatId: string, toolCallId: string, answer: {
575
596
  approved: boolean;
576
- always?: boolean;
577
597
  }): Promise<DvinaAnswerOutcome>;
578
598
  /** Answers a chat's waiting question from outside the chat (a notification's reply): one answer list per question. */
579
599
  declare function answerDvinaQuestion(sdk: DvinaChatActionsSdk, chatId: string, toolCallId: string, answers: string[][]): Promise<DvinaAnswerOutcome>;
600
+ /**
601
+ * Answers a chat's waiting client tool call (a question, a project choice, a voice request) from outside the chat, with
602
+ * its output, or ends it with an error (a dismissed question), as AI SDK's `addToolOutput` does in the chat itself. The
603
+ * server applies it under the reply's lock, so answers given at once on two devices both land.
604
+ */
605
+ declare function answerDvinaToolCall(sdk: DvinaChatActionsSdk, chatId: string, toolCallId: string, answer: {
606
+ output: unknown;
607
+ } | {
608
+ errorText: string;
609
+ }): Promise<DvinaAnswerOutcome>;
580
610
  /**
581
611
  * Starts the reader's day (their local day, from `x-user-timezone`) as the app opens or comes to the foreground: the
582
612
  * day's first call queues its work (pending day digests, the cards kept for the morning, the night's ideas); later
@@ -607,12 +637,17 @@ type DvinaMessagePage = {
607
637
  };
608
638
  /** A `chatMessages` or `chatMessagesAround` connection, oldest first, as a page of AI SDK messages. */
609
639
  declare function dvinaMessagePageOf(connection: Pick<ChatMessageConnection, 'nodes' | 'pageInfo'>): DvinaMessagePage;
610
- /** The most the API gives in one page (`first` and `last` are capped there). */
640
+ /**
641
+ * The most the API gives in one page (`first` and `last` are capped there).
642
+ * @deprecated Only fetchAllDvinaChatMessages reads it; page with `chatMessages` and dvinaMessagePageOf.
643
+ */
611
644
  declare const MAX_MESSAGE_PAGE = 200;
612
645
  /**
613
646
  * A whole chat, or one thread of it with the message it started from, oldest first: `chatMessages` read forward
614
647
  * (`first` + `after`) page by page to the end. For short reads such as a thread or a task chat; long chats load by
615
648
  * page. Each page is a one-off fetch, never a watch. A chat the caller may not read, or one not created yet, has none.
649
+ * @deprecated A one-off read of every page goes stale at once. Watch the chat's pages instead: `sdk.chatMessages(...)`
650
+ * with `.watch()` (or the React `useLiveQuery`), each page through dvinaMessagePageOf.
616
651
  */
617
652
  declare function fetchAllDvinaChatMessages(sdk: Pick<DvinaSdk, 'chatMessages'>, scope: {
618
653
  chatId: string;
@@ -633,4 +668,4 @@ type DvinaLazyToolOutput = {
633
668
  /** The held-back output a tool part carries instead of its output, or `null` for a whole output. */
634
669
  declare function lazyToolOutputOf(output: unknown): DvinaLazyToolOutput | null;
635
670
 
636
- export { type DvinaAnswerOutcome, type DvinaChatActionsSdk, type DvinaChatMessageNode, type DvinaChatTransportOptions, type DvinaDataParts, type DvinaGoal, type DvinaGoalCriterion, type DvinaGoalEvaluation, type DvinaGoalStatus, type DvinaLazyToolOutput, type DvinaMessageLinks, type DvinaMessageMetadata, type DvinaMessagePage, type DvinaMessageRoute, type DvinaToolMetadata, type DvinaUIMessage, LIVE_FILE_FORMATS, MAX_MESSAGE_PAGE, answerDvinaQuestion, createDvinaChatTransport, createDvinaTemporaryChatTransport, dvinaMessagePageOf, dvinaUIMessageOf, fetchAllDvinaChatMessages, fetchDvinaNextPrompt, grantDvinaTaskApproval, lazyToolOutputOf, postDvinaChatMessage, replyTargetIn, respondDvinaApproval, startDvinaDay, stopDvinaChat };
671
+ export { type DvinaAnswerOutcome, type DvinaChatActionsSdk, type DvinaChatMessageNode, type DvinaChatTransportOptions, type DvinaDataParts, type DvinaGoal, type DvinaGoalCriterion, type DvinaGoalEvaluation, type DvinaGoalStatus, type DvinaLazyToolOutput, type DvinaMessageLinks, type DvinaMessageMetadata, type DvinaMessagePage, type DvinaMessageRoute, type DvinaTaskRow, type DvinaTaskState, type DvinaToolMetadata, type DvinaUIMessage, LIVE_FILE_FORMATS, MAX_MESSAGE_PAGE, answerDvinaQuestion, answerDvinaToolCall, createDvinaChatTransport, createDvinaTemporaryChatTransport, dvinaMessagePageOf, dvinaUIMessageOf, fetchAllDvinaChatMessages, fetchDvinaNextPrompt, lazyToolOutputOf, postDvinaChatMessage, replyTargetIn, respondDvinaApproval, startDvinaDay, stopDvinaChat, taskStateOf, wasUpdated };
package/dist/ai/index.js CHANGED
@@ -1 +1 @@
1
- import {a}from'../chunk-32KGDH2Q.js';import {b as b$1,c as c$1}from'../chunk-YQD7354H.js';import'../chunk-EK7ODJWE.js';import {DefaultChatTransport}from'ai';var v={html:"html",htm:"html",md:"markdown",markdown:"markdown",csv:"csv",svg:"svg",mmd:"mermaid",mermaid:"mermaid"},k=2;function*w(e,{named:t=true}={}){if(e?.role!=="user")return;if(t&&e.metadata?.inResponseToTaskChatId)return e.metadata.inResponseToTaskChatId;let n=e.metadata?.inResponseToId??void 0;for(let a=0;n&&a<k;a++){let r=yield n;if(r?.referencedChatId)return r.referencedChatId;n=r?.inResponseToId??void 0;}}function f(e,t){let n=w(e),a=n.next();for(;!a.done;)a=n.next(t(a.value));return a.value}function S(e){let t=`${e.apiUrl.replace(/\/+$/,"")}/api/chat`;return new DefaultChatTransport({api:t,fetch:D(b(e)),prepareSendMessagesRequest:({id:n,messages:a,trigger:r,messageId:o,body:s})=>({api:`${t}/${encodeURIComponent(n)}`,body:{...s,trigger:r,messageId:o,message:a[a.length-1]}}),prepareReconnectToStreamRequest:({id:n})=>({api:`${t}/${encodeURIComponent(n)}/stream`})})}function R(e){return new DefaultChatTransport({api:`${e.apiUrl.replace(/\/+$/,"")}/api/temporary-chat`,fetch:D(b(e))})}var _=[1e3,2e3,4e3,8e3,15e3,3e4],E=429,P=6e4;function D(e,t=_,n=[503]){return async(a,r)=>{for(let o of t){let s=await e(a,r).catch(u=>{if(r?.signal?.aborted||!(u instanceof TypeError))throw u;return null}),i=s?.status===E;if(s&&!i&&!n.includes(s.status))return s;await s?.body?.cancel().catch(()=>{}),await U(i?O(s,o):o,r?.signal??void 0);}return e(a,r)}}function O(e,t){let n=Number.NaN;return e.headers.forEach((a,r)=>{Number.isNaN(n)&&r.toLowerCase().startsWith("retry-after")&&(n=Number(a));}),Number.isFinite(n)&&n>0?Math.min(Math.max(n*1e3,t),P):t}function U(e,t){return new Promise((n,a)=>{if(t?.aborted)return a(t.reason);let r=setTimeout(()=>{t?.removeEventListener("abort",o),n();},e),o=()=>{clearTimeout(r),a(t?.reason);};t?.addEventListener("abort",o,{once:true});})}var N=a();function b(e){let t=e.fetch??globalThis.fetch.bind(globalThis),n=async(a,r,o)=>{let s=new Headers(r?.headers);s.set("Authorization",`Bearer ${await e.getToken({forceRefresh:o})}`);let i=N();i&&!s.has("x-user-timezone")&&s.set("x-user-timezone",i);let u=e.getLanguage?.();return u&&!s.has("x-preferred-language")&&s.set("x-preferred-language",u),t(a,{...r,headers:s})};return async(a,r)=>{let o=await n(a,r,false);return o.status===401?n(a,r,true):o}}async function L(e,t,n,a){await d(()=>e.sendChatMessageWhileRunning({chatId:t,message:n}),{statuses:V,rateLimited:true,signal:a});}async function G(e,t){let n=await d(()=>e.chatNextPrompt({chatId:t}),{delaysMs:[1e3,3e3]});return typeof n=="string"&&n.trim()?n:null}async function z(e,t){await d(()=>e.stopChat({chatId:t}),{statuses:l});}async function j(e,t,n){await d(()=>e.grantChatApproval({chatId:t,toolName:n}),{statuses:l,signal:AbortSignal.timeout(x)});}function F(e,t,n,a){return M(()=>e.respondChatApproval({chatId:t,toolCallId:n,approved:a.approved,always:a.always}))}function Y(e,t,n,a){return M(()=>e.answerChatQuestion({chatId:t,toolCallId:n,answers:a}))}async function W(e){return {started:await e.startChatDay()}}async function M(e){try{return await d(e,{statuses:l,signal:AbortSignal.timeout(x)}),"sent"}catch(t){if($(t))return "answered-elsewhere";throw t}}function $(e){return e instanceof b$1&&e.errors.some(t=>t.message===y||t.extensions?.code===y)}var y="NOT_WAITING";function Q(e){return e instanceof c$1?e.status===T:e instanceof b$1&&e.errors.some(t=>/ThrottlerException|Too Many Requests/i.test(t.message)||t.extensions?.code==="TOO_MANY_REQUESTS"||t.extensions?.originalError?.statusCode===T)}var q=[1e3,2e3,4e3,8e3,15e3,3e4],B=[503],V=[500,502,503,504],T=429,l=[502,503,504],x=9e4,C=0;async function d(e,{delaysMs:t=q,statuses:n=B,rateLimited:a=false,signal:r}={}){let o=s=>s instanceof c$1&&(s.status===C||n.includes(s.status??C))||a&&Q(s);for(let s of t){try{return await I(e(),r)}catch(i){if(r?.aborted||!o(i))throw i}await H(s,r);}return I(e(),r)}function I(e,t){return t?t.aborted?Promise.reject(t.reason):new Promise((n,a)=>{let r=()=>a(t.reason);t.addEventListener("abort",r,{once:true}),e.then(n,a).finally(()=>t.removeEventListener("abort",r));}):e}function H(e,t){return new Promise((n,a)=>{if(t?.aborted)return a(t.reason);let r=setTimeout(()=>{t?.removeEventListener("abort",o),n();},e),o=()=>{clearTimeout(r),a(t?.reason);};t?.addEventListener("abort",o,{once:true});})}function c(e){return {id:e.id,role:e.role,parts:e.parts??[],...e.metadata?{metadata:e.metadata}:{}}}function X(e){let{pageInfo:t}=e;return {messages:e.nodes.map(c),hasOlder:t.hasPreviousPage,hasNewer:t.hasNextPage,...t.startCursor?{startCursor:t.startCursor}:{},...t.endCursor?{endCursor:t.endCursor}:{}}}var A=200;async function K(e,t,{pageSize:n=A}={}){let a=[],r;for(;;){let o=await e.chatMessages({...t,first:n,after:r}).fetch();a.push(...o.nodes.map(c));let s=o.pageInfo.endCursor??void 0;if(!o.pageInfo.hasNextPage||!s||s===r)return a;r=s;}}function J(e){if(!e||typeof e!="object"||!("dvinaLazyOutput"in e))return null;let t=e.dvinaLazyOutput;if(!t||typeof t!="object")return null;let{bytes:n,preview:a,urls:r}=t;return {bytes:typeof n=="number"?n:0,preview:typeof a=="string"?a:"",urls:Array.isArray(r)?r.filter(o=>typeof o=="string"):[]}}export{v as LIVE_FILE_FORMATS,A as MAX_MESSAGE_PAGE,Y as answerDvinaQuestion,S as createDvinaChatTransport,R as createDvinaTemporaryChatTransport,X as dvinaMessagePageOf,c as dvinaUIMessageOf,K as fetchAllDvinaChatMessages,G as fetchDvinaNextPrompt,j as grantDvinaTaskApproval,J as lazyToolOutputOf,L as postDvinaChatMessage,f as replyTargetIn,F as respondDvinaApproval,W as startDvinaDay,z as stopDvinaChat};
1
+ import {a}from'../chunk-32KGDH2Q.js';import {b as b$1,c as c$1}from'../chunk-YQD7354H.js';import'../chunk-EK7ODJWE.js';import {DefaultChatTransport}from'ai';var D={html:"html",htm:"html",md:"markdown",markdown:"markdown",csv:"csv",svg:"svg",mmd:"mermaid",mermaid:"mermaid"},S=2;function*E(e,{named:t=true}={}){if(e?.role!=="user")return;if(t&&e.metadata?.inResponseToTaskChatId)return e.metadata.inResponseToTaskChatId;let n=e.metadata?.inResponseToId??void 0;for(let a=0;n&&a<S;a++){let r=yield n;if(r?.referencedChatId)return r.referencedChatId;n=r?.inResponseToId??void 0;}}function y(e,t){let n=E(e),a=n.next();for(;!a.done;)a=n.next(t(a.value));return a.value}function b(e){return e.callProviderMetadata?.dvina?.updated===true}function T(e,t){if(e.waitingOn)return "waiting";let n=t===void 0||t==="running",a=r=>r?new Date(r).getTime():0;return n&&e.busyAt&&(!e.idleAt||a(e.busyAt)>a(e.idleAt))?"working":n&&e.queuedAt?"starting":t&&t!=="running"?"ready":e.idleOutcome==="interrupted"?"stopped":"done"}function _(e){let t=`${e.apiUrl.replace(/\/+$/,"")}/api/chat`;return new DefaultChatTransport({api:t,fetch:M(I(e)),prepareSendMessagesRequest:({id:n,messages:a,trigger:r,messageId:i,body:s})=>({api:`${t}/${encodeURIComponent(n)}`,body:{...s,trigger:r,messageId:i,message:a[a.length-1]}}),prepareReconnectToStreamRequest:({id:n})=>({api:`${t}/${encodeURIComponent(n)}/stream`})})}function O(e){return new DefaultChatTransport({api:`${e.apiUrl.replace(/\/+$/,"")}/api/temporary-chat`,fetch:M(I(e))})}var m=[1e3,2e3,4e3,8e3,15e3,3e4],u=429,P=6e4;function M(e,t=m,n=[503]){return async(a,r)=>{for(let i of t){let s=await e(a,r).catch(d=>{if(r?.signal?.aborted||!(d instanceof TypeError))throw d;return null}),o=s?.status===u;if(s&&!o&&!n.includes(s.status))return s;await s?.body?.cancel().catch(()=>{}),await c(o?U(s,i):i,r?.signal??void 0);}return e(a,r)}}function U(e,t){let n=Number.NaN;return e.headers.forEach((a,r)=>{Number.isNaN(n)&&r.toLowerCase().startsWith("retry-after")&&(n=Number(a));}),Number.isFinite(n)&&n>0?Math.min(Math.max(n*1e3,t),P):t}function c(e,t){return new Promise((n,a)=>{if(t?.aborted)return a(t.reason);let r=setTimeout(()=>{t?.removeEventListener("abort",i),n();},e),i=()=>{clearTimeout(r),a(t?.reason);};t?.addEventListener("abort",i,{once:true});})}var N=a();function I(e){let t=e.fetch??globalThis.fetch.bind(globalThis),n=async(a,r,i)=>{let s=new Headers(r?.headers);s.set("Authorization",`Bearer ${await e.getToken({forceRefresh:i})}`);let o=N();o&&!s.has("x-user-timezone")&&s.set("x-user-timezone",o);let d=e.getLanguage?.();return d&&!s.has("x-preferred-language")&&s.set("x-preferred-language",d),t(a,{...r,headers:s})};return async(a,r)=>{let i=await n(a,r,false);return i.status===401?n(a,r,true):i}}async function L(e,t,n,a){await g(()=>e.sendChatMessageWhileRunning({chatId:t,message:n}),{statuses:V,rateLimited:true,signal:a});}async function G(e,t){let n=await g(()=>e.chatNextPrompt({chatId:t}),{delaysMs:[1e3,3e3]});return typeof n=="string"&&n.trim()?n:null}async function z(e,t){await g(()=>e.stopChat({chatId:t}),{statuses:A});}function j(e,t,n,a){return f(()=>e.respondChatApproval({chatId:t,toolCallId:n,approved:a.approved}))}function F(e,t,n,a){return f(()=>e.answerChatQuestion({chatId:t,toolCallId:n,answers:a}))}function Y(e,t,n,a){return f(()=>e.answerChatToolCall({chatId:t,toolCallId:n,...a}))}async function W(e){return {started:await e.startChatDay()}}async function f(e){try{return await g(e,{statuses:A,signal:AbortSignal.timeout(B)}),"sent"}catch(t){if($(t))return "answered-elsewhere";throw t}}function $(e){return e instanceof b$1&&e.errors.some(t=>t.message===w||t.extensions?.code===w)}var w="NOT_WAITING";function Q(e){return e instanceof c$1?e.status===u:e instanceof b$1&&e.errors.some(t=>/ThrottlerException|Too Many Requests/i.test(t.message)||t.extensions?.code==="TOO_MANY_REQUESTS"||t.extensions?.originalError?.statusCode===u)}var q=[503],V=[500,502,503,504],A=[502,503,504],B=9e4,x=0;async function g(e,{delaysMs:t=m,statuses:n=q,rateLimited:a=false,signal:r}={}){let i=s=>s instanceof c$1&&(s.status===x||n.includes(s.status??x))||a&&Q(s);for(let s of t){try{return await k(e(),r)}catch(o){if(r?.aborted||!i(o))throw o}await c(s,r);}return k(e(),r)}function k(e,t){return t?t.aborted?Promise.reject(t.reason):new Promise((n,a)=>{let r=()=>a(t.reason);t.addEventListener("abort",r,{once:true}),e.then(n,a).finally(()=>t.removeEventListener("abort",r));}):e}function v(e){return {id:e.id,role:e.role,parts:e.parts??[],...e.metadata?{metadata:e.metadata}:{}}}function H(e){let{pageInfo:t}=e;return {messages:e.nodes.map(v),hasOlder:t.hasPreviousPage,hasNewer:t.hasNextPage,...t.startCursor?{startCursor:t.startCursor}:{},...t.endCursor?{endCursor:t.endCursor}:{}}}var R=200;async function X(e,t,{pageSize:n=R}={}){let a=[],r;for(;;){let i=await e.chatMessages({...t,first:n,after:r}).fetch();a.push(...i.nodes.map(v));let s=i.pageInfo.endCursor??void 0;if(!i.pageInfo.hasNextPage||!s||s===r)return a;r=s;}}function K(e){if(!e||typeof e!="object"||!("dvinaLazyOutput"in e))return null;let t=e.dvinaLazyOutput;if(!t||typeof t!="object")return null;let{bytes:n,preview:a,urls:r}=t;return {bytes:typeof n=="number"?n:0,preview:typeof a=="string"?a:"",urls:Array.isArray(r)?r.filter(i=>typeof i=="string"):[]}}export{D as LIVE_FILE_FORMATS,R as MAX_MESSAGE_PAGE,F as answerDvinaQuestion,Y as answerDvinaToolCall,_ as createDvinaChatTransport,O as createDvinaTemporaryChatTransport,H as dvinaMessagePageOf,v as dvinaUIMessageOf,X as fetchAllDvinaChatMessages,G as fetchDvinaNextPrompt,K as lazyToolOutputOf,L as postDvinaChatMessage,y as replyTargetIn,j as respondDvinaApproval,W as startDvinaDay,z as stopDvinaChat,T as taskStateOf,b as wasUpdated};
@@ -1 +1 @@
1
- export{j as BillingClient,f as CancelReason,g as EntitlementTier,h as SubscriptionCycle,i as SubscriptionProvider}from'../chunk-XTZRMWVM.js';import'../chunk-YQD7354H.js';import'../chunk-EK7ODJWE.js';
1
+ export{k as BillingClient,g as CancelReason,h as EntitlementTier,i as SubscriptionCycle,j as SubscriptionProvider}from'../chunk-3AC3GJMQ.js';import'../chunk-YQD7354H.js';import'../chunk-EK7ODJWE.js';
@@ -1,11 +1,11 @@
1
- import {g as g$1,d,c,a,l,e}from'./chunk-YQD7354H.js';var F=new WeakMap;async function x(e,n){let t=F.get(e);if(!t){let a=e({forceRefresh:true}).finally(()=>{F.get(e)===a&&F.delete(e);});F.set(e,a),t=a;}let i=await t;if(n&&i===n)throw new d("Token refresh did not produce a new token",n);return i}var qe=1e3,Z=1e3,Be=3,je=3e4;function He(e,n=Math.random){return Math.floor(n()*e)}function Ge(e){return e instanceof Error&&e.name==="AbortError"}function Q(){return Date.now()}var R=class{constructor(n){this.options=n;}abortController;abortReason;attemptPromise;closed=false;consecutiveAuthFailures=0;forceRefreshNext=false;lastActivityAt=null;lastConnectedAt=null;lastError;reconnectAttempt=0;reconnectTimer;restartAfterCurrentAttempt=false;state="idle";staleTimer;shouldRun=false;get snapshot(){return {consecutiveAuthFailures:this.consecutiveAuthFailures,id:this.options.id,kind:this.options.kind,lastActivityAt:this.lastActivityAt,lastConnectedAt:this.lastConnectedAt,lastError:this.lastError,reconnectAttempt:this.reconnectAttempt,state:this.state}}async start(){if(this.closed)throw new Error(`Connection '${this.options.kind}:${this.options.id}' is closed`);return this.shouldRun=true,this.clearReconnectTimer(),this.attemptPromise&&this.abortReason&&(this.restartAfterCurrentAttempt=true),this.ensureAttempt()}stop(){this.shouldRun=false,this.restartAfterCurrentAttempt=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.abort("manual"),this.setState("idle");}close(){this.closed=true,this.shouldRun=false,this.restartAfterCurrentAttempt=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.abort("manual"),this.setState("closed");}reconnect(){if(!(this.closed||this.isHealthy()||this.state==="connecting")){if(this.shouldRun=true,this.clearReconnectTimer(),this.clearStaleTimer(),this.abortController){this.restartAfterCurrentAttempt=true,this.abort("restart");return}this.ensureAttempt();}}ensureAttempt(){if(!this.shouldRun||this.closed)return Promise.resolve();if(!this.attemptPromise){let n=this.runAttempt().finally(()=>{this.attemptPromise===n&&(this.attemptPromise=void 0),this.restartAfterCurrentAttempt&&this.shouldRun&&!this.closed&&(this.restartAfterCurrentAttempt=false,this.ensureAttempt());});this.attemptPromise=n;}return this.attemptPromise}async runAttempt(){if(!this.shouldRun||this.closed)return;let n=this.lastConnectedAt!==null||this.reconnectAttempt>0;this.setState("connecting"),this.lastError=void 0,this.abortReason=void 0;let t=new AbortController;this.abortController=t;try{let i=this.forceRefreshNext?await x(this.options.getToken):await this.options.getToken(void 0);if(this.forceRefreshNext=!1,await this.options.dial({isReconnect:n,markActivity:()=>this.markActivity(),markConnected:()=>this.markConnected(),requestTokenRefresh:()=>{this.forceRefreshNext=!0;},signal:t.signal,token:i}),!this.shouldRun||this.closed)return;this.scheduleReconnect("end");}catch(i){if(Ge(i)){this.abortReason==="stale"&&this.shouldRun&&!this.closed&&this.scheduleReconnect("end");return}if(!this.shouldRun||this.closed)return;this.handleFailure(i);}finally{this.abortController===t&&(this.abortController=void 0),this.abortReason=void 0;}}handleFailure(n){if(this.lastError=n,n instanceof d||this.options.isFatalError?.(n)){this.shouldRun=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.setState("failed"),this.options.onFatalError?.(n);return}if(this.options.isAuthError?.(n)??false){if(this.consecutiveAuthFailures+=1,this.forceRefreshNext=true,this.setState("reconnecting"),this.consecutiveAuthFailures>=(this.options.maxConsecutiveAuthFailures??Be)){this.shouldRun=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.setState("failed"),this.options.onFatalError?.(n);return}this.scheduleReconnect("auth");return}this.consecutiveAuthFailures=0,typeof navigator<"u"&&"onLine"in navigator&&navigator.onLine===false?this.setState("offline"):this.setState("reconnecting"),this.scheduleReconnect("failure");}scheduleReconnect(n){if(!this.shouldRun||this.closed)return;this.clearReconnectTimer(),this.clearStaleTimer();let t=n==="auth"?this.options.authRetryDelayMs??qe:n==="failure"?this.nextReconnectDelay():this.options.baseReconnectDelayMs??Z;this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.ensureAttempt();},t);}nextReconnectDelay(){let n=this.options.baseReconnectDelayMs??Z,t=this.options.maxReconnectDelayMs??je,i=Math.min(n*Math.pow(2,this.reconnectAttempt),t);return this.reconnectAttempt+=1,this.options.jitter==="full"?He(i):i}isHealthy(){if(this.state!=="connected"||!this.abortController)return false;let n=this.options.staleTimeoutMs;return !n||n<=0?true:this.lastActivityAt!==null&&Q()-this.lastActivityAt<n}markConnected(){this.consecutiveAuthFailures=0,this.reconnectAttempt=0,this.lastConnectedAt=Q(),this.setState("connected"),this.markActivity();}markActivity(){this.lastActivityAt=Q(),this.armStaleTimer();}armStaleTimer(){this.clearStaleTimer();let n=this.options.staleTimeoutMs;!n||n<=0||this.state!=="connected"||(this.staleTimer=setTimeout(()=>{!this.shouldRun||this.closed||!this.abortController||(this.setState("stale"),this.abort("stale"));},n));}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0);}clearStaleTimer(){this.staleTimer&&(clearTimeout(this.staleTimer),this.staleTimer=void 0);}abort(n){this.abortController&&(this.abortReason=n,this.abortController.abort(),this.abortController=void 0);}setState(n){this.state!==n&&(this.state=n,this.options.onStateChange?.(this.snapshot));}};var Ye=(c=>(c.HitLimits="HIT_LIMITS",c.MissingFeature="MISSING_FEATURE",c.NotUsing="NOT_USING",c.Other="OTHER",c.Quality="QUALITY",c.Switching="SWITCHING",c.TooExpensive="TOO_EXPENSIVE",c))(Ye||{}),We=(o=>(o.Enterprise="enterprise",o.Free="free",o.Max="max",o.Plus="plus",o.Pro="pro",o))(We||{}),ze=(a=>(a.Daily="DAILY",a.Monthly="MONTHLY",a.Weekly="WEEKLY",a.Yearly="YEARLY",a))(ze||{}),Xe=(t=>(t.Revcat="REVCAT",t.Stripe="STRIPE",t))(Xe||{});var K={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Plans"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"plans"},selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"PlanFragment"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"PlanFragment"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"Plan"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"prices"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"currency"}},{kind:"Field",name:{kind:"Name",value:"amount"}},{kind:"Field",name:{kind:"Name",value:"interval"}},{kind:"Field",name:{kind:"Name",value:"campaign"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"originalAmount"}},{kind:"Field",name:{kind:"Name",value:"discountedAmount"}},{kind:"Field",name:{kind:"Name",value:"percentOff"}},{kind:"Field",name:{kind:"Name",value:"expiresAt"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"entitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}},{kind:"Field",name:{kind:"Name",value:"features"}}]}}]},ee={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Plan"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"plan"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"PlanFragment"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"PlanFragment"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"Plan"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"prices"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"currency"}},{kind:"Field",name:{kind:"Name",value:"amount"}},{kind:"Field",name:{kind:"Name",value:"interval"}},{kind:"Field",name:{kind:"Name",value:"campaign"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"originalAmount"}},{kind:"Field",name:{kind:"Name",value:"discountedAmount"}},{kind:"Field",name:{kind:"Name",value:"percentOff"}},{kind:"Field",name:{kind:"Name",value:"expiresAt"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"entitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}},{kind:"Field",name:{kind:"Name",value:"features"}}]}}]},ne={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"TierOrders"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tierOrders"}}]}}]},te={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Entitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"entitlements"}}]}}]},ie={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Subscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"provider"}},{kind:"Field",name:{kind:"Name",value:"cycle"}},{kind:"Field",name:{kind:"Name",value:"seats"}},{kind:"Field",name:{kind:"Name",value:"cancelAtPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodStart"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"pausedUntil"}},{kind:"Field",name:{kind:"Name",value:"scheduledChange"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"effectiveDate"}},{kind:"Field",name:{kind:"Name",value:"newTier"}},{kind:"Field",name:{kind:"Name",value:"newSeats"}},{kind:"Field",name:{kind:"Name",value:"newCycle"}}]}}]}}]}}]},ae={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SubscriptionForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscriptionForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"provider"}},{kind:"Field",name:{kind:"Name",value:"cycle"}},{kind:"Field",name:{kind:"Name",value:"seats"}},{kind:"Field",name:{kind:"Name",value:"cancelAtPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodStart"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"scheduledChange"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"effectiveDate"}},{kind:"Field",name:{kind:"Name",value:"newTier"}},{kind:"Field",name:{kind:"Name",value:"newSeats"}},{kind:"Field",name:{kind:"Name",value:"newCycle"}}]}}]}}]}}]},re={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SubscriptionEntitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscriptionEntitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}}]}}]},oe={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SubscriptionEntitlementsForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscriptionEntitlementsForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}}]}}]},se={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ProrationAmount"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"prorationAmount"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},le={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"UpgradePlan"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"upgradePlan"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},ue={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DowngradePlan"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"downgradePlan"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},ce={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"AddSeats"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"additionalSeats"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"addSeats"},arguments:[{kind:"Argument",name:{kind:"Name",value:"additionalSeats"},value:{kind:"Variable",name:{kind:"Name",value:"additionalSeats"}}}]}]}}]},de={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ChangeBillingCycle"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"changeBillingCycle"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},me={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"RemoveSeats"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"seatsToRemove"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"removeSeats"},arguments:[{kind:"Argument",name:{kind:"Name",value:"seatsToRemove"},value:{kind:"Variable",name:{kind:"Name",value:"seatsToRemove"}}}]}]}}]},pe={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelSubscription"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"reason"}},type:{kind:"NamedType",name:{kind:"Name",value:"CancelReason"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"comment"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancelSubscription"},arguments:[{kind:"Argument",name:{kind:"Name",value:"reason"},value:{kind:"Variable",name:{kind:"Name",value:"reason"}}},{kind:"Argument",name:{kind:"Name",value:"comment"},value:{kind:"Variable",name:{kind:"Name",value:"comment"}}}]}]}}]},ke={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"RetentionOffers"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"retentionOffers"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"pauseDays"}},{kind:"Field",name:{kind:"Name",value:"discountPercent"}},{kind:"Field",name:{kind:"Name",value:"discountMonths"}}]}}]}}]},Se={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"PauseSubscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"pauseSubscription"}}]}}]},ye={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ApplyRetentionDiscount"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"applyRetentionDiscount"}}]}}]},fe={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ReactivateSubscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"reactivateSubscription"}}]}}]},ve={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelSubscriptionForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancelSubscriptionForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}]}]}}]},he={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ReactivateSubscriptionForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"reactivateSubscriptionForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}]}]}}]},be={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateCustomer"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"name"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"email"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"userId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createCustomer"},arguments:[{kind:"Argument",name:{kind:"Name",value:"name"},value:{kind:"Variable",name:{kind:"Name",value:"name"}}},{kind:"Argument",name:{kind:"Name",value:"email"},value:{kind:"Variable",name:{kind:"Name",value:"email"}}},{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}},{kind:"Argument",name:{kind:"Name",value:"userId"},value:{kind:"Variable",name:{kind:"Name",value:"userId"}}}]}]}}]},ge={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ReleaseSchedule"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"releaseSchedule"}}]}}]},Ne={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateCheckoutSession"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"priceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"successUrl"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"cancelUrl"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createCheckoutSession"},arguments:[{kind:"Argument",name:{kind:"Name",value:"priceId"},value:{kind:"Variable",name:{kind:"Name",value:"priceId"}}},{kind:"Argument",name:{kind:"Name",value:"successUrl"},value:{kind:"Variable",name:{kind:"Name",value:"successUrl"}}},{kind:"Argument",name:{kind:"Name",value:"cancelUrl"},value:{kind:"Variable",name:{kind:"Name",value:"cancelUrl"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"url"}}]}}]}}]},Te={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateCustomerPortalSession"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"returnUrl"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createCustomerPortalSession"},arguments:[{kind:"Argument",name:{kind:"Name",value:"returnUrl"},value:{kind:"Variable",name:{kind:"Name",value:"returnUrl"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"url"}}]}}]}}]},De={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"CheckoutTrial"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"checkoutTrial"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"days"}}]}}]}}]};function Ee(e,n){throw new Error(n)}var B={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},Je=new Set(Object.keys(B));function j(e){let n=e?.kind;return typeof n=="string"&&Je.has(n)}var q;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription";})(q||(q={}));var g;(function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension";})(g||(g={}));function H(e){return e===9||e===32}function Ae(e,n){let t=e.replace(/"""/g,'\\"""'),i=t.split(/\r\n|[\n\r]/g),a=i.length===1,o=i.length>1&&i.slice(1).every(T=>T.length===0||H(T.charCodeAt(0))),l=t.endsWith('\\"""'),c=e.endsWith('"')&&!l,m=e.endsWith("\\"),s=c||m,d=(!a||e.length>70||s||o||l),p="",k=a&&H(e.charCodeAt(0));return (d&&!k||o)&&(p+=`
2
- `),p+=t,(d||s)&&(p+=`
3
- `),'"""'+p+'"""'}function Fe(e){return C(e,[])}function C(e,n){switch(typeof e){case "string":return JSON.stringify(e);case "function":return e.name?`[function ${e.name}]`:"[function]";case "object":return $e(e,n);default:return String(e)}}function $e(e,n){if(e===null)return "null";if(n.includes(e))return "[Circular]";let t=[...n,e];if(Ze(e)){let i=e.toJSON();if(i!==e)return typeof i=="string"?i:C(i,t)}else if(Array.isArray(e))return en(e,t);return Ke(e,t)}function Ze(e){return typeof e.toJSON=="function"}function Ke(e,n){let t=Object.entries(e);return t.length===0?"{}":n.length>2?"["+nn(e)+"]":"{ "+t.map(([a,o])=>a+": "+C(o,n)).join(", ")+" }"}function en(e,n){if(e.length===0)return "[]";if(n.length>2)return "[Array]";let t=Math.min(10,e.length),i=e.length-t,a=[];for(let o=0;o<t;++o)a.push(C(e[o],n));return i===1?a.push("... 1 more item"):i>1&&a.push(`... ${i} more items`),"["+a.join(", ")+"]"}function nn(e){let n=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if(n==="Object"&&typeof e.constructor=="function"){let t=e.constructor.name;if(typeof t=="string"&&t!=="")return t}return n}function xe(e){return `"${e.replace(tn,an)}"`}var tn=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function an(e){return rn[e.charCodeAt(0)]}var rn=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"];var G=Object.freeze({});function I(e,n,t=B){let i=new Map;for(let f of Object.values(g))i.set(f,Y(n,f));let a,o=Array.isArray(e),l=[e],c=-1,m=[],s=e,d,p,k=[],T=[];do{c++;let f=c===l.length,z=f&&m.length!==0;if(f){if(d=T.length===0?void 0:k[k.length-1],s=p,p=T.pop(),z)if(o){s=s.slice();let h=0;for(let[L,X]of m){let J=L-h;X===null?(s.splice(J,1),h++):s[J]=X;}}else {s=Object.defineProperties({},Object.getOwnPropertyDescriptors(s));for(let[h,L]of m)s[h]=L;}c=a.index,l=a.keys,m=a.edits,o=a.inArray,a=a.prev;}else if(p){if(d=o?c:l[c],s=p[d],s==null)continue;k.push(d);}let v;if(!Array.isArray(s)){var w,P;j(s)||Ee(false,`Invalid AST Node: ${Fe(s)}.`);let h=f?(w=i.get(s.kind))===null||w===void 0?void 0:w.leave:(P=i.get(s.kind))===null||P===void 0?void 0:P.enter;if(v=h?.call(n,s,d,p,k,T),v===G)break;if(v===false){if(!f){k.pop();continue}}else if(v!==void 0&&(m.push([d,v]),!f))if(j(v))s=v;else {k.pop();continue}}if(v===void 0&&z&&m.push([d,s]),f)k.pop();else {var U;a={inArray:o,index:c,keys:l,edits:m,prev:a},o=Array.isArray(s),l=o?s:(U=t[s.kind])!==null&&U!==void 0?U:[],c=-1,m=[],p&&T.push(p),p=s;}}while(a!==void 0);return m.length!==0?m[m.length-1][1]:e}function Y(e,n){let t=e[n];return typeof t=="object"?t:typeof t=="function"?{enter:t,leave:void 0}:{enter:e.enter,leave:e.leave}}function O(e){return I(e,sn)}var on=80,sn={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>r(e.definitions,`
1
+ import {g as g$1,d,c,a,l,e}from'./chunk-YQD7354H.js';var F=new WeakMap;async function x(e,n){let t=F.get(e);if(!t){let a=e({forceRefresh:true}).finally(()=>{F.get(e)===a&&F.delete(e);});F.set(e,a),t=a;}let i=await t;if(n&&i===n)throw new d("Token refresh did not produce a new token",n);return i}var qe=1e3,Z=1e3,Be=3,je=3e4;function He(e,n=Math.random){return Math.floor(n()*e)}function Ge(e){return e instanceof Error&&e.name==="AbortError"}function Q(){return Date.now()}var R=class{constructor(n){this.options=n;}abortController;abortReason;attemptPromise;closed=false;consecutiveAuthFailures=0;forceRefreshNext=false;lastActivityAt=null;lastConnectedAt=null;lastError;reconnectAttempt=0;reconnectTimer;restartAfterCurrentAttempt=false;state="idle";staleTimer;shouldRun=false;get snapshot(){return {consecutiveAuthFailures:this.consecutiveAuthFailures,id:this.options.id,kind:this.options.kind,lastActivityAt:this.lastActivityAt,lastConnectedAt:this.lastConnectedAt,lastError:this.lastError,reconnectAttempt:this.reconnectAttempt,state:this.state}}async start(){if(this.closed)throw new Error(`Connection '${this.options.kind}:${this.options.id}' is closed`);return this.shouldRun=true,this.clearReconnectTimer(),this.attemptPromise&&this.abortReason&&(this.restartAfterCurrentAttempt=true),this.ensureAttempt()}stop(){this.shouldRun=false,this.restartAfterCurrentAttempt=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.abort("manual"),this.setState("idle");}close(){this.closed=true,this.shouldRun=false,this.restartAfterCurrentAttempt=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.abort("manual"),this.setState("closed");}reconnect(){if(!(this.closed||this.isHealthy()||this.state==="connecting")){if(this.shouldRun=true,this.clearReconnectTimer(),this.clearStaleTimer(),this.abortController){this.restartAfterCurrentAttempt=true,this.abort("restart");return}this.ensureAttempt();}}ensureAttempt(){if(!this.shouldRun||this.closed)return Promise.resolve();if(!this.attemptPromise){let n=this.runAttempt().finally(()=>{this.attemptPromise===n&&(this.attemptPromise=void 0),this.restartAfterCurrentAttempt&&this.shouldRun&&!this.closed&&(this.restartAfterCurrentAttempt=false,this.ensureAttempt());});this.attemptPromise=n;}return this.attemptPromise}async runAttempt(){if(!this.shouldRun||this.closed)return;let n=this.lastConnectedAt!==null||this.reconnectAttempt>0;this.setState("connecting"),this.lastError=void 0,this.abortReason=void 0;let t=new AbortController;this.abortController=t;try{let i=this.forceRefreshNext?await x(this.options.getToken):await this.options.getToken(void 0);if(this.forceRefreshNext=!1,await this.options.dial({isReconnect:n,markActivity:()=>this.markActivity(),markConnected:()=>this.markConnected(),requestTokenRefresh:()=>{this.forceRefreshNext=!0;},signal:t.signal,token:i}),!this.shouldRun||this.closed)return;this.scheduleReconnect("end");}catch(i){if(Ge(i)){this.abortReason==="stale"&&this.shouldRun&&!this.closed&&this.scheduleReconnect("end");return}if(!this.shouldRun||this.closed)return;this.handleFailure(i);}finally{this.abortController===t&&(this.abortController=void 0),this.abortReason=void 0;}}handleFailure(n){if(this.lastError=n,n instanceof d||this.options.isFatalError?.(n)){this.shouldRun=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.setState("failed"),this.options.onFatalError?.(n);return}if(this.options.isAuthError?.(n)??false){if(this.consecutiveAuthFailures+=1,this.forceRefreshNext=true,this.setState("reconnecting"),this.consecutiveAuthFailures>=(this.options.maxConsecutiveAuthFailures??Be)){this.shouldRun=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.setState("failed"),this.options.onFatalError?.(n);return}this.scheduleReconnect("auth");return}this.consecutiveAuthFailures=0,typeof navigator<"u"&&"onLine"in navigator&&navigator.onLine===false?this.setState("offline"):this.setState("reconnecting"),this.scheduleReconnect("failure");}scheduleReconnect(n){if(!this.shouldRun||this.closed)return;this.clearReconnectTimer(),this.clearStaleTimer();let t=n==="auth"?this.options.authRetryDelayMs??qe:n==="failure"?this.nextReconnectDelay():this.options.baseReconnectDelayMs??Z;this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.ensureAttempt();},t);}nextReconnectDelay(){let n=this.options.baseReconnectDelayMs??Z,t=this.options.maxReconnectDelayMs??je,i=Math.min(n*Math.pow(2,this.reconnectAttempt),t);return this.reconnectAttempt+=1,this.options.jitter==="full"?He(i):i}isHealthy(){if(this.state!=="connected"||!this.abortController)return false;let n=this.options.staleTimeoutMs;return !n||n<=0?true:this.lastActivityAt!==null&&Q()-this.lastActivityAt<n}markConnected(){this.consecutiveAuthFailures=0,this.reconnectAttempt=0,this.lastConnectedAt=Q(),this.setState("connected"),this.markActivity();}markActivity(){this.lastActivityAt=Q(),this.armStaleTimer();}armStaleTimer(){this.clearStaleTimer();let n=this.options.staleTimeoutMs;!n||n<=0||this.state!=="connected"||(this.staleTimer=setTimeout(()=>{!this.shouldRun||this.closed||!this.abortController||(this.setState("stale"),this.abort("stale"));},n));}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0);}clearStaleTimer(){this.staleTimer&&(clearTimeout(this.staleTimer),this.staleTimer=void 0);}abort(n){this.abortController&&(this.abortReason=n,this.abortController.abort(),this.abortController=void 0);}setState(n){this.state!==n&&(this.state=n,this.options.onStateChange?.(this.snapshot));}};var Ye=(c=>(c.HitLimits="HIT_LIMITS",c.MissingFeature="MISSING_FEATURE",c.NotUsing="NOT_USING",c.Other="OTHER",c.Quality="QUALITY",c.Switching="SWITCHING",c.TooExpensive="TOO_EXPENSIVE",c))(Ye||{}),We=(o=>(o.Enterprise="enterprise",o.Free="free",o.Max="max",o.Plus="plus",o.Pro="pro",o))(We||{}),ze=(a=>(a.Daily="DAILY",a.Monthly="MONTHLY",a.Weekly="WEEKLY",a.Yearly="YEARLY",a))(ze||{}),Xe=(t=>(t.Revcat="REVCAT",t.Stripe="STRIPE",t))(Xe||{});var K={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Plans"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"plans"},selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"PlanFragment"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"PlanFragment"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"Plan"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"prices"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"currency"}},{kind:"Field",name:{kind:"Name",value:"amount"}},{kind:"Field",name:{kind:"Name",value:"interval"}},{kind:"Field",name:{kind:"Name",value:"campaign"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"originalAmount"}},{kind:"Field",name:{kind:"Name",value:"discountedAmount"}},{kind:"Field",name:{kind:"Name",value:"percentOff"}},{kind:"Field",name:{kind:"Name",value:"expiresAt"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"entitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}},{kind:"Field",name:{kind:"Name",value:"features"}}]}}]},ee={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Plan"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"plan"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"PlanFragment"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"PlanFragment"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"Plan"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"prices"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"currency"}},{kind:"Field",name:{kind:"Name",value:"amount"}},{kind:"Field",name:{kind:"Name",value:"interval"}},{kind:"Field",name:{kind:"Name",value:"campaign"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"originalAmount"}},{kind:"Field",name:{kind:"Name",value:"discountedAmount"}},{kind:"Field",name:{kind:"Name",value:"percentOff"}},{kind:"Field",name:{kind:"Name",value:"expiresAt"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"entitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}},{kind:"Field",name:{kind:"Name",value:"features"}}]}}]},ne={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"TierOrders"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tierOrders"}}]}}]},te={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Entitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"entitlements"}}]}}]},ie={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Subscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"provider"}},{kind:"Field",name:{kind:"Name",value:"cycle"}},{kind:"Field",name:{kind:"Name",value:"seats"}},{kind:"Field",name:{kind:"Name",value:"cancelAtPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodStart"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"pausedUntil"}},{kind:"Field",name:{kind:"Name",value:"scheduledChange"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"effectiveDate"}},{kind:"Field",name:{kind:"Name",value:"newTier"}},{kind:"Field",name:{kind:"Name",value:"newSeats"}},{kind:"Field",name:{kind:"Name",value:"newCycle"}}]}}]}}]}}]},ae={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SubscriptionForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscriptionForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"provider"}},{kind:"Field",name:{kind:"Name",value:"cycle"}},{kind:"Field",name:{kind:"Name",value:"seats"}},{kind:"Field",name:{kind:"Name",value:"cancelAtPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodStart"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"scheduledChange"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"effectiveDate"}},{kind:"Field",name:{kind:"Name",value:"newTier"}},{kind:"Field",name:{kind:"Name",value:"newSeats"}},{kind:"Field",name:{kind:"Name",value:"newCycle"}}]}}]}}]}}]},re={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SubscriptionEntitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscriptionEntitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}}]}}]},oe={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SubscriptionEntitlementsForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscriptionEntitlementsForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}}]}}]},se={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ProrationAmount"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"prorationAmount"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},le={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"UpgradePlan"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"upgradePlan"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},ue={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DowngradePlan"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"downgradePlan"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},ce={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"AddSeats"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"additionalSeats"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"addSeats"},arguments:[{kind:"Argument",name:{kind:"Name",value:"additionalSeats"},value:{kind:"Variable",name:{kind:"Name",value:"additionalSeats"}}}]}]}}]},de={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ChangeBillingCycle"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"changeBillingCycle"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},me={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"RemoveSeats"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"seatsToRemove"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"removeSeats"},arguments:[{kind:"Argument",name:{kind:"Name",value:"seatsToRemove"},value:{kind:"Variable",name:{kind:"Name",value:"seatsToRemove"}}}]}]}}]},pe={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelSubscription"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"reason"}},type:{kind:"NamedType",name:{kind:"Name",value:"CancelReason"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"comment"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancelSubscription"},arguments:[{kind:"Argument",name:{kind:"Name",value:"reason"},value:{kind:"Variable",name:{kind:"Name",value:"reason"}}},{kind:"Argument",name:{kind:"Name",value:"comment"},value:{kind:"Variable",name:{kind:"Name",value:"comment"}}}]}]}}]},ke={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"RetentionOffers"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"retentionOffers"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"pauseDays"}},{kind:"Field",name:{kind:"Name",value:"discountPercent"}},{kind:"Field",name:{kind:"Name",value:"discountMonths"}}]}}]}}]},Se={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"PauseSubscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"pauseSubscription"}}]}}]},ye={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ApplyRetentionDiscount"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"applyRetentionDiscount"}}]}}]},fe={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ReactivateSubscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"reactivateSubscription"}}]}}]},ve={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelSubscriptionForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancelSubscriptionForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}]}]}}]},be={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ReactivateSubscriptionForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"reactivateSubscriptionForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}]}]}}]},he={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateCustomer"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"name"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"email"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"userId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createCustomer"},arguments:[{kind:"Argument",name:{kind:"Name",value:"name"},value:{kind:"Variable",name:{kind:"Name",value:"name"}}},{kind:"Argument",name:{kind:"Name",value:"email"},value:{kind:"Variable",name:{kind:"Name",value:"email"}}},{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}},{kind:"Argument",name:{kind:"Name",value:"userId"},value:{kind:"Variable",name:{kind:"Name",value:"userId"}}}]}]}}]},ge={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ReleaseSchedule"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"releaseSchedule"}}]}}]},Ne={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateCheckoutSession"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"priceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"successUrl"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"cancelUrl"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createCheckoutSession"},arguments:[{kind:"Argument",name:{kind:"Name",value:"priceId"},value:{kind:"Variable",name:{kind:"Name",value:"priceId"}}},{kind:"Argument",name:{kind:"Name",value:"successUrl"},value:{kind:"Variable",name:{kind:"Name",value:"successUrl"}}},{kind:"Argument",name:{kind:"Name",value:"cancelUrl"},value:{kind:"Variable",name:{kind:"Name",value:"cancelUrl"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"url"}}]}}]}}]},Te={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateCustomerPortalSession"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"returnUrl"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createCustomerPortalSession"},arguments:[{kind:"Argument",name:{kind:"Name",value:"returnUrl"},value:{kind:"Variable",name:{kind:"Name",value:"returnUrl"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"url"}}]}}]}}]},De={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"CheckoutTrial"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"checkoutTrial"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"days"}}]}}]}}]};function Ee(e,n){throw new Error(n)}var B={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},Je=new Set(Object.keys(B));function j(e){let n=e?.kind;return typeof n=="string"&&Je.has(n)}var q;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription";})(q||(q={}));var g;(function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension";})(g||(g={}));function H(e){return e===9||e===32}function Ae(e,n){let t=e.replace(/"""/g,'\\"""'),i=t.split(/\r\n|[\n\r]/g),a=i.length===1,o=i.length>1&&i.slice(1).every(T=>T.length===0||H(T.charCodeAt(0))),s=t.endsWith('\\"""'),c=e.endsWith('"')&&!s,m=e.endsWith("\\"),l=c||m,d=(!a||e.length>70||l||o||s),p="",k=a&&H(e.charCodeAt(0));return (d&&!k||o)&&(p+=`
2
+ `),p+=t,(d||l)&&(p+=`
3
+ `),'"""'+p+'"""'}function Fe(e){return C(e,[])}function C(e,n){switch(typeof e){case "string":return JSON.stringify(e);case "function":return e.name?`[function ${e.name}]`:"[function]";case "object":return $e(e,n);default:return String(e)}}function $e(e,n){if(e===null)return "null";if(n.includes(e))return "[Circular]";let t=[...n,e];if(Ze(e)){let i=e.toJSON();if(i!==e)return typeof i=="string"?i:C(i,t)}else if(Array.isArray(e))return en(e,t);return Ke(e,t)}function Ze(e){return typeof e.toJSON=="function"}function Ke(e,n){let t=Object.entries(e);return t.length===0?"{}":n.length>2?"["+nn(e)+"]":"{ "+t.map(([a,o])=>a+": "+C(o,n)).join(", ")+" }"}function en(e,n){if(e.length===0)return "[]";if(n.length>2)return "[Array]";let t=Math.min(10,e.length),i=e.length-t,a=[];for(let o=0;o<t;++o)a.push(C(e[o],n));return i===1?a.push("... 1 more item"):i>1&&a.push(`... ${i} more items`),"["+a.join(", ")+"]"}function nn(e){let n=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if(n==="Object"&&typeof e.constructor=="function"){let t=e.constructor.name;if(typeof t=="string"&&t!=="")return t}return n}function xe(e){return `"${e.replace(tn,an)}"`}var tn=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function an(e){return rn[e.charCodeAt(0)]}var rn=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"];var G=Object.freeze({});function I(e,n,t=B){let i=new Map;for(let f of Object.values(g))i.set(f,Y(n,f));let a,o=Array.isArray(e),s=[e],c=-1,m=[],l=e,d,p,k=[],T=[];do{c++;let f=c===s.length,z=f&&m.length!==0;if(f){if(d=T.length===0?void 0:k[k.length-1],l=p,p=T.pop(),z)if(o){l=l.slice();let b=0;for(let[L,X]of m){let J=L-b;X===null?(l.splice(J,1),b++):l[J]=X;}}else {l=Object.defineProperties({},Object.getOwnPropertyDescriptors(l));for(let[b,L]of m)l[b]=L;}c=a.index,s=a.keys,m=a.edits,o=a.inArray,a=a.prev;}else if(p){if(d=o?c:s[c],l=p[d],l==null)continue;k.push(d);}let v;if(!Array.isArray(l)){var w,P;j(l)||Ee(false,`Invalid AST Node: ${Fe(l)}.`);let b=f?(w=i.get(l.kind))===null||w===void 0?void 0:w.leave:(P=i.get(l.kind))===null||P===void 0?void 0:P.enter;if(v=b?.call(n,l,d,p,k,T),v===G)break;if(v===false){if(!f){k.pop();continue}}else if(v!==void 0&&(m.push([d,v]),!f))if(j(v))l=v;else {k.pop();continue}}if(v===void 0&&z&&m.push([d,l]),f)k.pop();else {var U;a={inArray:o,index:c,keys:s,edits:m,prev:a},o=Array.isArray(l),s=o?l:(U=t[l.kind])!==null&&U!==void 0?U:[],c=-1,m=[],p&&T.push(p),p=l;}}while(a!==void 0);return m.length!==0?m[m.length-1][1]:e}function Y(e,n){let t=e[n];return typeof t=="object"?t:typeof t=="function"?{enter:t,leave:void 0}:{enter:e.enter,leave:e.leave}}function O(e){return I(e,sn)}var on=80,sn={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>r(e.definitions,`
4
4
 
5
- `)},OperationDefinition:{leave(e){let n=u("(",r(e.variableDefinitions,", "),")"),t=r([e.operation,r([e.name,n]),r(e.directives," ")]," ");return (t==="query"?"":t+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:n,defaultValue:t,directives:i})=>e+": "+n+u(" = ",t)+u(" ",r(i," "))},SelectionSet:{leave:({selections:e})=>y(e)},Field:{leave({alias:e,name:n,arguments:t,directives:i,selectionSet:a}){let o=u("",e,": ")+n,l=o+u("(",r(t,", "),")");return l.length>on&&(l=o+u(`(
5
+ `)},OperationDefinition:{leave(e){let n=u("(",r(e.variableDefinitions,", "),")"),t=r([e.operation,r([e.name,n]),r(e.directives," ")]," ");return (t==="query"?"":t+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:n,defaultValue:t,directives:i})=>e+": "+n+u(" = ",t)+u(" ",r(i," "))},SelectionSet:{leave:({selections:e})=>y(e)},Field:{leave({alias:e,name:n,arguments:t,directives:i,selectionSet:a}){let o=u("",e,": ")+n,s=o+u("(",r(t,", "),")");return s.length>on&&(s=o+u(`(
6
6
  `,M(r(t,`
7
7
  `)),`
8
- )`)),r([l,r(i," "),a]," ")}},Argument:{leave:({name:e,value:n})=>e+": "+n},FragmentSpread:{leave:({name:e,directives:n})=>"..."+e+u(" ",r(n," "))},InlineFragment:{leave:({typeCondition:e,directives:n,selectionSet:t})=>r(["...",u("on ",e),r(n," "),t]," ")},FragmentDefinition:{leave:({name:e,typeCondition:n,variableDefinitions:t,directives:i,selectionSet:a})=>`fragment ${e}${u("(",r(t,", "),")")} on ${n} ${u("",r(i," ")," ")}`+a},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:n})=>n?Ae(e):xe(e)},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+r(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+r(e,", ")+"}"},ObjectField:{leave:({name:e,value:n})=>e+": "+n},Directive:{leave:({name:e,arguments:n})=>"@"+e+u("(",r(n,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:n,operationTypes:t})=>u("",e,`
8
+ )`)),r([s,r(i," "),a]," ")}},Argument:{leave:({name:e,value:n})=>e+": "+n},FragmentSpread:{leave:({name:e,directives:n})=>"..."+e+u(" ",r(n," "))},InlineFragment:{leave:({typeCondition:e,directives:n,selectionSet:t})=>r(["...",u("on ",e),r(n," "),t]," ")},FragmentDefinition:{leave:({name:e,typeCondition:n,variableDefinitions:t,directives:i,selectionSet:a})=>`fragment ${e}${u("(",r(t,", "),")")} on ${n} ${u("",r(i," ")," ")}`+a},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:n})=>n?Ae(e):xe(e)},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+r(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+r(e,", ")+"}"},ObjectField:{leave:({name:e,value:n})=>e+": "+n},Directive:{leave:({name:e,arguments:n})=>"@"+e+u("(",r(n,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:n,operationTypes:t})=>u("",e,`
9
9
  `)+r(["schema",r(n," "),y(t)]," ")},OperationTypeDefinition:{leave:({operation:e,type:n})=>e+": "+n},ScalarTypeDefinition:{leave:({description:e,name:n,directives:t})=>u("",e,`
10
10
  `)+r(["scalar",n,r(t," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:n,interfaces:t,directives:i,fields:a})=>u("",e,`
11
11
  `)+r(["type",n,u("implements ",r(t," & ")),r(i," "),y(a)]," ")},FieldDefinition:{leave:({description:e,name:n,arguments:t,type:i,directives:a})=>u("",e,`
@@ -27,5 +27,5 @@ import {g as g$1,d,c,a,l,e}from'./chunk-YQD7354H.js';var F=new WeakMap;async fun
27
27
  `)),`
28
28
  }`)}function u(e,n,t=""){return n!=null&&n!==""?e+n+t:""}function M(e){return u(" ",e.replace(/\n/g,`
29
29
  `))}function Re(e){var n;return (n=e?.some(t=>t.includes(`
30
- `)))!==null&&n!==void 0?n:false}var Ce=new WeakMap;function V(e){let n=Ce.get(e);return n||(n=O(e),Ce.set(e,n)),n}var cn=new Set([g$1.SESSION_TOKEN_LIMIT_REACHED,g$1.STORAGE_LIMIT_REACHED,g$1.DEEP_ANALYSIS_LIMIT_EXCEEDED,g$1.PLAN_DETAIL_RESTRICTION,g$1.RESOURCE_NOT_FOUND]);function Oe(e,n){if(e)for(let t of e){let i=t.extensions?.code;if(i==null)continue;if(i===4401||i==="4401")return true;let a=String(i).toUpperCase();if(cn.has(a))return false;if(a==="UNAUTHORIZED"||a==="UNAUTHENTICATED"||t.message==="Unauthorized")return true}return false}async function Ve(e$1,n,t){let i=await e$1.getToken(),a=e$1.getLanguage(),o=e$1.getPlatform?.(),l=e$1.getUserTimezone?.(),c$1={"Content-Type":"application/json",Authorization:`Bearer ${i}`};a&&(c$1["x-preferred-language"]=a),o&&(c$1["x-platform"]=o),l&&(c$1["x-user-timezone"]=l);let m=JSON.stringify({query:V(n),variables:t}),s=dn(n)?new AbortController:void 0,d$1=s&&setTimeout(()=>s.abort(),we);try{let p;try{p=await fetch(e$1.url,{method:"POST",headers:c$1,body:m,...s&&{signal:s.signal}});}catch(k){throw s?.signal.aborted?Ie():k instanceof Error&&k.name==="AbortError"?k:new c(k instanceof Error?k.message:"Network request failed before reaching the server",0)}if(!p.ok)throw p.status===401?new d(`Authentication failed with status ${p.status}`,i):p.status===403?new e("Request refused with status 403"):new c(`HTTP ${p.status}: ${p.statusText}`,p.status);try{return {response:await p.json(),usedToken:i}}catch(k){throw s?.signal.aborted?Ie():k}}finally{clearTimeout(d$1);}}var we=3e4;function Ie(){return new c(`No answer within ${we/1e3} s`,0)}function dn(e){let n=e.definitions.filter(t=>t.kind==="OperationDefinition");return n.length>0&&n.every(t=>t.operation==="query")}var mn=4,pn=1e3;function Pe(e){async function n(t,i,a$1=0,o=true,l$1=e){let c$1;try{c$1=await Ve(l$1,t,i);}catch(d$1){if(d$1 instanceof d)return Me(t,i,l$1,d$1.failedToken,o);if(d$1 instanceof c&&d$1.status===0&&a$1<mn)return await fn(pn*(a$1+1)),n(t,i,a$1+1,o,l$1);throw o&&d$1 instanceof a&&N(l$1,t,d$1),d$1}let{response:m,usedToken:s}=c$1;if(Oe(m.errors))return Me(t,i,l$1,s,o);if(m.errors?.length&&!m.data){let d=l(m.errors,V(t),i);throw o&&N(l$1,t,d),d}if(!m.data){let d=l([{message:"No data returned from server"}],V(t),i);throw o&&N(l$1,t,d),d}return m.data}return {request:(t,i,a)=>n(t,i,0,a?.reportErrors??true,a?.watched?Sn(e):e)}}async function Me(e,n,t,i,a=true){try{await x(t.getToken,i);}catch{let o=new d("Token refresh failed");throw N(t,e,o),o}return kn(t,e,n,a)}async function kn(e,n,t,i=true){let a$1;try{a$1=await Ve(e,n,t);}catch(l){if(l instanceof d){let c=new d("Authentication failed after token refresh");throw N(e,n,c),c}throw i&&l instanceof a&&N(e,n,l),l}let{response:o}=a$1;if(Oe(o.errors)){let l=new d("Authentication failed after token refresh");throw N(e,n,l),l}if(o.errors?.length&&!o.data){let l$1=l(o.errors,V(n),t);throw i&&N(e,n,l$1),l$1}return o.data}function Sn(e){let{onError:n}=e;return n?{...e,onError:t=>{t.watched=true,n(t);}}:e}function N(e,n,t){t.operation??=yn(n),e.onError?.(t);}function yn(e){for(let n of e.definitions)if(n.kind===g.OPERATION_DEFINITION)return n.operation}function fn(e){return new Promise(n=>setTimeout(n,e))}async function Ue(e,n,t){let i=e.getReader(),a=new TextDecoder,o="";try{for(;!n.aborted;){let{done:l,value:c}=await i.read();if(l)break;t.onChunk?.(),o+=a.decode(c,{stream:!0});let m=o.split(/(?:\r\n|\r|\n){2}/);o=m.pop()??"";for(let s of m)t.onEventBlock(s.trim());}}finally{i.releaseLock();}}var Le=1e3,vn=3e4,hn=3,bn=35e3,E=class extends Error{constructor(t){super(`Billing SSE auth failed: ${t}`);this.status=t;this.name="BillingAuthStreamError";}};function _e(e){let n=e instanceof c?e.status:void 0;return n!==void 0&&n>=400&&n<500&&n!==408&&n!==429}var W=class{constructor(n,t){this.options=n;this.onClose=t;this.supervisor=new R({authRetryDelayMs:Le,baseReconnectDelayMs:Le,getToken:n.getToken,id:`billing-${Math.random().toString(36).slice(2)}`,isAuthError:i=>i instanceof E,isFatalError:_e,kind:"billing-sse",maxConsecutiveAuthFailures:hn,maxReconnectDelayMs:vn,onFatalError:i=>{this.options.onError?.(_e(i)?i:new d("Billing SSE stream authentication failed permanently")),this.close();},staleTimeoutMs:bn,dial:async i=>{let a=await fetch(this.options.billingSseUrl,{method:"GET",headers:{Authorization:`Bearer ${i.token}`,Accept:"text/event-stream","Cache-Control":"no-cache"},signal:i.signal});if(!a.ok)throw a.status===401||a.status===403?new E(a.status):new c(`Billing SSE failed: ${a.status} ${a.statusText}`,a.status);if(!a.body)throw new Error("Billing SSE response has no body");i.markConnected(),await Ue(a.body,i.signal,{onChunk:()=>i.markActivity(),onEventBlock:o=>this.processEventBlock(o,i.requestTokenRefresh)});}});}abortFinished=false;queue=[];pendingResolve=null;supervisor;start(){this.supervisor.start();}reconnect(){this.abortFinished||this.supervisor.reconnect();}next(){return this.queue.length>0?Promise.resolve({value:this.queue.shift(),done:false}):this.abortFinished?Promise.resolve({value:void 0,done:true}):new Promise(n=>{this.pendingResolve=n;})}return(){return this.close(),Promise.resolve({value:void 0,done:true})}[Symbol.asyncIterator](){return this}close(){this.abortFinished||(this.abortFinished=true,this.supervisor.close(),this.pendingResolve&&(this.pendingResolve({value:void 0,done:true}),this.pendingResolve=null),this.onClose(this));}push(n){if(!this.abortFinished){if(this.pendingResolve){this.pendingResolve({value:n,done:false}),this.pendingResolve=null;return}this.queue.length=0,this.queue.push(n);}}processEventBlock(n,t){if(!n||n.startsWith(":"))return;let i,a=[];for(let o of n.split(/\r\n|\r|\n/))o.startsWith("event: ")?i=o.slice(7).trim():o.startsWith("data: ")&&a.push(o.slice(6));if(i==="token-expired")throw t(),new E(401);if(!(i!=="subscription"||a.length===0))try{let o=JSON.parse(a.join(`
31
- `));this.push(o);}catch{}}},Qe=class{http;options;activeUpdateStreams=new Set;constructor(n){this.options=n,this.http=Pe({url:n.billingHttpUrl,getToken:n.getToken,getLanguage:()=>{},onError:n.onError});}destroy(){for(let n of Array.from(this.activeUpdateStreams))n.close();this.activeUpdateStreams.clear();}reconnectAll(){for(let n of this.activeUpdateStreams)n.reconnect();}get plans(){return {list:async()=>(await this.request(K)).plans,get:async n=>(await this.request(ee,n)).plan,entitlements:async()=>(await this.request(te)).entitlements,tierOrders:async()=>(await this.request(ne)).tierOrders}}get subscription(){return {get:async()=>(await this.request(ie)).subscription,entitlements:async()=>(await this.request(re)).subscriptionEntitlements,checkoutTrial:async()=>(await this.request(De)).checkoutTrial??null,upgrade:async n=>(await this.request(le,n)).upgradePlan,prorationAmount:async n=>(await this.request(se,n)).prorationAmount,downgrade:async n=>(await this.request(ue,n)).downgradePlan,changeBillingCycle:async n=>(await this.request(de,n)).changeBillingCycle,cancel:async(n={})=>(await this.request(pe,n)).cancelSubscription,retentionOffers:async()=>(await this.request(ke)).retentionOffers??null,pause:async()=>(await this.request(Se)).pauseSubscription,applyRetentionDiscount:async()=>(await this.request(ye)).applyRetentionDiscount,reactivate:async()=>(await this.request(fe)).reactivateSubscription,releaseSchedule:async()=>(await this.request(ge)).releaseSchedule,updates:()=>{let n=new W(this.options,t=>{this.activeUpdateStreams.delete(t);});return this.activeUpdateStreams.add(n),n.start(),n}}}get seats(){return {add:async n=>(await this.request(ce,n)).addSeats,remove:async n=>(await this.request(me,n)).removeSeats}}get session(){return {createSession:async n=>(await this.request(Ne,n)).createCheckoutSession,createCustomerPortalSession:async n=>(await this.request(Te,n)).createCustomerPortalSession}}get management(){return {subscription:async n=>(await this.request(ae,n)).subscriptionForManager,entitlements:async n=>(await this.request(oe,n)).subscriptionEntitlementsForManager,cancel:async n=>(await this.request(ve,n)).cancelSubscriptionForManager,reactivate:async n=>(await this.request(he,n)).reactivateSubscriptionForManager,createCustomer:async n=>(await this.request(be,n)).createCustomer}}request(n,t){return this.http.request(n,t)}};export{g as a,I as b,x as c,Pe as d,He as e,Ye as f,We as g,ze as h,Xe as i,Qe as j};
30
+ `)))!==null&&n!==void 0?n:false}var Ce=new WeakMap;function V(e){let n=Ce.get(e);return n||(n=O(e),Ce.set(e,n)),n}var cn=new Set([g$1.SESSION_TOKEN_LIMIT_REACHED,g$1.STORAGE_LIMIT_REACHED,g$1.DEEP_ANALYSIS_LIMIT_EXCEEDED,g$1.PLAN_DETAIL_RESTRICTION,g$1.RESOURCE_NOT_FOUND]);function Oe(e,n){if(e)for(let t of e){let i=t.extensions?.code;if(i==null)continue;if(i===4401||i==="4401")return true;let a=String(i).toUpperCase();if(cn.has(a))return false;if(a==="UNAUTHORIZED"||a==="UNAUTHENTICATED"||t.message==="Unauthorized")return true}return false}async function Ve(e$1,n,t){let i=await e$1.getToken(),a=e$1.getLanguage(),o=e$1.getPlatform?.(),s=e$1.getUserTimezone?.(),c$1={"Content-Type":"application/json",Authorization:`Bearer ${i}`};a&&(c$1["x-preferred-language"]=a),o&&(c$1["x-platform"]=o),s&&(c$1["x-user-timezone"]=s);let m=JSON.stringify({query:V(n),variables:t}),l=dn(n)?new AbortController:void 0,d$1=l&&setTimeout(()=>l.abort(),we);try{let p;try{p=await fetch(e$1.url,{method:"POST",headers:c$1,body:m,...l&&{signal:l.signal}});}catch(k){throw l?.signal.aborted?Ie():k instanceof Error&&k.name==="AbortError"?k:new c(k instanceof Error?k.message:"Network request failed before reaching the server",0)}if(!p.ok)throw p.status===401?new d(`Authentication failed with status ${p.status}`,i):p.status===403?new e("Request refused with status 403"):new c(`HTTP ${p.status}: ${p.statusText}`,p.status);try{return {response:await p.json(),usedToken:i}}catch(k){throw l?.signal.aborted?Ie():k}}finally{clearTimeout(d$1);}}var we=3e4;function Ie(){return new c(`No answer within ${we/1e3} s`,0)}function dn(e){let n=e.definitions.filter(t=>t.kind==="OperationDefinition");return n.length>0&&n.every(t=>t.operation==="query")}var mn=4,pn=1e3;function Pe(e){async function n(t,i,a$1=0,o=true,s=e){let c$1;try{c$1=await Ve(s,t,i);}catch(d$1){if(d$1 instanceof d)return Me(t,i,s,d$1.failedToken,o);if(d$1 instanceof c&&d$1.status===0&&a$1<mn)return await fn(pn*(a$1+1)),n(t,i,a$1+1,o,s);throw o&&d$1 instanceof a&&N(s,t,d$1),d$1}let{response:m,usedToken:l$1}=c$1;if(Oe(m.errors))return Me(t,i,s,l$1,o);if(m.errors?.length&&!m.data){let d=l(m.errors,V(t),i);throw o&&N(s,t,d),d}if(!m.data){let d=l([{message:"No data returned from server"}],V(t),i);throw o&&N(s,t,d),d}return m.data}return {request:(t,i,a)=>n(t,i,0,a?.reportErrors??true,a?.watched?Sn(e):e)}}async function Me(e,n,t,i,a=true){try{await x(t.getToken,i);}catch{let o=new d("Token refresh failed");throw N(t,e,o),o}return kn(t,e,n,a)}async function kn(e,n,t,i=true){let a$1;try{a$1=await Ve(e,n,t);}catch(s){if(s instanceof d){let c=new d("Authentication failed after token refresh");throw N(e,n,c),c}throw i&&s instanceof a&&N(e,n,s),s}let{response:o}=a$1;if(Oe(o.errors)){let s=new d("Authentication failed after token refresh");throw N(e,n,s),s}if(o.errors?.length&&!o.data){let s=l(o.errors,V(n),t);throw i&&N(e,n,s),s}return o.data}function Sn(e){let{onError:n}=e;return n?{...e,onError:t=>{t.watched=true,n(t);}}:e}function N(e,n,t){t.operation??=yn(n),e.onError?.(t);}function yn(e){for(let n of e.definitions)if(n.kind===g.OPERATION_DEFINITION)return n.operation}function fn(e){return new Promise(n=>setTimeout(n,e))}async function Ue(e,n,t){let i=e.getReader(),a=new TextDecoder,o="";try{for(;!n.aborted;){let{done:s,value:c}=await i.read();if(s)break;t.onChunk?.(),o+=a.decode(c,{stream:!0});let m=o.split(/(?:\r\n|\r|\n){2}/);o=m.pop()??"",await t.onEventBlocks(m.map(l=>l.trim()));}}finally{i.releaseLock();}}var Le=1e3,vn=3e4,bn=3,hn=35e3,E=class extends Error{constructor(t){super(`Billing SSE auth failed: ${t}`);this.status=t;this.name="BillingAuthStreamError";}};function _e(e){let n=e instanceof c?e.status:void 0;return n!==void 0&&n>=400&&n<500&&n!==408&&n!==429}var W=class{constructor(n,t){this.options=n;this.onClose=t;this.supervisor=new R({authRetryDelayMs:Le,baseReconnectDelayMs:Le,getToken:n.getToken,id:`billing-${crypto.randomUUID()}`,isAuthError:i=>i instanceof E,isFatalError:_e,kind:"billing-sse",maxConsecutiveAuthFailures:bn,maxReconnectDelayMs:vn,onFatalError:i=>{this.options.onError?.(_e(i)?i:new d("Billing SSE stream authentication failed permanently")),this.close();},staleTimeoutMs:hn,dial:async i=>{let a=await fetch(this.options.billingSseUrl,{method:"GET",headers:{Authorization:`Bearer ${i.token}`,Accept:"text/event-stream","Cache-Control":"no-cache"},signal:i.signal});if(!a.ok)throw a.status===401||a.status===403?new E(a.status):new c(`Billing SSE failed: ${a.status} ${a.statusText}`,a.status);if(!a.body)throw new Error("Billing SSE response has no body");i.markConnected(),await Ue(a.body,i.signal,{onChunk:()=>i.markActivity(),onEventBlocks:o=>{for(let s of o)this.processEventBlock(s,i.requestTokenRefresh);}});}});}abortFinished=false;queue=[];pendingResolve=null;supervisor;start(){this.supervisor.start();}reconnect(){this.abortFinished||this.supervisor.reconnect();}next(){return this.queue.length>0?Promise.resolve({value:this.queue.shift(),done:false}):this.abortFinished?Promise.resolve({value:void 0,done:true}):new Promise(n=>{this.pendingResolve=n;})}return(){return this.close(),Promise.resolve({value:void 0,done:true})}[Symbol.asyncIterator](){return this}close(){this.abortFinished||(this.abortFinished=true,this.supervisor.close(),this.pendingResolve&&(this.pendingResolve({value:void 0,done:true}),this.pendingResolve=null),this.onClose(this));}push(n){if(!this.abortFinished){if(this.pendingResolve){this.pendingResolve({value:n,done:false}),this.pendingResolve=null;return}this.queue.length=0,this.queue.push(n);}}processEventBlock(n,t){if(!n||n.startsWith(":"))return;let i,a=[];for(let o of n.split(/\r\n|\r|\n/))o.startsWith("event: ")?i=o.slice(7).trim():o.startsWith("data: ")&&a.push(o.slice(6));if(i==="token-expired")throw t(),new E(401);if(!(i!=="subscription"||a.length===0))try{let o=JSON.parse(a.join(`
31
+ `));this.push(o);}catch{}}},Qe=class{http;options;activeUpdateStreams=new Set;constructor(n){this.options=n,this.http=Pe({url:n.billingHttpUrl,getToken:n.getToken,getLanguage:()=>{},onError:n.onError});}destroy(){for(let n of Array.from(this.activeUpdateStreams))n.close();this.activeUpdateStreams.clear();}reconnectAll(){for(let n of this.activeUpdateStreams)n.reconnect();}get plans(){return {list:async()=>(await this.request(K)).plans,get:async n=>(await this.request(ee,n)).plan,entitlements:async()=>(await this.request(te)).entitlements,tierOrders:async()=>(await this.request(ne)).tierOrders}}get subscription(){return {get:async()=>(await this.request(ie)).subscription,entitlements:async()=>(await this.request(re)).subscriptionEntitlements,checkoutTrial:async()=>(await this.request(De)).checkoutTrial??null,upgrade:async n=>(await this.request(le,n)).upgradePlan,prorationAmount:async n=>(await this.request(se,n)).prorationAmount,downgrade:async n=>(await this.request(ue,n)).downgradePlan,changeBillingCycle:async n=>(await this.request(de,n)).changeBillingCycle,cancel:async(n={})=>(await this.request(pe,n)).cancelSubscription,retentionOffers:async()=>(await this.request(ke)).retentionOffers??null,pause:async()=>(await this.request(Se)).pauseSubscription,applyRetentionDiscount:async()=>(await this.request(ye)).applyRetentionDiscount,reactivate:async()=>(await this.request(fe)).reactivateSubscription,releaseSchedule:async()=>(await this.request(ge)).releaseSchedule,updates:()=>{let n=new W(this.options,t=>{this.activeUpdateStreams.delete(t);});return this.activeUpdateStreams.add(n),n.start(),n}}}get seats(){return {add:async n=>(await this.request(ce,n)).addSeats,remove:async n=>(await this.request(me,n)).removeSeats}}get session(){return {createSession:async n=>(await this.request(Ne,n)).createCheckoutSession,createCustomerPortalSession:async n=>(await this.request(Te,n)).createCustomerPortalSession}}get management(){return {subscription:async n=>(await this.request(ae,n)).subscriptionForManager,entitlements:async n=>(await this.request(oe,n)).subscriptionEntitlementsForManager,cancel:async n=>(await this.request(ve,n)).cancelSubscriptionForManager,reactivate:async n=>(await this.request(be,n)).reactivateSubscriptionForManager,createCustomer:async n=>(await this.request(he,n)).createCustomer}}request(n,t){return this.http.request(n,t)}};export{g as a,I as b,x as c,Pe as d,He as e,Ue as f,Ye as g,We as h,ze as i,Xe as j,Qe as k};