@arbidocs/blocks 0.5.130 → 0.5.132

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 (105) hide show
  1. package/dist/{DocumentReviewCard-M53XFLI2.cjs → DocumentReviewCard-2VI5OOLE.cjs} +3 -3
  2. package/dist/{DocumentReviewCard-M53XFLI2.cjs.map → DocumentReviewCard-2VI5OOLE.cjs.map} +1 -1
  3. package/dist/{FilesViewerDialog-EFRMXIM5.cjs → FilesViewerDialog-77YTFIX3.cjs} +4 -4
  4. package/dist/{FilesViewerDialog-EFRMXIM5.cjs.map → FilesViewerDialog-77YTFIX3.cjs.map} +1 -1
  5. package/dist/{WorkspaceTableView-QPROJRCF.cjs → WorkspaceTableView-7BMZ2O3Y.cjs} +6 -6
  6. package/dist/{WorkspaceTableView-QPROJRCF.cjs.map → WorkspaceTableView-7BMZ2O3Y.cjs.map} +1 -1
  7. package/dist/{chunk-KWHGYHRC.cjs → chunk-KSDTK66A.cjs} +2 -2
  8. package/dist/{chunk-KWHGYHRC.cjs.map → chunk-KSDTK66A.cjs.map} +1 -1
  9. package/dist/{chunk-MI3N3ZOT.cjs → chunk-PDDYAY4Z.cjs} +20 -20
  10. package/dist/{chunk-MI3N3ZOT.cjs.map → chunk-PDDYAY4Z.cjs.map} +1 -1
  11. package/dist/{chunk-T73BHNQX.cjs → chunk-TBPCG2PV.cjs} +240 -89
  12. package/dist/chunk-TBPCG2PV.cjs.map +1 -0
  13. package/dist/{chunk-GOQV6NOK.cjs → chunk-U7KB42OQ.cjs} +4 -4
  14. package/dist/{chunk-GOQV6NOK.cjs.map → chunk-U7KB42OQ.cjs.map} +1 -1
  15. package/dist/{chunk-GEZB3OEC.cjs → chunk-XJE7W42L.cjs} +18 -17
  16. package/dist/chunk-XJE7W42L.cjs.map +1 -0
  17. package/dist/connect/index.cjs +1413 -653
  18. package/dist/connect/index.cjs.map +1 -1
  19. package/dist/connect/viewer.cjs +1 -1
  20. package/dist/connection/billing/ChangePlanDialog.d.ts +2 -1
  21. package/dist/connection/billing/ChangePlanDialog.js +8 -3
  22. package/dist/connection/billing/ChangePlanDialog.js.map +2 -2
  23. package/dist/connection/billing/ChangeProPlan.js +4 -4
  24. package/dist/connection/billing/ChangeProPlan.js.map +2 -2
  25. package/dist/connection/billing/CollaboratorPlan.js +5 -3
  26. package/dist/connection/billing/CollaboratorPlan.js.map +2 -2
  27. package/dist/connection/billing/ConnectedWelcomeDialog.d.ts +5 -13
  28. package/dist/connection/billing/ConnectedWelcomeDialog.js +38 -19
  29. package/dist/connection/billing/ConnectedWelcomeDialog.js.map +2 -2
  30. package/dist/connection/billing/MonthlySpendCap.d.ts +10 -3
  31. package/dist/connection/billing/MonthlySpendCap.js +103 -11
  32. package/dist/connection/billing/MonthlySpendCap.js.map +2 -2
  33. package/dist/connection/billing/NewProjectFlow.js +20 -7
  34. package/dist/connection/billing/NewProjectFlow.js.map +2 -2
  35. package/dist/connection/billing/ProjectDetail.js +1 -1
  36. package/dist/connection/billing/ProjectDetail.js.map +2 -2
  37. package/dist/connection/billing/ProjectPurchaseOptions.d.ts +14 -3
  38. package/dist/connection/billing/ProjectPurchaseOptions.js +472 -139
  39. package/dist/connection/billing/ProjectPurchaseOptions.js.map +2 -2
  40. package/dist/connection/billing/ProjectUsageCard.js +4 -4
  41. package/dist/connection/billing/ProjectUsageCard.js.map +2 -2
  42. package/dist/connection/billing/ReduceAddonDialog.js +2 -2
  43. package/dist/connection/billing/ReduceAddonDialog.js.map +2 -2
  44. package/dist/connection/billing/StripeCheckoutModal.js +3 -2
  45. package/dist/connection/billing/StripeCheckoutModal.js.map +2 -2
  46. package/dist/connection/billing/SubscriptionPlans.d.ts +5 -1
  47. package/dist/connection/billing/SubscriptionPlans.js +89 -6
  48. package/dist/connection/billing/SubscriptionPlans.js.map +2 -2
  49. package/dist/connection/billing/index.d.ts +1 -1
  50. package/dist/connection/billing/index.js +2 -2
  51. package/dist/connection/billing/index.js.map +2 -2
  52. package/dist/connection/billing/referral-reward.d.ts +2 -3
  53. package/dist/connection/billing/referral-reward.js +8 -3
  54. package/dist/connection/billing/referral-reward.js.map +2 -2
  55. package/dist/connection/billing/tax-quote.d.ts +2 -2
  56. package/dist/connection/billing/tax-quote.js +1 -0
  57. package/dist/connection/billing/tax-quote.js.map +2 -2
  58. package/dist/connection/command/ConnectedCommandPalette.js +2 -0
  59. package/dist/connection/command/ConnectedCommandPalette.js.map +2 -2
  60. package/dist/connection/command/actions.js +1 -1
  61. package/dist/connection/command/actions.js.map +2 -2
  62. package/dist/connection/contacts/ConnectedAddContacts.d.ts +7 -1
  63. package/dist/connection/contacts/ConnectedAddContacts.js +33 -17
  64. package/dist/connection/contacts/ConnectedAddContacts.js.map +2 -2
  65. package/dist/connection/contacts/ConnectedInviteContactsDialog.js +3 -2
  66. package/dist/connection/contacts/ConnectedInviteContactsDialog.js.map +2 -2
  67. package/dist/connection/contacts/ConnectedWelcomeInvitations.d.ts +6 -0
  68. package/dist/connection/contacts/ConnectedWelcomeInvitations.js +198 -0
  69. package/dist/connection/contacts/ConnectedWelcomeInvitations.js.map +7 -0
  70. package/dist/connection/projects/ConnectedProjectsPanel.js +17 -5
  71. package/dist/connection/projects/ConnectedProjectsPanel.js.map +2 -2
  72. package/dist/connection/shell/ConnectedWorkspaceSwitcher.js +3 -3
  73. package/dist/connection/shell/ConnectedWorkspaceSwitcher.js.map +2 -2
  74. package/dist/connection/workspace-form/ConnectedWorkspaceFormModal.js +2 -2
  75. package/dist/connection/workspace-form/ConnectedWorkspaceFormModal.js.map +2 -2
  76. package/dist/connection/workspace-list/ConnectedWorkspaceList.js +1 -1
  77. package/dist/connection/workspace-list/ConnectedWorkspaceList.js.map +2 -2
  78. package/dist/connection/workspace-list/useConnectedWorkspaceList.d.ts +1 -1
  79. package/dist/connection/workspace-list/useConnectedWorkspaceList.js +4 -4
  80. package/dist/connection/workspace-list/useConnectedWorkspaceList.js.map +2 -2
  81. package/dist/embed/index.cjs +8 -8
  82. package/dist/index.cjs +48 -48
  83. package/dist/index.cjs.map +1 -1
  84. package/dist/nav/actions.d.ts +2 -0
  85. package/dist/nav/actions.js.map +2 -2
  86. package/dist/settings/Billing.d.ts +2 -2
  87. package/dist/settings/Billing.js +4 -3
  88. package/dist/settings/Billing.js.map +2 -2
  89. package/dist/settings/PanelFrame.d.ts +3 -1
  90. package/dist/settings/PanelFrame.js +3 -2
  91. package/dist/settings/PanelFrame.js.map +2 -2
  92. package/dist/settings/SubscriptionParts.d.ts +4 -2
  93. package/dist/settings/SubscriptionParts.js +22 -3
  94. package/dist/settings/SubscriptionParts.js.map +2 -2
  95. package/dist/settings/WelcomeDialog.d.ts +31 -4
  96. package/dist/settings/WelcomeDialog.js +221 -82
  97. package/dist/settings/WelcomeDialog.js.map +2 -2
  98. package/dist/settings/index.cjs +144 -144
  99. package/dist/styles.css +1 -1
  100. package/dist/workflow-canvas/index.cjs +7 -7
  101. package/node_modules/@arbidocs/coedit/package.json +1 -1
  102. package/package.json +5 -5
  103. package/src/connection/billing/project-purchase.css +518 -39
  104. package/dist/chunk-GEZB3OEC.cjs.map +0 -1
  105. package/dist/chunk-T73BHNQX.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/connection/billing/SubscriptionPlans.tsx"],
4
- "sourcesContent": ["/** Existing projects use the same compact monthly/annual purchase comparison. */\nimport { useState } from 'react'\nimport { Button } from '@arbidocs/react/ui'\nimport { PlanNotice, PlanStack } from '../../settings'\nimport { useProducts } from '@arbidocs/react'\nimport { StripeCheckoutModal } from './StripeCheckoutModal'\nimport { ProjectPurchaseOptions } from './ProjectPurchaseOptions'\nimport { findProPrices, type PlanInterval } from './plan-pricing'\nimport type { TaxQuote } from './tax-quote'\n\ninterface SubscriptionPlansProps {\n projectExtId: string\n isPersonal?: boolean\n onDismiss?: () => void\n}\n\nexport function SubscriptionPlans({ projectExtId, onDismiss }: SubscriptionPlansProps) {\n const { data: products, isLoading, error } = useProducts()\n const [aiBlocks, setAiBlocks] = useState(0)\n const [storageBlocks, setStorageBlocks] = useState(0)\n const [collaboratorBlocks, setCollaboratorBlocks] = useState(0)\n const [checkout, setCheckout] = useState<{\n interval: PlanInterval\n capPence: number\n quote?: TaxQuote\n } | null>(null)\n const [checkoutOpen, setCheckoutOpen] = useState(false)\n if (isLoading) return <PlanNotice>Loading prices\u2026</PlanNotice>\n if (error) return <PlanNotice tone=\"error\">Prices didn&apos;t load. Try again.</PlanNotice>\n if (!products?.length) return <PlanNotice>No plans available.</PlanNotice>\n return (\n <>\n <PlanStack>\n <ProjectPurchaseOptions\n products={products}\n projectExtId={projectExtId}\n aiBlocks={aiBlocks}\n storageBlocks={storageBlocks}\n collaboratorBlocks={collaboratorBlocks}\n onAiBlocksChange={setAiBlocks}\n onStorageBlocksChange={setStorageBlocks}\n onCollaboratorBlocksChange={setCollaboratorBlocks}\n onChoose={(interval, capPence, quote) => {\n setCheckout({ interval, capPence, quote })\n setCheckoutOpen(true)\n }}\n />\n {onDismiss && (\n <div className=\"flex justify-end\">\n <Button variant=\"ghost\" onClick={onDismiss}>\n Cancel\n </Button>\n </div>\n )}\n </PlanStack>\n {checkout && (\n <StripeCheckoutModal\n price={findProPrices(products)[checkout.interval === 'year' ? 'annual' : 'monthly']}\n projectExtId={projectExtId}\n interval={checkout.interval}\n addonBudgetPence={checkout.capPence}\n aiBlocks={aiBlocks}\n storageBlocks={storageBlocks}\n collaboratorBlocks={collaboratorBlocks}\n quote={checkout.quote}\n open={checkoutOpen}\n onOpenChange={setCheckoutOpen}\n />\n )}\n </>\n )\n}\n"],
5
- "mappings": ";AA2BwB,SAIpB,UAJoB,KAKlB,YALkB;AA1BxB,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,YAAY,iBAAiB;AACtC,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAS,qBAAwC;AAS1C,SAAS,kBAAkB,EAAE,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ly/annual purchase comparison. */\nimport { useState } from 'react'\nimport { Button, Input, Label } from '@arbidocs/react/ui'\nimport { PlanNotice, PlanStack } from '../../settings'\nimport { useProducts, useUpdateProjectFields } from '@arbidocs/react'\nimport { StripeCheckoutModal } from './StripeCheckoutModal'\nimport { ProjectPurchaseOptions } from './ProjectPurchaseOptions'\nimport { findProPrices, type PlanInterval } from './plan-pricing'\nimport type { TaxQuote } from './tax-quote'\nimport type { components } from '@arbidocs/client'\n\ninterface SubscriptionPlansProps {\n projectExtId: string\n projectName?: string\n isPersonal?: boolean\n dailyCapPerUser?: number | null\n currentQuotas?: components['schemas']['ProjectQuotas']\n onDismiss?: () => void\n}\n\nexport function SubscriptionPlans({\n projectExtId,\n projectName,\n onDismiss,\n dailyCapPerUser = null,\n currentQuotas,\n}: SubscriptionPlansProps) {\n const { data: products, isLoading, error } = useProducts()\n const rename = useUpdateProjectFields()\n const [name, setName] = useState(projectName ?? '')\n const [nameError, setNameError] = useState<string | null>(null)\n const validName = projectName === undefined || name.trim().length > 0\n const [dailyCapValue, setDailyCapValue] = useState(\n dailyCapPerUser == null ? '' : String(dailyCapPerUser)\n )\n const [savedDailyCap, setSavedDailyCap] = useState(dailyCapPerUser)\n const [dailyCapError, setDailyCapError] = useState<string | null>(null)\n const parsedDailyCap = dailyCapValue.trim() === '' ? null : Number(dailyCapValue)\n const validDailyCap =\n parsedDailyCap === null || (Number.isFinite(parsedDailyCap) && parsedDailyCap >= 0)\n const dailyCap = parsedDailyCap === null ? null : Math.round(parsedDailyCap * 100) / 100\n const dirtyDailyCap = dailyCap !== savedDailyCap\n // Save a changed name before handing a paid choice to checkout.\n const choose = (next: () => void, capOnly = false) => {\n if ((!capOnly && !validName) || !validDailyCap || rename.isPending) return\n const nameChanged = !capOnly && projectName !== undefined && name.trim() !== projectName\n if (!nameChanged && !dirtyDailyCap) {\n next()\n return\n }\n setNameError(null)\n setDailyCapError(null)\n rename.mutate(\n {\n projectExtId,\n patch: {\n ...(nameChanged ? { name: name.trim() } : {}),\n ...(dirtyDailyCap ? { daily_cap_per_user: dailyCap } : {}),\n },\n },\n {\n onSuccess: () => {\n setSavedDailyCap(dailyCap)\n next()\n },\n onError: () => {\n if (dirtyDailyCap) setDailyCapError(\"Couldn't save the daily limit. Try again.\")\n else setNameError(\"Couldn't save the project name. Try again.\")\n },\n }\n )\n }\n const [promoCode, setPromoCode] = useState('')\n const [aiBlocks, setAiBlocks] = useState(0)\n const [storageBlocks, setStorageBlocks] = useState(0)\n const [collaboratorBlocks, setCollaboratorBlocks] = useState(0)\n const [checkout, setCheckout] = useState<{\n interval: PlanInterval\n capPence: number\n quote?: TaxQuote\n promoCode?: string\n } | null>(null)\n const [checkoutOpen, setCheckoutOpen] = useState(false)\n if (isLoading) return <PlanNotice>Loading prices\u2026</PlanNotice>\n if (error) return <PlanNotice tone=\"error\">Prices didn&apos;t load. Try again.</PlanNotice>\n if (!products?.length) return <PlanNotice>No plans available.</PlanNotice>\n return (\n <>\n <PlanStack>\n {projectName !== undefined && (\n <div className=\"space-y-2\" data-testid=\"change-plan-project\">\n <Label htmlFor=\"upgrade-project-name\">Project name</Label>\n <Input\n id=\"upgrade-project-name\"\n value={name}\n onChange={(event) => {\n setName(event.target.value)\n setNameError(null)\n }}\n disabled={rename.isPending}\n aria-invalid={!validName || !!nameError}\n aria-describedby={nameError ? 'upgrade-project-name-error' : undefined}\n />\n {nameError && (\n <p id=\"upgrade-project-name-error\" role=\"alert\" className=\"text-sm text-destructive\">\n {nameError}\n </p>\n )}\n </div>\n )}\n <ProjectPurchaseOptions\n products={products}\n promoCode={promoCode}\n onPromoCodeChange={setPromoCode}\n projectExtId={projectExtId}\n currentQuotas={currentQuotas}\n aiBlocks={aiBlocks}\n storageBlocks={storageBlocks}\n collaboratorBlocks={collaboratorBlocks}\n onAiBlocksChange={setAiBlocks}\n onStorageBlocksChange={setStorageBlocks}\n onCollaboratorBlocksChange={setCollaboratorBlocks}\n dailyCapValue={dailyCapValue}\n onDailyCapChange={(value) => {\n setDailyCapValue(value)\n setDailyCapError(null)\n }}\n onSaveDailyCap={() => choose(() => {}, true)}\n canSaveDailyCap={dirtyDailyCap && validDailyCap}\n dailyCapError={\n !validDailyCap\n ? 'Enter a positive amount, zero, or leave blank for no limit.'\n : dailyCapError\n }\n disabled={!validName || !validDailyCap}\n busy={rename.isPending}\n busyLabel=\"Saving project settings\u2026\"\n onChoose={(interval, capPence, quote) =>\n choose(() => {\n setCheckout({ interval, capPence, quote, promoCode: promoCode.trim() || undefined })\n setCheckoutOpen(true)\n })\n }\n />\n {onDismiss && (\n <div className=\"flex justify-end\">\n <Button variant=\"ghost\" onClick={onDismiss}>\n Cancel\n </Button>\n </div>\n )}\n </PlanStack>\n {checkout && (\n <StripeCheckoutModal\n promoCode={checkout.promoCode}\n price={findProPrices(products)[checkout.interval === 'year' ? 'annual' : 'monthly']}\n projectExtId={projectExtId}\n interval={checkout.interval}\n addonBudgetPence={checkout.capPence}\n aiBlocks={aiBlocks}\n storageBlocks={storageBlocks}\n collaboratorBlocks={collaboratorBlocks}\n quote={checkout.quote}\n open={checkoutOpen}\n onOpenChange={setCheckoutOpen}\n />\n )}\n </>\n )\n}\n"],
5
+ "mappings": ";AAmFwB,SAIpB,UAJoB,KAOd,YAPc;AAlFxB,SAAS,gBAAgB;AACzB,SAAS,QAAQ,OAAO,aAAa;AACrC,SAAS,YAAY,iBAAiB;AACtC,SAAS,aAAa,8BAA8B;AACpD,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAS,qBAAwC;AAa1C,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AACF,GAA2B;AACzB,QAAM,EAAE,MAAM,UAAU,WAAW,MAAM,IAAI,YAAY;AACzD,QAAM,SAAS,uBAAuB;AACtC,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,eAAe,EAAE;AAClD,QAAM,CAAC,WAAW,YAAY,IAAI,SAAwB,IAAI;A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IAAI;AAAA,UAC3C,iBAAiB,iBAAiB;AAAA,UAClC,eACE,CAAC,gBACG,gEACA;AAAA,UAEN,UAAU,CAAC,aAAa,CAAC;AAAA,UACzB,MAAM,OAAO;AAAA,UACb,WAAU;AAAA,UACV,UAAU,CAAC,UAAU,UAAU,UAC7B,OAAO,MAAM;AACX,wBAAY,EAAE,UAAU,UAAU,OAAO,WAAW,UAAU,KAAK,KAAK,OAAU,CAAC;AACnF,4BAAgB,IAAI;AAAA,UACtB,CAAC;AAAA;AAAA,MAEL;AAAA,MACC,aACC,oBAAC,SAAI,WAAU,oBACb,8BAAC,UAAO,SAAQ,SAAQ,SAAS,WAAW,oBAE5C,GACF;AAAA,OAEJ;AAAA,IACC,YACC;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,SAAS;AAAA,QACpB,OAAO,cAAc,QAAQ,EAAE,SAAS,aAAa,SAAS,WAAW,SAAS;AAAA,QAClF;AAAA,QACA,UAAU,SAAS;AAAA,QACnB,kBAAkB,SAAS;AAAA,QAC3B;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,SAAS;AAAA,QAChB,MAAM;AAAA,QACN,cAAc;AAAA;AAAA,IAChB;AAAA,KAEJ;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -15,7 +15,7 @@ export { InvoicesModal } from './InvoicesModal';
15
15
  export { useOpenBillingPortal } from './useOpenBillingPortal';
