@streamoid/settings 0.15.2 → 0.16.1

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.
package/dist/index.mjs CHANGED
@@ -599,7 +599,7 @@ import {
599
599
  Fragment as Fragment15,
600
600
  useState as useState25,
601
601
  useEffect as useEffect20,
602
- useRef as useRef11,
602
+ useRef as useRef12,
603
603
  useCallback as useCallback10,
604
604
  useMemo as useMemo5
605
605
  } from "react";
@@ -2995,11 +2995,12 @@ var APP_ACCESS_MARKS = {
2995
2995
  "artifax": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20fill-rule%3D%22evenodd%22%20d%3D%22M6%2029L15%207H21L30%2029H25.7L23.5%2023H12.5L10.3%2029ZM14%2019H22L18%209Z%22%2F%3E%3C%2Fsvg%3E%0A",
2996
2996
  "photogenix": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20fill-rule%3D%22evenodd%22%20d%3D%22M10%2029V7H20C25%207%2028%2010%2028%2014.5S25%2022%2020%2022H14V29ZM14%2011V18H20C22.7%2018%2024%2017%2024%2014.5S22.7%2011%2020%2011Z%22%2F%3E%3C%2Fsvg%3E%0A",
2997
2997
  "catalogix": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20fill-rule%3D%22evenodd%22%20d%3D%22M30%2012L26.5%2014C24.8%2011.5%2022.3%2010%2018.5%2010C12.7%2010%209%2013%209%2018S12.7%2026%2018.5%2026C22.3%2026%2024.8%2024.5%2026.5%2022L30%2024C27.7%2028%2023.7%2030%2018.5%2030C10.5%2030%205%2025.3%205%2018S10.5%206%2018.5%206C23.7%206%2027.7%208%2030%2012Z%22%2F%3E%3C%2Fsvg%3E%0A",
2998
- "returns": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20transform%3D%22translate%288.034%207%29%20scale%280.782%29%22%20d%3D%22M4.536%2028.14H0V0H14.616C21%200%2024.948%203.024%2024.948%208.274C24.948%2012.936%2021.882%2015.792%2016.59%2016.086V16.38C18.774%2016.968%2019.782%2018.228%2020.79%2019.992L25.494%2028.14H20.286L15.792%2020.37C14.532%2018.144%2013.23%2017.22%209.702%2017.22H4.536V28.14ZM4.536%204.074V13.734H14.574C18.354%2013.734%2020.244%2012.432%2020.244%208.904C20.244%205.46%2018.354%204.074%2014.574%204.074H4.536Z%22%2F%3E%3C%2Fsvg%3E%0A"
2998
+ "returns": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20transform%3D%22translate%288.034%207%29%20scale%280.782%29%22%20d%3D%22M4.536%2028.14H0V0H14.616C21%200%2024.948%203.024%2024.948%208.274C24.948%2012.936%2021.882%2015.792%2016.59%2016.086V16.38C18.774%2016.968%2019.782%2018.228%2020.79%2019.992L25.494%2028.14H20.286L15.792%2020.37C14.532%2018.144%2013.23%2017.22%209.702%2017.22H4.536V28.14ZM4.536%204.074V13.734H14.574C18.354%2013.734%2020.244%2012.432%2020.244%208.904C20.244%205.46%2018.354%204.074%2014.574%204.074H4.536Z%22%2F%3E%3C%2Fsvg%3E%0A",
2999
+ "tactix": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2036%2036%22%3E%3Crect%20width%3D%2236%22%20height%3D%2236%22%20rx%3D%227%22%20fill%3D%22%23101010%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20fill-rule%3D%22evenodd%22%20d%3D%22M5%207H31V11H20V29H16V11H5Z%22%2F%3E%3C%2Fsvg%3E%0A"
2999
3000
  };
3000
3001
 
3001
3002
  // src/teams-content.tsx
3002
- import { useState as useState8, useEffect as useEffect8, useCallback as useCallback2, useRef as useRef5 } from "react";
3003
+ import { useState as useState8, useEffect as useEffect8, useCallback as useCallback2, useRef as useRef6 } from "react";
3003
3004
  import { ScPendingAction } from "@streamoid/ui";
3004
3005
  import { ScButton as ScButton4 } from "@streamoid/ui";
