meeting-scheduler-npm-package 1.0.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.
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { MeetingSchedulerProps } from "../types";
3
+ declare const MeetingScheduler: React.FC<MeetingSchedulerProps>;
4
+ export default MeetingScheduler;
@@ -0,0 +1 @@
1
+ export declare const API_BASE = "https://schedule-api.betopialimited.com/api";
@@ -0,0 +1,608 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ var jsxRuntime = {exports: {}};
6
+
7
+ var reactJsxRuntime_production = {};
8
+
9
+ /**
10
+ * @license React
11
+ * react-jsx-runtime.production.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */
18
+
19
+ var hasRequiredReactJsxRuntime_production;
20
+
21
+ function requireReactJsxRuntime_production () {
22
+ if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
23
+ hasRequiredReactJsxRuntime_production = 1;
24
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
25
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
26
+ function jsxProd(type, config, maybeKey) {
27
+ var key = null;
28
+ void 0 !== maybeKey && (key = "" + maybeKey);
29
+ void 0 !== config.key && (key = "" + config.key);
30
+ if ("key" in config) {
31
+ maybeKey = {};
32
+ for (var propName in config)
33
+ "key" !== propName && (maybeKey[propName] = config[propName]);
34
+ } else maybeKey = config;
35
+ config = maybeKey.ref;
36
+ return {
37
+ $$typeof: REACT_ELEMENT_TYPE,
38
+ type: type,
39
+ key: key,
40
+ ref: void 0 !== config ? config : null,
41
+ props: maybeKey
42
+ };
43
+ }
44
+ reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
45
+ reactJsxRuntime_production.jsx = jsxProd;
46
+ reactJsxRuntime_production.jsxs = jsxProd;
47
+ return reactJsxRuntime_production;
48
+ }
49
+
50
+ var reactJsxRuntime_development = {};
51
+
52
+ /**
53
+ * @license React
54
+ * react-jsx-runtime.development.js
55
+ *
56
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
57
+ *
58
+ * This source code is licensed under the MIT license found in the
59
+ * LICENSE file in the root directory of this source tree.
60
+ */
61
+
62
+ var hasRequiredReactJsxRuntime_development;
63
+
64
+ function requireReactJsxRuntime_development () {
65
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
66
+ hasRequiredReactJsxRuntime_development = 1;
67
+ "production" !== process.env.NODE_ENV &&
68
+ (function () {
69
+ function getComponentNameFromType(type) {
70
+ if (null == type) return null;
71
+ if ("function" === typeof type)
72
+ return type.$$typeof === REACT_CLIENT_REFERENCE
73
+ ? null
74
+ : type.displayName || type.name || null;
75
+ if ("string" === typeof type) return type;
76
+ switch (type) {
77
+ case REACT_FRAGMENT_TYPE:
78
+ return "Fragment";
79
+ case REACT_PROFILER_TYPE:
80
+ return "Profiler";
81
+ case REACT_STRICT_MODE_TYPE:
82
+ return "StrictMode";
83
+ case REACT_SUSPENSE_TYPE:
84
+ return "Suspense";
85
+ case REACT_SUSPENSE_LIST_TYPE:
86
+ return "SuspenseList";
87
+ case REACT_ACTIVITY_TYPE:
88
+ return "Activity";
89
+ }
90
+ if ("object" === typeof type)
91
+ switch (
92
+ ("number" === typeof type.tag &&
93
+ console.error(
94
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
95
+ ),
96
+ type.$$typeof)
97
+ ) {
98
+ case REACT_PORTAL_TYPE:
99
+ return "Portal";
100
+ case REACT_CONTEXT_TYPE:
101
+ return type.displayName || "Context";
102
+ case REACT_CONSUMER_TYPE:
103
+ return (type._context.displayName || "Context") + ".Consumer";
104
+ case REACT_FORWARD_REF_TYPE:
105
+ var innerType = type.render;
106
+ type = type.displayName;
107
+ type ||
108
+ ((type = innerType.displayName || innerType.name || ""),
109
+ (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
110
+ return type;
111
+ case REACT_MEMO_TYPE:
112
+ return (
113
+ (innerType = type.displayName || null),
114
+ null !== innerType
115
+ ? innerType
116
+ : getComponentNameFromType(type.type) || "Memo"
117
+ );
118
+ case REACT_LAZY_TYPE:
119
+ innerType = type._payload;
120
+ type = type._init;
121
+ try {
122
+ return getComponentNameFromType(type(innerType));
123
+ } catch (x) {}
124
+ }
125
+ return null;
126
+ }
127
+ function testStringCoercion(value) {
128
+ return "" + value;
129
+ }
130
+ function checkKeyStringCoercion(value) {
131
+ try {
132
+ testStringCoercion(value);
133
+ var JSCompiler_inline_result = !1;
134
+ } catch (e) {
135
+ JSCompiler_inline_result = true;
136
+ }
137
+ if (JSCompiler_inline_result) {
138
+ JSCompiler_inline_result = console;
139
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
140
+ var JSCompiler_inline_result$jscomp$0 =
141
+ ("function" === typeof Symbol &&
142
+ Symbol.toStringTag &&
143
+ value[Symbol.toStringTag]) ||
144
+ value.constructor.name ||
145
+ "Object";
146
+ JSCompiler_temp_const.call(
147
+ JSCompiler_inline_result,
148
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
149
+ JSCompiler_inline_result$jscomp$0
150
+ );
151
+ return testStringCoercion(value);
152
+ }
153
+ }
154
+ function getTaskName(type) {
155
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
156
+ if (
157
+ "object" === typeof type &&
158
+ null !== type &&
159
+ type.$$typeof === REACT_LAZY_TYPE
160
+ )
161
+ return "<...>";
162
+ try {
163
+ var name = getComponentNameFromType(type);
164
+ return name ? "<" + name + ">" : "<...>";
165
+ } catch (x) {
166
+ return "<...>";
167
+ }
168
+ }
169
+ function getOwner() {
170
+ var dispatcher = ReactSharedInternals.A;
171
+ return null === dispatcher ? null : dispatcher.getOwner();
172
+ }
173
+ function UnknownOwner() {
174
+ return Error("react-stack-top-frame");
175
+ }
176
+ function hasValidKey(config) {
177
+ if (hasOwnProperty.call(config, "key")) {
178
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
179
+ if (getter && getter.isReactWarning) return false;
180
+ }
181
+ return void 0 !== config.key;
182
+ }
183
+ function defineKeyPropWarningGetter(props, displayName) {
184
+ function warnAboutAccessingKey() {
185
+ specialPropKeyWarningShown ||
186
+ ((specialPropKeyWarningShown = true),
187
+ console.error(
188
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
189
+ displayName
190
+ ));
191
+ }
192
+ warnAboutAccessingKey.isReactWarning = true;
193
+ Object.defineProperty(props, "key", {
194
+ get: warnAboutAccessingKey,
195
+ configurable: true
196
+ });
197
+ }
198
+ function elementRefGetterWithDeprecationWarning() {
199
+ var componentName = getComponentNameFromType(this.type);
200
+ didWarnAboutElementRef[componentName] ||
201
+ ((didWarnAboutElementRef[componentName] = true),
202
+ console.error(
203
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
204
+ ));
205
+ componentName = this.props.ref;
206
+ return void 0 !== componentName ? componentName : null;
207
+ }
208
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
209
+ var refProp = props.ref;
210
+ type = {
211
+ $$typeof: REACT_ELEMENT_TYPE,
212
+ type: type,
213
+ key: key,
214
+ props: props,
215
+ _owner: owner
216
+ };
217
+ null !== (void 0 !== refProp ? refProp : null)
218
+ ? Object.defineProperty(type, "ref", {
219
+ enumerable: false,
220
+ get: elementRefGetterWithDeprecationWarning
221
+ })
222
+ : Object.defineProperty(type, "ref", { enumerable: false, value: null });
223
+ type._store = {};
224
+ Object.defineProperty(type._store, "validated", {
225
+ configurable: false,
226
+ enumerable: false,
227
+ writable: true,
228
+ value: 0
229
+ });
230
+ Object.defineProperty(type, "_debugInfo", {
231
+ configurable: false,
232
+ enumerable: false,
233
+ writable: true,
234
+ value: null
235
+ });
236
+ Object.defineProperty(type, "_debugStack", {
237
+ configurable: false,
238
+ enumerable: false,
239
+ writable: true,
240
+ value: debugStack
241
+ });
242
+ Object.defineProperty(type, "_debugTask", {
243
+ configurable: false,
244
+ enumerable: false,
245
+ writable: true,
246
+ value: debugTask
247
+ });
248
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
249
+ return type;
250
+ }
251
+ function jsxDEVImpl(
252
+ type,
253
+ config,
254
+ maybeKey,
255
+ isStaticChildren,
256
+ debugStack,
257
+ debugTask
258
+ ) {
259
+ var children = config.children;
260
+ if (void 0 !== children)
261
+ if (isStaticChildren)
262
+ if (isArrayImpl(children)) {
263
+ for (
264
+ isStaticChildren = 0;
265
+ isStaticChildren < children.length;
266
+ isStaticChildren++
267
+ )
268
+ validateChildKeys(children[isStaticChildren]);
269
+ Object.freeze && Object.freeze(children);
270
+ } else
271
+ console.error(
272
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
273
+ );
274
+ else validateChildKeys(children);
275
+ if (hasOwnProperty.call(config, "key")) {
276
+ children = getComponentNameFromType(type);
277
+ var keys = Object.keys(config).filter(function (k) {
278
+ return "key" !== k;
279
+ });
280
+ isStaticChildren =
281
+ 0 < keys.length
282
+ ? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
283
+ : "{key: someKey}";
284
+ didWarnAboutKeySpread[children + isStaticChildren] ||
285
+ ((keys =
286
+ 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
287
+ console.error(
288
+ 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
289
+ isStaticChildren,
290
+ children,
291
+ keys,
292
+ children
293
+ ),
294
+ (didWarnAboutKeySpread[children + isStaticChildren] = true));
295
+ }
296
+ children = null;
297
+ void 0 !== maybeKey &&
298
+ (checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
299
+ hasValidKey(config) &&
300
+ (checkKeyStringCoercion(config.key), (children = "" + config.key));
301
+ if ("key" in config) {
302
+ maybeKey = {};
303
+ for (var propName in config)
304
+ "key" !== propName && (maybeKey[propName] = config[propName]);
305
+ } else maybeKey = config;
306
+ children &&
307
+ defineKeyPropWarningGetter(
308
+ maybeKey,
309
+ "function" === typeof type
310
+ ? type.displayName || type.name || "Unknown"
311
+ : type
312
+ );
313
+ return ReactElement(
314
+ type,
315
+ children,
316
+ maybeKey,
317
+ getOwner(),
318
+ debugStack,
319
+ debugTask
320
+ );
321
+ }
322
+ function validateChildKeys(node) {
323
+ isValidElement(node)
324
+ ? node._store && (node._store.validated = 1)
325
+ : "object" === typeof node &&
326
+ null !== node &&
327
+ node.$$typeof === REACT_LAZY_TYPE &&
328
+ ("fulfilled" === node._payload.status
329
+ ? isValidElement(node._payload.value) &&
330
+ node._payload.value._store &&
331
+ (node._payload.value._store.validated = 1)
332
+ : node._store && (node._store.validated = 1));
333
+ }
334
+ function isValidElement(object) {
335
+ return (
336
+ "object" === typeof object &&
337
+ null !== object &&
338
+ object.$$typeof === REACT_ELEMENT_TYPE
339
+ );
340
+ }
341
+ var React$1 = React,
342
+ REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
343
+ REACT_PORTAL_TYPE = Symbol.for("react.portal"),
344
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
345
+ REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
346
+ REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
347
+ REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
348
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
349
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
350
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
351
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
352
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
353
+ REACT_LAZY_TYPE = Symbol.for("react.lazy"),
354
+ REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
355
+ REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
356
+ ReactSharedInternals =
357
+ React$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
358
+ hasOwnProperty = Object.prototype.hasOwnProperty,
359
+ isArrayImpl = Array.isArray,
360
+ createTask = console.createTask
361
+ ? console.createTask
362
+ : function () {
363
+ return null;
364
+ };
365
+ React$1 = {
366
+ react_stack_bottom_frame: function (callStackForError) {
367
+ return callStackForError();
368
+ }
369
+ };
370
+ var specialPropKeyWarningShown;
371
+ var didWarnAboutElementRef = {};
372
+ var unknownOwnerDebugStack = React$1.react_stack_bottom_frame.bind(
373
+ React$1,
374
+ UnknownOwner
375
+ )();
376
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
377
+ var didWarnAboutKeySpread = {};
378
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
379
+ reactJsxRuntime_development.jsx = function (type, config, maybeKey) {
380
+ var trackActualOwner =
381
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
382
+ return jsxDEVImpl(
383
+ type,
384
+ config,
385
+ maybeKey,
386
+ false,
387
+ trackActualOwner
388
+ ? Error("react-stack-top-frame")
389
+ : unknownOwnerDebugStack,
390
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
391
+ );
392
+ };
393
+ reactJsxRuntime_development.jsxs = function (type, config, maybeKey) {
394
+ var trackActualOwner =
395
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
396
+ return jsxDEVImpl(
397
+ type,
398
+ config,
399
+ maybeKey,
400
+ true,
401
+ trackActualOwner
402
+ ? Error("react-stack-top-frame")
403
+ : unknownOwnerDebugStack,
404
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
405
+ );
406
+ };
407
+ })();
408
+ return reactJsxRuntime_development;
409
+ }
410
+
411
+ var hasRequiredJsxRuntime;
412
+
413
+ function requireJsxRuntime () {
414
+ if (hasRequiredJsxRuntime) return jsxRuntime.exports;
415
+ hasRequiredJsxRuntime = 1;
416
+
417
+ if (process.env.NODE_ENV === 'production') {
418
+ jsxRuntime.exports = requireReactJsxRuntime_production();
419
+ } else {
420
+ jsxRuntime.exports = requireReactJsxRuntime_development();
421
+ }
422
+ return jsxRuntime.exports;
423
+ }
424
+
425
+ var jsxRuntimeExports = requireJsxRuntime();
426
+
427
+ var DefaultContext = {
428
+ color: undefined,
429
+ size: undefined,
430
+ className: undefined,
431
+ style: undefined,
432
+ attr: undefined
433
+ };
434
+ var IconContext = React.createContext && /*#__PURE__*/React.createContext(DefaultContext);
435
+
436
+ var _excluded = ["attr", "size", "title"];
437
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
438
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
439
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
440
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
441
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
442
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
443
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
444
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
445
+ function Tree2Element(tree) {
446
+ return tree && tree.map((node, i) => /*#__PURE__*/React.createElement(node.tag, _objectSpread({
447
+ key: i
448
+ }, node.attr), Tree2Element(node.child)));
449
+ }
450
+ function GenIcon(data) {
451
+ return props => /*#__PURE__*/React.createElement(IconBase, _extends({
452
+ attr: _objectSpread({}, data.attr)
453
+ }, props), Tree2Element(data.child));
454
+ }
455
+ function IconBase(props) {
456
+ var elem = conf => {
457
+ var {
458
+ attr,
459
+ size,
460
+ title
461
+ } = props,
462
+ svgProps = _objectWithoutProperties(props, _excluded);
463
+ var computedSize = size || conf.size || "1em";
464
+ var className;
465
+ if (conf.className) className = conf.className;
466
+ if (props.className) className = (className ? className + " " : "") + props.className;
467
+ return /*#__PURE__*/React.createElement("svg", _extends({
468
+ stroke: "currentColor",
469
+ fill: "currentColor",
470
+ strokeWidth: "0"
471
+ }, conf.attr, attr, svgProps, {
472
+ className: className,
473
+ style: _objectSpread(_objectSpread({
474
+ color: props.color || conf.color
475
+ }, conf.style), props.style),
476
+ height: computedSize,
477
+ width: computedSize,
478
+ xmlns: "http://www.w3.org/2000/svg"
479
+ }), title && /*#__PURE__*/React.createElement("title", null, title), props.children);
480
+ };
481
+ return IconContext !== undefined ? /*#__PURE__*/React.createElement(IconContext.Consumer, null, conf => elem(conf)) : elem(DefaultContext);
482
+ }
483
+
484
+ // THIS FILE IS AUTO GENERATED
485
+ function IoIosArrowBack (props) {
486
+ return GenIcon({"attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"path","attr":{"d":"M217.9 256L345 129c9.4-9.4 9.4-24.6 0-33.9-9.4-9.4-24.6-9.3-34 0L167 239c-9.1 9.1-9.3 23.7-.7 33.1L310.9 417c4.7 4.7 10.9 7 17 7s12.3-2.3 17-7c9.4-9.4 9.4-24.6 0-33.9L217.9 256z"},"child":[]}]})(props);
487
+ }function IoIosArrowForward (props) {
488
+ return GenIcon({"attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"path","attr":{"d":"M294.1 256L167 129c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.3 34 0L345 239c9.1 9.1 9.3 23.7.7 33.1L201.1 417c-4.7 4.7-10.9 7-17 7s-12.3-2.3-17-7c-9.4-9.4-9.4-24.6 0-33.9l127-127.1z"},"child":[]}]})(props);
489
+ }
490
+
491
+ const API_BASE = "https://schedule-api.betopialimited.com/api";
492
+
493
+ const daysOfWeek = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
494
+ const MeetingScheduler = ({ userId, availabilityId, authToken, onSuccess, onError, }) => {
495
+ const [currentMonth, setCurrentMonth] = React.useState(new Date());
496
+ const [selectedDate, setSelectedDate] = React.useState(null);
497
+ const [availableSlots, setAvailableSlots] = React.useState([]);
498
+ const [selectedSlot, setSelectedSlot] = React.useState(null);
499
+ const [loading, setLoading] = React.useState(false);
500
+ const [timezone, setTimezone] = React.useState("UTC");
501
+ const [formData, setFormData] = React.useState({
502
+ name: "",
503
+ email: "",
504
+ phone: "",
505
+ message: "",
506
+ });
507
+ /* ============ Timezone ============ */
508
+ React.useEffect(() => {
509
+ setTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone);
510
+ }, []);
511
+ /* ============ Helpers ============ */
512
+ const handleInputChange = (e) => {
513
+ setFormData(Object.assign(Object.assign({}, formData), { [e.target.name]: e.target.value }));
514
+ };
515
+ const formatTime = (value) => {
516
+ const time = value.split(" ")[1];
517
+ let [h, m] = time.split(":").map(Number);
518
+ const ampm = h >= 12 ? "PM" : "AM";
519
+ h = h % 12 || 12;
520
+ return `${h}:${m.toString().padStart(2, "0")} ${ampm}`;
521
+ };
522
+ const today = new Date();
523
+ today.setHours(0, 0, 0, 0);
524
+ const isPastDate = (date) => date <= today;
525
+ /* ============ API ============ */
526
+ const fetchSlots = async (date) => {
527
+ try {
528
+ setLoading(true);
529
+ const yyyy = date.getFullYear();
530
+ const mm = String(date.getMonth() + 1).padStart(2, "0");
531
+ const dd = String(date.getDate()).padStart(2, "0");
532
+ const res = await fetch(`${API_BASE}/v1/meeting-schedule/check-schedule/${yyyy}-${mm}-${dd}?timezone=${timezone}`, {
533
+ headers: authToken
534
+ ? { Authorization: `Bearer ${authToken}` }
535
+ : {},
536
+ });
537
+ const data = await res.json();
538
+ setAvailableSlots(data.slots || []);
539
+ }
540
+ catch (_a) {
541
+ onError === null || onError === void 0 ? void 0 : onError("Failed to load slots");
542
+ }
543
+ finally {
544
+ setLoading(false);
545
+ }
546
+ };
547
+ const handleBooking = async () => {
548
+ if (!selectedSlot)
549
+ return;
550
+ try {
551
+ setLoading(true);
552
+ const res = await fetch(`${API_BASE}/v1/meeting-schedule/book-schedule`, {
553
+ method: "POST",
554
+ headers: Object.assign({ "Content-Type": "application/json" }, (authToken && { Authorization: `Bearer ${authToken}` })),
555
+ body: JSON.stringify({
556
+ user_id: userId,
557
+ availability_id: availabilityId,
558
+ visitor: Object.assign(Object.assign({}, formData), { timezone }),
559
+ start: selectedSlot.start_local,
560
+ end: selectedSlot.end_local,
561
+ }),
562
+ });
563
+ if (!res.ok)
564
+ throw new Error();
565
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
566
+ setFormData({ name: "", email: "", phone: "", message: "" });
567
+ setSelectedSlot(null);
568
+ setSelectedDate(null);
569
+ }
570
+ catch (_a) {
571
+ onError === null || onError === void 0 ? void 0 : onError("Booking failed");
572
+ }
573
+ finally {
574
+ setLoading(false);
575
+ }
576
+ };
577
+ /* ============ Calendar ============ */
578
+ const getDaysInMonth = () => {
579
+ const year = currentMonth.getFullYear();
580
+ const month = currentMonth.getMonth();
581
+ const firstDay = new Date(year, month, 1).getDay();
582
+ const daysInMonth = new Date(year, month + 1, 0).getDate();
583
+ const days = [];
584
+ for (let i = 0; i < firstDay; i++)
585
+ days.push(null);
586
+ for (let i = 1; i <= daysInMonth; i++)
587
+ days.push(new Date(year, month, i));
588
+ return days;
589
+ };
590
+ const isFormValid = formData.name && formData.email && formData.phone && selectedSlot;
591
+ /* ============ JSX ============ */
592
+ return (jsxRuntimeExports.jsxs("div", { className: "bg-white p-6 rounded-xl shadow-md", children: [jsxRuntimeExports.jsx("h2", { className: "text-2xl font-semibold mb-4", children: "Schedule a Meeting" }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-4", children: [jsxRuntimeExports.jsx("button", { onClick: () => setCurrentMonth(new Date(currentMonth.getFullYear(), currentMonth.getMonth() - 1)), children: jsxRuntimeExports.jsx(IoIosArrowBack, {}) }), jsxRuntimeExports.jsx("span", { className: "font-semibold", children: currentMonth.toLocaleDateString("en-US", {
593
+ month: "long",
594
+ year: "numeric",
595
+ }) }), jsxRuntimeExports.jsx("button", { onClick: () => setCurrentMonth(new Date(currentMonth.getFullYear(), currentMonth.getMonth() + 1)), children: jsxRuntimeExports.jsx(IoIosArrowForward, {}) })] }), jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-7 gap-2 mb-4", children: [daysOfWeek.map((d) => (jsxRuntimeExports.jsx("div", { className: "text-center text-xs font-semibold", children: d }, d))), getDaysInMonth().map((day, i) => (jsxRuntimeExports.jsx("button", { disabled: !day || isPastDate(day), onClick: () => {
596
+ if (day) {
597
+ setSelectedDate(day);
598
+ fetchSlots(day);
599
+ }
600
+ }, className: `p-2 rounded ${(selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.toDateString()) === (day === null || day === void 0 ? void 0 : day.toDateString())
601
+ ? "bg-orange-500 text-white"
602
+ : "hover:bg-gray-100"}`, children: day === null || day === void 0 ? void 0 : day.getDate() }, i)))] }), selectedDate && (jsxRuntimeExports.jsx("div", { className: "space-y-2 mb-4", children: availableSlots.map((slot, i) => (jsxRuntimeExports.jsxs("button", { disabled: slot.is_booked, onClick: () => setSelectedSlot(slot), className: `w-full p-2 rounded ${selectedSlot === slot
603
+ ? "bg-orange-500 text-white"
604
+ : "bg-gray-100"}`, children: [formatTime(slot.start_local), " \u2013", " ", formatTime(slot.end_local)] }, i))) })), jsxRuntimeExports.jsx("input", { name: "name", placeholder: "Name", className: "w-full mb-2 p-2 border rounded", value: formData.name, onChange: handleInputChange }), jsxRuntimeExports.jsx("input", { name: "email", placeholder: "Email", className: "w-full mb-2 p-2 border rounded", value: formData.email, onChange: handleInputChange }), jsxRuntimeExports.jsx("input", { name: "phone", placeholder: "Phone", className: "w-full mb-2 p-2 border rounded", value: formData.phone, onChange: handleInputChange }), jsxRuntimeExports.jsx("button", { disabled: !isFormValid || loading, onClick: handleBooking, className: "w-full bg-orange-500 text-white p-3 rounded disabled:opacity-50", children: loading ? "Booking..." : "Confirm Booking" })] }));
605
+ };
606
+
607
+ exports.MeetingScheduler = MeetingScheduler;
608
+ //# sourceMappingURL=index.cjs.js.map