@datatechsolutions/ui 3.11.0 → 3.11.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.
Files changed (89) hide show
  1. package/dist/astrlabe/index.js +108 -108
  2. package/dist/astrlabe/index.mjs +4 -4
  3. package/dist/astrlabe/workflow-canvas.js +4 -4
  4. package/dist/astrlabe/workflow-canvas.mjs +3 -3
  5. package/dist/{chunk-K4AJL4BH.mjs → chunk-3U3CIARA.mjs} +3 -3
  6. package/dist/{chunk-K4AJL4BH.mjs.map → chunk-3U3CIARA.mjs.map} +1 -1
  7. package/dist/{chunk-TCIK6WHT.mjs → chunk-7DZ2C5IN.mjs} +4 -4
  8. package/dist/{chunk-TCIK6WHT.mjs.map → chunk-7DZ2C5IN.mjs.map} +1 -1
  9. package/dist/{chunk-H475T2N7.js → chunk-APONR6ZM.js} +135 -135
  10. package/dist/{chunk-H475T2N7.js.map → chunk-APONR6ZM.js.map} +1 -1
  11. package/dist/{chunk-7MPIYSRH.js → chunk-BTMHQCDB.js} +36 -36
  12. package/dist/{chunk-7MPIYSRH.js.map → chunk-BTMHQCDB.js.map} +1 -1
  13. package/dist/{chunk-G52HXPSB.js → chunk-CLXEVSGB.js} +13 -13
  14. package/dist/{chunk-G52HXPSB.js.map → chunk-CLXEVSGB.js.map} +1 -1
  15. package/dist/{chunk-GTJGX7IZ.js → chunk-CVCMJJ56.js} +10 -10
  16. package/dist/{chunk-GTJGX7IZ.js.map → chunk-CVCMJJ56.js.map} +1 -1
  17. package/dist/{chunk-35O2X7WY.js → chunk-DPXCJVJT.js} +9 -9
  18. package/dist/{chunk-35O2X7WY.js.map → chunk-DPXCJVJT.js.map} +1 -1
  19. package/dist/{chunk-ZJMYLUZ2.mjs → chunk-E3NMVWRL.mjs} +4 -4
  20. package/dist/{chunk-ZJMYLUZ2.mjs.map → chunk-E3NMVWRL.mjs.map} +1 -1
  21. package/dist/{chunk-KTEEXEAX.mjs → chunk-I77TTBYO.mjs} +6 -6
  22. package/dist/{chunk-KTEEXEAX.mjs.map → chunk-I77TTBYO.mjs.map} +1 -1
  23. package/dist/{chunk-3US2QXEF.mjs → chunk-IHOCYBHM.mjs} +3 -3
  24. package/dist/{chunk-3US2QXEF.mjs.map → chunk-IHOCYBHM.mjs.map} +1 -1
  25. package/dist/{chunk-NM3YTQ26.mjs → chunk-K3LIDGMA.mjs} +3 -3
  26. package/dist/{chunk-NM3YTQ26.mjs.map → chunk-K3LIDGMA.mjs.map} +1 -1
  27. package/dist/{chunk-Z6FZQOTW.js → chunk-KDVZIDVF.js} +28 -28
  28. package/dist/{chunk-Z6FZQOTW.js.map → chunk-KDVZIDVF.js.map} +1 -1
  29. package/dist/{chunk-2AJ73ULK.mjs → chunk-LHAOIPYP.mjs} +3 -3
  30. package/dist/{chunk-2AJ73ULK.mjs.map → chunk-LHAOIPYP.mjs.map} +1 -1
  31. package/dist/{chunk-GKI74CPB.js → chunk-LM6BJOKX.js} +55 -55
  32. package/dist/{chunk-GKI74CPB.js.map → chunk-LM6BJOKX.js.map} +1 -1
  33. package/dist/{chunk-BO3RXG6M.js → chunk-MN777KLN.js} +45 -45
  34. package/dist/{chunk-BO3RXG6M.js.map → chunk-MN777KLN.js.map} +1 -1
  35. package/dist/{chunk-62BD4WLW.js → chunk-NW32BM3F.js} +34 -34
  36. package/dist/{chunk-62BD4WLW.js.map → chunk-NW32BM3F.js.map} +1 -1
  37. package/dist/{chunk-R3CGJK7D.mjs → chunk-O4DIKNNH.mjs} +3 -3
  38. package/dist/{chunk-R3CGJK7D.mjs.map → chunk-O4DIKNNH.mjs.map} +1 -1
  39. package/dist/{chunk-BCJATFZE.js → chunk-OD2AZBEX.js} +25 -25
  40. package/dist/{chunk-BCJATFZE.js.map → chunk-OD2AZBEX.js.map} +1 -1
  41. package/dist/{chunk-35P352JX.mjs → chunk-OKCEK7GH.mjs} +3 -3
  42. package/dist/{chunk-35P352JX.mjs.map → chunk-OKCEK7GH.mjs.map} +1 -1
  43. package/dist/{chunk-O2CUOJ74.js → chunk-OO4YMN4P.js} +4 -4
  44. package/dist/{chunk-O2CUOJ74.js.map → chunk-OO4YMN4P.js.map} +1 -1
  45. package/dist/{chunk-6TKCMQ75.js → chunk-OSXBMLZP.js} +68 -68
  46. package/dist/{chunk-6TKCMQ75.js.map → chunk-OSXBMLZP.js.map} +1 -1
  47. package/dist/{chunk-7V7WEXHS.mjs → chunk-Q6MMJYEG.mjs} +3 -3
  48. package/dist/{chunk-7V7WEXHS.mjs.map → chunk-Q6MMJYEG.mjs.map} +1 -1
  49. package/dist/{chunk-PHBZ3TXE.js → chunk-QASAHGLE.js} +4 -4
  50. package/dist/{chunk-PHBZ3TXE.js.map → chunk-QASAHGLE.js.map} +1 -1
  51. package/dist/{chunk-7D52TFVL.mjs → chunk-QDW3IJIL.mjs} +3 -3
  52. package/dist/{chunk-7D52TFVL.mjs.map → chunk-QDW3IJIL.mjs.map} +1 -1
  53. package/dist/{chunk-HUAWGBYL.mjs → chunk-QKWNQOJB.mjs} +3 -3
  54. package/dist/{chunk-HUAWGBYL.mjs.map → chunk-QKWNQOJB.mjs.map} +1 -1
  55. package/dist/{chunk-NRVV4PHB.mjs → chunk-S46LUR7O.mjs} +7 -7
  56. package/dist/{chunk-NRVV4PHB.mjs.map → chunk-S46LUR7O.mjs.map} +1 -1
  57. package/dist/{chunk-37FWIPYO.mjs → chunk-S4LHC5SF.mjs} +3 -3
  58. package/dist/{chunk-37FWIPYO.mjs.map → chunk-S4LHC5SF.mjs.map} +1 -1
  59. package/dist/{chunk-JTD3BBVI.js → chunk-SSKKTSMA.js} +35 -35
  60. package/dist/{chunk-JTD3BBVI.js.map → chunk-SSKKTSMA.js.map} +1 -1
  61. package/dist/{chunk-ZGVN23J4.js → chunk-TIJXCRM4.js} +3 -3
  62. package/dist/{chunk-ZGVN23J4.js.map → chunk-TIJXCRM4.js.map} +1 -1
  63. package/dist/{chunk-7KPMLHPR.mjs → chunk-VHU5FWFB.mjs} +3 -3
  64. package/dist/{chunk-7KPMLHPR.mjs.map → chunk-VHU5FWFB.mjs.map} +1 -1
  65. package/dist/index.js +663 -663
  66. package/dist/index.mjs +2 -2
  67. package/dist/platform/admin/index.js +10 -10
  68. package/dist/platform/admin/index.mjs +4 -4
  69. package/dist/platform/agents-workspace.js +7 -7
  70. package/dist/platform/agents-workspace.mjs +6 -6
  71. package/dist/platform/app-shell.js +4 -4
  72. package/dist/platform/app-shell.mjs +3 -3
  73. package/dist/platform/auth/index.js +22 -22
  74. package/dist/platform/auth/index.mjs +4 -4
  75. package/dist/platform/billing/index.js +4 -4
  76. package/dist/platform/billing/index.mjs +3 -3
  77. package/dist/platform/impersonation/index.js +4 -4
  78. package/dist/platform/impersonation/index.mjs +3 -3
  79. package/dist/platform/index.js +78 -78
  80. package/dist/platform/index.mjs +18 -18
  81. package/dist/platform/pages/index.js +471 -473
  82. package/dist/platform/pages/index.js.map +1 -1
  83. package/dist/platform/pages/index.mjs +173 -175
  84. package/dist/platform/pages/index.mjs.map +1 -1
  85. package/dist/platform/settings/index.js +7 -7
  86. package/dist/platform/settings/index.mjs +6 -6
  87. package/dist/platform/workflow-canvas-shell.js +5 -5
  88. package/dist/platform/workflow-canvas-shell.mjs +4 -4
  89. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkBCJATFZE_js = require('./chunk-BCJATFZE.js');
5
- var chunkBO3RXG6M_js = require('./chunk-BO3RXG6M.js');
6
- var chunkGTJGX7IZ_js = require('./chunk-GTJGX7IZ.js');
7
- var chunkZGVN23J4_js = require('./chunk-ZGVN23J4.js');
4
+ var chunkOD2AZBEX_js = require('./chunk-OD2AZBEX.js');
5
+ var chunkMN777KLN_js = require('./chunk-MN777KLN.js');
6
+ var chunkCVCMJJ56_js = require('./chunk-CVCMJJ56.js');
7
+ var chunkTIJXCRM4_js = require('./chunk-TIJXCRM4.js');
8
8
  var chunkYXN2K77G_js = require('./chunk-YXN2K77G.js');
9
9
  var react = require('react');
10
10
  var jsxRuntime = require('react/jsx-runtime');
