@wodira/browser 1.2.2 → 1.3.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/dist/ui/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  __export,
3
+ __preload,
3
4
  __chunks,
4
5
  css,
5
6
  html,
@@ -10,14 +11,15 @@ import {
10
11
  } from "./index-1zshfsk6.js";
11
12
  import {
12
13
  wodiraUiStyles,
14
+ waiverDocumentStyles,
13
15
  WodiraShirtAuction2,
14
16
  defineWodiraShirtElements2
15
- } from "./index-bjb0t7yn.js";
17
+ } from "./index-4eecjr6y.js";
16
18
  import {
17
19
  WodiraRoute3d2,
18
20
  defineWodiraRouteElements2
19
21
  } from "./index-3qe91gk8.js";
20
- __chunks(import.meta.url,["4nanjhzx","1zshfsk6","bjb0t7yn","3qe91gk8","jyks1h8f","rn3jgtqn","xdhg885t"],[["./index.js",1,2,3],["./index-1zshfsk6.js"],["./index-bjb0t7yn.js",1],["./index-3qe91gk8.js",1],["./shirt-3d-renderer-jyks1h8f.js",6],["./map-view-rn3jgtqn.js",3],["./index-xdhg885t.js"]],0);
22
+ __chunks(import.meta.url,["10wnpxb1","kemkgn03","1zshfsk6","4eecjr6y","3qe91gk8","jyks1h8f","rn3jgtqn","xdhg885t"],[["./index.js",2,3,4],["./waiver-document-kemkgn03.js"],["./index-1zshfsk6.js"],["./index-4eecjr6y.js",2],["./index-3qe91gk8.js",2],["./shirt-3d-renderer-jyks1h8f.js",7],["./map-view-rn3jgtqn.js",4],["./index-xdhg885t.js"]],0);
21
23
 
22
24
  // ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/iso.js
23
25
  var exports_iso = {};
