@sonordev/site-kit 2.6.3 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5014,6 +5014,735 @@ function CheckoutForm({
5014
5014
  ] })
5015
5015
  ] }) });
5016
5016
  }
5017
+ function loadSquareSDK2(environment) {
5018
+ return new Promise((resolve, reject) => {
5019
+ if (typeof window === "undefined") return reject(new Error("No window"));
5020
+ if (window.Square) return resolve();
5021
+ const script = document.createElement("script");
5022
+ script.src = environment === "sandbox" ? "https://sandbox.web.squarecdn.com/v1/square.js" : "https://web.squarecdn.com/v1/square.js";
5023
+ script.onload = () => resolve();
5024
+ script.onerror = () => reject(new Error("Failed to load Square SDK"));
5025
+ document.head.appendChild(script);
5026
+ });
5027
+ }
5028
+ function resolveCssVar(name, fallback) {
5029
+ if (typeof window === "undefined") return fallback;
5030
+ const value = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
5031
+ return value || fallback;
5032
+ }
5033
+ var SINGLE_TICKET_KEY = "__single__";
5034
+ function EventCheckout({
5035
+ event,
5036
+ schedule: propSchedule,
5037
+ collectPhone = true,
5038
+ maxPerVariant = 10,
5039
+ cardLabel = "Card Details",
5040
+ submitText,
5041
+ onSuccess,
5042
+ onError,
5043
+ className = ""
5044
+ }) {
5045
+ const schedule = propSchedule || event.schedules?.[0] || event?.next_schedule;
5046
+ const variants = React5.useMemo(
5047
+ () => event.variants ?? [],
5048
+ [event.variants]
5049
+ );
5050
+ const hasVariants = variants.length > 0;
5051
+ const currency = event.currency || "USD";
5052
+ const [qty, setQty] = React5.useState(() => {
5053
+ if (hasVariants) {
5054
+ return Object.fromEntries(variants.map((v) => [v.id, 0]));
5055
+ }
5056
+ return { [SINGLE_TICKET_KEY]: 1 };
5057
+ });
5058
+ const [customer, setCustomer] = React5.useState({
5059
+ email: "",
5060
+ name: "",
5061
+ phone: ""
5062
+ });
5063
+ const [loading, setLoading] = React5.useState(false);
5064
+ const [error, setError] = React5.useState(null);
5065
+ const [success, setSuccess] = React5.useState(null);
5066
+ const [processorConfig, setProcessorConfig] = React5.useState(null);
5067
+ const [squareCard, setSquareCard] = React5.useState(null);
5068
+ const [cardReady, setCardReady] = React5.useState(false);
5069
+ const cardContainerRef = React5.useRef(null);
5070
+ const totalQuantity = React5.useMemo(
5071
+ () => Object.values(qty).reduce((sum, n) => sum + (n || 0), 0),
5072
+ [qty]
5073
+ );
5074
+ const lineBreakdown = React5.useMemo(() => {
5075
+ if (!hasVariants) {
5076
+ const q = qty[SINGLE_TICKET_KEY] || 0;
5077
+ const price = event.price ?? 0;
5078
+ return [
5079
+ {
5080
+ key: SINGLE_TICKET_KEY,
5081
+ name: "Ticket",
5082
+ unitPrice: price,
5083
+ quantity: q,
5084
+ subtotal: price * q,
5085
+ variantId: null
5086
+ }
5087
+ ];
5088
+ }
5089
+ return variants.map((v) => {
5090
+ const q = qty[v.id] || 0;
5091
+ const price = v.price ?? event.price ?? 0;
5092
+ return {
5093
+ key: v.id,
5094
+ name: v.name,
5095
+ unitPrice: price,
5096
+ quantity: q,
5097
+ subtotal: price * q,
5098
+ variantId: v.id
5099
+ };
5100
+ });
5101
+ }, [variants, qty, hasVariants, event.price]);
5102
+ const subtotal = lineBreakdown.reduce((s, l) => s + l.subtotal, 0);
5103
+ const spotsRemaining = schedule ? getSpotsRemaining(schedule.capacity, schedule.current_registrations ?? void 0) ?? schedule.spots_remaining ?? null : null;
5104
+ const soldOut = schedule ? isEventSoldOut(schedule.capacity, schedule.current_registrations ?? void 0) : false;
5105
+ const overCapacity = spotsRemaining !== null && totalQuantity > spotsRemaining;
5106
+ React5.useEffect(() => {
5107
+ let cancelled = false;
5108
+ let attachedCard = null;
5109
+ fetchProcessorConfig().then(async (config) => {
5110
+ if (cancelled) return;
5111
+ setProcessorConfig(config);
5112
+ if (config?.processor !== "square" || !config.squareAppId || !config.squareLocationId) {
5113
+ return;
5114
+ }
5115
+ try {
5116
+ await loadSquareSDK2(config.squareEnvironment || "production");
5117
+ if (cancelled) return;
5118
+ const Square = window.Square;
5119
+ const payments = Square.payments(config.squareAppId, config.squareLocationId);
5120
+ const card = await payments.card({
5121
+ style: {
5122
+ ".input-container": {
5123
+ borderColor: resolveCssVar("--sk-border", "#d1d5db"),
5124
+ borderRadius: "6px"
5125
+ },
5126
+ ".input-container.is-focus": {
5127
+ borderColor: resolveCssVar("--sk-primary", "#2563eb")
5128
+ },
5129
+ ".input-container.is-error": {
5130
+ borderColor: "#dc2626"
5131
+ }
5132
+ }
5133
+ });
5134
+ if (cancelled) {
5135
+ await card.destroy?.().catch(() => {
5136
+ });
5137
+ return;
5138
+ }
5139
+ await card.attach("#sk-event-checkout-card");
5140
+ attachedCard = card;
5141
+ setSquareCard(card);
5142
+ setCardReady(true);
5143
+ } catch (err) {
5144
+ console.error("[EventCheckout] Square card init failed:", err);
5145
+ }
5146
+ });
5147
+ return () => {
5148
+ cancelled = true;
5149
+ if (attachedCard) {
5150
+ attachedCard.destroy?.().catch(() => {
5151
+ });
5152
+ }
5153
+ setSquareCard(null);
5154
+ setCardReady(false);
5155
+ };
5156
+ }, []);
5157
+ const updateQty = (key, delta) => {
5158
+ setQty((prev) => {
5159
+ const current = prev[key] ?? 0;
5160
+ const next = Math.max(0, Math.min(maxPerVariant, current + delta));
5161
+ return { ...prev, [key]: next };
5162
+ });
5163
+ setError(null);
5164
+ };
5165
+ const updateCustomer = (field, value) => {
5166
+ setCustomer((prev) => ({ ...prev, [field]: value }));
5167
+ };
5168
+ const handleSubmit = async (e) => {
5169
+ e.preventDefault();
5170
+ setError(null);
5171
+ if (!schedule) {
5172
+ setError("No event date available");
5173
+ return;
5174
+ }
5175
+ if (totalQuantity === 0) {
5176
+ setError("Select at least one ticket");
5177
+ return;
5178
+ }
5179
+ if (overCapacity) {
5180
+ setError(
5181
+ `Only ${spotsRemaining} spot${spotsRemaining === 1 ? "" : "s"} remaining. Please reduce quantity.`
5182
+ );
5183
+ return;
5184
+ }
5185
+ if (!customer.name || !customer.email) {
5186
+ setError("Name and email are required");
5187
+ return;
5188
+ }
5189
+ if (processorConfig?.processor !== "square") {
5190
+ setError("Inline checkout requires Square. Please contact support.");
5191
+ return;
5192
+ }
5193
+ if (!squareCard || !cardReady) {
5194
+ setError("Card form is still loading. Please wait a moment and try again.");
5195
+ return;
5196
+ }
5197
+ setLoading(true);
5198
+ try {
5199
+ const tokenResult = await squareCard.tokenize();
5200
+ if (tokenResult.status !== "OK") {
5201
+ const msg = tokenResult.errors?.[0]?.message || "Card verification failed. Please check your card details.";
5202
+ setError(msg);
5203
+ onError?.(msg);
5204
+ setLoading(false);
5205
+ return;
5206
+ }
5207
+ const lineItems = lineBreakdown.filter((l) => l.quantity > 0).map((l) => ({
5208
+ offeringId: event.id,
5209
+ variantId: l.variantId ?? void 0,
5210
+ scheduleId: schedule.id,
5211
+ quantity: l.quantity
5212
+ }));
5213
+ const result = await createCheckoutSession({
5214
+ offeringId: event.id,
5215
+ lineItems,
5216
+ customer,
5217
+ sourceId: tokenResult.token,
5218
+ successUrl: typeof window !== "undefined" ? window.location.href + "?registration=success" : void 0,
5219
+ cancelUrl: typeof window !== "undefined" ? window.location.href : void 0
5220
+ });
5221
+ if (result.success) {
5222
+ setSuccess(result);
5223
+ onSuccess?.(result);
5224
+ } else {
5225
+ setError(result.error || "Checkout failed");
5226
+ onError?.(result.error || "Checkout failed");
5227
+ }
5228
+ } catch (err) {
5229
+ const message = err instanceof Error ? err.message : "An error occurred";
5230
+ setError(message);
5231
+ onError?.(message);
5232
+ } finally {
5233
+ setLoading(false);
5234
+ }
5235
+ };
5236
+ if (success) {
5237
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5238
+ "div",
5239
+ {
5240
+ className: `site-kit-event-checkout-success ${className}`,
5241
+ style: {
5242
+ padding: "2rem",
5243
+ textAlign: "center",
5244
+ background: "var(--sk-bg, #fff)",
5245
+ border: "1px solid var(--sk-border, #e5e7eb)",
5246
+ borderRadius: "12px"
5247
+ },
5248
+ children: [
5249
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: "3rem", marginBottom: "0.75rem" }, children: "\u{1F39F}\uFE0F" }),
5250
+ /* @__PURE__ */ jsxRuntime.jsx(
5251
+ "h3",
5252
+ {
5253
+ style: {
5254
+ margin: "0 0 0.5rem",
5255
+ fontSize: "1.5rem",
5256
+ color: "var(--sk-text-primary, #111)"
5257
+ },
5258
+ children: "You're booked!"
5259
+ }
5260
+ ),
5261
+ /* @__PURE__ */ jsxRuntime.jsxs(
5262
+ "p",
5263
+ {
5264
+ style: {
5265
+ margin: "0 0 0.5rem",
5266
+ color: "var(--sk-text-secondary, #555)"
5267
+ },
5268
+ children: [
5269
+ "Confirmation #",
5270
+ success.confirmation_number || success.sale_id
5271
+ ]
5272
+ }
5273
+ ),
5274
+ /* @__PURE__ */ jsxRuntime.jsx(
5275
+ "p",
5276
+ {
5277
+ style: {
5278
+ margin: 0,
5279
+ color: "var(--sk-text-secondary, #555)",
5280
+ fontSize: "0.9rem"
5281
+ },
5282
+ children: "Check your email for ticket details."
5283
+ }
5284
+ )
5285
+ ]
5286
+ }
5287
+ );
5288
+ }
5289
+ if (soldOut) {
5290
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5291
+ "div",
5292
+ {
5293
+ className: `site-kit-event-checkout-soldout ${className}`,
5294
+ style: {
5295
+ padding: "2rem",
5296
+ textAlign: "center",
5297
+ background: "var(--sk-surface, #f9fafb)",
5298
+ border: "1px solid var(--sk-border, #e5e7eb)",
5299
+ borderRadius: "12px"
5300
+ },
5301
+ children: [
5302
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontWeight: 600, fontSize: "1.125rem" }, children: "This cruise is sold out" }),
5303
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "0.5rem 0 0", color: "var(--sk-text-secondary, #555)" }, children: "Check back soon for additional dates." })
5304
+ ]
5305
+ }
5306
+ );
5307
+ }
5308
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5309
+ "div",
5310
+ {
5311
+ className: `site-kit-event-checkout ${className}`,
5312
+ style: {
5313
+ background: "var(--sk-bg, #fff)",
5314
+ border: "1px solid var(--sk-border, #e5e7eb)",
5315
+ borderRadius: "12px",
5316
+ padding: "1.5rem"
5317
+ },
5318
+ children: [
5319
+ schedule && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1.25rem" }, children: [
5320
+ /* @__PURE__ */ jsxRuntime.jsx(
5321
+ "div",
5322
+ {
5323
+ style: {
5324
+ fontSize: "0.75rem",
5325
+ textTransform: "uppercase",
5326
+ letterSpacing: "0.08em",
5327
+ color: "var(--sk-text-secondary, #555)",
5328
+ marginBottom: "0.25rem"
5329
+ },
5330
+ children: "Date & Time"
5331
+ }
5332
+ ),
5333
+ /* @__PURE__ */ jsxRuntime.jsxs(
5334
+ "div",
5335
+ {
5336
+ style: {
5337
+ fontSize: "1.125rem",
5338
+ fontWeight: 600,
5339
+ color: "var(--sk-text-primary, #111)"
5340
+ },
5341
+ children: [
5342
+ formatDate(schedule.starts_at),
5343
+ " \xB7 ",
5344
+ formatTime(schedule.starts_at)
5345
+ ]
5346
+ }
5347
+ ),
5348
+ spotsRemaining !== null && spotsRemaining <= 10 && spotsRemaining > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
5349
+ "div",
5350
+ {
5351
+ style: {
5352
+ marginTop: "0.5rem",
5353
+ fontSize: "0.875rem",
5354
+ color: "var(--sk-warning, #b45309)",
5355
+ fontWeight: 500
5356
+ },
5357
+ children: [
5358
+ "Only ",
5359
+ spotsRemaining,
5360
+ " spot",
5361
+ spotsRemaining === 1 ? "" : "s",
5362
+ " left"
5363
+ ]
5364
+ }
5365
+ )
5366
+ ] }),
5367
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
5368
+ /* @__PURE__ */ jsxRuntime.jsx(
5369
+ "div",
5370
+ {
5371
+ style: {
5372
+ display: "flex",
5373
+ flexDirection: "column",
5374
+ gap: "0.75rem",
5375
+ marginBottom: "1.25rem"
5376
+ },
5377
+ children: lineBreakdown.map((line) => /* @__PURE__ */ jsxRuntime.jsxs(
5378
+ "div",
5379
+ {
5380
+ style: {
5381
+ display: "flex",
5382
+ alignItems: "center",
5383
+ justifyContent: "space-between",
5384
+ gap: "1rem",
5385
+ padding: "0.875rem 1rem",
5386
+ background: "var(--sk-surface, #f9fafb)",
5387
+ borderRadius: "8px",
5388
+ border: "1px solid var(--sk-border, #e5e7eb)"
5389
+ },
5390
+ children: [
5391
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [
5392
+ /* @__PURE__ */ jsxRuntime.jsx(
5393
+ "div",
5394
+ {
5395
+ style: {
5396
+ fontWeight: 600,
5397
+ color: "var(--sk-text-primary, #111)"
5398
+ },
5399
+ children: line.name
5400
+ }
5401
+ ),
5402
+ /* @__PURE__ */ jsxRuntime.jsxs(
5403
+ "div",
5404
+ {
5405
+ style: {
5406
+ fontSize: "0.875rem",
5407
+ color: "var(--sk-text-secondary, #555)"
5408
+ },
5409
+ children: [
5410
+ formatPrice(line.unitPrice, currency),
5411
+ " each"
5412
+ ]
5413
+ }
5414
+ )
5415
+ ] }),
5416
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
5417
+ /* @__PURE__ */ jsxRuntime.jsx(
5418
+ "button",
5419
+ {
5420
+ type: "button",
5421
+ onClick: () => updateQty(line.key, -1),
5422
+ disabled: line.quantity === 0,
5423
+ "aria-label": `Decrease ${line.name} quantity`,
5424
+ style: {
5425
+ width: "32px",
5426
+ height: "32px",
5427
+ borderRadius: "50%",
5428
+ border: "1px solid var(--sk-border, #d1d5db)",
5429
+ background: "var(--sk-bg, #fff)",
5430
+ color: "var(--sk-text-primary, #111)",
5431
+ cursor: line.quantity === 0 ? "not-allowed" : "pointer",
5432
+ opacity: line.quantity === 0 ? 0.4 : 1,
5433
+ fontSize: "1.25rem",
5434
+ lineHeight: 1,
5435
+ display: "flex",
5436
+ alignItems: "center",
5437
+ justifyContent: "center"
5438
+ },
5439
+ children: "\u2212"
5440
+ }
5441
+ ),
5442
+ /* @__PURE__ */ jsxRuntime.jsx(
5443
+ "div",
5444
+ {
5445
+ style: {
5446
+ minWidth: "2.5rem",
5447
+ textAlign: "center",
5448
+ fontWeight: 600,
5449
+ fontSize: "1.125rem"
5450
+ },
5451
+ children: line.quantity
5452
+ }
5453
+ ),
5454
+ /* @__PURE__ */ jsxRuntime.jsx(
5455
+ "button",
5456
+ {
5457
+ type: "button",
5458
+ onClick: () => updateQty(line.key, 1),
5459
+ disabled: line.quantity >= maxPerVariant,
5460
+ "aria-label": `Increase ${line.name} quantity`,
5461
+ style: {
5462
+ width: "32px",
5463
+ height: "32px",
5464
+ borderRadius: "50%",
5465
+ border: "1px solid var(--sk-border, #d1d5db)",
5466
+ background: "var(--sk-bg, #fff)",
5467
+ color: "var(--sk-text-primary, #111)",
5468
+ cursor: line.quantity >= maxPerVariant ? "not-allowed" : "pointer",
5469
+ opacity: line.quantity >= maxPerVariant ? 0.4 : 1,
5470
+ fontSize: "1.25rem",
5471
+ lineHeight: 1,
5472
+ display: "flex",
5473
+ alignItems: "center",
5474
+ justifyContent: "center"
5475
+ },
5476
+ children: "+"
5477
+ }
5478
+ )
5479
+ ] })
5480
+ ]
5481
+ },
5482
+ line.key
5483
+ ))
5484
+ }
5485
+ ),
5486
+ /* @__PURE__ */ jsxRuntime.jsxs(
5487
+ "div",
5488
+ {
5489
+ style: {
5490
+ display: "flex",
5491
+ justifyContent: "space-between",
5492
+ alignItems: "baseline",
5493
+ padding: "0.75rem 0",
5494
+ borderTop: "1px solid var(--sk-border, #e5e7eb)",
5495
+ borderBottom: "1px solid var(--sk-border, #e5e7eb)",
5496
+ marginBottom: "1.25rem"
5497
+ },
5498
+ children: [
5499
+ /* @__PURE__ */ jsxRuntime.jsxs(
5500
+ "span",
5501
+ {
5502
+ style: {
5503
+ fontSize: "0.875rem",
5504
+ color: "var(--sk-text-secondary, #555)",
5505
+ textTransform: "uppercase",
5506
+ letterSpacing: "0.06em"
5507
+ },
5508
+ children: [
5509
+ "Total (",
5510
+ totalQuantity,
5511
+ " ",
5512
+ totalQuantity === 1 ? "ticket" : "tickets",
5513
+ ")"
5514
+ ]
5515
+ }
5516
+ ),
5517
+ /* @__PURE__ */ jsxRuntime.jsx(
5518
+ "span",
5519
+ {
5520
+ style: {
5521
+ fontSize: "1.5rem",
5522
+ fontWeight: 700,
5523
+ color: "var(--sk-text-primary, #111)"
5524
+ },
5525
+ children: formatPrice(subtotal, currency)
5526
+ }
5527
+ )
5528
+ ]
5529
+ }
5530
+ ),
5531
+ /* @__PURE__ */ jsxRuntime.jsxs(
5532
+ "div",
5533
+ {
5534
+ style: {
5535
+ display: "flex",
5536
+ flexDirection: "column",
5537
+ gap: "0.75rem",
5538
+ marginBottom: "1rem"
5539
+ },
5540
+ children: [
5541
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5542
+ /* @__PURE__ */ jsxRuntime.jsx(
5543
+ "label",
5544
+ {
5545
+ style: {
5546
+ display: "block",
5547
+ fontSize: "0.75rem",
5548
+ fontWeight: 600,
5549
+ textTransform: "uppercase",
5550
+ letterSpacing: "0.06em",
5551
+ color: "var(--sk-text-secondary, #555)",
5552
+ marginBottom: "0.25rem"
5553
+ },
5554
+ children: "Full Name"
5555
+ }
5556
+ ),
5557
+ /* @__PURE__ */ jsxRuntime.jsx(
5558
+ "input",
5559
+ {
5560
+ type: "text",
5561
+ required: true,
5562
+ value: customer.name,
5563
+ onChange: (e) => updateCustomer("name", e.target.value),
5564
+ placeholder: "John Smith",
5565
+ style: {
5566
+ width: "100%",
5567
+ padding: "0.625rem 0.75rem",
5568
+ borderRadius: "6px",
5569
+ border: "1px solid var(--sk-border, #d1d5db)",
5570
+ fontSize: "1rem",
5571
+ background: "var(--sk-bg, #fff)",
5572
+ color: "var(--sk-text-primary, #111)"
5573
+ }
5574
+ }
5575
+ )
5576
+ ] }),
5577
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5578
+ /* @__PURE__ */ jsxRuntime.jsx(
5579
+ "label",
5580
+ {
5581
+ style: {
5582
+ display: "block",
5583
+ fontSize: "0.75rem",
5584
+ fontWeight: 600,
5585
+ textTransform: "uppercase",
5586
+ letterSpacing: "0.06em",
5587
+ color: "var(--sk-text-secondary, #555)",
5588
+ marginBottom: "0.25rem"
5589
+ },
5590
+ children: "Email Address"
5591
+ }
5592
+ ),
5593
+ /* @__PURE__ */ jsxRuntime.jsx(
5594
+ "input",
5595
+ {
5596
+ type: "email",
5597
+ required: true,
5598
+ value: customer.email,
5599
+ onChange: (e) => updateCustomer("email", e.target.value),
5600
+ placeholder: "john@example.com",
5601
+ style: {
5602
+ width: "100%",
5603
+ padding: "0.625rem 0.75rem",
5604
+ borderRadius: "6px",
5605
+ border: "1px solid var(--sk-border, #d1d5db)",
5606
+ fontSize: "1rem",
5607
+ background: "var(--sk-bg, #fff)",
5608
+ color: "var(--sk-text-primary, #111)"
5609
+ }
5610
+ }
5611
+ )
5612
+ ] }),
5613
+ collectPhone && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5614
+ /* @__PURE__ */ jsxRuntime.jsx(
5615
+ "label",
5616
+ {
5617
+ style: {
5618
+ display: "block",
5619
+ fontSize: "0.75rem",
5620
+ fontWeight: 600,
5621
+ textTransform: "uppercase",
5622
+ letterSpacing: "0.06em",
5623
+ color: "var(--sk-text-secondary, #555)",
5624
+ marginBottom: "0.25rem"
5625
+ },
5626
+ children: "Phone Number"
5627
+ }
5628
+ ),
5629
+ /* @__PURE__ */ jsxRuntime.jsx(
5630
+ "input",
5631
+ {
5632
+ type: "tel",
5633
+ value: customer.phone || "",
5634
+ onChange: (e) => updateCustomer("phone", e.target.value),
5635
+ placeholder: "(555) 123-4567",
5636
+ style: {
5637
+ width: "100%",
5638
+ padding: "0.625rem 0.75rem",
5639
+ borderRadius: "6px",
5640
+ border: "1px solid var(--sk-border, #d1d5db)",
5641
+ fontSize: "1rem",
5642
+ background: "var(--sk-bg, #fff)",
5643
+ color: "var(--sk-text-primary, #111)"
5644
+ }
5645
+ }
5646
+ )
5647
+ ] })
5648
+ ]
5649
+ }
5650
+ ),
5651
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "1rem" }, children: [
5652
+ /* @__PURE__ */ jsxRuntime.jsx(
5653
+ "label",
5654
+ {
5655
+ style: {
5656
+ display: "block",
5657
+ fontSize: "0.75rem",
5658
+ fontWeight: 600,
5659
+ textTransform: "uppercase",
5660
+ letterSpacing: "0.06em",
5661
+ color: "var(--sk-text-secondary, #555)",
5662
+ marginBottom: "0.25rem"
5663
+ },
5664
+ children: cardLabel
5665
+ }
5666
+ ),
5667
+ /* @__PURE__ */ jsxRuntime.jsx(
5668
+ "div",
5669
+ {
5670
+ id: "sk-event-checkout-card",
5671
+ ref: cardContainerRef,
5672
+ style: {
5673
+ minHeight: "44px",
5674
+ border: "1px solid var(--sk-border, #d1d5db)",
5675
+ borderRadius: "6px",
5676
+ padding: "0.5rem 0.75rem",
5677
+ background: "var(--sk-bg, #fff)"
5678
+ }
5679
+ }
5680
+ ),
5681
+ !cardReady && /* @__PURE__ */ jsxRuntime.jsx(
5682
+ "p",
5683
+ {
5684
+ style: {
5685
+ fontSize: "0.75rem",
5686
+ color: "var(--sk-text-secondary, #555)",
5687
+ marginTop: "0.25rem"
5688
+ },
5689
+ children: "Loading card form..."
5690
+ }
5691
+ )
5692
+ ] }),
5693
+ error && /* @__PURE__ */ jsxRuntime.jsx(
5694
+ "div",
5695
+ {
5696
+ role: "alert",
5697
+ style: {
5698
+ marginBottom: "1rem",
5699
+ padding: "0.75rem 1rem",
5700
+ background: "rgba(220, 38, 38, 0.06)",
5701
+ border: "1px solid rgba(220, 38, 38, 0.25)",
5702
+ borderRadius: "6px",
5703
+ color: "#b91c1c",
5704
+ fontSize: "0.875rem"
5705
+ },
5706
+ children: error
5707
+ }
5708
+ ),
5709
+ /* @__PURE__ */ jsxRuntime.jsx(
5710
+ "button",
5711
+ {
5712
+ type: "submit",
5713
+ disabled: loading || totalQuantity === 0 || !cardReady || overCapacity,
5714
+ style: {
5715
+ width: "100%",
5716
+ padding: "0.875rem 1rem",
5717
+ fontSize: "1rem",
5718
+ fontWeight: 600,
5719
+ borderRadius: "8px",
5720
+ border: "none",
5721
+ background: loading || totalQuantity === 0 || !cardReady || overCapacity ? "var(--sk-primary-hover, #94a3b8)" : "var(--sk-primary, #2563eb)",
5722
+ color: "var(--sk-primary-text, #fff)",
5723
+ cursor: loading || totalQuantity === 0 || !cardReady || overCapacity ? "not-allowed" : "pointer",
5724
+ transition: "background 0.15s ease"
5725
+ },
5726
+ children: loading ? "Processing..." : submitText ? submitText : totalQuantity === 0 ? "Select tickets" : `Buy ${formatPrice(subtotal, currency)}`
5727
+ }
5728
+ ),
5729
+ /* @__PURE__ */ jsxRuntime.jsx(
5730
+ "p",
5731
+ {
5732
+ style: {
5733
+ textAlign: "center",
5734
+ fontSize: "0.75rem",
5735
+ color: "var(--sk-text-secondary, #888)",
5736
+ margin: "0.75rem 0 0"
5737
+ },
5738
+ children: "\u{1F512} Secure checkout powered by Square"
5739
+ }
5740
+ )
5741
+ ] })
5742
+ ]
5743
+ }
5744
+ );
5745
+ }
5017
5746
  function RegistrationForm({
5018
5747
  event,
5019
5748
  scheduleId,
@@ -5652,7 +6381,7 @@ function CalendarView({
5652
6381
  }, children: "Loading..." })
5653
6382
  ] });