@@ -18,7 +18,7 @@ function PlatformSettings({
18
18
  billing
19
19
  }) {
20
20
  const t = chunkYXN2K77G_js.useTranslations("windsock");
21
- const { status } = chunkZGVN23J4_js.useAuth();
21
+ const { status } = chunkTIJXCRM4_js.useAuth();
22
22
  const visibleSections = react.useMemo(() => {
23
23
  return sections.filter((section) => {
24
24
  if (section === "organization") {
@@ -54,7 +54,7 @@ function PlatformSettings({
54
54
  };
55
55
  }, [activeSection, adminClient, organizationId, organization?.id]);
56
56
  if (status === "loading") {
57
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(chunkZGVN23J4_js.InlineSpinner, {}) });
57
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(chunkTIJXCRM4_js.InlineSpinner, {}) });
58
58
  }
59
59
  if (status !== "authenticated") {
60
60
  return null;
@@ -68,7 +68,7 @@ function PlatformSettings({
68
68
  }));
69
69
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
70
70
  visibleSections.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
71
- chunkZGVN23J4_js.SegmentedControl,
71
+ chunkTIJXCRM4_js.SegmentedControl,
72
72
  {
73
73
  segments,
74
74
  value: activeSection,
@@ -76,9 +76,9 @@ function PlatformSettings({
76
76
  fullWidth: true
77
77
  }
78
78
  ),
79
- activeSection === "account" && /* @__PURE__ */ jsxRuntime.jsx(chunkBO3RXG6M_js.UserProfile, {}),
79
+ activeSection === "account" && /* @__PURE__ */ jsxRuntime.jsx(chunkMN777KLN_js.UserProfile, {}),
80
80
  activeSection === "organization" && adminClient && organizationId && (organization ? /* @__PURE__ */ jsxRuntime.jsx(
81
- chunkBCJATFZE_js.AdminOrganizationDetail,
81
+ chunkOD2AZBEX_js.AdminOrganizationDetail,
82
82
  {
83
83
  client: adminClient,
84
84
  organization
@@ -90,11 +90,11 @@ function PlatformSettings({
90
90
  className: "rounded-xl border border-red-300/40 bg-red-50/80 px-4 py-3 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300",
91
91
  children: orgLoadError
92
92
  }
93
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(chunkZGVN23J4_js.InlineSpinner, {}) })),
94
- activeSection === "billing" && /* @__PURE__ */ jsxRuntime.jsx(chunkGTJGX7IZ_js.BillingPanel, { ...billing })
93
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(chunkTIJXCRM4_js.InlineSpinner, {}) })),
94
+ activeSection === "billing" && /* @__PURE__ */ jsxRuntime.jsx(chunkCVCMJJ56_js.BillingPanel, { ...billing })
95
95
  ] });
96
96
  }
97
97
 
98
98
  exports.PlatformSettings = PlatformSettings;
99
- //# sourceMappingURL=chunk-G52HXPSB.js.map
100
- //# sourceMappingURL=chunk-G52HXPSB.js.map
99
+ //# sourceMappingURL=chunk-CLXEVSGB.js.map
100
+ //# sourceMappingURL=chunk-CLXEVSGB.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/platform/settings/platform-settings.tsx"],"names":["useTranslations","useAuth","useMemo","useState","useEffect","jsx","InlineSpinner","jsxs","SegmentedControl","UserProfile","AdminOrganizationDetail","BillingPanel"],"mappings":";;;;;;;;;;AA+CA,IAAM,gBAAA,GAA8C,CAAC,SAAA,EAAW,cAAA,EAAgB,SAAS,CAAA;AAElF,SAAS,gBAAA,CAAiB;AAAA,EAC/B,QAAA,GAAW,gBAAA;AAAA,EACX,cAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,EAA0B;AACxB,EAAA,MAAM,CAAA,GAAIA,iCAAgB,UAAU,CAAA;AACpC,EA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AC,KAAA,KAAkB,gBAAA,CAAiB,KAAgC,CAAA;AAAA,QAC9E,SAAA,EAAS;AAAA;AAAA,KACX;AAAA,IAGD,aAAA,KAAkB,SAAA,oBAAaH,cAAA,CAACI,4BAAA,EAAA,EAAY,CAAA;AAAA,IAE5C,aAAA,KAAkB,cAAA,IAAkB,WAAA,IAAe,cAAA,KAClD,YAAA,mBACEJ,cAAA;AAAA,MAACK,wCAAA;AAAA,MAAA;AAAA,QACC,MAAA,EAAQ,WAAA;AAAA,QACR;AAAA;AAAA,QAEA,YAAA,mBACFL,cAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,IAAA,EAAK,OAAA;AAAA,QACL,SAAA,EAAU,6IAAA;AAAA,QAET,QAAA,EAAA;AAAA;AAAA,wBAGHA,cAAA,CAAC,KAAA,EAAA,EAAI,WAAU,wCAAA,EACb,QAAA,kBAAAA,cAAA,CAACC,kCAAc,CAAA,EACjB,CAAA,CAAA;AAAA,IAIH,aAAA,KAAkB,SAAA,oBAAaD,cAAA,CAACM,6BAAA,EAAA,EAAc,GAAG,OAAA,EAAS;AAAA,GAAA,EAC7D,CAAA;AAEJ","file":"chunk-G52HXPSB.js","sourcesContent":["// =============================================================================\n// @datatechsolutions/windsock/ui — PlatformSettings\n// Unified settings shell consumed by every product (astrlabe, kori).\n// Composes existing building blocks:\n// - `<UserProfile>` — Profile / Security / Sessions / Linked accounts\n// - `<AdminOrganizationDetail>` — Members / Invitations / Domains\n// - `<BillingPanel>` — Current subscription + plan catalogue\n// Apps mount this at their `/settings` route; feature toggles hide sections\n// that a given user's role cannot access.\n// =============================================================================\n\nimport { useEffect, useMemo, useState } from 'react'\nimport { useTranslations } from '@ui/lib/i18n-context'\nimport { SegmentedControl, InlineSpinner } from '@ui/index'\nimport type { AdminClient, AuthOrganization } from '@datatechsolutions/shared-domain'\n\nimport { useAuth } from '../../_auth'\nimport { UserProfile } from '../auth/user-profile'\nimport { AdminOrganizationDetail } from '../admin/admin-organization-detail'\nimport { BillingPanel, type BillingPanelProps } from '../billing/billing-panel'\n\nexport type PlatformSettingsSection = 'account' | 'organization' | 'billing'\n\nexport interface PlatformSettingsProps {\n /**\n * Sections to surface to the current user. The host app is responsible for\n * picking the right set based on RBAC — e.g. hide `organization` for users\n * without `org:manage` and hide `billing` for users without `billing:read`.\n * Defaults to all three.\n */\n sections?: PlatformSettingsSection[]\n /** Starting section. Defaults to the first item in `sections`. */\n defaultSection?: PlatformSettingsSection\n /**\n * Windsock admin API client. Required when `organization` is in `sections`.\n * Create it once with `createAdminClient({ issuer, authClient })` and reuse.\n */\n adminClient?: AdminClient\n /**\n * Current organization id (usually `ctx.organizationId` from the JWT).\n * Required when `organization` is in `sections`.\n */\n organizationId?: string\n /** Forwarded to `<BillingPanel>` — e.g. redirect handler, billing interval. */\n billing?: BillingPanelProps\n}\n\nconst DEFAULT_SECTIONS: PlatformSettingsSection[] = ['account', 'organization', 'billing']\n\nexport function PlatformSettings({\n sections = DEFAULT_SECTIONS,\n defaultSection,\n adminClient,\n organizationId,\n billing,\n}: PlatformSettingsProps) {\n const t = useTranslations('windsock')\n const { status } = useAuth()\n\n const visibleSections = useMemo(() => {\n // Drop `organization` if the caller didn't pass an admin client + org id.\n return sections.filter((section) => {\n if (section === 'organization') {\n return Boolean(adminClient && organizationId)\n }\n return true\n })\n }, [sections, adminClient, organizationId])\n\n const initialSection: PlatformSettingsSection = (\n defaultSection && visibleSections.includes(defaultSection)\n ? defaultSection\n : visibleSections[0] ?? 'account'\n )\n\n const [activeSection, setActiveSection] = useState<PlatformSettingsSection>(initialSection)\n const [organization, setOrganization] = useState<AuthOrganization | null>(null)\n const [orgLoadError, setOrgLoadError] = useState<string | null>(null)\n\n // Resolve the org detail record (AdminOrganizationDetail needs the full\n // AuthOrganization, not just the id). Fires once the organization tab is\n // first selected so the listOrganizations round-trip is lazy.\n useEffect(() => {\n if (activeSection !== 'organization') return\n if (!adminClient || !organizationId) return\n if (organization?.id === organizationId) return\n\n let cancelled = false\n setOrgLoadError(null)\n void adminClient.listOrganizations()\n .then((orgs) => {\n if (cancelled) return\n const match = orgs.find((org) => org.id === organizationId)\n if (match) {\n setOrganization(match)\n } else {\n setOrgLoadError('Organization not found')\n }\n })\n .catch((loadError: unknown) => {\n if (cancelled) return\n setOrgLoadError(loadError instanceof Error ? loadError.message : String(loadError))\n })\n return () => {\n cancelled = true\n }\n }, [activeSection, adminClient, organizationId, organization?.id])\n\n if (status === 'loading') {\n return (\n <div className=\"flex items-center justify-center py-12\">\n <InlineSpinner />\n </div>\n )\n }\n\n if (status !== 'authenticated') {\n return null\n }\n\n if (visibleSections.length === 0) {\n return null\n }\n\n const segments = visibleSections.map((section) => ({\n value: section,\n label: t(`platformSettings.sections.${section}`),\n }))\n\n return (\n <div className=\"space-y-6\">\n {visibleSections.length > 1 && (\n <SegmentedControl\n segments={segments}\n value={activeSection}\n onChange={(value: string) => setActiveSection(value as PlatformSettingsSection)}\n fullWidth\n />\n )}\n\n {activeSection === 'account' && <UserProfile />}\n\n {activeSection === 'organization' && adminClient && organizationId && (\n organization ? (\n <AdminOrganizationDetail\n client={adminClient}\n organization={organization}\n />\n ) : orgLoadError ? (\n <div\n role=\"alert\"\n className=\"rounded-xl border border-red-300/40 bg-red-50/80 px-4 py-3 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300\"\n >\n {orgLoadError}\n </div>\n ) : (\n <div className=\"flex items-center justify-center py-12\">\n <InlineSpinner />\n </div>\n )\n )}\n\n {activeSection === 'billing' && <BillingPanel {...billing} />}\n </div>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/platform/settings/platform-settings.tsx"],"names":["useTranslations","useAuth","useMemo","useState","useEffect","jsx","InlineSpinner","jsxs","SegmentedControl","UserProfile","AdminOrganizationDetail","BillingPanel"],"mappings":";;;;;;;;;;AA+CA,IAAM,gBAAA,GAA8C,CAAC,SAAA,EAAW,cAAA,EAAgB,SAAS,CAAA;AAElF,SAAS,gBAAA,CAAiB;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EACZ,QAAA,EAAA;AAAA,IAAA,eAAA,CAAgB,SAAS,CAAA,oBACxBF,cAAA;AAAA,MAACG,iCAAA;AAAA,MAAA;AAAA,QACC,QAAA;AAAA,QACA,KAAA,EAAO,aAAA;AAAA,QACP,QAAA,EAAU,CAAC,KAAA,KAAkB,gBAAA,CAAiB,KAAgC,CAAA;AAAA,QAC9E,SAAA,EAAS;AAAA;AAAA,KACX;AAAA,IAGD,aAAA,KAAkB,SAAA,oBAAaH,cAAA,CAACI,4BAAA,EAAA,EAAY,CAAA;AAAA,IAE5C,aAAA,KAAkB,cAAA,IAAkB,WAAA,IAAe,cAAA,KAClD,YAAA,mBACEJ,cAAA;AAAA,MAACK,wCAAA;AAAA,MAAA;AAAA,QACC,MAAA,EAAQ,WAAA;AAAA,QACR;AAAA;AAAA,QAEA,YAAA,mBACFL,cAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,IAAA,EAAK,OAAA;AAAA,QACL,SAAA,EAAU,6IAAA;AAAA,QAET,QAAA,EAAA;AAAA;AAAA,wBAGHA,cAAA,CAAC,KAAA,EAAA,EAAI,WAAU,wCAAA,EACb,QAAA,kBAAAA,cAAA,CAACC,kCAAc,CAAA,EACjB,CAAA,CAAA;AAAA,IAIH,aAAA,KAAkB,SAAA,oBAAaD,cAAA,CAACM,6BAAA,EAAA,EAAc,GAAG,OAAA,EAAS;AAAA,GAAA,EAC7D,CAAA;AAEJ","file":"chunk-CLXEVSGB.js","sourcesContent":["// =============================================================================\n// @datatechsolutions/windsock/ui — PlatformSettings\n// Unified settings shell consumed by every product (astrlabe, kori).\n// Composes existing building blocks:\n// - `<UserProfile>` — Profile / Security / Sessions / Linked accounts\n// - `<AdminOrganizationDetail>` — Members / Invitations / Domains\n// - `<BillingPanel>` — Current subscription + plan catalogue\n// Apps mount this at their `/settings` route; feature toggles hide sections\n// that a given user's role cannot access.\n// =============================================================================\n\nimport { useEffect, useMemo, useState } from 'react'\nimport { useTranslations } from '@ui/lib/i18n-context'\nimport { SegmentedControl, InlineSpinner } from '@ui/index'\nimport type { AdminClient, AuthOrganization } from '@datatechsolutions/shared-domain'\n\nimport { useAuth } from '../../_auth'\nimport { UserProfile } from '../auth/user-profile'\nimport { AdminOrganizationDetail } from '../admin/admin-organization-detail'\nimport { BillingPanel, type BillingPanelProps } from '../billing/billing-panel'\n\nexport type PlatformSettingsSection = 'account' | 'organization' | 'billing'\n\nexport interface PlatformSettingsProps {\n /**\n * Sections to surface to the current user. The host app is responsible for\n * picking the right set based on RBAC — e.g. hide `organization` for users\n * without `org:manage` and hide `billing` for users without `billing:read`.\n * Defaults to all three.\n */\n sections?: PlatformSettingsSection[]\n /** Starting section. Defaults to the first item in `sections`. */\n defaultSection?: PlatformSettingsSection\n /**\n * Windsock admin API client. Required when `organization` is in `sections`.\n * Create it once with `createAdminClient({ issuer, authClient })` and reuse.\n */\n adminClient?: AdminClient\n /**\n * Current organization id (usually `ctx.organizationId` from the JWT).\n * Required when `organization` is in `sections`.\n */\n organizationId?: string\n /** Forwarded to `<BillingPanel>` — e.g. redirect handler, billing interval. */\n billing?: BillingPanelProps\n}\n\nconst DEFAULT_SECTIONS: PlatformSettingsSection[] = ['account', 'organization', 'billing']\n\nexport function PlatformSettings({\n sections = DEFAULT_SECTIONS,\n defaultSection,\n adminClient,\n organizationId,\n billing,\n}: PlatformSettingsProps) {\n const t = useTranslations('windsock')\n const { status } = useAuth()\n\n const visibleSections = useMemo(() => {\n // Drop `organization` if the caller didn't pass an admin client + org id.\n return sections.filter((section) => {\n if (section === 'organization') {\n return Boolean(adminClient && organizationId)\n }\n return true\n })\n }, [sections, adminClient, organizationId])\n\n const initialSection: PlatformSettingsSection = (\n defaultSection && visibleSections.includes(defaultSection)\n ? defaultSection\n : visibleSections[0] ?? 'account'\n )\n\n const [activeSection, setActiveSection] = useState<PlatformSettingsSection>(initialSection)\n const [organization, setOrganization] = useState<AuthOrganization | null>(null)\n const [orgLoadError, setOrgLoadError] = useState<string | null>(null)\n\n // Resolve the org detail record (AdminOrganizationDetail needs the full\n // AuthOrganization, not just the id). Fires once the organization tab is\n // first selected so the listOrganizations round-trip is lazy.\n useEffect(() => {\n if (activeSection !== 'organization') return\n if (!adminClient || !organizationId) return\n if (organization?.id === organizationId) return\n\n let cancelled = false\n setOrgLoadError(null)\n void adminClient.listOrganizations()\n .then((orgs) => {\n if (cancelled) return\n const match = orgs.find((org) => org.id === organizationId)\n if (match) {\n setOrganization(match)\n } else {\n setOrgLoadError('Organization not found')\n }\n })\n .catch((loadError: unknown) => {\n if (cancelled) return\n setOrgLoadError(loadError instanceof Error ? loadError.message : String(loadError))\n })\n return () => {\n cancelled = true\n }\n }, [activeSection, adminClient, organizationId, organization?.id])\n\n if (status === 'loading') {\n return (\n <div className=\"flex items-center justify-center py-12\">\n <InlineSpinner />\n </div>\n )\n }\n\n if (status !== 'authenticated') {\n return null\n }\n\n if (visibleSections.length === 0) {\n return null\n }\n\n const segments = visibleSections.map((section) => ({\n value: section,\n label: t(`platformSettings.sections.${section}`),\n }))\n\n return (\n <div className=\"space-y-6\">\n {visibleSections.length > 1 && (\n <SegmentedControl\n segments={segments}\n value={activeSection}\n onChange={(value: string) => setActiveSection(value as PlatformSettingsSection)}\n fullWidth\n />\n )}\n\n {activeSection === 'account' && <UserProfile />}\n\n {activeSection === 'organization' && adminClient && organizationId && (\n organization ? (\n <AdminOrganizationDetail\n client={adminClient}\n organization={organization}\n />\n ) : orgLoadError ? (\n <div\n role=\"alert\"\n className=\"rounded-xl border border-red-300/40 bg-red-50/80 px-4 py-3 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300\"\n >\n {orgLoadError}\n </div>\n ) : (\n <div className=\"flex items-center justify-center py-12\">\n <InlineSpinner />\n </div>\n )\n )}\n\n {activeSection === 'billing' && <BillingPanel {...billing} />}\n </div>\n )\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkZGVN23J4_js = require('./chunk-ZGVN23J4.js');
4
+ var chunkTIJXCRM4_js = require('./chunk-TIJXCRM4.js');
5
5
  var chunkYXN2K77G_js = require('./chunk-YXN2K77G.js');
