glitchgrab 1.59.0 → 1.60.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/README.md +19 -0
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +275 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +275 -27
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/{types-BpTLWJ1y.d.mts → types-BlMF6wzX.d.mts} +28 -2
- package/dist/{types-BpTLWJ1y.d.ts → types-BlMF6wzX.d.ts} +28 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1426,10 +1426,21 @@ function drawStroke(ctx, s) {
|
|
|
1426
1426
|
ctx.moveTo(s.points[0].x, s.points[0].y);
|
|
1427
1427
|
for (let i = 1; i < s.points.length; i++) ctx.lineTo(s.points[i].x, s.points[i].y);
|
|
1428
1428
|
ctx.stroke();
|
|
1429
|
-
} else {
|
|
1429
|
+
} else if (s.type === "circle") {
|
|
1430
1430
|
ctx.beginPath();
|
|
1431
1431
|
ctx.arc(s.cx, s.cy, s.r, 0, Math.PI * 2);
|
|
1432
1432
|
ctx.stroke();
|
|
1433
|
+
} else {
|
|
1434
|
+
if (Math.hypot(s.x2 - s.x1, s.y2 - s.y1) < 3) return;
|
|
1435
|
+
const angle = Math.atan2(s.y2 - s.y1, s.x2 - s.x1);
|
|
1436
|
+
const head = Math.max(14, s.width * 4);
|
|
1437
|
+
ctx.beginPath();
|
|
1438
|
+
ctx.moveTo(s.x1, s.y1);
|
|
1439
|
+
ctx.lineTo(s.x2, s.y2);
|
|
1440
|
+
ctx.moveTo(s.x2 - head * Math.cos(angle - Math.PI / 6), s.y2 - head * Math.sin(angle - Math.PI / 6));
|
|
1441
|
+
ctx.lineTo(s.x2, s.y2);
|
|
1442
|
+
ctx.lineTo(s.x2 - head * Math.cos(angle + Math.PI / 6), s.y2 - head * Math.sin(angle + Math.PI / 6));
|
|
1443
|
+
ctx.stroke();
|
|
1433
1444
|
}
|
|
1434
1445
|
}
|
|
1435
1446
|
function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
@@ -1478,7 +1489,7 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1478
1489
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1479
1490
|
const { x, y } = getPos(e);
|
|
1480
1491
|
setCurrentStroke(
|
|
1481
|
-
tool === "pen" ? { type: "freehand", color, width: strokeWidth, points: [{ x, y }] } : { type: "circle", color, width: strokeWidth, cx: x, cy: y, r: 0 }
|
|
1492
|
+
tool === "pen" ? { type: "freehand", color, width: strokeWidth, points: [{ x, y }] } : tool === "circle" ? { type: "circle", color, width: strokeWidth, cx: x, cy: y, r: 0 } : { type: "arrow", color, width: strokeWidth, x1: x, y1: y, x2: x, y2: y }
|
|
1482
1493
|
);
|
|
1483
1494
|
};
|
|
1484
1495
|
const handlePointerMove = (e) => {
|
|
@@ -1487,6 +1498,7 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1487
1498
|
setCurrentStroke((prev) => {
|
|
1488
1499
|
if (!prev) return prev;
|
|
1489
1500
|
if (prev.type === "freehand") return { ...prev, points: [...prev.points, { x, y }] };
|
|
1501
|
+
if (prev.type === "arrow") return { ...prev, x2: x, y2: y };
|
|
1490
1502
|
return { ...prev, r: Math.hypot(x - prev.cx, y - prev.cy) };
|
|
1491
1503
|
});
|
|
1492
1504
|
};
|
|
@@ -1567,6 +1579,7 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1567
1579
|
children: [
|
|
1568
1580
|
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => setTool("pen"), style: iconBtn(tool === "pen"), title: "Freehand", "aria-label": "Freehand tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M12 20h9M16.5 3.5a2.12 2.12 0 013 3L7 19l-4 1 1-4L16.5 3.5z", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
1569
1581
|
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => setTool("circle"), style: iconBtn(tool === "circle"), title: "Circle", "aria-label": "Circle tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "8", stroke: "currentColor", strokeWidth: "1.8" }) }) }),
|
|
1582
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => setTool("arrow"), style: iconBtn(tool === "arrow"), title: "Arrow", "aria-label": "Arrow tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M5 19L19 5M19 5h-8M19 5v8", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
1570
1583
|
/* @__PURE__ */ jsx("div", { style: { width: "1px", height: "20px", background: "rgba(255,255,255,0.15)" } }),
|
|
1571
1584
|
PALETTE.map((c) => /* @__PURE__ */ jsx(
|
|
1572
1585
|
"button",
|
|
@@ -2441,6 +2454,7 @@ function AssistSheet({
|
|
|
2441
2454
|
canReadPdf = false,
|
|
2442
2455
|
onRemoveFile,
|
|
2443
2456
|
onRemoveImage,
|
|
2457
|
+
onAnnotateImage,
|
|
2444
2458
|
attachmentCount,
|
|
2445
2459
|
context,
|
|
2446
2460
|
reportTypeLabel,
|
|
@@ -2560,6 +2574,12 @@ function AssistSheet({
|
|
|
2560
2574
|
const id = setTimeout(() => setAutoFileLeft((n) => n === null ? null : n - 1), 1e3);
|
|
2561
2575
|
return () => clearTimeout(id);
|
|
2562
2576
|
}, [autoFileLeft, isSubmitting, submitted, phase]);
|
|
2577
|
+
function markUp(index, shot) {
|
|
2578
|
+
if (!onAnnotateImage) return;
|
|
2579
|
+
stopAutoFile("marked up an image");
|
|
2580
|
+
logEvent("image_markup", pageShot && shot === pageShot ? "page capture" : "attached");
|
|
2581
|
+
onAnnotateImage(index);
|
|
2582
|
+
}
|
|
2563
2583
|
function stopAutoFile(reason) {
|
|
2564
2584
|
if (autoFileLeft === null) return;
|
|
2565
2585
|
setAutoFileLeft(null);
|
|
@@ -2985,7 +3005,7 @@ function AssistSheet({
|
|
|
2985
3005
|
@keyframes gg-autofile{from{transform:scaleX(0)}to{transform:scaleX(1)}}
|
|
2986
3006
|
@keyframes gg-spin{to{transform:rotate(360deg)}}
|
|
2987
3007
|
@keyframes gg-dot{0%,80%,100%{transform:translateY(0);opacity:.4}40%{transform:translateY(-3px);opacity:1}}
|
|
2988
|
-
[data-gg-sheet-send]:focus-visible,[data-gg-chip]:focus-visible,[data-gg-assist-remove]:focus-visible,[data-gg-stop-auto-file]:focus-visible{outline:2px solid currentColor;outline-offset:2px}
|
|
3008
|
+
[data-gg-sheet-send]:focus-visible,[data-gg-chip]:focus-visible,[data-gg-assist-remove]:focus-visible,[data-gg-assist-annotate]:focus-visible,[data-gg-stop-auto-file]:focus-visible{outline:2px solid currentColor;outline-offset:2px}
|
|
2989
3009
|
` }),
|
|
2990
3010
|
/* @__PURE__ */ jsx3(
|
|
2991
3011
|
"div",
|
|
@@ -3039,7 +3059,10 @@ function AssistSheet({
|
|
|
3039
3059
|
display: "flex",
|
|
3040
3060
|
alignItems: "flex-start",
|
|
3041
3061
|
justifyContent: "space-between",
|
|
3042
|
-
|
|
3062
|
+
// The title is one unbreakable line, so on a phone-width sheet the
|
|
3063
|
+
// pills drop to their own row instead of landing on the Beta tag (#591).
|
|
3064
|
+
flexWrap: "wrap",
|
|
3065
|
+
gap: "8px 12px",
|
|
3043
3066
|
minWidth: 0
|
|
3044
3067
|
},
|
|
3045
3068
|
children: [
|
|
@@ -3084,7 +3107,7 @@ function AssistSheet({
|
|
|
3084
3107
|
projectSlot ? /* @__PURE__ */ jsx3("span", { style: { marginLeft: "6px" }, children: projectSlot }) : null
|
|
3085
3108
|
] })
|
|
3086
3109
|
] }),
|
|
3087
|
-
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "6px", flexShrink: 0 }, children: [
|
|
3110
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "6px", flexShrink: 0, marginLeft: "auto" }, children: [
|
|
3088
3111
|
historyKey && (showChats || otherChats.length > 0) && /* @__PURE__ */ jsx3(
|
|
3089
3112
|
"button",
|
|
3090
3113
|
{
|
|
@@ -3147,7 +3170,8 @@ function AssistSheet({
|
|
|
3147
3170
|
ref: scrollRef,
|
|
3148
3171
|
style: {
|
|
3149
3172
|
flex: 1,
|
|
3150
|
-
|
|
3173
|
+
// 0 while the "already filed?" card is up: its footer scrolls instead (#590).
|
|
3174
|
+
minHeight: narrow && !similarSlot ? "180px" : 0,
|
|
3151
3175
|
overflowY: "auto",
|
|
3152
3176
|
padding: "16px",
|
|
3153
3177
|
display: "flex",
|
|
@@ -3999,7 +4023,10 @@ function AssistSheet({
|
|
|
3999
4023
|
borderTop: `1px solid ${t.border}`,
|
|
4000
4024
|
padding: "12px 16px",
|
|
4001
4025
|
paddingBottom: narrow ? "max(12px, env(safe-area-inset-bottom))" : "12px",
|
|
4002
|
-
backgroundColor: t.bg
|
|
4026
|
+
backgroundColor: t.bg,
|
|
4027
|
+
// The "already filed?" card can be taller than the sheet; scroll
|
|
4028
|
+
// it instead of clipping its buttons off the bottom (#590).
|
|
4029
|
+
...similarSlot ? { maxHeight: "70%", overflowY: "auto" } : {}
|
|
4003
4030
|
},
|
|
4004
4031
|
children: [
|
|
4005
4032
|
phase === "solved" ? /* @__PURE__ */ jsx3(
|
|
@@ -4079,7 +4106,9 @@ function AssistSheet({
|
|
|
4079
4106
|
src: shot,
|
|
4080
4107
|
alt: read ? "Attached image the assistant reads" : "Attached image",
|
|
4081
4108
|
"data-gg-assist-thumb": "",
|
|
4109
|
+
onClick: onAnnotateImage ? () => markUp(i, shot) : void 0,
|
|
4082
4110
|
style: {
|
|
4111
|
+
cursor: onAnnotateImage ? "pointer" : void 0,
|
|
4083
4112
|
display: "block",
|
|
4084
4113
|
width: "100%",
|
|
4085
4114
|
height: "100%",
|
|
@@ -4091,6 +4120,59 @@ function AssistSheet({
|
|
|
4091
4120
|
}
|
|
4092
4121
|
}
|
|
4093
4122
|
),
|
|
4123
|
+
onAnnotateImage && /* @__PURE__ */ jsx3(
|
|
4124
|
+
"button",
|
|
4125
|
+
{
|
|
4126
|
+
type: "button",
|
|
4127
|
+
"data-gg-assist-annotate": "",
|
|
4128
|
+
"aria-label": `Draw on image ${i + 1}`,
|
|
4129
|
+
title: "Draw or circle on this image",
|
|
4130
|
+
onClick: () => markUp(i, shot),
|
|
4131
|
+
style: {
|
|
4132
|
+
position: "absolute",
|
|
4133
|
+
bottom: "-13px",
|
|
4134
|
+
right: "-13px",
|
|
4135
|
+
width: "32px",
|
|
4136
|
+
height: "32px",
|
|
4137
|
+
border: "none",
|
|
4138
|
+
background: "transparent",
|
|
4139
|
+
padding: 0,
|
|
4140
|
+
cursor: "pointer",
|
|
4141
|
+
display: "flex",
|
|
4142
|
+
alignItems: "center",
|
|
4143
|
+
justifyContent: "center",
|
|
4144
|
+
borderRadius: "50%"
|
|
4145
|
+
},
|
|
4146
|
+
children: /* @__PURE__ */ jsx3(
|
|
4147
|
+
"span",
|
|
4148
|
+
{
|
|
4149
|
+
"aria-hidden": "true",
|
|
4150
|
+
style: {
|
|
4151
|
+
width: "20px",
|
|
4152
|
+
height: "20px",
|
|
4153
|
+
boxSizing: "border-box",
|
|
4154
|
+
borderRadius: "50%",
|
|
4155
|
+
border: `2px solid ${t.bg}`,
|
|
4156
|
+
background: t.accent,
|
|
4157
|
+
color: t.accentText,
|
|
4158
|
+
display: "flex",
|
|
4159
|
+
alignItems: "center",
|
|
4160
|
+
justifyContent: "center"
|
|
4161
|
+
},
|
|
4162
|
+
children: /* @__PURE__ */ jsx3("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx3(
|
|
4163
|
+
"path",
|
|
4164
|
+
{
|
|
4165
|
+
d: "M16.5 3.5a2.12 2.12 0 013 3L7 19l-4 1 1-4L16.5 3.5z",
|
|
4166
|
+
stroke: "currentColor",
|
|
4167
|
+
strokeWidth: "2.6",
|
|
4168
|
+
strokeLinecap: "round",
|
|
4169
|
+
strokeLinejoin: "round"
|
|
4170
|
+
}
|
|
4171
|
+
) })
|
|
4172
|
+
}
|
|
4173
|
+
)
|
|
4174
|
+
}
|
|
4175
|
+
),
|
|
4094
4176
|
onRemoveImage && /* @__PURE__ */ jsx3(
|
|
4095
4177
|
"button",
|
|
4096
4178
|
{
|
|
@@ -6282,6 +6364,10 @@ function ReportDialog({
|
|
|
6282
6364
|
setAttachingTo(null);
|
|
6283
6365
|
}
|
|
6284
6366
|
};
|
|
6367
|
+
const plainIssueTitle = (title) => (
|
|
6368
|
+
// Only emphasis markers: a lone "_" is part of a name (task_module).
|
|
6369
|
+
title.replace(/(\*\*|__)(?=\S)(.+?)(?<=\S)\1/g, "$2").replace(/[*`]+/g, "").replace(/\s+/g, " ").trim() || title
|
|
6370
|
+
);
|
|
6285
6371
|
const similarCard = similarIssues ? /* @__PURE__ */ jsxs5(
|
|
6286
6372
|
"div",
|
|
6287
6373
|
{
|
|
@@ -6369,10 +6455,7 @@ function ReportDialog({
|
|
|
6369
6455
|
fontSize: "12.5px",
|
|
6370
6456
|
lineHeight: 1.45,
|
|
6371
6457
|
wordBreak: "break-word",
|
|
6372
|
-
|
|
6373
|
-
display: "-webkit-box",
|
|
6374
|
-
WebkitLineClamp: 3,
|
|
6375
|
-
WebkitBoxOrient: "vertical"
|
|
6458
|
+
overflowWrap: "anywhere"
|
|
6376
6459
|
},
|
|
6377
6460
|
children: [
|
|
6378
6461
|
/* @__PURE__ */ jsxs5("span", { style: { color: t.textMuted, fontWeight: 600 }, children: [
|
|
@@ -6380,7 +6463,7 @@ function ReportDialog({
|
|
|
6380
6463
|
issue.number
|
|
6381
6464
|
] }),
|
|
6382
6465
|
" ",
|
|
6383
|
-
issue.title
|
|
6466
|
+
plainIssueTitle(issue.title)
|
|
6384
6467
|
]
|
|
6385
6468
|
}
|
|
6386
6469
|
),
|
|
@@ -8353,6 +8436,7 @@ function ReportDialog({
|
|
|
8353
8436
|
pageShot,
|
|
8354
8437
|
onAddFiles: addFiles,
|
|
8355
8438
|
onRemoveImage: (index) => setScreenshots((prev) => prev.filter((_, i) => i !== index)),
|
|
8439
|
+
onAnnotateImage: setAnnotatingIndex,
|
|
8356
8440
|
files: heldFiles,
|
|
8357
8441
|
canReadPdf: !!readFile,
|
|
8358
8442
|
onRemoveFile: (index) => setAttachments((prev) => prev.filter((_, i) => i !== index)),
|
|
@@ -8558,6 +8642,69 @@ function getTypeIcon(type, color, size = 24) {
|
|
|
8558
8642
|
|
|
8559
8643
|
// src/booking-dialog.tsx
|
|
8560
8644
|
import { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo3, useState as useState5 } from "react";
|
|
8645
|
+
|
|
8646
|
+
// src/phone.ts
|
|
8647
|
+
var COUNTRIES = [
|
|
8648
|
+
{ iso: "IN", name: "India", dial: "91" },
|
|
8649
|
+
{ iso: "AE", name: "UAE", dial: "971" },
|
|
8650
|
+
{ iso: "US", name: "US / Canada", dial: "1" },
|
|
8651
|
+
{ iso: "GB", name: "UK", dial: "44" },
|
|
8652
|
+
{ iso: "SG", name: "Singapore", dial: "65" },
|
|
8653
|
+
{ iso: "AU", name: "Australia", dial: "61" },
|
|
8654
|
+
{ iso: "SA", name: "Saudi Arabia", dial: "966" },
|
|
8655
|
+
{ iso: "QA", name: "Qatar", dial: "974" },
|
|
8656
|
+
{ iso: "NP", name: "Nepal", dial: "977" },
|
|
8657
|
+
{ iso: "BD", name: "Bangladesh", dial: "880" },
|
|
8658
|
+
{ iso: "LK", name: "Sri Lanka", dial: "94" },
|
|
8659
|
+
{ iso: "DE", name: "Germany", dial: "49" }
|
|
8660
|
+
];
|
|
8661
|
+
var ZONE_COUNTRY = {
|
|
8662
|
+
"Asia/Kolkata": "91",
|
|
8663
|
+
"Asia/Calcutta": "91",
|
|
8664
|
+
"Asia/Dubai": "971",
|
|
8665
|
+
"Europe/London": "44",
|
|
8666
|
+
"Asia/Singapore": "65",
|
|
8667
|
+
"Asia/Riyadh": "966",
|
|
8668
|
+
"Asia/Qatar": "974",
|
|
8669
|
+
"Asia/Kathmandu": "977",
|
|
8670
|
+
"Asia/Katmandu": "977",
|
|
8671
|
+
"Asia/Dhaka": "880",
|
|
8672
|
+
"Asia/Colombo": "94",
|
|
8673
|
+
"Europe/Berlin": "49"
|
|
8674
|
+
};
|
|
8675
|
+
function defaultDialForZone(zone) {
|
|
8676
|
+
if (ZONE_COUNTRY[zone]) return ZONE_COUNTRY[zone];
|
|
8677
|
+
if (zone.startsWith("America/")) return "1";
|
|
8678
|
+
if (zone.startsWith("Australia/")) return "61";
|
|
8679
|
+
return "91";
|
|
8680
|
+
}
|
|
8681
|
+
function splitTypedPhone(typed, dial) {
|
|
8682
|
+
const trimmed = typed.trim();
|
|
8683
|
+
const digits = trimmed.replace(/\D/g, "");
|
|
8684
|
+
if (trimmed.startsWith("+")) {
|
|
8685
|
+
const match = [...COUNTRIES].sort((a, b) => b.dial.length - a.dial.length).find((c) => digits.startsWith(c.dial));
|
|
8686
|
+
if (match) return { dial: match.dial, national: digits.slice(match.dial.length) };
|
|
8687
|
+
}
|
|
8688
|
+
if (dial === "91" && digits.length === 12 && digits.startsWith("91")) return { dial, national: digits.slice(2) };
|
|
8689
|
+
if (dial === "91" && digits.length === 11 && digits.startsWith("0")) return { dial, national: digits.slice(1) };
|
|
8690
|
+
return { dial, national: digits };
|
|
8691
|
+
}
|
|
8692
|
+
function phoneProblem(dial, national) {
|
|
8693
|
+
const digits = national.replace(/\D/g, "");
|
|
8694
|
+
if (!digits) return "Enter your mobile number";
|
|
8695
|
+
if (dial === "91") {
|
|
8696
|
+
if (digits.length !== 10) return `An Indian mobile has 10 digits \u2014 this has ${digits.length}`;
|
|
8697
|
+
if (!/^[6-9]/.test(digits)) return "An Indian mobile starts with 6, 7, 8 or 9";
|
|
8698
|
+
return null;
|
|
8699
|
+
}
|
|
8700
|
+
if (digits.length < 6 || digits.length > 12) return "Check the number \u2014 it looks too short or too long";
|
|
8701
|
+
return null;
|
|
8702
|
+
}
|
|
8703
|
+
function toE164(dial, national) {
|
|
8704
|
+
return `+${dial}${national.replace(/\D/g, "")}`;
|
|
8705
|
+
}
|
|
8706
|
+
|
|
8707
|
+
// src/booking-dialog.tsx
|
|
8561
8708
|
import { Fragment as Fragment5, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
8562
8709
|
function readQuestions(value) {
|
|
8563
8710
|
if (!Array.isArray(value)) return [];
|
|
@@ -8700,7 +8847,9 @@ function BookingDialog({
|
|
|
8700
8847
|
open,
|
|
8701
8848
|
onClose,
|
|
8702
8849
|
preview = false,
|
|
8703
|
-
availabilityUrl
|
|
8850
|
+
availabilityUrl,
|
|
8851
|
+
intro,
|
|
8852
|
+
onBooked
|
|
8704
8853
|
}) {
|
|
8705
8854
|
var _a, _b, _c, _d, _e;
|
|
8706
8855
|
const wide = useMediaQuery(WIDE_QUERY, true);
|
|
@@ -8723,6 +8872,8 @@ function BookingDialog({
|
|
|
8723
8872
|
const [name, setName] = useState5("");
|
|
8724
8873
|
const [email, setEmail] = useState5("");
|
|
8725
8874
|
const [phone, setPhone] = useState5("");
|
|
8875
|
+
const [dial, setDial] = useState5(() => defaultDialForZone(localZone()));
|
|
8876
|
+
const [phoneTouched, setPhoneTouched] = useState5(false);
|
|
8726
8877
|
const [note, setNote] = useState5("");
|
|
8727
8878
|
const [questions, setQuestions] = useState5([]);
|
|
8728
8879
|
const [answers, setAnswers] = useState5({});
|
|
@@ -8833,8 +8984,12 @@ function BookingDialog({
|
|
|
8833
8984
|
const view = step !== "slots" ? step : !pageLoaded ? "loading" : questions.length > 0 && !asked ? "questions" : "slots";
|
|
8834
8985
|
const roomy = step === "slots";
|
|
8835
8986
|
async function startBooking() {
|
|
8836
|
-
var _a2, _b2;
|
|
8987
|
+
var _a2, _b2, _c2;
|
|
8837
8988
|
if (!selected) return;
|
|
8989
|
+
if (phoneError) {
|
|
8990
|
+
setPhoneTouched(true);
|
|
8991
|
+
return;
|
|
8992
|
+
}
|
|
8838
8993
|
if (preview) {
|
|
8839
8994
|
setPreviewEnded(true);
|
|
8840
8995
|
return;
|
|
@@ -8848,7 +9003,7 @@ function BookingDialog({
|
|
|
8848
9003
|
body: JSON.stringify({
|
|
8849
9004
|
name,
|
|
8850
9005
|
email,
|
|
8851
|
-
phone,
|
|
9006
|
+
phone: toE164(dial, phone),
|
|
8852
9007
|
note,
|
|
8853
9008
|
answers: Object.fromEntries(given.map((q) => [q.id, q.answer])),
|
|
8854
9009
|
startsAt: selected.startsAt,
|
|
@@ -8867,6 +9022,7 @@ function BookingDialog({
|
|
|
8867
9022
|
if (json.data.confirmed) {
|
|
8868
9023
|
setMeetUrl((_b2 = json.data.meetUrl) != null ? _b2 : null);
|
|
8869
9024
|
setStep("done");
|
|
9025
|
+
reportBooked(json.data.bookingId, (_c2 = json.data.meetUrl) != null ? _c2 : null);
|
|
8870
9026
|
return;
|
|
8871
9027
|
}
|
|
8872
9028
|
setBookingId(json.data.bookingId);
|
|
@@ -8877,8 +9033,16 @@ function BookingDialog({
|
|
|
8877
9033
|
setBusy(false);
|
|
8878
9034
|
}
|
|
8879
9035
|
}
|
|
9036
|
+
function reportBooked(id, meet) {
|
|
9037
|
+
if (!onBooked || !id || !selected) return;
|
|
9038
|
+
try {
|
|
9039
|
+
onBooked({ bookingId: id, startsAt: selected.startsAt, name, email, phone: toE164(dial, phone), meetUrl: meet });
|
|
9040
|
+
} catch (e) {
|
|
9041
|
+
console.error("[glitchgrab] onBooked threw", e);
|
|
9042
|
+
}
|
|
9043
|
+
}
|
|
8880
9044
|
async function confirmBooking() {
|
|
8881
|
-
var _a2;
|
|
9045
|
+
var _a2, _b2;
|
|
8882
9046
|
if (!bookingId) return;
|
|
8883
9047
|
setBusy(true);
|
|
8884
9048
|
setError(null);
|
|
@@ -8895,13 +9059,15 @@ function BookingDialog({
|
|
|
8895
9059
|
}
|
|
8896
9060
|
setMeetUrl(json.data.meetUrl);
|
|
8897
9061
|
setStep("done");
|
|
9062
|
+
reportBooked(bookingId, (_b2 = json.data.meetUrl) != null ? _b2 : null);
|
|
8898
9063
|
} catch (e) {
|
|
8899
9064
|
setError("Couldn't reach the booking service");
|
|
8900
9065
|
} finally {
|
|
8901
9066
|
setBusy(false);
|
|
8902
9067
|
}
|
|
8903
9068
|
}
|
|
8904
|
-
const
|
|
9069
|
+
const phoneError = phoneProblem(dial, phone);
|
|
9070
|
+
const canSubmitDetails = Boolean(name.trim() && email.includes("@"));
|
|
8905
9071
|
const selectedEnd = selected ? (_e = selected.endsAt) != null ? _e : new Date(new Date(selected.startsAt).getTime() + page.slotMinutes * 6e4).toISOString() : null;
|
|
8906
9072
|
const monthDate = new Date(keyToUtc(`${month}-01`));
|
|
8907
9073
|
const muted = { color: t.muted };
|
|
@@ -9048,6 +9214,14 @@ function BookingDialog({
|
|
|
9048
9214
|
children: "Preview \u2014 nothing is booked"
|
|
9049
9215
|
}
|
|
9050
9216
|
),
|
|
9217
|
+
intro && /* @__PURE__ */ jsx6(
|
|
9218
|
+
"div",
|
|
9219
|
+
{
|
|
9220
|
+
"data-glitchgrab-booking-intro": true,
|
|
9221
|
+
style: { fontSize: 13, fontWeight: 600, lineHeight: 1.45, paddingRight: 32, color: t.ink, overflowWrap: "anywhere" },
|
|
9222
|
+
children: intro
|
|
9223
|
+
}
|
|
9224
|
+
),
|
|
9051
9225
|
/* @__PURE__ */ jsx6("div", { style: { fontSize: 20, fontWeight: 600, lineHeight: 1.25, paddingRight: 32, overflowWrap: "anywhere" }, children: page.title }),
|
|
9052
9226
|
page.description && /* @__PURE__ */ jsx6("div", { style: { fontSize: 13, lineHeight: 1.5, overflowWrap: "anywhere", ...muted }, children: page.description }),
|
|
9053
9227
|
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "column", gap: 10, marginTop: 4, fontSize: 14 }, children: [
|
|
@@ -9490,14 +9664,17 @@ function BookingDialog({
|
|
|
9490
9664
|
/* @__PURE__ */ jsx6(Field, { t, label: "Your name", value: name, onChange: setName, autoComplete: "name" }),
|
|
9491
9665
|
/* @__PURE__ */ jsx6(Field, { t, label: "Email", value: email, onChange: setEmail, type: "email", autoComplete: "email" }),
|
|
9492
9666
|
/* @__PURE__ */ jsx6(
|
|
9493
|
-
|
|
9667
|
+
PhoneField,
|
|
9494
9668
|
{
|
|
9495
9669
|
t,
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
onChange:
|
|
9499
|
-
|
|
9500
|
-
|
|
9670
|
+
dial,
|
|
9671
|
+
national: phone,
|
|
9672
|
+
onChange: (nextDial, national) => {
|
|
9673
|
+
setDial(nextDial);
|
|
9674
|
+
setPhone(national);
|
|
9675
|
+
},
|
|
9676
|
+
onBlur: () => setPhoneTouched(true),
|
|
9677
|
+
error: phoneTouched ? phoneError : null,
|
|
9501
9678
|
hint: requireOtp ? "We send a code here to confirm, then a reminder before the call." : "We send a reminder here before the call."
|
|
9502
9679
|
}
|
|
9503
9680
|
),
|
|
@@ -9785,6 +9962,64 @@ function Field({
|
|
|
9785
9962
|
hint && /* @__PURE__ */ jsx6("div", { style: { marginTop: 6, fontSize: 12, fontWeight: 400, color: t.muted }, children: hint })
|
|
9786
9963
|
] });
|
|
9787
9964
|
}
|
|
9965
|
+
function PhoneField({
|
|
9966
|
+
t,
|
|
9967
|
+
dial,
|
|
9968
|
+
national,
|
|
9969
|
+
onChange,
|
|
9970
|
+
onBlur,
|
|
9971
|
+
error,
|
|
9972
|
+
hint
|
|
9973
|
+
}) {
|
|
9974
|
+
const box = {
|
|
9975
|
+
boxSizing: "border-box",
|
|
9976
|
+
padding: "9px 12px",
|
|
9977
|
+
background: t.input,
|
|
9978
|
+
color: t.text,
|
|
9979
|
+
border: `1px solid ${error ? t.danger : t.border}`,
|
|
9980
|
+
borderRadius: 8,
|
|
9981
|
+
fontFamily: "inherit",
|
|
9982
|
+
fontSize: 14,
|
|
9983
|
+
outline: "none"
|
|
9984
|
+
};
|
|
9985
|
+
return /* @__PURE__ */ jsxs6("label", { style: { display: "block", fontSize: 13, fontWeight: 500, color: t.text }, children: [
|
|
9986
|
+
"Mobile number",
|
|
9987
|
+
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", gap: 8, marginTop: 6 }, children: [
|
|
9988
|
+
/* @__PURE__ */ jsx6(
|
|
9989
|
+
"select",
|
|
9990
|
+
{
|
|
9991
|
+
"aria-label": "Country code",
|
|
9992
|
+
value: dial,
|
|
9993
|
+
onChange: (e) => onChange(e.target.value, national),
|
|
9994
|
+
style: { ...box, flex: "0 0 auto", paddingRight: 8, cursor: "pointer" },
|
|
9995
|
+
children: COUNTRIES.map((c) => /* @__PURE__ */ jsxs6("option", { value: c.dial, children: [
|
|
9996
|
+
c.iso,
|
|
9997
|
+
" +",
|
|
9998
|
+
c.dial
|
|
9999
|
+
] }, c.iso))
|
|
10000
|
+
}
|
|
10001
|
+
),
|
|
10002
|
+
/* @__PURE__ */ jsx6(
|
|
10003
|
+
"input",
|
|
10004
|
+
{
|
|
10005
|
+
type: "tel",
|
|
10006
|
+
autoComplete: "tel",
|
|
10007
|
+
inputMode: "numeric",
|
|
10008
|
+
placeholder: dial === "91" ? "98765 43210" : "Mobile number",
|
|
10009
|
+
value: national,
|
|
10010
|
+
"aria-invalid": Boolean(error),
|
|
10011
|
+
onChange: (e) => {
|
|
10012
|
+
const next = splitTypedPhone(e.target.value, dial);
|
|
10013
|
+
onChange(next.dial, next.national);
|
|
10014
|
+
},
|
|
10015
|
+
onBlur,
|
|
10016
|
+
style: { ...box, flex: "1 1 auto", minWidth: 0, width: "100%" }
|
|
10017
|
+
}
|
|
10018
|
+
)
|
|
10019
|
+
] }),
|
|
10020
|
+
error ? /* @__PURE__ */ jsx6("div", { role: "alert", style: { marginTop: 6, fontSize: 12, fontWeight: 500, color: t.danger }, children: error }) : /* @__PURE__ */ jsx6("div", { style: { marginTop: 6, fontSize: 12, fontWeight: 400, color: t.muted }, children: hint })
|
|
10021
|
+
] });
|
|
10022
|
+
}
|
|
9788
10023
|
|
|
9789
10024
|
// src/rejection.ts
|
|
9790
10025
|
var DETAILS_MAX_LENGTH = 1e3;
|
|
@@ -10375,8 +10610,18 @@ function GlitchgrabProviderInner({
|
|
|
10375
10610
|
const [signedUsers, setSignedUsers] = useState6("OFF");
|
|
10376
10611
|
const aiBlockedUnsigned = signedUsers === "ENFORCE" && !signature;
|
|
10377
10612
|
const [booking, setBooking] = useState6("closed");
|
|
10378
|
-
const
|
|
10379
|
-
const
|
|
10613
|
+
const [bookingOptions, setBookingOptions] = useState6({});
|
|
10614
|
+
const openBookingDialog = useCallback3((options) => {
|
|
10615
|
+
setBookingOptions({
|
|
10616
|
+
intro: typeof (options == null ? void 0 : options.intro) === "string" ? options.intro : void 0,
|
|
10617
|
+
onBooked: typeof (options == null ? void 0 : options.onBooked) === "function" ? options.onBooked : void 0
|
|
10618
|
+
});
|
|
10619
|
+
setBooking("live");
|
|
10620
|
+
}, []);
|
|
10621
|
+
const openBookingPreview = useCallback3(() => {
|
|
10622
|
+
setBookingOptions({});
|
|
10623
|
+
setBooking("preview");
|
|
10624
|
+
}, []);
|
|
10380
10625
|
useEffect6(() => {
|
|
10381
10626
|
let cancelled = false;
|
|
10382
10627
|
fetch(`${baseUrl}/api/v1/sdk/project`, {
|
|
@@ -10475,6 +10720,8 @@ function GlitchgrabProviderInner({
|
|
|
10475
10720
|
baseUrl: baseUrl != null ? baseUrl : DEFAULT_BASE_URL2,
|
|
10476
10721
|
open: booking !== "closed",
|
|
10477
10722
|
preview: booking === "preview",
|
|
10723
|
+
intro: bookingOptions.intro,
|
|
10724
|
+
onBooked: bookingOptions.onBooked,
|
|
10478
10725
|
onClose: () => setBooking("closed")
|
|
10479
10726
|
}
|
|
10480
10727
|
),
|
|
@@ -10616,12 +10863,13 @@ function BookDemoButton({
|
|
|
10616
10863
|
children
|
|
10617
10864
|
}) {
|
|
10618
10865
|
const { openBookingDialog } = useGlitchgrab();
|
|
10619
|
-
|
|
10866
|
+
const open = () => openBookingDialog();
|
|
10867
|
+
if (children) return /* @__PURE__ */ jsx9(Fragment8, { children: children({ onClick: open }) });
|
|
10620
10868
|
return /* @__PURE__ */ jsx9(
|
|
10621
10869
|
"button",
|
|
10622
10870
|
{
|
|
10623
10871
|
type: "button",
|
|
10624
|
-
onClick:
|
|
10872
|
+
onClick: open,
|
|
10625
10873
|
className,
|
|
10626
10874
|
style: className ? void 0 : {
|
|
10627
10875
|
padding: "10px 18px",
|