16
16
  export { useAutoRefreshPendingProjects } from './useAutoRefreshPendingProjects';
17
17
  export { formatMoney, useRewardBalance, type RewardBalance } from './reward-balance';
18
- export { REFERRAL_OFFER, useReferralReward } from './referral-reward';
18
+ export { useReferralOffer, useReferralReward } from './referral-reward';
19
19
  export { isProProject, planBadgeView, planName } from './plan-badge';
20
20
  export { aiUsageResetTimestamp, formatResetDate, getQuotaItems } from './quota-items';
21
21
  export { CAP_REACHED_MESSAGE, ZERO_BUDGET_MESSAGE, isAddonBudgetZero } from './addon-pricing';
@@ -14,7 +14,7 @@ import { InvoicesModal } from "./InvoicesModal.js";
14
14
  import { useOpenBillingPortal } from "./useOpenBillingPortal.js";
15
15
  import { useAutoRefreshPendingProjects } from "./useAutoRefreshPendingProjects.js";
16
16
  import { formatMoney, useRewardBalance } from "./reward-balance.js";
17
- import { REFERRAL_OFFER, useReferralReward } from "./referral-reward.js";
17
+ import { useReferralOffer, useReferralReward } from "./referral-reward.js";
18
18
  import { isProProject, planBadgeView, planName } from "./plan-badge.js";
19
19
  import { aiUsageResetTimestamp, formatResetDate, getQuotaItems } from "./quota-items.js";
20
20
  import { CAP_REACHED_MESSAGE, ZERO_BUDGET_MESSAGE, isAddonBudgetZero } from "./addon-pricing.js";
@@ -44,7 +44,6 @@ export {
44
44
  ProjectDetail,
45
45
  ProjectUsageContent,
46
46
  ProjectsTable,
47
- REFERRAL_OFFER,
48
47
  SharedProjects,
49
48
  ZERO_BUDGET_MESSAGE,
50
49
  aiUsageResetTimestamp,
@@ -66,6 +65,7 @@ export {
66
65
  useBillingSupport,
67
66
  useOpenBillingPortal,
68
67
  useProjectBillingFocus,
68
+ useReferralOffer,
69
69
  useReferralReward,
70
70
  useRewardBalance
71
71
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/connection/billing/index.ts"],
4
- "sourcesContent": ["/**\n * The billing kit: a host's projects (plan, usage, add-ons, invoices), the plan picker and checkout,\n * new projects, and the projects shared with the user. Stripe stays the host's (the host\n * configuration's `billing`); without it projects show their limits and usage only.\n */\nexport { useBillingSupport, type BillingSupport, type BillingCheckoutSupport } from './support'\nexport {\n requestProjectBillingFocus,\n useProjectBillingFocus,\n type ProjectBillingFocus,\n} from './billing-focus'\nexport { ProjectsTable } from './ProjectsTable'\nexport { SharedProjects } from './SharedProjects'\nexport { ProjectDetail, type ProjectDetailProps } from './ProjectDetail'\nexport { NewProjectFlow } from './NewProjectFlow'\nexport { ChangePlanDialog } from './ChangePlanDialog'\nexport { AddAddonDialog } from './AddAddonDialog'\nexport { InvoicesModal } from './InvoicesModal'\nexport { useOpenBillingPortal } from './useOpenBillingPortal'\nexport { useAutoRefreshPendingProjects } from './useAutoRefreshPendingProjects'\nexport { formatMoney, useRewardBalance, type RewardBalance } from './reward-balance'\nexport { REFERRAL_OFFER, useReferralReward } from './referral-reward'\nexport { isProProject, planBadgeView, planName } from './plan-badge'\nexport { aiUsageResetTimestamp, formatResetDate, getQuotaItems } from './quota-items'\nexport { CAP_REACHED_MESSAGE, ZERO_BUDGET_MESSAGE, isAddonBudgetZero } from './addon-pricing'\nexport {\n ConnectedQuotaDialog,\n type ConnectedQuotaDialogProps,\n type QuotaExceededInfo,\n} from './ConnectedQuotaDialog'\nexport {\n createPaymentRequiredMiddleware,\n openQuotaDialogIfUsedUp,\n paymentConfirmationUrl,\n paymentRequiredToastMessage,\n routePaymentRequired,\n surfacePaymentRequired,\n type PaymentRequiredOptions,\n type PaymentRequiredRoute,\n} from './payment-required'\nexport { ConnectedWelcomeDialog, type ConnectedWelcomeDialogProps } from './ConnectedWelcomeDialog'\nexport {\n ProjectUsageContent,\n type ProjectUsageContentProps,\n type UsageBreakdownKey,\n} from './ProjectUsageContent'\n"],
5
- "mappings": ";AAKA,SAAS,yBAA2E;AACpF;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,qBAA8C;AACvD,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,qCAAqC;AAC9C,SAAS,aAAa,wBAA4C;AAClE,SAAS,gBAAgB,yBAAyB;AAClD,SAAS,cAAc,eAAe,gBAAgB;AACtD,SAAS,uBAAuB,iBAAiB,qBAAqB;AACtE,SAAS,qBAAqB,qBAAqB,yBAAyB;AAC5E;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,8BAAgE;AACzE;AAAA,EACE;AAAA,OAGK;",
4
+ "sourcesContent": ["/**\n * The billing kit: a host's projects (plan, usage, add-ons, invoices), the plan picker and checkout,\n * new projects, and the projects shared with the user. Stripe stays the host's (the host\n * configuration's `billing`); without it projects show their limits and usage only.\n */\nexport { useBillingSupport, type BillingSupport, type BillingCheckoutSupport } from './support'\nexport {\n requestProjectBillingFocus,\n useProjectBillingFocus,\n type ProjectBillingFocus,\n} from './billing-focus'\nexport { ProjectsTable } from './ProjectsTable'\nexport { SharedProjects } from './SharedProjects'\nexport { ProjectDetail, type ProjectDetailProps } from './ProjectDetail'\nexport { NewProjectFlow } from './NewProjectFlow'\nexport { ChangePlanDialog } from './ChangePlanDialog'\nexport { AddAddonDialog } from './AddAddonDialog'\nexport { InvoicesModal } from './InvoicesModal'\nexport { useOpenBillingPortal } from './useOpenBillingPortal'\nexport { useAutoRefreshPendingProjects } from './useAutoRefreshPendingProjects'\nexport { formatMoney, useRewardBalance, type RewardBalance } from './reward-balance'\nexport { useReferralOffer, useReferralReward } from './referral-reward'\nexport { isProProject, planBadgeView, planName } from './plan-badge'\nexport { aiUsageResetTimestamp, formatResetDate, getQuotaItems } from './quota-items'\nexport { CAP_REACHED_MESSAGE, ZERO_BUDGET_MESSAGE, isAddonBudgetZero } from './addon-pricing'\nexport {\n ConnectedQuotaDialog,\n type ConnectedQuotaDialogProps,\n type QuotaExceededInfo,\n} from './ConnectedQuotaDialog'\nexport {\n createPaymentRequiredMiddleware,\n openQuotaDialogIfUsedUp,\n paymentConfirmationUrl,\n paymentRequiredToastMessage,\n routePaymentRequired,\n surfacePaymentRequired,\n type PaymentRequiredOptions,\n type PaymentRequiredRoute,\n} from './payment-required'\nexport { ConnectedWelcomeDialog, type ConnectedWelcomeDialogProps } from './ConnectedWelcomeDialog'\nexport {\n ProjectUsageContent,\n type ProjectUsageContentProps,\n type UsageBreakdownKey,\n} from './ProjectUsageContent'\n"],
5
+ "mappings": ";AAKA,SAAS,yBAA2E;AACpF;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,qBAA8C;AACvD,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,qCAAqC;AAC9C,SAAS,aAAa,wBAA4C;AAClE,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,cAAc,eAAe,gBAAgB;AACtD,SAAS,uBAAuB,iBAAiB,qBAAqB;AACtE,SAAS,qBAAqB,qBAAqB,yBAAyB;AAC5E;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,8BAAgE;AACzE;AAAA,EACE;AAAA,OAGK;",
6
6
  "names": []
7
7
  }
@@ -11,9 +11,8 @@ export interface ReferralReward {
11
11
  amount: number;
12
12
  currency: string;
13
13
  }
14
- /** The standing referral offer — what one successful invite earns. One constant
15
- * so the welcome modal and the rewards modal can never quote different money. */
16
- export declare const REFERRAL_OFFER: ReferralReward;
14
+ /** The configured referral offer, supplied with the backend billing catalogue. */
15
+ export declare function useReferralOffer(enabled?: boolean): ReferralReward | null;
17
16
  /** The user's available referral reward, or null if none. */
18
17
  export declare function useReferralReward(): ReferralReward | null;
19
18
  /**
@@ -1,7 +1,12 @@
1
1
  "use client";
2
- import { useUserSettings } from "@arbidocs/react";
2
+ import { useProducts, useUserSettings } from "@arbidocs/react";
3
3
  import { formatMoney } from "./reward-balance.js";
4
- const REFERRAL_OFFER = { amount: 2e3, currency: "gbp" };
4
+ function useReferralOffer(enabled = true) {
5
+ const { data } = useProducts({ enabled });
6
+ const product = data?.[0];
7
+ if (product?.inviter_reward_amount == null || !product.reward_currency) return null;
8
+ return { amount: product.inviter_reward_amount, currency: product.reward_currency };
9
+ }
5
10
  function useReferralReward() {
6
11
  const { data } = useUserSettings();
7
12
  const ed = data?.extra_discount;
@@ -20,9 +25,9 @@ function applyReferralReward(totalCents, reward, priceCurrency) {
20
25
  };
21
26
  }
22
27
  export {
23
- REFERRAL_OFFER,
24
28
  applyReferralReward,
25
29
  formatMoney,
30
+ useReferralOffer,
26
31
  useReferralReward
27
32
  };
28
33
  //# sourceMappingURL=referral-reward.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/connection/billing/referral-reward.ts"],
4
- "sourcesContent": ["/**\n * Referral-reward logic (hook + pure helpers) shared across the pricing UI.\n *\n * The reward is a single GLOBAL per-user number \u2014 a Stripe account balance mirrored\n * read-only into `settings.extra_discount`. It auto-applies to the user's NEXT invoice.\n * `applyReferralReward` mirrors Stripe's customer-balance logic: applied to the charge,\n * clamped at zero, remainder rolls forward. Components live in `./ConnectedReferralReward`.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\n\n// Money formatting lives with the broad reward balance \u2014 referral reward is one source\n// that feeds it. Re-exported so existing `from './referral-reward'` imports keep working.\nexport { formatMoney } from './reward-balance'\n\nexport interface ReferralReward {\n amount: number // minor units (e.g. pennies) of available account balance\n currency: string\n}\n\n/** The standing referral offer \u2014 what one successful invite earns. One constant\n * so the welcome modal and the rewards modal can never quote different money. */\nexport const REFERRAL_OFFER: ReferralReward = { amount: 2000, currency: 'gbp' }\n\n/** The user's available referral reward, or null if none. */\nexport function useReferralReward(): ReferralReward | null {\n const { data } = useUserSettings()\n // Backend mirrors this read-only as { amount, currency }; schema types it as a loose object.\n const ed = data?.extra_discount as { amount?: number; currency?: string } | null | undefined\n if (!ed || !ed.amount || ed.amount <= 0) return null\n return { amount: ed.amount, currency: ed.currency || 'gbp' }\n}\n\n/**\n * Apply the reward to a charge, mirroring Stripe's customer-balance behaviour.\n * Returns null when there's no usable reward or the currency doesn't match the price.\n */\nexport function applyReferralReward(\n totalCents: number,\n reward: ReferralReward | null,\n priceCurrency: string\n) {\n if (!reward || reward.amount <= 0) return null\n if (reward.currency.toLowerCase() !== priceCurrency.toLowerCase()) return null\n const bonus = Math.min(totalCents, reward.amount)\n return {\n bonus,\n youPay: totalCents - bonus,\n remaining: reward.amount - bonus,\n currency: priceCurrency,\n }\n}\n"],
5
- "mappings": ";AASA,SAAS,uBAAuB;AAIhC,SAAS,mBAAmB;AASrB,MAAM,iBAAiC,EAAE,QAAQ,KAAM,UAAU,MAAM;AAGvE,SAAS,oBAA2C;AACzD,QAAM,EAAE,KAAK,IAAI,gBAAgB;AAEjC,QAAM,KAAK,MAAM;AACjB,MAAI,CAAC,MAAM,CAAC,GAAG,UAAU,GAAG,UAAU,EAAG,QAAO;AAChD,SAAO,EAAE,QAAQ,GAAG,QAAQ,UAAU,GAAG,YAAY,MAAM;AAC7D;AAMO,SAAS,oBACd,YACA,QACA,eACA;AACA,MAAI,CAAC,UAAU,OAAO,UAAU,EAAG,QAAO;AAC1C,MAAI,OAAO,SAAS,YAAY,MAAM,cAAc,YAAY,EAAG,QAAO;AAC1E,QAAM,QAAQ,KAAK,IAAI,YAAY,OAAO,MAAM;AAChD,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,aAAa;AAAA,IACrB,WAAW,OAAO,SAAS;AAAA,IAC3B,UAAU;AAAA,EACZ;AACF;",
4
+ "sourcesContent": ["/**\n * Referral-reward logic (hook + pure helpers) shared across the pricing UI.\n *\n * The reward is a single GLOBAL per-user number \u2014 a Stripe account balance mirrored\n * read-only into `settings.extra_discount`. It auto-applies to the user's NEXT invoice.\n * `applyReferralReward` mirrors Stripe's customer-balance logic: applied to the charge,\n * clamped at zero, remainder rolls forward. Components live in `./ConnectedReferralReward`.\n */\n\nimport { useProducts, useUserSettings } from '@arbidocs/react'\n\n// Money formatting lives with the broad reward balance \u2014 referral reward is one source\n// that feeds it. Re-exported so existing `from './referral-reward'` imports keep working.\nexport { formatMoney } from './reward-balance'\n\nexport interface ReferralReward {\n amount: number // minor units (e.g. pennies) of available account balance\n currency: string\n}\n\n/** The configured referral offer, supplied with the backend billing catalogue. */\nexport function useReferralOffer(enabled = true): ReferralReward | null {\n const { data } = useProducts({ enabled })\n const product = data?.[0]\n if (product?.inviter_reward_amount == null || !product.reward_currency) return null\n return { amount: product.inviter_reward_amount, currency: product.reward_currency }\n}\n\n/** The user's available referral reward, or null if none. */\nexport function useReferralReward(): ReferralReward | null {\n const { data } = useUserSettings()\n // Backend mirrors this read-only as { amount, currency }; schema types it as a loose object.\n const ed = data?.extra_discount as { amount?: number; currency?: string } | null | undefined\n if (!ed || !ed.amount || ed.amount <= 0) return null\n return { amount: ed.amount, currency: ed.currency || 'gbp' }\n}\n\n/**\n * Apply the reward to a charge, mirroring Stripe's customer-balance behaviour.\n * Returns null when there's no usable reward or the currency doesn't match the price.\n */\nexport function applyReferralReward(\n totalCents: number,\n reward: ReferralReward | null,\n priceCurrency: string\n) {\n if (!reward || reward.amount <= 0) return null\n if (reward.currency.toLowerCase() !== priceCurrency.toLowerCase()) return null\n const bonus = Math.min(totalCents, reward.amount)\n return {\n bonus,\n youPay: totalCents - bonus,\n remaining: reward.amount - bonus,\n currency: priceCurrency,\n }\n}\n"],
5
+ "mappings": ";AASA,SAAS,aAAa,uBAAuB;AAI7C,SAAS,mBAAmB;AAQrB,SAAS,iBAAiB,UAAU,MAA6B;AACtE,QAAM,EAAE,KAAK,IAAI,YAAY,EAAE,QAAQ,CAAC;AACxC,QAAM,UAAU,OAAO,CAAC;AACxB,MAAI,SAAS,yBAAyB,QAAQ,CAAC,QAAQ,gBAAiB,QAAO;AAC/E,SAAO,EAAE,QAAQ,QAAQ,uBAAuB,UAAU,QAAQ,gBAAgB;AACpF;AAGO,SAAS,oBAA2C;AACzD,QAAM,EAAE,KAAK,IAAI,gBAAgB;AAEjC,QAAM,KAAK,MAAM;AACjB,MAAI,CAAC,MAAM,CAAC,GAAG,UAAU,GAAG,UAAU,EAAG,QAAO;AAChD,SAAO,EAAE,QAAQ,GAAG,QAAQ,UAAU,GAAG,YAAY,MAAM;AAC7D;AAMO,SAAS,oBACd,YACA,QACA,eACA;AACA,MAAI,CAAC,UAAU,OAAO,UAAU,EAAG,QAAO;AAC1C,MAAI,OAAO,SAAS,YAAY,MAAM,cAAc,YAAY,EAAG,QAAO;AAC1E,QAAM,QAAQ,KAAK,IAAI,YAAY,OAAO,MAAM;AAChD,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,aAAa;AAAA,IACrB,WAAW,OAAO,SAAS;AAAA,IAC3B,UAAU;AAAA,EACZ;AACF;",
6
6
  "names": []
7
7
  }
@@ -3,8 +3,8 @@
3
3
  * previews, add-on quotes): "£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)", "£40.00 · no VAT