5654
6383
  }
5655
- function loadSquareSDK2(environment) {
6384
+ function loadSquareSDK3(environment) {
5656
6385
  return new Promise((resolve, reject) => {
5657
6386
  if (typeof window === "undefined") return reject(new Error("No window"));
5658
6387
  if (window.Square) return resolve();
@@ -5699,7 +6428,7 @@ function EventModal({
5699
6428
  if (config?.processor) setProcessor(config.processor);
5700
6429
  if (config?.processor === "square" && config.squareAppId && config.squareLocationId) {
5701
6430
  try {
5702
- await loadSquareSDK2(config.squareEnvironment || "production");
6431
+ await loadSquareSDK3(config.squareEnvironment || "production");
5703
6432
  const Square = window.Square;
5704
6433
  const payments = Square.payments(config.squareAppId, config.squareLocationId);
5705
6434
  const card = await payments.card({
@@ -7018,6 +7747,7 @@ function groupEventsByOffering(events) {
7018
7747
  exports.CalendarView = CalendarView;
7019
7748
  exports.CheckoutForm = CheckoutForm;
7020
7749
  exports.EventCalendar = EventCalendar;
7750
+ exports.EventCheckout = EventCheckout;
7021
7751
  exports.EventEmbed = EventEmbed;
7022
7752
  exports.EventModal = EventModal;
7023
7753
  exports.EventTile = EventTile;
@@ -7059,5 +7789,5 @@ exports.registerForEvent = registerForEvent;
7059
7789
  exports.useEventModal = useEventModal;
7060
7790
  exports.validateAddress = validateAddress;
7061
7791
  exports.validateDiscountCode = validateDiscountCode;
7062
- //# sourceMappingURL=chunk-D5ES7H7E.js.map
7063
- //# sourceMappingURL=chunk-D5ES7H7E.js.map
7792
+ //# sourceMappingURL=chunk-2OGUBINV.js.map
7793
+ //# sourceMappingURL=chunk-2OGUBINV.js.map