@@ -116,6 +118,7 @@ var es = {
116
118
  invalidSelection: "Selecciona una opción válida",
117
119
  invalidUrl: "URL inválida",
118
120
  inviteLater: "Invitar después",
121
+ inviteLaterRequiresSignature: "Esta inscripción puede requerir una firma antes del pago. Completa los datos de esta plaza ahora.",
119
122
  inviteLaterUnavailable: "Ya no es posible completar participantes después del pago.",
120
123
  loadingEvent: "Cargando evento…",
121
124
  loadingEvents: "Cargando eventos…",
@@ -133,6 +136,8 @@ var es = {
133
136
  priceTiers: "Tramos de precio",
134
137
  readLess: "Ver menos",
135
138
  readMore: "Leer más",
139
+ closeWaiverDocument: "Cerrar",
140
+ readWaiverDocument: "Leer documento",
136
141
  registerData: "Datos de inscripción",
137
142
  registrationReceiptEmail: "Email de la inscripción",
138
143
  registrationReceiptFound: "Inscripción encontrada",
@@ -248,6 +253,7 @@ var en = {
248
253
  invalidSelection: "Select a valid option",
249
254
  invalidUrl: "Invalid URL",
250
255
  inviteLater: "Invite later",
256
+ inviteLaterRequiresSignature: "This registration may require a signature before payment. Complete this participant’s details now.",
251
257
  inviteLaterUnavailable: "Participants can no longer complete their details after payment.",
252
258
  loadingEvent: "Loading event…",
253
259
  loadingEvents: "Loading events…",
@@ -265,6 +271,8 @@ var en = {
265
271
  priceTiers: "Price tiers",
266
272
  readLess: "Show less",
267
273
  readMore: "Read more",
274
+ closeWaiverDocument: "Close",
275
+ readWaiverDocument: "Read document",
268
276
  registerData: "Registration details",
269
277
  registrationReceiptEmail: "Registration email",
270
278
  registrationReceiptFound: "Registration found",
@@ -6535,10 +6543,6 @@ var deferredTeamCompletionSchema = object({
6535
6543
  message: "Pending participant positions must refer to an existing team slot."
6536
6544
  });
6537
6545
  });
6538
- var teamParticipantCompletionSchema = object({
6539
- athlete: AthleteSchema,
6540
- waiversAccepted: record(string2().nonempty("Waiver ID is required"), boolean2())
6541
- });
6542
6546
  var browserIpEnrichmentValueSchema = object({
6543
6547
  provider: _enum([
6544
6548
  "ipquery",
@@ -6597,6 +6601,26 @@ var legalSignatureSchema = object({
6597
6601
  return points.length >= 8 && Math.max(...xs) - Math.min(...xs) >= 0.08 && Math.max(...ys) - Math.min(...ys) >= 0.03;
6598
6602
  }, { message: "Signature trace is too short" })
6599
6603
  });
6604
+ var teamParticipantLegalSignatureSchema = legalSignatureSchema.extend({ locale: _enum([
6605
+ "es",
6606
+ "en",
6607
+ "pt",
6608
+ "fr"
6609
+ ]).default("es") });
6610
+ var teamParticipantCompletionSchema = object({
6611
+ athlete: AthleteSchema,
6612
+ waiversAccepted: record(string2().nonempty("Waiver ID is required"), boolean2()),
6613
+ customFields: array(object({
6614
+ fieldId: string2().min(1),
6615
+ value: union([
6616
+ boolean2(),
6617
+ number2(),
6618
+ string2(),
6619
+ array(string2())
6620
+ ])
6621
+ })).max(250).optional(),
6622
+ legalSignature: teamParticipantLegalSignatureSchema.optional()
6623
+ });
6600
6624
  var pendingLegalSignatureSchema = union([legalSignatureSchema, object({}).strict().transform(() => {
6601
6625
  return;
6602
6626
  })]);
@@ -6948,7 +6972,17 @@ function eventFormAnswerSchema(field) {
6948
6972
  function matchesRegistrationVisibilityCondition(condition, participants = []) {
6949
6973
  return condition == null || participants.some((answers) => answers.some(({ fieldId, value }) => fieldId === condition.fieldId && value === condition.value));
6950
6974
  }
6951
-
6975
+ function hasParticipantConditionalRegistrationSupplement(supplements, fields, categoryId) {
6976
+ return applicableEventWaivers(supplements, categoryId).some(({ isActive, visibilityCondition }) => {
6977
+ if (isActive === false || visibilityCondition == null)
6978
+ return false;
6979
+ if (typeof visibilityCondition !== "object" || !("fieldId" in visibilityCondition) || !("value" in visibilityCondition) || typeof visibilityCondition.fieldId !== "string" || typeof visibilityCondition.value !== "string" && typeof visibilityCondition.value !== "boolean")
6980
+ return true;
6981
+ const fieldId = visibilityCondition.fieldId;
6982
+ const field = fields.find(({ id }) => id === fieldId);
6983
+ return !field || field.target === "ATHLETE" && field.responseScope !== "REGISTRATION" && applicableEventWaivers([field], categoryId).length > 0;
6984
+ });
6985
+ }
6952
6986
  // src/ui/events.ts
6953
6987
  function emitWodiraEvent(target, name, detail) {
6954
6988
  target.dispatchEvent(new CustomEvent(name, {
@@ -7607,6 +7641,13 @@ var wodiraUiParts = [
7607
7641
  "empty",
7608
7642
  "success",
7609
7643
  "waiver",
7644
+ "waiver-item",
7645
+ "waiver-read",
7646
+ "waiver-dialog",
7647
+ "waiver-dialog-header",
7648
+ "waiver-close",
7649
+ "waiver-document",
7650
+ "waiver-document-plain",
7610
7651
  "supplement",
7611
7652
  "eligibility-summary",
7612
7653
  "participant-mode",
@@ -8077,18 +8118,18 @@ function categoryAvailabilityMessage(category, locale, eventAvailableSpots, requ
8077
8118
 
8078
8119
  class RegistrationWindowElement extends LitElement {
8079
8120
  registrationTimer;
8080
- watchRegistrationWindow(event) {
8121
+ watchRegistrationWindow(event, extraBoundary) {
8081
8122
  clearTimeout(this.registrationTimer);
8082
8123
  if (!event || !this.isConnected)
8083
8124
  return;
8084
8125
  const { opens, closes } = registrationBoundaries(event);
8085
8126
  const now = Date.now();
8086
- const next = Math.min(...[opens, closes + 1].filter((at) => Number.isFinite(at) && at > now));
8127
+ const next = Math.min(...[opens, closes + 1, extraBoundary ?? Infinity].filter((at) => Number.isFinite(at) && at > now));
8087
8128
  if (!Number.isFinite(next))
8088
8129
  return;
8089
8130
  this.registrationTimer = setTimeout(() => {
8090
8131
  this.requestUpdate();
8091
- this.watchRegistrationWindow(event);
8132
+ this.watchRegistrationWindow(event, extraBoundary);
8092
8133
  }, Math.min(next - now, 2147483647));
8093
8134
  }
8094
8135
  disconnectedCallback() {
@@ -8419,7 +8460,7 @@ class WodiraPricingCards extends RegistrationWindowElement {
8419
8460
  }
8420
8461
 
8421
8462
  class WodiraRegistrationForm extends RegistrationWindowElement {
8422
- static styles = [wodiraUiStyles, wodiraLayoutStyles];
8463
+ static styles = [wodiraUiStyles, wodiraLayoutStyles, waiverDocumentStyles];
8423
8464
  static properties = {
8424
8465
  publishableKey: { type: String, attribute: "publishable-key" },
8425
8466
  baseUrl: { type: String, attribute: "base-url" },
@@ -8444,6 +8485,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8444
8485
  pendingParticipantPositions: { state: true },
8445
8486
  customFieldValues: { state: true },
8446
8487
  waiversAccepted: { state: true },
8488
+ waiverDocument: { state: true },
8447
8489
  signatureDraft: { state: true },
8448
8490
  selectedSupplementIds: { state: true },
8449
8491
  supplementSelections: { state: true },
@@ -8505,10 +8547,11 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8505
8547
  disconnectedCallback() {
8506
8548
  clearTimeout(this.summaryTimer);
8507
8549
  this.summaryRequestId++;
8550
+ this.waiverDocument = undefined;
8508
8551
  super.disconnectedCallback();
8509
8552
  }
8510
8553
  updated(changed) {
8511
- this.watchRegistrationWindow(this.event);
8554
+ this.watchRegistrationWindow(this.event, this.deferredTeamCompletionDeadline);
8512
8555
  if (changed.has("eventId") || changed.has("categoryId") || changed.has("publishableKey") || changed.has("baseUrl"))
8513
8556
  this.completedSession = undefined;
8514
8557
  const waiverEntries = this.waiverEntries;
@@ -8516,11 +8559,33 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8516
8559
  if (Object.keys(this.waiversAccepted).some((key) => !visibleWaiverKeys.has(key))) {
8517
8560
  this.waiversAccepted = Object.fromEntries(Object.entries(this.waiversAccepted).filter(([key]) => visibleWaiverKeys.has(key)));
8518
8561
  }
8519
- const signatureKey = JSON.stringify(this.signatureWaivers.map((waiver) => [
8520
- waiver.id,
8521
- waiver.version,
8522
- waiver.visibilityCondition ? waiverEntries.filter((entry) => entry.waiver.id === waiver.id).map(({ guest }) => [this.waiverEntryId(guest), guest?.categoryId ?? this.categoryId]) : null
8523
- ]));
8562
+ const signatureWaivers = this.signatureWaivers;
8563
+ const signatureKey = signatureWaivers.length ? JSON.stringify([
8564
+ signatureWaivers.map(({ id, version }) => [id, version]),
8565
+ [undefined, ...this.guestRegistrations].map((guest) => {
8566
+ const categoryId = guest?.categoryId ?? this.categoryId;
8567
+ const answers = this.conditionAnswers(categoryId, guest);
8568
+ const sharedFieldIds = new Set(this.registrationFields(categoryId).filter((field) => field.responseScope === "REGISTRATION").map((field) => field.id));
8569
+ const sharedAnswers = answers[0]?.filter(({ fieldId }) => sharedFieldIds.has(fieldId));
8570
+ const conditionalWaivers = waiverEntries.filter((entry) => entry.guest === guest && entry.waiver.requiresSignature && entry.waiver.visibilityCondition != null).map(({ waiver }) => waiver);
8571
+ const participants = (guest?.athletes ?? this.athletes).map((athlete, position) => ({ athlete, position })).filter(({ position }) => guest || !this.isParticipantDeferred(position));
8572
+ return [
8573
+ this.waiverEntryId(guest),
8574
+ categoryId,
8575
+ participants.map(({ athlete, position }, index) => [
8576
+ position,
8577
+ athlete.fullname,
8578
+ athlete.idNumber,
8579
+ athlete.email,
8580
+ athlete.birthDate,
8581
+ conditionalWaivers.filter((waiver) => matchesRegistrationVisibilityCondition(waiver.visibilityCondition, [
8582
+ answers[index] ?? [],
8583
+ sharedAnswers ?? []
8584
+ ])).map(({ id }) => id)
8585
+ ])
8586
+ ];
8587
+ })
8588
+ ]) : "";
8524
8589
  if (signatureKey !== this.signatureDocumentKey) {
8525
8590
  this.signatureDocumentKey = signatureKey;
8526
8591
  this.signatureDraft = {
@@ -8548,7 +8613,9 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8548
8613
  if (changed.has("summary") || changed.has("event"))
8549
8614
  this.syncDeferredParticipantPositions();
8550
8615
  const previousAthletes = changed.get("athletes");
8551
- const conditionalAnswersChanged = this.conditionFieldIds(this.categoryId).size > 0 && (changed.has("customFieldValues") || changed.has("pendingParticipantPositions") || changed.has("athletes") && this.athletes.some((athlete, index) => athlete.conditionalFieldValues !== previousAthletes?.[index]?.conditionalFieldValues));
8616
+ const previousValues = changed.get("customFieldValues");
8617
+ const conditionIds = this.conditionFieldIds(this.categoryId);
8618
+ const conditionalAnswersChanged = conditionIds.size > 0 && (changed.has("pendingParticipantPositions") || [...conditionIds].some((id) => changed.has("customFieldValues") && this.customFieldValues[id] !== previousValues?.[id] || changed.has("athletes") && this.athletes.some((athlete, index) => athlete.customFieldValues?.[id] !== previousAthletes?.[index]?.customFieldValues?.[id])));
8552
8619
  if (conditionalAnswersChanged)
8553
8620
  this.syncRequiredSupplements();
8554
8621
  if (changed.has("guestRegistrations"))
@@ -8624,6 +8691,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8624
8691
  </div>
8625
8692
  </div>
8626
8693
  </form>
8694
+ ${this.renderWaiverDocument()}
8627
8695
  `;
8628
8696
  }
8629
8697
  get registrationUnavailableMessage() {
@@ -8638,15 +8706,25 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8638
8706
  const category = this.selectedCategory;
8639
8707
  if (!category || category.teamSize <= 1)
8640
8708
  return false;
8641
- if (this.conditionFieldIds(category.id).size)
8642
- return false;
8643
8709
  const summaryDecision = this.summary?.categoryId === category.id ? this.summary.teamCompletion : undefined;
8644
- if (summaryDecision)
8645
- return summaryDecision.available;
8646
- if (applicableEventWaivers(this.event?.waivers ?? [], category.id).some((waiver) => waiver.visibilityCondition == null && waiver.requiresSignature))
8710
+ if (summaryDecision) {
8711
+ return summaryDecision.available && this.deferredTeamCompletionDeadline > Date.now();
8712
+ }
8713
+ if (this.deferredTeamCompletionBlockedBySignature || hasParticipantConditionalRegistrationSupplement(this.event?.supplements ?? [], this.event?.eventFormFields ?? [], category.id)) {
8647
8714
  return false;
8648
- const eventStart = new Date(this.event?.startDate ?? "").getTime();
8649
- return Number.isFinite(eventStart) && eventStart - 24 * 60 * 60 * 1000 > Date.now();
8715
+ }
8716
+ return this.deferredTeamCompletionDeadline > Date.now();
8717
+ }
8718
+ get deferredTeamCompletionDeadline() {
8719
+ const decision = this.summary?.categoryId === this.categoryId ? this.summary.teamCompletion : undefined;
8720
+ return decision?.deadlineAt ? Date.parse(decision.deadlineAt) : Date.parse(this.event?.startDate ?? "") - 24 * 60 * 60 * 1000;
8721
+ }
8722
+ get deferredTeamCompletionBlockedBySignature() {
8723
+ const categoryId = this.categoryId;
8724
+ const decision = this.summary?.categoryId === categoryId ? this.summary.teamCompletion : undefined;
8725
+ if (decision)
8726
+ return !decision.available && decision.unavailableReason === "SIGNATURE_REQUIRED";
8727
+ return applicableEventWaivers(this.event?.waivers ?? [], categoryId).some(({ requiresSignature, visibilityCondition }) => requiresSignature && visibilityCondition == null);
8650
8728
  }
8651
8729
  isParticipantDeferred(position) {
8652
8730
  return this.pendingParticipantPositions.includes(position);
@@ -8657,24 +8735,33 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8657
8735
  getSupplementsForCategory(categoryId, answers = this.conditionAnswers(categoryId)) {
8658
8736
  return (this.event?.supplements ?? []).filter((supplement) => supplement.isActive !== false && isSupplementAvailableForCategory(supplement, categoryId) && matchesRegistrationVisibilityCondition(supplement.visibilityCondition, answers));
8659
8737
  }
8660
- fieldAnswers(categoryId, values) {
8661
- return (this.event?.eventFormFields ?? []).flatMap((field) => {
8662
- const value = values?.[field.id];
8663
- return !isBlank(value) && isFormFieldTargetAthlete(field) && isFormFieldAvailableForCategory(field, categoryId) ? [{ fieldId: field.id, value }] : [];
8738
+ registrationFields(categoryId) {
8739
+ return (this.event?.eventFormFields ?? []).filter((field) => isFormFieldTargetAthlete(field) && isFormFieldAvailableForCategory(field, categoryId));
8740
+ }
8741
+ isParticipantField(field, conditionIds) {
8742
+ return field.responseScope == null ? conditionIds.has(field.id) : field.responseScope === "PARTICIPANT";
8743
+ }
8744
+ fieldAnswers(categoryId, values, participantOnly = false) {
8745
+ if (!values)
8746
+ return [];
8747
+ const conditionIds = participantOnly ? this.conditionFieldIds(categoryId) : undefined;
8748
+ return this.registrationFields(categoryId).flatMap((field) => {
8749
+ const value = values[field.id];
8750
+ return !isBlank(value) && (!conditionIds || this.isParticipantField(field, conditionIds)) ? [{ fieldId: field.id, value }] : [];
8664
8751
  });
8665
8752
  }
8666
8753
  conditionAnswers(categoryId, guest) {
8667
8754
  const conditionIds = this.conditionFieldIds(categoryId);
8668
- const answersFor = (values) => this.fieldAnswers(categoryId, values).filter(({ fieldId }) => conditionIds.has(fieldId));
8755
+ const answersFor = (values, participantOnly = false) => this.fieldAnswers(categoryId, values, participantOnly).filter(({ fieldId }) => conditionIds.has(fieldId));
8669
8756
  const mainAnswers = answersFor(guest ? guest.customFieldValues : this.customFieldValues);
8670
8757
  const athletes = guest?.athletes ?? this.athletes;
8671
8758
  return [
8672
8759
  mainAnswers,
8673
- ...athletes.slice(1).flatMap((athlete, index) => !guest && this.isParticipantDeferred(index + 1) ? [] : [answersFor(athlete.conditionalFieldValues)])
8760
+ ...athletes.slice(1).flatMap((athlete, index) => !guest && this.isParticipantDeferred(index + 1) ? [] : [answersFor(athlete.customFieldValues, true)])
8674
8761
  ];
8675
8762
  }
8676
8763
  conditionFieldIds(categoryId) {
8677
- const eligibleFields = new Set((this.event?.eventFormFields ?? []).filter((field) => isFormFieldTargetAthlete(field) && isFormFieldAvailableForCategory(field, categoryId)).map((field) => field.id));
8764
+ const eligibleFields = new Set(this.registrationFields(categoryId).map((field) => field.id));
8678
8765
  return new Set([
8679
8766
  ...applicableEventWaivers(this.event?.waivers ?? [], categoryId),
8680
8767
  ...(this.event?.supplements ?? []).filter((supplement) => supplement.isActive !== false && isSupplementAvailableForCategory(supplement, categoryId))
@@ -8843,12 +8930,13 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8843
8930
  const genderLocked = this.isGenderSlotLocked(category, slotPlan, index);
8844
8931
  const genderErrorKey = `athletes.${index}.gender`;
8845
8932
  const deferred = this.isParticipantDeferred(index);
8933
+ const canDefer = this.deferredTeamCompletionAvailable;
8846
8934
  return html`
8847
8935
  <fieldset part="card athlete ${deferred ? "deferred" : ""}">
8848
8936
  <legend part="title" id=${`participant-slot-title-${index}`}>
8849
8937
  ${isTeam ? `${t(this.locale, "participantSlot")} ${index + 1}` : t(this.locale, "participant")}${slotPlan?.[index] ? ` · ${this.genderLabel(slotPlan[index])}` : ""}${isTeam && index === 0 ? ` · ${t(this.locale, "captain")}` : ""}
8850
8938
  </legend>
8851
- ${this.deferredTeamCompletionAvailable && index > 0 ? html`
8939
+ ${(canDefer || deferred) && index > 0 ? html`
8852
8940
  <div
8853
8941
  part="participant-mode"
8854
8942
  role="group"
@@ -8865,15 +8953,18 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8865
8953
  <button
8866
8954
  part="participant-mode-button ${deferred ? "active" : ""}"
8867
8955
  type="button"
8956
+ ?disabled=${!canDefer}
8868
8957
  aria-pressed=${deferred ? "true" : "false"}
8869
8958
  @click=${() => this.setParticipantDeferred(index, true)}
8870
8959
  >
8871
8960
  ${t(this.locale, "inviteLater")}
8872
8961
  </button>
8873
8962
  </div>
8874
- ` : nothing}
8875
- ${deferred ? html`<p part="deferred-participant-hint">
8876
- ${t(this.locale, "deferredParticipantHelp")}
8963
+ ` : isTeam && index > 0 && this.deferredTeamCompletionBlockedBySignature ? html`<p part="deferred-participant-hint">
8964
+ ${t(this.locale, "inviteLaterRequiresSignature")}
8965
+ </p>` : nothing}
8966
+ ${deferred ? html`<p part="deferred-participant-hint" role="status">
8967
+ ${t(this.locale, canDefer ? "deferredParticipantHelp" : "inviteLaterUnavailable")}
8877
8968
  </p>` : html`
8878
8969
  <div part="grid athlete-grid">
8879
8970
  ${this.renderAthleteInput(index, "fullname", t(this.locale, "fullName"), "text", athlete.fullname)}
@@ -8900,7 +8991,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8900
8991
  ${this.renderFieldError(genderErrorKey)}
8901
8992
  </label>
8902
8993
  </div>
8903
- ${index > 0 ? this.renderCustomFields(this.categoryId, undefined, index) : nothing}
8994
+ ${isTeam ? this.renderCustomFields(this.categoryId, undefined, index) : nothing}
8904
8995
  `}
8905
8996
  </fieldset>
8906
8997
  `;
@@ -8931,14 +9022,16 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8931
9022
  }
8932
9023
  renderCustomFields(categoryId = this.categoryId, guestIndex, participantIndex) {
8933
9024
  const conditionIds = this.conditionFieldIds(categoryId);
8934
- const fields = this.event?.eventFormFields.filter((field) => isFormFieldTargetAthlete(field) && isFormFieldAvailableForCategory(field, categoryId) && (participantIndex === undefined || conditionIds.has(field.id))) ?? [];
9025
+ const isTeam = (this.getCategory(categoryId)?.teamSize ?? 1) > 1;
9026
+ const fields = this.registrationFields(categoryId).filter((field) => !isTeam || this.isParticipantField(field, conditionIds) === (participantIndex !== undefined));
8935
9027
  if (!fields.length)
8936
9028
  return nothing;
9029
+ const answerIndex = participantIndex === 0 ? undefined : participantIndex;
8937
9030
  return html`
8938
9031
  <fieldset part="card custom-fields">
8939
9032
  <legend part="title">${t(this.locale, "customFieldsTitle")}</legend>
8940
9033
  <div part="grid custom-fields-grid">
8941
- ${fields.map((field) => this.renderCustomField(field, conditionIds.has(field.id), guestIndex, participantIndex))}
9034
+ ${fields.map((field) => this.renderCustomField(field, conditionIds.has(field.id), guestIndex, answerIndex))}
8942
9035
  </div>
8943
9036
  </fieldset>
8944
9037
  `;
@@ -8946,7 +9039,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
8946
9039
  renderCustomField(field, drivesVisibility, guestIndex, participantIndex) {
8947
9040
  const guest = guestIndex === undefined ? undefined : this.guestRegistrations[guestIndex];
8948
9041
  const athlete = participantIndex === undefined ? undefined : (guest?.athletes ?? this.athletes)[participantIndex];
8949
- const values = participantIndex === undefined ? guest ? guest.customFieldValues ?? {} : this.customFieldValues : athlete?.conditionalFieldValues ?? {};
9042
+ const values = participantIndex === undefined ? guest ? guest.customFieldValues ?? {} : this.customFieldValues : athlete?.customFieldValues ?? {};
8950
9043
  const errorKey = this.customFieldErrorKey(field.id, guestIndex, participantIndex);
8951
9044
  const update = (value) => this.updateCustomField(field.id, value, guestIndex, participantIndex);
8952
9045
  const id = fieldErrorId(errorKey);
@@ -9308,7 +9401,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
9308
9401
  ${this.renderFieldError(genderErrorKey)}
9309
9402
  </label>
9310
9403
  </div>
9311
- ${athleteIndex > 0 ? this.renderCustomFields(this.guestRegistrations[guestIndex]?.categoryId, guestIndex, athleteIndex) : nothing}
9404
+ ${category && category.teamSize > 1 ? this.renderCustomFields(guest.categoryId, guestIndex, athleteIndex) : nothing}
9312
9405
  </fieldset>
9313
9406
  `;
9314
9407
  }
@@ -9371,7 +9464,12 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
9371
9464
  };
9372
9465
  }
9373
9466
  updateSignature(patch) {
9374
- this.signatureDraft = { ...this.signatureDraft, ...patch };
9467
+ const before = this.signatureDraft;
9468
+ const next = { ...before, ...patch };
9469
+ if (before.signerName !== next.signerName || before.signerIdNumber !== next.signerIdNumber || before.minorRelationship !== next.minorRelationship) {
9470
+ next.strokes = [];
9471
+ }
9472
+ this.signatureDraft = next;
9375
9473
  this.clearFieldError("legalSignature");
9376
9474
  }
9377
9475
  renderSignature() {
@@ -9435,7 +9533,12 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
9435
9533
  >` : nothing}
9436
9534
  <wodira-signature-pad
9437
9535
  .locale=${this.locale}
9438
- .resetKey=${this.signatureDocumentKey}
9536
+ .resetKey=${JSON.stringify([
9537
+ this.signatureDocumentKey,
9538
+ this.signatureDraft.signerName,
9539
+ this.signatureDraft.signerIdNumber,
9540
+ this.signatureDraft.minorRelationship
9541
+ ])}
9439
9542
  @wodira:signature-change=${(event) => this.updateSignature({ strokes: event.detail.strokes })}
9440
9543
  ></wodira-signature-pad>
9441
9544
  </section>`;
@@ -9458,22 +9561,76 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
9458
9561
  const acceptanceKey = this.waiverAcceptanceKey(waiver, guest);
9459
9562
  const errorKey = `waivers.${acceptanceKey}`;
9460
9563
  return html`
9461
- <label part="label checkbox waiver">
9462
- <span>
9463
- <input
9464
- part="checkbox"
9465
- type="checkbox"
9466
- .checked=${this.waiversAccepted[acceptanceKey] === true}
9467
- aria-invalid=${this.fieldErrors[errorKey] ? "true" : "false"}
9468
- @change=${(event) => this.updateWaiver(acceptanceKey, event.target.checked)}
9469
- />
9470
- ${waiver.name}${waiver.isRequired ? " *" : ""}
9471
- </span>
9472
- ${waiver.bodyText ? html`<small part="hint">${waiver.bodyText}</small>` : nothing}
9473
- ${this.renderFieldError(errorKey)}
9474
- </label>
9564
+ <div part="waiver-item">
9565
+ <label part="label checkbox waiver">
9566
+ <span>
9567
+ <input
9568
+ part="checkbox"
9569
+ type="checkbox"
9570
+ .checked=${this.waiversAccepted[acceptanceKey] === true}
9571
+ aria-invalid=${this.fieldErrors[errorKey] ? "true" : "false"}
9572
+ @change=${(event) => this.updateWaiver(acceptanceKey, event.target.checked)}
9573
+ />
9574
+ ${waiver.name}${waiver.isRequired ? " *" : ""}
9575
+ </span>
9576
+ ${this.renderFieldError(errorKey)}
9577
+ </label>
9578
+ ${waiver.bodyText?.trim() ? html`<button
9579
+ part="button secondary text-button waiver-read"
9580
+ type="button"
9581
+ aria-haspopup="dialog"
9582
+ aria-label=${`${t(this.locale, "readWaiverDocument")} · ${waiver.name}`}
9583
+ @click=${(event) => this.openWaiverDocument(waiver, event.currentTarget)}
9584
+ >${t(this.locale, "readWaiverDocument")}</button>` : nothing}
9585
+ </div>
9475
9586
  `;
9476
9587
  }
9588
+ renderWaiverDocument() {
9589
+ if (!this.waiverDocument)
9590
+ return nothing;
9591
+ const { title, body, content } = this.waiverDocument;
9592
+ return html`
9593
+ <dialog part="waiver-dialog" aria-labelledby="waiver-document-title"
9594
+ @close=${this.closeWaiverDocument}>
9595
+ <header part="waiver-dialog-header">
9596
+ <h2 id="waiver-document-title">${title}</h2>
9597
+ <button part="button secondary waiver-close" type="button" autofocus
9598
+ @click=${(event) => event.currentTarget.closest("dialog")?.close()}>
9599
+ ${t(this.locale, "closeWaiverDocument")}
9600
+ </button>
9601
+ </header>
9602
+ <div part="waiver-document" tabindex="0">
9603
+ ${content ?? html`<p part="waiver-document-plain">${body}</p>`}
9604
+ </div>
9605
+ </dialog>
9606
+ `;
9607
+ }
9608
+ async openWaiverDocument(waiver, trigger) {
9609
+ const body = waiver.bodyText?.trim();
9610
+ if (!body)
9611
+ return;
9612
+ const document2 = { title: waiver.name, body, trigger };
9613
+ this.waiverDocument = document2;
9614
+ await this.updateComplete;
9615
+ if (this.waiverDocument !== document2 || !this.isConnected)
9616
+ return;
9617
+ const dialog = this.renderRoot.querySelector('[part~="waiver-dialog"]');
9618
+ if (!dialog)
9619
+ return;
9620
+ if (!dialog.open)
9621
+ dialog.showModal();
9622
+ try {
9623
+ const { renderWaiverDocumentBody } = await (__preload("kemkgn03"), import("./waiver-document-kemkgn03.js"));
9624
+ if (this.waiverDocument === document2) {
9625
+ this.waiverDocument = { ...document2, content: renderWaiverDocumentBody(body) };
9626
+ }
9627
+ } catch {}
9628
+ }
9629
+ closeWaiverDocument() {
9630
+ const trigger = this.waiverDocument?.trigger;
9631
+ this.waiverDocument = undefined;
9632
+ trigger?.focus();
9633
+ }
9477
9634
  renderSummary() {
9478
9635
  if (this.summaryError)
9479
9636
  return html`<aside part="card summary">
@@ -9558,7 +9715,8 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
9558
9715
  }
9559
9716
  syncDeferredParticipantPositions() {
9560
9717
  const teamSize = this.selectedCategory?.teamSize ?? 1;
9561
- const next = this.deferredTeamCompletionAvailable ? [...new Set(this.pendingParticipantPositions)].filter((position) => Number.isInteger(position) && position > 0 && position < teamSize).sort((left, right) => left - right) : [];
9718
+ const explicitlyUnavailable = this.summary?.categoryId === this.categoryId && this.summary.teamCompletion?.available === false;
9719
+ const next = explicitlyUnavailable ? [] : this.pendingParticipantPositions.filter((position) => position < teamSize);
9562
9720
  if (JSON.stringify(next) !== JSON.stringify(this.pendingParticipantPositions)) {
9563
9721
  this.pendingParticipantPositions = next;
9564
9722
  }
@@ -9799,7 +9957,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
9799
9957
  updateCustomField(fieldId, value, guestIndex, participantIndex) {
9800
9958
  const updateAthletes = (athletes) => athletes.map((athlete, position) => position === participantIndex ? {
9801
9959
  ...athlete,
9802
- conditionalFieldValues: { ...athlete.conditionalFieldValues, [fieldId]: value }
9960
+ customFieldValues: { ...athlete.customFieldValues, [fieldId]: value }
9803
9961
  } : athlete);
9804
9962
  if (guestIndex === undefined) {
9805
9963
  if (participantIndex === undefined) {
@@ -9854,8 +10012,8 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
9854
10012
  }
9855
10013
  validateRegistrationFields(errors, categoryId, values, guestIndex, participantIndex) {
9856
10014
  const conditions = this.conditionFieldIds(categoryId);
9857
- for (const field of this.event?.eventFormFields ?? []) {
9858
- if (!isFormFieldTargetAthlete(field) || !isFormFieldAvailableForCategory(field, categoryId) || participantIndex !== undefined && !conditions.has(field.id))
10015
+ for (const field of this.registrationFields(categoryId)) {
10016
+ if (participantIndex !== undefined && !this.isParticipantField(field, conditions))
9859
10017
  continue;
9860
10018
  const value = values?.[field.id];
9861
10019
  const input = isCheckboxField(field) && conditions.has(field.id) ? {
@@ -9922,7 +10080,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
9922
10080
  errors[`guestRegistrations.${guestIndex}.categoryId`] = guestUnavailable;
9923
10081
  for (const [athleteIndex, athlete] of guest.athletes.entries()) {
9924
10082
  if (athleteIndex > 0)
9925
- this.validateRegistrationFields(errors, guest.categoryId, athlete.conditionalFieldValues, guestIndex, athleteIndex);
10083
+ this.validateRegistrationFields(errors, guest.categoryId, athlete.customFieldValues, guestIndex, athleteIndex);
9926
10084
  setValidationError(errors, this.locale, `guestRegistrations.${guestIndex}.athletes.${athleteIndex}.fullname`, validateRequiredText(athlete.fullname));
9927
10085
  setValidationError(errors, this.locale, `guestRegistrations.${guestIndex}.athletes.${athleteIndex}.email`, validateEmail(athlete.email, true));
9928
10086
  setValidationError(errors, this.locale, `guestRegistrations.${guestIndex}.athletes.${athleteIndex}.phone`, validateRequiredText(athlete.phone));
@@ -9951,7 +10109,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
9951
10109
  this.validateRegistrationFields(errors, this.categoryId, this.customFieldValues);
9952
10110
  for (const [index, athlete] of this.athletes.entries()) {
9953
10111
  if (index > 0 && !this.isParticipantDeferred(index))
9954
- this.validateRegistrationFields(errors, this.categoryId, athlete.conditionalFieldValues, undefined, index);
10112
+ this.validateRegistrationFields(errors, this.categoryId, athlete.customFieldValues, undefined, index);
9955
10113
  }
9956
10114
  for (const { waiver, guest } of this.waiverEntries) {
9957
10115
  const acceptanceKey = this.waiverAcceptanceKey(waiver, guest);
@@ -9983,8 +10141,8 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
9983
10141
  }));
9984
10142
  }
9985
10143
  checkoutAthlete(athlete, categoryId) {
9986
- const { conditionalFieldValues, ...details } = athlete;
9987
- const customFields = this.fieldAnswers(categoryId, conditionalFieldValues);
10144
+ const { customFieldValues, ...details } = athlete;
10145
+ const customFields = this.fieldAnswers(categoryId, customFieldValues, true);
9988
10146
  return {
9989
10147
  ...details,
9990
10148
  fullname: details.fullname.trim(),
@@ -10005,9 +10163,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
10005
10163
  ...guest.club.trim() ? { club: guest.club.trim() } : {},
10006
10164
  selectedSupplementIds: guest.selectedSupplementIds,
10007
10165
  ...guest.supplementSelections?.length ? { supplementSelections: guest.supplementSelections } : {},
10008
- ...guest.customFieldValues ? {
10009
- customFields: Object.entries(guest.customFieldValues).filter(([fieldId, value]) => !isBlank(value) && this.event?.eventFormFields.some((field) => field.id === fieldId && isFormFieldTargetAthlete(field) && isFormFieldAvailableForCategory(field, guest.categoryId))).map(([fieldId, value]) => ({ fieldId, value }))
10010
- } : {},
10166
+ ...guest.customFieldValues ? { customFields: this.fieldAnswers(guest.categoryId, guest.customFieldValues) } : {},
10011
10167
  waiversAccepted: this.checkoutWaiverAcceptances(guest),
10012
10168
  athletes: guest.athletes.map((athlete) => this.checkoutAthlete(athlete, guest.categoryId))
10013
10169
  }));
@@ -10143,8 +10299,7 @@ class WodiraRegistrationForm extends RegistrationWindowElement {
10143
10299
  eventId: this.eventId,
10144
10300
  categoryId: this.categoryId
10145
10301
  });
10146
- const activeFieldIds = new Set((this.event?.eventFormFields ?? []).filter((field) => isFormFieldTargetAthlete(field) && isFormFieldAvailableForCategory(field, this.categoryId)).map((field) => field.id));
10147
- const customFields = Object.entries(this.customFieldValues).filter(([fieldId, value]) => activeFieldIds.has(fieldId) && !isBlank(value)).map(([fieldId, value]) => ({ fieldId, value }));
10302
+ const customFields = this.fieldAnswers(this.categoryId, this.customFieldValues);
10148
10303
  const client = createClient({
10149
10304
  publishableKey: this.publishableKey.trim(),
10150
10305
  baseUrl: this.baseUrl