@gropulse/booking-widget 0.1.1 → 0.1.2
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/index.cjs +1 -1
- package/dist/index.js +41 -38
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),w=require("react");function v(g){const{apiBaseUrl:o,context:r,onBookingConfirmed:t}=g,[s,b]=w.useState([]),[d,n]=w.useState(null),[f,i]=w.useState(null),[u,x]=w.useState(!1),[j,p]=w.useState(null),h=w.useCallback(async l=>{const a={...r,timezone:r.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone},c=await fetch(`${o}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:l,context:a})});if(!c.ok){const m=await c.text();throw new Error(`Chat API error ${c.status}: ${m}`)}return await c.json()},[o,r]),y=w.useCallback(l=>{b(a=>[...a,{role:"assistant",content:l.message}]),l.action==="show_slots"&&l.slots&&n(l.slots),l.action==="booking_confirmed"&&l.booking&&(i(l.booking),n(null),t==null||t(l.booking))},[t]),k=w.useCallback(async()=>{if(!(s.length>0||u)){x(!0),p(null);try{const a=await h([{role:"user",content:"__START__"}]);b([{role:"assistant",content:a.message}]),a.action==="show_slots"&&a.slots&&n(a.slots),a.action==="booking_confirmed"&&a.booking&&(i(a.booking),t==null||t(a.booking))}catch(l){p(l.message)}finally{x(!1)}}},[s.length,u,h,t]),N=w.useCallback(async l=>{const a=l.trim();if(!a||u)return;const c=[...s,{role:"user",content:a}];b(c),x(!0),p(null);try{const m=await h(c);y(m)}catch(m){p(m.message)}finally{x(!1)}},[s,u,h,y]),S=w.useCallback(async l=>{if(u)return;const a=new Date(l.time).toLocaleString(void 0,{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),c=[...s,{role:"user",content:`I'll take ${a} (${l.time})`}];b(c),n(null),x(!0),p(null);try{const m=await h(c);y(m)}catch(m){p(m.message)}finally{x(!1)}},[s,u,h,y]);return{messages:s,slots:d,booking:f,isLoading:u,error:j,sendMessage:N,pickSlot:S,start:k}}function C(g){return g.split(`
|
|
2
|
-
`).flatMap((o,r,t)=>{const s=[],b=o.split(/(\*\*[^*]+\*\*|\*[^*]+\*)/g);for(let d=0;d<b.length;d++){const n=b[d];n.startsWith("**")&&n.endsWith("**")?s.push(e.jsx("strong",{children:n.slice(2,-2)},`${r}-${d}`)):n.startsWith("*")&&n.endsWith("*")?s.push(e.jsx("em",{children:n.slice(1,-1)},`${r}-${d}`)):s.push(n)}return r<t.length-1&&s.push(e.jsx("br",{},`br-${r}`)),s})}function L({message:g}){const o=g.role==="user";return e.jsx("div",{className:`gbw-flex ${o?"gbw-justify-end":"gbw-justify-start"} gbw-mb-2`,children:e.jsx("div",{className:o?"gbw-max-w-[80%] gbw-rounded-2xl gbw-rounded-br-sm gbw-bg-gropulse-navy gbw-px-3.5 gbw-py-2 gbw-text-sm gbw-text-white":"gbw-max-w-[80%] gbw-rounded-2xl gbw-rounded-bl-sm gbw-bg-gropulse-bg gbw-px-3.5 gbw-py-2 gbw-text-sm gbw-text-gropulse-text gbw-border gbw-border-gropulse-border",children:o?g.content:C(g.content)})})}function $({messages:g,isLoading:o}){const r=w.useRef(null);return w.useEffect(()=>{var t;(t=r.current)==null||t.scrollIntoView({behavior:"smooth",block:"end"})},[g,o]),e.jsxs("div",{className:"gbw-flex-1 gbw-overflow-y-auto gbw-px-4 gbw-py-3",children:[g.map((t,s)=>e.jsx(L,{message:t},s)),o?e.jsx(
|
|
2
|
+
`).flatMap((o,r,t)=>{const s=[],b=o.split(/(\*\*[^*]+\*\*|\*[^*]+\*)/g);for(let d=0;d<b.length;d++){const n=b[d];n.startsWith("**")&&n.endsWith("**")?s.push(e.jsx("strong",{children:n.slice(2,-2)},`${r}-${d}`)):n.startsWith("*")&&n.endsWith("*")?s.push(e.jsx("em",{children:n.slice(1,-1)},`${r}-${d}`)):s.push(n)}return r<t.length-1&&s.push(e.jsx("br",{},`br-${r}`)),s})}function L({message:g}){const o=g.role==="user";return e.jsx("div",{className:`gbw-flex ${o?"gbw-justify-end":"gbw-justify-start"} gbw-mb-2`,children:e.jsx("div",{className:o?"gbw-max-w-[80%] gbw-rounded-2xl gbw-rounded-br-sm gbw-bg-gropulse-navy gbw-px-3.5 gbw-py-2 gbw-text-sm gbw-text-white":"gbw-max-w-[80%] gbw-rounded-2xl gbw-rounded-bl-sm gbw-bg-gropulse-bg gbw-px-3.5 gbw-py-2 gbw-text-sm gbw-text-gropulse-text gbw-border gbw-border-gropulse-border",children:o?g.content:C(g.content)})})}function $({messages:g,isLoading:o}){const r=w.useRef(null);return w.useEffect(()=>{var t;(t=r.current)==null||t.scrollIntoView({behavior:"smooth",block:"end"})},[g,o]),e.jsxs("div",{className:"gbw-flex-1 gbw-overflow-y-auto gbw-px-4 gbw-py-3",children:[g.map((t,s)=>e.jsx(L,{message:t},s)),o?e.jsx(T,{}):null,e.jsx("div",{ref:r})]})}function T(){return e.jsx("div",{className:"gbw-flex gbw-justify-start gbw-mb-2",children:e.jsx("div",{className:"gbw-rounded-2xl gbw-rounded-bl-sm gbw-bg-gropulse-bg gbw-border gbw-border-gropulse-border gbw-px-3.5 gbw-py-2.5",children:e.jsxs("div",{className:"gbw-flex gbw-gap-1",children:[e.jsx("span",{className:"gbw-typing-dot gbw-h-1.5 gbw-w-1.5 gbw-rounded-full gbw-bg-gropulse-muted gbw-inline-block"}),e.jsx("span",{className:"gbw-typing-dot gbw-h-1.5 gbw-w-1.5 gbw-rounded-full gbw-bg-gropulse-muted gbw-inline-block"}),e.jsx("span",{className:"gbw-typing-dot gbw-h-1.5 gbw-w-1.5 gbw-rounded-full gbw-bg-gropulse-muted gbw-inline-block"})]})})})}function B({onSend:g,disabled:o,placeholder:r}){const[t,s]=w.useState(""),b=()=>{const n=t.trim();!n||o||(g(n),s(""))},d=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),b())};return e.jsx("div",{className:"gbw-border-t gbw-border-gropulse-border gbw-bg-white gbw-p-3",children:e.jsxs("div",{className:"gbw-flex gbw-items-end gbw-gap-2",children:[e.jsx("textarea",{value:t,onChange:n=>s(n.target.value),onKeyDown:d,disabled:o,rows:1,placeholder:r??"Type a message…",className:"gbw-flex-1 gbw-resize-none gbw-rounded-xl gbw-border gbw-border-gropulse-border gbw-bg-white gbw-px-3 gbw-py-2 gbw-text-sm gbw-outline-none focus:gbw-border-gropulse-navy focus:gbw-ring-2 focus:gbw-ring-gropulse-navy/10 disabled:gbw-bg-gropulse-bg disabled:gbw-text-gropulse-muted",style:{maxHeight:120}}),e.jsx("button",{type:"button",onClick:b,disabled:o||!t.trim(),className:"gbw-shrink-0 gbw-rounded-xl gbw-bg-gropulse-navy gbw-px-4 gbw-py-2 gbw-text-sm gbw-font-medium gbw-text-white gbw-transition hover:gbw-bg-gropulse-navyHover disabled:gbw-opacity-40",children:"Send"})]})})}function M({slots:g,onPick:o,disabled:r}){const t=w.useMemo(()=>D(g),[g]);return g.length===0?e.jsx("div",{className:"gbw-mx-4 gbw-mb-3 gbw-rounded-xl gbw-border gbw-border-gropulse-border gbw-bg-gropulse-bg gbw-px-3 gbw-py-2 gbw-text-sm gbw-text-gropulse-muted",children:"No slots available right now — try again in a moment."}):e.jsxs("div",{className:"gbw-mx-4 gbw-mb-3 gbw-rounded-xl gbw-border gbw-border-gropulse-border gbw-bg-white gbw-p-3",children:[e.jsx("div",{className:"gbw-mb-2 gbw-text-xs gbw-font-medium gbw-uppercase gbw-tracking-wide gbw-text-gropulse-muted",children:"Pick a time that works"}),e.jsx("div",{className:"gbw-flex gbw-flex-col gbw-gap-3 gbw-max-h-60 gbw-overflow-y-auto",children:t.map(s=>e.jsxs("div",{children:[e.jsx("div",{className:"gbw-mb-1.5 gbw-text-xs gbw-font-semibold gbw-text-gropulse-text",children:s.dayLabel}),e.jsx("div",{className:"gbw-grid gbw-grid-cols-3 gbw-gap-1.5",children:s.slots.map(b=>e.jsx("button",{type:"button",disabled:r,onClick:()=>o(b),className:"gbw-rounded-lg gbw-border gbw-border-gropulse-border gbw-bg-white gbw-px-2 gbw-py-1.5 gbw-text-xs gbw-font-medium gbw-text-gropulse-text gbw-transition hover:gbw-border-gropulse-navy hover:gbw-bg-gropulse-navy hover:gbw-text-white disabled:gbw-opacity-40",children:W(b.time)},b.time))})]},s.dayLabel))})]})}function D(g){const o=new Map;for(const t of g){const b=new Date(t.time).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"}),d=o.get(b);d?d.push(t):o.set(b,[t])}const r=new Date().toLocaleTimeString(void 0,{timeZoneName:"short"}).split(" ").pop()??"";return Array.from(o.entries()).map(([t,s])=>({dayLabel:`${t} · ${r}`,slots:s}))}function W(g){return new Date(g).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function _(g){const{apiBaseUrl:o,context:r,trigger:t="button",buttonLabel:s="Book Free Strategy Call",onBookingConfirmed:b,className:d}=g,[n,f]=w.useState(t==="auto"),i=v({apiBaseUrl:o,context:r,onBookingConfirmed:b});return w.useEffect(()=>{n&&i.messages.length===0&&!i.isLoading&&i.start()},[n,i]),e.jsxs("div",{className:`gbw-root ${d??""}`,children:[t==="button"?e.jsxs("button",{type:"button",onClick:()=>f(u=>!u),className:"gbw-inline-flex gbw-items-center gbw-gap-2 gbw-rounded-xl gbw-bg-gropulse-navy gbw-px-4 gbw-py-2.5 gbw-text-sm gbw-font-medium gbw-text-white gbw-shadow-sm gbw-transition hover:gbw-bg-gropulse-navyHover",children:[e.jsx("span",{className:"gbw-h-2 gbw-w-2 gbw-rounded-full gbw-bg-gropulse-accent"}),s]}):null,n?e.jsxs("div",{className:"gbw-fixed gbw-inset-0 gbw-z-[9999] gbw-flex gbw-items-end gbw-justify-end gbw-p-0 sm:gbw-p-4",children:[e.jsx("div",{className:"gbw-absolute gbw-inset-0 gbw-bg-black/20",onClick:()=>f(!1)}),e.jsxs("div",{className:"gbw-relative gbw-flex gbw-h-full gbw-w-full gbw-flex-col gbw-overflow-hidden gbw-bg-white gbw-shadow-panel sm:gbw-h-[620px] sm:gbw-w-[400px] sm:gbw-rounded-2xl",children:[e.jsx(z,{ownerName:r.ownerName,onClose:()=>f(!1)}),e.jsx($,{messages:i.messages,isLoading:i.isLoading}),i.slots&&!i.booking?e.jsx(M,{slots:i.slots,onPick:i.pickSlot,disabled:i.isLoading}):null,i.error?e.jsx("div",{className:"gbw-mx-4 gbw-mb-2 gbw-rounded-lg gbw-border gbw-border-red-200 gbw-bg-red-50 gbw-px-3 gbw-py-2 gbw-text-xs gbw-text-red-700",children:i.error}):null,i.booking?e.jsx(P,{}):e.jsx(B,{onSend:i.sendMessage,disabled:i.isLoading,placeholder:"Reply…"})]})]}):null]})}function z({ownerName:g,onClose:o}){return e.jsxs("div",{className:"gbw-flex gbw-items-center gbw-justify-between gbw-border-b gbw-border-gropulse-border gbw-bg-gropulse-navy gbw-px-4 gbw-py-3 gbw-text-white",children:[e.jsxs("div",{children:[e.jsx("div",{className:"gbw-text-sm gbw-font-semibold",children:"Gropulse Growth Strategy"}),e.jsxs("div",{className:"gbw-text-xs gbw-text-white/70",children:["Hey ",g.split(" ")[0]," — let’s find a time."]})]}),e.jsx("button",{type:"button",onClick:o,"aria-label":"Close",className:"gbw-rounded-md gbw-p-1 gbw-text-white/80 gbw-transition hover:gbw-bg-white/10 hover:gbw-text-white",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})})]})}function P(){return e.jsx("div",{className:"gbw-border-t gbw-border-gropulse-border gbw-bg-gropulse-bg gbw-px-4 gbw-py-3 gbw-text-center gbw-text-xs gbw-text-gropulse-muted",children:"Calendar invite on its way. You can close this window."})}exports.BookingWidget=_;exports.useBookingChat=v;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useState as p, useCallback as v, useRef as
|
|
3
|
-
function
|
|
4
|
-
const { apiBaseUrl: s, context: r, onBookingConfirmed: t } = g, [o, b] = p([]), [
|
|
1
|
+
import { jsx as e, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { useState as p, useCallback as v, useRef as T, useEffect as N, useMemo as j } from "react";
|
|
3
|
+
function D(g) {
|
|
4
|
+
const { apiBaseUrl: s, context: r, onBookingConfirmed: t } = g, [o, b] = p([]), [a, n] = p(null), [y, i] = p(null), [u, h] = p(!1), [L, f] = p(null), x = v(
|
|
5
5
|
async (l) => {
|
|
6
6
|
const w = {
|
|
7
7
|
...r,
|
|
@@ -23,7 +23,7 @@ function B(g) {
|
|
|
23
23
|
b((w) => [...w, { role: "assistant", content: l.message }]), l.action === "show_slots" && l.slots && n(l.slots), l.action === "booking_confirmed" && l.booking && (i(l.booking), n(null), t == null || t(l.booking));
|
|
24
24
|
},
|
|
25
25
|
[t]
|
|
26
|
-
),
|
|
26
|
+
), S = v(async () => {
|
|
27
27
|
if (!(o.length > 0 || u)) {
|
|
28
28
|
h(!0), f(null);
|
|
29
29
|
try {
|
|
@@ -38,7 +38,7 @@ function B(g) {
|
|
|
38
38
|
h(!1);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
}, [o.length, u, x, t]),
|
|
41
|
+
}, [o.length, u, x, t]), C = v(
|
|
42
42
|
async (l) => {
|
|
43
43
|
const w = l.trim();
|
|
44
44
|
if (!w || u) return;
|
|
@@ -79,15 +79,15 @@ function B(g) {
|
|
|
79
79
|
},
|
|
80
80
|
[o, u, x, k]
|
|
81
81
|
);
|
|
82
|
-
return { messages: o, slots:
|
|
82
|
+
return { messages: o, slots: a, booking: y, isLoading: u, error: L, sendMessage: C, pickSlot: $, start: S };
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function B(g) {
|
|
85
85
|
return g.split(`
|
|
86
86
|
`).flatMap((s, r, t) => {
|
|
87
87
|
const o = [], b = s.split(/(\*\*[^*]+\*\*|\*[^*]+\*)/g);
|
|
88
|
-
for (let
|
|
89
|
-
const n = b[
|
|
90
|
-
n.startsWith("**") && n.endsWith("**") ? o.push(/* @__PURE__ */ e("strong", { children: n.slice(2, -2) }, `${r}-${
|
|
88
|
+
for (let a = 0; a < b.length; a++) {
|
|
89
|
+
const n = b[a];
|
|
90
|
+
n.startsWith("**") && n.endsWith("**") ? o.push(/* @__PURE__ */ e("strong", { children: n.slice(2, -2) }, `${r}-${a}`)) : n.startsWith("*") && n.endsWith("*") ? o.push(/* @__PURE__ */ e("em", { children: n.slice(1, -1) }, `${r}-${a}`)) : o.push(n);
|
|
91
91
|
}
|
|
92
92
|
return r < t.length - 1 && o.push(/* @__PURE__ */ e("br", {}, `br-${r}`)), o;
|
|
93
93
|
});
|
|
@@ -98,23 +98,23 @@ function M({ message: g }) {
|
|
|
98
98
|
"div",
|
|
99
99
|
{
|
|
100
100
|
className: s ? "gbw-max-w-[80%] gbw-rounded-2xl gbw-rounded-br-sm gbw-bg-gropulse-navy gbw-px-3.5 gbw-py-2 gbw-text-sm gbw-text-white" : "gbw-max-w-[80%] gbw-rounded-2xl gbw-rounded-bl-sm gbw-bg-gropulse-bg gbw-px-3.5 gbw-py-2 gbw-text-sm gbw-text-gropulse-text gbw-border gbw-border-gropulse-border",
|
|
101
|
-
children: s ? g.content :
|
|
101
|
+
children: s ? g.content : B(g.content)
|
|
102
102
|
}
|
|
103
103
|
) });
|
|
104
104
|
}
|
|
105
105
|
function _({ messages: g, isLoading: s }) {
|
|
106
|
-
const r =
|
|
106
|
+
const r = T(null);
|
|
107
107
|
return N(() => {
|
|
108
108
|
var t;
|
|
109
109
|
(t = r.current) == null || t.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
110
|
-
}, [g, s]), /* @__PURE__ */
|
|
110
|
+
}, [g, s]), /* @__PURE__ */ d("div", { className: "gbw-flex-1 gbw-overflow-y-auto gbw-px-4 gbw-py-3", children: [
|
|
111
111
|
g.map((t, o) => /* @__PURE__ */ e(M, { message: t }, o)),
|
|
112
112
|
s ? /* @__PURE__ */ e(W, {}) : null,
|
|
113
113
|
/* @__PURE__ */ e("div", { ref: r })
|
|
114
114
|
] });
|
|
115
115
|
}
|
|
116
116
|
function W() {
|
|
117
|
-
return /* @__PURE__ */ e("div", { className: "gbw-flex gbw-justify-start gbw-mb-2", children: /* @__PURE__ */ e("div", { className: "gbw-rounded-2xl gbw-rounded-bl-sm gbw-bg-gropulse-bg gbw-border gbw-border-gropulse-border gbw-px-3.5 gbw-py-2.5", children: /* @__PURE__ */
|
|
117
|
+
return /* @__PURE__ */ e("div", { className: "gbw-flex gbw-justify-start gbw-mb-2", children: /* @__PURE__ */ e("div", { className: "gbw-rounded-2xl gbw-rounded-bl-sm gbw-bg-gropulse-bg gbw-border gbw-border-gropulse-border gbw-px-3.5 gbw-py-2.5", children: /* @__PURE__ */ d("div", { className: "gbw-flex gbw-gap-1", children: [
|
|
118
118
|
/* @__PURE__ */ e("span", { className: "gbw-typing-dot gbw-h-1.5 gbw-w-1.5 gbw-rounded-full gbw-bg-gropulse-muted gbw-inline-block" }),
|
|
119
119
|
/* @__PURE__ */ e("span", { className: "gbw-typing-dot gbw-h-1.5 gbw-w-1.5 gbw-rounded-full gbw-bg-gropulse-muted gbw-inline-block" }),
|
|
120
120
|
/* @__PURE__ */ e("span", { className: "gbw-typing-dot gbw-h-1.5 gbw-w-1.5 gbw-rounded-full gbw-bg-gropulse-muted gbw-inline-block" })
|
|
@@ -125,7 +125,7 @@ function z({ onSend: g, disabled: s, placeholder: r }) {
|
|
|
125
125
|
const n = t.trim();
|
|
126
126
|
!n || s || (g(n), o(""));
|
|
127
127
|
};
|
|
128
|
-
return /* @__PURE__ */ e("div", { className: "gbw-border-t gbw-border-gropulse-border gbw-bg-white gbw-p-3", children: /* @__PURE__ */
|
|
128
|
+
return /* @__PURE__ */ e("div", { className: "gbw-border-t gbw-border-gropulse-border gbw-bg-white gbw-p-3", children: /* @__PURE__ */ d("div", { className: "gbw-flex gbw-items-end gbw-gap-2", children: [
|
|
129
129
|
/* @__PURE__ */ e(
|
|
130
130
|
"textarea",
|
|
131
131
|
{
|
|
@@ -154,10 +154,10 @@ function z({ onSend: g, disabled: s, placeholder: r }) {
|
|
|
154
154
|
] }) });
|
|
155
155
|
}
|
|
156
156
|
function H({ slots: g, onPick: s, disabled: r }) {
|
|
157
|
-
const t =
|
|
158
|
-
return g.length === 0 ? /* @__PURE__ */ e("div", { className: "gbw-mx-4 gbw-mb-3 gbw-rounded-xl gbw-border gbw-border-gropulse-border gbw-bg-gropulse-bg gbw-px-3 gbw-py-2 gbw-text-sm gbw-text-gropulse-muted", children: "No slots available right now — try again in a moment." }) : /* @__PURE__ */
|
|
157
|
+
const t = j(() => P(g), [g]);
|
|
158
|
+
return g.length === 0 ? /* @__PURE__ */ e("div", { className: "gbw-mx-4 gbw-mb-3 gbw-rounded-xl gbw-border gbw-border-gropulse-border gbw-bg-gropulse-bg gbw-px-3 gbw-py-2 gbw-text-sm gbw-text-gropulse-muted", children: "No slots available right now — try again in a moment." }) : /* @__PURE__ */ d("div", { className: "gbw-mx-4 gbw-mb-3 gbw-rounded-xl gbw-border gbw-border-gropulse-border gbw-bg-white gbw-p-3", children: [
|
|
159
159
|
/* @__PURE__ */ e("div", { className: "gbw-mb-2 gbw-text-xs gbw-font-medium gbw-uppercase gbw-tracking-wide gbw-text-gropulse-muted", children: "Pick a time that works" }),
|
|
160
|
-
/* @__PURE__ */ e("div", { className: "gbw-flex gbw-flex-col gbw-gap-3 gbw-max-h-60 gbw-overflow-y-auto", children: t.map((o) => /* @__PURE__ */
|
|
160
|
+
/* @__PURE__ */ e("div", { className: "gbw-flex gbw-flex-col gbw-gap-3 gbw-max-h-60 gbw-overflow-y-auto", children: t.map((o) => /* @__PURE__ */ d("div", { children: [
|
|
161
161
|
/* @__PURE__ */ e("div", { className: "gbw-mb-1.5 gbw-text-xs gbw-font-semibold gbw-text-gropulse-text", children: o.dayLabel }),
|
|
162
162
|
/* @__PURE__ */ e("div", { className: "gbw-grid gbw-grid-cols-3 gbw-gap-1.5", children: o.slots.map((b) => /* @__PURE__ */ e(
|
|
163
163
|
"button",
|
|
@@ -175,21 +175,24 @@ function H({ slots: g, onPick: s, disabled: r }) {
|
|
|
175
175
|
}
|
|
176
176
|
function P(g) {
|
|
177
177
|
const s = /* @__PURE__ */ new Map();
|
|
178
|
-
for (const
|
|
179
|
-
const
|
|
180
|
-
weekday: "
|
|
178
|
+
for (const t of g) {
|
|
179
|
+
const b = new Date(t.time).toLocaleDateString(void 0, {
|
|
180
|
+
weekday: "long",
|
|
181
181
|
month: "short",
|
|
182
182
|
day: "numeric"
|
|
183
|
-
}),
|
|
184
|
-
|
|
183
|
+
}), a = s.get(b);
|
|
184
|
+
a ? a.push(t) : s.set(b, [t]);
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
const r = (/* @__PURE__ */ new Date()).toLocaleTimeString(void 0, { timeZoneName: "short" }).split(" ").pop() ?? "";
|
|
187
|
+
return Array.from(s.entries()).map(([t, o]) => ({
|
|
188
|
+
dayLabel: `${t} · ${r}`,
|
|
189
|
+
slots: o
|
|
190
|
+
}));
|
|
187
191
|
}
|
|
188
192
|
function R(g) {
|
|
189
193
|
return new Date(g).toLocaleTimeString(void 0, {
|
|
190
194
|
hour: "numeric",
|
|
191
|
-
minute: "2-digit"
|
|
192
|
-
timeZoneName: "short"
|
|
195
|
+
minute: "2-digit"
|
|
193
196
|
});
|
|
194
197
|
}
|
|
195
198
|
function A(g) {
|
|
@@ -199,12 +202,12 @@ function A(g) {
|
|
|
199
202
|
trigger: t = "button",
|
|
200
203
|
buttonLabel: o = "Book Free Strategy Call",
|
|
201
204
|
onBookingConfirmed: b,
|
|
202
|
-
className:
|
|
203
|
-
} = g, [n, y] = p(t === "auto"), i =
|
|
205
|
+
className: a
|
|
206
|
+
} = g, [n, y] = p(t === "auto"), i = D({ apiBaseUrl: s, context: r, onBookingConfirmed: b });
|
|
204
207
|
return N(() => {
|
|
205
208
|
n && i.messages.length === 0 && !i.isLoading && i.start();
|
|
206
|
-
}, [n, i]), /* @__PURE__ */
|
|
207
|
-
t === "button" ? /* @__PURE__ */
|
|
209
|
+
}, [n, i]), /* @__PURE__ */ d("div", { className: `gbw-root ${a ?? ""}`, children: [
|
|
210
|
+
t === "button" ? /* @__PURE__ */ d(
|
|
208
211
|
"button",
|
|
209
212
|
{
|
|
210
213
|
type: "button",
|
|
@@ -216,7 +219,7 @@ function A(g) {
|
|
|
216
219
|
]
|
|
217
220
|
}
|
|
218
221
|
) : null,
|
|
219
|
-
n ? /* @__PURE__ */
|
|
222
|
+
n ? /* @__PURE__ */ d("div", { className: "gbw-fixed gbw-inset-0 gbw-z-[9999] gbw-flex gbw-items-end gbw-justify-end gbw-p-0 sm:gbw-p-4", children: [
|
|
220
223
|
/* @__PURE__ */ e(
|
|
221
224
|
"div",
|
|
222
225
|
{
|
|
@@ -224,7 +227,7 @@ function A(g) {
|
|
|
224
227
|
onClick: () => y(!1)
|
|
225
228
|
}
|
|
226
229
|
),
|
|
227
|
-
/* @__PURE__ */
|
|
230
|
+
/* @__PURE__ */ d("div", { className: "gbw-relative gbw-flex gbw-h-full gbw-w-full gbw-flex-col gbw-overflow-hidden gbw-bg-white gbw-shadow-panel sm:gbw-h-[620px] sm:gbw-w-[400px] sm:gbw-rounded-2xl", children: [
|
|
228
231
|
/* @__PURE__ */ e(
|
|
229
232
|
E,
|
|
230
233
|
{
|
|
@@ -255,10 +258,10 @@ function A(g) {
|
|
|
255
258
|
] });
|
|
256
259
|
}
|
|
257
260
|
function E({ ownerName: g, onClose: s }) {
|
|
258
|
-
return /* @__PURE__ */
|
|
259
|
-
/* @__PURE__ */
|
|
261
|
+
return /* @__PURE__ */ d("div", { className: "gbw-flex gbw-items-center gbw-justify-between gbw-border-b gbw-border-gropulse-border gbw-bg-gropulse-navy gbw-px-4 gbw-py-3 gbw-text-white", children: [
|
|
262
|
+
/* @__PURE__ */ d("div", { children: [
|
|
260
263
|
/* @__PURE__ */ e("div", { className: "gbw-text-sm gbw-font-semibold", children: "Gropulse Growth Strategy" }),
|
|
261
|
-
/* @__PURE__ */
|
|
264
|
+
/* @__PURE__ */ d("div", { className: "gbw-text-xs gbw-text-white/70", children: [
|
|
262
265
|
"Hey ",
|
|
263
266
|
g.split(" ")[0],
|
|
264
267
|
" — let’s find a time."
|
|
@@ -271,7 +274,7 @@ function E({ ownerName: g, onClose: s }) {
|
|
|
271
274
|
onClick: s,
|
|
272
275
|
"aria-label": "Close",
|
|
273
276
|
className: "gbw-rounded-md gbw-p-1 gbw-text-white/80 gbw-transition hover:gbw-bg-white/10 hover:gbw-text-white",
|
|
274
|
-
children: /* @__PURE__ */
|
|
277
|
+
children: /* @__PURE__ */ d(
|
|
275
278
|
"svg",
|
|
276
279
|
{
|
|
277
280
|
width: "18",
|
|
@@ -297,5 +300,5 @@ function I() {
|
|
|
297
300
|
}
|
|
298
301
|
export {
|
|
299
302
|
A as BookingWidget,
|
|
300
|
-
|
|
303
|
+
D as useBookingChat
|
|
301
304
|
};
|
package/package.json
CHANGED