3005
3006
  import {
@@ -3007,12 +3008,13 @@ import {
3007
3008
  } from "@streamoid/icons";
3008
3009
 
3009
3010
  // src/invite-update-modal.tsx
3010
- import { useState as useState7, useEffect as useEffect7 } from "react";
3011
+ import { useState as useState7, useEffect as useEffect7, useRef as useRef5 } from "react";
3011
3012
  import { ScButton as ScButton3 } from "@streamoid/ui";
3012
3013
  import {
3013
3014
  SiconClose as SiconClose2,
3014
3015
  SiconArrowLeftRight,
3015
3016
  SiconArtifacts,
3017
+ SiconChartBar,
3016
3018
  SiconPhotogenix,
3017
3019
  SiconSearch
3018
3020
  } from "@streamoid/icons";
@@ -3034,6 +3036,7 @@ var svg_rodctpja6f_default = {
3034
3036
  // src/team-types.ts
3035
3037
  var APP_KEYS = [
3036
3038
  "artifax",
3039
+ "tactix",
3037
3040
  "photogenix",
3038
3041
  "returns",
3039
3042
  "catalogix"
@@ -3043,11 +3046,27 @@ var DEFAULT_PERMISSIONS = {
3043
3046
  photogenix: true,
3044
3047
  catalogix: true,
3045
3048
  returns: true,
3049
+ tactix: true,
3046
3050
  canUseCredits: true,
3047
3051
  canInviteUser: true,
3048
3052
  role: "admin",
3049
3053
  catalogixStores: []
3050
3054
  };
3055
+ function parseInviteEmails(input) {
3056
+ const emails = [];
3057
+ const invalid = [];
3058
+ for (const raw of input.split(/[\s,;]+/)) {
3059
+ const token = raw.trim();
3060
+ if (!token) continue;
3061
+ if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(token)) {
3062
+ const email = token.toLowerCase();
3063
+ if (!emails.includes(email)) emails.push(email);
3064
+ } else if (!invalid.includes(token)) {
3065
+ invalid.push(token);
3066
+ }
3067
+ }
3068
+ return { emails, invalid };
3069
+ }
3051
3070
 
3052
3071
  // src/invite-update-modal.tsx
3053
3072
  import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
@@ -3168,9 +3187,22 @@ function InviteUpdateModal({
3168
3187
  initialOrganizationStanding = "guest",
3169
3188
  organizationDomain: _organizationDomain,
3170
3189
  allowAdminRole = true,
3171
- onInvite
3190
+ onInvite,
3191
+ onInviteMany
3172
3192
  }) {
3173
- useOverlayOpen(open, onClose);
3193
+ const pendingInvite = useRef5(false);
3194
+ const inviteGeneration = useRef5(0);
3195
+ const requestClose = () => {
3196
+ if (!pendingInvite.current) onClose();
3197
+ };
3198
+ useOverlayOpen(open, requestClose);
3199
+ useEffect7(() => {
3200
+ setSubmitting(false);
3201
+ return () => {
3202
+ inviteGeneration.current += 1;
3203
+ pendingInvite.current = false;
3204
+ };
3205
+ }, [open, mode, userEmail]);
3174
3206
  const [emailValue, setEmailValue] = useState7("");
3175
3207
  const [hasChanges, setHasChanges] = useState7(false);
3176
3208
  const [role, setRole] = useState7("member");
@@ -3187,6 +3219,8 @@ function InviteUpdateModal({
3187
3219
  !hiddenApps.includes("catalogix")
3188
3220
  );
3189
3221
  const [returnsOn, setReturnsOn] = useState7(!hiddenApps.includes("returns"));
3222
+ const [tactixOn, setTactixOn] = useState7(!hiddenApps.includes("tactix"));
3223
+ const [submitting, setSubmitting] = useState7(false);
3190
3224
  const [storeSearch, setStoreSearch] = useState7("");
3191
3225
  const [selectedStores, setSelectedStores] = useState7(/* @__PURE__ */ new Set());
3192
3226
  const filteredStores = stores.filter(
@@ -3205,6 +3239,7 @@ function InviteUpdateModal({
3205
3239
  );
3206
3240
  setCatalogixOn(!hidden.has("catalogix") && initialPermissions.catalogix);
3207
3241
  setReturnsOn(!hidden.has("returns") && initialPermissions.returns);
3242
+ setTactixOn(!hidden.has("tactix") && Boolean(initialPermissions.tactix));
3208
3243
  setSelectedStores(
3209
3244
  new Set(hidden.has("catalogix") ? [] : initialPermissions.catalogixStores)
3210
3245
  );
@@ -3220,6 +3255,8 @@ function InviteUpdateModal({
3220
3255
  setPhotogenixOn(!hidden.has("photogenix"));
3221
3256
  setCatalogixOn(!hidden.has("catalogix"));
3222
3257
  setReturnsOn(!hidden.has("returns"));
3258
+ setTactixOn(!hidden.has("tactix"));
3259
+ setSubmitting(false);
3223
3260
  setStoreSearch("");
3224
3261
  setSelectedStores(/* @__PURE__ */ new Set());
3225
3262
  }
@@ -3227,7 +3264,8 @@ function InviteUpdateModal({
3227
3264
  const adminLocked = mode === "invite" && !allowAdminRole;
3228
3265
  if (!open) return null;
3229
3266
  const isInvite = mode === "invite";
3230
- const hasEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailValue.trim());
3267
+ const parsedEmails = parseInviteEmails(emailValue);
3268
+ const hasEmail = parsedEmails.emails.length > 0 && parsedEmails.invalid.length === 0;
3231
3269
  function markChanged() {
3232
3270
  setHasChanges(true);
3233
3271
  }
@@ -3237,12 +3275,13 @@ function InviteUpdateModal({
3237
3275
  artifax: artifaxOn,
3238
3276
  photogenix: photogenixOn,
3239
3277
  returns: returnsOn,
3240
- catalogix: catalogixOn
3278
+ catalogix: catalogixOn,
3279
+ tactix: tactixOn
3241
3280
  };
3242
3281
  const notLastShown = (key) => shownApps[shownApps.length - 1] !== key;
3243
3282
  const appValue = (key) => role === "admin" || showsApp(key) ? appToggles[key] : false;
3244
3283
  const grantsNoApp = role === "member" && shownApps.length > 0 && !shownApps.some((key) => appToggles[key]);
3245
- const isSubmitDisabled = isInvite ? !hasEmail || grantsNoApp : !(allowSubmitWithoutChanges || hasChanges);
3284
+ const isSubmitDisabled = isInvite ? !hasEmail || grantsNoApp || submitting : !(allowSubmitWithoutChanges || hasChanges);
3246
3285
  function toggleStore(storeId) {
3247
3286
  setSelectedStores((prev) => {
3248
3287
  const next = new Set(prev);
@@ -3258,7 +3297,7 @@ function InviteUpdateModal({
3258
3297
  className: "fixed inset-0 z-50 flex items-center justify-center",
3259
3298
  style: { backgroundColor: "rgba(0, 0, 0, 0.6)" },
3260
3299
  onClick: (e) => {
3261
- if (e.target === e.currentTarget) onClose();
3300
+ if (e.target === e.currentTarget) requestClose();
3262
3301
  },
3263
3302
  children: /* @__PURE__ */ jsxs11(
3264
3303
  "div",
@@ -3301,7 +3340,7 @@ function InviteUpdateModal({
3301
3340
  children: isInvite ? "Invite" : "Update user"
3302
3341
  }
3303
3342
  ),
3304
- /* @__PURE__ */ jsx14("div", { className: "shrink-0 cursor-pointer", onClick: onClose, children: /* @__PURE__ */ jsx14(SiconClose2, { className: "w-6 h-6", color: T6.primary }) })
3343
+ /* @__PURE__ */ jsx14("button", { type: "button", "aria-label": "Close invite dialog", disabled: submitting, className: "shrink-0 cursor-pointer disabled:cursor-wait", onClick: requestClose, children: /* @__PURE__ */ jsx14(SiconClose2, { className: "w-6 h-6", color: T6.primary }) })
3305
3344
  ]
3306
3345
  }
3307
3346
  ) })
@@ -3348,6 +3387,7 @@ function InviteUpdateModal({
3348
3387
  color: T6.primary
3349
3388
  },
3350
3389
  placeholder: "email@domain.in, email@domain.in, email@domain.in...",
3390
+ "aria-invalid": parsedEmails.invalid.length > 0,
3351
3391
  value: emailValue,
3352
3392
  onChange: (e) => setEmailValue(e.target.value)
3353
3393
  }
@@ -3369,6 +3409,20 @@ function InviteUpdateModal({
3369
3409
  }
3370
3410
  ) })
3371
3411
  }
3412
+ ),
3413
+ isInvite && parsedEmails.invalid.length > 0 && /* @__PURE__ */ jsx14(
3414
+ "span",
3415
+ {
3416
+ role: "alert",
3417
+ style: {
3418
+ fontFamily: T6.font,
3419
+ fontSize: T6.fsXs,
3420
+ fontWeight: 400,
3421
+ lineHeight: T6.lhXs,
3422
+ color: "var(--alias-text---icons-error)"
3423
+ },
3424
+ children: parsedEmails.invalid.length === 1 ? `Not a valid email: ${parsedEmails.invalid[0]}` : `Not valid emails: ${parsedEmails.invalid.join(", ")}`
3425
+ }
3372
3426
  )
3373
3427
  ]
3374
3428
  }
@@ -3803,6 +3857,101 @@ function InviteUpdateModal({
3803
3857
  }
3804
3858
  ) })
3805
3859
  ] }) }),