4
4
  * (reverse charge)", "£40.00 · no tax".
5
5
  */
6
- import type { components } from '@arbidocs/client';
7
- export type TaxQuote = components['schemas']['TaxQuoteResponse'];
6
+ import type { ProjectPlanQuoteResponse } from '@arbidocs/client';
7
+ export type TaxQuote = ProjectPlanQuoteResponse;
8
8
  /** Countries whose tax depends on the postcode: the field is shown up front. */
9
9
  export declare const POSTCODE_COUNTRIES: readonly string[];
10
10
  /** The quote error that asks for a ZIP / postal code. */
@@ -33,6 +33,7 @@ function quoteParts(quote) {
33
33
  };
34
34
  }
35
35
  function quoteTotalLine(quote) {
36
+ if (quote.tax_calculated === false) return `Total today ${money2(quote.total_pence)} ex VAT`;
36
37
  return `Total today ${taxSummary(quoteParts(quote))}`;
37
38
  }
38
39
  function quoteError(error) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/connection/billing/tax-quote.ts"],
4
- "sourcesContent": ["/**\n * Tax-inclusive totals from the backend's Stripe Tax quotes (`TaxQuoteResponse`, plan-change\n * previews, add-on quotes): \"\u00A348.00 incl. VAT (\u00A340.00 + \u00A38.00 VAT 20%)\", \"\u00A340.00 \u00B7 no VAT\n * (reverse charge)\", \"\u00A340.00 \u00B7 no tax\".\n */\n\nimport type { components } from '@arbidocs/client'\nimport { apiErrorDetail } from './api-error'\n\nexport type TaxQuote = components['schemas']['TaxQuoteResponse']\n\n/** Countries whose tax depends on the postcode: the field is shown up front. */\nexport const POSTCODE_COUNTRIES: readonly string[] = ['US', 'CA']\n\n/** The quote error that asks for a ZIP / postal code. */\nexport const TAX_LOCATION_INVALID = 'TAX_LOCATION_INVALID'\n\n/** \"\u00A342.00\" \u2014 always pence, so the parts of a total add up on screen. */\nexport function money2(pence: number, currency = 'gbp'): string {\n const symbol = { gbp: '\u00A3', usd: '$', eur: '\u20AC' }[currency.toLowerCase()] ?? `${currency} `\n return `${symbol}${(pence / 100).toLocaleString('en-GB', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}`\n}\n\nexport interface TaxParts {\n subtotal: number\n tax: number\n total: number\n /** \"VAT 20%\"; null when no tax is due. */\n label?: string | null\n reverseCharge?: boolean\n}\n\n/** \"VAT\" for a VAT label, else \"tax\". */\nfunction taxKind(label: string | null | undefined): string {\n return /^vat\\b/i.test(label ?? '') ? 'VAT' : 'tax'\n}\n\n/** What follows the total: \"incl. VAT (\u00A340.00 + \u00A38.00 VAT 20%)\", \"\u00B7 no VAT (reverse charge)\", \"\u00B7 no tax\". */\nexport function taxDetail({ subtotal, tax, label, reverseCharge }: TaxParts): string {\n if (reverseCharge) return '\u00B7 no VAT (reverse charge)'\n if (tax <= 0) return '\u00B7 no tax'\n return `incl. ${taxKind(label)} (${money2(subtotal)} + ${money2(tax)} ${label ?? 'tax'})`\n}\n\n/** \"\u00A348.00 incl. VAT (\u00A340.00 + \u00A38.00 VAT 20%)\", \"\u00A340.00 \u00B7 no VAT (reverse charge)\", \"\u00A340.00 \u00B7 no tax\". */\nexport function taxSummary(parts: TaxParts): string {\n return `${money2(parts.total)} ${taxDetail(parts)}`\n}\n\n/** \"\u00A321.00 incl. VAT\" / \"\u00A317.50\" \u2014 a total with only the word for its tax. */\nexport function totalWithTaxWord({ total, tax, label }: TaxParts): string {\n return tax > 0 ? `${money2(total)} incl. ${taxKind(label)}` : money2(total)\n}\n\n/** The parts of a quote response. */\nexport function quoteParts(quote: TaxQuote): TaxParts {\n return {\n subtotal: quote.subtotal_pence,\n tax: quote.tax_pence,\n total: quote.total_pence,\n label: quote.tax_label,\n reverseCharge: quote.reverse_charge,\n }\n}\n\n/** \"Total today \u00A348.00 incl. VAT (\u00A340.00 + \u00A38.00 VAT 20%)\". */\nexport function quoteTotalLine(quote: TaxQuote): string {\n return `Total today ${taxSummary(quoteParts(quote))}`\n}\n\n/** The API error code (`detail.code`) and message, if any. */\nexport function quoteError(error: unknown): { code?: string; message?: string } {\n const detail = apiErrorDetail(error)\n if (detail && typeof detail === 'object') {\n const { code, message } = detail as { code?: unknown; message?: unknown }\n return {\n code: typeof code === 'string' ? code : undefined,\n message: typeof message === 'string' ? message : undefined,\n }\n }\n return { message: typeof detail === 'string' ? detail : undefined }\n}\n"],
5
- "mappings": ";AAOA,SAAS,sBAAsB;AAKxB,MAAM,qBAAwC,CAAC,MAAM,IAAI;AAGzD,MAAM,uBAAuB;AAG7B,SAAS,OAAO,OAAe,WAAW,OAAe;AAC9D,QAAM,SAAS,EAAE,KAAK,QAAK,KAAK,KAAK,KAAK,SAAI,EAAE,SAAS,YAAY,CAAC,KAAK,GAAG,QAAQ;AACtF,SAAO,GAAG,MAAM,IAAI,QAAQ,KAAK,eAAe,SAAS;AAAA,IACvD,uBAAuB;AAAA,IACvB,uBAAuB;AAAA,EACzB,CAAC,CAAC;AACJ;AAYA,SAAS,QAAQ,OAA0C;AACzD,SAAO,UAAU,KAAK,SAAS,EAAE,IAAI,QAAQ;AAC/C;AAGO,SAAS,UAAU,EAAE,UAAU,KAAK,OAAO,cAAc,GAAqB;AACnF,MAAI,cAAe,QAAO;AAC1B,MAAI,OAAO,EAAG,QAAO;AACrB,SAAO,SAAS,QAAQ,KAAK,CAAC,KAAK,OAAO,QAAQ,CAAC,MAAM,OAAO,GAAG,CAAC,IAAI,SAAS,KAAK;AACxF;AAGO,SAAS,WAAW,OAAyB;AAClD,SAAO,GAAG,OAAO,MAAM,KAAK,CAAC,IAAI,UAAU,KAAK,CAAC;AACnD;AAGO,SAAS,iBAAiB,EAAE,OAAO,KAAK,MAAM,GAAqB;AACxE,SAAO,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC,UAAU,QAAQ,KAAK,CAAC,KAAK,OAAO,KAAK;AAC5E;AAGO,SAAS,WAAW,OAA2B;AACpD,SAAO;AAAA,IACL,UAAU,MAAM;AAAA,IAChB,KAAK,MAAM;AAAA,IACX,OAAO,MAAM;AAAA,IACb,OAAO,MAAM;AAAA,IACb,eAAe,MAAM;AAAA,EACvB;AACF;AAGO,SAAS,eAAe,OAAyB;AACtD,SAAO,eAAe,WAAW,WAAW,KAAK,CAAC,CAAC;AACrD;AAGO,SAAS,WAAW,OAAqD;AAC9E,QAAM,SAAS,eAAe,KAAK;AACnC,MAAI,UAAU,OAAO,WAAW,UAAU;AACxC,UAAM,EAAE,MAAM,QAAQ,IAAI;AAC1B,WAAO;AAAA,MACL,MAAM,OAAO,SAAS,WAAW,OAAO;AAAA,MACxC,SAAS,OAAO,YAAY,WAAW,UAAU;AAAA,IACnD;AAAA,EACF;AACA,SAAO,EAAE,SAAS,OAAO,WAAW,WAAW,SAAS,OAAU;AACpE;",
4
+ "sourcesContent": ["/**\n * Tax-inclusive totals from the backend's Stripe Tax quotes (`TaxQuoteResponse`, plan-change\n * previews, add-on quotes): \"\u00A348.00 incl. VAT (\u00A340.00 + \u00A38.00 VAT 20%)\", \"\u00A340.00 \u00B7 no VAT\n * (reverse charge)\", \"\u00A340.00 \u00B7 no tax\".\n */\n\nimport type { ProjectPlanQuoteResponse } from '@arbidocs/client'\nimport { apiErrorDetail } from './api-error'\n\nexport type TaxQuote = ProjectPlanQuoteResponse\n\n/** Countries whose tax depends on the postcode: the field is shown up front. */\nexport const POSTCODE_COUNTRIES: readonly string[] = ['US', 'CA']\n\n/** The quote error that asks for a ZIP / postal code. */\nexport const TAX_LOCATION_INVALID = 'TAX_LOCATION_INVALID'\n\n/** \"\u00A342.00\" \u2014 always pence, so the parts of a total add up on screen. */\nexport function money2(pence: number, currency = 'gbp'): string {\n const symbol = { gbp: '\u00A3', usd: '$', eur: '\u20AC' }[currency.toLowerCase()] ?? `${currency} `\n return `${symbol}${(pence / 100).toLocaleString('en-GB', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}`\n}\n\nexport interface TaxParts {\n subtotal: number\n tax: number\n total: number\n /** \"VAT 20%\"; null when no tax is due. */\n label?: string | null\n reverseCharge?: boolean\n}\n\n/** \"VAT\" for a VAT label, else \"tax\". */\nfunction taxKind(label: string | null | undefined): string {\n return /^vat\\b/i.test(label ?? '') ? 'VAT' : 'tax'\n}\n\n/** What follows the total: \"incl. VAT (\u00A340.00 + \u00A38.00 VAT 20%)\", \"\u00B7 no VAT (reverse charge)\", \"\u00B7 no tax\". */\nexport function taxDetail({ subtotal, tax, label, reverseCharge }: TaxParts): string {\n if (reverseCharge) return '\u00B7 no VAT (reverse charge)'\n if (tax <= 0) return '\u00B7 no tax'\n return `incl. ${taxKind(label)} (${money2(subtotal)} + ${money2(tax)} ${label ?? 'tax'})`\n}\n\n/** \"\u00A348.00 incl. VAT (\u00A340.00 + \u00A38.00 VAT 20%)\", \"\u00A340.00 \u00B7 no VAT (reverse charge)\", \"\u00A340.00 \u00B7 no tax\". */\nexport function taxSummary(parts: TaxParts): string {\n return `${money2(parts.total)} ${taxDetail(parts)}`\n}\n\n/** \"\u00A321.00 incl. VAT\" / \"\u00A317.50\" \u2014 a total with only the word for its tax. */\nexport function totalWithTaxWord({ total, tax, label }: TaxParts): string {\n return tax > 0 ? `${money2(total)} incl. ${taxKind(label)}` : money2(total)\n}\n\n/** The parts of a quote response. */\nexport function quoteParts(quote: TaxQuote): TaxParts {\n return {\n subtotal: quote.subtotal_pence,\n tax: quote.tax_pence,\n total: quote.total_pence,\n label: quote.tax_label,\n reverseCharge: quote.reverse_charge,\n }\n}\n\n/** \"Total today \u00A348.00 incl. VAT (\u00A340.00 + \u00A38.00 VAT 20%)\". */\nexport function quoteTotalLine(quote: TaxQuote): string {\n if (quote.tax_calculated === false) return `Total today ${money2(quote.total_pence)} ex VAT`\n return `Total today ${taxSummary(quoteParts(quote))}`\n}\n\n/** The API error code (`detail.code`) and message, if any. */\nexport function quoteError(error: unknown): { code?: string; message?: string } {\n const detail = apiErrorDetail(error)\n if (detail && typeof detail === 'object') {\n const { code, message } = detail as { code?: unknown; message?: unknown }\n return {\n code: typeof code === 'string' ? code : undefined,\n message: typeof message === 'string' ? message : undefined,\n }\n }\n return { message: typeof detail === 'string' ? detail : undefined }\n}\n"],
5
+ "mappings": ";AAOA,SAAS,sBAAsB;AAKxB,MAAM,qBAAwC,CAAC,MAAM,IAAI;AAGzD,MAAM,uBAAuB;AAG7B,SAAS,OAAO,OAAe,WAAW,OAAe;AAC9D,QAAM,SAAS,EAAE,KAAK,QAAK,KAAK,KAAK,KAAK,SAAI,EAAE,SAAS,YAAY,CAAC,KAAK,GAAG,QAAQ;AACtF,SAAO,GAAG,MAAM,IAAI,QAAQ,KAAK,eAAe,SAAS;AAAA,IACvD,uBAAuB;AAAA,IACvB,uBAAuB;AAAA,EACzB,CAAC,CAAC;AACJ;AAYA,SAAS,QAAQ,OAA0C;AACzD,SAAO,UAAU,KAAK,SAAS,EAAE,IAAI,QAAQ;AAC/C;AAGO,SAAS,UAAU,EAAE,UAAU,KAAK,OAAO,cAAc,GAAqB;AACnF,MAAI,cAAe,QAAO;AAC1B,MAAI,OAAO,EAAG,QAAO;AACrB,SAAO,SAAS,QAAQ,KAAK,CAAC,KAAK,OAAO,QAAQ,CAAC,MAAM,OAAO,GAAG,CAAC,IAAI,SAAS,KAAK;AACxF;AAGO,SAAS,WAAW,OAAyB;AAClD,SAAO,GAAG,OAAO,MAAM,KAAK,CAAC,IAAI,UAAU,KAAK,CAAC;AACnD;AAGO,SAAS,iBAAiB,EAAE,OAAO,KAAK,MAAM,GAAqB;AACxE,SAAO,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC,UAAU,QAAQ,KAAK,CAAC,KAAK,OAAO,KAAK;AAC5E;AAGO,SAAS,WAAW,OAA2B;AACpD,SAAO;AAAA,IACL,UAAU,MAAM;AAAA,IAChB,KAAK,MAAM;AAAA,IACX,OAAO,MAAM;AAAA,IACb,OAAO,MAAM;AAAA,IACb,eAAe,MAAM;AAAA,EACvB;AACF;AAGO,SAAS,eAAe,OAAyB;AACtD,MAAI,MAAM,mBAAmB,MAAO,QAAO,eAAe,OAAO,MAAM,WAAW,CAAC;AACnF,SAAO,eAAe,WAAW,WAAW,KAAK,CAAC,CAAC;AACrD;AAGO,SAAS,WAAW,OAAqD;AAC9E,QAAM,SAAS,eAAe,KAAK;AACnC,MAAI,UAAU,OAAO,WAAW,UAAU;AACxC,UAAM,EAAE,MAAM,QAAQ,IAAI;AAC1B,WAAO;AAAA,MACL,MAAM,OAAO,SAAS,WAAW,OAAO;AAAA,MACxC,SAAS,OAAO,YAAY,WAAW,UAAU;AAAA,IACnD;AAAA,EACF;AACA,SAAO,EAAE,SAAS,OAAO,WAAW,WAAW,SAAS,OAAU;AACpE;",
6
6
  "names": []
