@aglyn/aglyn 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -11
- package/src/lib/app-utils/ai-credit-blocks.d.ts +124 -0
- package/src/lib/app-utils/ai-credit-blocks.js +122 -0
- package/src/lib/app-utils/ai-credit-blocks.js.map +1 -0
- package/src/lib/app-utils/bundle-intent.d.ts +17 -51
- package/src/lib/app-utils/bundle-intent.js +30 -74
- package/src/lib/app-utils/bundle-intent.js.map +1 -1
- package/src/lib/app-utils/contacts.d.ts +4 -1
- package/src/lib/app-utils/contacts.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +3 -3
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +1 -1
- package/src/lib/app-utils/docs-help.generated.js +1 -1
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +97 -97
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/error-beacon.d.ts +25 -1
- package/src/lib/app-utils/error-beacon.js +55 -4
- package/src/lib/app-utils/error-beacon.js.map +1 -1
- package/src/lib/app-utils/foreign-script.d.ts +1 -1
- package/src/lib/app-utils/foreign-script.js +1 -1
- package/src/lib/app-utils/foreign-script.js.map +1 -1
- package/src/lib/app-utils/margin-utilization.js +6 -5
- package/src/lib/app-utils/margin-utilization.js.map +1 -1
- package/src/lib/app-utils/onboarding-deep-link.d.ts +10 -11
- package/src/lib/app-utils/onboarding-deep-link.js +37 -32
- package/src/lib/app-utils/onboarding-deep-link.js.map +1 -1
- package/src/lib/app-utils/operator-alerts.js +17 -0
- package/src/lib/app-utils/operator-alerts.js.map +1 -1
- package/src/lib/app-utils/plan-entitlements.d.ts +142 -150
- package/src/lib/app-utils/plan-entitlements.js +202 -201
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/release-flags.d.ts +6 -4
- package/src/lib/app-utils/release-flags.js +8 -9
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +1 -0
- package/src/lib/app-utils/server.js +3 -0
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/site-interactions.d.ts +1 -1
- package/src/lib/app-utils/site-interactions.js +2 -2
- package/src/lib/app-utils/site-interactions.js.map +1 -1
- package/src/lib/app-utils/transactional-email-ceiling.d.ts +119 -0
- package/src/lib/app-utils/transactional-email-ceiling.js +134 -0
- package/src/lib/app-utils/transactional-email-ceiling.js.map +1 -0
- package/src/lib/app-utils/upgrade-proposal.d.ts +17 -7
- package/src/lib/app-utils/upgrade-proposal.js +20 -13
- package/src/lib/app-utils/upgrade-proposal.js.map +1 -1
- package/src/lib/foundation/definitions/org-billing.types.d.ts +4 -29
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
- package/src/lib/foundation/definitions/organization.types.d.ts +1 -3
- package/src/lib/foundation/definitions/organization.types.js.map +1 -1
- package/src/lib/foundation/index.d.ts +1 -1
- package/src/lib/foundation/index.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +0 -6
- package/src/lib/plugin-manager/first-party-plugins.generated.js +9 -55
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/plugin-usage-axes.d.ts +14 -0
- package/src/lib/plugin-manager/plugin-usage-axes.js.map +1 -1
- package/src/lib/plugin-manager/video-embed-provider.d.ts +29 -0
- package/src/lib/plugin-manager/video-embed-provider.js +26 -7
- package/src/lib/plugin-manager/video-embed-provider.js.map +1 -1
- package/src/lib/plugin-manager/video-embed-providers.generated.d.ts +11 -0
- package/src/lib/plugin-manager/video-embed-providers.generated.js +161 -0
- package/src/lib/plugin-manager/video-embed-providers.generated.js.map +1 -0
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
* A link is typed by a person and passed through hops nobody controls, so
|
|
31
31
|
* the parser never throws and never guesses: an unknown token is dropped and
|
|
32
32
|
* reported, so the page can say so in one line instead of failing.
|
|
33
|
-
*/ import {
|
|
34
|
-
import {
|
|
33
|
+
*/ import { AI_CREDIT_BLOCK_MONTHLY_USD, AI_CREDIT_BLOCKS_MAX } from "./ai-credit-blocks.js";
|
|
34
|
+
import { aiAddonName, EVENT_CALENDAR_ADDON_MONTHLY_USD, EXTRA_HOSTS_ADDON_MAX, PLAN_LABELS, PLAN_PRICING, planSellsAiCredits, planSellsSiteCare, POS_REGISTER_ADDON_MONTHLY_USD, POS_REGISTERS_ADDON_MAX, resolveOrgEntitlements, SITE_CARE_ADDON_MONTHLY_USD, UNLIMITED } from "./plan-entitlements.js";
|
|
35
35
|
/**
|
|
36
36
|
* Every add-on kind Billing sells, in the order the Billing card lists them.
|
|
37
37
|
* `/api/billing/addons`, the webhook's price map and the native add-ons
|
|
@@ -46,9 +46,11 @@ import { AI_TIER_IDS, AI_TIERS, aiAddonName, aiTierAddonKey, aiTierName, default
|
|
|
46
46
|
'aiAddon',
|
|
47
47
|
'siteCare'
|
|
48
48
|
];
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* The org-wide 0/1 kinds: one purchase covers the workspace. Aglyn AI is a
|
|
51
|
+
* quantity since AGL-4144 — blocks of credits, 0 to 30 — not a toggle.
|
|
52
|
+
*/ export const TOGGLE_ADDON_KIND_LIST = [
|
|
50
53
|
'eventCalendar',
|
|
51
|
-
'aiAddon',
|
|
52
54
|
'siteCare'
|
|
53
55
|
];
|
|
54
56
|
export function isAddonKind(value) {
|
|
@@ -57,10 +59,9 @@ export function isAddonKind(value) {
|
|
|
57
59
|
/**
|
|
58
60
|
* Monthly USD per unit for an add-on on a plan (yearly prices are ×12 of
|
|
59
61
|
* this); null when the plan doesn't sell the kind. Single pricing source
|
|
60
|
-
* of truth: `PLAN_PRICING`, the
|
|
61
|
-
*
|
|
62
|
-
|
|
63
|
-
*/ export function addonUnitUsd(kind, plan, tier) {
|
|
62
|
+
* of truth: `PLAN_PRICING`, the flat add-on constants and the Aglyn AI
|
|
63
|
+
* credit block (`ai-credit-blocks.ts`, AGL-4144).
|
|
64
|
+
*/ export function addonUnitUsd(kind, plan) {
|
|
64
65
|
const pricing = PLAN_PRICING[plan];
|
|
65
66
|
switch(kind){
|
|
66
67
|
case 'managers':
|
|
@@ -76,10 +77,8 @@ export function isAddonKind(value) {
|
|
|
76
77
|
case 'eventCalendar':
|
|
77
78
|
return EVENT_CALENDAR_ADDON_MONTHLY_USD;
|
|
78
79
|
case 'aiAddon':
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return chosen ? AI_TIERS[chosen].monthlyUsd : null;
|
|
82
|
-
}
|
|
80
|
+
// A block of credits, the same price on every plan that sells it.
|
|
81
|
+
return planSellsAiCredits(plan) ? AI_CREDIT_BLOCK_MONTHLY_USD : null;
|
|
83
82
|
case 'siteCare':
|
|
84
83
|
return SITE_CARE_ADDON_MONTHLY_USD;
|
|
85
84
|
}
|
|
@@ -88,8 +87,8 @@ export function isAddonKind(value) {
|
|
|
88
87
|
* Max purchasable quantity per kind, from a purchases-free entitlement
|
|
89
88
|
* resolution (plan defaults + staff overrides only) so the ceiling does not
|
|
90
89
|
* drift as the org buys: seat/dataset kinds stop at the plan's hard max,
|
|
91
|
-
* hosts/registers use flat ceilings,
|
|
92
|
-
* Care are 0/1 toggles. POS registers additionally require the `pos`
|
|
90
|
+
* hosts/registers use flat ceilings, Aglyn AI credit blocks stop at 30, the
|
|
91
|
+
* Event Calendar and Site Care are 0/1 toggles. POS registers additionally require the `pos`
|
|
93
92
|
* feature, and Site Care a plan that sells it (`planSellsSiteCare`), which is
|
|
94
93
|
* why the plan travels with the baseline.
|
|
95
94
|
*
|
|
@@ -112,9 +111,9 @@ export function isAddonKind(value) {
|
|
|
112
111
|
case 'eventCalendar':
|
|
113
112
|
return 1;
|
|
114
113
|
case 'aiAddon':
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
return
|
|
114
|
+
// Blocks of credits, 0 to 30, on any plan that sells them (AGL-4144)
|
|
115
|
+
// — not Free, not Enterprise.
|
|
116
|
+
return planSellsAiCredits(plan) ? AI_CREDIT_BLOCKS_MAX : 0;
|
|
118
117
|
case 'siteCare':
|
|
119
118
|
// Flat-priced, so the price map cannot say "not sold here" the way it
|
|
120
119
|
// does for Aglyn AI. This ceiling is the rule that keeps Free (no
|
|
@@ -173,35 +172,11 @@ export function isAddonKind(value) {
|
|
|
173
172
|
add('hosts', 'extraHosts', 'extraSite', 'extraSites', 'sites');
|
|
174
173
|
add('posRegisters', 'registers', 'register');
|
|
175
174
|
add('eventCalendar', 'events', 'calendar');
|
|
176
|
-
add('aiAddon', 'aglynAi');
|
|
175
|
+
add('aiAddon', 'aglynAi', 'aiCredits', 'aiBlocks');
|
|
177
176
|
add('siteCare', 'site-care', 'site_care', 'care');
|
|
178
177
|
return map;
|
|
179
178
|
})();
|
|
180
179
|
/** The most of a quantity kind a link may ask for, before the plan's ceiling. */ const MAX_LINK_QUANTITY = 999;
|
|
181
|
-
/**
|
|
182
|
-
* THE `ai:<tier>` TOKENS (AGL-3965).
|
|
183
|
-
*
|
|
184
|
-
* Aglyn AI is a tier chosen on its own, on any paid plan: `ai:boost` adds
|
|
185
|
-
* Aglyn AI Boost. The words are the tier ids, lower-cased as every token is,
|
|
186
|
-
* and resolve through `parseAiTierAddonKey`, the one spelling of the
|
|
187
|
-
* `ai:<tier>` key. A bare `ai` (or `ai:1`) still means "add it" and sells
|
|
188
|
-
* the plan's default tier (`defaultAiTierForPlan`). An unknown tier is
|
|
189
|
-
* dropped with the notice like any other unknown add-on, never read as
|
|
190
|
-
* "add whichever tier": that would sell a tier nobody chose.
|
|
191
|
-
*/ export const AI_ADDON_TIER_TOKENS = Object.freeze(Object.fromEntries(AI_TIER_IDS.map((tier)=>[
|
|
192
|
-
tier.toLowerCase(),
|
|
193
|
-
tier
|
|
194
|
-
])));
|
|
195
|
-
export function resolveAiAddonTier(tier) {
|
|
196
|
-
const word = tier.trim().toLowerCase();
|
|
197
|
-
if (!Object.prototype.hasOwnProperty.call(AI_ADDON_TIER_TOKENS, word)) return null;
|
|
198
|
-
const parsed = parseAiTierAddonKey(aiTierAddonKey(AI_ADDON_TIER_TOKENS[word]));
|
|
199
|
-
return parsed ? {
|
|
200
|
-
kind: 'aiAddon',
|
|
201
|
-
quantity: 1,
|
|
202
|
-
tier: parsed
|
|
203
|
-
} : null;
|
|
204
|
-
}
|
|
205
180
|
/** One token, `kind` or `kind:quantity`, or null when nothing understands it. */ function parseToken(raw) {
|
|
206
181
|
const token = raw.trim();
|
|
207
182
|
if (!token) return null;
|
|
@@ -221,7 +196,7 @@ export function resolveAiAddonTier(tier) {
|
|
|
221
196
|
quantity: TOGGLE_ADDON_KIND_LIST.includes(kind) ? 1 : quantity
|
|
222
197
|
};
|
|
223
198
|
}
|
|
224
|
-
return
|
|
199
|
+
return null;
|
|
225
200
|
}
|
|
226
201
|
/**
|
|
227
202
|
* Read the add-ons a link, a proposal or a request names.
|
|
@@ -233,7 +208,6 @@ export function resolveAiAddonTier(tier) {
|
|
|
233
208
|
*/ export function parseBundleAddons(input) {
|
|
234
209
|
const addons = {};
|
|
235
210
|
const dropped = [];
|
|
236
|
-
let aiTier;
|
|
237
211
|
const take = (parsed, raw)=>{
|
|
238
212
|
var _addons_parsed_kind;
|
|
239
213
|
if (!parsed) {
|
|
@@ -241,8 +215,6 @@ export function resolveAiAddonTier(tier) {
|
|
|
241
215
|
return;
|
|
242
216
|
}
|
|
243
217
|
addons[parsed.kind] = Math.max((_addons_parsed_kind = addons[parsed.kind]) != null ? _addons_parsed_kind : 0, parsed.quantity);
|
|
244
|
-
// The first tier named wins: one workspace holds one tier.
|
|
245
|
-
if (parsed.tier && !aiTier) aiTier = parsed.tier;
|
|
246
218
|
};
|
|
247
219
|
if (typeof input === 'string') {
|
|
248
220
|
for (const raw of input.split(/[,\s]+/))take(parseToken(raw), raw);
|
|
@@ -258,12 +230,10 @@ export function resolveAiAddonTier(tier) {
|
|
|
258
230
|
take(parseToken(quantity ? `${name}:${quantity}` : name), name);
|
|
259
231
|
}
|
|
260
232
|
}
|
|
261
|
-
return
|
|
233
|
+
return {
|
|
262
234
|
addons,
|
|
263
235
|
dropped
|
|
264
|
-
}
|
|
265
|
-
aiTier
|
|
266
|
-
} : {});
|
|
236
|
+
};
|
|
267
237
|
}
|
|
268
238
|
/**
|
|
269
239
|
* The add-ons a plan can actually carry: kinds it does not sell are dropped,
|
|
@@ -289,30 +259,18 @@ export function resolveAiAddonTier(tier) {
|
|
|
289
259
|
};
|
|
290
260
|
}
|
|
291
261
|
/**
|
|
292
|
-
* The add-ons as the link writes them: `siteCare,ai:
|
|
293
|
-
*
|
|
294
|
-
|
|
295
|
-
*/ export function bundleAddonsParam(addons, aiTier) {
|
|
262
|
+
* The add-ons as the link writes them: `siteCare,ai:3,extraHost:2`. Aglyn AI
|
|
263
|
+
* is written with its block count past one (AGL-4144), as bare `ai` for one.
|
|
264
|
+
*/ export function bundleAddonsParam(addons) {
|
|
296
265
|
return ADDON_KINDS.filter((kind)=>{
|
|
297
266
|
var _ref;
|
|
298
267
|
return ((_ref = addons == null ? void 0 : addons[kind]) != null ? _ref : 0) > 0;
|
|
299
268
|
}).map((kind)=>{
|
|
300
269
|
var _ref;
|
|
301
|
-
if (kind === 'aiAddon' && aiTier) return aiTierAddonKey(aiTier);
|
|
302
270
|
const quantity = (_ref = addons == null ? void 0 : addons[kind]) != null ? _ref : 0;
|
|
303
271
|
return quantity > 1 ? `${BUNDLE_ADDON_TOKENS[kind]}:${quantity}` : BUNDLE_ADDON_TOKENS[kind];
|
|
304
272
|
}).join(',');
|
|
305
273
|
}
|
|
306
|
-
/**
|
|
307
|
-
* The Aglyn AI tier a bundle sells (AGL-4025): the tier named, or the plan's
|
|
308
|
-
* default (`defaultAiTierForPlan`) when none is; null when the bundle has no
|
|
309
|
-
* Aglyn AI or the plan sells no tier. A picker shows this tier as chosen, the
|
|
310
|
-
* link writes it as `ai:<tier>`, and checkout charges it, so the three agree.
|
|
311
|
-
*/ export function bundleAiTier(addons, plan, tier) {
|
|
312
|
-
var _ref;
|
|
313
|
-
if (!(((_ref = addons == null ? void 0 : addons.aiAddon) != null ? _ref : 0) > 0) || !planSellsAiTiers(plan)) return null;
|
|
314
|
-
return isAiTierId(tier) ? tier : defaultAiTierForPlan(plan);
|
|
315
|
-
}
|
|
316
274
|
/**
|
|
317
275
|
* What a bundle costs at list price, in cents, before tax and any promotion
|
|
318
276
|
* code (AGL-4026): the plan at its price for the cadence (the annual monthly
|
|
@@ -332,7 +290,7 @@ export function resolveAiAddonTier(tier) {
|
|
|
332
290
|
for (const kind of ADDON_KINDS){
|
|
333
291
|
var _addons_kind;
|
|
334
292
|
const quantity = (_addons_kind = addons[kind]) != null ? _addons_kind : 0;
|
|
335
|
-
const unit = addonUnitUsd(kind, bundle.plan
|
|
293
|
+
const unit = addonUnitUsd(kind, bundle.plan);
|
|
336
294
|
if (quantity > 0 && unit != null) cents += Math.round(unit * 100) * quantity * (yearly ? 12 : 1);
|
|
337
295
|
}
|
|
338
296
|
return cents;
|
|
@@ -343,10 +301,7 @@ export function resolveAiAddonTier(tier) {
|
|
|
343
301
|
return ((_ref = addons == null ? void 0 : addons[kind]) != null ? _ref : 0) > 0;
|
|
344
302
|
});
|
|
345
303
|
}
|
|
346
|
-
/**
|
|
347
|
-
* How each kind is named to a customer, singular. Aglyn AI carries its tier
|
|
348
|
-
* when one is named: "Aglyn AI Boost" (AGL-3965).
|
|
349
|
-
*/ export function bundleAddonLabel(kind, brand, aiTier) {
|
|
304
|
+
/** How each kind is named to a customer, singular: "Aglyn AI credit block". */ export function bundleAddonLabel(kind, brand) {
|
|
350
305
|
switch(kind){
|
|
351
306
|
case 'managers':
|
|
352
307
|
return 'Extra manager seat';
|
|
@@ -361,13 +316,14 @@ export function resolveAiAddonTier(tier) {
|
|
|
361
316
|
case 'eventCalendar':
|
|
362
317
|
return 'Event Calendar';
|
|
363
318
|
case 'aiAddon':
|
|
364
|
-
|
|
319
|
+
// One unit is a block of credits (AGL-4144).
|
|
320
|
+
return `${aiAddonName(brand)} credit block`;
|
|
365
321
|
case 'siteCare':
|
|
366
322
|
return 'Site Care';
|
|
367
323
|
}
|
|
368
324
|
}
|
|
369
|
-
/** "Site Care", "2 × Extra site", "Aglyn AI
|
|
370
|
-
const label = bundleAddonLabel(kind, brand
|
|
325
|
+
/** "Site Care", "2 × Extra site", "3 × Aglyn AI credit block". */ export function describeBundleAddon(kind, quantity, brand) {
|
|
326
|
+
const label = bundleAddonLabel(kind, brand);
|
|
371
327
|
return quantity > 1 ? `${quantity} × ${label}` : label;
|
|
372
328
|
}
|
|
373
329
|
/** The longest coupon code a link carries. Stripe codes are far shorter. */ export const BUNDLE_COUPON_MAX = 64;
|
|
@@ -419,7 +375,7 @@ export function resolveAiAddonTier(tier) {
|
|
|
419
375
|
}).map((kind)=>{
|
|
420
376
|
var _ref;
|
|
421
377
|
var _bundle_addons;
|
|
422
|
-
return describeBundleAddon(kind, (_ref = (_bundle_addons = bundle.addons) == null ? void 0 : _bundle_addons[kind]) != null ? _ref : 0, options.brand
|
|
378
|
+
return describeBundleAddon(kind, (_ref = (_bundle_addons = bundle.addons) == null ? void 0 : _bundle_addons[kind]) != null ? _ref : 0, options.brand);
|
|
423
379
|
});
|
|
424
380
|
const addons = parts.length === 0 ? '' : parts.length === 1 ? ` with ${parts[0]}` : ` with ${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`;
|
|
425
381
|
const interval = bundle.interval === 'year' ? ', billed yearly' : bundle.interval === 'month' ? ', billed monthly' : '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/bundle-intent.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * THE ADD-ONS A PLAN SELLS, AND THE BUNDLE A LINK ASKS FOR (AGL-3955).\n *\n * One list of add-on kinds and one parser for the add-ons a link, an upgrade\n * proposal or a staff dialog names, so the Billing card, the bundle checkout\n * link, the hand-off proposal (AGL-3956) and `/api/billing/checkout` agree on\n * what `addons=siteCare,ai,extraHost:2` means.\n *\n * The kinds are `OrgSeatAddons`' keys: what `resolvePurchasedAddons` counts,\n * what the webhook mirrors from Stripe, and what `/api/billing/addons` sells.\n * The prices and ceilings here are the ones `billing-addons.ts` (server)\n * re-exports, so a kind the link can preselect is always a kind the\n * checkout can price.\n *\n * A link is typed by a person and passed through hops nobody controls, so\n * the parser never throws and never guesses: an unknown token is dropped and\n * reported, so the page can say so in one line instead of failing.\n */\n\nimport type {\n AiTierId,\n OrgPlan,\n OrgSeatAddons,\n} from '../foundation/definitions/org-billing.types'\nimport {\n AI_TIER_IDS,\n AI_TIERS,\n aiAddonName,\n aiTierAddonKey,\n aiTierName,\n defaultAiTierForPlan,\n EVENT_CALENDAR_ADDON_MONTHLY_USD,\n EXTRA_HOSTS_ADDON_MAX,\n isAiTierId,\n PLAN_LABELS,\n parseAiTierAddonKey,\n PLAN_PRICING,\n planSellsAiTiers,\n planSellsSiteCare,\n POS_REGISTER_ADDON_MONTHLY_USD,\n POS_REGISTERS_ADDON_MAX,\n resolveOrgEntitlements,\n SITE_CARE_ADDON_MONTHLY_USD,\n UNLIMITED,\n} from './plan-entitlements'\n\n/** An add-on kind: a key of `org.seatAddons`. */\nexport type AddonKind = keyof Required<OrgSeatAddons>\n\n/**\n * Every add-on kind Billing sells, in the order the Billing card lists them.\n * `/api/billing/addons`, the webhook's price map and the native add-ons\n * screen all read this list.\n */\nexport const ADDON_KINDS: readonly AddonKind[] = [\n 'managers',\n 'members',\n 'datasets',\n 'hosts',\n 'posRegisters',\n 'eventCalendar',\n 'aiAddon',\n 'siteCare',\n]\n\n/** The org-wide 0/1 kinds: one purchase covers the workspace. */\nexport const TOGGLE_ADDON_KIND_LIST: readonly AddonKind[] = [\n 'eventCalendar',\n 'aiAddon',\n 'siteCare',\n]\n\nexport function isAddonKind(value: unknown): value is AddonKind {\n return typeof value === 'string' && (ADDON_KINDS as readonly string[]).includes(value)\n}\n\n/**\n * Monthly USD per unit for an add-on on a plan (yearly prices are ×12 of\n * this); null when the plan doesn't sell the kind. Single pricing source\n * of truth: `PLAN_PRICING`, the three flat add-on constants and `AI_TIERS`\n * (`tier` as `addonPriceId` reads it; absent, the tier a plan-named purchase\n * means, `defaultAiTierForPlan`, AGL-3965).\n */\nexport function addonUnitUsd(\n kind: AddonKind,\n plan: OrgPlan,\n tier?: AiTierId | null,\n): number | null {\n const pricing = PLAN_PRICING[plan]\n switch (kind) {\n case 'managers':\n return pricing.extraSeatMonthlyUsd\n case 'members':\n return pricing.extraCollaboratorMonthlyUsd\n case 'datasets':\n return pricing.extraDatasetMonthlyUsd\n case 'hosts':\n return pricing.extraHostMonthlyUsd\n case 'posRegisters':\n return POS_REGISTER_ADDON_MONTHLY_USD\n case 'eventCalendar':\n return EVENT_CALENDAR_ADDON_MONTHLY_USD\n case 'aiAddon': {\n const chosen = planSellsAiTiers(plan) ? (tier ?? defaultAiTierForPlan(plan)) : null\n return chosen ? AI_TIERS[chosen].monthlyUsd : null\n }\n case 'siteCare':\n return SITE_CARE_ADDON_MONTHLY_USD\n }\n}\n\n/**\n * Max purchasable quantity per kind, from a purchases-free entitlement\n * resolution (plan defaults + staff overrides only) so the ceiling does not\n * drift as the org buys: seat/dataset kinds stop at the plan's hard max,\n * hosts/registers use flat ceilings, the Event Calendar, Aglyn AI and Site\n * Care are 0/1 toggles. POS registers additionally require the `pos`\n * feature, and Site Care a plan that sells it (`planSellsSiteCare`), which is\n * why the plan travels with the baseline.\n *\n * One definition for every reader: `/api/billing/addons` asks how many the\n * org may buy on its plan, a plan change asks how many of what it bought the\n * new plan can deliver, and a bundle link asks how many it may preselect.\n */\nexport function addonMaxForBaseline(\n kind: AddonKind,\n baseline: ReturnType<typeof resolveOrgEntitlements>,\n plan: OrgPlan,\n): number {\n const bounded = (included: number, max: number) =>\n Number.isFinite(max) ? Math.max(0, max - included) : EXTRA_HOSTS_ADDON_MAX\n switch (kind) {\n case 'managers':\n return bounded(baseline.managersPerOrg, baseline.maxManagersPerOrg)\n case 'members':\n return bounded(baseline.membersPerHost, baseline.maxMembersPerHost)\n case 'datasets':\n return bounded(baseline.datasetsPerOrg, baseline.maxDatasetsPerOrg)\n case 'hosts':\n return baseline.hostLimit === UNLIMITED ? 0 : EXTRA_HOSTS_ADDON_MAX\n case 'posRegisters':\n return baseline.features.pos ? POS_REGISTERS_ADDON_MAX : 0\n case 'eventCalendar':\n return 1\n case 'aiAddon':\n // Org-wide like the Event Calendar: one purchase, of one tier, on any\n // plan that sells tiers (AGL-3965) — not Free, not Enterprise.\n return planSellsAiTiers(plan) ? 1 : 0\n case 'siteCare':\n // Flat-priced, so the price map cannot say \"not sold here\" the way it\n // does for Aglyn AI. This ceiling is the rule that keeps Free (no\n // subscription) and Enterprise (quoted per deal) from buying it.\n return planSellsSiteCare(plan) ? 1 : 0\n }\n}\n\n/** The ceiling a PLAN would impose on an add-on kind, purchases excluded. */\nexport function addonMaxForPlan(kind: AddonKind, plan: OrgPlan): number {\n return addonMaxForBaseline(\n kind,\n resolveOrgEntitlements({ plan } as never),\n plan,\n )\n}\n\n/** Whether a plan sells an add-on at all: priced, with a ceiling above zero. */\nexport function planSellsAddon(kind: AddonKind, plan: OrgPlan): boolean {\n return addonUnitUsd(kind, plan) != null && addonMaxForPlan(kind, plan) > 0\n}\n\n/**\n * The first of `plans` (listed smallest first) that sells an add-on kind, or\n * null when none does: the plan a picker names beside an add-on the chosen\n * plan does not sell, so it shows as \"needs Pro or higher\" rather than\n * vanishing (AGL-4025). POS registers need a plan with the point of sale.\n */\nexport function firstPlanSellingAddon(\n kind: AddonKind,\n plans: readonly OrgPlan[],\n): OrgPlan | null {\n return plans.find((plan) => planSellsAddon(kind, plan)) ?? null\n}\n\n/** Quantities by kind, absent kinds meaning none. */\nexport type BundleAddons = Partial<Record<AddonKind, number>>\n\n/**\n * What a link writes for each kind. `ai` and `extraHost` are the words the\n * account owner chose (AGL-3955); the rest follow the same shape.\n */\nexport const BUNDLE_ADDON_TOKENS: Record<AddonKind, string> = {\n managers: 'extraSeat',\n members: 'extraMember',\n datasets: 'extraDataset',\n hosts: 'extraHost',\n posRegisters: 'posRegister',\n eventCalendar: 'eventCalendar',\n aiAddon: 'ai',\n siteCare: 'siteCare',\n}\n\n/**\n * Every spelling the parser accepts, lower-cased: the written token, the\n * stored kind, and the plurals a person types. Exported for the native apps'\n * generated words (AGL-4011), which read a stored proposal the same way.\n */\nexport const TOKEN_KINDS: Readonly<Record<string, AddonKind>> = (() => {\n const map: Record<string, AddonKind> = {}\n const add = (kind: AddonKind, ...words: string[]) => {\n for (const word of [kind, BUNDLE_ADDON_TOKENS[kind], ...words]) {\n map[word.toLowerCase()] = kind\n }\n }\n add('managers', 'extraSeats', 'seats', 'managerSeats')\n add('members', 'extraMembers', 'collaborators', 'collaboratorSeats')\n add('datasets', 'extraDatasets')\n add('hosts', 'extraHosts', 'extraSite', 'extraSites', 'sites')\n add('posRegisters', 'registers', 'register')\n add('eventCalendar', 'events', 'calendar')\n add('aiAddon', 'aglynAi')\n add('siteCare', 'site-care', 'site_care', 'care')\n return map\n})()\n\n/** The most of a quantity kind a link may ask for, before the plan's ceiling. */\nconst MAX_LINK_QUANTITY = 999\n\n/** One add-on a token names, with the Aglyn AI tier when it names one. */\ninterface ParsedToken {\n kind: AddonKind\n quantity: number\n tier?: AiTierId\n}\n\n/**\n * THE `ai:<tier>` TOKENS (AGL-3965).\n *\n * Aglyn AI is a tier chosen on its own, on any paid plan: `ai:boost` adds\n * Aglyn AI Boost. The words are the tier ids, lower-cased as every token is,\n * and resolve through `parseAiTierAddonKey`, the one spelling of the\n * `ai:<tier>` key. A bare `ai` (or `ai:1`) still means \"add it\" and sells\n * the plan's default tier (`defaultAiTierForPlan`). An unknown tier is\n * dropped with the notice like any other unknown add-on, never read as\n * \"add whichever tier\": that would sell a tier nobody chose.\n */\nexport const AI_ADDON_TIER_TOKENS: Readonly<Record<string, AiTierId>> = Object.freeze(\n Object.fromEntries(AI_TIER_IDS.map((tier) => [tier.toLowerCase(), tier])),\n)\n\nexport function resolveAiAddonTier(tier: string): ParsedToken | null {\n const word = tier.trim().toLowerCase()\n if (!Object.prototype.hasOwnProperty.call(AI_ADDON_TIER_TOKENS, word)) return null\n const parsed = parseAiTierAddonKey(aiTierAddonKey(AI_ADDON_TIER_TOKENS[word]))\n return parsed ? { kind: 'aiAddon', quantity: 1, tier: parsed } : null\n}\n\nexport interface ParsedBundleAddons {\n addons: BundleAddons\n /** The tokens nothing understood, as they were written. */\n dropped: string[]\n /** The Aglyn AI tier an `ai:<tier>` token named (AGL-3965), if any. */\n aiTier?: AiTierId\n}\n\n/** One token, `kind` or `kind:quantity`, or null when nothing understands it. */\nfunction parseToken(raw: string): ParsedToken | null {\n const token = raw.trim()\n if (!token) return null\n const [name, ...rest] = token.split(':')\n const kind = TOKEN_KINDS[name.trim().toLowerCase()]\n if (!kind) return null\n const value = rest.join(':').trim()\n if (!value) return { kind, quantity: 1 }\n if (/^\\d+$/.test(value)) {\n const quantity = Math.min(MAX_LINK_QUANTITY, Number(value))\n if (quantity < 1) return null\n return {\n kind,\n quantity: (TOGGLE_ADDON_KIND_LIST as readonly string[]).includes(kind) ? 1 : quantity,\n }\n }\n return kind === 'aiAddon' ? resolveAiAddonTier(value) : null\n}\n\n/**\n * Read the add-ons a link, a proposal or a request names.\n *\n * Accepts the link form (`\"siteCare,ai,extraHost:2\"`), a list of tokens, or a\n * map of kind → quantity or flag (`{ siteCare: true, hosts: 2 }`, the shape\n * the native staff screens post from their toggles). Never throws: anything\n * it cannot read is reported in `dropped` and left out.\n */\nexport function parseBundleAddons(input: unknown): ParsedBundleAddons {\n const addons: BundleAddons = {}\n const dropped: string[] = []\n let aiTier: AiTierId | undefined\n const take = (parsed: ParsedToken | null, raw: string) => {\n if (!parsed) {\n if (raw.trim()) dropped.push(raw.trim().slice(0, 40))\n return\n }\n addons[parsed.kind] = Math.max(addons[parsed.kind] ?? 0, parsed.quantity)\n // The first tier named wins: one workspace holds one tier.\n if (parsed.tier && !aiTier) aiTier = parsed.tier\n }\n if (typeof input === 'string') {\n for (const raw of input.split(/[,\\s]+/)) take(parseToken(raw), raw)\n } else if (Array.isArray(input)) {\n for (const raw of input) {\n if (typeof raw === 'string') take(parseToken(raw), raw)\n }\n } else if (input && typeof input === 'object') {\n for (const [name, value] of Object.entries(input as Record<string, unknown>)) {\n const off =\n value === false ||\n value === 0 ||\n value === null ||\n value === undefined ||\n value === '' ||\n value === 'false' ||\n value === '0'\n if (off) continue\n const quantity =\n value === true || value === 'true'\n ? ''\n : typeof value === 'number' || typeof value === 'string'\n ? String(value)\n : ''\n take(parseToken(quantity ? `${name}:${quantity}` : name), name)\n }\n }\n return { addons, dropped, ...(aiTier ? { aiTier } : {}) }\n}\n\nexport interface FittedBundleAddons {\n addons: BundleAddons\n /** Kinds the plan does not sell, dropped. */\n notSold: AddonKind[]\n}\n\n/**\n * The add-ons a plan can actually carry: kinds it does not sell are dropped,\n * quantities are held to its ceiling. What a link preselects on one plan is\n * re-fitted when the owner picks another, so the checkout is never asked for\n * something it would refuse.\n */\nexport function fitBundleAddonsToPlan(\n addons: BundleAddons | null | undefined,\n plan: OrgPlan,\n): FittedBundleAddons {\n const fitted: BundleAddons = {}\n const notSold: AddonKind[] = []\n for (const kind of ADDON_KINDS) {\n const wanted = Math.floor(Number(addons?.[kind] ?? 0))\n if (!(wanted > 0)) continue\n if (!planSellsAddon(kind, plan)) {\n notSold.push(kind)\n continue\n }\n fitted[kind] = Math.min(wanted, addonMaxForPlan(kind, plan))\n }\n return { addons: fitted, notSold }\n}\n\n/**\n * The add-ons as the link writes them: `siteCare,ai:boost,extraHost:2`.\n * Aglyn AI is written with its tier when one is named (AGL-3965), as bare\n * `ai` otherwise.\n */\nexport function bundleAddonsParam(\n addons: BundleAddons | null | undefined,\n aiTier?: AiTierId | null,\n): string {\n return ADDON_KINDS.filter((kind) => (addons?.[kind] ?? 0) > 0)\n .map((kind) => {\n if (kind === 'aiAddon' && aiTier) return aiTierAddonKey(aiTier)\n const quantity = addons?.[kind] ?? 0\n return quantity > 1 ? `${BUNDLE_ADDON_TOKENS[kind]}:${quantity}` : BUNDLE_ADDON_TOKENS[kind]\n })\n .join(',')\n}\n\n/**\n * The Aglyn AI tier a bundle sells (AGL-4025): the tier named, or the plan's\n * default (`defaultAiTierForPlan`) when none is; null when the bundle has no\n * Aglyn AI or the plan sells no tier. A picker shows this tier as chosen, the\n * link writes it as `ai:<tier>`, and checkout charges it, so the three agree.\n */\nexport function bundleAiTier(\n addons: BundleAddons | null | undefined,\n plan: OrgPlan,\n tier?: AiTierId | null,\n): AiTierId | null {\n if (!((addons?.aiAddon ?? 0) > 0) || !planSellsAiTiers(plan)) return null\n return isAiTierId(tier) ? tier : defaultAiTierForPlan(plan)\n}\n\n/**\n * What a bundle costs at list price, in cents, before tax and any promotion\n * code (AGL-4026): the plan at its price for the cadence (the annual monthly\n * price × 12 yearly, the monthly price monthly), plus every add-on the plan\n * sells at its unit price × quantity, × 12 yearly as every add-on bills.\n *\n * The figure Billing shows while Stripe cannot price the bundle with tax —\n * no billing address yet, the preview still on its way, or a preview that\n * failed — so the owner always sees what the bundle costs and sees it move\n * as they change it. Never shown in place of Stripe's taxed total.\n */\nexport function bundleListPriceCents(bundle: {\n plan: OrgPlan\n interval: 'month' | 'year'\n addons?: BundleAddons | null\n aiTier?: AiTierId | null\n}): number {\n const pricing = PLAN_PRICING[bundle.plan]\n const yearly = bundle.interval === 'year'\n const base = yearly ? pricing.basePriceAnnualMonthlyUsd * 12 : pricing.basePriceMonthlyUsd\n let cents = Math.round(base * 100)\n const addons = fitBundleAddonsToPlan(bundle.addons, bundle.plan).addons\n for (const kind of ADDON_KINDS) {\n const quantity = addons[kind] ?? 0\n const unit = addonUnitUsd(kind, bundle.plan, kind === 'aiAddon' ? bundle.aiTier : null)\n if (quantity > 0 && unit != null) cents += Math.round(unit * 100) * quantity * (yearly ? 12 : 1)\n }\n return cents\n}\n\n/** Whether any add-on is asked for. */\nexport function hasBundleAddons(addons: BundleAddons | null | undefined): boolean {\n return ADDON_KINDS.some((kind) => (addons?.[kind] ?? 0) > 0)\n}\n\n/**\n * How each kind is named to a customer, singular. Aglyn AI carries its tier\n * when one is named: \"Aglyn AI Boost\" (AGL-3965).\n */\nexport function bundleAddonLabel(\n kind: AddonKind,\n brand?: string,\n aiTier?: AiTierId | null,\n): string {\n switch (kind) {\n case 'managers':\n return 'Extra manager seat'\n case 'members':\n return 'Extra collaborator seat'\n case 'datasets':\n return 'Extra dataset'\n case 'hosts':\n return 'Extra site'\n case 'posRegisters':\n return 'POS register'\n case 'eventCalendar':\n return 'Event Calendar'\n case 'aiAddon':\n return aiTier ? aiTierName(aiTier, brand) : aiAddonName(brand)\n case 'siteCare':\n return 'Site Care'\n }\n}\n\n/** \"Site Care\", \"2 × Extra site\", \"Aglyn AI Boost\". */\nexport function describeBundleAddon(\n kind: AddonKind,\n quantity: number,\n brand?: string,\n aiTier?: AiTierId | null,\n): string {\n const label = bundleAddonLabel(kind, brand, aiTier)\n return quantity > 1 ? `${quantity} × ${label}` : label\n}\n\n/** The longest coupon code a link carries. Stripe codes are far shorter. */\nexport const BUNDLE_COUPON_MAX = 64\n\n/**\n * A promotion code as a link carries it, or undefined. Only the characters\n * Stripe allows in a customer-facing code; anything else is not a code\n * somebody was handed, and is dropped rather than sent to Stripe.\n *\n * The code is only APPLIED here. Codes are minted on the staff Coupons page,\n * which audits them; nothing on this path creates one.\n */\nexport function normalizeBundleCoupon(raw: unknown): string | undefined {\n if (typeof raw !== 'string') return undefined\n const code = raw.trim()\n if (!code || code.length > BUNDLE_COUPON_MAX) return undefined\n return /^[A-Za-z0-9_-]+$/.test(code) ? code : undefined\n}\n\n/**\n * A domain name as a bundle carries it — lower-cased, no scheme, no path —\n * or undefined. Whether it is for sale and at what price is the registrar's\n * answer, re-checked at purchase; this only refuses what cannot be a name.\n */\nexport function normalizeBundleDomain(raw: unknown): string | undefined {\n if (typeof raw !== 'string') return undefined\n const name = raw\n .trim()\n .toLowerCase()\n .replace(/^https?:\\/\\//, '')\n .replace(/\\/.*$/, '')\n .replace(/\\.$/, '')\n if (!name || name.length > 253) return undefined\n const labels = name.split('.')\n if (labels.length < 2) return undefined\n const ok = labels.every((label) => /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label))\n return ok && /^[a-z]{2,63}$/.test(labels[labels.length - 1]) ? name : undefined\n}\n\n/** \"$15.99\". */\nexport function formatBundleCents(cents: number): string {\n return `$${(Math.max(0, Math.round(cents)) / 100).toFixed(2)}`\n}\n\n/**\n * The domain line a bundle shows (AGL-3955): \"example.com — $15.99 first\n * year, renews yearly at $15.99\". The price is the registrar's at the moment\n * the link was minted; the purchase re-checks it.\n */\nexport function bundleDomainLine(domain: {\n name: string\n firstYearCents: number\n renewalCents: number\n}): string {\n return (\n `${domain.name} — ${formatBundleCents(domain.firstYearCents)} first year, ` +\n `renews yearly at ${formatBundleCents(domain.renewalCents)}`\n )\n}\n\n/**\n * The bundle in one line, for an email, a dialog or a snackbar:\n * \"Starter with Site Care and Aglyn AI, billed yearly, code BOOTH25\".\n */\nexport function describeBundle(\n bundle: {\n plan: OrgPlan\n addons?: BundleAddons | null\n interval?: 'month' | 'year' | null\n coupon?: string | null\n /** The Aglyn AI tier, named with the AI add-on (AGL-3965). */\n aiTier?: AiTierId | null\n },\n options: { brand?: string } = {},\n): string {\n const parts = ADDON_KINDS.filter((kind) => (bundle.addons?.[kind] ?? 0) > 0).map((kind) =>\n describeBundleAddon(kind, bundle.addons?.[kind] ?? 0, options.brand, bundle.aiTier),\n )\n const addons =\n parts.length === 0\n ? ''\n : parts.length === 1\n ? ` with ${parts[0]}`\n : ` with ${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`\n const interval =\n bundle.interval === 'year'\n ? ', billed yearly'\n : bundle.interval === 'month'\n ? ', billed monthly'\n : ''\n const coupon = bundle.coupon ? `, code ${bundle.coupon}` : ''\n return `${PLAN_LABELS[bundle.plan] ?? bundle.plan}${addons}${interval}${coupon}`\n}\n"],"names":["AI_TIER_IDS","AI_TIERS","aiAddonName","aiTierAddonKey","aiTierName","defaultAiTierForPlan","EVENT_CALENDAR_ADDON_MONTHLY_USD","EXTRA_HOSTS_ADDON_MAX","isAiTierId","PLAN_LABELS","parseAiTierAddonKey","PLAN_PRICING","planSellsAiTiers","planSellsSiteCare","POS_REGISTER_ADDON_MONTHLY_USD","POS_REGISTERS_ADDON_MAX","resolveOrgEntitlements","SITE_CARE_ADDON_MONTHLY_USD","UNLIMITED","ADDON_KINDS","TOGGLE_ADDON_KIND_LIST","isAddonKind","value","includes","addonUnitUsd","kind","plan","tier","pricing","extraSeatMonthlyUsd","extraCollaboratorMonthlyUsd","extraDatasetMonthlyUsd","extraHostMonthlyUsd","chosen","monthlyUsd","addonMaxForBaseline","baseline","bounded","included","max","Number","isFinite","Math","managersPerOrg","maxManagersPerOrg","membersPerHost","maxMembersPerHost","datasetsPerOrg","maxDatasetsPerOrg","hostLimit","features","pos","addonMaxForPlan","planSellsAddon","firstPlanSellingAddon","plans","find","BUNDLE_ADDON_TOKENS","managers","members","datasets","hosts","posRegisters","eventCalendar","aiAddon","siteCare","TOKEN_KINDS","map","add","words","word","toLowerCase","MAX_LINK_QUANTITY","AI_ADDON_TIER_TOKENS","Object","freeze","fromEntries","resolveAiAddonTier","trim","prototype","hasOwnProperty","call","parsed","quantity","parseToken","raw","token","name","rest","split","join","test","min","parseBundleAddons","input","addons","dropped","aiTier","take","push","slice","Array","isArray","entries","off","undefined","String","fitBundleAddonsToPlan","fitted","notSold","wanted","floor","bundleAddonsParam","filter","bundleAiTier","bundleListPriceCents","bundle","yearly","interval","base","basePriceAnnualMonthlyUsd","basePriceMonthlyUsd","cents","round","unit","hasBundleAddons","some","bundleAddonLabel","brand","describeBundleAddon","label","BUNDLE_COUPON_MAX","normalizeBundleCoupon","code","length","normalizeBundleDomain","replace","labels","ok","every","formatBundleCents","toFixed","bundleDomainLine","domain","firstYearCents","renewalCents","describeBundle","options","parts","coupon"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;CAiBC;AAOD,SACEA,WAAW,EACXC,QAAQ,EACRC,WAAW,EACXC,cAAc,EACdC,UAAU,EACVC,oBAAoB,EACpBC,gCAAgC,EAChCC,qBAAqB,EACrBC,UAAU,EACVC,WAAW,EACXC,mBAAmB,EACnBC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,8BAA8B,EAC9BC,uBAAuB,EACvBC,sBAAsB,EACtBC,2BAA2B,EAC3BC,SAAS,QACJ,yBAAqB;AAK5B;;;;CAIC,GACD,OAAO,MAAMC,cAAoC;IAC/C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED,+DAA+D,GAC/D,OAAO,MAAMC,yBAA+C;IAC1D;IACA;IACA;CACD,CAAA;AAED,OAAO,SAASC,YAAYC,KAAc;IACxC,OAAO,OAAOA,UAAU,YAAY,AAACH,YAAkCI,QAAQ,CAACD;AAClF;AAEA;;;;;;CAMC,GACD,OAAO,SAASE,aACdC,IAAe,EACfC,IAAa,EACbC,IAAsB;IAEtB,MAAMC,UAAUjB,YAAY,CAACe,KAAK;IAClC,OAAQD;QACN,KAAK;YACH,OAAOG,QAAQC,mBAAmB;QACpC,KAAK;YACH,OAAOD,QAAQE,2BAA2B;QAC5C,KAAK;YACH,OAAOF,QAAQG,sBAAsB;QACvC,KAAK;YACH,OAAOH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AK,mBAAI,KAAK;OAAG0C,GAAG,CAAC,CAAC1C;;YACtD2F;eAA1Ba,oBAAoBxG,eAAM2F,iBAAAA,OAAOrB,MAAM,qBAAbqB,cAAe,CAAC3F,KAAK,mBAAI,GAAG0H,QAAQnB,KAAK,EAAEZ,OAAOnB,MAAM;;IAEpF,MAAMF,SACJqD,MAAMd,MAAM,KAAK,IACb,KACAc,MAAMd,MAAM,KAAK,IACf,CAAC,MAAM,EAAEc,KAAK,CAAC,EAAE,EAAE,GACnB,CAAC,MAAM,EAAEA,MAAMhD,KAAK,CAAC,GAAG,CAAC,GAAGV,IAAI,CAAC,MAAM,KAAK,EAAE0D,KAAK,CAACA,MAAMd,MAAM,GAAG,EAAE,EAAE;IAC/E,MAAMhB,WACJF,OAAOE,QAAQ,KAAK,SAChB,oBACAF,OAAOE,QAAQ,KAAK,UAClB,qBACA;IACR,MAAM+B,SAASjC,OAAOiC,MAAM,GAAG,CAAC,OAAO,EAAEjC,OAAOiC,MAAM,EAAE,GAAG;IAC3D,OAAO,IAAG5I,2BAAAA,WAAW,CAAC2G,OAAO1F,IAAI,CAAC,YAAxBjB,2BAA4B2G,OAAO1F,IAAI,GAAGqE,SAASuB,WAAW+B,QAAQ;AAClF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/bundle-intent.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * THE ADD-ONS A PLAN SELLS, AND THE BUNDLE A LINK ASKS FOR (AGL-3955).\n *\n * One list of add-on kinds and one parser for the add-ons a link, an upgrade\n * proposal or a staff dialog names, so the Billing card, the bundle checkout\n * link, the hand-off proposal (AGL-3956) and `/api/billing/checkout` agree on\n * what `addons=siteCare,ai,extraHost:2` means.\n *\n * The kinds are `OrgSeatAddons`' keys: what `resolvePurchasedAddons` counts,\n * what the webhook mirrors from Stripe, and what `/api/billing/addons` sells.\n * The prices and ceilings here are the ones `billing-addons.ts` (server)\n * re-exports, so a kind the link can preselect is always a kind the\n * checkout can price.\n *\n * A link is typed by a person and passed through hops nobody controls, so\n * the parser never throws and never guesses: an unknown token is dropped and\n * reported, so the page can say so in one line instead of failing.\n */\n\nimport type {\n OrgPlan,\n OrgSeatAddons,\n} from '../foundation/definitions/org-billing.types'\nimport {\n AI_CREDIT_BLOCK_MONTHLY_USD,\n AI_CREDIT_BLOCKS_MAX,\n} from './ai-credit-blocks'\nimport {\n aiAddonName,\n EVENT_CALENDAR_ADDON_MONTHLY_USD,\n EXTRA_HOSTS_ADDON_MAX,\n PLAN_LABELS,\n PLAN_PRICING,\n planSellsAiCredits,\n planSellsSiteCare,\n POS_REGISTER_ADDON_MONTHLY_USD,\n POS_REGISTERS_ADDON_MAX,\n resolveOrgEntitlements,\n SITE_CARE_ADDON_MONTHLY_USD,\n UNLIMITED,\n} from './plan-entitlements'\n\n/** An add-on kind: a key of `org.seatAddons`. */\nexport type AddonKind = keyof Required<OrgSeatAddons>\n\n/**\n * Every add-on kind Billing sells, in the order the Billing card lists them.\n * `/api/billing/addons`, the webhook's price map and the native add-ons\n * screen all read this list.\n */\nexport const ADDON_KINDS: readonly AddonKind[] = [\n 'managers',\n 'members',\n 'datasets',\n 'hosts',\n 'posRegisters',\n 'eventCalendar',\n 'aiAddon',\n 'siteCare',\n]\n\n/**\n * The org-wide 0/1 kinds: one purchase covers the workspace. Aglyn AI is a\n * quantity since AGL-4144 — blocks of credits, 0 to 30 — not a toggle.\n */\nexport const TOGGLE_ADDON_KIND_LIST: readonly AddonKind[] = [\n 'eventCalendar',\n 'siteCare',\n]\n\nexport function isAddonKind(value: unknown): value is AddonKind {\n return typeof value === 'string' && (ADDON_KINDS as readonly string[]).includes(value)\n}\n\n/**\n * Monthly USD per unit for an add-on on a plan (yearly prices are ×12 of\n * this); null when the plan doesn't sell the kind. Single pricing source\n * of truth: `PLAN_PRICING`, the flat add-on constants and the Aglyn AI\n * credit block (`ai-credit-blocks.ts`, AGL-4144).\n */\nexport function addonUnitUsd(\n kind: AddonKind,\n plan: OrgPlan,\n): number | null {\n const pricing = PLAN_PRICING[plan]\n switch (kind) {\n case 'managers':\n return pricing.extraSeatMonthlyUsd\n case 'members':\n return pricing.extraCollaboratorMonthlyUsd\n case 'datasets':\n return pricing.extraDatasetMonthlyUsd\n case 'hosts':\n return pricing.extraHostMonthlyUsd\n case 'posRegisters':\n return POS_REGISTER_ADDON_MONTHLY_USD\n case 'eventCalendar':\n return EVENT_CALENDAR_ADDON_MONTHLY_USD\n case 'aiAddon':\n // A block of credits, the same price on every plan that sells it.\n return planSellsAiCredits(plan) ? AI_CREDIT_BLOCK_MONTHLY_USD : null\n case 'siteCare':\n return SITE_CARE_ADDON_MONTHLY_USD\n }\n}\n\n/**\n * Max purchasable quantity per kind, from a purchases-free entitlement\n * resolution (plan defaults + staff overrides only) so the ceiling does not\n * drift as the org buys: seat/dataset kinds stop at the plan's hard max,\n * hosts/registers use flat ceilings, Aglyn AI credit blocks stop at 30, the\n * Event Calendar and Site Care are 0/1 toggles. POS registers additionally require the `pos`\n * feature, and Site Care a plan that sells it (`planSellsSiteCare`), which is\n * why the plan travels with the baseline.\n *\n * One definition for every reader: `/api/billing/addons` asks how many the\n * org may buy on its plan, a plan change asks how many of what it bought the\n * new plan can deliver, and a bundle link asks how many it may preselect.\n */\nexport function addonMaxForBaseline(\n kind: AddonKind,\n baseline: ReturnType<typeof resolveOrgEntitlements>,\n plan: OrgPlan,\n): number {\n const bounded = (included: number, max: number) =>\n Number.isFinite(max) ? Math.max(0, max - included) : EXTRA_HOSTS_ADDON_MAX\n switch (kind) {\n case 'managers':\n return bounded(baseline.managersPerOrg, baseline.maxManagersPerOrg)\n case 'members':\n return bounded(baseline.membersPerHost, baseline.maxMembersPerHost)\n case 'datasets':\n return bounded(baseline.datasetsPerOrg, baseline.maxDatasetsPerOrg)\n case 'hosts':\n return baseline.hostLimit === UNLIMITED ? 0 : EXTRA_HOSTS_ADDON_MAX\n case 'posRegisters':\n return baseline.features.pos ? POS_REGISTERS_ADDON_MAX : 0\n case 'eventCalendar':\n return 1\n case 'aiAddon':\n // Blocks of credits, 0 to 30, on any plan that sells them (AGL-4144)\n // — not Free, not Enterprise.\n return planSellsAiCredits(plan) ? AI_CREDIT_BLOCKS_MAX : 0\n case 'siteCare':\n // Flat-priced, so the price map cannot say \"not sold here\" the way it\n // does for Aglyn AI. This ceiling is the rule that keeps Free (no\n // subscription) and Enterprise (quoted per deal) from buying it.\n return planSellsSiteCare(plan) ? 1 : 0\n }\n}\n\n/** The ceiling a PLAN would impose on an add-on kind, purchases excluded. */\nexport function addonMaxForPlan(kind: AddonKind, plan: OrgPlan): number {\n return addonMaxForBaseline(\n kind,\n resolveOrgEntitlements({ plan } as never),\n plan,\n )\n}\n\n/** Whether a plan sells an add-on at all: priced, with a ceiling above zero. */\nexport function planSellsAddon(kind: AddonKind, plan: OrgPlan): boolean {\n return addonUnitUsd(kind, plan) != null && addonMaxForPlan(kind, plan) > 0\n}\n\n/**\n * The first of `plans` (listed smallest first) that sells an add-on kind, or\n * null when none does: the plan a picker names beside an add-on the chosen\n * plan does not sell, so it shows as \"needs Pro or higher\" rather than\n * vanishing (AGL-4025). POS registers need a plan with the point of sale.\n */\nexport function firstPlanSellingAddon(\n kind: AddonKind,\n plans: readonly OrgPlan[],\n): OrgPlan | null {\n return plans.find((plan) => planSellsAddon(kind, plan)) ?? null\n}\n\n/** Quantities by kind, absent kinds meaning none. */\nexport type BundleAddons = Partial<Record<AddonKind, number>>\n\n/**\n * What a link writes for each kind. `ai` and `extraHost` are the words the\n * account owner chose (AGL-3955); the rest follow the same shape.\n */\nexport const BUNDLE_ADDON_TOKENS: Record<AddonKind, string> = {\n managers: 'extraSeat',\n members: 'extraMember',\n datasets: 'extraDataset',\n hosts: 'extraHost',\n posRegisters: 'posRegister',\n eventCalendar: 'eventCalendar',\n aiAddon: 'ai',\n siteCare: 'siteCare',\n}\n\n/**\n * Every spelling the parser accepts, lower-cased: the written token, the\n * stored kind, and the plurals a person types. Exported for the native apps'\n * generated words (AGL-4011), which read a stored proposal the same way.\n */\nexport const TOKEN_KINDS: Readonly<Record<string, AddonKind>> = (() => {\n const map: Record<string, AddonKind> = {}\n const add = (kind: AddonKind, ...words: string[]) => {\n for (const word of [kind, BUNDLE_ADDON_TOKENS[kind], ...words]) {\n map[word.toLowerCase()] = kind\n }\n }\n add('managers', 'extraSeats', 'seats', 'managerSeats')\n add('members', 'extraMembers', 'collaborators', 'collaboratorSeats')\n add('datasets', 'extraDatasets')\n add('hosts', 'extraHosts', 'extraSite', 'extraSites', 'sites')\n add('posRegisters', 'registers', 'register')\n add('eventCalendar', 'events', 'calendar')\n add('aiAddon', 'aglynAi', 'aiCredits', 'aiBlocks')\n add('siteCare', 'site-care', 'site_care', 'care')\n return map\n})()\n\n/** The most of a quantity kind a link may ask for, before the plan's ceiling. */\nconst MAX_LINK_QUANTITY = 999\n\n/**\n * One add-on a token names. Aglyn AI is `ai` (one block) or `ai:<blocks>`\n * (AGL-4144); a retired tier name (`ai:boost`) is not a number and is\n * dropped with the notice like any other unknown add-on, never read as\n * \"some blocks\".\n */\ninterface ParsedToken {\n kind: AddonKind\n quantity: number\n}\n\nexport interface ParsedBundleAddons {\n addons: BundleAddons\n /** The tokens nothing understood, as they were written. */\n dropped: string[]\n}\n\n/** One token, `kind` or `kind:quantity`, or null when nothing understands it. */\nfunction parseToken(raw: string): ParsedToken | null {\n const token = raw.trim()\n if (!token) return null\n const [name, ...rest] = token.split(':')\n const kind = TOKEN_KINDS[name.trim().toLowerCase()]\n if (!kind) return null\n const value = rest.join(':').trim()\n if (!value) return { kind, quantity: 1 }\n if (/^\\d+$/.test(value)) {\n const quantity = Math.min(MAX_LINK_QUANTITY, Number(value))\n if (quantity < 1) return null\n return {\n kind,\n quantity: (TOGGLE_ADDON_KIND_LIST as readonly string[]).includes(kind) ? 1 : quantity,\n }\n }\n return null\n}\n\n/**\n * Read the add-ons a link, a proposal or a request names.\n *\n * Accepts the link form (`\"siteCare,ai,extraHost:2\"`), a list of tokens, or a\n * map of kind → quantity or flag (`{ siteCare: true, hosts: 2 }`, the shape\n * the native staff screens post from their toggles). Never throws: anything\n * it cannot read is reported in `dropped` and left out.\n */\nexport function parseBundleAddons(input: unknown): ParsedBundleAddons {\n const addons: BundleAddons = {}\n const dropped: string[] = []\n const take = (parsed: ParsedToken | null, raw: string) => {\n if (!parsed) {\n if (raw.trim()) dropped.push(raw.trim().slice(0, 40))\n return\n }\n addons[parsed.kind] = Math.max(addons[parsed.kind] ?? 0, parsed.quantity)\n }\n if (typeof input === 'string') {\n for (const raw of input.split(/[,\\s]+/)) take(parseToken(raw), raw)\n } else if (Array.isArray(input)) {\n for (const raw of input) {\n if (typeof raw === 'string') take(parseToken(raw), raw)\n }\n } else if (input && typeof input === 'object') {\n for (const [name, value] of Object.entries(input as Record<string, unknown>)) {\n const off =\n value === false ||\n value === 0 ||\n value === null ||\n value === undefined ||\n value === '' ||\n value === 'false' ||\n value === '0'\n if (off) continue\n const quantity =\n value === true || value === 'true'\n ? ''\n : typeof value === 'number' || typeof value === 'string'\n ? String(value)\n : ''\n take(parseToken(quantity ? `${name}:${quantity}` : name), name)\n }\n }\n return { addons, dropped }\n}\n\nexport interface FittedBundleAddons {\n addons: BundleAddons\n /** Kinds the plan does not sell, dropped. */\n notSold: AddonKind[]\n}\n\n/**\n * The add-ons a plan can actually carry: kinds it does not sell are dropped,\n * quantities are held to its ceiling. What a link preselects on one plan is\n * re-fitted when the owner picks another, so the checkout is never asked for\n * something it would refuse.\n */\nexport function fitBundleAddonsToPlan(\n addons: BundleAddons | null | undefined,\n plan: OrgPlan,\n): FittedBundleAddons {\n const fitted: BundleAddons = {}\n const notSold: AddonKind[] = []\n for (const kind of ADDON_KINDS) {\n const wanted = Math.floor(Number(addons?.[kind] ?? 0))\n if (!(wanted > 0)) continue\n if (!planSellsAddon(kind, plan)) {\n notSold.push(kind)\n continue\n }\n fitted[kind] = Math.min(wanted, addonMaxForPlan(kind, plan))\n }\n return { addons: fitted, notSold }\n}\n\n/**\n * The add-ons as the link writes them: `siteCare,ai:3,extraHost:2`. Aglyn AI\n * is written with its block count past one (AGL-4144), as bare `ai` for one.\n */\nexport function bundleAddonsParam(addons: BundleAddons | null | undefined): string {\n return ADDON_KINDS.filter((kind) => (addons?.[kind] ?? 0) > 0)\n .map((kind) => {\n const quantity = addons?.[kind] ?? 0\n return quantity > 1 ? `${BUNDLE_ADDON_TOKENS[kind]}:${quantity}` : BUNDLE_ADDON_TOKENS[kind]\n })\n .join(',')\n}\n\n/**\n * What a bundle costs at list price, in cents, before tax and any promotion\n * code (AGL-4026): the plan at its price for the cadence (the annual monthly\n * price × 12 yearly, the monthly price monthly), plus every add-on the plan\n * sells at its unit price × quantity, × 12 yearly as every add-on bills.\n *\n * The figure Billing shows while Stripe cannot price the bundle with tax —\n * no billing address yet, the preview still on its way, or a preview that\n * failed — so the owner always sees what the bundle costs and sees it move\n * as they change it. Never shown in place of Stripe's taxed total.\n */\nexport function bundleListPriceCents(bundle: {\n plan: OrgPlan\n interval: 'month' | 'year'\n addons?: BundleAddons | null\n}): number {\n const pricing = PLAN_PRICING[bundle.plan]\n const yearly = bundle.interval === 'year'\n const base = yearly ? pricing.basePriceAnnualMonthlyUsd * 12 : pricing.basePriceMonthlyUsd\n let cents = Math.round(base * 100)\n const addons = fitBundleAddonsToPlan(bundle.addons, bundle.plan).addons\n for (const kind of ADDON_KINDS) {\n const quantity = addons[kind] ?? 0\n const unit = addonUnitUsd(kind, bundle.plan)\n if (quantity > 0 && unit != null) cents += Math.round(unit * 100) * quantity * (yearly ? 12 : 1)\n }\n return cents\n}\n\n/** Whether any add-on is asked for. */\nexport function hasBundleAddons(addons: BundleAddons | null | undefined): boolean {\n return ADDON_KINDS.some((kind) => (addons?.[kind] ?? 0) > 0)\n}\n\n/** How each kind is named to a customer, singular: \"Aglyn AI credit block\". */\nexport function bundleAddonLabel(kind: AddonKind, brand?: string): string {\n switch (kind) {\n case 'managers':\n return 'Extra manager seat'\n case 'members':\n return 'Extra collaborator seat'\n case 'datasets':\n return 'Extra dataset'\n case 'hosts':\n return 'Extra site'\n case 'posRegisters':\n return 'POS register'\n case 'eventCalendar':\n return 'Event Calendar'\n case 'aiAddon':\n // One unit is a block of credits (AGL-4144).\n return `${aiAddonName(brand)} credit block`\n case 'siteCare':\n return 'Site Care'\n }\n}\n\n/** \"Site Care\", \"2 × Extra site\", \"3 × Aglyn AI credit block\". */\nexport function describeBundleAddon(\n kind: AddonKind,\n quantity: number,\n brand?: string,\n): string {\n const label = bundleAddonLabel(kind, brand)\n return quantity > 1 ? `${quantity} × ${label}` : label\n}\n\n/** The longest coupon code a link carries. Stripe codes are far shorter. */\nexport const BUNDLE_COUPON_MAX = 64\n\n/**\n * A promotion code as a link carries it, or undefined. Only the characters\n * Stripe allows in a customer-facing code; anything else is not a code\n * somebody was handed, and is dropped rather than sent to Stripe.\n *\n * The code is only APPLIED here. Codes are minted on the staff Coupons page,\n * which audits them; nothing on this path creates one.\n */\nexport function normalizeBundleCoupon(raw: unknown): string | undefined {\n if (typeof raw !== 'string') return undefined\n const code = raw.trim()\n if (!code || code.length > BUNDLE_COUPON_MAX) return undefined\n return /^[A-Za-z0-9_-]+$/.test(code) ? code : undefined\n}\n\n/**\n * A domain name as a bundle carries it — lower-cased, no scheme, no path —\n * or undefined. Whether it is for sale and at what price is the registrar's\n * answer, re-checked at purchase; this only refuses what cannot be a name.\n */\nexport function normalizeBundleDomain(raw: unknown): string | undefined {\n if (typeof raw !== 'string') return undefined\n const name = raw\n .trim()\n .toLowerCase()\n .replace(/^https?:\\/\\//, '')\n .replace(/\\/.*$/, '')\n .replace(/\\.$/, '')\n if (!name || name.length > 253) return undefined\n const labels = name.split('.')\n if (labels.length < 2) return undefined\n const ok = labels.every((label) => /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label))\n return ok && /^[a-z]{2,63}$/.test(labels[labels.length - 1]) ? name : undefined\n}\n\n/** \"$15.99\". */\nexport function formatBundleCents(cents: number): string {\n return `$${(Math.max(0, Math.round(cents)) / 100).toFixed(2)}`\n}\n\n/**\n * The domain line a bundle shows (AGL-3955): \"example.com — $15.99 first\n * year, renews yearly at $15.99\". The price is the registrar's at the moment\n * the link was minted; the purchase re-checks it.\n */\nexport function bundleDomainLine(domain: {\n name: string\n firstYearCents: number\n renewalCents: number\n}): string {\n return (\n `${domain.name} — ${formatBundleCents(domain.firstYearCents)} first year, ` +\n `renews yearly at ${formatBundleCents(domain.renewalCents)}`\n )\n}\n\n/**\n * The bundle in one line, for an email, a dialog or a snackbar:\n * \"Starter with Site Care and Aglyn AI, billed yearly, code BOOTH25\".\n */\nexport function describeBundle(\n bundle: {\n plan: OrgPlan\n addons?: BundleAddons | null\n interval?: 'month' | 'year' | null\n coupon?: string | null\n },\n options: { brand?: string } = {},\n): string {\n const parts = ADDON_KINDS.filter((kind) => (bundle.addons?.[kind] ?? 0) > 0).map((kind) =>\n describeBundleAddon(kind, bundle.addons?.[kind] ?? 0, options.brand),\n )\n const addons =\n parts.length === 0\n ? ''\n : parts.length === 1\n ? ` with ${parts[0]}`\n : ` with ${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`\n const interval =\n bundle.interval === 'year'\n ? ', billed yearly'\n : bundle.interval === 'month'\n ? ', billed monthly'\n : ''\n const coupon = bundle.coupon ? `, code ${bundle.coupon}` : ''\n return `${PLAN_LABELS[bundle.plan] ?? bundle.plan}${addons}${interval}${coupon}`\n}\n"],"names":["AI_CREDIT_BLOCK_MONTHLY_USD","AI_CREDIT_BLOCKS_MAX","aiAddonName","EVENT_CALENDAR_ADDON_MONTHLY_USD","EXTRA_HOSTS_ADDON_MAX","PLAN_LABELS","PLAN_PRICING","planSellsAiCredits","planSellsSiteCare","POS_REGISTER_ADDON_MONTHLY_USD","POS_REGISTERS_ADDON_MAX","resolveOrgEntitlements","SITE_CARE_ADDON_MONTHLY_USD","UNLIMITED","ADDON_KINDS","TOGGLE_ADDON_KIND_LIST","isAddonKind","value","includes","addonUnitUsd","kind","plan","pricing","extraSeatMonthlyUsd","extraCollaboratorMonthlyUsd","extraDatasetMonthlyUsd","extraHostMonthlyUsd","addonMaxForBaseline","baseline","bounded","included","max","Number","isFinite","Math","managersPerOrg","maxManagersPerOrg","membersPerHost","maxMembersPerHost","datasetsPerOrg","maxDatasetsPerOrg","hostLimit","features","pos","addonMaxForPlan","planSellsAddon","firstPlanSellingAddon","plans","find","BUNDLE_ADDON_TOKENS","managers","members","datasets","hosts","posRegisters","eventCalendar","aiAddon","siteCare","TOKEN_KINDS","map","add","words","word","toLowerCase","MAX_LINK_QUANTITY","parseToken","raw","token","trim","name","rest","split","join","quantity","test","min","parseBundleAddons","input","addons","dropped","take","parsed","push","slice","Array","isArray","Object","entries","off","undefined","String","fitBundleAddonsToPlan","fitted","notSold","wanted","floor","bundleAddonsParam","filter","bundleListPriceCents","bundle","yearly","interval","base","basePriceAnnualMonthlyUsd","basePriceMonthlyUsd","cents","round","unit","hasBundleAddons","some","bundleAddonLabel","brand","describeBundleAddon","label","BUNDLE_COUPON_MAX","normalizeBundleCoupon","code","length","normalizeBundleDomain","replace","labels","ok","every","formatBundleCents","toFixed","bundleDomainLine","domain","firstYearCents","renewalCents","describeBundle","options","parts","coupon"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;CAiBC,GAMD,SACEA,2BAA2B,EAC3BC,oBAAoB,QACf,wBAAoB;AAC3B,SACEC,WAAW,EACXC,gCAAgC,EAChCC,qBAAqB,EACrBC,WAAW,EACXC,YAAY,EACZC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SAChB,oBACAF,OAAOE,QAAQ,KAAK,UAClB,qBACA;IACR,MAAM+B,SAASjC,OAAOiC,MAAM,GAAG,CAAC,OAAO,EAAEjC,OAAOiC,MAAM,EAAE,GAAG;IAC3D,OAAO,IAAG/H,2BAAAA,WAAW,CAAC8F,OAAO9E,IAAI,CAAC,YAAxBhB,2BAA4B8F,OAAO9E,IAAI,GAAGyD,SAASuB,WAAW+B,QAAQ;AAClF"}
|
|
@@ -132,7 +132,10 @@ export interface HostContact {
|
|
|
132
132
|
* the interaction; only a QUERY reads this.
|
|
133
133
|
*/
|
|
134
134
|
formIds?: string[];
|
|
135
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* E.164, mirrored from the last facet write that set one: the Phone, or
|
|
137
|
+
* the mobile of a person who gave no other number.
|
|
138
|
+
*/
|
|
136
139
|
phone?: string;
|
|
137
140
|
/** The company name as typed, mirrored the same way. */
|
|
138
141
|
companyName?: string;
|