@odla-ai/chapter 0.30.0 → 0.31.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.
@@ -0,0 +1,15 @@
1
+ // src/ui/form-fields.ts
2
+ function collectFormFields(form) {
3
+ const fields = {};
4
+ for (const key of new Set(form.keys())) {
5
+ const values = form.getAll(key).filter((v) => typeof v === "string");
6
+ if (values.length === 0) continue;
7
+ fields[key] = values.length > 1 ? values : values[0];
8
+ }
9
+ return fields;
10
+ }
11
+
12
+ export {
13
+ collectFormFields
14
+ };
15
+ //# sourceMappingURL=chunk-IVXVECKR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui/form-fields.ts"],"sourcesContent":["// Turning a submitted form into the JSON body /api/applications receives.\n// Split out of join.tsx so the multi-value rule is unit-testable without\n// mounting the island.\n\n/**\n * Collect a form's fields into a JSON-serializable object.\n *\n * A name that appears once yields its single value; a name that repeats yields\n * an array. Repetition is how a checkbox group (several inputs sharing one\n * `name`) expresses a multi-select, so folding it to a single value would\n * silently discard all but the last box the member ticked.\n *\n * `File` values are dropped: the application body is JSON, and a `File` would\n * serialize to `{}` and land in the row as an empty object.\n */\nexport function collectFormFields(form: FormData): Record<string, unknown> {\n const fields: Record<string, unknown> = {};\n for (const key of new Set(form.keys())) {\n const values = form.getAll(key).filter((v): v is string => typeof v === \"string\");\n if (values.length === 0) continue;\n fields[key] = values.length > 1 ? values : values[0];\n }\n return fields;\n}\n"],"mappings":";AAeO,SAAS,kBAAkB,MAAyC;AACzE,QAAM,SAAkC,CAAC;AACzC,aAAW,OAAO,IAAI,IAAI,KAAK,KAAK,CAAC,GAAG;AACtC,UAAM,SAAS,KAAK,OAAO,GAAG,EAAE,OAAO,CAAC,MAAmB,OAAO,MAAM,QAAQ;AAChF,QAAI,OAAO,WAAW,EAAG;AACzB,WAAO,GAAG,IAAI,OAAO,SAAS,IAAI,SAAS,OAAO,CAAC;AAAA,EACrD;AACA,SAAO;AACT;","names":[]}
@@ -2,6 +2,9 @@ import {
2
2
  formatChapterCopy,
3
3
  useChapterCopy
4
4
  } from "./chunk-JAWTIROV.js";
5
+ import {
6
+ collectFormFields
7
+ } from "./chunk-IVXVECKR.js";
5
8
 
6
9
  // src/ui/slot-picker.tsx
7
10
  import { useMemo, useState } from "preact/hooks";
@@ -319,7 +322,7 @@ function MembersArea(props) {
319
322
  }
320
323
 
321
324
  // src/ui/join.tsx
322
- import { useEffect as useEffect3, useRef as useRef2, useState as useState6 } from "preact/hooks";
325
+ import { useEffect as useEffect3, useRef as useRef2, useState as useState7 } from "preact/hooks";
323
326
 
324
327
  // src/ui/payment-step.tsx
325
328
  import { useRef, useState as useState4 } from "preact/hooks";
@@ -441,17 +444,6 @@ function PaymentStep(props) {
441
444
  ] });
442
445
  }
443
446
 
444
- // src/ui/form-fields.ts
445
- function collectFormFields(form) {
446
- const fields = {};
447
- for (const key of new Set(form.keys())) {
448
- const values = form.getAll(key).filter((v) => typeof v === "string");
449
- if (values.length === 0) continue;
450
- fields[key] = values.length > 1 ? values : values[0];
451
- }
452
- return fields;
453
- }
454
-
455
447
  // src/ui/join-booking.tsx
456
448
  import { useEffect as useEffect2, useState as useState5 } from "preact/hooks";
457
449
  import { jsx as jsx5, jsxs as jsxs5 } from "preact/jsx-runtime";
@@ -523,8 +515,48 @@ function JoinBooking(props) {
523
515
  ] });
524
516
  }
525
517
 
518
+ // src/ui/join-tiers.tsx
519
+ import { useState as useState6 } from "preact/hooks";
520
+ import { jsx as jsx6, jsxs as jsxs6 } from "preact/jsx-runtime";
521
+ function useTierSelection(tiers, initialTierId) {
522
+ const [selectedTierId, setSelectedTierId] = useState6(() => {
523
+ const preset = tiers.find((tier) => tier.id === initialTierId);
524
+ if (preset) return preset.id;
525
+ return tiers.length === 1 ? tiers[0].id : null;
526
+ });
527
+ return {
528
+ tiers,
529
+ selected: tiers.find((tier) => tier.id === selectedTierId) ?? null,
530
+ selectedTierId,
531
+ selectTier: (tierId) => {
532
+ if (tiers.some((tier) => tier.id === tierId)) setSelectedTierId(tierId);
533
+ }
534
+ };
535
+ }
536
+ function TierPlaceholder(context) {
537
+ return /* @__PURE__ */ jsxs6("fieldset", { "data-chapter-placeholder": "tiers", children: [
538
+ /* @__PURE__ */ jsx6("legend", { children: "Membership (placeholder \u2014 pass renderTiers to style this)" }),
539
+ context.tiers.map((tier) => /* @__PURE__ */ jsxs6("label", { children: [
540
+ /* @__PURE__ */ jsx6(
541
+ "input",
542
+ {
543
+ type: "radio",
544
+ name: "__chapterTier",
545
+ value: tier.id,
546
+ checked: context.selectedTierId === tier.id,
547
+ onChange: () => context.selectTier(tier.id)
548
+ }
549
+ ),
550
+ tier.name
551
+ ] }, tier.id))
552
+ ] });
553
+ }
554
+ function tierNeedsPayment(selected, paymentsReady) {
555
+ return selected ? !selected.free && paymentsReady : paymentsReady;
556
+ }
557
+
526
558
  // src/ui/join.tsx