7
7
  }
@@ -6,6 +6,7 @@ import {
6
6
  useArbiSession,
7
7
  useArbiSessionStore,
8
8
  useCanCreateProjects,
9
+ useCanCreateWorkspaces,
9
10
  useCurrentWorkspace,
10
11
  useFeatureCheck
11
12
  } from "@arbidocs/react";
@@ -62,6 +63,7 @@ function ConnectedCommandPalette({
62
63
  role,
63
64
  isTemporaryAccess: useArbiSession().user?.temporary_access_only === true,
64
65
  canCreateProjects: useCanCreateProjects(),
66
+ canCreateWorkspaces: useCanCreateWorkspaces(),
65
67
  isFeatureOn: useFeatureCheck()
66
68
  };
67
69
  const { ask, search } = useWorkspaceAsk();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/connection/command/ConnectedCommandPalette.tsx"],
4
- "sourcesContent": ["/**\n * The \u2318K command palette: one input that jumps to a page, runs an action, or hands the text to the\n * workspace's ask and search. \u2318K / Ctrl+K toggles it anywhere; `openCommandPalette()` opens it from\n * a button or a menu.\n *\n * Its actions are the built-in catalogue (`createBuiltinActions`) on the host's environment and\n * session, plus the host's own `actions` (an equal id replaces a built-in one). An action is\n * offered when its `available` says so (the gates of its primary UI: the workspace, the role, the\n * account, the features) and it is `listed`. Pages are the host's\n * `navigation` (`defineNavigation(...).items`). With text typed and a workspace open, the last rows\n * are \"Ask\" (a new chat that sends the text) and \"Search\" (the Files search view), exactly as the\n * workspace's ask field does (`useWorkspaceAsk`); when nothing else matches, Enter asks.\n */\nimport { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\nimport { ArrowRight, Search, Sparkles, Wand2 } from 'lucide-react'\nimport {\n useArbiSession,\n useArbiSessionStore,\n useCanCreateProjects,\n useCurrentWorkspace,\n useFeatureCheck,\n} from '@arbidocs/react'\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogTitle,\n} from '@arbidocs/react/ui'\nimport type { ActionContext, ActionDefinition } from '../../nav/actions'\nimport type { AppNavItem } from '../../nav/types'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useWorkspaceAsk } from '../ask/useWorkspaceAsk'\nimport { useSlashSkillWorkflows } from '../workflows/useSlashSkillWorkflows'\nimport { isSkillPackWorkflow } from '../../agents/workflows/skillPack'\n\nimport { useConnectedWorkspace } from '../ConnectionProvider'\nimport { useShellNavigation } from '../shell/shell-navigation'\nimport { createBuiltinActions } from './actions'\nimport { actionIcon } from './icons'\nimport {\n DEFAULT_COMMAND_PALETTE_LABELS,\n isPaletteShortcut,\n usePaletteOpen,\n type CommandPaletteLabels,\n} from './palette-state'\n\n/** How many skills show before anything is typed. */\nconst EMPTY_QUERY_SKILLS = 5\n\nexport interface ConnectedCommandPaletteProps {\n /**\n * The host's destinations (`defineNavigation(...).items`), listed under Pages. Default: inside a\n * routed `ConnectedAppShell`, its visible (gated) destinations; elsewhere none.\n */\n navigation?: readonly AppNavItem[]\n /** Go to a destination. Default: the environment's `navigate(item.to)`. */\n onNavigate?: (item: AppNavItem) => void\n /** The host's own actions, beside the built-in ones (an equal id replaces a built-in one). */\n actions?: Readonly<Partial<Record<string, ActionDefinition>>>\n labels?: Partial<CommandPaletteLabels>\n}\n\n/** Every word of the query appears in the fields. */\nfunction matches(query: string, ...fields: Array<string | readonly string[] | undefined>): boolean {\n const haystack = fields.flat().join(' ').toLowerCase()\n return query\n .toLowerCase()\n .split(/\\s+/)\n .every((word) => haystack.includes(word))\n}\n\nexport function ConnectedCommandPalette({\n navigation: navigationProp,\n onNavigate,\n actions,\n labels: labelOverrides,\n}: ConnectedCommandPaletteProps) {\n const labels = { ...DEFAULT_COMMAND_PALETTE_LABELS, ...labelOverrides }\n const isOpen = usePaletteOpen()\n const shellItems = useShellNavigation()?.visibleItems\n // An explicit list wins; in a routed shell, its gated rows (a hidden row never shows here).\n const navigation = navigationProp ?? shellItems ?? []\n const setOpen = (open: boolean) => usePaletteOpen.setState(open, true)\n const [query, setQuery] = useState('')\n const listRef = useRef<HTMLDivElement>(null)\n const environment = useBlocksEnvironment()\n const session = useArbiSessionStore()\n const { workspaceId } = useConnectedWorkspace()\n const { isMember, role } = useCurrentWorkspace()\n const context: ActionContext = {\n workspaceId,\n isMember,\n role,\n isTemporaryAccess: useArbiSession().user?.temporary_access_only === true,\n canCreateProjects: useCanCreateProjects(),\n isFeatureOn: useFeatureCheck(),\n }\n const { ask, search } = useWorkspaceAsk()\n // The skills open their form through the one launcher the `/` menus use, landing in a chat.\n const skillLauncher = useSlashSkillWorkflows({ landing: 'chat' })\n\n useEffect(() => {\n const onKey = (event: KeyboardEvent) => {\n if (!isPaletteShortcut(event)) return\n event.preventDefault()\n usePaletteOpen.setState((open) => !open, true)\n }\n window.addEventListener('keydown', onKey)\n return () => window.removeEventListener('keydown', onKey)\n }, [])\n\n // New text shows its best rows from the top (the browser would keep the old scroll position).\n useLayoutEffect(() => {\n listRef.current?.scrollTo?.({ top: 0 })\n }, [query])\n\n // Closed, it forgets the text: it opens empty, never on the last query's rows.\n useEffect(() => {\n if (!isOpen) setQuery('')\n }, [isOpen])\n\n const catalogue = useMemo(() => {\n const all: Partial<Record<string, ActionDefinition>> = {\n ...createBuiltinActions(environment, session),\n ...actions,\n }\n return Object.values(all).filter((action): action is ActionDefinition => !!action)\n }, [environment, session, actions])\n\n const text = query.trim()\n const pages = navigation.filter((item) => !text || matches(text, item.label, item.keywords))\n const groups = new Map<string, ActionDefinition[]>()\n for (const action of catalogue) {\n if (action.listed === false || (action.available && !action.available(context))) continue\n if (text && !matches(text, action.label, action.category, action.keywords)) continue\n groups.set(action.category, [...(groups.get(action.category) ?? []), action])\n }\n\n // Skills run in the open workspace: none without one. Typed text searches them all; with nothing\n // typed only a few show, the host's packs first, so the actions stay in view.\n const skills = !workspaceId\n ? []\n : text\n ? skillLauncher.openable.filter((w) =>\n matches(text, w.title, w.description, w.id, w.category)\n )\n : [\n ...skillLauncher.openable.filter(isSkillPackWorkflow),\n ...skillLauncher.openable.filter((w) => !isSkillPackWorkflow(w)),\n ].slice(0, EMPTY_QUERY_SKILLS)\n\n const choose = (run: () => void) => {\n setOpen(false)\n run()\n }\n\n return (\n <>\n <Dialog open={isOpen} onOpenChange={setOpen}>\n <DialogContent\n className=\"top-[12%] max-w-2xl translate-y-0 gap-0 overflow-hidden p-0\"\n data-testid=\"command-palette\"\n >\n <DialogTitle className=\"sr-only\">{labels.title}</DialogTitle>\n <DialogDescription className=\"sr-only\">{labels.placeholder}</DialogDescription>\n {/* No vim keys: Ctrl+K in the input closes the palette rather than moving up. */}\n <Command shouldFilter={false} loop vimBindings={false}>\n <CommandInput\n value={query}\n onValueChange={setQuery}\n placeholder={labels.placeholder}\n className=\"h-12 text-base\"\n data-testid=\"command-palette-input\"\n />\n <CommandList ref={listRef} className=\"max-h-[60vh] p-1\">\n <CommandEmpty className=\"py-6 text-center text-sm text-muted-foreground\">\n {labels.empty}\n </CommandEmpty>\n {pages.length > 0 && (\n <CommandGroup heading={labels.pages}>\n {pages.map((item) => (\n <CommandItem\n key={item.id}\n value={`page:${item.id}`}\n onSelect={() =>\n choose(() =>\n onNavigate ? onNavigate(item) : environment.navigate(item.to)\n )\n }\n data-testid={`command-palette-nav-${item.id}`}\n >\n <item.icon className=\"text-muted-foreground\" />\n <span className=\"flex-1\">{item.label}</span>\n <ArrowRight className=\"text-muted-foreground\" />\n </CommandItem>\n ))}\n </CommandGroup>\n )}\n {[...groups].map(([category, rows]) => (\n <CommandGroup key={category} heading={category}>\n {rows.map((action) => {\n const Icon = actionIcon(action.icon)\n return (\n <CommandItem\n key={action.id}\n value={`action:${action.id}`}\n onSelect={() => choose(action.run)}\n data-testid={`command-palette-action-${action.id}`}\n >\n <Icon className=\"text-muted-foreground\" />\n <span>{action.label}</span>\n </CommandItem>\n )\n })}\n </CommandGroup>\n ))}\n {skills.length > 0 && (\n <CommandGroup heading={labels.skills}>\n {skills.map((workflow) => (\n <CommandItem\n key={workflow.id}\n value={`skill:${workflow.id}`}\n onSelect={() => choose(() => skillLauncher.openSkill(workflow.id))}\n data-testid={`command-palette-skill-${workflow.id}`}\n >\n <Wand2 className=\"text-muted-foreground\" />\n <span className=\"flex-1 truncate\">{workflow.title}</span>\n <span className=\"truncate text-xs text-muted-foreground\">/{workflow.id}</span>\n </CommandItem>\n ))}\n </CommandGroup>\n )}\n {text && workspaceId && (\n <CommandGroup>\n <CommandItem\n value=\"ask\"\n onSelect={() => choose(() => ask(text))}\n data-testid=\"command-palette-ask\"\n >\n <Sparkles className=\"text-ai-accent\" />\n <span className=\"truncate\">\n {labels.ask}: \u201C{text}\u201D\n </span>\n </CommandItem>\n <CommandItem\n value=\"search\"\n onSelect={() => choose(() => search(text))}\n data-testid=\"command-palette-search\"\n >\n <Search className=\"text-muted-foreground\" />\n <span className=\"truncate\">\n {labels.search} \u201C{text}\u201D\n </span>\n </CommandItem>\n </CommandGroup>\n )}\n </CommandList>\n </Command>\n </DialogContent>\n </Dialog>\n {/* The skill's form, outside the palette: it stays open once the palette closes. */}\n {skillLauncher.launcher}\n </>\n )\n}\n"],
5
- "mappings": ";AAmKI,mBAMM,KAkBU,YAxBhB;AAtJJ,SAAS,WAAW,iBAAiB,SAAS,QAAQ,gBAAgB;AACtE,SAAS,YAAY,QAAQ,UAAU,aAAa;AACpD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AAEpC,SAAS,6BAA6B;AACtC,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAGP,MAAM,qBAAqB;AAgB3B,SAAS,QAAQ,UAAkB,QAAgE;AACjG,QAAM,WAAW,OAAO,KAAK,EAAE,KAAK,GAAG,EAAE,YAAY;AACrD,SAAO,MACJ,YAAY,EACZ,MAAM,KAAK,EACX,MAAM,CAAC,SAAS,SAAS,SAAS,IAAI,CAAC;AAC5C;AAEO,SAAS,wBAAwB;AAAA,EACtC,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,QAAQ;AACV,GAAiC;AAC/B,QAAM,SAAS,EAAE,GAAG,gCAAgC,GAAG,eAAe;AACtE,QAAM,SAAS,eAAe;AAC9B,QAAM,aAAa,mBAAmB,GAAG;AAEzC,QAAM,aAAa,kBAAkB,cAAc,CAAC;AACpD,QAAM,UAAU,CAAC,SAAkB,eAAe,SAAS,MAAM,IAAI;AACrE,QAAM,CAAC,OA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M,OAAO,MAAM,cAAc,UAAU,SAAS,EAAE,CAAC;AAAA,kBACjE,eAAa,yBAAyB,SAAS,EAAE;AAAA,kBAEjD;AAAA,wCAAC,SAAM,WAAU,yBAAwB;AAAA,oBACzC,oBAAC,UAAK,WAAU,mBAAmB,mBAAS,OAAM;AAAA,oBAClD,qBAAC,UAAK,WAAU,0CAAyC;AAAA;AAAA,sBAAE,SAAS;AAAA,uBAAG;AAAA;AAAA;AAAA,gBAPlE,SAAS;AAAA,cAQhB,CACD,GACH;AAAA,cAED,QAAQ,eACP,qBAAC,gBACC;AAAA;AAAA,kBAAC;AAAA;AAAA,oBACC,OAAM;AAAA,oBACN,UAAU,MAAM,OAAO,MAAM,IAAI,IAAI,CAAC;AAAA,oBACtC,eAAY;AAAA,oBAEZ;AAAA,0CAAC,YAAS,WAAU,kBAAiB;AAAA,sBACrC,qBAAC,UAAK,WAAU,YACb;AAAA,+BAAO;AAAA,wBAAI;AAAA,wBAAI;AAAA,wBAAK;AAAA,yBACvB;AAAA;AAAA;AAAA,gBACF;AAAA,gBACA;AAAA,kBAAC;AAAA;AAAA,oBACC,OAAM;AAAA,oBACN,UAAU,MAAM,OAAO,MAAM,OAAO,IAAI,CAAC;AAAA,oBACzC,eAAY;AAAA,oBAEZ;AAAA,0CAAC,UAAO,WAAU,yBAAwB;AAAA,sBAC1C,qBAAC,UAAK,WAAU,YACb;AAAA,+BAAO;AAAA,wBAAO;AAAA,wBAAG;AAAA,wBAAK;AAAA,yBACzB;AAAA;AAAA;AAAA,gBACF;AAAA,iBACF;AAAA,eAEJ;AAAA,aACF;AAAA;AAAA;AAAA,IACF,GACF;AAAA,IAEC,cAAc;AAAA,KACjB;AAEJ;",
4
+ "sourcesContent": ["/**\n * The \u2318K command palette: one input that jumps to a page, runs an action, or hands the text to the\n * workspace's ask and search. \u2318K / Ctrl+K toggles it anywhere; `openCommandPalette()` opens it from\n * a button or a menu.\n *\n * Its actions are the built-in catalogue (`createBuiltinActions`) on the host's environment and\n * session, plus the host's own `actions` (an equal id replaces a built-in one). An action is\n * offered when its `available` says so (the gates of its primary UI: the workspace, the role, the\n * account, the features) and it is `listed`. Pages are the host's\n * `navigation` (`defineNavigation(...).items`). With text typed and a workspace open, the last rows\n * are \"Ask\" (a new chat that sends the text) and \"Search\" (the Files search view), exactly as the\n * workspace's ask field does (`useWorkspaceAsk`); when nothing else matches, Enter asks.\n */\nimport { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\nimport { ArrowRight, Search, Sparkles, Wand2 } from 'lucide-react'\nimport {\n useArbiSession,\n useArbiSessionStore,\n useCanCreateProjects,\n useCanCreateWorkspaces,\n useCurrentWorkspace,\n useFeatureCheck,\n} from '@arbidocs/react'\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogTitle,\n} from '@arbidocs/react/ui'\nimport type { ActionContext, ActionDefinition } from '../../nav/actions'\nimport type { AppNavItem } from '../../nav/types'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { useWorkspaceAsk } from '../ask/useWorkspaceAsk'\nimport { useSlashSkillWorkflows } from '../workflows/useSlashSkillWorkflows'\nimport { isSkillPackWorkflow } from '../../agents/workflows/skillPack'\n\nimport { useConnectedWorkspace } from '../ConnectionProvider'\nimport { useShellNavigation } from '../shell/shell-navigation'\nimport { createBuiltinActions } from './actions'\nimport { actionIcon } from './icons'\nimport {\n DEFAULT_COMMAND_PALETTE_LABELS,\n isPaletteShortcut,\n usePaletteOpen,\n type CommandPaletteLabels,\n} from './palette-state'\n\n/** How many skills show before anything is typed. */\nconst EMPTY_QUERY_SKILLS = 5\n\nexport interface ConnectedCommandPaletteProps {\n /**\n * The host's destinations (`defineNavigation(...).items`), listed under Pages. Default: inside a\n * routed `ConnectedAppShell`, its visible (gated) destinations; elsewhere none.\n */\n navigation?: readonly AppNavItem[]\n /** Go to a destination. Default: the environment's `navigate(item.to)`. */\n onNavigate?: (item: AppNavItem) => void\n /** The host's own actions, beside the built-in ones (an equal id replaces a built-in one). */\n actions?: Readonly<Partial<Record<string, ActionDefinition>>>\n labels?: Partial<CommandPaletteLabels>\n}\n\n/** Every word of the query appears in the fields. */\nfunction matches(query: string, ...fields: Array<string | readonly string[] | undefined>): boolean {\n const haystack = fields.flat().join(' ').toLowerCase()\n return query\n .toLowerCase()\n .split(/\\s+/)\n .every((word) => haystack.includes(word))\n}\n\nexport function ConnectedCommandPalette({\n navigation: navigationProp,\n onNavigate,\n actions,\n labels: labelOverrides,\n}: ConnectedCommandPaletteProps) {\n const labels = { ...DEFAULT_COMMAND_PALETTE_LABELS, ...labelOverrides }\n const isOpen = usePaletteOpen()\n const shellItems = useShellNavigation()?.visibleItems\n // An explicit list wins; in a routed shell, its gated rows (a hidden row never shows here).\n const navigation = navigationProp ?? shellItems ?? []\n const setOpen = (open: boolean) => usePaletteOpen.setState(open, true)\n const [query, setQuery] = useState('')\n const listRef = useRef<HTMLDivElement>(null)\n const environment = useBlocksEnvironment()\n const session = useArbiSessionStore()\n const { workspaceId } = useConnectedWorkspace()\n const { isMember, role } = useCurrentWorkspace()\n const context: ActionContext = {\n workspaceId,\n isMember,\n role,\n isTemporaryAccess: useArbiSession().user?.temporary_access_only === true,\n canCreateProjects: useCanCreateProjects(),\n canCreateWorkspaces: useCanCreateWorkspaces(),\n isFeatureOn: useFeatureCheck(),\n }\n const { ask, search } = useWorkspaceAsk()\n // The skills open their form through the one launcher the `/` menus use, landing in a chat.\n const skillLauncher = useSlashSkillWorkflows({ landing: 'chat' })\n\n useEffect(() => {\n const onKey = (event: KeyboardEvent) => {\n if (!isPaletteShortcut(event)) return\n event.preventDefault()\n usePaletteOpen.setState((open) => !open, true)\n }\n window.addEventListener('keydown', onKey)\n return () => window.removeEventListener('keydown', onKey)\n }, [])\n\n // New text shows its best rows from the top (the browser would keep the old scroll position).\n useLayoutEffect(() => {\n listRef.current?.scrollTo?.({ top: 0 })\n }, [query])\n\n // Closed, it forgets the text: it opens empty, never on the last query's rows.\n useEffect(() => {\n if (!isOpen) setQuery('')\n }, [isOpen])\n\n const catalogue = useMemo(() => {\n const all: Partial<Record<string, ActionDefinition>> = {\n ...createBuiltinActions(environment, session),\n ...actions,\n }\n return Object.values(all).filter((action): action is ActionDefinition => !!action)\n }, [environment, session, actions])\n\n const text = query.trim()\n const pages = navigation.filter((item) => !text || matches(text, item.label, item.keywords))\n const groups = new Map<string, ActionDefinition[]>()\n for (const action of catalogue) {\n if (action.listed === false || (action.available && !action.available(context))) continue\n if (text && !matches(text, action.label, action.category, action.keywords)) continue\n groups.set(action.category, [...(groups.get(action.category) ?? []), action])\n }\n\n // Skills run in the open workspace: none without one. Typed text searches them all; with nothing\n // typed only a few show, the host's packs first, so the actions stay in view.\n const skills = !workspaceId\n ? []\n : text\n ? skillLauncher.openable.filter((w) =>\n matches(text, w.title, w.description, w.id, w.category)\n )\n : [\n ...skillLauncher.openable.filter(isSkillPackWorkflow),\n ...skillLauncher.openable.filter((w) => !isSkillPackWorkflow(w)),\n ].slice(0, EMPTY_QUERY_SKILLS)\n\n const choose = (run: () => void) => {\n setOpen(false)\n run()\n }\n\n return (\n <>\n <Dialog open={isOpen} onOpenChange={setOpen}>\n <DialogContent\n className=\"top-[12%] max-w-2xl translate-y-0 gap-0 overflow-hidden p-0\"\n data-testid=\"command-palette\"\n >\n <DialogTitle className=\"sr-only\">{labels.title}</DialogTitle>\n <DialogDescription className=\"sr-only\">{labels.placeholder}</DialogDescription>\n {/* No vim keys: Ctrl+K in the input closes the palette rather than moving up. */}\n <Command shouldFilter={false} loop vimBindings={false}>\n <CommandInput\n value={query}\n onValueChange={setQuery}\n placeholder={labels.placeholder}\n className=\"h-12 text-base\"\n data-testid=\"command-palette-input\"\n />\n <CommandList ref={listRef} className=\"max-h-[60vh] p-1\">\n <CommandEmpty className=\"py-6 text-center text-sm text-muted-foreground\">\n {labels.empty}\n </CommandEmpty>\n {pages.length > 0 && (\n <CommandGroup heading={labels.pages}>\n {pages.map((item) => (\n <CommandItem\n key={item.id}\n value={`page:${item.id}`}\n onSelect={() =>\n choose(() =>\n onNavigate ? onNavigate(item) : environment.navigate(item.to)\n )\n }\n data-testid={`command-palette-nav-${item.id}`}\n >\n <item.icon className=\"text-muted-foreground\" />\n <span className=\"flex-1\">{item.label}</span>\n <ArrowRight className=\"text-muted-foreground\" />\n </CommandItem>\n ))}\n </CommandGroup>\n )}\n {[...groups].map(([category, rows]) => (\n <CommandGroup key={category} heading={category}>\n {rows.map((action) => {\n const Icon = actionIcon(action.icon)\n return (\n <CommandItem\n key={action.id}\n value={`action:${action.id}`}\n onSelect={() => choose(action.run)}\n data-testid={`command-palette-action-${action.id}`}\n >\n <Icon className=\"text-muted-foreground\" />\n <span>{action.label}</span>\n </CommandItem>\n )\n })}\n </CommandGroup>\n ))}\n {skills.length > 0 && (\n <CommandGroup heading={labels.skills}>\n {skills.map((workflow) => (\n <CommandItem\n key={workflow.id}\n value={`skill:${workflow.id}`}\n onSelect={() => choose(() => skillLauncher.openSkill(workflow.id))}\n data-testid={`command-palette-skill-${workflow.id}`}\n >\n <Wand2 className=\"text-muted-foreground\" />\n <span className=\"flex-1 truncate\">{workflow.title}</span>\n <span className=\"truncate text-xs text-muted-foreground\">/{workflow.id}</span>\n </CommandItem>\n ))}\n </CommandGroup>\n )}\n {text && workspaceId && (\n <CommandGroup>\n <CommandItem\n value=\"ask\"\n onSelect={() => choose(() => ask(text))}\n data-testid=\"command-palette-ask\"\n >\n <Sparkles className=\"text-ai-accent\" />\n <span className=\"truncate\">\n {labels.ask}: \u201C{text}\u201D\n </span>\n </CommandItem>\n <CommandItem\n value=\"search\"\n onSelect={() => choose(() => search(text))}\n data-testid=\"command-palette-search\"\n >\n <Search className=\"text-muted-foreground\" />\n <span className=\"truncate\">\n {labels.search} \u201C{text}\u201D\n </span>\n </CommandItem>\n </CommandGroup>\n )}\n </CommandList>\n </Command>\n </DialogContent>\n </Dialog>\n {/* The skill's form, outside the palette: it stays open once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AS,EAAE;AAAA,kBAEjD;AAAA,wCAAC,SAAM,WAAU,yBAAwB;AAAA,oBACzC,oBAAC,UAAK,WAAU,mBAAmB,mBAAS,OAAM;AAAA,oBAClD,qBAAC,UAAK,WAAU,0CAAyC;AAAA;AAAA,sBAAE,SAAS;AAAA,uBAAG;AAAA;AAAA;AAAA,gBAPlE,SAAS;AAAA,cAQhB,CACD,GACH;AAAA,cAED,QAAQ,eACP,qBAAC,gBACC;AAAA;AAAA,kBAAC;AAAA;AAAA,oBACC,OAAM;AAAA,oBACN,UAAU,MAAM,OAAO,MAAM,IAAI,IAAI,CAAC;AAAA,oBACtC,eAAY;AAAA,oBAEZ;AAAA,0CAAC,YAAS,WAAU,kBAAiB;AAAA,sBACrC,qBAAC,UAAK,WAAU,YACb;AAAA,+BAAO;AAAA,wBAAI;AAAA,wBAAI;AAAA,wBAAK;AAAA,yBACvB;AAAA;AAAA;AAAA,gBACF;AAAA,gBACA;AAAA,kBAAC;AAAA;AAAA,oBACC,OAAM;AAAA,oBACN,UAAU,MAAM,OAAO,MAAM,OAAO,IAAI,CAAC;AAAA,oBACzC,eAAY;AAAA,oBAEZ;AAAA,0CAAC,UAAO,WAAU,yBAAwB;AAAA,sBAC1C,qBAAC,UAAK,WAAU,YACb;AAAA,+BAAO;AAAA,wBAAO;AAAA,wBAAG;AAAA,wBAAK;AAAA,yBACzB;AAAA;AAAA;AAAA,gBACF;AAAA,iBACF;AAAA,eAEJ;AAAA,aACF;AAAA;AAAA;AAAA,IACF,GACF;AAAA,IAEC,cAAc;AAAA,KACjB;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -50,7 +50,7 @@ function createBuiltinActions(environment, session) {
50
50
  category: "Workspace",
51
51
  icon: "Plus",
52
52
  keywords: ["new workspace", "add workspace"],
53
- available: ({ canCreateProjects }) => canCreateProjects !== false,
53
+ available: ({ canCreateProjects, canCreateWorkspaces }) => (canCreateWorkspaces ?? canCreateProjects) !== false,
54
54
  run: () => openDialog("createWorkspace")
55
55
  },
56
56
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/connection/command/actions.ts"],
4
- "sourcesContent": ["/**\n * The built-in action catalogue: the parameter-light things a user can do from anywhere on any\n * host (open a dialog, create something, switch the Files view, open settings, get help). Each\n * `run` goes through the host's environment intents and the session store, never an app path, so\n * the catalogue works outside React too (a tip's CTA, a validated remote dispatch).\n *\n * A host adds its own actions beside these (its pages, its panels) and may replace one by giving\n * an action with the same id. `ConnectedCommandPalette` builds this catalogue from the host in\n * scope; code outside React builds it with the host's environment and session store.\n */\nimport { setWorkOfflineIn, type ArbiSessionStore } from '@arbidocs/react'\nimport { useNotify } from '@arbidocs/react/shell'\nimport { openWorkflowLaunch } from '../../agents/workflows/launchRequest'\nimport type { ActionContext, ActionDefinition } from '../../nav/actions'\nimport type { BlocksEnvironment } from '../../provider/environment'\nimport { startWelcomeReplay } from '../../tips/visibility'\nimport { useAiReviewStore, useFilesDialogs, useFilesPrefs } from '../files/store'\n\nexport type BuiltinActionId =\n | 'goto-user-settings'\n | 'open-analytics'\n | 'create-workspace'\n | 'upload-documents'\n | 'view-processing-status'\n | 'transfer-workspace'\n | 'export-documents'\n | 'bulk-tag-documents'\n | 'move-to-folder'\n | 'ai-review-documents'\n | 'docs-grid-view'\n | 'docs-navigator-view'\n | 'docs-explorer-view'\n | 'show-uploaded-docs'\n | 'show-generated-docs'\n | 'clear-document-selection'\n | 'summarise-document'\n | 'translate-document'\n | 'attach-context'\n | 'conversation-settings'\n | 'open-skills-library'\n | 'clear-conversation-context'\n | 'open-invite-contacts'\n | 'open-projects'\n | 'open-user-settings'\n | 'view-pro-features'\n | 'logout'\n | 'start-welcome-tour'\n | 'mute-notifications'\n | 'work-offline'\n\ntype Session = Pick<\n ArbiSessionStore,\n 'getState' | 'setConversationDocuments' | 'setSelectedDocumentIds' | 'setTransientView'\n>\n\nconst inWorkspace = ({ workspaceId }: ActionContext) => !!workspaceId\n/** Upload's gate in Files and the conversation: a member who is not a guest. */\nconst canWrite = ({ isMember, role }: ActionContext) => isMember && role !== 'guest'\n/** Plan & Usage, Pro and the welcome journey are not offered to temporary-access accounts. */\nconst notTemporary = ({ isTemporaryAccess }: ActionContext) => !isTemporaryAccess\n\n/** Flip the Files \"Source\" quick filter to only uploaded or only generated documents. */\nfunction setDocumentSourceFilter(source: 'uploaded' | 'generated'): void {\n const { documentFilters, setDocumentFilters } = useFilesPrefs.getState()\n setDocumentFilters({\n ...documentFilters,\n source_uploaded: source === 'uploaded' ? 'include' : null,\n source_generated: source === 'generated' ? 'include' : null,\n })\n}\n\n/**\n * The built-in catalogue on a host's environment and session store. An action whose intent the\n * host does not offer (`openProcessing`) is left out.\n */\nexport function createBuiltinActions(\n environment: BlocksEnvironment,\n session: Session\n): Partial<Record<BuiltinActionId, ActionDefinition<BuiltinActionId>>> {\n const { openDialog, openSettings, openProcessing, openAnalytics } = environment\n /** Start a workflow on the document in view, else the selected ones (its form asks if none). */\n const startWorkflowOnDocuments = (workflowId: string) => {\n const { viewingDocument, selectedDocumentIds } = session.getState()\n const documents = viewingDocument ? [viewingDocument.id] : [...selectedDocumentIds]\n openWorkflowLaunch({ workflowId, context: { documents } })\n }\n const setFilesView = (mode: 'grid' | 'navigator' | 'explorer') => () =>\n useFilesPrefs.getState().setViewMode(mode)\n\n const actions: Array<ActionDefinition<BuiltinActionId> | false | undefined> = [\n {\n id: 'goto-user-settings',\n label: 'Go to Account settings',\n category: 'Navigate',\n icon: 'UserCog',\n keywords: ['profile', 'preferences', 'account'],\n // The same as `open-user-settings`: dispatch only.\n listed: false,\n run: () => openSettings(),\n },\n // Analytics is the person's own (not a workspace's): offered wherever the host has it.\n !!openAnalytics && {\n id: 'open-analytics',\n label: 'Open Analytics',\n category: 'Navigate',\n icon: 'ChartColumn',\n keywords: ['dashboards', 'charts', 'usage', 'reports'],\n available: ({ isFeatureOn }) => isFeatureOn('dashboards'),\n run: () => openAnalytics(),\n },\n {\n id: 'create-workspace',\n label: 'Create a workspace',\n category: 'Workspace',\n icon: 'Plus',\n keywords: ['new workspace', 'add workspace'],\n available: ({ canCreateProjects }) => canCreateProjects !== false,\n run: () => openDialog('createWorkspace'),\n },\n {\n id: 'upload-documents',\n label: 'Upload documents',\n category: 'Workspace',\n icon: 'Upload',\n keywords: ['add files', 'import', 'attach files'],\n available: canWrite,\n run: () => openDialog('upload'),\n },\n !!openProcessing && {\n id: 'view-processing-status',\n label: 'View processing status',\n category: 'Workspace',\n icon: 'ClipboardList',\n keywords: ['indexing', 'progress', 'jobs', 'tasks'],\n available: inWorkspace,\n run: () => openProcessing(),\n },\n {\n id: 'transfer-workspace',\n label: 'Export, copy or move workspace',\n category: 'Workspace',\n icon: 'FolderInput',\n keywords: ['export', 'download', 'copy', 'move', 'backup', 'transfer', 'zip'],\n available: ({ isMember }) => isMember,\n run: () => openDialog('transfer'),\n },\n {\n id: 'export-documents',\n label: 'Export documents',\n category: 'Documents',\n icon: 'Files',\n keywords: ['download', 'csv', 'excel'],\n available: inWorkspace,\n run: () => useFilesDialogs.getState().setExportOpen(true),\n },\n {\n id: 'bulk-tag-documents',\n label: 'Tag selected documents',\n category: 'Documents',\n icon: 'Tags',\n keywords: ['labels', 'categorize', 'bulk tag'],\n available: inWorkspace,\n run: () => useFilesDialogs.getState().setBulkTagsOpen(true),\n },\n {\n id: 'move-to-folder',\n label: 'Move documents to folder',\n category: 'Documents',\n icon: 'FolderInput',\n keywords: ['organize', 'relocate'],\n available: inWorkspace,\n run: () => useFilesDialogs.getState().openMove(),\n },\n {\n id: 'ai-review-documents',\n label: 'AI review documents',\n category: 'Documents',\n icon: 'Sparkles',\n keywords: ['auto tag', 'analyze', 'suggest tags'],\n available: inWorkspace,\n run: () => useAiReviewStore.getState().setOpen(true),\n },\n {\n id: 'docs-grid-view',\n label: 'Switch to grid view',\n category: 'Documents',\n icon: 'LayoutGrid',\n keywords: ['table', 'spreadsheet'],\n available: inWorkspace,\n run: setFilesView('grid'),\n },\n {\n id: 'docs-navigator-view',\n label: 'Switch to navigator view',\n category: 'Documents',\n icon: 'FolderTree',\n keywords: ['folders', 'tree'],\n available: inWorkspace,\n run: setFilesView('navigator'),\n },\n {\n id: 'docs-explorer-view',\n label: 'Switch to explorer view',\n category: 'Documents',\n icon: 'Compass',\n keywords: ['browse', 'gallery'],\n available: inWorkspace,\n run: setFilesView('explorer'),\n },\n {\n id: 'show-uploaded-docs',\n label: 'Show uploaded documents',\n category: 'Documents',\n icon: 'Upload',\n keywords: ['filter', 'source', 'originals'],\n available: inWorkspace,\n run: () => setDocumentSourceFilter('uploaded'),\n },\n {\n id: 'show-generated-docs',\n label: 'Show AI-generated documents',\n category: 'Documents',\n icon: 'Sparkles',\n keywords: ['filter', 'source', 'artifacts'],\n available: inWorkspace,\n run: () => setDocumentSourceFilter('generated'),\n },\n {\n id: 'clear-document-selection',\n label: 'Clear document selection',\n category: 'Documents',\n icon: 'SquareDashedMousePointer',\n keywords: ['deselect', 'unselect'],\n available: inWorkspace,\n run: () => session.setSelectedDocumentIds([]),\n },\n {\n id: 'summarise-document',\n label: 'Summarise a document',\n category: 'Documents',\n icon: 'FileText',\n keywords: ['summary', 'brief', 'overview'],\n available: inWorkspace,\n run: () => startWorkflowOnDocuments('summarise'),\n },\n {\n id: 'translate-document',\n label: 'Translate a document',\n category: 'Documents',\n icon: 'Sparkles',\n keywords: ['translation', 'language'],\n available: inWorkspace,\n run: () => startWorkflowOnDocuments('translate'),\n },\n {\n id: 'attach-context',\n label: 'Attach documents to conversation',\n category: 'Conversation',\n icon: 'Paperclip',\n keywords: ['context', 'add documents', 'reference'],\n available: inWorkspace,\n run: () => openDialog('conversationDocuments'),\n },\n {\n id: 'conversation-settings',\n label: 'Open conversation settings',\n category: 'Conversation',\n icon: 'Settings2',\n keywords: ['model', 'config', 'options'],\n run: () => openDialog('conversationSettings'),\n },\n {\n id: 'open-skills-library',\n label: 'Browse skills',\n category: 'Conversation',\n icon: 'Library',\n keywords: ['skills', 'start', 'summarise', 'translate', 'commands'],\n available: ({ isFeatureOn }) => isFeatureOn('skills'),\n run: () => openDialog('skillsBrowser'),\n },\n {\n id: 'clear-conversation-context',\n label: 'Clear attached documents',\n category: 'Conversation',\n icon: 'Eraser',\n keywords: ['remove context', 'detach', 'reset'],\n available: inWorkspace,\n // Each conversation's documents, cleared by choice: an empty chat does not pick them up again.\n run: () =>\n Object.keys(session.getState().conversationDocuments).forEach((id) =>\n session.setConversationDocuments(id, [])\n ),\n },\n {\n id: 'open-invite-contacts',\n label: 'Invite contacts',\n category: 'Sharing',\n icon: 'UserPlus',\n keywords: ['add people', 'invite', 'share'],\n run: () => openDialog('inviteContacts'),\n },\n {\n id: 'open-projects',\n label: 'Open projects',\n category: 'Account',\n icon: 'FolderKanban',\n keywords: ['plans', 'billing groups', 'projects'],\n available: notTemporary,\n run: () => environment.openProject(),\n },\n {\n id: 'open-user-settings',\n label: 'Open account settings',\n category: 'Account',\n icon: 'UserCog',\n keywords: ['profile', 'preferences', 'account'],\n run: () => openSettings(),\n },\n {\n id: 'view-pro-features',\n label: 'See Pro features',\n category: 'Account',\n icon: 'Crown',\n keywords: ['upgrade', 'premium', 'subscription'],\n available: notTemporary,\n run: () => openDialog('welcome'),\n },\n {\n id: 'logout',\n label: 'Log out',\n category: 'Account',\n icon: 'LogOut',\n keywords: ['sign out', 'exit'],\n run: () => openDialog('logout'),\n },\n {\n id: 'start-welcome-tour',\n label: 'Start the getting-started tour',\n category: 'Help',\n icon: 'Compass',\n keywords: ['onboarding', 'walkthrough', 'tutorial'],\n available: (context) => notTemporary(context) && context.isFeatureOn('welcomeJourney'),\n // The getting-started checklist, fresh, with the helper header on for the session.\n run: () => startWelcomeReplay(session),\n },\n {\n id: 'mute-notifications',\n label: 'Mute notifications',\n category: 'Help',\n icon: 'BellOff',\n keywords: ['silence', 'do not disturb', 'quiet'],\n run: () => useNotify.getState().setMuted(true),\n },\n {\n id: 'work-offline',\n label: 'Work offline',\n category: 'Help',\n icon: 'WifiOff',\n keywords: ['offline mode', 'disconnect'],\n run: () => setWorkOfflineIn(session, true),\n },\n ]\n return Object.fromEntries(\n actions\n .filter((action): action is ActionDefinition<BuiltinActionId> => !!action)\n .map((action) => [action.id, action])\n )\n}\n"],
5
- "mappings": ";AAUA,SAAS,wBAA+C;AACxD,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AAGnC,SAAS,0BAA0B;AACnC,SAAS,kBAAkB,iBAAiB,qBAAqB;AAuCjE,MAAM,cAAc,CAAC,EAAE,YAAY,MAAqB,CAAC,CAAC;AAE1D,MAAM,WAAW,CAAC,EAAE,UAAU,KAAK,MAAqB,YAAY,SAAS;AAE7E,MAAM,eAAe,CAAC,EAAE,kBAAkB,MAAqB,CAAC;AAGhE,SAAS,wBAAwB,QAAwC;AACvE,QAAM,EAAE,iBAAiB,mBAAmB,IAAI,cAAc,SAAS;AACvE,qBAAmB;AAAA,IACjB,GAAG;AAAA,IACH,iBAAiB,WAAW,aAAa,YAAY;AAAA,IACrD,kBAAkB,WAAW,cAAc,YAAY;AAAA,EACzD,CAAC;AACH;AAMO,SAAS,qBACd,aACA,SACqE;AACrE,QAAM,EAAE,YAAY,cAAc,gBAAgB,cAAc,IAAI;AAEpE,QAAM,2BAA2B,CAAC,eAAuB;AACvD,UAAM,EAAE,iBAAiB,oBAAoB,IAAI,QAAQ,SAAS;AAClE,UAAM,YAAY,kBAAkB,CAAC,gBAAgB,EAAE,IAAI,CAAC,GAAG,mBAAmB;AAClF,uBAAmB,EAAE,YAAY,SAAS,EAAE,UAAU,EAAE,CAAC;AAAA,EAC3D;AACA,QAAM,eAAe,CAAC,SAA4C,MAChE,cAAc,SAAS,EAAE,YAAY,IAAI;AAE3C,QAAM,UAAwE;AAAA,IAC5E;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,UAAU,CAAC,WAAW,eAAe,SAAS;AAAA;AAAA,MAE9C,QAAQ;AAAA,MACR,KAAK,MAA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A,MACN,UAAU,CAAC,WAAW,WAAW,cAAc;AAAA,MAC/C,WAAW;AAAA,MACX,KAAK,MAAM,WAAW,SAAS;AAAA,IACjC;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,UAAU,CAAC,YAAY,MAAM;AAAA,MAC7B,KAAK,MAAM,WAAW,QAAQ;AAAA,IAChC;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,UAAU,CAAC,cAAc,eAAe,UAAU;AAAA,MAClD,WAAW,CAAC,YAAY,aAAa,OAAO,KAAK,QAAQ,YAAY,gBAAgB;AAAA;AAAA,MAErF,KAAK,MAAM,mBAAmB,OAAO;AAAA,IACvC;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,UAAU,CAAC,WAAW,kBAAkB,OAAO;AAAA,MAC/C,KAAK,MAAM,UAAU,SAAS,EAAE,SAAS,IAAI;AAAA,IAC/C;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,UAAU,CAAC,gBAAgB,YAAY;AAAA,MACvC,KAAK,MAAM,iBAAiB,SAAS,IAAI;AAAA,IAC3C;AAAA,EACF;AACA,SAAO,OAAO;AAAA,IACZ,QACG,OAAO,CAAC,WAAwD,CAAC,CAAC,MAAM,EACxE,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,MAAM,CAAC;AAAA,EACxC;AACF;",
4
+ "sourcesContent": ["/**\n * The built-in action catalogue: the parameter-light things a user can do from anywhere on any\n * host (open a dialog, create something, switch the Files view, open settings, get help). Each\n * `run` goes through the host's environment intents and the session store, never an app path, so\n * the catalogue works outside React too (a tip's CTA, a validated remote dispatch).\n *\n * A host adds its own actions beside these (its pages, its panels) and may replace one by giving\n * an action with the same id. `ConnectedCommandPalette` builds this catalogue from the host in\n * scope; code outside React builds it with the host's environment and session store.\n */\nimport { setWorkOfflineIn, type ArbiSessionStore } from '@arbidocs/react'\nimport { useNotify } from '@arbidocs/react/shell'\nimport { openWorkflowLaunch } from '../../agents/workflows/launchRequest'\nimport type { ActionContext, ActionDefinition } from '../../nav/actions'\nimport type { BlocksEnvironment } from '../../provider/environment'\nimport { startWelcomeReplay } from '../../tips/visibility'\nimport { useAiReviewStore, useFilesDialogs, useFilesPrefs } from '../files/store'\n\nexport type BuiltinActionId =\n | 'goto-user-settings'\n | 'open-analytics'\n | 'create-workspace'\n | 'upload-documents'\n | 'view-processing-status'\n | 'transfer-workspace'\n | 'export-documents'\n | 'bulk-tag-documents'\n | 'move-to-folder'\n | 'ai-review-documents'\n | 'docs-grid-view'\n | 'docs-navigator-view'\n | 'docs-explorer-view'\n | 'show-uploaded-docs'\n | 'show-generated-docs'\n | 'clear-document-selection'\n | 'summarise-document'\n | 'translate-document'\n | 'attach-context'\n | 'conversation-settings'\n | 'open-skills-library'\n | 'clear-conversation-context'\n | 'open-invite-contacts'\n | 'open-projects'\n | 'open-user-settings'\n | 'view-pro-features'\n | 'logout'\n | 'start-welcome-tour'\n | 'mute-notifications'\n | 'work-offline'\n\ntype Session = Pick<\n ArbiSessionStore,\n 'getState' | 'setConversationDocuments' | 'setSelectedDocumentIds' | 'setTransientView'\n>\n\nconst inWorkspace = ({ workspaceId }: ActionContext) => !!workspaceId\n/** Upload's gate in Files and the conversation: a member who is not a guest. */\nconst canWrite = ({ isMember, role }: ActionContext) => isMember && role !== 'guest'\n/** Plan & Usage, Pro and the welcome journey are not offered to temporary-access accounts. */\nconst notTemporary = ({ isTemporaryAccess }: ActionContext) => !isTemporaryAccess\n\n/** Flip the Files \"Source\" quick filter to only uploaded or only generated documents. */\nfunction setDocumentSourceFilter(source: 'uploaded' | 'generated'): void {\n const { documentFilters, setDocumentFilters } = useFilesPrefs.getState()\n setDocumentFilters({\n ...documentFilters,\n source_uploaded: source === 'uploaded' ? 'include' : null,\n source_generated: source === 'generated' ? 'include' : null,\n })\n}\n\n/**\n * The built-in catalogue on a host's environment and session store. An action whose intent the\n * host does not offer (`openProcessing`) is left out.\n */\nexport function createBuiltinActions(\n environment: BlocksEnvironment,\n session: Session\n): Partial<Record<BuiltinActionId, ActionDefinition<BuiltinActionId>>> {\n const { openDialog, openSettings, openProcessing, openAnalytics } = environment\n /** Start a workflow on the document in view, else the selected ones (its form asks if none). */\n const startWorkflowOnDocuments = (workflowId: string) => {\n const { viewingDocument, selectedDocumentIds } = session.getState()\n const documents = viewingDocument ? [viewingDocument.id] : [...selectedDocumentIds]\n openWorkflowLaunch({ workflowId, context: { documents } })\n }\n const setFilesView = (mode: 'grid' | 'navigator' | 'explorer') => () =>\n useFilesPrefs.getState().setViewMode(mode)\n\n const actions: Array<ActionDefinition<BuiltinActionId> | false | undefined> = [\n {\n id: 'goto-user-settings',\n label: 'Go to Account settings',\n category: 'Navigate',\n icon: 'UserCog',\n keywords: ['profile', 'preferences', 'account'],\n // The same as `open-user-settings`: dispatch only.\n listed: false,\n run: () => openSettings(),\n },\n // Analytics is the person's own (not a workspace's): offered wherever the host has it.\n !!openAnalytics && {\n id: 'open-analytics',\n label: 'Open Analytics',\n category: 'Navigate',\n icon: 'ChartColumn',\n keywords: ['dashboards', 'charts', 'usage', 'reports'],\n available: ({ isFeatureOn }) => isFeatureOn('dashboards'),\n run: () => openAnalytics(),\n },\n {\n id: 'create-workspace',\n label: 'Create a workspace',\n category: 'Workspace',\n icon: 'Plus',\n keywords: ['new workspace', 'add workspace'],\n available: ({ canCreateProjects, canCreateWorkspaces }) =>\n (canCreateWorkspaces ?? canCreateProjects) !== false,\n run: () => openDialog('createWorkspace'),\n },\n {\n id: 'upload-documents',\n label: 'Upload documents',\n category: 'Workspace',\n icon: 'Upload',\n keywords: ['add files', 'import', 'attach files'],\n available: canWrite,\n run: () => openDialog('upload'),\n },\n !!openProcessing && {\n id: 'view-processing-status',\n label: 'View processing status',\n category: 'Workspace',\n icon: 'ClipboardList',\n keywords: ['indexing', 'progress', 'jobs', 'tasks'],\n available: inWorkspace,\n run: () => openProcessing(),\n },\n {\n id: 'transfer-workspace',\n label: 'Export, copy or move workspace',\n category: 'Workspace',\n icon: 'FolderInput',\n keywords: ['export', 'download', 'copy', 'move', 'backup', 'transfer', 'zip'],\n available: ({ isMember }) => isMember,\n run: () => openDialog('transfer'),\n },\n {\n id: 'export-documents',\n label: 'Export documents',\n category: 'Documents',\n icon: 'Files',\n keywords: ['download', 'csv', 'excel'],\n available: inWorkspace,\n run: () => useFilesDialogs.getState().setExportOpen(true),\n },\n {\n id: 'bulk-tag-documents',\n label: 'Tag selected documents',\n category: 'Documents',\n icon: 'Tags',\n keywords: ['labels', 'categorize', 'bulk tag'],\n available: inWorkspace,\n run: () => useFilesDialogs.getState().setBulkTagsOpen(true),\n },\n {\n id: 'move-to-folder',\n label: 'Move documents to folder',\n category: 'Documents',\n icon: 'FolderInput',\n keywords: ['organize', 'relocate'],\n available: inWorkspace,\n run: () => useFilesDialogs.getState().openMove(),\n },\n {\n id: 'ai-review-documents',\n label: 'AI review documents',\n category: 'Documents',\n icon: 'Sparkles',\n keywords: ['auto tag', 'analyze', 'suggest tags'],\n available: inWorkspace,\n run: () => useAiReviewStore.getState().setOpen(true),\n },\n {\n id: 'docs-grid-view',\n label: 'Switch to grid view',\n category: 'Documents',\n icon: 'LayoutGrid',\n keywords: ['table', 'spreadsheet'],\n available: inWorkspace,\n run: setFilesView('grid'),\n },\n {\n id: 'docs-navigator-view',\n label: 'Switch to navigator view',\n category: 'Documents',\n icon: 'FolderTree',\n keywords: ['folders', 'tree'],\n available: inWorkspace,\n run: setFilesView('navigator'),\n },\n {\n id: 'docs-explorer-view',\n label: 'Switch to explorer view',\n category: 'Documents',\n icon: 'Compass',\n keywords: ['browse', 'gallery'],\n available: inWorkspace,\n run: setFilesView('explorer'),\n },\n {\n id: 'show-uploaded-docs',\n label: 'Show uploaded documents',\n category: 'Documents',\n icon: 'Upload',\n keywords: ['filter', 'source', 'originals'],\n available: inWorkspace,\n run: () => setDocumentSourceFilter('uploaded'),\n },\n {\n id: 'show-generated-docs',\n label: 'Show AI-generated documents',\n category: 'Documents',\n icon: 'Sparkles',\n keywords: ['filter', 'source', 'artifacts'],\n available: inWorkspace,\n run: () => setDocumentSourceFilter('generated'),\n },\n {\n id: 'clear-document-selection',\n label: 'Clear document selection',\n category: 'Documents',\n icon: 'SquareDashedMousePointer',\n keywords: ['deselect', 'unselect'],\n available: inWorkspace,\n run: () => session.setSelectedDocumentIds([]),\n },\n {\n id: 'summarise-document',\n label: 'Summarise a document',\n category: 'Documents',\n icon: 'FileText',\n keywords: ['summary', 'brief', 'overview'],\n available: inWorkspace,\n run: () => startWorkflowOnDocuments('summarise'),\n },\n {\n id: 'translate-document',\n label: 'Translate a document',\n category: 'Documents',\n icon: 'Sparkles',\n keywords: ['translation', 'language'],\n available: inWorkspace,\n run: () => startWorkflowOnDocuments('translate'),\n },\n {\n id: 'attach-context',\n label: 'Attach documents to conversation',\n category: 'Conversation',\n icon: 'Paperclip',\n keywords: ['context', 'add documents', 'reference'],\n available: inWorkspace,\n run: () => openDialog('conversationDocuments'),\n },\n {\n id: 'conversation-settings',\n label: 'Open conversation settings',\n category: 'Conversation',\n icon: 'Settings2',\n keywords: ['model', 'config', 'options'],\n run: () => openDialog('conversationSettings'),\n },\n {\n id: 'open-skills-library',\n label: 'Browse skills',\n category: 'Conversation',\n icon: 'Library',\n keywords: ['skills', 'start', 'summarise', 'translate', 'commands'],\n available: ({ isFeatureOn }) => isFeatureOn('skills'),\n run: () => openDialog('skillsBrowser'),\n },\n {\n id: 'clear-conversation-context',\n label: 'Clear attached documents',\n category: 'Conversation',\n icon: 'Eraser',\n keywords: ['remove context', 'detach', 'reset'],\n available: inWorkspace,\n // Each conversation's documents, cleared by choice: an empty chat does not pick them up again.\n run: () =>\n Object.keys(session.getState().conversationDocuments).forEach((id) =>\n session.setConversationDocuments(id, [])\n ),\n },\n {\n id: 'open-invite-contacts',\n label: 'Invite contacts',\n category: 'Sharing',\n icon: 'UserPlus',\n keywords: ['add people', 'invite', 'share'],\n run: () => openDialog('inviteContacts'),\n },\n {\n id: 'open-projects',\n label: 'Open projects',\n category: 'Account',\n icon: 'FolderKanban',\n keywords: ['plans', 'billing groups', 'projects'],\n available: notTemporary,\n run: () => environment.openProject(),\n },\n {\n id: 'open-user-settings',\n label: 'Open account settings',\n category: 'Account',\n icon: 'UserCog',\n keywords: ['profile', 'preferences', 'account'],\n run: () => openSettings(),\n },\n {\n id: 'view-pro-features',\n label: 'See Pro features',\n category: 'Account',\n icon: 'Crown',\n keywords: ['upgrade', 'premium', 'subscription'],\n available: notTemporary,\n run: () => openDialog('welcome'),\n },\n {\n id: 'logout',\n label: 'Log out',\n category: 'Account',\n icon: 'LogOut',\n keywords: ['sign out', 'exit'],\n run: () => openDialog('logout'),\n },\n {\n id: 'start-welcome-tour',\n label: 'Start the getting-started tour',\n category: 'Help',\n icon: 'Compass',\n keywords: ['onboarding', 'walkthrough', 'tutorial'],\n available: (context) => notTemporary(context) && context.isFeatureOn('welcomeJourney'),\n // The getting-started checklist, fresh, with the helper header on for the session.\n run: () => startWelcomeReplay(session),\n },\n {\n id: 'mute-notifications',\n label: 'Mute notifications',\n category: 'Help',\n icon: 'BellOff',\n keywords: ['silence', 'do not disturb', 'quiet'],\n run: () => useNotify.getState().setMuted(true),\n },\n {\n id: 'work-offline',\n label: 'Work offline',\n category: 'Help',\n icon: 'WifiOff',\n keywords: ['offline mode', 'disconnect'],\n run: () => setWorkOfflineIn(session, true),\n },\n ]\n return Object.fromEntries(\n actions\n .filter((action): action is ActionDefinition<BuiltinActionId> => !!action)\n .map((action) => [action.id, action])\n )\n}\n"],
5
+ "mappings": ";AAUA,SAAS,wBAA+C;AACxD,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AAGnC,SAAS,0BAA0B;AACnC,SAAS,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MAAM,WAAW,QAAQ;AAAA,IAChC;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,UAAU,CAAC,cAAc,eAAe,UAAU;AAAA,MAClD,WAAW,CAAC,YAAY,aAAa,OAAO,KAAK,QAAQ,YAAY,gBAAgB;AAAA;AAAA,MAErF,KAAK,MAAM,mBAAmB,OAAO;AAAA,IACvC;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,UAAU,CAAC,WAAW,kBAAkB,OAAO;AAAA,MAC/C,KAAK,MAAM,UAAU,SAAS,EAAE,SAAS,IAAI;AAAA,IAC/C;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,UAAU,CAAC,gBAAgB,YAAY;AAAA,MACvC,KAAK,MAAM,iBAAiB,SAAS,IAAI;AAAA,IAC3C;AAAA,EACF;AACA,SAAO,OAAO;AAAA,IACZ,QACG,OAAO,CAAC,WAAwD,CAAC,CAAC,MAAM,EACxE,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,MAAM,CAAC;AAAA,EACxC;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,9 +1,15 @@
1
+ import { type AddContactsLabels } from '../../collaboration/contacts/AddContactsParts';
1
2
  export interface ConnectedAddContactsProps {
2
3
  /** After a submit (also when nothing needed sending). */
3
4
  onSuccess?: () => void;
4
5
  onClose?: () => void;
6
+ /** Results completed; defaults to closing the form. */
7
+ onDone?: () => void;
5
8
  initialEmail?: string;
6
9
  /** Formatted referral reward ("£20"); omit to hide the banner. */
7
10
  rewardAmount?: string;
11
+ /** Keep the input available after submitting, with failures shown inline. */
12
+ keepFormOpen?: boolean;
13
+ labels?: Partial<AddContactsLabels>;
8
14
  }
9
- export declare function ConnectedAddContacts({ onSuccess, onClose, initialEmail, rewardAmount, }: ConnectedAddContactsProps): import("react").JSX.Element;
15
+ export declare function ConnectedAddContacts({ onSuccess, onClose, onDone, initialEmail, rewardAmount, keepFormOpen, labels, }: ConnectedAddContactsProps): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useArbi, useContacts, useInviteContacts } from "@arbidocs/react";
4
4
  import { refusalReason } from "@arbidocs/sdk/browser";
