@pisell/private-materials 6.3.89 → 6.3.90

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.
Files changed (94) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +10 -10
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +10 -10
  11. package/es/components/appointmentBooking/components/TimeSlicing/components/SelectDateOS.d.ts +1 -0
  12. package/es/components/booking/info/date/index.d.ts +0 -1
  13. package/es/components/ecocup/components/CupInfoCard/index.d.ts +1 -0
  14. package/es/components/ecocup/components/CustomerCard/index.d.ts +1 -0
  15. package/es/components/eftposPay/windcave/windcave.d.ts +1 -0
  16. package/es/index.d.ts +1 -0
  17. package/es/index.js +1 -0
  18. package/es/plus/saasAttendance/index.d.ts +6 -0
  19. package/es/plus/saasAttendance/index.js +5 -0
  20. package/es/plus/saasAttendance/locales.d.ts +318 -0
  21. package/es/plus/saasAttendance/locales.js +354 -0
  22. package/es/plus/saasAttendance/settings/BasicInfoTab.d.ts +5 -0
  23. package/es/plus/saasAttendance/settings/BasicInfoTab.js +96 -0
  24. package/es/plus/saasAttendance/settings/ClockInMethodTab.d.ts +8 -0
  25. package/es/plus/saasAttendance/settings/ClockInMethodTab.js +81 -0
  26. package/es/plus/saasAttendance/settings/CorrectionPolicyTab.d.ts +8 -0
  27. package/es/plus/saasAttendance/settings/CorrectionPolicyTab.js +293 -0
  28. package/es/plus/saasAttendance/settings/ShiftScheduleTab.d.ts +5 -0
  29. package/es/plus/saasAttendance/settings/ShiftScheduleTab.js +109 -0
  30. package/es/plus/saasAttendance/settings/components/MapField.d.ts +78 -0
  31. package/es/plus/saasAttendance/settings/components/MapField.js +810 -0
  32. package/es/plus/saasAttendance/settings/components/index.d.ts +3 -0
  33. package/es/plus/saasAttendance/settings/components/index.js +2 -0
  34. package/es/plus/saasAttendance/settings/components/membersField/index.d.ts +7 -0
  35. package/es/plus/saasAttendance/settings/components/membersField/index.js +216 -0
  36. package/es/plus/saasAttendance/settings/components/membersField/index.less +70 -0
  37. package/es/plus/saasAttendance/settings/components/shiftModal/index.d.ts +18 -0
  38. package/es/plus/saasAttendance/settings/components/shiftModal/index.js +438 -0
  39. package/es/plus/saasAttendance/settings/index.d.ts +18 -0
  40. package/es/plus/saasAttendance/settings/index.js +255 -0
  41. package/es/plus/saasAttendance/settings/index.less +495 -0
  42. package/es/plus/saasAttendance/settings/serve.d.ts +27 -0
  43. package/es/plus/saasAttendance/settings/serve.js +83 -0
  44. package/es/plus/saasAttendance/settings/types.d.ts +128 -0
  45. package/es/plus/saasAttendance/settings/types.js +1 -0
  46. package/es/plus/selectHolder/locales.d.ts +6 -0
  47. package/es/plus/selectHolder/locales.js +6 -0
  48. package/es/plus/skuOptionsSelection/components/TitleExtra/index.d.ts +1 -0
  49. package/es/plus/skuOptionsSelection/components/VariantCard/index.d.ts +1 -0
  50. package/es/pro/Selector/demo.d.ts +1 -0
  51. package/lib/components/appointmentBooking/components/TimeSlicing/components/SelectDateOS.d.ts +1 -0
  52. package/lib/components/booking/info/date/index.d.ts +0 -1
  53. package/lib/components/ecocup/components/CupInfoCard/index.d.ts +1 -0
  54. package/lib/components/ecocup/components/CustomerCard/index.d.ts +1 -0
  55. package/lib/components/eftposPay/windcave/windcave.d.ts +1 -0
  56. package/lib/index.d.ts +1 -0
  57. package/lib/index.js +3 -0
  58. package/lib/plus/saasAttendance/index.d.ts +6 -0
  59. package/lib/plus/saasAttendance/index.js +39 -0
  60. package/lib/plus/saasAttendance/locales.d.ts +318 -0
  61. package/lib/plus/saasAttendance/locales.js +342 -0
  62. package/lib/plus/saasAttendance/settings/BasicInfoTab.d.ts +5 -0
  63. package/lib/plus/saasAttendance/settings/BasicInfoTab.js +152 -0
  64. package/lib/plus/saasAttendance/settings/ClockInMethodTab.d.ts +8 -0
  65. package/lib/plus/saasAttendance/settings/ClockInMethodTab.js +88 -0
  66. package/lib/plus/saasAttendance/settings/CorrectionPolicyTab.d.ts +8 -0
  67. package/lib/plus/saasAttendance/settings/CorrectionPolicyTab.js +369 -0
  68. package/lib/plus/saasAttendance/settings/ShiftScheduleTab.d.ts +5 -0
  69. package/lib/plus/saasAttendance/settings/ShiftScheduleTab.js +106 -0
  70. package/lib/plus/saasAttendance/settings/components/MapField.d.ts +78 -0
  71. package/lib/plus/saasAttendance/settings/components/MapField.js +631 -0
  72. package/lib/plus/saasAttendance/settings/components/index.d.ts +3 -0
  73. package/lib/plus/saasAttendance/settings/components/index.js +42 -0
  74. package/lib/plus/saasAttendance/settings/components/membersField/index.d.ts +7 -0
  75. package/lib/plus/saasAttendance/settings/components/membersField/index.js +247 -0
  76. package/lib/plus/saasAttendance/settings/components/membersField/index.less +70 -0
  77. package/lib/plus/saasAttendance/settings/components/shiftModal/index.d.ts +18 -0
  78. package/lib/plus/saasAttendance/settings/components/shiftModal/index.js +447 -0
  79. package/lib/plus/saasAttendance/settings/index.d.ts +18 -0
  80. package/lib/plus/saasAttendance/settings/index.js +283 -0
  81. package/lib/plus/saasAttendance/settings/index.less +495 -0
  82. package/lib/plus/saasAttendance/settings/serve.d.ts +27 -0
  83. package/lib/plus/saasAttendance/settings/serve.js +54 -0
  84. package/lib/plus/saasAttendance/settings/types.d.ts +128 -0
  85. package/lib/plus/saasAttendance/settings/types.js +17 -0
  86. package/lib/plus/selectHolder/locales.d.ts +6 -0
  87. package/lib/plus/selectHolder/locales.js +6 -0
  88. package/lib/plus/skuOptionsSelection/components/TitleExtra/index.d.ts +1 -0
  89. package/lib/plus/skuOptionsSelection/components/VariantCard/index.d.ts +1 -0
  90. package/lib/pro/Selector/demo.d.ts +1 -0
  91. package/lowcode/eco-cup-list/meta.ts +1 -1
  92. package/lowcode/eco-customer-list/meta.ts +1 -1
  93. package/lowcode/saas-attendance-settings/meta.ts +56 -0
  94. package/package.json +3 -3