6
6
  var chunkBHOT22QL_js = require('./chunk-BHOT22QL.js');
7
7
  var chunkUZ3CMNUJ_js = require('./chunk-UZ3CMNUJ.js');
@@ -20,7 +20,7 @@ function BillingPanel({
20
20
  }) {
21
21
  const t = chunkYXN2K77G_js.useTranslations("windsock");
22
22
  const format = chunkYXN2K77G_js.useFormatter();
23
- const { client } = chunkZGVN23J4_js.useAuth();
23
+ const { client } = chunkTIJXCRM4_js.useAuth();
24
24
  const [subscription, setSubscription] = react.useState(null);
25
25
  const [plans, setPlans] = react.useState([]);
26
26
  const [isLoading, setIsLoading] = react.useState(true);
@@ -104,7 +104,7 @@ function BillingPanel({
104
104
  }
105
105
  }, [client, load, t]);
106
106
  if (isLoading) {
107
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(chunkZGVN23J4_js.InlineSpinner, {}) });
107
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(chunkTIJXCRM4_js.InlineSpinner, {}) });
108
108
  }
109
109
  const currentPlan = subscription?.plan ?? plans.find((plan) => plan.id === subscription?.planId) ?? null;
110
110
  const currentTier = subscription?.tier ?? currentPlan?.tier ?? null;
@@ -118,7 +118,7 @@ function BillingPanel({
118
118
  }
119
119
  ),