5
5
  import { useState } from "react";
@@ -20,8 +20,11 @@ import {
20
20
  function ConnectedAddContacts({
21
21
  onSuccess,
22
22
  onClose,
23
+ onDone,
23
24
  initialEmail = "",
24
- rewardAmount
25
+ rewardAmount,
26
+ keepFormOpen = false,
27
+ labels
25
28
  }) {
26
29
  const { notify } = useBlocksEnvironment();
27
30
  const arbi = useArbi();
@@ -48,7 +51,12 @@ function ConnectedAddContacts({
48
51
  }
49
52
  try {
50
53
  const response = await invite.mutateAsync(plan.send);
51
- setRows(applyContactInviteResults(plan, response));
54
+ const results = applyContactInviteResults(plan, response);
55
+ setRows(results);
56
+ if (keepFormOpen)
57
+ setText(
58
+ results.filter((row) => row.status === "failed").map((row) => row.email).join(", ")
59
+ );
52
60
  const summary = summarizeContactInvites(response);
53
61
  notify(summary.message, summary.failed ? "error" : "success");
54
62
  onSuccess?.();
@@ -58,30 +66,38 @@ function ConnectedAddContacts({
58
66
  notify(message, "error");
59
67
  }
60
68
  };
61
- if (rows)
69
+ if (rows && !keepFormOpen)
62
70
  return /* @__PURE__ */ jsx(
63
71
  AddContactsResults,
64
72
  {
65
73
  rows,
66
- onDone: onClose,
74
+ onDone: onDone ?? onClose,
67
75
  onAddMore: () => {
68
76
  setText("");
69
77
  setRows(null);
70
78
  }
71
79
  }
72
80
  );
73
- return /* @__PURE__ */ jsx(
74
- AddContactsForm,
75
- {
76
- value: text,
77
- onChange: setText,
78
- emailCount: emailTokens(text).length,
79
- isPending: invite.isPending,
80
- onSubmit: () => void submit(),
81
- onCancel: onClose,
82
- rewardAmount
83
- }
84
- );
81
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
82
+ /* @__PURE__ */ jsx(
83
+ AddContactsForm,
84
+ {
85
+ value: text,
86
+ onChange: setText,
87
+ emailCount: emailTokens(text).length,
88
+ isPending: invite.isPending,
89
+ onSubmit: () => void submit(),
90
+ onCancel: onClose,
91
+ rewardAmount,
92
+ labels
93
+ }
94
+ ),
95
+ keepFormOpen && rows?.some((row) => row.status === "failed") && /* @__PURE__ */ jsx("ul", { role: "alert", className: "text-sm text-destructive", children: rows.filter((row) => row.status === "failed").map((row) => /* @__PURE__ */ jsxs("li", { children: [
96
+ row.email,
97
+ ": ",
98
+ row.message
99
+ ] }, row.email)) })
100
+ ] });
85
101
  }