527
- import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs6 } from "preact/jsx-runtime";
559
+ import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs7 } from "preact/jsx-runtime";
528
560
  async function loadJoinResume(applicationId, fetcher = fetch) {
529
561
  const res = await fetcher(`/api/join/resume?application=${encodeURIComponent(applicationId)}`);
530
562
  const data = await res.json();
@@ -551,9 +583,12 @@ function JoinIsland(props) {
551
583
  renderSubmit
552
584
  } = props;
553
585
  const copy = props.copy ?? config.copy ?? inheritedCopy.join;
554
- const [state, setState] = useState6(props.initialState ?? { step: "form" });
555
- const [error, setError] = useState6(null);
556
- const [submitting, setSubmitting] = useState6(false);
586
+ const tiers = config.tiers ?? [];
587
+ const tierSelection = useTierSelection(tiers, props.initialTierId);
588
+ const { selectedTierId, selected: selectedTier } = tierSelection;
589
+ const [state, setState] = useState7(props.initialState ?? { step: "form" });
590
+ const [error, setError] = useState7(null);
591
+ const [submitting, setSubmitting] = useState7(false);
557
592
  const submissionId = useRef2(null);
558
593
  useEffect3(() => {
559
594
  const resolver = props.loadResume ?? (() => {
@@ -599,6 +634,7 @@ function JoinIsland(props) {
599
634
  try {
600
635
  const fields = collectFormFields(new FormData(e.currentTarget));
601
636
  fields.submissionId = submissionId.current ??= crypto.randomUUID();
637
+ if (selectedTierId) fields.tierId = selectedTierId;
602
638
  const res = await fetch("/api/applications", {
603
639
  method: "POST",
604
640
  headers: { "content-type": "application/json" },
@@ -607,7 +643,7 @@ function JoinIsland(props) {
607
643
  const data = await res.json();
608
644
  if (!res.ok || !data.id) throw new Error(data.error ?? copy.form.submitFailed);
609
645
  setState({
610
- step: config.paymentsReady ? "payment" : "booking",
646
+ step: tierNeedsPayment(selectedTier, config.paymentsReady) ? "payment" : "booking",
611
647
  applicationId: data.id
612
648
  });
613
649
  } catch (err) {
@@ -621,21 +657,21 @@ function JoinIsland(props) {
621
657
  ..."applicationId" in state ? { applicationId: state.applicationId } : {}
622
658
  });
623
659
  if (state.step === "done") {
624
- const body = renderDone?.({ ...state, membersHref }) ?? /* @__PURE__ */ jsxs6("div", { className: "join-done card", children: [
625
- /* @__PURE__ */ jsx6("div", { className: "card-label", children: copy.done.label }),
626
- /* @__PURE__ */ jsx6("p", { className: "meeting-date", children: fullLabel(state.booked.startAt, state.booked.timezone) }),
627
- /* @__PURE__ */ jsx6("p", { className: "meeting-note", children: copy.done.calendarInvite }),
628
- /* @__PURE__ */ jsx6("a", { className: "apply-link", href: membersHref, children: copy.done.memberArea })
660
+ const body = renderDone?.({ ...state, membersHref }) ?? /* @__PURE__ */ jsxs7("div", { className: "join-done card", children: [
661
+ /* @__PURE__ */ jsx7("div", { className: "card-label", children: copy.done.label }),
662
+ /* @__PURE__ */ jsx7("p", { className: "meeting-date", children: fullLabel(state.booked.startAt, state.booked.timezone) }),
663
+ /* @__PURE__ */ jsx7("p", { className: "meeting-note", children: copy.done.calendarInvite }),
664
+ /* @__PURE__ */ jsx7("a", { className: "apply-link", href: membersHref, children: copy.done.memberArea })
629
665
  ] });
630
- return /* @__PURE__ */ jsxs6(Fragment3, { children: [
666
+ return /* @__PURE__ */ jsxs7(Fragment3, { children: [
631
667
  header,
632
668
  body
633
669
  ] });
634
670
  }
635
671
  if (state.step === "booking") {
636
- return /* @__PURE__ */ jsxs6(Fragment3, { children: [
672
+ return /* @__PURE__ */ jsxs7(Fragment3, { children: [
637
673
  header,
638
- /* @__PURE__ */ jsx6(
674
+ /* @__PURE__ */ jsx7(
639
675
  JoinBooking,
640
676
  {
641
677
  applicationId: state.applicationId,
@@ -648,9 +684,9 @@ function JoinIsland(props) {
648
684
  ] });
649
685
  }
650
686
  if (state.step === "payment") {
651
- return /* @__PURE__ */ jsxs6(Fragment3, { children: [
687
+ return /* @__PURE__ */ jsxs7(Fragment3, { children: [
652
688
  header,
653
- /* @__PURE__ */ jsx6(
689
+ /* @__PURE__ */ jsx7(
654
690
  PaymentStep,
655
691
  {
656
692
  applicationId: state.applicationId,
@@ -666,18 +702,20 @@ function JoinIsland(props) {
666
702
  ] });
667
703
  }
668
704
  if (state.step === "paymentPending") {
669
- return /* @__PURE__ */ jsxs6(Fragment3, { children: [
705
+ return /* @__PURE__ */ jsxs7(Fragment3, { children: [
670
706
  header,
671
- /* @__PURE__ */ jsx6("p", { className: "pay-status", role: "status", children: copy.payment.pending })
707
+ /* @__PURE__ */ jsx7("p", { className: "pay-status", role: "status", children: copy.payment.pending })
672
708
  ] });
673
709
  }
674
710
  const submitDisabled = submitting || props.submitDisabled === true;
675
- return /* @__PURE__ */ jsxs6(Fragment3, { children: [
711
+ const tierChooser = tiers.length > 1 ? props.renderTiers?.(tierSelection) ?? TierPlaceholder(tierSelection) : null;
712
+ return /* @__PURE__ */ jsxs7(Fragment3, { children: [
676
713
  header,
677
- /* @__PURE__ */ jsxs6("form", { className: "join-form", onSubmit: (e) => void submit(e), children: [
714
+ /* @__PURE__ */ jsxs7("form", { className: "join-form", onSubmit: (e) => void submit(e), children: [
715
+ tierChooser,
678
716
  children,
679
- error ? /* @__PURE__ */ jsx6("p", { className: "join-error", children: error }) : null,
680
- renderSubmit?.({ submitting, disabled: submitDisabled }) ?? /* @__PURE__ */ jsx6("button", { className: "submit-btn", type: "submit", disabled: submitDisabled, children: submitting ? copy.form.submitting : copy.form.submit })
717
+ error ? /* @__PURE__ */ jsx7("p", { className: "join-error", children: error }) : null,
718
+ renderSubmit?.({ submitting, disabled: submitDisabled }) ?? /* @__PURE__ */ jsx7("button", { className: "submit-btn", type: "submit", disabled: submitDisabled, children: submitting ? copy.form.submitting : copy.form.submit })
681
719
  ] })
682
720
  ] });
683
721
  }
@@ -695,7 +733,10 @@ export {
695
733
  Rescheduler,
696
734
  MembersArea,
697
735
  PaymentStep,
736
+ useTierSelection,
737
+ TierPlaceholder,
738
+ tierNeedsPayment,
698
739
  loadJoinResume,
699
740
  JoinIsland
700
741
  };
701
- //# sourceMappingURL=chunk-IOHVFBXH.js.map
742
+ //# sourceMappingURL=chunk-QWMP6TSM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui/slot-picker.tsx","../src/ui/datetime.ts","../src/ui/members.tsx","../src/ui/reschedule.tsx","../src/ui/join.tsx","../src/ui/payment-step.tsx","../src/ui/join-booking.tsx","../src/ui/join-tiers.tsx"],"sourcesContent":["// SlotPicker — a pure presentational day-chips + time-grid picker, shared by the\n// join booking step and the member-area reschedule. Ported from the proven\n// reference Preact island; behaviour and DOM shape are unchanged.\n//\n// It holds only the active-day UI state; slot data, selection, and booking are\n// the caller's (the picker is `onPick`-driven). `classes` lets the composing\n// island supply its own CSS contract (join styles `slot-*`, reschedule\n// `msched-*`); the defaults work standalone against those class names.\nimport { useMemo, useState } from \"preact/hooks\";\nimport { dayLabel, groupSlotsByDay, timeLabel } from \"./datetime.js\";\nimport type { Slot } from \"./datetime.js\";\n\n/** CSS class names for the four picker parts — overridable so one component\n * serves several differently-styled surfaces. */\nexport interface SlotPickerClasses {\n days: string;\n day: string;\n times: string;\n time: string;\n}\n\nconst DEFAULT_CLASSES: SlotPickerClasses = {\n days: \"slot-days\",\n day: \"slot-day\",\n times: \"slot-grid\",\n time: \"slot-time\",\n};\n\n/** Props for {@link SlotPicker}. Generic over the slot type so a caller's richer\n * slot object survives through `onPick`. */\nexport interface SlotPickerProps<T extends Slot = Slot> {\n /** Bookable slots, ideally already chronological. */\n slots: readonly T[];\n /** The group's scheduling timezone; all labels render in it. */\n timezone: string;\n /** The currently-selected slot's start, for the pressed state. */\n selectedStartAt?: number;\n /** Called with the full slot object when a time is chosen. */\n onPick: (slot: T) => void;\n /** Called when the active day changes (callers clear their selection). */\n onDayChange?: () => void;\n classes?: SlotPickerClasses;\n}\n\n/** A day-chips + time-grid slot picker. Presentational and `onPick`-driven: it\n * owns only the active-day selection; the caller owns slot data, the chosen\n * slot, and booking. Shared by the join booking step and the member reschedule. */\nexport function SlotPicker<T extends Slot = Slot>(props: SlotPickerProps<T>) {\n const { slots, timezone, selectedStartAt, onPick, onDayChange, classes = DEFAULT_CLASSES } = props;\n const byDay = useMemo(() => groupSlotsByDay(slots, timezone), [slots, timezone]);\n const dayKeys = [...byDay.keys()];\n const [activeDay, setActiveDay] = useState<string | undefined>(dayKeys[0]);\n\n // Keep the active day valid if the slot set changed under us (e.g. a reload\n // after a 409): fall back to the first available day.\n const day = activeDay !== undefined && byDay.has(activeDay) ? activeDay : dayKeys[0];\n const times = (day !== undefined ? byDay.get(day) : undefined) ?? [];\n\n return (\n <>\n <div className={classes.days}>\n {dayKeys.map((key) => {\n const first = byDay.get(key)?.[0];\n return (\n <button\n key={key}\n type=\"button\"\n className={classes.day}\n aria-pressed={key === day}\n onClick={() => {\n setActiveDay(key);\n onDayChange?.();\n }}\n >\n {first ? dayLabel(first.startAt, timezone) : key}\n </button>\n );\n })}\n </div>\n <div className={classes.times}>\n {times.map((s) => (\n <button\n key={s.startAt}\n type=\"button\"\n className={classes.time}\n aria-pressed={selectedStartAt === s.startAt}\n onClick={() => onPick(s)}\n >\n {timeLabel(s.startAt, timezone)}\n </button>\n ))}\n </div>\n </>\n );\n}\n","// Date/timezone formatting for the chapter member islands (join booking, member\n// area). Ported from proven production helpers. Every time renders in the\n// group's SCHEDULING timezone with an explicit abbreviation — never the viewer's\n// unlabeled local zone — so an applicant always sees the time the chapter meant.\n// Pure and framework-free, so it is unit-testable without a DOM.\n\n/** A bookable slot: a start instant in epoch milliseconds. */\nexport interface Slot {\n startAt: number;\n}\n\n/** The timezone's short abbreviation (e.g. \"PST\"); falls back to the id if the\n * runtime can't resolve it. */\nexport function tzShort(tz: string): string {\n try {\n const parts = new Intl.DateTimeFormat(undefined, { timeZone: tz, timeZoneName: \"short\" }).formatToParts(\n new Date(),\n );\n return parts.find((p) => p.type === \"timeZoneName\")?.value ?? tz;\n } catch {\n return tz;\n }\n}\n\n/** DST-safe day bucket key (ISO date in the target zone). Groups slots by the\n * calendar day a viewer in `tz` would see, not by UTC midnight. */\nexport function dayKey(ms: number, tz: string): string {\n return new Date(ms).toLocaleDateString(\"en-CA\", { timeZone: tz });\n}\n\n/** Short day label for a day chip, e.g. \"Mon, Jun 3\". */\nexport function dayLabel(ms: number, tz: string): string {\n return new Date(ms).toLocaleDateString(undefined, { timeZone: tz, weekday: \"short\", month: \"short\", day: \"numeric\" });\n}\n\n/** Time-of-day label for a slot button, e.g. \"2:30 PM\". */\nexport function timeLabel(ms: number, tz: string): string {\n return new Date(ms).toLocaleTimeString(undefined, { timeZone: tz, hour: \"numeric\", minute: \"2-digit\" });\n}\n\n/** Full, human confirmation label, e.g. \"Monday, June 3, 2:30 PM PST\". */\nexport function fullLabel(ms: number, tz: string): string {\n return new Date(ms).toLocaleString(undefined, {\n timeZone: tz,\n weekday: \"long\",\n month: \"long\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n timeZoneName: \"short\",\n });\n}\n\n/** Currency label from integer cents, e.g. 100000 → \"$1,000\". */\nexport function fmtMoney(cents: number): string {\n return \"$\" + Math.round(cents / 100).toLocaleString();\n}\n\n/** Short date label, e.g. \"Jun 3, 2026\" (used for renewal/refund copy). */\nexport function fmtDate(ms: number): string {\n return new Date(ms).toLocaleDateString(undefined, { month: \"short\", day: \"numeric\", year: \"numeric\" });\n}\n\n/** Bucket slots into an insertion-ordered `Map<dayKey, Slot[]>` for the picker.\n * Input order is preserved within each day, so a server that returns slots\n * chronologically yields chronological chips + times. */\nexport function groupSlotsByDay<T extends Slot>(slots: readonly T[], tz: string): Map<string, T[]> {\n const byDay = new Map<string, T[]>();\n for (const s of slots) {\n const k = dayKey(s.startAt, tz);\n const bucket = byDay.get(k);\n if (bucket) bucket.push(s);\n else byDay.set(k, [s]);\n }\n return byDay;\n}\n","// The member area island. Reads GET /api/me (role + the member's own\n// application, folded server-side) and renders the account header plus, for a\n// provisional member, their application card with book/reschedule; a full member\n// sees the caller-supplied `memberContent`. Ported from the reference members island to\n// Preact, driven by the injected `api` (no Clerk SDK dependency).\nimport type { ComponentChildren } from \"preact\";\nimport { useEffect, useState } from \"preact/hooks\";\nimport { Rescheduler } from \"./reschedule.js\";\nimport { fmtDate, fullLabel } from \"./datetime.js\";\nimport type { ApiFn } from \"./api.js\";\nimport type { MemberApplication } from \"../session.js\";\nimport { formatChapterCopy, type ChapterCopy } from \"../copy.js\";\nimport { useChapterCopy } from \"./copy-context.js\";\n\ninterface Me {\n email: string | null;\n role: string;\n application: MemberApplication | null;\n}\n\n/** Props for {@link MembersArea}. */\nexport interface MembersAreaProps {\n api: ApiFn;\n /** Sign the member out (the host owns Clerk's signOut). */\n signOut: () => void;\n /** Where the \"Admin console\" link points for admins. Default \"/admin/\". */\n adminHref?: string;\n /** Where an accountless member goes to apply. Default \"/join.html\". */\n applyHref?: string;\n /** What a full (non-provisional) member sees below the account header. */\n memberContent?: ComponentChildren;\n /** Resolved member-area copy. */\n copy?: ChapterCopy[\"members\"];\n /** Replace the provisional application card without replacing auth/data load. */\n renderProvisional?: (context: MemberProvisionalRenderContext) => ComponentChildren;\n}\n\n/** Data and actions supplied to a site's provisional-member render slot. */\nexport interface MemberProvisionalRenderContext {\n api: ApiFn;\n application: MemberApplication | null;\n applyHref: string;\n reload: () => Promise<void>;\n defaultContent: ComponentChildren;\n}\n\nfunction card(copy: ChapterCopy[\"members\"], kicker: string, body: ComponentChildren): ComponentChildren {\n return (\n <div className=\"card\">\n <div className=\"card-label\">{copy.provisional.cardLabel}</div>\n <div className=\"meeting-block\">\n <div className=\"meeting-kicker\">{kicker}</div>\n {body}\n </div>\n </div>\n );\n}\n\nfunction ProvisionalCard(props: {\n api: ApiFn;\n application: MemberApplication | null;\n applyHref: string;\n copy: ChapterCopy[\"members\"];\n onReschedule: () => void | Promise<void>;\n}): ComponentChildren {\n const { api, application, applyHref, copy, onReschedule } = props;\n if (!application) {\n return card(\n copy,\n copy.provisional.applicationNeeded,\n <>\n <div className=\"meeting-note\">{copy.provisional.applicationNeededBody}</div>\n <a className=\"apply-link\" href={applyHref}>\n {copy.provisional.apply}\n </a>\n </>,\n );\n }\n if (application.status === \"refunded\") {\n return card(\n copy,\n copy.provisional.refunded,\n <div className=\"meeting-note\">{copy.provisional.refundedBody}</div>,\n );\n }\n const membership = application.paid ? (\n <div className=\"meeting-note\">\n {application.renewalAt\n ? formatChapterCopy(copy.provisional.renews, { date: fmtDate(application.renewalAt) })\n : copy.provisional.active}\n </div>\n ) : null;\n if (application.meetingAt) {\n return card(\n copy,\n copy.provisional.introductionCall,\n <>\n <div className=\"meeting-date\">{fullLabel(application.meetingAt, application.timezone)}</div>\n <div className=\"meeting-note\">{copy.provisional.calendarInvite}</div>\n {application.meetUrl ? (\n <div className=\"meeting-note\">\n <a href={application.meetUrl} target=\"_blank\" rel=\"noopener\">\n {copy.provisional.joinCall}\n </a>\n </div>\n ) : null}\n <Rescheduler\n api={api}\n applicationId={application.id}\n timezone={application.timezone}\n copy={copy.reschedule}\n onRescheduled={onReschedule}\n />\n {membership}\n </>,\n );\n }\n return card(\n copy,\n copy.provisional.bookCall,\n <>\n <div className=\"meeting-note\">{copy.provisional.bookCallBody}</div>\n <Rescheduler\n api={api}\n applicationId={application.id}\n timezone={application.timezone}\n copy={copy.reschedule}\n onRescheduled={onReschedule}\n label={copy.provisional.chooseTime}\n />\n {membership}\n </>,\n );\n}\n\n/** The signed-in member area. Loads /api/me on mount and renders the account\n * header plus the provisional application card or the full-member content. */\nexport function MembersArea(props: MembersAreaProps) {\n const inheritedCopy = useChapterCopy();\n const {\n api,\n signOut,\n adminHref = \"/admin/\",\n applyHref = \"/join.html\",\n memberContent,\n renderProvisional,\n } = props;\n const copy = props.copy ?? inheritedCopy.members;\n const [me, setMe] = useState<Me | null>(null);\n const [error, setError] = useState(false);\n\n const reload = async () => {\n try {\n setMe(await api<Me>(\"/api/me\"));\n } catch {\n setError(true);\n }\n };\n useEffect(() => {\n void reload();\n }, []);\n\n if (error) return <p className=\"meeting-note\">{copy.loadFailed}</p>;\n if (!me) return <p className=\"meeting-note\">{inheritedCopy.common.loading}</p>;\n const role = me.role || \"provisional\";\n\n return (\n <>\n <div className=\"card\">\n <div className=\"member-row\">\n <span className=\"member-email\">{me.email}</span>\n <span className={\"role-badge \" + role}>{role}</span>\n </div>\n <div className=\"account-actions\">\n <button className=\"btn secondary mini\" onClick={signOut}>\n {copy.account.signOut}\n </button>\n {role === \"admin\" ? (\n <a className=\"admin-console-link\" href={adminHref}>\n {copy.account.adminConsole}\n </a>\n ) : null}\n </div>\n </div>\n {role === \"provisional\" ? (() => {\n const defaultContent = (\n <ProvisionalCard\n api={api}\n application={me.application}\n applyHref={applyHref}\n copy={copy}\n onReschedule={reload}\n />\n );\n return renderProvisional?.({\n api,\n application: me.application,\n applyHref,\n reload,\n defaultContent,\n }) ?? defaultContent;\n })() : (\n (memberContent ?? (\n <div className=\"card\">\n <div className=\"card-label\">{copy.full.welcome}</div>\n </div>\n ))\n )}\n </>\n );\n}\n","// In-place reschedule: open a SlotPicker, rebook via /api/schedule/book (the same\n// capability the join flow uses; the application id is the credential). Ported\n// from the reference member-area Rescheduler, driven by the injected `api`.\nimport { useState } from \"preact/hooks\";\nimport { SlotPicker } from \"./slot-picker.js\";\nimport type { Slot } from \"./datetime.js\";\nimport type { ApiFn } from \"./api.js\";\nimport type { ChapterCopy } from \"../copy.js\";\nimport { useChapterCopy } from \"./copy-context.js\";\n\ninterface SlotsResponse {\n schedulingReady?: boolean;\n slots?: Slot[];\n timezone?: string;\n}\n\n/** Props for {@link Rescheduler}. */\nexport interface RescheduleProps {\n api: ApiFn;\n applicationId: string;\n timezone: string;\n /** Called after a successful (re)booking so the caller can refresh /api/me. */\n onRescheduled: () => void | Promise<void>;\n /** Link text to open the picker (e.g. \"Choose a time\" for a first booking). */\n label?: string;\n /** Resolved rescheduling copy. */\n copy?: ChapterCopy[\"members\"][\"reschedule\"];\n}\n\n/** A collapsed \"change your time\" link that expands into a {@link SlotPicker} and\n * rebooks on pick. Degrades to a message when scheduling is unavailable. */\nexport function Rescheduler(props: RescheduleProps) {\n const inheritedCopy = useChapterCopy();\n const copy = props.copy ?? inheritedCopy.members.reschedule;\n const { api, applicationId, timezone, onRescheduled, label = copy.changeTime } = props;\n const [open, setOpen] = useState(false);\n const [slots, setSlots] = useState<Slot[] | null>(null);\n const [tz, setTz] = useState(timezone);\n const [busy, setBusy] = useState(false);\n const [msg, setMsg] = useState<string | null>(null);\n\n const start = async () => {\n setOpen(true);\n setSlots(null);\n setMsg(null);\n try {\n const r = await api<SlotsResponse>(\"/api/schedule/slots\");\n if (r.schedulingReady === false) {\n setSlots([]);\n setMsg(copy.unavailable);\n return;\n }\n setSlots(r.slots ?? []);\n if (r.timezone) setTz(r.timezone);\n } catch {\n setSlots([]);\n setMsg(copy.loadFailed);\n }\n };\n\n const pick = async (slot: Slot) => {\n setBusy(true);\n setMsg(null);\n try {\n await api(\"/api/schedule/book\", { method: \"POST\", body: JSON.stringify({ applicationId, startAt: slot.startAt }) });\n setOpen(false);\n await onRescheduled();\n } catch (e) {\n setMsg(e instanceof Error ? e.message : copy.slotGone);\n } finally {\n setBusy(false);\n }\n };\n\n if (!open) {\n return (\n <p className=\"meeting-note\">\n <a\n href=\"#\"\n onClick={(e) => {\n e.preventDefault();\n void start();\n }}\n >\n {label}\n </a>\n </p>\n );\n }\n return (\n <div className=\"msched\">\n {slots === null ? (\n <p className=\"meeting-note\">{copy.loading}</p>\n ) : slots.length === 0 ? (\n <p className=\"meeting-note\">{msg ?? copy.noTimes}</p>\n ) : (\n <SlotPicker\n slots={slots}\n timezone={tz}\n classes={{ days: \"msched-days\", day: \"msched-day\", times: \"msched-times\", time: \"msched-time\" }}\n onPick={(s) => void pick(s)}\n />\n )}\n {busy ? <p className=\"meeting-note\">{copy.rescheduling}</p> : null}\n {msg && slots && slots.length > 0 ? <p className=\"meeting-note error\">{msg}</p> : null}\n <p className=\"meeting-note\">\n <a\n href=\"#\"\n onClick={(e) => {\n e.preventDefault();\n setOpen(false);\n }}\n >\n {copy.keepTime}\n </a>\n </p>\n </div>\n );\n}\n","// The join island — the signup flow orchestrator. The SITE provides the form\n// fields (as children); this owns the flow: submit → /api/applications →\n// (paymentsReady) the Stripe PaymentStep → (schedulingReady) the SlotPicker\n// booking → confirmation. Faithful to the reference join flow, but the flow +\n// payment + booking are packaged instead of hand-rolled per site.\nimport type { ComponentChildren, JSX } from \"preact\";\nimport { useEffect, useRef, useState } from \"preact/hooks\";\nimport { PaymentStep } from \"./payment-step.js\";\nimport { fullLabel } from \"./datetime.js\";\nimport type { ChapterCopy } from \"../copy.js\";\nimport { useChapterCopy } from \"./copy-context.js\";\nimport { collectFormFields } from \"./form-fields.js\";\nimport { JoinBooking } from \"./join-booking.js\";\nimport { TierPlaceholder, tierNeedsPayment, useTierSelection } from \"./join-tiers.js\";\nimport type { JoinTier, JoinTierRenderContext } from \"./join-tiers.js\";\n\nexport type { JoinTier, JoinTierRenderContext };\n\n/** The public join config (the shape `GET /api/join-config` returns). */\nexport interface JoinConfig {\n id: string;\n name: string;\n paymentsReady: boolean;\n refundPolicyText?: string;\n /** Offered membership tiers, in display order. Empty on a chapter that\n * declares none, in which case no tier is posted and nothing renders. */\n tiers?: readonly JoinTier[];\n /** Resolved copy for the packaged join flow. */\n copy?: ChapterCopy[\"join\"];\n}\n\n\n/** Server-validated state used to resume a join journey after a redirect. */\nexport type JoinFlowState =\n | { step: \"form\" }\n | { step: \"payment\"; applicationId: string }\n | { step: \"paymentPending\"; applicationId: string }\n | { step: \"booking\"; applicationId: string }\n | {\n step: \"done\";\n applicationId: string;\n booked: { startAt: number; timezone: string };\n };\n\n/** Canonical flow state supplied to a site's per-step heading render slot. */\nexport interface JoinStepRenderContext {\n state: JoinFlowState;\n applicationId?: string;\n}\n\n/** Submission state supplied to a site's submit-control render slot. */\nexport interface JoinSubmitRenderContext {\n submitting: boolean;\n disabled: boolean;\n}\n\ninterface JoinResumeResponse {\n state: \"payment\" | \"paymentPending\" | \"booking\" | \"done\";\n applicationId: string;\n booked?: { startAt: number; timezone: string };\n}\n\n/** Load canonical server state for a capability-bearing application id. */\nexport async function loadJoinResume(\n applicationId: string,\n fetcher: typeof fetch = fetch,\n): Promise<JoinFlowState> {\n const res = await fetcher(`/api/join/resume?application=${encodeURIComponent(applicationId)}`);\n const data = (await res.json()) as JoinResumeResponse & { error?: string };\n if (!res.ok) throw new Error(data.error ?? \"The application could not be resumed.\");\n if (data.state === \"done\" && data.booked) {\n return { step: \"done\", applicationId: data.applicationId, booked: data.booked };\n }\n if (data.state === \"paymentPending\") {\n return { step: \"paymentPending\", applicationId: data.applicationId };\n }\n if (data.state === \"booking\") {\n return { step: \"booking\", applicationId: data.applicationId };\n }\n return { step: \"payment\", applicationId: data.applicationId };\n}\n\n/** Props for {@link JoinIsland}. */\nexport interface JoinIslandProps {\n config: JoinConfig;\n /** The site's application form fields — inputs with `name` attributes; their\n * values are collected via FormData and posted to /api/applications. */\n children: ComponentChildren;\n /** Where the confirmation links after booking. Default \"/members/\". */\n membersHref?: string;\n /** Resolved join copy. Defaults to `config.copy`, then the nearest provider. */\n copy?: ChapterCopy[\"join\"];\n /** Trusted initial state produced by the server, never raw URL parameters. */\n initialState?: JoinFlowState;\n /** Resolve redirect/query state against the server before resuming the flow. */\n loadResume?: () => Promise<JoinFlowState | null>;\n /** Render a heading or other site-owned framing above each packaged step. */\n renderStepHeader?: (context: JoinStepRenderContext) => ComponentChildren;\n /** Replace the packaged completion card while retaining flow orchestration. */\n renderDone?: (\n context: Extract<JoinFlowState, { step: \"done\" }> & { membersHref: string },\n ) => ComponentChildren;\n /** Replace the submit control without replacing the application form. */\n renderSubmit?: (context: JoinSubmitRenderContext) => ComponentChildren;\n /** Render the site's own tier chooser. Omitted, the flow still works and\n * emits an unstyled placeholder meant to be replaced, never shipped. */\n renderTiers?: (context: JoinTierRenderContext) => ComponentChildren;\n /** Preselect a tier, e.g. from a pricing page link. Ignored if not offered.\n * With exactly one offered tier the selection is implicit and needs no UI. */\n initialTierId?: string;\n /** Additional host validation gate for the submit action. */\n submitDisabled?: boolean;\n /** Stripe Elements presentation and site-owned payment content. */\n payment?: {\n appearance?: Record<string, unknown>;\n fonts?: readonly Record<string, unknown>[];\n renderPriceLines?: (lines: {\n standardCents: number;\n discountCents: number;\n dueTodayCents: number;\n }) => ComponentChildren;\n children?: ComponentChildren;\n };\n}\n\n/** The signup island. Renders the site's form, keeps one application\n * `submissionId` across ambiguous retries, then drives payment (when the\n * chapter charges) and booking (when a calendar is connected) to confirmation. */\nexport function JoinIsland(props: JoinIslandProps) {\n const inheritedCopy = useChapterCopy();\n const {\n config,\n children,\n membersHref = \"/members/\",\n renderStepHeader,\n renderDone,\n renderSubmit,\n } = props;\n const copy = props.copy ?? config.copy ?? inheritedCopy.join;\n const tiers = config.tiers ?? [];\n const tierSelection = useTierSelection(tiers, props.initialTierId);\n const { selectedTierId, selected: selectedTier } = tierSelection;\n const [state, setState] = useState<JoinFlowState>(props.initialState ?? { step: \"form\" });\n const [error, setError] = useState<string | null>(null);\n const [submitting, setSubmitting] = useState(false);\n // One logical form journey owns one idempotency key. Keep it across explicit\n // errors and ambiguous lost responses so a retry cannot create another row.\n const submissionId = useRef<string | null>(null);\n\n useEffect(() => {\n const resolver = props.loadResume ?? (() => {\n if (typeof window === \"undefined\") return Promise.resolve(null);\n const applicationId = new URL(window.location.href).searchParams.get(\"application\");\n return applicationId ? loadJoinResume(applicationId) : Promise.resolve(null);\n });\n let live = true;\n void resolver()\n .then((resumed) => {\n if (live && resumed) setState(resumed);\n })\n .catch(() => {\n if (live) setError(copy.form.unexpectedFailure);\n });\n return () => {\n live = false;\n };\n }, [props.loadResume]);\n\n useEffect(() => {\n if (state.step !== \"paymentPending\") return;\n let live = true;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const poll = async () => {\n try {\n const resumed = props.loadResume\n ? await props.loadResume()\n : await loadJoinResume(state.applicationId);\n if (!live || !resumed) return;\n setState(resumed);\n if (resumed.step === \"paymentPending\") timer = setTimeout(() => void poll(), 1500);\n } catch {\n if (live) timer = setTimeout(() => void poll(), 2500);\n }\n };\n timer = setTimeout(() => void poll(), 1000);\n return () => {\n live = false;\n if (timer) clearTimeout(timer);\n };\n }, [state, props.loadResume]);\n\n const submit = async (e: JSX.TargetedSubmitEvent<HTMLFormElement>) => {\n e.preventDefault();\n if (submitting || props.submitDisabled === true) return;\n setSubmitting(true);\n setError(null);\n try {\n const fields = collectFormFields(new FormData(e.currentTarget));\n fields.submissionId = submissionId.current ??= crypto.randomUUID();\n if (selectedTierId) fields.tierId = selectedTierId;\n const res = await fetch(\"/api/applications\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(fields),\n });\n const data = (await res.json()) as { id?: string; error?: string };\n if (!res.ok || !data.id) throw new Error(data.error ?? copy.form.submitFailed);\n // The server reaches the same conclusion independently on resume.\n setState({\n step: tierNeedsPayment(selectedTier, config.paymentsReady) ? \"payment\" : \"booking\",\n applicationId: data.id,\n });\n } catch (err) {\n setError(err instanceof Error ? err.message : copy.form.unexpectedFailure);\n } finally {\n setSubmitting(false);\n }\n };\n\n const header = renderStepHeader?.({\n state,\n ...(\"applicationId\" in state ? { applicationId: state.applicationId } : {}),\n });\n if (state.step === \"done\") {\n const body = renderDone?.({ ...state, membersHref }) ?? (\n <div className=\"join-done card\">\n <div className=\"card-label\">{copy.done.label}</div>\n <p className=\"meeting-date\">{fullLabel(state.booked.startAt, state.booked.timezone)}</p>\n <p className=\"meeting-note\">{copy.done.calendarInvite}</p>\n <a className=\"apply-link\" href={membersHref}>\n {copy.done.memberArea}\n </a>\n </div>\n );\n return <>{header}{body}</>;\n }\n if (state.step === \"booking\") {\n return (\n <>\n {header}\n <JoinBooking\n applicationId={state.applicationId}\n copy={copy.booking}\n onBooked={(booked) => {\n setState({ step: \"done\", applicationId: state.applicationId, booked });\n }}\n />\n </>\n );\n }\n if (state.step === \"payment\") {\n return (\n <>\n {header}\n <PaymentStep\n applicationId={state.applicationId}\n refundPolicyText={config.refundPolicyText ?? \"\"}\n copy={copy.payment}\n appearance={props.payment?.appearance}\n fonts={props.payment?.fonts}\n renderPriceLines={props.payment?.renderPriceLines}\n onPaid={() => setState({ step: \"booking\", applicationId: state.applicationId })}\n >\n {props.payment?.children}\n </PaymentStep>\n </>\n );\n }\n if (state.step === \"paymentPending\") {\n return (\n <>\n {header}\n <p className=\"pay-status\" role=\"status\">{copy.payment.pending}</p>\n </>\n );\n }\n const submitDisabled = submitting || props.submitDisabled === true;\n // Presentation belongs to the site; the placeholder is a fallback, not a\n // design. One tier needs no chooser at all.\n const tierChooser = tiers.length > 1\n ? props.renderTiers?.(tierSelection) ?? TierPlaceholder(tierSelection)\n : null;\n return (\n <>\n {header}\n <form className=\"join-form\" onSubmit={(e) => void submit(e)}>\n {tierChooser}\n {children}\n {error ? <p className=\"join-error\">{error}</p> : null}\n {renderSubmit?.({ submitting, disabled: submitDisabled }) ?? (\n <button className=\"submit-btn\" type=\"submit\" disabled={submitDisabled}>\n {submitting ? copy.form.submitting : copy.form.submit}\n </button>\n )}\n </form>\n </>\n );\n}\n","// The join flow's payment step. Ports the reference card entry into the island:\n// dynamically loads js.stripe.com (NO @stripe/react-stripe-js dep), creates a\n// subscription server-side, and mounts a Stripe Payment Element. The refund-policy\n// checkbox is the gate — checking it starts the (money-creating) subscription\n// call. Client success is advisory only; the webhook is the\n// authoritative writer of paid state (see payments.ts).\nimport type { ComponentChildren } from \"preact\";\nimport { useRef, useState } from \"preact/hooks\";\nimport type { ChapterCopy } from \"../copy.js\";\nimport { useChapterCopy } from \"./copy-context.js\";\n\n// Minimal shapes for the dynamically-loaded js.stripe.com global.\ninterface StripeElementsApi {\n create(type: string): { mount(target: HTMLElement): void };\n}\ninterface StripeApi {\n elements(opts: {\n clientSecret: string;\n appearance?: Record<string, unknown>;\n fonts?: readonly Record<string, unknown>[];\n }): StripeElementsApi;\n confirmPayment(opts: {\n elements: StripeElementsApi;\n confirmParams?: { return_url?: string };\n redirect?: \"if_required\";\n }): Promise<{ error?: { message?: string }; paymentIntent?: { status?: string } }>;\n}\ntype StripeFactory = (publishableKey: string) => StripeApi;\n\nlet loader: Promise<StripeFactory> | null = null;\n\n/** Load js.stripe.com once and resolve the `Stripe` global (browser only). */\nfunction loadStripe(): Promise<StripeFactory> {\n const existing = (globalThis as { Stripe?: StripeFactory }).Stripe;\n if (existing) return Promise.resolve(existing);\n if (!loader) {\n loader = new Promise<StripeFactory>((resolve, reject) => {\n const s = document.createElement(\"script\");\n s.src = \"https://js.stripe.com/v3/\";\n s.onload = () => {\n const fn = (globalThis as { Stripe?: StripeFactory }).Stripe;\n if (fn) resolve(fn);\n else reject(new Error(\"stripe.js unavailable\"));\n };\n s.onerror = () => reject(new Error(\"stripe.js failed to load\"));\n document.head.appendChild(s);\n });\n }\n return loader;\n}\n\n/** Props for {@link PaymentStep}. */\nexport interface PaymentStepProps {\n /** The application to attach the subscription to (the capability). */\n applicationId: string;\n /** Refund-policy copy the applicant must acknowledge to start payment. */\n refundPolicyText: string;\n /** Called once the payment succeeds (or is processing) — advance to booking. */\n onPaid: () => void;\n /** Stripe Elements appearance passed through without Chapter reinterpretation. */\n appearance?: Record<string, unknown>;\n /** Stripe Elements custom-font descriptors. */\n fonts?: readonly Record<string, unknown>[];\n /** Resolved payment-step copy. */\n copy?: ChapterCopy[\"join\"][\"payment\"];\n /** Render the server-returned membership price breakdown. */\n renderPriceLines?: (lines: PaymentPriceLines) => ComponentChildren;\n /** Site-owned trust, security, or explanatory content. */\n children?: ComponentChildren;\n}\n\n/** Server-authoritative membership amounts supplied to the payment price slot. */\nexport interface PaymentPriceLines {\n standardCents: number;\n discountCents: number;\n dueTodayCents: number;\n}\n\ninterface SubResponse {\n clientSecret?: string;\n publishableKey?: string | null;\n lineItems?: PaymentPriceLines;\n}\n\n/** The card-entry step: acknowledge the refund policy → create the subscription\n * → mount Stripe Elements → confirm. */\nexport function PaymentStep(props: PaymentStepProps) {\n const inheritedCopy = useChapterCopy();\n const {\n applicationId,\n refundPolicyText,\n onPaid,\n appearance,\n fonts,\n renderPriceLines,\n children,\n } = props;\n const copy = props.copy ?? inheritedCopy.join.payment;\n const [status, setStatus] = useState<\"idle\" | \"loading\" | \"ready\" | \"confirming\">(\"idle\");\n const [error, setError] = useState<string | null>(null);\n const [lineItems, setLineItems] = useState<PaymentPriceLines | null>(null);\n const mountRef = useRef<HTMLDivElement | null>(null);\n const stripeRef = useRef<StripeApi | null>(null);\n const elementsRef = useRef<StripeElementsApi | null>(null);\n\n const begin = async () => {\n setStatus(\"loading\");\n setError(null);\n try {\n const res = await fetch(\"/api/payments/subscription\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ applicationId, refundPolicyAck: true }),\n });\n const data = (await res.json()) as SubResponse;\n if (!res.ok || !data.clientSecret || !data.publishableKey) throw new Error(copy.setupFailed);\n const stripe = (await loadStripe())(data.publishableKey);\n const elements = stripe.elements({\n clientSecret: data.clientSecret,\n ...(appearance ? { appearance } : {}),\n ...(fonts ? { fonts } : {}),\n });\n const element = elements.create(\"payment\");\n if (mountRef.current) element.mount(mountRef.current);\n stripeRef.current = stripe;\n elementsRef.current = elements;\n setLineItems(data.lineItems ?? null);\n setStatus(\"ready\");\n } catch (e) {\n setStatus(\"idle\");\n setError(e instanceof Error ? e.message : copy.setupFailed);\n }\n };\n\n const pay = async () => {\n const stripe = stripeRef.current;\n const elements = elementsRef.current;\n if (!stripe || !elements) return;\n setStatus(\"confirming\");\n setError(null);\n let returnUrl: string | undefined;\n if (typeof window !== \"undefined\") {\n const next = new URL(window.location.href);\n next.searchParams.set(\"application\", applicationId);\n next.searchParams.set(\"redirect_status\", \"succeeded\");\n returnUrl = next.toString();\n }\n const result = await stripe.confirmPayment({ elements, confirmParams: { return_url: returnUrl }, redirect: \"if_required\" });\n if (result.error) {\n setError(result.error.message ?? copy.incomplete);\n setStatus(\"ready\");\n return;\n }\n const paid = result.paymentIntent?.status;\n if (paid === \"succeeded\" || paid === \"processing\") onPaid();\n else {\n setError(copy.incomplete);\n setStatus(\"ready\");\n }\n };\n\n return (\n <div className=\"join-pay\">\n {/*\n The policy is a block of its own and the checkbox carries the\n affirmative sentence, so what the member agrees to is a statement of\n agreement rather than the policy text itself. A site that wants the\n checkbox labelled only by the policy sets `copy.join.payment.consent`\n to an empty string.\n */}\n <div className=\"compliance-box\">\n <p className=\"compliance-policy\">{refundPolicyText}</p>\n <label className=\"compliance-check\">\n <input\n type=\"checkbox\"\n disabled={status !== \"idle\"}\n onChange={(e) => {\n if (e.currentTarget.checked) void begin();\n }}\n />\n {copy.consent ? <span>{copy.consent}</span> : null}\n </label>\n </div>\n {status === \"loading\" ? <p className=\"pay-status\">{copy.preparing}</p> : null}\n {lineItems && renderPriceLines ? renderPriceLines(lineItems) : null}\n {children}\n <div ref={mountRef} hidden={status === \"idle\" || status === \"loading\"} />\n {status === \"ready\" || status === \"confirming\" ? (\n <button className=\"submit-btn\" disabled={status === \"confirming\"} onClick={() => void pay()}>\n {status === \"confirming\" ? copy.processing : copy.payAndContinue}\n </button>\n ) : null}\n {error ? <p className=\"pay-error\">{error}</p> : null}\n </div>\n );\n}\n","import type { ComponentChildren } from \"preact\";\nimport { useEffect, useState } from \"preact/hooks\";\nimport type { ChapterCopy } from \"../copy.js\";\nimport type { Slot } from \"./datetime.js\";\nimport { SlotPicker } from \"./slot-picker.js\";\n\ninterface SlotsResponse {\n schedulingReady?: boolean;\n slots?: Slot[];\n timezone?: string;\n}\n\nexport function JoinBooking(props: {\n applicationId: string;\n copy: ChapterCopy[\"join\"][\"booking\"];\n onBooked: (b: { startAt: number; timezone: string }) => void;\n}): ComponentChildren {\n const { applicationId, copy, onBooked } = props;\n const [state, setState] = useState<{ slots: Slot[]; timezone: string } | null>(null);\n const [msg, setMsg] = useState<string | null>(null);\n const [busy, setBusy] = useState(false);\n const [selected, setSelected] = useState<Slot | null>(null);\n\n const load = async () => {\n setMsg(null);\n try {\n const res = await fetch(\"/api/schedule/slots\");\n const data = (await res.json()) as SlotsResponse;\n if (data.schedulingReady === false || !data.slots?.length) {\n setState(null);\n setMsg(copy.unavailable);\n return;\n }\n setState({ slots: data.slots, timezone: data.timezone ?? \"UTC\" });\n } catch {\n setMsg(copy.loadFailed);\n }\n };\n useEffect(() => {\n void load();\n }, []);\n\n const book = async () => {\n if (!selected) return;\n setBusy(true);\n setMsg(null);\n try {\n const res = await fetch(\"/api/schedule/book\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ applicationId, startAt: selected.startAt }),\n });\n const data = (await res.json()) as { startAt?: number; error?: string; code?: string };\n if (res.status === 409 && data.code === \"calendar_slot_unavailable\") {\n setSelected(null);\n setMsg(copy.slotTaken);\n await load();\n return;\n }\n if (!res.ok) throw new Error(data.error ?? copy.failed);\n onBooked({ startAt: data.startAt ?? selected.startAt, timezone: state?.timezone ?? \"UTC\" });\n } catch (e) {\n setMsg(e instanceof Error ? e.message : copy.failed);\n } finally {\n setBusy(false);\n }\n };\n\n if (!state) return <p className=\"slots-status\">{msg ?? copy.loading}</p>;\n return (\n <div className=\"join-book\">\n <SlotPicker\n slots={state.slots}\n timezone={state.timezone}\n selectedStartAt={selected?.startAt}\n onPick={setSelected}\n onDayChange={() => setSelected(null)}\n />\n <div className=\"slot-confirm\" hidden={!selected}>\n <button className=\"submit-btn\" disabled={busy} onClick={() => void book()}>\n {busy ? copy.booking : copy.book}\n </button>\n {msg ? <p className=\"step2-note\">{msg}</p> : null}\n </div>\n </div>\n );\n}\n","// The tier chooser seam. The package owns which tier is selected, whether it\n// needs paying for, and what gets posted; a site owns entirely what a tier\n// looks like. Everything here exists so the site can replace the visuals\n// without reimplementing the flow.\nimport type { ComponentChildren } from \"preact\";\nimport { useState } from \"preact/hooks\";\n\n/** One membership tier as the public join config exposes it. */\nexport interface JoinTier {\n id: string;\n name: string;\n priceCents: number;\n blurb: string;\n /** True when the tier costs nothing, so the flow skips the payment step. */\n free: boolean;\n}\n\n/**\n * What a site needs to render its own tier chooser.\n *\n * Pass `renderTiers` to take over presentation entirely — the built-in output\n * is an unstyled placeholder, not a design.\n */\nexport interface JoinTierRenderContext {\n /** Offered tiers, in display order. */\n tiers: readonly JoinTier[];\n /** The chosen tier, or null while nothing is chosen. */\n selected: JoinTier | null;\n selectedTierId: string | null;\n /** Choose a tier. Unknown ids are ignored. */\n selectTier: (tierId: string) => void;\n}\n\n/**\n * Track the selected tier.\n *\n * A single offered tier is selected implicitly: the choice is unambiguous, so\n * a chooser would be furniture. Nothing is preselected when several are on\n * offer, because defaulting silently picks a price on the applicant's behalf.\n */\nexport function useTierSelection(\n tiers: readonly JoinTier[],\n initialTierId?: string,\n): JoinTierRenderContext {\n const [selectedTierId, setSelectedTierId] = useState<string | null>(() => {\n const preset = tiers.find((tier) => tier.id === initialTierId);\n if (preset) return preset.id;\n return tiers.length === 1 ? tiers[0]!.id : null;\n });\n return {\n tiers,\n selected: tiers.find((tier) => tier.id === selectedTierId) ?? null,\n selectedTierId,\n selectTier: (tierId: string) => {\n if (tiers.some((tier) => tier.id === tierId)) setSelectedTierId(tierId);\n },\n };\n}\n\n/**\n * The unstyled fallback chooser.\n *\n * Deliberately plain and self-labelling: the flow stays usable before a site\n * has designed anything, and it is obvious on sight that this was never meant\n * to ship. Sites replace it wholesale via `renderTiers`; the `data-*` hook is\n * there so a build can assert no placeholder survives into production.\n */\nexport function TierPlaceholder(context: JoinTierRenderContext): ComponentChildren {\n return (\n <fieldset data-chapter-placeholder=\"tiers\">\n <legend>Membership (placeholder — pass renderTiers to style this)</legend>\n {context.tiers.map((tier) => (\n <label key={tier.id}>\n <input\n type=\"radio\"\n name=\"__chapterTier\"\n value={tier.id}\n checked={context.selectedTierId === tier.id}\n onChange={() => context.selectTier(tier.id)}\n />\n {tier.name}\n </label>\n ))}\n </fieldset>\n );\n}\n\n/**\n * Whether the flow should charge for this submission.\n *\n * A free tier skips payment even on a chapter otherwise wired for it. With no\n * tier in play the chapter-wide readiness decides, which is how every chapter\n * behaved before tiers existed.\n */\nexport function tierNeedsPayment(\n selected: JoinTier | null,\n paymentsReady: boolean,\n): boolean {\n return selected ? !selected.free && paymentsReady : paymentsReady;\n}\n"],"mappings":";;;;;;;;;AAQA,SAAS,SAAS,gBAAgB;;;ACK3B,SAAS,QAAQ,IAAoB;AAC1C,MAAI;AACF,UAAM,QAAQ,IAAI,KAAK,eAAe,QAAW,EAAE,UAAU,IAAI,cAAc,QAAQ,CAAC,EAAE;AAAA,MACxF,oBAAI,KAAK;AAAA,IACX;AACA,WAAO,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,cAAc,GAAG,SAAS;AAAA,EAChE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIO,SAAS,OAAO,IAAY,IAAoB;AACrD,SAAO,IAAI,KAAK,EAAE,EAAE,mBAAmB,SAAS,EAAE,UAAU,GAAG,CAAC;AAClE;AAGO,SAAS,SAAS,IAAY,IAAoB;AACvD,SAAO,IAAI,KAAK,EAAE,EAAE,mBAAmB,QAAW,EAAE,UAAU,IAAI,SAAS,SAAS,OAAO,SAAS,KAAK,UAAU,CAAC;AACtH;AAGO,SAAS,UAAU,IAAY,IAAoB;AACxD,SAAO,IAAI,KAAK,EAAE,E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YAAO,WAAU,cAAa,MAAK,UAAS,UAAU,gBACpD,uBAAa,KAAK,KAAK,aAAa,KAAK,KAAK,QACjD;AAAA,OAEJ;AAAA,KACF;AAEJ;","names":["useState","useState","jsx","jsxs","useState","Fragment","jsx","jsxs","useState","useEffect","useRef","useState","useState","jsx","jsxs","useState","useEffect","useState","jsx","jsxs","useState","useEffect","useState","jsx","jsxs","Fragment","jsx","jsxs","useState","useRef","useEffect"]}
@@ -1,7 +1,25 @@
1
- import { CrmConfig, Crm } from '@odla-ai/crm';
1
+ import { CrmConfig, Crm, FieldConditions } from '@odla-ai/crm';
2
2
  import * as preact from 'preact';
3
3
  import { ComponentChildren } from 'preact';
4
4
 
5
+ /**
6
+ * A tier as declared in `defineChapter`, before it becomes a row.
7
+ *
8
+ * `groupId` is absent here because the chapter owns exactly one group at seed
9
+ * time; the seeder fills it in.
10
+ */
11
+ interface ChapterTierConfig {
12
+ id: string;
13
+ name: string;
14
+ priceCents: number;
15
+ stripePriceId?: string;
16
+ blurb?: string;
17
+ /** Defaults to declaration order when omitted. */
18
+ sortOrder?: number;
19
+ /** Defaults to true; set false to retire a tier without deleting it. */
20
+ active?: boolean;
21
+ }
22
+
5
23
  type TextFields$1<Key extends string> = {
6
24
  [Field in Key]: string;
7
25
  };
@@ -148,6 +166,30 @@ interface ResolvedNetwork {
148
166
  readers: readonly ResolvedNetworkReader[];
149
167
  }
150
168
 
169
+ /**
170
+ * Membership pricing for the group row (chapter mode).
171
+ *
172
+ * This is the single-price model that predates tiers. It still seeds the group
173
+ * row and remains the fallback a chapter reads when it declares no tiers, so
174
+ * existing chapters keep working; new work should prefer `tiers`.
175
+ */
176
+ interface ChapterPrices {
177
+ standardCents: number;
178
+ foundingDiscountCents?: number;
179
+ /** ISO currency, default "usd". */
180
+ currency?: string;
181
+ /** Billing interval, default "year". */
182
+ interval?: "year" | "month";
183
+ }
184
+ /** Membership policy + compliance copy stored on the group row. */
185
+ interface ChapterPolicy {
186
+ disclaimerText?: string;
187
+ refundPolicyText?: string;
188
+ trustCopy?: string;
189
+ commitmentText?: string;
190
+ normsText?: string;
191
+ }
192
+
151
193
  /** Which feature profile a site runs. `chapter` is the full public member site
152
194
  * (join, Stripe membership, booking, member area, admin, CRM); `hub` is
153
195
  * admin-only and CRM-focused (a directory/registry over the same CRM). */
@@ -253,23 +295,7 @@ interface ChapterBrand {
253
295
  }>>;
254
296
  logos?: string;
255
297
  }
256
- /** Membership pricing for the group row (chapter mode). */
257
- interface ChapterPrices {
258
- standardCents: number;
259
- foundingDiscountCents?: number;
260
- /** ISO currency, default "usd". */
261
- currency?: string;
262
- /** Billing interval, default "year". */
263
- interval?: "year" | "month";
264
- }
265
- /** Membership policy + compliance copy stored on the group row. */
266
- interface ChapterPolicy {
267
- disclaimerText?: string;
268
- refundPolicyText?: string;
269
- trustCopy?: string;
270
- commitmentText?: string;
271
- normsText?: string;
272
- }
298
+
273
299
  /** One owner-editable transactional email template. */
274
300
  interface EmailTemplate {
275
301
  subject: string;
@@ -351,6 +377,11 @@ interface ResolvedPipeline {
351
377
  interface ChapterApplication {
352
378
  required?: readonly string[];
353
379
  optional?: readonly string[];
380
+ /** Per-field CEL conditions — show a field, or demand it, based on the
381
+ * answers so far. Enforced server-side as well as rendered, so a hidden
382
+ * field is never demanded and a conditionally-required one cannot be
383
+ * skipped by posting directly. Validated when the chapter is defined. */
384
+ conditions?: Record<string, FieldConditions>;
354
385
  /** Per-field character cap. Fields not listed use `defaultMaxLen`. */
355
386
  maxLen?: Record<string, number>;
356
387
  defaultMaxLen?: number;
@@ -391,6 +422,8 @@ interface ResolvedApplication {
391
422
  crmFields: readonly string[];
392
423
  maxArrayLen: number;
393
424
  validateEmail: boolean;
425
+ /** Resolved per-field conditions. Empty means every field is unconditional. */
426
+ conditions: Record<string, FieldConditions>;
394
427
  }
395
428
  /** The `defineChapter()` config a site fills in. */
396
429
  interface ChapterConfig {
@@ -412,8 +445,10 @@ interface ChapterConfig {
412
445
  /** Enable a public, host-rendered formation application workflow. */
413
446
  formation?: LeaderFormationConfig;
414
447
  thesis?: unknown;
415
- /** Required in `chapter` mode. */
448
+ /** Required in `chapter` mode, and the fallback when `tiers` is empty. */
416
449
  prices?: ChapterPrices;
450
+ /** Membership tiers. A tier priced at 0 is free and never touches Stripe. */
451
+ tiers?: ChapterTierConfig[];
417
452
  policy?: ChapterPolicy;
418
453
  /** `notificationEmail` required in `chapter` mode. */
419
454
  emails?: ChapterEmails;