@@ -0,0 +1,810 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
6
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
7
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
8
+ 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; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ 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 || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
20
+ import React, { forwardRef, useImperativeHandle, useState, useMemo, useEffect, useCallback, useRef } from 'react';
21
+ import { Alert, Button, Form, Input, Slider } from 'antd';
22
+ import { BaseTranslation, Icon, PisellModal } from '@pisell/materials';
23
+ import { locales } from '@pisell/utils';
24
+ import useEngineContext from "../../../../hooks/useEngineContext";
25
+ // Default map center (Beijing)
26
+ var DEFAULT_CENTER = {
27
+ lat: -37.8136,
28
+ lng: 144.9631
29
+ };
30
+ var DEFAULT_ZOOM = 14;
31
+ var CIRCLE_STROKE_COLOR = '#5d3f9f';
32
+ var CIRCLE_FILL_COLOR = '#5d3f9f';
33
+ var COORDINATE_NUMBER_PATTERN = /^-?\d+(\.\d+)?$/;
34
+
35
+ // Helper function to get current geolocation
36
+ var getCurrentPosition = function getCurrentPosition() {
37
+ return new Promise(function (resolve) {
38
+ if (!navigator.geolocation) {
39
+ resolve(null);
40
+ return;
41
+ }
42
+ navigator.geolocation.getCurrentPosition(function (position) {
43
+ resolve({
44
+ lat: position.coords.latitude,
45
+ lng: position.coords.longitude
46
+ });
47
+ }, function () {
48
+ // Permission denied or error - resolve with null, no special handling
49
+ resolve(null);
50
+ }, {
51
+ enableHighAccuracy: true,
52
+ timeout: 10000,
53
+ maximumAge: 0
54
+ });
55
+ });
56
+ };
57
+ var toMultiLangName = function toMultiLangName(input) {
58
+ if (!input) return {
59
+ original: ''
60
+ };
61
+ if (typeof input === 'string') return {
62
+ original: input
63
+ };
64
+ if (_typeof(input) === 'object') return input;
65
+ return {
66
+ original: String(input)
67
+ };
68
+ };
69
+ var getLocationNameText = function getLocationNameText(name) {
70
+ var n = toMultiLangName(name);
71
+ return n.original || n['zh-CN'] || n['zh-HK'] || n.en || '';
72
+ };
73
+ var createLocationId = function createLocationId() {
74
+ var anyCrypto = typeof crypto !== 'undefined' ? crypto : undefined;
75
+ if (anyCrypto !== null && anyCrypto !== void 0 && anyCrypto.randomUUID) return anyCrypto.randomUUID();
76
+ return "".concat(Date.now(), "_").concat(Math.random().toString(16).slice(2));
77
+ };
78
+ var normalizeLocations = function normalizeLocations(input) {
79
+ if (!Array.isArray(input)) return [];
80
+ return input.map(function (item) {
81
+ var _item$address, _item$address2, _item$id2;
82
+ if (item !== null && item !== void 0 && item.address && ((_item$address = item.address) === null || _item$address === void 0 ? void 0 : _item$address.lat) != null && ((_item$address2 = item.address) === null || _item$address2 === void 0 ? void 0 : _item$address2.lng) != null) {
83
+ var _item$id;
84
+ var _lat = typeof item.address.lat === 'number' ? item.address.lat : parseFloat(item.address.lat) || 0;
85
+ var _lng = typeof item.address.lng === 'number' ? item.address.lng : parseFloat(item.address.lng) || 0;
86
+ return {
87
+ id: String((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : createLocationId()),
88
+ name: toMultiLangName(item.name),
89
+ radius: item === null || item === void 0 ? void 0 : item.radius,
90
+ address: {
91
+ lat: _lat,
92
+ lng: _lng
93
+ }
94
+ };
95
+ }
96
+ var lat = typeof (item === null || item === void 0 ? void 0 : item.lat) === 'number' ? item.lat : parseFloat(item === null || item === void 0 ? void 0 : item.lat) || 0;
97
+ var lng = typeof (item === null || item === void 0 ? void 0 : item.lng) === 'number' ? item.lng : parseFloat(item === null || item === void 0 ? void 0 : item.lng) || 0;
98
+ return {
99
+ id: String((_item$id2 = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id2 !== void 0 ? _item$id2 : createLocationId()),
100
+ name: toMultiLangName(item === null || item === void 0 ? void 0 : item.name),
101
+ radius: item === null || item === void 0 ? void 0 : item.radius,
102
+ address: {
103
+ lat: lat,
104
+ lng: lng
105
+ }
106
+ };
107
+ });
108
+ };
109
+ var LocationFormMap = /*#__PURE__*/forwardRef(function (props, ref) {
110
+ var _Form$useWatch;
111
+ var value = props.value,
112
+ onChange = props.onChange,
113
+ _props$defaultRadius = props.defaultRadius,
114
+ defaultRadius = _props$defaultRadius === void 0 ? 100 : _props$defaultRadius;
115
+ var _Form$useForm = Form.useForm(),
116
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
117
+ form = _Form$useForm2[0];
118
+ var modalMapRef = useRef(null);
119
+ var _useState = useState(false),
120
+ _useState2 = _slicedToArray(_useState, 2),
121
+ isModalMapReady = _useState2[0],
122
+ setIsModalMapReady = _useState2[1];
123
+ var context = useEngineContext();
124
+
125
+ // Get Google Map component from plugin system
126
+ var GoogleMapComponent = useMemo(function () {
127
+ var _context$appHelper, _context$appHelper$ge;
128
+ var app = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 || (_context$appHelper$ge = _context$appHelper.getApp) === null || _context$appHelper$ge === void 0 ? void 0 : _context$appHelper$ge.call(_context$appHelper);
129
+ if (!app) return null;
130
+ return app.getPlugin('google-map') || null;
131
+ }, [context]);
132
+
133
+ // Watch form values for map visualization
134
+ var lat = Form.useWatch('latitude', form);
135
+ var lng = Form.useWatch('longitude', form);
136
+ var validRangeMeters = (_Form$useWatch = Form.useWatch('validRangeMeters', form)) !== null && _Form$useWatch !== void 0 ? _Form$useWatch : defaultRadius;
137
+
138
+ // Debounce validRangeMeters to prevent map flickering/multiple circles
139
+ var _useState3 = useState(validRangeMeters),
140
+ _useState4 = _slicedToArray(_useState3, 2),
141
+ debouncedValidRangeMeters = _useState4[0],
142
+ setDebouncedValidRangeMeters = _useState4[1];
143
+ useEffect(function () {
144
+ setDebouncedValidRangeMeters(validRangeMeters);
145
+ }, []); // Initialize
146
+
147
+ useEffect(function () {
148
+ var timer = setTimeout(function () {
149
+ setDebouncedValidRangeMeters(validRangeMeters);
150
+ }, 200);
151
+ return function () {
152
+ return clearTimeout(timer);
153
+ };
154
+ }, [validRangeMeters]);
155
+
156
+ // Sync value prop to form
157
+ useEffect(function () {
158
+ if (value) {
159
+ form.setFieldsValue(value);
160
+ if (value.latitude && value.longitude && modalMapRef.current) {
161
+ var center = {
162
+ lat: parseFloat(value.latitude),
163
+ lng: parseFloat(value.longitude)
164
+ };
165
+ modalMapRef.current.setCamera({
166
+ coordinate: center,
167
+ zoom: DEFAULT_ZOOM,
168
+ animate: true
169
+ });
170
+ }
171
+ } else {
172
+ form.resetFields();
173
+ form.setFieldsValue({
174
+ validRangeMeters: defaultRadius
175
+ });
176
+ }
177
+ }, [value, form, defaultRadius]);
178
+ useEffect(function () {
179
+ if (!isModalMapReady || !modalMapRef.current) return;
180
+ var latNum = parseFloat(lat);
181
+ var lngNum = parseFloat(lng);
182
+ if (isNaN(latNum) || isNaN(lngNum)) return;
183
+ modalMapRef.current.setCamera({
184
+ coordinate: {
185
+ lat: latNum,
186
+ lng: lngNum
187
+ },
188
+ zoom: DEFAULT_ZOOM,
189
+ animate: true
190
+ });
191
+ }, [isModalMapReady, lat, lng]);
192
+ useImperativeHandle(ref, function () {
193
+ return {
194
+ validate: function validate() {
195
+ return form.validateFields();
196
+ }
197
+ };
198
+ });
199
+ var handleMapClick = useCallback(function (coordinate) {
200
+ var newValues = {
201
+ latitude: coordinate.lat.toFixed(6),
202
+ longitude: coordinate.lng.toFixed(6)
203
+ };
204
+ form.setFieldsValue(newValues);
205
+ // Trigger onChange with merged values
206
+ var currentValues = form.getFieldsValue();
207
+ onChange === null || onChange === void 0 || onChange(_objectSpread(_objectSpread({}, currentValues), newValues));
208
+ }, [form, onChange]);
209
+ var handleValuesChange = function handleValuesChange(changedValues, allValues) {
210
+ onChange === null || onChange === void 0 || onChange(allValues);
211
+ };
212
+
213
+ // Calculate markers and circles based on current form values
214
+ var mapVisualization = useMemo(function () {
215
+ var latNum = parseFloat(lat);
216
+ var lngNum = parseFloat(lng);
217
+ if (isNaN(latNum) || isNaN(lngNum)) {
218
+ return {
219
+ markers: [],
220
+ circles: [],
221
+ center: DEFAULT_CENTER
222
+ };
223
+ }
224
+ var coordinate = {
225
+ lat: latNum,
226
+ lng: lngNum
227
+ };
228
+ var markers = [{
229
+ id: 'current-location',
230
+ coordinate: coordinate,
231
+ draggable: false
232
+ }];
233
+ var circles = [{
234
+ id: 'current-range',
235
+ center: coordinate,
236
+ radius: debouncedValidRangeMeters,
237
+ strokeColor: CIRCLE_STROKE_COLOR,
238
+ strokeOpacity: 0.8,
239
+ strokeWeight: 2,
240
+ fillColor: CIRCLE_FILL_COLOR,
241
+ fillOpacity: 0.2
242
+ }];
243
+ return {
244
+ markers: markers,
245
+ circles: circles,
246
+ center: coordinate
247
+ };
248
+ }, [lat, lng, debouncedValidRangeMeters]);
249
+ return /*#__PURE__*/React.createElement(Form, {
250
+ form: form,
251
+ layout: "vertical",
252
+ className: "saas-attendance-group-settings__modal-form",
253
+ onValuesChange: handleValuesChange,
254
+ initialValues: {
255
+ validRangeMeters: defaultRadius
256
+ }
257
+ }, /*#__PURE__*/React.createElement(Form.Item, {
258
+ label: locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.location-name.label'),
259
+ name: "name",
260
+ required: true,
261
+ rules: [{
262
+ validator: function () {
263
+ var _validator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_rule, value) {
264
+ var texts;
265
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
266
+ while (1) switch (_context.prev = _context.next) {
267
+ case 0:
268
+ if (value) {
269
+ _context.next = 2;
270
+ break;
271
+ }
272
+ throw new Error(locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.location-name.validation'));
273
+ case 2:
274
+ if (!(typeof value === 'string')) {
275
+ _context.next = 7;
276
+ break;
277
+ }
278
+ if (!value.trim()) {
279
+ _context.next = 5;
280
+ break;
281
+ }
282
+ return _context.abrupt("return", Promise.resolve());
283
+ case 5:
284
+ _context.next = 11;
285
+ break;
286
+ case 7:
287
+ if (!(_typeof(value) === 'object')) {
288
+ _context.next = 11;
289
+ break;
290
+ }
291
+ texts = Object.values(value).filter(function (item) {
292
+ return typeof item === 'string' && item.trim();
293
+ });
294
+ if (!(texts.length > 0)) {
295
+ _context.next = 11;
296
+ break;
297
+ }
298
+ return _context.abrupt("return", Promise.resolve());
299
+ case 11:
300
+ throw new Error(locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.location-name.validation'));
301
+ case 12:
302
+ case "end":
303
+ return _context.stop();
304
+ }
305
+ }, _callee);
306
+ }));
307
+ function validator(_x, _x2) {
308
+ return _validator.apply(this, arguments);
309
+ }
310
+ return validator;
311
+ }()
312
+ }]
313
+ }, /*#__PURE__*/React.createElement(BaseTranslation, {
314
+ placeholder: locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.location-name.placeholder')
315
+ })), /*#__PURE__*/React.createElement("div", {
316
+ className: "saas-attendance-group-settings__modal-grid"
317
+ }, /*#__PURE__*/React.createElement(Form.Item, {
318
+ label: locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.latitude.label'),
319
+ name: "latitude",
320
+ required: true,
321
+ rules: [{
322
+ required: true
323
+ }, {
324
+ validator: function () {
325
+ var _validator2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_rule, value) {
326
+ var text, latValue;
327
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
328
+ while (1) switch (_context2.prev = _context2.next) {
329
+ case 0:
330
+ text = String(value !== null && value !== void 0 ? value : '').trim();
331
+ if (text) {
332
+ _context2.next = 3;
333
+ break;
334
+ }
335
+ return _context2.abrupt("return", Promise.resolve());
336
+ case 3:
337
+ if (COORDINATE_NUMBER_PATTERN.test(text)) {
338
+ _context2.next = 5;
339
+ break;
340
+ }
341
+ throw new Error(locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.latitude.validation'));
342
+ case 5:
343
+ latValue = parseFloat(text);
344
+ if (!(latValue < -90 || latValue > 90)) {
345
+ _context2.next = 8;
346
+ break;
347
+ }
348
+ throw new Error(locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.latitude.validation'));
349
+ case 8:
350
+ return _context2.abrupt("return", Promise.resolve());
351
+ case 9:
352
+ case "end":
353
+ return _context2.stop();
354
+ }
355
+ }, _callee2);
356
+ }));
357
+ function validator(_x3, _x4) {
358
+ return _validator2.apply(this, arguments);
359
+ }
360
+ return validator;
361
+ }()
362
+ }]
363
+ }, /*#__PURE__*/React.createElement(Input, {
364
+ placeholder: locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.latitude.placeholder')
365
+ })), /*#__PURE__*/React.createElement(Form.Item, {
366
+ label: locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.longitude.label'),
367
+ name: "longitude",
368
+ required: true,
369
+ rules: [{
370
+ required: true
371
+ }, {
372
+ validator: function () {
373
+ var _validator3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_rule, value) {
374
+ var text, lngValue;
375
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
376
+ while (1) switch (_context3.prev = _context3.next) {
377
+ case 0:
378
+ text = String(value !== null && value !== void 0 ? value : '').trim();
379
+ if (text) {
380
+ _context3.next = 3;
381
+ break;
382
+ }
383
+ return _context3.abrupt("return", Promise.resolve());
384
+ case 3:
385
+ if (COORDINATE_NUMBER_PATTERN.test(text)) {
386
+ _context3.next = 5;
387
+ break;
388
+ }
389
+ throw new Error(locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.longitude.validation'));
390
+ case 5:
391
+ lngValue = parseFloat(text);
392
+ if (!(lngValue < -180 || lngValue > 180)) {
393
+ _context3.next = 8;
394
+ break;
395
+ }
396
+ throw new Error(locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.longitude.validation'));
397
+ case 8:
398
+ return _context3.abrupt("return", Promise.resolve());
399
+ case 9:
400
+ case "end":
401
+ return _context3.stop();
402
+ }
403
+ }, _callee3);
404
+ }));
405
+ function validator(_x5, _x6) {
406
+ return _validator3.apply(this, arguments);
407
+ }
408
+ return validator;
409
+ }()
410
+ }]
411
+ }, /*#__PURE__*/React.createElement(Input, {
412
+ placeholder: locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.longitude.placeholder')
413
+ }))), /*#__PURE__*/React.createElement(Form.Item, {
414
+ label: locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.valid-range.label'),
415
+ required: true
416
+ }, /*#__PURE__*/React.createElement("div", {
417
+ className: "saas-attendance-group-settings__modal-slider-row"
418
+ }, /*#__PURE__*/React.createElement(Form.Item, {
419
+ name: "validRangeMeters",
420
+ noStyle: true,
421
+ rules: [{
422
+ required: true
423
+ }]
424
+ }, /*#__PURE__*/React.createElement(Slider, {
425
+ min: 0,
426
+ max: 1000
427
+ })), /*#__PURE__*/React.createElement("div", {
428
+ className: "saas-attendance-group-settings__slider-value"
429
+ }, locales.getText('pisell2.attendance.group-settings.clock-in-method.meters')(validRangeMeters)))), /*#__PURE__*/React.createElement(Alert, {
430
+ message: locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.tip.google-maps'),
431
+ type: "info",
432
+ showIcon: true
433
+ }), /*#__PURE__*/React.createElement("div", {
434
+ className: "saas-attendance-group-settings__map-placeholder saas-attendance-map-field__modal-map",
435
+ style: {
436
+ marginTop: '10px'
437
+ }
438
+ }, GoogleMapComponent && /*#__PURE__*/React.createElement(GoogleMapComponent, {
439
+ ref: modalMapRef,
440
+ config: {
441
+ center: mapVisualization.center,
442
+ zoom: DEFAULT_ZOOM
443
+ },
444
+ markers: mapVisualization.markers,
445
+ circles: mapVisualization.circles,
446
+ onReady: function onReady() {
447
+ return setIsModalMapReady(true);
448
+ },
449
+ onMapClick: handleMapClick,
450
+ onError: function onError(err) {
451
+ return console.error('Map Error:', err);
452
+ }
453
+ })));
454
+ });
455
+ var MapField = /*#__PURE__*/forwardRef(function (props, ref) {
456
+ var _props$value = props.value,
457
+ value = _props$value === void 0 ? [] : _props$value,
458
+ onChange = props.onChange,
459
+ _props$defaultRadius2 = props.defaultRadius,
460
+ defaultRadius = _props$defaultRadius2 === void 0 ? 100 : _props$defaultRadius2,
461
+ className = props.className;
462
+ var locations = useMemo(function () {
463
+ return normalizeLocations(value);
464
+ }, [value]);
465
+ var _useState5 = useState(false),
466
+ _useState6 = _slicedToArray(_useState5, 2),
467
+ addLocationOpen = _useState6[0],
468
+ setAddLocationOpen = _useState6[1];
469
+ var _useState7 = useState(null),
470
+ _useState8 = _slicedToArray(_useState7, 2),
471
+ editingLocationValue = _useState8[0],
472
+ setEditingLocationValue = _useState8[1];
473
+ var locationFormMapRef = useRef(null);
474
+ var mapRef = useRef(null);
475
+ var _useState9 = useState(false),
476
+ _useState10 = _slicedToArray(_useState9, 2),
477
+ isMapReady = _useState10[0],
478
+ setIsMapReady = _useState10[1];
479
+ var _useState11 = useState(null),
480
+ _useState12 = _slicedToArray(_useState11, 2),
481
+ activeLocationId = _useState12[0],
482
+ setActiveLocationId = _useState12[1];
483
+ var context = useEngineContext();
484
+ useEffect(function () {
485
+ if (!onChange || !Array.isArray(value) || value.length === 0) return;
486
+ var needsNormalize = value.some(function (item) {
487
+ return !(item !== null && item !== void 0 && item.address) || (item === null || item === void 0 ? void 0 : item.lat) != null || (item === null || item === void 0 ? void 0 : item.lng) != null || typeof (item === null || item === void 0 ? void 0 : item.name) === 'string' || (item === null || item === void 0 ? void 0 : item.address) && _typeof(item.address) === 'object' && Object.keys(item.address).some(function (k) {
488
+ return k !== 'lat' && k !== 'lng';
489
+ });
490
+ });
491
+ if (!needsNormalize) return;
492
+ onChange(normalizeLocations(value));
493
+ }, [onChange, value]);
494
+
495
+ // Get Google Map component from plugin system
496
+ var GoogleMapComponent = useMemo(function () {
497
+ var _context$appHelper2, _context$appHelper2$g;
498
+ var app = context === null || context === void 0 || (_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 || (_context$appHelper2 = _context$appHelper2.utils) === null || _context$appHelper2 === void 0 || (_context$appHelper2$g = _context$appHelper2.getApp) === null || _context$appHelper2$g === void 0 ? void 0 : _context$appHelper2$g.call(_context$appHelper2);
499
+ if (!app) return null;
500
+ return app.getPlugin('google-map') || null;
501
+ }, [context]);
502
+
503
+ // Auto-select the first location when locations change or when active location is deleted
504
+ useEffect(function () {
505
+ if (locations.length === 0) {
506
+ setActiveLocationId(null);
507
+ return;
508
+ }
509
+
510
+ // If active location still exists, keep it
511
+ if (activeLocationId && locations.some(function (loc) {
512
+ return loc.id === activeLocationId;
513
+ })) {
514
+ return;
515
+ }
516
+
517
+ // Otherwise, select the first location
518
+ setActiveLocationId(locations[0].id);
519
+ }, [locations, activeLocationId]);
520
+
521
+ // Calculate map center based on active location or default to first
522
+ var mapCenter = useMemo(function () {
523
+ if (locations.length === 0) return DEFAULT_CENTER;
524
+
525
+ // If there's an active location, use it
526
+ var activeLocation = activeLocationId ? locations.find(function (loc) {
527
+ return loc.id === activeLocationId;
528
+ }) : null;
529
+ if (activeLocation) {
530
+ return {
531
+ lat: activeLocation.address.lat,
532
+ lng: activeLocation.address.lng
533
+ };
534
+ }
535
+
536
+ // Default to first location
537
+ return {
538
+ lat: locations[0].address.lat,
539
+ lng: locations[0].address.lng
540
+ };
541
+ }, [locations, activeLocationId]);
542
+
543
+ // Convert locations to markers
544
+ var markers = useMemo(function () {
545
+ return locations.map(function (loc) {
546
+ return {
547
+ id: loc.id,
548
+ coordinate: {
549
+ lat: loc.address.lat,
550
+ lng: loc.address.lng
551
+ },
552
+ title: getLocationNameText(loc.name),
553
+ draggable: false
554
+ };
555
+ });
556
+ }, [locations]);
557
+
558
+ // Convert locations to circles
559
+ var circles = useMemo(function () {
560
+ return locations.map(function (loc) {
561
+ return {
562
+ id: "circle-".concat(loc.id),
563
+ center: {
564
+ lat: loc.address.lat,
565
+ lng: loc.address.lng
566
+ },
567
+ radius: loc.radius || defaultRadius,
568
+ strokeColor: CIRCLE_STROKE_COLOR,
569
+ strokeOpacity: 0.8,
570
+ strokeWeight: 2,
571
+ fillColor: CIRCLE_FILL_COLOR,
572
+ fillOpacity: 0.2
573
+ };
574
+ });
575
+ }, [locations, defaultRadius]);
576
+
577
+ // Expose onAddLocation via ref
578
+ useImperativeHandle(ref, function () {
579
+ return {
580
+ onAddLocation: function () {
581
+ var _onAddLocation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
582
+ var baseFormValue, currentPosition;
583
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
584
+ while (1) switch (_context4.prev = _context4.next) {
585
+ case 0:
586
+ baseFormValue = {
587
+ name: {
588
+ original: '',
589
+ en: '',
590
+ 'zh-CN': '',
591
+ 'zh-HK': ''
592
+ },
593
+ latitude: '',
594
+ longitude: '',
595
+ validRangeMeters: defaultRadius
596
+ };
597
+ setAddLocationOpen(true);
598
+ setEditingLocationValue(baseFormValue);
599
+
600
+ // Request geolocation permission and get current position
601
+ _context4.next = 5;
602
+ return getCurrentPosition();
603
+ case 5:
604
+ currentPosition = _context4.sent;
605
+ if (currentPosition) {
606
+ // Pre-fill the form with current position
607
+ setEditingLocationValue(_objectSpread(_objectSpread({}, baseFormValue), {}, {
608
+ latitude: currentPosition.lat.toFixed(6),
609
+ longitude: currentPosition.lng.toFixed(6)
610
+ }));
611
+ }
612
+ case 7:
613
+ case "end":
614
+ return _context4.stop();
615
+ }
616
+ }, _callee4);
617
+ }));
618
+ function onAddLocation() {
619
+ return _onAddLocation.apply(this, arguments);
620
+ }
621
+ return onAddLocation;
622
+ }()
623
+ };
624
+ }, [defaultRadius]);
625
+ var handleAddLocation = /*#__PURE__*/function () {
626
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
627
+ var _values, newLocation, nextLocations;
628
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
629
+ while (1) switch (_context5.prev = _context5.next) {
630
+ case 0:
631
+ if (locationFormMapRef.current) {
632
+ _context5.next = 2;
633
+ break;
634
+ }
635
+ return _context5.abrupt("return");
636
+ case 2:
637
+ _context5.prev = 2;
638
+ _context5.next = 5;
639
+ return locationFormMapRef.current.validate();
640
+ case 5:
641
+ _values = _context5.sent;
642
+ newLocation = {
643
+ id: createLocationId(),
644
+ name: toMultiLangName(_values.name),
645
+ radius: _values.validRangeMeters,
646
+ address: {
647
+ lat: parseFloat(_values.latitude) || 0,
648
+ lng: parseFloat(_values.longitude) || 0
649
+ }
650
+ }; // Use unshift - add new location to the beginning
651
+ nextLocations = [newLocation].concat(_toConsumableArray(locations));
652
+ onChange === null || onChange === void 0 || onChange(nextLocations);
653
+ // Set the new location as active
654
+ setActiveLocationId(newLocation.id);
655
+ setAddLocationOpen(false);
656
+ setEditingLocationValue(null);
657
+ _context5.next = 17;
658
+ break;
659
+ case 14:
660
+ _context5.prev = 14;
661
+ _context5.t0 = _context5["catch"](2);
662
+ console.error('Validation failed:', _context5.t0);
663
+ case 17:
664
+ case "end":
665
+ return _context5.stop();
666
+ }
667
+ }, _callee5, null, [[2, 14]]);
668
+ }));
669
+ return function handleAddLocation() {
670
+ return _ref.apply(this, arguments);
671
+ };
672
+ }();
673
+ var handleRemoveLocation = function handleRemoveLocation(locationId) {
674
+ var nextLocations = locations.filter(function (loc) {
675
+ return loc.id !== locationId;
676
+ });
677
+ onChange === null || onChange === void 0 || onChange(nextLocations);
678
+ // If the deleted location was active, the useEffect will auto-select the first remaining one
679
+ };
680
+
681
+ // Handle clicking a location item to position the map
682
+ var handleLocationItemClick = useCallback(function (location) {
683
+ var _mapRef$current;
684
+ setActiveLocationId(location.id);
685
+ // Position the map to the clicked location
686
+ (_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 || _mapRef$current.setCamera({
687
+ coordinate: {
688
+ lat: location.address.lat,
689
+ lng: location.address.lng
690
+ },
691
+ zoom: DEFAULT_ZOOM,
692
+ animate: true
693
+ });
694
+ }, []);
695
+ var handleMapReady = useCallback(function () {
696
+ setIsMapReady(true);
697
+ }, []);
698
+ var handleMarkerClick = useCallback(function (markerId, marker) {
699
+ // Can be extended to show location details or edit
700
+ console.log('Marker clicked:', markerId, marker);
701
+ }, []);
702
+
703
+ // Position map to active location when map is ready or active location changes
704
+ useEffect(function () {
705
+ if (!isMapReady || !mapRef.current || locations.length === 0) return;
706
+
707
+ // Always position to the active location (or first one)
708
+ var targetLocation = activeLocationId ? locations.find(function (loc) {
709
+ return loc.id === activeLocationId;
710
+ }) : locations[0];
711
+ if (targetLocation) {
712
+ mapRef.current.setCamera({
713
+ coordinate: {
714
+ lat: targetLocation.address.lat,
715
+ lng: targetLocation.address.lng
716
+ },
717
+ zoom: DEFAULT_ZOOM,
718
+ animate: true
719
+ });
720
+ }
721
+ }, [isMapReady, activeLocationId, locations]);
722
+ var renderEmptyState = function renderEmptyState() {
723
+ return /*#__PURE__*/React.createElement("div", {
724
+ className: "saas-attendance-group-settings__locations-empty"
725
+ }, /*#__PURE__*/React.createElement("div", {
726
+ className: "saas-attendance-group-settings__locations-empty-icon"
727
+ }, /*#__PURE__*/React.createElement(Icon, {
728
+ type: "pisell2-marker-pin-01",
729
+ size: 48
730
+ })), /*#__PURE__*/React.createElement("div", {
731
+ className: "saas-attendance-group-settings__locations-empty-title"
732
+ }, locales.getText('pisell2.attendance.group-settings.clock-in-method.approved-locations.empty.title')), /*#__PURE__*/React.createElement("div", {
733
+ className: "saas-attendance-group-settings__locations-empty-desc"
734
+ }, locales.getText('pisell2.attendance.group-settings.clock-in-method.approved-locations.empty.desc')));
735
+ };
736
+ var renderLocationsList = function renderLocationsList() {
737
+ return /*#__PURE__*/React.createElement("div", {
738
+ className: "saas-attendance-group-settings__locations-list"
739
+ }, /*#__PURE__*/React.createElement("div", {
740
+ className: "saas-attendance-map-field__map-container"
741
+ }, /*#__PURE__*/React.createElement(GoogleMapComponent, {
742
+ ref: mapRef,
743
+ config: {
744
+ center: mapCenter,
745
+ zoom: DEFAULT_ZOOM
746
+ },
747
+ markers: markers,
748
+ circles: circles,
749
+ onReady: handleMapReady
750
+ // onMapClick={handleMapClick} // Removed in refactor
751
+ ,
752
+ onMarkerClick: handleMarkerClick,
753
+ onError: function onError(err) {
754
+ return console.error('Map Error:', err);
755
+ }
756
+ })), /*#__PURE__*/React.createElement("div", {
757
+ className: "saas-attendance-map-field__locations"
758
+ }, locations.map(function (location) {
759
+ return /*#__PURE__*/React.createElement("div", {
760
+ key: location.id,
761
+ className: "saas-attendance-group-settings__location-item".concat(activeLocationId === location.id ? ' saas-attendance-group-settings__location-item--active' : ''),
762
+ onClick: function onClick() {
763
+ return handleLocationItemClick(location);
764
+ },
765
+ style: {
766
+ cursor: 'pointer'
767
+ }
768
+ }, /*#__PURE__*/React.createElement("div", {
769
+ className: "saas-attendance-map-field__location-header"
770
+ }, /*#__PURE__*/React.createElement("div", {
771
+ className: "saas-attendance-group-settings__location-name"
772
+ }, getLocationNameText(location.name)), /*#__PURE__*/React.createElement(Button, {
773
+ type: "text",
774
+ size: "small",
775
+ icon: /*#__PURE__*/React.createElement(Icon, {
776
+ type: "pisell2-trash-01",
777
+ size: 16
778
+ }),
779
+ className: "saas-attendance-map-field__delete-btn",
780
+ onClick: function onClick(e) {
781
+ e.stopPropagation(); // Prevent triggering location item click
782
+ handleRemoveLocation(location.id);
783
+ }
784
+ })), /*#__PURE__*/React.createElement("div", {
785
+ className: "saas-attendance-group-settings__location-meta"
786
+ }, locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.valid-range.label'), ": ", /*#__PURE__*/React.createElement("span", null, location.radius || defaultRadius)));
787
+ })));
788
+ };
789
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
790
+ className: "saas-attendance-group-settings__locations-box ".concat(className || '')
791
+ }, locations.length === 0 ? renderEmptyState() : renderLocationsList()), /*#__PURE__*/React.createElement(PisellModal, {
792
+ open: addLocationOpen,
793
+ title: locales.getText('pisell2.attendance.group-settings.clock-in-method.add-location-modal.title'),
794
+ destroyOnHidden: true,
795
+ onCancel: function onCancel() {
796
+ setAddLocationOpen(false);
797
+ setEditingLocationValue(null);
798
+ },
799
+ okText: locales.getText('pisell2.attendance.group-settings.actions.add-location-confirm'),
800
+ cancelText: locales.getText('pisell2.attendance.group-settings.actions.cancel'),
801
+ onOk: handleAddLocation
802
+ }, /*#__PURE__*/React.createElement(LocationFormMap, {
803
+ ref: locationFormMapRef,
804
+ value: editingLocationValue,
805
+ onChange: setEditingLocationValue,
806
+ defaultRadius: defaultRadius
807
+ })));
808
+ });
809
+ MapField.displayName = 'MapField';
810
+ export default MapField;