86
102
  export {
87
103
  ConnectedAddContacts
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/connection/contacts/ConnectedAddContacts.tsx"],
4
- "sourcesContent": ["/**\n * Add contacts by e-mail (`@arbidocs/blocks/connect`): one or many addresses typed or pasted, then a row per\n * address with what happened. Bad addresses and your own are left out, people already in your contacts are\n * not sent again (an expired invitation is), and the server's outcome is shown for the rest.\n */\nimport { useArbi, useContacts, useInviteContacts } from '@arbidocs/react'\nimport { refusalReason } from '@arbidocs/sdk/browser'\nimport { useState } from 'react'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport {\n AddContactsForm,\n AddContactsResults,\n type AddContactsResultRow,\n} from '../../collaboration/contacts/AddContactsParts'\nimport { MAX_INVITE_EMAILS } from '../../collaboration/contacts/parseEmails'\nimport {\n applyContactInviteResults,\n emailTokens,\n failContactInvites,\n planContactInvites,\n summarizeContactInvites,\n summarizeUnsentInvites,\n} from '../../collaboration/contacts/invite-plan'\n\nexport interface ConnectedAddContactsProps {\n /** After a submit (also when nothing needed sending). */\n onSuccess?: () => void\n onClose?: () => void\n initialEmail?: string\n /** Formatted referral reward (\"\u00A320\"); omit to hide the banner. */\n rewardAmount?: string\n}\n\nexport function ConnectedAddContacts({\n onSuccess,\n onClose,\n initialEmail = '',\n rewardAmount,\n}: ConnectedAddContactsProps) {\n const { notify } = useBlocksEnvironment()\n const arbi = useArbi()\n const { data: contacts = [] } = useContacts()\n const invite = useInviteContacts()\n const [text, setText] = useState(initialEmail)\n const [rows, setRows] = useState<AddContactsResultRow[] | null>(null)\n const selfEmail = arbi.isLoggedIn ? arbi.user.identity()?.email : null\n\n const submit = async () => {\n if (!emailTokens(text).length) {\n notify('Please enter at least one email address', 'error')\n return\n }\n const plan = planContactInvites(text, contacts, selfEmail)\n if (plan.send.length > MAX_INVITE_EMAILS) {\n notify(`Maximum ${MAX_INVITE_EMAILS} new emails allowed per batch`, 'error')\n return\n }\n setRows(plan.rows)\n if (!plan.send.length) {\n notify(summarizeUnsentInvites(plan.rows), 'info')\n onSuccess?.()\n return\n }\n try {\n const response = await invite.mutateAsync(plan.send)\n setRows(applyContactInviteResults(plan, response))\n const summary = summarizeContactInvites(response)\n notify(summary.message, summary.failed ? 'error' : 'success')\n onSuccess?.()\n } catch (error) {\n const message = refusalReason(error, 'Failed to add contacts')\n setRows(failContactInvites(plan, message))\n notify(message, 'error')\n }\n }\n\n if (rows)\n return (\n <AddContactsResults\n rows={rows}\n onDone={onClose}\n onAddMore={() => {\n setText('')\n setRows(null)\n }}\n />\n )\n\n return (\n <AddContactsForm\n value={text}\n onChange={setText}\n emailCount={emailTokens(text).length}\n isPending={invite.isPending}\n onSubmit={() => void submit()}\n onCancel={onClose}\n rewardAmount={rewardAmount}\n />\n )\n}\n"],
5
- "mappings": ";AA8EM;AAzEN,SAAS,SAAS,aAAa,yBAAyB;AACxD,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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M;AACf,kBAAQ,EAAE;AACV,kBAAQ,IAAI;AAAA,QACd;AAAA;AAAA,IACF;AAGJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP,UAAU;AAAA,MACV,YAAY,YAAY,IAAI,EAAE;AAAA,MAC9B,WAAW,OAAO;AAAA,MAClB,UAAU,MAAM,KAAK,OAAO;AAAA,MAC5B,UAAU;AAAA,MACV;AAAA;AAAA,EACF;AAEJ;",
4
+ "sourcesContent": ["/**\n * Add contacts by e-mail (`@arbidocs/blocks/connect`): one or many addresses typed or pasted, then a row per\n * address with what happened. Bad addresses and your own are left out, people already in your contacts are\n * not sent again (an expired invitation is), and the server's outcome is shown for the rest.\n */\nimport { useArbi, useContacts, useInviteContacts } from '@arbidocs/react'\nimport { refusalReason } from '@arbidocs/sdk/browser'\nimport { useState } from 'react'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport {\n AddContactsForm,\n AddContactsResults,\n type AddContactsResultRow,\n type AddContactsLabels,\n} from '../../collaboration/contacts/AddContactsParts'\nimport { MAX_INVITE_EMAILS } from '../../collaboration/contacts/parseEmails'\nimport {\n applyContactInviteResults,\n emailTokens,\n failContactInvites,\n planContactInvites,\n summarizeContactInvites,\n summarizeUnsentInvites,\n} from '../../collaboration/contacts/invite-plan'\n\nexport interface ConnectedAddContactsProps {\n /** After a submit (also when nothing needed sending). */\n onSuccess?: () => void\n onClose?: () => void\n /** Results completed; defaults to closing the form. */\n onDone?: () => void\n initialEmail?: string\n /** Formatted referral reward (\"\u00A320\"); omit to hide the banner. */\n rewardAmount?: string\n /** Keep the input available after submitting, with failures shown inline. */\n keepFormOpen?: boolean\n labels?: Partial<AddContactsLabels>\n}\n\nexport function ConnectedAddContacts({\n onSuccess,\n onClose,\n onDone,\n initialEmail = '',\n rewardAmount,\n keepFormOpen = false,\n labels,\n}: ConnectedAddContactsProps) {\n const { notify } = useBlocksEnvironment()\n const arbi = useArbi()\n const { data: contacts = [] } = useContacts()\n const invite = useInviteContacts()\n const [text, setText] = useState(initialEmail)\n const [rows, setRows] = useState<AddContactsResultRow[] | null>(null)\n const selfEmail = arbi.isLoggedIn ? arbi.user.identity()?.email : null\n\n const submit = async () => {\n if (!emailTokens(text).length) {\n notify('Please enter at least one email address', 'error')\n return\n }\n const plan = planContactInvites(text, contacts, selfEmail)\n if (plan.send.length > MAX_INVITE_EMAILS) {\n notify(`Maximum ${MAX_INVITE_EMAILS} new emails allowed per batch`, 'error')\n return\n }\n setRows(plan.rows)\n if (!plan.send.length) {\n notify(summarizeUnsentInvites(plan.rows), 'info')\n onSuccess?.()\n return\n }\n try {\n const response = await invite.mutateAsync(plan.send)\n const results = applyContactInviteResults(plan, response)\n setRows(results)\n if (keepFormOpen)\n setText(\n results\n .filter((row) => row.status === 'failed')\n .map((row) => row.email)\n .join(', ')\n )\n const summary = summarizeContactInvites(response)\n notify(summary.message, summary.failed ? 'error' : 'success')\n onSuccess?.()\n } catch (error) {\n const message = refusalReason(error, 'Failed to add contacts')\n setRows(failContactInvites(plan, message))\n notify(message, 'error')\n }\n }\n\n if (rows && !keepFormOpen)\n return (\n <AddContactsResults\n rows={rows}\n onDone={onDone ?? onClose}\n onAddMore={() => {\n setText('')\n setRows(null)\n }}\n />\n )\n\n return (\n <>\n <AddContactsForm\n value={text}\n onChange={setText}\n emailCount={emailTokens(text).length}\n isPending={invite.isPending}\n onSubmit={() => void submit()}\n onCancel={onClose}\n rewardAmount={rewardAmount}\n labels={labels}\n />\n {keepFormOpen && rows?.some((row) => row.status === 'failed') && (\n <ul role=\"alert\" className=\"text-sm text-destructive\">\n {rows\n .filter((row) => row.status === 'failed')\n .map((row) => (\n <li key={row.email}>\n {row.email}: {row.message}\n </li>\n ))}\n </ul>\n )}\n </>\n )\n}\n"],
5
+ "mappings": ";AA+FM,SAWF,UAXE,KA2BQ,YA3BR;AA1FN,SAAS,SAAS,aAAa,yBAAyB;AACxD,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,4B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