120
120
  /* @__PURE__ */ jsxRuntime.jsx(
121
- chunkZGVN23J4_js.SectionCard,
121
+ chunkTIJXCRM4_js.SectionCard,
122
122
  {
123
123
  header: {
124
124
  title: t("billing.currentPlan.title"),
@@ -128,7 +128,7 @@ function BillingPanel({
128
128
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
129
129
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: currentPlan.name }),
130
130
  /* @__PURE__ */ jsxRuntime.jsx(
131
- chunkZGVN23J4_js.StatusBadge,
131
+ chunkTIJXCRM4_js.StatusBadge,
132
132
  {
133
133
  status: subscription.status === "active" ? "success" : subscription.status === "past_due" ? "pending" : "error",
134
134
  label: t(`billing.status.${subscription.status}`)
@@ -180,17 +180,17 @@ function BillingPanel({
180
180
  }
181
181
  ),
182
182
  /* @__PURE__ */ jsxRuntime.jsx(
183
- chunkZGVN23J4_js.SectionCard,
183
+ chunkTIJXCRM4_js.SectionCard,
184
184
  {
185
185
  header: {
186
186
  title: t("billing.plans.title"),
187
187
  subtitle: t("billing.plans.description")
188
188
  },
189
- children: plans.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: t("billing.plans.empty") }) : /* @__PURE__ */ jsxRuntime.jsx(chunkZGVN23J4_js.ListCard, { children: plans.map((plan) => {
189
+ children: plans.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: t("billing.plans.empty") }) : /* @__PURE__ */ jsxRuntime.jsx(chunkTIJXCRM4_js.ListCard, { children: plans.map((plan) => {
190
190
  const isCurrent = currentPlan?.id === plan.id;
191
191
  const isDowngrade = currentTier != null && (TIER_ORDER[plan.tier] ?? 0) < (TIER_ORDER[currentTier] ?? 0);
192
192
  return /* @__PURE__ */ jsxRuntime.jsx(
193
- chunkZGVN23J4_js.ListCardItem,
193
+ chunkTIJXCRM4_js.ListCardItem,
194
194
  {
195
195
  leading: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-xl bg-gradient-to-br from-violet-500/20 to-blue-500/20 text-violet-600 dark:text-violet-300", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-bold uppercase", children: plan.tier.charAt(0) }) }),
196
196
  trailing: isCurrent ? /* @__PURE__ */ jsxRuntime.jsx(chunkBHOT22QL_js.Badge, { color: "green", children: t("billing.plans.currentBadge") }) : isDowngrade ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -237,5 +237,5 @@ function BillingPanel({
237
237
  }
238
238
 
239
239
  exports.BillingPanel = BillingPanel;
240
- //# sourceMappingURL=chunk-GTJGX7IZ.js.map
241
- //# sourceMappingURL=chunk-GTJGX7IZ.js.map
240
+ //# sourceMappingURL=chunk-CVCMJJ56.js.map
241
+ //# sourceMappingURL=chunk-CVCMJJ56.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/platform/billing/billing-panel.tsx"],"names":["useTranslations","useFormatter","useAuth","useState","useCallback","useEffect","triggerHaptic","jsx","InlineSpinner","jsxs","SectionCard","StatusBadge","Badge","Button","ListCard","ListCardItem"],"mappings":";;;;;;;;;AAyCA,IAAM,UAAA,GAA+C;AAAA,EACnD,UAAA,EAAY,CAAA;AAAA,EACZ,OAAA,EAAS,CAAA;AAAA,EACT,YAAA,EAAc,CAAA;AAAA,EACd,UAAA,EAAY;AACd,CAAA;AAEO,SAAS,YAAA,CAAa;AAAA,EAC3B,sBAAA,GAAyB,SAAA;AAAA,EACzB;AACF,CAAA,EAAsB;AACpB,EAAA,MAAM,CAAA,GAAIA,iCAAgB,UAAU,CAAA;AACpC,EAAA,MAAM,SAASC,6BAAA,EAAa;AAC5B,EAAA,MAAM,EAAE,MAAA,EAAO,GAAIC,wBAAA,EAAQ;AAE3B,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAIC,eAAqC,IAAI,CAAA;AACjF,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,cAAA,CAA2B,EAAE,CAAA;AACvD,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAIA,eAAS,IAAI,CAAA;AAC/C,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,eAAwB,IAAI,CAAA;AACtD,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,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AA,eAAA,CAAC,KAAA,EAAA,EAAI,WAAU,yBAAA,EACb,QAAA,EAAA;AAAA,kCAAAF,cAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,mDAAA,EACV,QAAA,EAAA,IAAA,CAAK,IAAA,EACR,CAAA;AAAA,kCACAE,eAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,0CAAA,EACb,QAAA,EAAA;AAAA,oBAAA,MAAA,CAAO,MAAA,CAAO,KAAK,KAAA,EAAO,EAAE,OAAO,UAAA,EAAY,QAAA,EAAU,IAAA,CAAK,QAAA,EAAU,CAAA;AAAA,oBACxE,GAAA;AAAA,oBAAI,GAAA;AAAA,oBAAE,GAAA;AAAA,oBACN,CAAA,CAAE,CAAA,iBAAA,EAAoB,IAAA,CAAK,QAAQ,CAAA,CAAE;AAAA,mBAAA,EACxC;AAAA,iBAAA,EACF,CAAA;AAAA,gBACC,KAAK,WAAA,oBACJF,cAAA,CAAC,OAAE,SAAA,EAAU,0CAAA,EACV,eAAK,WAAA,EACR;AAAA,eAAA,EAEJ;AAAA,aAAA;AAAA,YAlDK,IAAA,CAAK;AAAA,WAmDZ;AAAA,QAEJ,CAAC,CAAA,EACH;AAAA;AAAA;AAEJ,GAAA,EACF,CAAA;AAEJ","file":"chunk-GTJGX7IZ.js","sourcesContent":["// =============================================================================\n// @datatechsolutions/windsock/ui — BillingPanel\n// Shows the current organization subscription plus the plan catalogue, with\n// actions for opening the Stripe portal, starting checkout, or cancelling.\n// Backed by `AuthClient.getSubscription / getPlans / createPortalSession /\n// createCheckoutSession / cancelSubscription`.\n// =============================================================================\n\nimport { useEffect, useState, useCallback } from 'react'\nimport { useTranslations, useFormatter } from '@ui/lib/i18n-context'\nimport {\n SectionCard,\n Button,\n Badge,\n StatusBadge,\n InlineSpinner,\n ListCard,\n ListCardItem,\n triggerHaptic,\n} from '@ui/index'\nimport type {\n SubscriptionDetails,\n PlanDefinition,\n SubscriptionTier,\n} from '@datatechsolutions/shared-domain'\nimport { useAuth } from '../../_auth'\n\nexport interface BillingPanelProps {\n /**\n * Which billing interval to prefer when starting checkout. Defaults to\n * `'monthly'`. Surface a toggle in the host app if both matter.\n */\n defaultBillingInterval?: 'monthly' | 'yearly'\n /**\n * Called after the portal/checkout URL is resolved. Defaults to\n * `window.location.assign(url)`. Override to open in a new tab, use a\n * router, etc.\n */\n onRedirect?: (url: string) => void\n}\n\nconst TIER_ORDER: Record<SubscriptionTier, number> = {\n free_trial: 0,\n starter: 1,\n professional: 2,\n enterprise: 3,\n}\n\nexport function BillingPanel({\n defaultBillingInterval = 'monthly',\n onRedirect,\n}: BillingPanelProps) {\n const t = useTranslations('windsock')\n const format = useFormatter()\n const { client } = useAuth()\n\n const [subscription, setSubscription] = useState<SubscriptionDetails | null>(null)\n const [plans, setPlans] = useState<PlanDefinition[]>([])\n const [isLoading, setIsLoading] = useState(true)\n const [error, setError] = useState<string | null>(null)\n const [busyAction, setBusyAction] = useState<string | null>(null)\n\n const redirect = useCallback((url: string) => {\n if (onRedirect) {\n onRedirect(url)\n } else if (typeof window !== 'undefined') {\n window.location.assign(url)\n }\n }, [onRedirect])\n\n const load = useCallback(async () => {\n setIsLoading(true)\n setError(null)\n try {\n const [sub, availablePlans] = await Promise.all([\n client.getSubscription(),\n client.getPlans(),\n ])\n setSubscription(sub)\n setPlans(\n [...availablePlans]\n .filter((plan: { active: boolean }) => plan.active)\n .sort(\n (a: { tier: SubscriptionTier }, b: { tier: SubscriptionTier }) =>\n (TIER_ORDER[a.tier] ?? 0) - (TIER_ORDER[b.tier] ?? 0),\n ),\n )\n } catch (loadError) {\n setError(loadError instanceof Error ? loadError.message : String(loadError))\n } finally {\n setIsLoading(false)\n }\n }, [client])\n\n useEffect(() => {\n void load()\n }, [load])\n\n const handleOpenPortal = useCallback(async () => {\n setBusyAction('portal')\n triggerHaptic('light')\n try {\n const { url } = await client.createPortalSession()\n redirect(url)\n } catch (portalError) {\n setError(portalError instanceof Error ? portalError.message : String(portalError))\n triggerHaptic('error')\n } finally {\n setBusyAction(null)\n }\n }, [client, redirect])\n\n const handleStartCheckout = useCallback(async (planCode: string) => {\n setBusyAction(`checkout:${planCode}`)\n triggerHaptic('light')\n try {\n const { url } = await client.createCheckoutSession(planCode, defaultBillingInterval)\n redirect(url)\n } catch (checkoutError) {\n setError(checkoutError instanceof Error ? checkoutError.message : String(checkoutError))\n triggerHaptic('error')\n } finally {\n setBusyAction(null)\n }\n }, [client, defaultBillingInterval, redirect])\n\n const handleCancel = useCallback(async () => {\n if (typeof window !== 'undefined') {\n const confirmed = window.confirm(t('billing.cancelConfirm'))\n if (!confirmed) return\n }\n setBusyAction('cancel')\n triggerHaptic('warning')\n try {\n const result = await client.cancelSubscription()\n if (!result.success) {\n throw new Error(result.error ?? 'Subscription cancellation failed')\n }\n triggerHaptic('success')\n await load()\n } catch (cancelError) {\n setError(cancelError instanceof Error ? cancelError.message : String(cancelError))\n triggerHaptic('error')\n } finally {\n setBusyAction(null)\n }\n }, [client, load, t])\n\n if (isLoading) {\n return (\n <div className=\"flex items-center justify-center py-12\">\n <InlineSpinner />\n </div>\n )\n }\n\n const currentPlan = subscription?.plan ?? plans.find((plan) => plan.id === subscription?.planId) ?? null\n const currentTier = subscription?.tier ?? currentPlan?.tier ?? null\n\n return (\n <div className=\"space-y-6\">\n {error && (\n <div\n role=\"alert\"\n className=\"rounded-xl border border-red-300/40 bg-red-50/80 px-4 py-3 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300\"\n >\n {error}\n </div>\n )}\n\n <SectionCard\n header={{\n title: t('billing.currentPlan.title'),\n subtitle: t('billing.currentPlan.description'),\n }}\n >\n {subscription && currentPlan ? (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-center gap-3\">\n <span className=\"text-lg font-semibold text-gray-900 dark:text-white\">\n {currentPlan.name}\n </span>\n <StatusBadge\n status={\n subscription.status === 'active' ? 'success'\n : subscription.status === 'past_due' ? 'pending'\n : 'error'\n }\n label={t(`billing.status.${subscription.status}`)}\n />\n {subscription.cancelAtPeriodEnd && (\n <Badge color=\"amber\">{t('billing.currentPlan.cancelAtPeriodEnd')}</Badge>\n )}\n </div>\n\n <dl className=\"grid grid-cols-1 gap-3 text-sm sm:grid-cols-2\">\n <div>\n <dt className=\"text-gray-500 dark:text-gray-400\">\n {t('billing.currentPlan.price')}\n </dt>\n <dd className=\"font-medium text-gray-900 dark:text-white\">\n {format.number(currentPlan.price, { style: 'currency', currency: currentPlan.currency })}\n {' '}/{' '}\n {t(`billing.interval.${currentPlan.interval}`)}\n </dd>\n </div>\n {subscription.currentPeriodEnd && (\n <div>\n <dt className=\"text-gray-500 dark:text-gray-400\">\n {t('billing.currentPlan.renewsOn')}\n </dt>\n <dd className=\"font-medium text-gray-900 dark:text-white\">\n {format.dateTime(new Date(subscription.currentPeriodEnd), { dateStyle: 'medium' })}\n </dd>\n </div>\n )}\n </dl>\n\n <div className=\"flex flex-wrap gap-2 pt-2\">\n <Button\n size=\"sm\"\n color=\"ios-glass-blue\"\n onClick={handleOpenPortal}\n loading={busyAction === 'portal'}\n disabled={busyAction !== null}\n >\n {t('billing.currentPlan.manageInPortal')}\n </Button>\n {subscription.status === 'active' && !subscription.cancelAtPeriodEnd && (\n <Button\n size=\"sm\"\n color=\"ios-glass-red\"\n onClick={handleCancel}\n loading={busyAction === 'cancel'}\n disabled={busyAction !== null}\n >\n {t('billing.currentPlan.cancel')}\n </Button>\n )}\n </div>\n </div>\n ) : (\n <p className=\"text-sm text-gray-500 dark:text-gray-400\">\n {t('billing.currentPlan.noSubscription')}\n </p>\n )}\n </SectionCard>\n\n <SectionCard\n header={{\n title: t('billing.plans.title'),\n subtitle: t('billing.plans.description'),\n }}\n >\n {plans.length === 0 ? (\n <p className=\"text-sm text-gray-500 dark:text-gray-400\">\n {t('billing.plans.empty')}\n </p>\n ) : (\n <ListCard>\n {plans.map((plan) => {\n const isCurrent = currentPlan?.id === plan.id\n const isDowngrade = currentTier != null\n && (TIER_ORDER[plan.tier] ?? 0) < (TIER_ORDER[currentTier] ?? 0)\n return (\n <ListCardItem\n key={plan.id}\n leading={\n <div className=\"flex h-10 w-10 items-center justify-center rounded-xl bg-gradient-to-br from-violet-500/20 to-blue-500/20 text-violet-600 dark:text-violet-300\">\n <span className=\"text-sm font-bold uppercase\">{plan.tier.charAt(0)}</span>\n </div>\n }\n trailing={\n isCurrent ? (\n <Badge color=\"green\">{t('billing.plans.currentBadge')}</Badge>\n ) : (\n isDowngrade ? (\n <Button\n size=\"sm\"\n plain\n onClick={() => handleStartCheckout(plan.code)}\n loading={busyAction === `checkout:${plan.code}`}\n disabled={busyAction !== null}\n >\n {t('billing.plans.downgradeAction')}\n </Button>\n ) : (\n <Button\n size=\"sm\"\n color=\"ios-glass-blue\"\n onClick={() => handleStartCheckout(plan.code)}\n loading={busyAction === `checkout:${plan.code}`}\n disabled={busyAction !== null}\n >\n {t('billing.plans.selectAction')}\n </Button>\n )\n )\n }\n >\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex items-center gap-2\">\n <p className=\"text-sm font-medium text-gray-900 dark:text-white\">\n {plan.name}\n </p>\n <span className=\"text-xs text-gray-500 dark:text-gray-400\">\n {format.number(plan.price, { style: 'currency', currency: plan.currency })}\n {' '}/{' '}\n {t(`billing.interval.${plan.interval}`)}\n </span>\n </div>\n {plan.description && (\n <p className=\"text-xs text-gray-500 dark:text-gray-400\">\n {plan.description}\n </p>\n )}\n </div>\n </ListCardItem>\n )\n })}\n </ListCard>\n )}\n </SectionCard>\n </div>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/platform/billing/billing-panel.tsx"],"names":["useTranslations","useFormatter","useAuth","useState","useCallback","useEffect","triggerHaptic","jsx","InlineSpinner","jsxs","SectionCard","StatusBadge","Badge","Button","ListCard","ListCardItem"],"mappings":";;;;;;;;;AAyCA,IAAM,UAAA,GAA+C;AAAA,EACnD,UAAA,EAAY,CAAA;AAAA,EACZ,OAAA,EAAS,CAAA;AAAA,EACT,YAAA,E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AAA,EAAU,0CAAA,EACV,eAAK,WAAA,EACR;AAAA,eAAA,EAEJ;AAAA,aAAA;AAAA,YAlDK,IAAA,CAAK;AAAA,WAmDZ;AAAA,QAEJ,CAAC,CAAA,EACH;AAAA;AAAA;AAEJ,GAAA,EACF,CAAA;AAEJ","file":"chunk-CVCMJJ56.js","sourcesContent":["// =============================================================================\n// @datatechsolutions/windsock/ui — BillingPanel\n// Shows the current organization subscription plus the plan catalogue, with\n// actions for opening the Stripe portal, starting checkout, or cancelling.\n// Backed by `AuthClient.getSubscription / getPlans / createPortalSession /\n// createCheckoutSession / cancelSubscription`.\n// =============================================================================\n\nimport { useEffect, useState, useCallback } from 'react'\nimport { useTranslations, useFormatter } from '@ui/lib/i18n-context'\nimport {\n SectionCard,\n Button,\n Badge,\n StatusBadge,\n InlineSpinner,\n ListCard,\n ListCardItem,\n triggerHaptic,\n} from '@ui/index'\nimport type {\n SubscriptionDetails,\n PlanDefinition,\n SubscriptionTier,\n} from '@datatechsolutions/shared-domain'\nimport { useAuth } from '../../_auth'\n\nexport interface BillingPanelProps {\n /**\n * Which billing interval to prefer when starting checkout. Defaults to\n * `'monthly'`. Surface a toggle in the host app if both matter.\n */\n defaultBillingInterval?: 'monthly' | 'yearly'\n /**\n * Called after the portal/checkout URL is resolved. Defaults to\n * `window.location.assign(url)`. Override to open in a new tab, use a\n * router, etc.\n */\n onRedirect?: (url: string) => void\n}\n\nconst TIER_ORDER: Record<SubscriptionTier, number> = {\n free_trial: 0,\n starter: 1,\n professional: 2,\n enterprise: 3,\n}\n\nexport function BillingPanel({\n defaultBillingInterval = 'monthly',\n onRedirect,\n}: BillingPanelProps) {\n const t = useTranslations('windsock')\n const format = useFormatter()\n const { client } = useAuth()\n\n const [subscription, setSubscription] = useState<SubscriptionDetails | null>(null)\n const [plans, setPlans] = useState<PlanDefinition[]>([])\n const [isLoading, setIsLoading] = useState(true)\n const [error, setError] = useState<string | null>(null)\n const [busyAction, setBusyAction] = useState<string | null>(null)\n\n const redirect = useCallback((url: string) => {\n if (onRedirect) {\n onRedirect(url)\n } else if (typeof window !== 'undefined') {\n window.location.assign(url)\n }\n }, [onRedirect])\n\n const load = useCallback(async () => {\n setIsLoading(true)\n setError(null)\n try {\n const [sub, availablePlans] = await Promise.all([\n client.getSubscription(),\n client.getPlans(),\n ])\n setSubscription(sub)\n setPlans(\n [...availablePlans]\n .filter((plan: { active: boolean }) => plan.active)\n .sort(\n (a: { tier: SubscriptionTier }, b: { tier: SubscriptionTier }) =>\n (TIER_ORDER[a.tier] ?? 0) - (TIER_ORDER[b.tier] ?? 0),\n ),\n )\n } catch (loadError) {\n setError(loadError instanceof Error ? loadError.message : String(loadError))\n } finally {\n setIsLoading(false)\n }\n }, [client])\n\n useEffect(() => {\n void load()\n }, [load])\n\n const handleOpenPortal = useCallback(async () => {\n setBusyAction('portal')\n triggerHaptic('light')\n try {\n const { url } = await client.createPortalSession()\n redirect(url)\n } catch (portalError) {\n setError(portalError instanceof Error ? portalError.message : String(portalError))\n triggerHaptic('error')\n } finally {\n setBusyAction(null)\n }\n }, [client, redirect])\n\n const handleStartCheckout = useCallback(async (planCode: string) => {\n setBusyAction(`checkout:${planCode}`)\n triggerHaptic('light')\n try {\n const { url } = await client.createCheckoutSession(planCode, defaultBillingInterval)\n redirect(url)\n } catch (checkoutError) {\n setError(checkoutError instanceof Error ? checkoutError.message : String(checkoutError))\n triggerHaptic('error')\n } finally {\n setBusyAction(null)\n }\n }, [client, defaultBillingInterval, redirect])\n\n const handleCancel = useCallback(async () => {\n if (typeof window !== 'undefined') {\n const confirmed = window.confirm(t('billing.cancelConfirm'))\n if (!confirmed) return\n }\n setBusyAction('cancel')\n triggerHaptic('warning')\n try {\n const result = await client.cancelSubscription()\n if (!result.success) {\n throw new Error(result.error ?? 'Subscription cancellation failed')\n }\n triggerHaptic('success')\n await load()\n } catch (cancelError) {\n setError(cancelError instanceof Error ? cancelError.message : String(cancelError))\n triggerHaptic('error')\n } finally {\n setBusyAction(null)\n }\n }, [client, load, t])\n\n if (isLoading) {\n return (\n <div className=\"flex items-center justify-center py-12\">\n <InlineSpinner />\n </div>\n )\n }\n\n const currentPlan = subscription?.plan ?? plans.find((plan) => plan.id === subscription?.planId) ?? null\n const currentTier = subscription?.tier ?? currentPlan?.tier ?? null\n\n return (\n <div className=\"space-y-6\">\n {error && (\n <div\n role=\"alert\"\n className=\"rounded-xl border border-red-300/40 bg-red-50/80 px-4 py-3 text-sm text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-300\"\n >\n {error}\n </div>\n )}\n\n <SectionCard\n header={{\n title: t('billing.currentPlan.title'),\n subtitle: t('billing.currentPlan.description'),\n }}\n >\n {subscription && currentPlan ? (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-center gap-3\">\n <span className=\"text-lg font-semibold text-gray-900 dark:text-white\">\n {currentPlan.name}\n </span>\n <StatusBadge\n status={\n subscription.status === 'active' ? 'success'\n : subscription.status === 'past_due' ? 'pending'\n : 'error'\n }\n label={t(`billing.status.${subscription.status}`)}\n />\n {subscription.cancelAtPeriodEnd && (\n <Badge color=\"amber\">{t('billing.currentPlan.cancelAtPeriodEnd')}</Badge>\n )}\n </div>\n\n <dl className=\"grid grid-cols-1 gap-3 text-sm sm:grid-cols-2\">\n <div>\n <dt className=\"text-gray-500 dark:text-gray-400\">\n {t('billing.currentPlan.price')}\n </dt>\n <dd className=\"font-medium text-gray-900 dark:text-white\">\n {format.number(currentPlan.price, { style: 'currency', currency: currentPlan.currency })}\n {' '}/{' '}\n {t(`billing.interval.${currentPlan.interval}`)}\n </dd>\n </div>\n {subscription.currentPeriodEnd && (\n <div>\n <dt className=\"text-gray-500 dark:text-gray-400\">\n {t('billing.currentPlan.renewsOn')}\n </dt>\n <dd className=\"font-medium text-gray-900 dark:text-white\">\n {format.dateTime(new Date(subscription.currentPeriodEnd), { dateStyle: 'medium' })}\n </dd>\n </div>\n )}\n </dl>\n\n <div className=\"flex flex-wrap gap-2 pt-2\">\n <Button\n size=\"sm\"\n color=\"ios-glass-blue\"\n onClick={handleOpenPortal}\n loading={busyAction === 'portal'}\n disabled={busyAction !== null}\n >\n {t('billing.currentPlan.manageInPortal')}\n </Button>\n {subscription.status === 'active' && !subscription.cancelAtPeriodEnd && (\n <Button\n size=\"sm\"\n color=\"ios-glass-red\"\n onClick={handleCancel}\n loading={busyAction === 'cancel'}\n disabled={busyAction !== null}\n >\n {t('billing.currentPlan.cancel')}\n </Button>\n )}\n </div>\n </div>\n ) : (\n <p className=\"text-sm text-gray-500 dark:text-gray-400\">\n {t('billing.currentPlan.noSubscription')}\n </p>\n )}\n </SectionCard>\n\n <SectionCard\n header={{\n title: t('billing.plans.title'),\n subtitle: t('billing.plans.description'),\n }}\n >\n {plans.length === 0 ? (\n <p className=\"text-sm text-gray-500 dark:text-gray-400\">\n {t('billing.plans.empty')}\n </p>\n ) : (\n <ListCard>\n {plans.map((plan) => {\n const isCurrent = currentPlan?.id === plan.id\n const isDowngrade = currentTier != null\n && (TIER_ORDER[plan.tier] ?? 0) < (TIER_ORDER[currentTier] ?? 0)\n return (\n <ListCardItem\n key={plan.id}\n leading={\n <div className=\"flex h-10 w-10 items-center justify-center rounded-xl bg-gradient-to-br from-violet-500/20 to-blue-500/20 text-violet-600 dark:text-violet-300\">\n <span className=\"text-sm font-bold uppercase\">{plan.tier.charAt(0)}</span>\n </div>\n }\n trailing={\n isCurrent ? (\n <Badge color=\"green\">{t('billing.plans.currentBadge')}</Badge>\n ) : (\n isDowngrade ? (\n <Button\n size=\"sm\"\n plain\n onClick={() => handleStartCheckout(plan.code)}\n loading={busyAction === `checkout:${plan.code}`}\n disabled={busyAction !== null}\n >\n {t('billing.plans.downgradeAction')}\n </Button>\n ) : (\n <Button\n size=\"sm\"\n color=\"ios-glass-blue\"\n onClick={() => handleStartCheckout(plan.code)}\n loading={busyAction === `checkout:${plan.code}`}\n disabled={busyAction !== null}\n >\n {t('billing.plans.selectAction')}\n </Button>\n )\n )\n }\n >\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex items-center gap-2\">\n <p className=\"text-sm font-medium text-gray-900 dark:text-white\">\n {plan.name}\n </p>\n <span className=\"text-xs text-gray-500 dark:text-gray-400\">\n {format.number(plan.price, { style: 'currency', currency: plan.currency })}\n {' '}/{' '}\n {t(`billing.interval.${plan.interval}`)}\n </span>\n </div>\n {plan.description && (\n <p className=\"text-xs text-gray-500 dark:text-gray-400\">\n {plan.description}\n </p>\n )}\n </div>\n </ListCardItem>\n )\n })}\n </ListCard>\n )}\n </SectionCard>\n </div>\n )\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkZGVN23J4_js = require('./chunk-ZGVN23J4.js');
4
+ var chunkTIJXCRM4_js = require('./chunk-TIJXCRM4.js');
5
5
  var chunkYXN2K77G_js = require('./chunk-YXN2K77G.js');
6
6
  var chunkS7KHTUHA_js = require('./chunk-S7KHTUHA.js');
7
7
  var react = require('react');
@@ -11,7 +11,7 @@ var jsxRuntime = require('react/jsx-runtime');
11
11
 
12
12
  var PlatformStateContext = react.createContext(null);
13
13
  function PlatformStateProvider({ children, normalizeRole }) {
14
- const { user } = chunkZGVN23J4_js.useAuth();
14
+ const { user } = chunkTIJXCRM4_js.useAuth();
15
15
  const state = react.useMemo(() => {
16
16
  const organizationId = user?.organizationId ?? "";
17
17
  const actor = user ? {
@@ -33,7 +33,7 @@ function usePlatformState() {
33
33
  }
34
34
  function resolveFlag(locale) {
35
35
  const code = locale === "pt-BR" ? "br" : locale;
36
- return chunkZGVN23J4_js.LOCALE_FLAGS?.[code];
36
+ return chunkTIJXCRM4_js.LOCALE_FLAGS?.[code];
37
37
  }
38
38
  function PlatformAppShell({
39
39
  appName,
@@ -50,12 +50,12 @@ function PlatformAppShell({
50
50
  children
51
51
  }) {
52
52
  const tCommon = chunkYXN2K77G_js.useTranslations("common");
53
- const { user, status, logout } = chunkZGVN23J4_js.useAuth();
53
+ const { user, status, logout } = chunkTIJXCRM4_js.useAuth();
54
54
  usePlatformState();
55
- const { resolvedTheme, setTheme, dockPosition, dockAutoHide, dockEnabled } = chunkZGVN23J4_js.usePlatformPreferences();
55
+ const { resolvedTheme, setTheme, dockPosition, dockAutoHide, dockEnabled } = chunkTIJXCRM4_js.usePlatformPreferences();
56
56
  const pathname = chunkS7KHTUHA_js.usePathname();
57
57
  const router = chunkS7KHTUHA_js.useRouter();
58
- const { history, openHistory } = chunkZGVN23J4_js.useNotifications();
58
+ const { history, openHistory } = chunkTIJXCRM4_js.useNotifications();
59
59
  const currentLocale = chunkYXN2K77G_js.useLocale();
60
60
  const localeMeta = i18n.LANGUAGE_META[currentLocale];
61
61
  const items = react.useMemo(() => navigationItems.filter((item) => {
@@ -83,7 +83,7 @@ function PlatformAppShell({
83
83
  organizationId: user.organizationId ?? null
84
84
  } : null;
85
85
  return /* @__PURE__ */ jsxRuntime.jsx(
86
- chunkZGVN23J4_js.PlatformShell,
86
+ chunkTIJXCRM4_js.PlatformShell,
87
87
  {
88
88
  items,
89
89
  launchpadPageOrder: pageOrder,
@@ -129,5 +129,5 @@ function PlatformAppShell({
129
129
  exports.PlatformAppShell = PlatformAppShell;
130
130
  exports.PlatformStateProvider = PlatformStateProvider;
131
131
  exports.usePlatformState = usePlatformState;
132
- //# sourceMappingURL=chunk-35O2X7WY.js.map
133
- //# sourceMappingURL=chunk-35O2X7WY.js.map
132
+ //# sourceMappingURL=chunk-DPXCJVJT.js.map
133
+ //# sourceMappingURL=chunk-DPXCJVJT.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/platform/platform-state-provider.tsx","../src/platform/app-shell.tsx"],"names":["createContext","useAuth","useMemo","useContext","LOCALE_FLAGS","useTranslations","usePlatformPreferences","usePathname","useRouter","useNotifications","useLocale","LANGUAGE_META","useCallback","jsx","PlatformShell","RectangleStackIcon","HomeIcon"],"mappings":";;;;;;;;;;AAQA,IAAM,oBAAA,GAAuBA,oBAAoC,IAAI,CAAA;AAa9D,SAAS,qBAA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C1B,mBAAA,EAAqB,QAAQ,qBAAqB,CAAA;AAAA,QAClD,MAAA,EAAQ,QAAQ,QAAQ,CAAA;AAAA,QACxB,aAAA,EAAe,QAAQ,eAAe,CAAA;AAAA,QACtC,KAAA,EAAO,QAAQ,OAAO,CAAA;AAAA,QACtB,cAAc,aAAA,KAAkB,MAAA,GAAS,QAAQ,UAAU,CAAA,GAAI,QAAQ,WAAW,CAAA;AAAA,QAClF,QAAA,EAAU,QAAQ,UAAU,CAAA;AAAA,QAC5B,aAAA,EAAe,YAAY,UAAA,IAAc,aAAA;AAAA,QACzC,UAAA,EAAY,YAAY,aAAa,CAAA;AAAA,QACrC,OAAA,EAAS,QAAQ,SAAS;AAAA,OAC5B;AAAA,MACC,GAAI,aAAA,GAAgB,EAAE,aAAA,EAAe,aAAA,KAAkB,EAAC;AAAA,MAExD;AAAA;AAAA,GACH;AAEJ","file":"chunk-35O2X7WY.js","sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport { useAuth, type AuthUser } from '../_auth'\n\ntype PlatformState = {\n currentOrganizationId: string\n actor: AuthUser | null\n}\n\nconst PlatformStateContext = createContext<PlatformState | null>(null)\n\nexport type PlatformStateProviderProps = {\n children: ReactNode\n /**\n * Function that converts a JWT role claim to the app's canonical role\n * union (the same `normalizePlatformRole` produced by\n * `createPlatformRbac()` in this app). Lifted out as a prop because\n * each consuming app uses its own role enum.\n */\n normalizeRole: (input: unknown) => string\n}\n\nexport function PlatformStateProvider({ children, normalizeRole }: PlatformStateProviderProps) {\n const { user } = useAuth()\n\n const state = useMemo<PlatformState>(() => {\n const organizationId = user?.organizationId ?? ''\n\n const actor: AuthUser | null = user\n ? {\n ...user,\n role: normalizeRole(user.role),\n organizationId,\n }\n : null\n\n return {\n currentOrganizationId: organizationId,\n actor,\n }\n }, [user, normalizeRole])\n\n return (\n <PlatformStateContext.Provider value={state}>\n {children}\n </PlatformStateContext.Provider>\n )\n}\n\nexport function usePlatformState() {\n const context = useContext(PlatformStateContext)\n if (!context) throw new Error('usePlatformState must be used inside PlatformStateProvider')\n return context\n}\n","import { useCallback, useMemo, type ComponentType, type ReactNode } from 'react'\nimport { RectangleStackIcon, HomeIcon } from '@heroicons/react/24/outline'\nimport { useAuth, usePlatformPreferences } from '../_auth'\nimport { LANGUAGE_META } from '@datatechsolutions/shared-domain/i18n'\nimport {\n PlatformShell,\n type NavigationItem,\n} from '@ui/index'\nimport { useNotifications } from '@ui/components/notifications'\nimport { useLocale, useTranslations } from '@ui/lib/i18n-context'\nimport { usePathname, useRouter } from '@ui/lib/router-context'\nimport { LOCALE_FLAGS } from '@ui/lib/locale-flags'\nimport { usePlatformState } from './platform-state-provider'\n\nfunction resolveFlag(locale: string): string | undefined {\n const code = locale === 'pt-BR' ? 'br' : locale\n return LOCALE_FLAGS?.[code as keyof typeof LOCALE_FLAGS]\n}\n\nexport type PlatformAppShellProps = {\n /** App display name (e.g. \"Astrlabe\"). */\n appName: string\n /** Tailwind gradient classes for the shell branding (e.g. \"from-sky-500 to-indigo-600\"). */\n appGradient: string\n /** Branded logo node rendered inside the flyout trigger. */\n appLogo: ReactNode\n /**\n * Optional app icon for the branded loader (defaults to the platform's\n * RectangleStackIcon if omitted).\n */\n appIcon?: ReactNode\n /**\n * When the appIcon is a brand SVG that has its own background\n * (gradient, fill, etc), set this to true so the BrandedLoader\n * doesn't wrap it in a second gradient container.\n */\n appIconRaw?: boolean\n /**\n * Optional override for the dock dashboard icon (defaults to HomeIcon).\n */\n dashboardIcon?: ComponentType<{ className?: string }>\n\n /** App-specific navigation items already pre-translated. */\n navigationItems: NavigationItem[]\n /** Custom ordering of launchpad page tiles. */\n pageOrder: string[]\n /**\n * Map of navigation/module ID → required permission name. The shell\n * filters `navigationItems` so that any item whose ID has an entry here\n * is hidden unless `hasPermission` returns true for the listed permission.\n */\n modulePermissions: Record<string, string>\n /**\n * Permission predicate, typically `(p) => can(actor, p)` from each app's\n * `createPlatformRbac()` factory.\n */\n hasPermission: (permission: string) => boolean\n\n /**\n * Optional settings/profile drawer content (e.g. an app-specific\n * `<SettingsModal>`). Receives the open state + close handler the shell\n * manages internally so the drawer renders inside the shell chrome.\n */\n settingsModal?: (props: { open: boolean; onClose: () => void }) => ReactNode\n\n children: ReactNode\n}\n\n/**\n * Cross-app platform shell — wires `<PlatformShell>` from ui to windsock's\n * auth + preferences hooks and to ui's i18n/router contexts. Each app\n * passes its own logo, gradient, navigation, and permission predicate; the\n * rest of the chrome (header, dock, flyout, sign-out confirm modal) is\n * shared.\n */\nexport function PlatformAppShell({\n appName,\n appGradient,\n appLogo,\n appIcon,\n appIconRaw,\n dashboardIcon,\n navigationItems,\n pageOrder,\n modulePermissions,\n hasPermission,\n settingsModal,\n children,\n}: PlatformAppShellProps) {\n const tCommon = useTranslations('common')\n const { user, status, logout } = useAuth()\n // Validate the platform-state provider is mounted above this shell;\n // the actor itself isn't read here, but the same provider feeds children.\n usePlatformState()\n const { resolvedTheme, setTheme, dockPosition, dockAutoHide, dockEnabled } = usePlatformPreferences()\n const pathname = usePathname()\n const router = useRouter()\n const { history, openHistory } = useNotifications()\n const currentLocale = useLocale()\n const localeMeta = LANGUAGE_META[currentLocale as keyof typeof LANGUAGE_META]\n\n const items = useMemo(() => navigationItems.filter((item) => {\n const permission = modulePermissions[item.id]\n if (!permission) return true\n return hasPermission(permission)\n }), [navigationItems, modulePermissions, hasPermission])\n\n const handleSignOut = useCallback(() => { void logout('/login') }, [logout])\n const handleToggleTheme = useCallback(\n () => { setTheme(resolvedTheme === 'dark' ? 'light' : 'dark') },\n [resolvedTheme, setTheme],\n )\n const handleNavigate = useCallback((href: string) => router.push(href), [router])\n const handlePrefetch = useCallback((href: string) => router.prefetch(href), [router])\n\n const shellUser = user\n ? {\n name: user.name ?? null,\n email: user.email ?? null,\n image: user.image ?? null,\n role: user.role ?? null,\n permissions: user.permissions as string[] | undefined,\n organizationId: user.organizationId ?? null,\n }\n : null\n\n return (\n <PlatformShell\n items={items}\n launchpadPageOrder={pageOrder}\n user={shellUser}\n authStatus={status}\n onSignOut={handleSignOut}\n dockPosition={dockPosition}\n dockAutoHide={dockAutoHide}\n dockEnabled={dockEnabled}\n resolvedTheme={resolvedTheme}\n onToggleTheme={handleToggleTheme}\n pathname={pathname}\n onNavigate={handleNavigate}\n onPrefetch={handlePrefetch}\n appName={appName}\n appIcon={appIcon ?? <RectangleStackIcon className=\"h-full w-full\" />}\n appIconRaw={appIconRaw}\n appLogo={appLogo}\n appGradient={appGradient}\n dashboardIcon={dashboardIcon ?? HomeIcon}\n notificationCount={history.length}\n onNotifications={openHistory}\n labels={{\n home: tCommon('home'),\n profile: tCommon('profile'),\n signOut: tCommon('signOut'),\n signOutConfirmTitle: tCommon('signOutConfirmTitle'),\n cancel: tCommon('cancel'),\n notifications: tCommon('notifications'),\n theme: tCommon('theme'),\n currentTheme: resolvedTheme === 'dark' ? tCommon('darkMode') : tCommon('lightMode'),\n language: tCommon('language'),\n currentLocale: localeMeta?.nativeName ?? currentLocale,\n localeFlag: resolveFlag(currentLocale),\n actions: tCommon('actions'),\n }}\n {...(settingsModal ? { profileDrawer: settingsModal } : {})}\n >\n {children}\n </PlatformShell>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/platform/platform-state-provider.tsx","../src/platform/app-shell.tsx"],"names":["createContext","useAuth","useMemo","useContext","LOCALE_FLAGS","useTranslations","usePlatformPreferences","usePathname","useRouter","useNotifications","useLocale","LANGUAGE_META","useCallback","jsx","PlatformShell","RectangleStackIcon","HomeIcon"],"mappings":";;;;;;;;;;AAQA,IAAM,oBAAA,GAAuBA,oBAAoC,IAAI,CAAA;AAa9D,SAAS,qBAAA,CAAsB,EAAE,QAAA,EAAU,aAAA,EAAc,EAA+B;AAC7F,EAAA,MAAM,EAAE,IAAA,EAAK,GAAIC,wBAAA,EAAQ;AAEzB,EAAA,MAAM,KAAA,GAAQC,cAAuB,MAAM;AACzC,IAAA,MAAM,cAAA,GAAiB,MAAM,cAAA,IAAkB,EAAA;AAE/C,IAAA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Q,UAAU,CAAA,GAAI,QAAQ,WAAW,CAAA;AAAA,QAClF,QAAA,EAAU,QAAQ,UAAU,CAAA;AAAA,QAC5B,aAAA,EAAe,YAAY,UAAA,IAAc,aAAA;AAAA,QACzC,UAAA,EAAY,YAAY,aAAa,CAAA;AAAA,QACrC,OAAA,EAAS,QAAQ,SAAS;AAAA,OAC5B;AAAA,MACC,GAAI,aAAA,GAAgB,EAAE,aAAA,EAAe,aAAA,KAAkB,EAAC;AAAA,MAExD;AAAA;AAAA,GACH;AAEJ","file":"chunk-DPXCJVJT.js","sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport { useAuth, type AuthUser } from '../_auth'\n\ntype PlatformState = {\n currentOrganizationId: string\n actor: AuthUser | null\n}\n\nconst PlatformStateContext = createContext<PlatformState | null>(null)\n\nexport type PlatformStateProviderProps = {\n children: ReactNode\n /**\n * Function that converts a JWT role claim to the app's canonical role\n * union (the same `normalizePlatformRole` produced by\n * `createPlatformRbac()` in this app). Lifted out as a prop because\n * each consuming app uses its own role enum.\n */\n normalizeRole: (input: unknown) => string\n}\n\nexport function PlatformStateProvider({ children, normalizeRole }: PlatformStateProviderProps) {\n const { user } = useAuth()\n\n const state = useMemo<PlatformState>(() => {\n const organizationId = user?.organizationId ?? ''\n\n const actor: AuthUser | null = user\n ? {\n ...user,\n role: normalizeRole(user.role),\n organizationId,\n }\n : null\n\n return {\n currentOrganizationId: organizationId,\n actor,\n }\n }, [user, normalizeRole])\n\n return (\n <PlatformStateContext.Provider value={state}>\n {children}\n </PlatformStateContext.Provider>\n )\n}\n\nexport function usePlatformState() {\n const context = useContext(PlatformStateContext)\n if (!context) throw new Error('usePlatformState must be used inside PlatformStateProvider')\n return context\n}\n","import { useCallback, useMemo, type ComponentType, type ReactNode } from 'react'\nimport { RectangleStackIcon, HomeIcon } from '@heroicons/react/24/outline'\nimport { useAuth, usePlatformPreferences } from '../_auth'\nimport { LANGUAGE_META } from '@datatechsolutions/shared-domain/i18n'\nimport {\n PlatformShell,\n type NavigationItem,\n} from '@ui/index'\nimport { useNotifications } from '@ui/components/notifications'\nimport { useLocale, useTranslations } from '@ui/lib/i18n-context'\nimport { usePathname, useRouter } from '@ui/lib/router-context'\nimport { LOCALE_FLAGS } from '@ui/lib/locale-flags'\nimport { usePlatformState } from './platform-state-provider'\n\nfunction resolveFlag(locale: string): string | undefined {\n const code = locale === 'pt-BR' ? 'br' : locale\n return LOCALE_FLAGS?.[code as keyof typeof LOCALE_FLAGS]\n}\n\nexport type PlatformAppShellProps = {\n /** App display name (e.g. \"Astrlabe\"). */\n appName: string\n /** Tailwind gradient classes for the shell branding (e.g. \"from-sky-500 to-indigo-600\"). */\n appGradient: string\n /** Branded logo node rendered inside the flyout trigger. */\n appLogo: ReactNode\n /**\n * Optional app icon for the branded loader (defaults to the platform's\n * RectangleStackIcon if omitted).\n */\n appIcon?: ReactNode\n /**\n * When the appIcon is a brand SVG that has its own background\n * (gradient, fill, etc), set this to true so the BrandedLoader\n * doesn't wrap it in a second gradient container.\n */\n appIconRaw?: boolean\n /**\n * Optional override for the dock dashboard icon (defaults to HomeIcon).\n */\n dashboardIcon?: ComponentType<{ className?: string }>\n\n /** App-specific navigation items already pre-translated. */\n navigationItems: NavigationItem[]\n /** Custom ordering of launchpad page tiles. */\n pageOrder: string[]\n /**\n * Map of navigation/module ID → required permission name. The shell\n * filters `navigationItems` so that any item whose ID has an entry here\n * is hidden unless `hasPermission` returns true for the listed permission.\n */\n modulePermissions: Record<string, string>\n /**\n * Permission predicate, typically `(p) => can(actor, p)` from each app's\n * `createPlatformRbac()` factory.\n */\n hasPermission: (permission: string) => boolean\n\n /**\n * Optional settings/profile drawer content (e.g. an app-specific\n * `<SettingsModal>`). Receives the open state + close handler the shell\n * manages internally so the drawer renders inside the shell chrome.\n */\n settingsModal?: (props: { open: boolean; onClose: () => void }) => ReactNode\n\n children: ReactNode\n}\n\n/**\n * Cross-app platform shell — wires `<PlatformShell>` from ui to windsock's\n * auth + preferences hooks and to ui's i18n/router contexts. Each app\n * passes its own logo, gradient, navigation, and permission predicate; the\n * rest of the chrome (header, dock, flyout, sign-out confirm modal) is\n * shared.\n */\nexport function PlatformAppShell({\n appName,\n appGradient,\n appLogo,\n appIcon,\n appIconRaw,\n dashboardIcon,\n navigationItems,\n pageOrder,\n modulePermissions,\n hasPermission,\n settingsModal,\n children,\n}: PlatformAppShellProps) {\n const tCommon = useTranslations('common')\n const { user, status, logout } = useAuth()\n // Validate the platform-state provider is mounted above this shell;\n // the actor itself isn't read here, but the same provider feeds children.\n usePlatformState()\n const { resolvedTheme, setTheme, dockPosition, dockAutoHide, dockEnabled } = usePlatformPreferences()\n const pathname = usePathname()\n const router = useRouter()\n const { history, openHistory } = useNotifications()\n const currentLocale = useLocale()\n const localeMeta = LANGUAGE_META[currentLocale as keyof typeof LANGUAGE_META]\n\n const items = useMemo(() => navigationItems.filter((item) => {\n const permission = modulePermissions[item.id]\n if (!permission) return true\n return hasPermission(permission)\n }), [navigationItems, modulePermissions, hasPermission])\n\n const handleSignOut = useCallback(() => { void logout('/login') }, [logout])\n const handleToggleTheme = useCallback(\n () => { setTheme(resolvedTheme === 'dark' ? 'light' : 'dark') },\n [resolvedTheme, setTheme],\n )\n const handleNavigate = useCallback((href: string) => router.push(href), [router])\n const handlePrefetch = useCallback((href: string) => router.prefetch(href), [router])\n\n const shellUser = user\n ? {\n name: user.name ?? null,\n email: user.email ?? null,\n image: user.image ?? null,\n role: user.role ?? null,\n permissions: user.permissions as string[] | undefined,\n organizationId: user.organizationId ?? null,\n }\n : null\n\n return (\n <PlatformShell\n items={items}\n launchpadPageOrder={pageOrder}\n user={shellUser}\n authStatus={status}\n onSignOut={handleSignOut}\n dockPosition={dockPosition}\n dockAutoHide={dockAutoHide}\n dockEnabled={dockEnabled}\n resolvedTheme={resolvedTheme}\n onToggleTheme={handleToggleTheme}\n pathname={pathname}\n onNavigate={handleNavigate}\n onPrefetch={handlePrefetch}\n appName={appName}\n appIcon={appIcon ?? <RectangleStackIcon className=\"h-full w-full\" />}\n appIconRaw={appIconRaw}\n appLogo={appLogo}\n appGradient={appGradient}\n dashboardIcon={dashboardIcon ?? HomeIcon}\n notificationCount={history.length}\n onNotifications={openHistory}\n labels={{\n home: tCommon('home'),\n profile: tCommon('profile'),\n signOut: tCommon('signOut'),\n signOutConfirmTitle: tCommon('signOutConfirmTitle'),\n cancel: tCommon('cancel'),\n notifications: tCommon('notifications'),\n theme: tCommon('theme'),\n currentTheme: resolvedTheme === 'dark' ? tCommon('darkMode') : tCommon('lightMode'),\n language: tCommon('language'),\n currentLocale: localeMeta?.nativeName ?? currentLocale,\n localeFlag: resolveFlag(currentLocale),\n actions: tCommon('actions'),\n }}\n {...(settingsModal ? { profileDrawer: settingsModal } : {})}\n >\n {children}\n </PlatformShell>\n )\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { NodeRunningIndicator, WorkflowHandle, NodeCard, NodeCardHeader, NodeCardMeta, NodeInteractiveCard, NodeIconBubble, NodeCardBadge, NodeCardDeleteAction, Workspace, useModalStore, CATEGORY_COLORS, CATEGORY_PILL_COLORS, ICON_MAP, WorkflowCanvas, EXPERIMENTAL_NODE_TYPES, getEntityIcon, getEntityGradient, useWorkflowStore, LOGIC_ICON_MAP, LOGIC_NODE_GRADIENTS, getFrameworkMeta, getCompatibleModels, isModelCompatibleWithFramework, FRAMEWORK_META, isFrameworkCompatibleWithProviders } from './chunk-3US2QXEF.mjs';
3
- import { FormInput, FormSelect, Avatar, ToggleSwitch, HeroBlock, GlassModal, SectionCard, FormTextarea, FormGrid, Input, DynamicIslandConfirm } from './chunk-35P352JX.mjs';
2
+ import { NodeRunningIndicator, WorkflowHandle, NodeCard, NodeCardHeader, NodeCardMeta, NodeInteractiveCard, NodeIconBubble, NodeCardBadge, NodeCardDeleteAction, Workspace, useModalStore, CATEGORY_COLORS, CATEGORY_PILL_COLORS, ICON_MAP, WorkflowCanvas, EXPERIMENTAL_NODE_TYPES, getEntityIcon, getEntityGradient, useWorkflowStore, LOGIC_ICON_MAP, LOGIC_NODE_GRADIENTS, getFrameworkMeta, getCompatibleModels, isModelCompatibleWithFramework, FRAMEWORK_META, isFrameworkCompatibleWithProviders } from './chunk-IHOCYBHM.mjs';
3
+ import { FormInput, FormSelect, Avatar, ToggleSwitch, HeroBlock, GlassModal, SectionCard, FormTextarea, FormGrid, Input, DynamicIslandConfirm } from './chunk-OKCEK7GH.mjs';
4
4
  import { useTranslations } from './chunk-7VJ7CMMT.mjs';
5
5
  import { Badge, Button } from './chunk-WR55H7DH.mjs';
6
6
  import { getAgentTier, createDefaultLogicNodeConfig } from './chunk-G7JQ4OCE.mjs';
@@ -5047,5 +5047,5 @@ function useHelpLines() {
5047
5047
  }
5048
5048
 
5049
5049
  export { AgentModal, AmazonNovaIcon, AnthropicModelIcon, AutoSaveWorkspace, DslExportModal, DslImportModal, DynamicIslandConfirm2 as DynamicIslandConfirm, ExecutionTimelinePanel, MetaLlamaIcon, ModelProviderFlowNode, NodePalette, OutputSchemaBuilder, PipelineSettingsModal, PreviewPanel, RULE_STATUS_OPTIONS, RuleActionBuilder, RuleConditionBuilder, RuleForm, RunInputDialog, RunPanel, RunReplayModal, S3WriteFlowNode, SaveStatusBadge, SubworkflowModal, TIMEZONE_OPTIONS, VariableInspector, VersionHistoryPanel, WorkflowListBar, defaultAgentOutputSchema, defaultRuleAction, defaultRuleCondition, defaultRuleForm, getModelIcon, useCanRedo, useCanUndo, useCanvasShortcuts, useClipboard, useContextMenu, useEditingNodeId, useHasCopied, useHelpLines, useIsRunning, useNodeResults, useSelectedNodeCount, useSubworkflowStore, useUndoRedo };
5050
- //# sourceMappingURL=chunk-ZJMYLUZ2.mjs.map
5051
- //# sourceMappingURL=chunk-ZJMYLUZ2.mjs.map
5050
+ //# sourceMappingURL=chunk-E3NMVWRL.mjs.map
5051
+ //# sourceMappingURL=chunk-E3NMVWRL.mjs.map