3860
+ showsApp("tactix") && /* @__PURE__ */ jsx14(Fragment5, { children: /* @__PURE__ */ jsxs11("div", { className: "shrink-0 w-full relative", children: [
3861
+ notLastShown("tactix") && /* @__PURE__ */ jsx14(
3862
+ "div",
3863
+ {
3864
+ "aria-hidden": true,
3865
+ className: "absolute inset-0 pointer-events-none",
3866
+ style: {
3867
+ borderBottom: `1px solid ${T6.borderSubtle}`
3868
+ }
3869
+ }
3870
+ ),
3871
+ /* @__PURE__ */ jsx14("div", { className: "flex flex-row items-center size-full", children: /* @__PURE__ */ jsxs11(
3872
+ "div",
3873
+ {
3874
+ className: "flex items-center w-full",
3875
+ style: { padding: T6.sp3xl, gap: T6.spMd },
3876
+ children: [
3877
+ /* @__PURE__ */ jsxs11(
3878
+ "div",
3879
+ {
3880
+ className: "flex flex-1 min-w-0 items-center",
3881
+ style: { gap: T6.spXl },
3882
+ children: [
3883
+ /* @__PURE__ */ jsx14(
3884
+ "div",
3885
+ {
3886
+ className: "shrink-0 flex items-center",
3887
+ style: {
3888
+ background: T6.fillHover,
3889
+ borderRadius: T6.rXl,
3890
+ padding: T6.spMd
3891
+ },
3892
+ children: /* @__PURE__ */ jsx14(
3893
+ SiconChartBar,
3894
+ {
3895
+ className: "w-6 h-6",
3896
+ color: T6.primary
3897
+ }
3898
+ )
3899
+ }
3900
+ ),
3901
+ /* @__PURE__ */ jsxs11(
3902
+ "div",
3903
+ {
3904
+ className: "flex flex-1 min-w-0 flex-col items-start overflow-hidden text-ellipsis whitespace-nowrap",
3905
+ style: { opacity: tactixOn ? 1 : 0.5 },
3906
+ children: [
3907
+ /* @__PURE__ */ jsx14(
3908
+ "p",
3909
+ {
3910
+ className: "w-full overflow-hidden shrink-0",
3911
+ style: {
3912
+ fontFamily: T6.font,
3913
+ fontSize: T6.fsSm,
3914
+ fontWeight: 500,
3915
+ lineHeight: T6.lhSm,
3916
+ color: T6.primary
3917
+ },
3918
+ children: "Tactix"
3919
+ }
3920
+ ),
3921
+ /* @__PURE__ */ jsx14(
3922
+ "p",
3923
+ {
3924
+ className: "w-full overflow-hidden shrink-0",
3925
+ style: {
3926
+ fontFamily: T6.font,
3927
+ fontSize: T6.fsXs,
3928
+ fontWeight: 400,
3929
+ lineHeight: T6.lhXs,
3930
+ color: T6.tertiary
3931
+ },
3932
+ children: "Buying and planning"
3933
+ }
3934
+ )
3935
+ ]
3936
+ }
3937
+ )
3938
+ ]
3939
+ }
3940
+ ),
3941
+ /* @__PURE__ */ jsx14(
3942
+ ToggleSwitch,
3943
+ {
3944
+ active: tactixOn,
3945
+ onClick: () => {
3946
+ setTactixOn(!tactixOn);
3947
+ markChanged();
3948
+ }
3949
+ }
3950
+ )
3951
+ ]
3952
+ }
3953
+ ) })
3954
+ ] }) }),
3806
3955
  showsApp("photogenix") && /* @__PURE__ */ jsx14(Fragment5, { children: /* @__PURE__ */ jsxs11("div", { className: "shrink-0 w-full relative", children: [
3807
3956
  notLastShown("photogenix") && /* @__PURE__ */ jsx14(
3808
3957
  "div",
@@ -4317,18 +4466,33 @@ function InviteUpdateModal({
4317
4466
  photogenix: appValue("photogenix"),
4318
4467
  catalogix: appValue("catalogix"),
4319
4468
  returns: appValue("returns"),
4469
+ tactix: appValue("tactix"),
4320
4470
  // Stores ride on Catalogix, so they follow it: a
4321
4471
  // hidden Catalogix grants no app and therefore no
4322
4472
  // storefronts. Keeping them would leave a member
4323
4473
  // scoped to stores in a product they cannot open.
4324
4474
  catalogixStores: role === "admin" || showsApp("catalogix") ? Array.from(selectedStores) : []
4325
4475
  };
4326
- if (isInvite && onInvite) {
4327
- onInvite(
4328
- perms,
4329
- emailValue.trim(),
4330
- showOrganizationStanding ? orgStanding : void 0
4331
- );
4476
+ const standing = showOrganizationStanding ? orgStanding : void 0;
4477
+ if (isInvite && onInviteMany) {
4478
+ if (pendingInvite.current) return;
4479
+ pendingInvite.current = true;
4480
+ const generation = ++inviteGeneration.current;
4481
+ const current = () => inviteGeneration.current === generation;
4482
+ setSubmitting(true);
4483
+ Promise.resolve().then(() => current() ? onInviteMany(perms, parsedEmails.emails, standing) : void 0).then((result) => {
4484
+ if (current() && result && result.failed.length > 0) {
4485
+ setEmailValue(result.failed.join(", "));
4486
+ }
4487
+ }).catch(() => void 0).finally(() => {
4488
+ if (!current()) return;
4489
+ pendingInvite.current = false;
4490
+ setSubmitting(false);
4491
+ });
4492
+ } else if (isInvite && onInvite) {
4493
+ for (const email of parsedEmails.emails) {
4494
+ onInvite(perms, email, standing);
4495
+ }
4332
4496
  } else if (onSave) {
4333
4497
  onSave(perms);
4334
4498
  }
@@ -4563,6 +4727,7 @@ function appNameTokens(app) {
4563
4727
  return ["artifax", "artifact", "artifacts", "artifex", "chat"];
4564
4728
  if (app === "photogenix") return ["photogenix"];
4565
4729
  if (app === "returns") return ["returns", "return"];
4730
+ if (app === "tactix") return ["tactix"];
4566
4731
  return ["catalogix"];
4567
4732
  }
4568
4733
  function normalizeServiceName(value) {
@@ -4591,6 +4756,7 @@ function permissionServiceIds(services, permissions) {
4591
4756
  if (serviceMatchesApp(s, "catalogix") && permissions.catalogix)
4592
4757
  return true;
4593
4758
  if (serviceMatchesApp(s, "returns") && permissions.returns) return true;
4759
+ if (serviceMatchesApp(s, "tactix") && permissions.tactix) return true;
4594
4760
  return false;
4595
4761
  }).map((s) => s._id);
4596
4762
  }
@@ -4703,7 +4869,8 @@ function readInviteAppFlag(invRecord, app) {
4703
4869
  ],
4704
4870
  photogenix: ["photogenix", "photogenixAccess"],
4705
4871
  catalogix: ["catalogix", "catalogixAccess"],
4706
- returns: ["returns", "return", "returnsAccess"]
4872
+ returns: ["returns", "return", "returnsAccess"],
4873
+ tactix: ["tactix", "tactixAccess"]
4707
4874
  };
4708
4875
  const containers = [invRecord];
4709
4876
  for (const nestedKey of ["permissions", "permission", "access", "apps"]) {
@@ -4778,6 +4945,7 @@ function memberToTeamMember(m, services) {
4778
4945
  const hasPhotogenix = isAdmin || userHasApp("photogenix");
4779
4946
  const hasCatalogix = isAdmin || userHasApp("catalogix");
4780
4947
  const hasReturns = isAdmin || userHasApp("returns");
4948
+ const hasTactix = isAdmin || userHasApp("tactix");
4781
4949
  return {
4782
4950
  id: m._id,
4783
4951
  kind: "member",
@@ -4804,6 +4972,7 @@ function memberToTeamMember(m, services) {
4804
4972
  photogenix: hasPhotogenix,
4805
4973
  catalogix: hasCatalogix,
4806
4974
  returns: hasReturns,
4975
+ tactix: hasTactix,
4807
4976
  canUseCredits: m.creditAccess,
4808
4977
  canInviteUser: m.inviteAccess,
4809
4978
  role: m.role,
@@ -4822,14 +4991,17 @@ function inviteToTeamMember(inv, services) {
4822
4991
  );
4823
4992
  const derivedCatalogix = serviceNames.some((n) => matchesApp(n, "catalogix"));
4824
4993
  const derivedReturns = serviceNames.some((n) => matchesApp(n, "returns"));
4994
+ const derivedTactix = serviceNames.some((n) => matchesApp(n, "tactix"));
4825
4995
  const explicitArtifax = readInviteAppFlag(invRecord, "artifax");
4826
4996
  const explicitPhotogenix = readInviteAppFlag(invRecord, "photogenix");
4827
4997
  const explicitCatalogix = readInviteAppFlag(invRecord, "catalogix");
4828
4998
  const explicitReturns = readInviteAppFlag(invRecord, "returns");
4999
+ const explicitTactix = readInviteAppFlag(invRecord, "tactix");
4829
5000
  const artifaxFlag = Boolean(explicitArtifax) || derivedArtifax;
4830
5001
  const photogenixFlag = Boolean(explicitPhotogenix) || derivedPhotogenix;
4831
5002
  const catalogixFlag = Boolean(explicitCatalogix) || derivedCatalogix;
4832
5003
  const returnsFlag = Boolean(explicitReturns) || derivedReturns;
5004
+ const tactixFlag = Boolean(explicitTactix) || derivedTactix;
4833
5005
  const catalogixStores = uniqueNonEmpty([
4834
5006
  ...extractIdsFromMixedArray(invRecord.stores),
4835
5007
  ...extractIdsFromMixedArray(invRecord.storeIds)
@@ -4846,6 +5018,7 @@ function inviteToTeamMember(inv, services) {
4846
5018
  photogenix: photogenixFlag,
4847
5019
  catalogix: catalogixFlag,
4848
5020
  returns: returnsFlag,
5021
+ tactix: tactixFlag,
4849
5022
  canUseCredits: inv.creditAccess ?? false,
4850
5023
  canInviteUser: inv.inviteAccess ?? false,
4851
5024
  role: inv.role ?? "member",
@@ -4854,7 +5027,7 @@ function inviteToTeamMember(inv, services) {
4854
5027
  };
4855
5028
  }
4856
5029
  function AccessIcons({ permissions }) {
4857
- const apps = ["artifax", "photogenix", "catalogix", "returns"];
5030
+ const apps = ["artifax", "tactix", "photogenix", "catalogix", "returns"];
4858
5031
  return /* @__PURE__ */ jsx16("div", { className: "flex items-center shrink-0", style: { gap: 6 }, children: apps.filter((app) => permissions[app]).map((app) => /* @__PURE__ */ jsx16(
4859
5032
  "img",
4860
5033
  {
@@ -5028,9 +5201,9 @@ function TeamsContent({
5028
5201
  const currentRoster = roster?.scope === permissionScope && roster.api === api ? roster : null;
5029
5202
  const activeMembers = currentRoster?.active ?? [];
5030
5203
  const pendingMembers = currentRoster?.pending ?? [];
5031
- const fetchGeneration = useRef5(0);
5032
- const fetchMounted = useRef5(false);
5033
- const latestFetchScope = useRef5({ scope: permissionScope, api });
5204
+ const fetchGeneration = useRef6(0);
5205
+ const fetchMounted = useRef6(false);
5206
+ const latestFetchScope = useRef6({ scope: permissionScope, api });
5034
5207
  latestFetchScope.current = { scope: permissionScope, api };
5035
5208
  const [permissionData, setPermissionData] = useState8(null);
5036
5209
  const [searchQuery, setSearchQuery] = useState8("");
@@ -5047,12 +5220,17 @@ function TeamsContent({
5047
5220
  isReady: permissionsReady,
5048
5221
  failed: permissionData?.failed
5049
5222
  });
5223
+ const modalSession = useRef6(0);
5050
5224
  const [modal, setModal] = useState8({
5051
5225
  open: false,
5052
5226
  mode: "invite"
5053
5227
  });
5054
5228
  useEffect8(() => {
5229
+ modalSession.current += 1;
5055
5230
  setModal({ open: false, mode: "invite" });
5231
+ return () => {
5232
+ modalSession.current += 1;
5233
+ };
5056
5234
  }, [permissionScope, api]);
5057
5235
  const MOCK_ACTIVE = [
5058
5236
  {
@@ -5201,7 +5379,10 @@ function TeamsContent({
5201
5379
  fetchGeneration.current += 1;
5202
5380
  };
5203
5381
  }, [fetchData]);
5204
- const openInviteModal = () => setModal({ open: true, mode: "invite" });
5382
+ const openInviteModal = () => {
5383
+ modalSession.current += 1;
5384
+ setModal({ open: true, mode: "invite" });
5385
+ };
5205
5386
  useEffect8(() => {
5206
5387
  if ((onInviteOpen || inviteRequested) && permissionsReady && !permissionData?.failed) {
5207
5388
  if (viewerCanInvite) openInviteModal();
@@ -5213,6 +5394,7 @@ function TeamsContent({
5213
5394
  onCanInviteChange?.(viewerCanInvite);
5214
5395
  }, [viewerCanInvite, onCanInviteChange]);
5215
5396
  const openUpdateModal = async (member) => {
5397
+ modalSession.current += 1;
5216
5398
  setModal({
5217
5399
  open: true,
5218
5400
  mode: "update",
@@ -5232,7 +5414,10 @@ function TeamsContent({
5232
5414
  } catch {
5233
5415
  }
5234
5416
  };
5235
- const closeModal = () => setModal({ open: false, mode: "invite" });
5417
+ const closeModal = () => {
5418
+ modalSession.current += 1;
5419
+ setModal({ open: false, mode: "invite" });
5420
+ };
5236
5421
  const currentMemberPermissions = modal.target?.permissions;
5237
5422
  const handleSave = async (permissions) => {
5238
5423
  if (!modal.target) {
@@ -5377,34 +5562,55 @@ function TeamsContent({
5377
5562
  toast.error(msg);
5378
5563
  }
5379
5564
  };
5380
- const handleInvite = async (permissions, email, organizationStanding) => {
5565
+ const handleInviteMany = async (permissions, emails, organizationStanding) => {
5566
+ const session = modalSession.current;
5567
+ const isCurrent = () => fetchMounted.current && modalSession.current === session && latestFetchScope.current.scope === permissionScope && latestFetchScope.current.api === api;
5568
+ if (!isCurrent()) return { failed: emails };
5381
5569
  if (!viewerCanInvite || permissions.role === "admin" && highestRole !== "admin") {
5382
5570
  toast.error("You do not have permission to invite users");
5383
5571
  closeModal();
5384
- return;
5572
+ return { failed: [] };
5385
5573
  }
5386
5574
  const serviceIds = permissions.role === "admin" ? [] : permissionServiceIds(allServices, permissions);
5387
- try {
5388
- await api.inviteMember({
5389
- email,
5390
- creditAccess: permissions.canUseCredits,
5391
- inviteAccess: permissions.canInviteUser,
5392
- role: permissions.role,
5393
- serviceIds,
5394
- storeIds: permissions.catalogixStores || [],
5395
- // Omitted when the control was never shown, which leaves the backend
5396
- // deriving the standing from the invitee's email domain as before.
5397
- ...organizationStanding ? {
5398
- organizationRole: organizationStanding === "colleague" ? "member" : "guest"
5399
- } : {}
5400
- });
5401
- toast.success(`Invitation sent to ${email}`);
5402
- await fetchData();
5403
- closeModal();
5404
- } catch (err) {
5405
- const msg = errorMessage(err, { method: "POST" });
5406
- toast.error(msg);
5575
+ const sent = [];
5576
+ const failed = [];
5577
+ for (const email of emails) {
5578
+ if (!isCurrent()) return { failed: emails.filter((address) => !sent.includes(address)) };
5579
+ try {
5580
+ await api.inviteMember({
5581
+ email,
5582
+ creditAccess: permissions.canUseCredits,
5583
+ inviteAccess: permissions.canInviteUser,
5584
+ role: permissions.role,
5585
+ serviceIds,
5586
+ storeIds: permissions.catalogixStores || [],
5587
+ // Omitted when the control was never shown, which leaves the backend
5588
+ // deriving the standing from the invitee's email domain as before.
5589
+ ...organizationStanding ? {
5590
+ organizationRole: organizationStanding === "colleague" ? "member" : "guest"
5591
+ } : {}
5592
+ });
5593
+ sent.push(email);
5594
+ } catch (err) {
5595
+ failed.push({ email, message: errorMessage(err, { method: "POST" }) });
5596
+ }
5597
+ }
5598
+ if (!isCurrent()) return { failed: failed.map((f) => f.email) };
5599
+ if (sent.length === 1) toast.success(`Invitation sent to ${sent[0]}`);
5600
+ else if (sent.length > 1)
5601
+ toast.success(`Invitations sent to ${sent.length} people`);
5602
+ if (failed.length === 1) {
5603
+ toast.error(
5604
+ emails.length === 1 ? failed[0].message : `${failed[0].email}: ${failed[0].message}`
5605
+ );
5606
+ } else if (failed.length > 1) {
5607
+ toast.error(
5608
+ `${failed.length} invitations were not sent. ${failed[0].email}: ${failed[0].message}`
5609
+ );
5407
5610
  }
5611
+ if (sent.length > 0) await fetchData();
5612
+ if (isCurrent() && failed.length === 0) closeModal();
5613
+ return { failed: failed.map((f) => f.email) };
5408
5614
  };
5409
5615
  const filteredActive = activeMembers.filter((m) => {
5410
5616
  const q = searchQuery.toLowerCase();
@@ -5522,7 +5728,7 @@ function TeamsContent({
5522
5728
  showOrganizationStanding: mayGrantOrgMembership,
5523
5729
  organizationName: organizationName ?? orgCurrent?.name,
5524
5730
  organizationDomain: workspaceOrgId && orgCurrent?.id === workspaceOrgId ? orgCurrent?.domain : void 0,
5525
- onInvite: handleInvite
5731
+ onInviteMany: handleInviteMany
5526
5732
  }
5527
5733
  )
5528
5734
  ] });
@@ -5948,7 +6154,7 @@ function OrganizationMemberModal({
5948
6154
  }
5949
6155
 
5950
6156
  // src/organization-modal.tsx
5951
- import { useState as useState10, useRef as useRef6, useEffect as useEffect10 } from "react";
6157
+ import { useState as useState10, useRef as useRef7, useEffect as useEffect10 } from "react";
5952
6158
  import { Fragment as Fragment7, jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
5953
6159
  var T10 = {
5954
6160
  primary: "var(--alias-text---icons-primary)",
@@ -6021,7 +6227,7 @@ function OrganizationModal({
6021
6227
  );
6022
6228
  const [submitting, setSubmitting] = useState10(false);
6023
6229
  const [canDelete, setCanDelete] = useState10(false);
6024
- const fileInputRef = useRef6(null);
6230
+ const fileInputRef = useRef7(null);
6025
6231
  const { organization: organizationAdapter } = useSettingsAdapters();
6026
6232
  useEffect10(() => {
6027
6233
  if (open) {
@@ -7341,7 +7547,7 @@ function OrganizationContent({
7341
7547
  }
7342
7548
 
7343
7549
  // src/organization-list-content.tsx
7344
- import { useCallback as useCallback4, useEffect as useEffect12, useRef as useRef7, useState as useState12 } from "react";
7550
+ import { useCallback as useCallback4, useEffect as useEffect12, useRef as useRef8, useState as useState12 } from "react";
7345
7551
  import { ScButton as ScButton7 } from "@streamoid/ui";
7346
7552
  import { jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
7347
7553
  var T12 = {
@@ -7379,7 +7585,7 @@ function OrganizationListContent() {
7379
7585
  const [openingId, setOpeningId] = useState12(null);
7380
7586
  const [joinable, setJoinable] = useState12([]);
7381
7587
  const [joiningId, setJoiningId] = useState12(null);
7382
- const organizationRef = useRef7(organization);
7588
+ const organizationRef = useRef8(organization);
7383
7589
  organizationRef.current = organization;
7384
7590
  const load = useCallback4(async () => {
7385
7591
  setLoading(true);
@@ -7629,6 +7835,35 @@ function OrganizationListContent() {
7629
7835
  ] });
7630
7836
  }
7631
7837
 
7838
+ // src/billing-request-gate.ts
7839
+ function createBillingRequestGate(initialScope) {
7840
+ let scope = initialScope;
7841
+ let generation = 0;
7842
+ return {
7843
+ setScope(next) {
7844
+ if (next !== scope) {
7845
+ scope = next;
7846
+ generation++;
7847
+ }
7848
+ },
7849
+ invalidate() {
7850
+ generation++;
7851
+ },
7852
+ begin(requestScope) {
7853
+ if (requestScope !== scope) return null;
7854
+ const id = ++generation;
7855
+ return () => id === generation && requestScope === scope;
7856
+ }
7857
+ };
7858
+ }
7859
+
7860
+ // src/plan-card-state.ts
7861
+ function planCardState(loaded, loading, failed, hasSubscription) {
7862
+ if (!loaded || loading) return "loading";
7863
+ if (failed) return "error";
7864
+ return hasSubscription ? "ready" : "empty";
7865
+ }
7866
+
7632
7867
  // src/billing-errors.ts
7633
7868
  function isBillingWorkspaceMissing(failure) {
7634
7869
  const seen = /* @__PURE__ */ new Set();
@@ -7677,7 +7912,7 @@ import {
7677
7912
  useCallback as useCallback8,
7678
7913
  useMemo as useMemo4,
7679
7914
  useReducer,
7680
- useRef as useRef10
7915
+ useRef as useRef11
7681
7916
  } from "react";
7682
7917
  import {
7683
7918
  ScPlanDetailsCard,
@@ -8621,7 +8856,7 @@ function BuyCreditsModal({
8621
8856
  }
8622
8857
 
8623
8858
  // src/per-user-limits-view.tsx
8624
- import { useCallback as useCallback6, useEffect as useEffect14, useMemo as useMemo3, useRef as useRef8, useState as useState16 } from "react";
8859
+ import { useCallback as useCallback6, useEffect as useEffect14, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
8625
8860
  import { ScButton as ScButton9 } from "@streamoid/ui";
8626
8861
 
8627
8862
  // src/member-credit-limit-modal.tsx
@@ -9128,7 +9363,7 @@ function PerUserLimitsView() {
9128
9363
  const [searchQuery, setSearchQuery] = useState16("");
9129
9364
  const [editing, setEditing] = useState16(null);
9130
9365
  const [editingDefault, setEditingDefault] = useState16(false);
9131
- const latestLoad = useRef8(0);
9366
+ const latestLoad = useRef9(0);
9132
9367
  const load = useCallback6(async ({ refresh = false } = {}) => {
9133
9368
  const loadId = ++latestLoad.current;
9134
9369
  if (!api.fetchMemberCreditLimits) {
@@ -9334,7 +9569,7 @@ function PerUserLimitsView() {
9334
9569
  }
9335
9570
 
9336
9571
  // src/shared-credits-view.tsx
9337
- import { useCallback as useCallback7, useEffect as useEffect17, useRef as useRef9, useState as useState20 } from "react";
9572
+ import { useCallback as useCallback7, useEffect as useEffect17, useRef as useRef10, useState as useState20 } from "react";
9338
9573
  import { ScButton as ScButton13 } from "@streamoid/ui";
9339
9574
 
9340
9575
  // src/connected-apps-shared.tsx
@@ -10370,7 +10605,7 @@ function SharedCreditsView() {
10370
10605
  const [adding, setAdding] = useState20(false);
10371
10606
  const [editing, setEditing] = useState20(null);
10372
10607
  const [removing, setRemoving] = useState20(null);
10373
- const latestLoad = useRef9(0);
10608
+ const latestLoad = useRef10(0);
10374
10609
  const load = useCallback7(
10375
10610
  async ({ refresh = false } = {}) => {
10376
10611
  const loadId = ++latestLoad.current;
@@ -10603,12 +10838,23 @@ async function loadCurrentPlan(fetchCurrentPlan) {
10603
10838
  response = await fetchCurrentPlan();
10604
10839
  } catch (failure) {
10605
10840
  const entitlement2 = entitlementFromFailure(failure);
10606
- if (!entitlement2) throw failure;
10841
+ if (!entitlement2) {
10842
+ const error = failure;
10843
+ if (error?.status === 404 || error?.response?.status === 404) {
10844
+ return { subscription: null, entitlement: null, paid: false, noSubscriptionConfirmed: true };
10845
+ }
10846
+ throw failure;
10847
+ }
10607
10848
  return { subscription: null, entitlement: entitlement2, paid: entitlement2.paid };
10608
10849
  }
10609
10850
  const subscription = response?.data ?? null;
10610
10851
  const entitlement = entitlementFromBody(response);
10611
- return { subscription, entitlement, paid: hasPaidFeatures({ entitlement, subscription }) };
10852
+ return {
10853
+ subscription,
10854
+ entitlement,
10855
+ paid: hasPaidFeatures({ entitlement, subscription }),
10856
+ ...response?.noSubscription === true ? { noSubscriptionConfirmed: true } : {}
10857
+ };
10612
10858
  }
10613
10859
 
10614
10860
  // src/billing-layout.ts
@@ -11286,7 +11532,7 @@ function PlansView({
11286
11532
  selectedMiddlePlan && actionInFlight === selectedMiddlePlan.key
11287
11533
  );
11288
11534
  const [isPlanSelectorOpen, setIsPlanSelectorOpen] = useState21(false);
11289
- const planDropdownRef = useRef10(null);
11535
+ const planDropdownRef = useRef11(null);
11290
11536
  useEffect18(() => {
11291
11537
  if (!isPlanSelectorOpen) return;
11292
11538
  const handleClickOutside = (event) => {
@@ -12090,7 +12336,7 @@ function BillingContent({
12090
12336
  const [showExportModal, setShowExportModal] = useState21(false);
12091
12337
  const [exportProgress, setExportProgress] = useState21(null);
12092
12338
  const [exportNotice, setExportNotice] = useState21(null);
12093
- const exportAbortRef = useRef10(null);
12339
+ const exportAbortRef = useRef11(null);
12094
12340
  const [showBuyCreditsModal, setShowBuyCreditsModal] = useState21(false);
12095
12341
  const [subscription, setSubscription] = useState21(null);
12096
12342
  const [entitlement, setEntitlement] = useState21(
@@ -12116,12 +12362,12 @@ function BillingContent({
12116
12362
  loading: loadingUsageLogs,
12117
12363
  error: usageLogsError
12118
12364
  } = usageLogsState;
12119
- const usageLogsRequestRef = useRef10(0);
12120
- const usageLogsStateRef = useRef10(usageLogsState);
12365
+ const usageLogsRequestRef = useRef11(0);
12366
+ const usageLogsStateRef = useRef11(usageLogsState);
12121
12367
  usageLogsStateRef.current = usageLogsState;
12122
- const workspaceIdRef = useRef10(workspaceId);
12368
+ const workspaceIdRef = useRef11(workspaceId);
12123
12369
  workspaceIdRef.current = workspaceId;
12124
- const loadUsedByNamesRef = useRef10(null);
12370
+ const loadUsedByNamesRef = useRef11(null);
12125
12371
  loadUsedByNamesRef.current ??= createUsedByNamesLoader((forWorkspace, names) => {
12126
12372
  if (forWorkspace !== workspaceIdRef.current) return false;
12127
12373
  setUsedByNames(names);
@@ -12136,6 +12382,10 @@ function BillingContent({
12136
12382
  );
12137
12383
  const [buyCreditsInFlight, setBuyCreditsInFlight] = useState21(false);
12138
12384
  const [loadingBilling, setLoadingBilling] = useState21(false);
12385
+ const [planLoadFailed, setPlanLoadFailed] = useState21(false);
12386
+ const billingRequestGate = useRef11(createBillingRequestGate(workspaceId));
12387
+ billingRequestGate.current.setScope(workspaceId);
12388
+ useEffect18(() => () => billingRequestGate.current.invalidate(), []);
12139
12389
  const [billingOverviewLoaded, setBillingOverviewLoaded] = useState21(false);
12140
12390
  const [loadingTable, setLoadingTable] = useState21(false);
12141
12391
  const [showInitialLoader, setShowInitialLoader] = useState21(true);
@@ -12160,6 +12410,8 @@ function BillingContent({
12160
12410
  }
12161
12411
  }, [api]);
12162
12412
  const fetchBillingOverview = useCallback8(async () => {
12413
+ const isCurrent = billingRequestGate.current.begin(workspaceId);
12414
+ if (!isCurrent) return;
12163
12415
  setLoadingBilling(true);
12164
12416
  setBillingOverviewLoaded(false);
12165
12417
  try {
@@ -12172,8 +12424,13 @@ function BillingContent({
12172
12424
  api.fetchPlans().catch(() => null),
12173
12425
  api.getCustomCreditInfo?.().catch(() => null) ?? Promise.resolve(null)
12174
12426
  ]);
12175
- if (subRes?.subscription) setSubscription(subRes.subscription);
12176
- if (subRes) setEntitlement(subRes.entitlement);
12427
+ if (!isCurrent()) return;
12428
+ const knownPlan = subRes && (subRes.subscription || subRes.entitlement || subRes.noSubscriptionConfirmed);
12429
+ setPlanLoadFailed(!knownPlan);
12430
+ if (knownPlan) {
12431
+ setSubscription(subRes.subscription);
12432
+ setEntitlement(subRes.entitlement);
12433
+ }
12177
12434
  if (creditsRes?.availableCredits != null)
12178
12435
  setAvailableCredits(creditsRes.availableCredits);
12179
12436
  setSharedPool(creditsRes?.sharedPool ?? null);
@@ -12182,11 +12439,14 @@ function BillingContent({
12182
12439
  setCustomPlanCredits(customRes.data.credits);
12183
12440
  }
12184
12441
  } catch {
12442
+ if (isCurrent()) setPlanLoadFailed(true);
12185
12443
  } finally {
12186
- setLoadingBilling(false);
12187
- setBillingOverviewLoaded(true);
12444
+ if (isCurrent()) {
12445
+ setLoadingBilling(false);
12446
+ setBillingOverviewLoaded(true);
12447
+ }
12188
12448
  }
12189
- }, [api]);
12449
+ }, [api, workspaceId]);
12190
12450
  const fetchUserMap = useCallback8(async () => {
12191
12451
  try {
12192
12452
  const members = await api.fetchMembers();
@@ -12382,8 +12642,10 @@ function BillingContent({
12382
12642
  setInitialFetchTriggered(false);
12383
12643
  setBillingOverviewLoaded(false);
12384
12644
  setSubscription(null);
12645
+ setPlanLoadFailed(false);
12385
12646
  setEntitlement(null);
12386
12647
  setAvailableCredits(null);
12648
+ setSharedPool(null);
12387
12649
  setProducts([]);
12388
12650
  setTotalCredits(null);
12389
12651
  setCustomPlanCredits(null);
@@ -12444,15 +12706,17 @@ function BillingContent({
12444
12706
  );
12445
12707
  const scheduledDowngradeText = subscription?.downgradeScheduled && subscription.plan?.name ? `Downgrades to ${subscription.plan.name}${scheduledDowngradeDateLabel ? ` ${scheduledDowngradeDateLabel}` : ""}` : void 0;
12446
12708
  const sponsored = isSponsoredEntitlement(entitlement);
12447
- const sponsoredWithoutPlan = sponsored && billingOverviewLoaded && !loadingBilling && subscription == null;
12448
- const isPlanDetailsLoading = sponsoredWithoutPlan ? false : !billingOverviewLoaded || loadingBilling || subscription?.plan == null || !planName || planName === "-" || !planAmount || currentPlanCredits == null;
12709
+ const planState = planCardState(billingOverviewLoaded, loadingBilling, planLoadFailed, subscription != null);
12710
+ const withoutPlan = planState === "empty";
12711
+ const sponsoredWithoutPlan = sponsored && withoutPlan;
12712
+ const isPlanDetailsLoading = planState === "loading";
12449
12713
  const paidFeatures = hasPaidFeatures({ entitlement, subscription });
12450
- const onEntitlementChangeRef = useRef10(onEntitlementChange);
12714
+ const onEntitlementChangeRef = useRef11(onEntitlementChange);
12451
12715
  onEntitlementChangeRef.current = onEntitlementChange;
12452
12716
  useEffect18(() => {
12453
- if (!billingOverviewLoaded) return;
12717
+ if (!billingOverviewLoaded || loadingBilling || planLoadFailed) return;
12454
12718
  onEntitlementChangeRef.current?.({ entitlement, paid: paidFeatures });
12455
- }, [billingOverviewLoaded, entitlement, paidFeatures]);
12719
+ }, [billingOverviewLoaded, loadingBilling, planLoadFailed, entitlement, paidFeatures]);
12456
12720
  const {
12457
12721
  used: usedCredits,
12458
12722
  remaining: remainingCredits,
@@ -12722,20 +12986,27 @@ function BillingContent({
12722
12986
  className: "flex items-start shrink-0 w-full",
12723
12987
  style: { gap: 12 },
12724
12988
  children: [
12725
- /* @__PURE__ */ jsx29(
12989
+ planState === "error" ? /* @__PURE__ */ jsxs26("div", { role: "alert", className: "flex-1 min-w-0", style: { padding: 16 }, children: [
12990
+ /* @__PURE__ */ jsx29("p", { children: "Plan details could not be loaded." }),
12991
+ /* @__PURE__ */ jsx29(ScButton14, { text: "Retry plan details", variant: "outline", size: "sm", onClick: () => void fetchBillingOverview() })
12992
+ ] }) : /* @__PURE__ */ jsx29(
12726
12993
  ScPlanDetailsCard,
12727
12994
  {
12728
- planName: sponsoredWithoutPlan ? "Free" : planName,
12995
+ planName: withoutPlan ? "Free" : planName || "Current plan",
12729
12996
  planCredits: sponsoredWithoutPlan ? "Shared credits" : planCreditsText,
12730
- planPrice: sponsoredWithoutPlan ? `${workspace.current?.country?.trim().toUpperCase() === "IN" ? "\u20B9" : "$"}0.00 / month` : planAmount,
12997
+ planPrice: withoutPlan ? "No paid subscription" : planAmount,
12731
12998
  badgeText: "Active",
12732
12999
  badgeSubText: scheduledDowngradeText,
12733
13000
  currentPlanLabel: "Current plan",
12734
- upgradeButtonText: subscription?.downgradeScheduled ? "Cancel downgrade" : "Manage Plan",
13001
+ upgradeButtonText: withoutPlan ? "See plans" : navigation.manageBilling ? "Manage Plan" : subscription?.downgradeScheduled ? "Cancel downgrade" : "Manage Plan",
12735
13002
  isLoading: isPlanDetailsLoading,
12736
13003
  className: "flex-1 min-w-0",
12737
13004
  style: { padding: 16, gap: 8 },
12738
13005
  onUpgrade: () => {
13006
+ if (navigation.manageBilling) {
13007
+ navigation.manageBilling();
13008
+ return;
13009
+ }
12739
13010
  void logBillingEvent("billing_plans_opened", "Plans opened", {
12740
13011
  action: "open_plans"
12741
13012
  });
@@ -12760,6 +13031,10 @@ function BillingContent({
12760
13031
  className: "flex-1 min-w-0",
12761
13032
  style: { padding: 16, gap: 8 },
12762
13033
  onBuyClick: () => {
13034
+ if (navigation.manageBilling) {
13035
+ navigation.manageBilling();
13036
+ return;
13037
+ }
12763
13038
  void logBillingEvent(
12764
13039
  "billing_buy_credits_clicked",
12765
13040
  "Buy credits clicked",
@@ -14605,7 +14880,7 @@ function SpecializationDropdown({
14605
14880
  }) {
14606
14881
  const { auth } = useSettingsAdapters();
14607
14882
  const [open, setOpen] = useState25(false);
14608
- const containerRef = useRef11(null);
14883
+ const containerRef = useRef12(null);
14609
14884
  const [options, setOptions] = useState25([]);
14610
14885
  useEffect20(() => {
14611
14886
  if (!auth.getSpecializations) return;
@@ -14743,7 +15018,7 @@ function LanguageDropdown({
14743
15018
  disabled
14744
15019
  }) {
14745
15020
  const [open, setOpen] = useState25(false);
14746
- const containerRef = useRef11(null);
15021
+ const containerRef = useRef12(null);
14747
15022
  useEffect20(() => {
14748
15023
  if (!open) return;
14749
15024
  function handleMouseDown(e) {
@@ -14870,7 +15145,7 @@ function ProfileTab() {
14870
15145
  const [imagePreview, setImagePreview] = useState25(
14871
15146
  void 0
14872
15147
  );
14873
- const fileInputRef = useRef11(null);
15148
+ const fileInputRef = useRef12(null);
14874
15149
  const profileDisplayName = fullName || user?.email || "User";
14875
15150
  const profileImage = imagePreview ?? getUserProfileImage(user);
14876
15151
  const profileInitial = profileDisplayName.charAt(0).toUpperCase();
@@ -15320,13 +15595,13 @@ function WorkspaceListTab({
15320
15595
  const pageWorkspaces = pageRows.map((row) => row.ws);
15321
15596
  const listLoading = loading || serverMode && !serverPage;
15322
15597
  const [plans, setPlans] = useState25({});
15323
- const requestedPlans = useRef11(/* @__PURE__ */ new Set());
15598
+ const requestedPlans = useRef12(/* @__PURE__ */ new Set());
15324
15599
  const visibleIds = [
15325
15600
  ...currentWorkspace ? [currentWorkspace._id] : [],
15326
15601
  ...pageWorkspaces.map((ws) => ws._id)
15327
15602
  ];
15328
15603
  const visibleKey = visibleIds.join(",");
15329
- const mounted = useRef11(true);
15604
+ const mounted = useRef12(true);
15330
15605
  useEffect20(() => {
15331
15606
  mounted.current = true;
15332
15607
  return () => {
@@ -17262,9 +17537,9 @@ function OrganizationPicker({
17262
17537
  }
17263
17538
 
17264
17539
  // src/use-billing-entitlement.ts
17265
- import { useEffect as useEffect22, useRef as useRef12, useState as useState28 } from "react";
17540
+ import { useEffect as useEffect22, useRef as useRef13, useState as useState28 } from "react";
17266
17541
  function useBillingEntitlement(fetchCurrentPlan, key) {
17267
- const fetchRef = useRef12(fetchCurrentPlan);
17542
+ const fetchRef = useRef13(fetchCurrentPlan);
17268
17543
  fetchRef.current = fetchCurrentPlan;
17269
17544
  const [state, setState] = useState28(null);
17270
17545
  const [loading, setLoading] = useState28(false);
@@ -17519,6 +17794,7 @@ export {
17519
17794
  minimumCreditLimit,
17520
17795
  ownCreditsFirstText,
17521
17796
  parseBillingEntitlement,
17797
+ parseInviteEmails,
17522
17798
  pausedOwnCreditsText,
17523
17799
  poolEndsAtFrom,
17524
17800
  poolErrorMessage,