@verbb/formie-browser 1.0.0 → 1.0.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.
Files changed (120) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/chunks/address-finder-CQW81kY0.js +37 -0
  3. package/dist/chunks/bpoint-D8OjLmsn.js +26 -0
  4. package/dist/chunks/calculations-BqZsENCq.js +147 -0
  5. package/dist/chunks/captcha-eu-DIa6aUWz.js +34 -0
  6. package/dist/chunks/checkbox-radio-BI-UjgMF.js +136 -0
  7. package/dist/chunks/conditions-BVl6jTYo.js +433 -0
  8. package/dist/chunks/date-picker-69TgvErA.js +4994 -0
  9. package/dist/chunks/eway-1GPxH6DU.js +74 -0
  10. package/dist/chunks/file-upload-BDZZftgL.js +281 -0
  11. package/dist/chunks/friendly-captcha-v1-DA2QPKA3.js +33 -0
  12. package/dist/chunks/friendly-captcha-v2-BorOWiz_.js +38 -0
  13. package/dist/chunks/go-cardless-DwBgERcA.js +24 -0
  14. package/dist/chunks/google-address-BcTBncyS.js +162 -0
  15. package/dist/chunks/hcaptcha-BchdVCqq.js +56 -0
  16. package/dist/chunks/hidden-D8RqSPt7.js +31 -0
  17. package/dist/chunks/index-BEsfee-D.js +1839 -0
  18. package/dist/chunks/index-BP7Unm5Y.js +863 -0
  19. package/dist/chunks/index-C1ZOKiAi.js +4229 -0
  20. package/dist/chunks/loqate-nXuTX7In.js +55 -0
  21. package/dist/chunks/mollie-qdCynQCd.js +24 -0
  22. package/dist/chunks/moneris-BNEA-laO.js +101 -0
  23. package/dist/chunks/opayo-BJtXOkuK.js +122 -0
  24. package/dist/chunks/paddle-D72Pa8kr.js +60 -0
  25. package/dist/chunks/paypal-Cqt2bned.js +100 -0
  26. package/dist/chunks/payway-BjCqsc0H.js +56 -0
  27. package/dist/chunks/phone-country-K9pYAlzM.js +3765 -0
  28. package/dist/chunks/place-kit-Dg6f_UoM.js +42 -0
  29. package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +1299 -0
  30. package/dist/chunks/recaptcha-enterprise--VYAeeqz.js +71 -0
  31. package/dist/chunks/recaptcha-shared-PSIEEEe1.js +15 -0
  32. package/dist/chunks/recaptcha-v2-checkbox-atBNe5ml.js +41 -0
  33. package/dist/chunks/recaptcha-v2-invisible-DnBufNPT.js +59 -0
  34. package/dist/chunks/recaptcha-v3-CF6O8rDj.js +28 -0
  35. package/dist/chunks/repeater-CB7Yojvx.js +124 -0
  36. package/dist/chunks/rich-text-nAV_SQZo.js +304 -0
  37. package/dist/chunks/scripts-BkAAux0i.js +36 -0
  38. package/dist/chunks/sdk-3SicTWby.js +1559 -0
  39. package/dist/chunks/shared-DGqeMvcJ.js +80 -0
  40. package/dist/chunks/signature-BT6CsQ6n.js +550 -0
  41. package/dist/chunks/snaptcha-C7qQo02f.js +8 -0
  42. package/dist/chunks/square-C5AH3trb.js +46 -0
  43. package/dist/chunks/stripe-EJK0RyUv.js +202 -0
  44. package/dist/chunks/styles-C3aqgtek.js +21 -0
  45. package/dist/chunks/summary-DC_ipXCU.js +126 -0
  46. package/dist/chunks/table-BEAI99qo.js +95 -0
  47. package/dist/chunks/text-limit-Blgq5G-G.js +135 -0
  48. package/dist/chunks/turnstile-_uCRwnU-.js +59 -0
  49. package/dist/chunks/utils-BntI3W4S.js +6149 -0
  50. package/dist/index.js +39 -3205
  51. package/package.json +5 -5
  52. package/src/js/modules/fields/file-upload.ts +1 -1
  53. package/src/js/modules/fields/repeater.ts +1 -1
  54. package/src/js/modules/fields/rich-text.ts +2 -2
  55. package/src/js/modules/fields/signature.ts +1 -1
  56. package/src/js/modules/fields/summary.ts +1 -1
  57. package/src/js/modules/fields/table.ts +1 -1
  58. package/src/js/modules/fields/text-limit.ts +1 -1
  59. package/src/js/modules/payments/paypal.ts +1 -1
  60. package/src/js/modules/payments/payway.ts +1 -1
  61. package/src/js/modules/payments/stripe.ts +1 -1
  62. package/dist/chunks/address-finder-DfMCiW89.js +0 -47
  63. package/dist/chunks/api-CbqEMQT5.js +0 -181
  64. package/dist/chunks/api-DE7LfK-R.js +0 -960
  65. package/dist/chunks/api-DOfDzYC_.js +0 -538
  66. package/dist/chunks/async-B3DUf1GZ.js +0 -26
  67. package/dist/chunks/bpoint-Ciy3yY9Q.js +0 -34
  68. package/dist/chunks/calculations-CkYAqO_-.js +0 -197
  69. package/dist/chunks/captcha-eu-DnOWhMwr.js +0 -43
  70. package/dist/chunks/checkbox-radio-0x7Tc0br.js +0 -197
  71. package/dist/chunks/chunk-K6L4z4UQ.js +0 -24
  72. package/dist/chunks/conditions-4fXKhEJS.js +0 -609
  73. package/dist/chunks/date-picker-B6iZkjHS.js +0 -6204
  74. package/dist/chunks/debug-KnZeKYBI.js +0 -39
  75. package/dist/chunks/dist-D09GnXMW.js +0 -2663
  76. package/dist/chunks/event-names-DamGPtXR.js +0 -51
  77. package/dist/chunks/eway-DEAYcwT0.js +0 -86
  78. package/dist/chunks/field-references.keys-BpBZ_quS.js +0 -24
  79. package/dist/chunks/field-references.resolver-Ba6xhiJC.js +0 -183
  80. package/dist/chunks/file-upload-Bh63PQSE.js +0 -430
  81. package/dist/chunks/friendly-captcha-v1-CqO4WVre.js +0 -40
  82. package/dist/chunks/friendly-captcha-v2-CyykcJcM.js +0 -47
  83. package/dist/chunks/friendly-challenge-Dg8XkStd.js +0 -1101
  84. package/dist/chunks/go-cardless-CuND59rR.js +0 -26
  85. package/dist/chunks/google-address--uR8WDSm.js +0 -208
  86. package/dist/chunks/hcaptcha-CmaFUesv.js +0 -72
  87. package/dist/chunks/hidden-CYnZYple.js +0 -36
  88. package/dist/chunks/http-18nn97DZ.js +0 -29
  89. package/dist/chunks/i18n-vUh-KGiH.js +0 -55
  90. package/dist/chunks/loqate-BICNJlVK.js +0 -97
  91. package/dist/chunks/mollie-DwlsgHZ1.js +0 -26
  92. package/dist/chunks/moneris-B_IFZFTx.js +0 -159
  93. package/dist/chunks/opayo-U2x_TOII.js +0 -192
  94. package/dist/chunks/paddle-BqXFrc79.js +0 -75
  95. package/dist/chunks/paypal-Cn_DYGDb.js +0 -121
  96. package/dist/chunks/payway-Rnq796eC.js +0 -75
  97. package/dist/chunks/phone-country-B6Me4lK0.js +0 -3317
  98. package/dist/chunks/place-kit-ldUl-u9w.js +0 -56
  99. package/dist/chunks/placekit-autocomplete.esm-D-lGeaZl.js +0 -1771
  100. package/dist/chunks/recaptcha-enterprise-DPJNyv1X.js +0 -72
  101. package/dist/chunks/recaptcha-shared-DTI4qWVR.js +0 -22
  102. package/dist/chunks/recaptcha-v2-checkbox-zFjpvJ5c.js +0 -49
  103. package/dist/chunks/recaptcha-v2-invisible-CnYtkNvz.js +0 -62
  104. package/dist/chunks/recaptcha-v3-EAlWhnkX.js +0 -33
  105. package/dist/chunks/repeater-CXD1eLSn.js +0 -151
  106. package/dist/chunks/rich-text-DkmZRhGj.js +0 -442
  107. package/dist/chunks/scripts-BGD_iU_6.js +0 -41
  108. package/dist/chunks/sdk-B7u9fTlP.js +0 -2103
  109. package/dist/chunks/shared-DC6_1u8X.js +0 -85
  110. package/dist/chunks/signature-E9KyYXS1.js +0 -765
  111. package/dist/chunks/snaptcha-CCDunGeb.js +0 -8
  112. package/dist/chunks/square-BLqK51rS.js +0 -61
  113. package/dist/chunks/stripe-B8gHpZNC.js +0 -273
  114. package/dist/chunks/styles-BIh6g7V_.js +0 -22
  115. package/dist/chunks/summary-EcNE0cvg.js +0 -191
  116. package/dist/chunks/table-yxEDL6kA.js +0 -124
  117. package/dist/chunks/text-limit-D0H_Ca2c.js +0 -179
  118. package/dist/chunks/theme-classes-vSHpdCUO.js +0 -59
  119. package/dist/chunks/turnstile-DP0bdR7T.js +0 -68
  120. package/dist/chunks/utils-ByrEVYrJ.js +0 -49584
@@ -0,0 +1,80 @@
1
+ import { q as u } from "./index-C1ZOKiAi.js";
2
+ const f = (e) => e.replace(/["\\]/g, "\\$&"), a = /* @__PURE__ */ new WeakMap();
3
+ function l(e) {
4
+ return typeof window.CSS?.escape == "function" ? window.CSS.escape(e) : f(e);
5
+ }
6
+ function d(e) {
7
+ return e.target instanceof HTMLElement && e.target.hasAttribute("data-formie-field-handle") ? [e.target] : e.target instanceof HTMLElement ? Array.from(e.target.querySelectorAll("[data-formie-field-handle]")).filter((t) => t instanceof HTMLElement) : [];
8
+ }
9
+ function g(e) {
10
+ return d(e)[0] || null;
11
+ }
12
+ function s(e) {
13
+ return e && e.formieValidation || null;
14
+ }
15
+ function E(e, t, i) {
16
+ if (!e)
17
+ return;
18
+ const n = a.get(e) || /* @__PURE__ */ new Map(), r = n.get(t) || 0;
19
+ if (r === 0) {
20
+ const o = s(e);
21
+ o && i(o);
22
+ }
23
+ n.set(t, r + 1), a.set(e, n);
24
+ }
25
+ function M(e, t, i) {
26
+ if (!e)
27
+ return;
28
+ const n = a.get(e), r = n?.get(t) || 0;
29
+ if (r <= 1) {
30
+ const o = s(e);
31
+ if (i.forEach((c) => {
32
+ o?.removeValidator(c);
33
+ }), n?.delete(t), !n || n.size === 0) {
34
+ a.delete(e);
35
+ return;
36
+ }
37
+ a.set(e, n);
38
+ return;
39
+ }
40
+ n?.set(t, r - 1);
41
+ }
42
+ function m(e) {
43
+ return e.ownerDocument || document;
44
+ }
45
+ function S(e, t) {
46
+ const i = m(e);
47
+ if (t) {
48
+ const n = [
49
+ e.querySelector(`template[data-formie-template-id="${l(t)}"]`),
50
+ e.querySelector(`script[data-formie-template-id="${l(t)}"]`),
51
+ i.querySelector(`template[data-formie-template-id="${l(t)}"]`),
52
+ i.querySelector(`script[data-formie-template-id="${l(t)}"]`),
53
+ i.getElementById(t)
54
+ ];
55
+ for (const r of n)
56
+ if (r instanceof HTMLTemplateElement || r instanceof HTMLScriptElement)
57
+ return r;
58
+ }
59
+ return null;
60
+ }
61
+ function T(e) {
62
+ return e instanceof HTMLTemplateElement ? e.innerHTML : e instanceof HTMLScriptElement ? e.textContent || "" : e.innerHTML;
63
+ }
64
+ function H(e, t, i, n) {
65
+ const r = u(t, i);
66
+ e.dispatchEvent(new CustomEvent(r, {
67
+ bubbles: !0,
68
+ detail: n
69
+ }));
70
+ }
71
+ export {
72
+ M as a,
73
+ g as b,
74
+ T as c,
75
+ H as d,
76
+ l as e,
77
+ S as f,
78
+ d as g,
79
+ E as r
80
+ };
@@ -0,0 +1,550 @@
1
+ import { g as C, d as M } from "./shared-DGqeMvcJ.js";
2
+ import { e as T } from "./styles-C3aqgtek.js";
3
+ var E = class {
4
+ x;
5
+ y;
6
+ pressure;
7
+ time;
8
+ constructor(r, t, e, i) {
9
+ if (isNaN(r) || isNaN(t))
10
+ throw new Error(`Point is invalid: (${r}, ${t})`);
11
+ this.x = +r, this.y = +t, this.pressure = e || 0, this.time = i || Date.now();
12
+ }
13
+ distanceTo(r) {
14
+ return Math.sqrt(
15
+ Math.pow(this.x - r.x, 2) + Math.pow(this.y - r.y, 2)
16
+ );
17
+ }
18
+ equals(r) {
19
+ return this.x === r.x && this.y === r.y && this.pressure === r.pressure && this.time === r.time;
20
+ }
21
+ velocityFrom(r) {
22
+ return this.time !== r.time ? this.distanceTo(r) / (this.time - r.time) : 0;
23
+ }
24
+ }, L = class S {
25
+ constructor(t, e, i, n, s, a) {
26
+ this.startPoint = t, this.control2 = e, this.control1 = i, this.endPoint = n, this.startWidth = s, this.endWidth = a;
27
+ }
28
+ static fromPoints(t, e) {
29
+ const i = this.calculateControlPoints(t[0], t[1], t[2]).c2, n = this.calculateControlPoints(t[1], t[2], t[3]).c1;
30
+ return new S(t[1], i, n, t[2], e.start, e.end);
31
+ }
32
+ static calculateControlPoints(t, e, i) {
33
+ const n = t.x - e.x, s = t.y - e.y, a = e.x - i.x, d = e.y - i.y, h = { x: (t.x + e.x) / 2, y: (t.y + e.y) / 2 }, l = { x: (e.x + i.x) / 2, y: (e.y + i.y) / 2 }, o = Math.sqrt(n * n + s * s), c = Math.sqrt(a * a + d * d), _ = h.x - l.x, f = h.y - l.y, m = o + c == 0 ? 0 : c / (o + c), u = { x: l.x + _ * m, y: l.y + f * m }, p = e.x - u.x, g = e.y - u.y;
34
+ return {
35
+ c1: new E(h.x + p, h.y + g),
36
+ c2: new E(l.x + p, l.y + g)
37
+ };
38
+ }
39
+ // Returns approximated length. Code taken from https://www.lemoda.net/maths/bezier-length/index.html.
40
+ length() {
41
+ let e = 0, i, n;
42
+ for (let s = 0; s <= 10; s += 1) {
43
+ const a = s / 10, d = this.point(
44
+ a,
45
+ this.startPoint.x,
46
+ this.control1.x,
47
+ this.control2.x,
48
+ this.endPoint.x
49
+ ), h = this.point(
50
+ a,
51
+ this.startPoint.y,
52
+ this.control1.y,
53
+ this.control2.y,
54
+ this.endPoint.y
55
+ );
56
+ if (s > 0) {
57
+ const l = d - i, o = h - n;
58
+ e += Math.sqrt(l * l + o * o);
59
+ }
60
+ i = d, n = h;
61
+ }
62
+ return e;
63
+ }
64
+ // Calculate parametric value of x or y given t and the four point coordinates of a cubic bezier curve.
65
+ point(t, e, i, n, s) {
66
+ return e * (1 - t) * (1 - t) * (1 - t) + 3 * i * (1 - t) * (1 - t) * t + 3 * n * (1 - t) * t * t + s * t * t * t;
67
+ }
68
+ }, U = class {
69
+ /* tslint:disable: variable-name */
70
+ _et;
71
+ /* tslint:enable: variable-name */
72
+ constructor() {
73
+ try {
74
+ this._et = new EventTarget();
75
+ } catch {
76
+ this._et = document;
77
+ }
78
+ }
79
+ addEventListener(r, t, e) {
80
+ this._et.addEventListener(r, t, e);
81
+ }
82
+ dispatchEvent(r) {
83
+ return this._et.dispatchEvent(r);
84
+ }
85
+ removeEventListener(r, t, e) {
86
+ this._et.removeEventListener(r, t, e);
87
+ }
88
+ };
89
+ function W(r, t = 250) {
90
+ let e = 0, i = null, n, s, a;
91
+ const d = () => {
92
+ e = Date.now(), i = null, n = r.apply(s, a), i || (s = null, a = []);
93
+ };
94
+ return function(...l) {
95
+ const o = Date.now(), c = t - (o - e);
96
+ return s = this, a = l, c <= 0 || c > t ? (i && (clearTimeout(i), i = null), e = o, n = r.apply(s, a), i || (s = null, a = [])) : i || (i = window.setTimeout(d, c)), n;
97
+ };
98
+ }
99
+ var D = class x extends U {
100
+ /* tslint:enable: variable-name */
101
+ constructor(t, e = {}) {
102
+ super(), this.canvas = t, this.velocityFilterWeight = e.velocityFilterWeight || 0.7, this.minWidth = e.minWidth || 0.5, this.maxWidth = e.maxWidth || 2.5, this.throttle = e.throttle ?? 16, this.minDistance = e.minDistance ?? 5, this.dotSize = e.dotSize || 0, this.penColor = e.penColor || "black", this.backgroundColor = e.backgroundColor || "rgba(0,0,0,0)", this.compositeOperation = e.compositeOperation || "source-over", this.canvasContextOptions = e.canvasContextOptions ?? {}, this._strokeMoveUpdate = this.throttle ? W(x.prototype._strokeUpdate, this.throttle) : x.prototype._strokeUpdate, this._handleMouseDown = this._handleMouseDown.bind(this), this._handleMouseMove = this._handleMouseMove.bind(this), this._handleMouseUp = this._handleMouseUp.bind(this), this._handleTouchStart = this._handleTouchStart.bind(this), this._handleTouchMove = this._handleTouchMove.bind(this), this._handleTouchEnd = this._handleTouchEnd.bind(this), this._handlePointerDown = this._handlePointerDown.bind(this), this._handlePointerMove = this._handlePointerMove.bind(this), this._handlePointerUp = this._handlePointerUp.bind(this), this._handlePointerCancel = this._handlePointerCancel.bind(this), this._handleTouchCancel = this._handleTouchCancel.bind(this), this._ctx = t.getContext(
103
+ "2d",
104
+ this.canvasContextOptions
105
+ ), this.clear(), this.on();
106
+ }
107
+ // Public stuff
108
+ dotSize;
109
+ minWidth;
110
+ maxWidth;
111
+ penColor;
112
+ minDistance;
113
+ velocityFilterWeight;
114
+ compositeOperation;
115
+ backgroundColor;
116
+ throttle;
117
+ canvasContextOptions;
118
+ // Private stuff
119
+ /* tslint:disable: variable-name */
120
+ _ctx;
121
+ _drawingStroke = !1;
122
+ _isEmpty = !0;
123
+ _dataUrl;
124
+ _dataUrlOptions;
125
+ _lastPoints = [];
126
+ // Stores up to 4 most recent points; used to generate a new curve
127
+ _data = [];
128
+ // Stores all points in groups (one group per line or dot)
129
+ _lastVelocity = 0;
130
+ _lastWidth = 0;
131
+ _strokeMoveUpdate;
132
+ _strokePointerId;
133
+ clear() {
134
+ const { _ctx: t, canvas: e } = this;
135
+ t.fillStyle = this.backgroundColor, t.clearRect(0, 0, e.width, e.height), t.fillRect(0, 0, e.width, e.height), this._data = [], this._reset(this._getPointGroupOptions()), this._isEmpty = !0, this._dataUrl = void 0, this._dataUrlOptions = void 0, this._strokePointerId = void 0;
136
+ }
137
+ redraw() {
138
+ const t = this._data, e = this._dataUrl, i = this._dataUrlOptions;
139
+ this.clear(), e && this.fromDataURL(e, i), this.fromData(t, { clear: !1 });
140
+ }
141
+ fromDataURL(t, e = {}) {
142
+ return new Promise((i, n) => {
143
+ const s = new Image(), a = e.ratio || window.devicePixelRatio || 1, d = e.width || this.canvas.width / a, h = e.height || this.canvas.height / a, l = e.xOffset || 0, o = e.yOffset || 0;
144
+ this._reset(this._getPointGroupOptions()), s.onload = () => {
145
+ this._ctx.drawImage(s, l, o, d, h), i();
146
+ }, s.onerror = (c) => {
147
+ n(c);
148
+ }, s.crossOrigin = "anonymous", s.src = t, this._isEmpty = !1, this._dataUrl = t, this._dataUrlOptions = { ...e };
149
+ });
150
+ }
151
+ toDataURL(t = "image/png", e) {
152
+ return t === "image/svg+xml" ? (typeof e != "object" && (e = void 0), `data:image/svg+xml;base64,${btoa(
153
+ this.toSVG(e)
154
+ )}`) : (typeof e != "number" && (e = void 0), this.canvas.toDataURL(t, e));
155
+ }
156
+ on() {
157
+ this.canvas.style.touchAction = "none", this.canvas.style.msTouchAction = "none", this.canvas.style.userSelect = "none", this.canvas.style.webkitUserSelect = "none";
158
+ const t = /Macintosh/.test(navigator.userAgent) && "ontouchstart" in document;
159
+ window.PointerEvent && !t ? this._handlePointerEvents() : (this._handleMouseEvents(), "ontouchstart" in window && this._handleTouchEvents());
160
+ }
161
+ off() {
162
+ this.canvas.style.touchAction = "auto", this.canvas.style.msTouchAction = "auto", this.canvas.style.userSelect = "auto", this.canvas.style.webkitUserSelect = "auto", this.canvas.removeEventListener("pointerdown", this._handlePointerDown), this.canvas.removeEventListener("mousedown", this._handleMouseDown), this.canvas.removeEventListener("touchstart", this._handleTouchStart), this._removeMoveUpEventListeners();
163
+ }
164
+ _getListenerFunctions() {
165
+ const t = window.document === this.canvas.ownerDocument ? window : this.canvas.ownerDocument.defaultView ?? this.canvas.ownerDocument;
166
+ return {
167
+ addEventListener: t.addEventListener.bind(
168
+ t
169
+ ),
170
+ removeEventListener: t.removeEventListener.bind(
171
+ t
172
+ )
173
+ };
174
+ }
175
+ _removeMoveUpEventListeners() {
176
+ const { removeEventListener: t } = this._getListenerFunctions();
177
+ t("pointermove", this._handlePointerMove), t("pointerup", this._handlePointerUp), t("pointercancel", this._handlePointerCancel), t("mousemove", this._handleMouseMove), t("mouseup", this._handleMouseUp), t("touchmove", this._handleTouchMove), t("touchend", this._handleTouchEnd), t("touchcancel", this._handleTouchCancel);
178
+ }
179
+ isEmpty() {
180
+ return this._isEmpty;
181
+ }
182
+ fromData(t, { clear: e = !0 } = {}) {
183
+ e && this.clear(), this._fromData(
184
+ t,
185
+ this._drawCurve.bind(this),
186
+ this._drawDot.bind(this)
187
+ ), this._data = this._data.concat(t);
188
+ }
189
+ toData() {
190
+ return this._data;
191
+ }
192
+ _isLeftButtonPressed(t, e) {
193
+ return e ? t.buttons === 1 : (t.buttons & 1) === 1;
194
+ }
195
+ _pointerEventToSignatureEvent(t) {
196
+ return {
197
+ event: t,
198
+ type: t.type,
199
+ x: t.clientX,
200
+ y: t.clientY,
201
+ pressure: "pressure" in t ? t.pressure : 0
202
+ };
203
+ }
204
+ _touchEventToSignatureEvent(t) {
205
+ const e = t.changedTouches[0];
206
+ return {
207
+ event: t,
208
+ type: t.type,
209
+ x: e.clientX,
210
+ y: e.clientY,
211
+ pressure: e.force
212
+ };
213
+ }
214
+ // Event handlers
215
+ _handleMouseDown(t) {
216
+ !this._isLeftButtonPressed(t, !0) || this._drawingStroke || this._strokeBegin(this._pointerEventToSignatureEvent(t));
217
+ }
218
+ _handleMouseMove(t) {
219
+ if (!this._isLeftButtonPressed(t, !0) || !this._drawingStroke) {
220
+ this._strokeEnd(this._pointerEventToSignatureEvent(t), !1);
221
+ return;
222
+ }
223
+ this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t));
224
+ }
225
+ _handleMouseUp(t) {
226
+ this._isLeftButtonPressed(t) || this._strokeEnd(this._pointerEventToSignatureEvent(t));
227
+ }
228
+ _handleTouchStart(t) {
229
+ t.targetTouches.length !== 1 || this._drawingStroke || (t.cancelable && t.preventDefault(), this._strokeBegin(this._touchEventToSignatureEvent(t)));
230
+ }
231
+ _handleTouchMove(t) {
232
+ if (t.targetTouches.length === 1) {
233
+ if (t.cancelable && t.preventDefault(), !this._drawingStroke) {
234
+ this._strokeEnd(this._touchEventToSignatureEvent(t), !1);
235
+ return;
236
+ }
237
+ this._strokeMoveUpdate(this._touchEventToSignatureEvent(t));
238
+ }
239
+ }
240
+ _handleTouchEnd(t) {
241
+ t.targetTouches.length === 0 && (t.cancelable && t.preventDefault(), this._strokeEnd(this._touchEventToSignatureEvent(t)));
242
+ }
243
+ _handlePointerCancel(t) {
244
+ this._allowPointerId(t) && (t.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(t), !1));
245
+ }
246
+ _handleTouchCancel(t) {
247
+ t.cancelable && t.preventDefault(), this._strokeEnd(this._touchEventToSignatureEvent(t), !1);
248
+ }
249
+ _getPointerId(t) {
250
+ return t.persistentDeviceId || t.pointerId;
251
+ }
252
+ _allowPointerId(t, e = !1) {
253
+ return typeof this._strokePointerId > "u" ? e : this._getPointerId(t) === this._strokePointerId;
254
+ }
255
+ _handlePointerDown(t) {
256
+ this._drawingStroke || !this._isLeftButtonPressed(t) || !this._allowPointerId(t, !0) || (this._strokePointerId = this._getPointerId(t), t.preventDefault(), this._strokeBegin(this._pointerEventToSignatureEvent(t)));
257
+ }
258
+ _handlePointerMove(t) {
259
+ if (this._allowPointerId(t)) {
260
+ if (!this._isLeftButtonPressed(t, !0) || !this._drawingStroke) {
261
+ this._strokeEnd(this._pointerEventToSignatureEvent(t), !1);
262
+ return;
263
+ }
264
+ t.preventDefault(), this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t));
265
+ }
266
+ }
267
+ _handlePointerUp(t) {
268
+ this._isLeftButtonPressed(t) || !this._allowPointerId(t) || (t.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(t)));
269
+ }
270
+ _getPointGroupOptions(t) {
271
+ return {
272
+ penColor: t && "penColor" in t ? t.penColor : this.penColor,
273
+ dotSize: t && "dotSize" in t ? t.dotSize : this.dotSize,
274
+ minWidth: t && "minWidth" in t ? t.minWidth : this.minWidth,
275
+ maxWidth: t && "maxWidth" in t ? t.maxWidth : this.maxWidth,
276
+ velocityFilterWeight: t && "velocityFilterWeight" in t ? t.velocityFilterWeight : this.velocityFilterWeight,
277
+ compositeOperation: t && "compositeOperation" in t ? t.compositeOperation : this.compositeOperation
278
+ };
279
+ }
280
+ // Private methods
281
+ _strokeBegin(t) {
282
+ if (!this.dispatchEvent(
283
+ new CustomEvent("beginStroke", { detail: t, cancelable: !0 })
284
+ ))
285
+ return;
286
+ const { addEventListener: i } = this._getListenerFunctions();
287
+ switch (t.event.type) {
288
+ case "mousedown":
289
+ i("mousemove", this._handleMouseMove, {
290
+ passive: !1
291
+ }), i("mouseup", this._handleMouseUp, { passive: !1 });
292
+ break;
293
+ case "touchstart":
294
+ i("touchmove", this._handleTouchMove, {
295
+ passive: !1
296
+ }), i("touchend", this._handleTouchEnd, { passive: !1 }), i("touchcancel", this._handleTouchCancel, { passive: !1 });
297
+ break;
298
+ case "pointerdown":
299
+ i("pointermove", this._handlePointerMove, {
300
+ passive: !1
301
+ }), i("pointerup", this._handlePointerUp, {
302
+ passive: !1
303
+ }), i("pointercancel", this._handlePointerCancel, {
304
+ passive: !1
305
+ });
306
+ break;
307
+ }
308
+ this._drawingStroke = !0;
309
+ const n = this._getPointGroupOptions(), s = {
310
+ ...n,
311
+ points: []
312
+ };
313
+ this._data.push(s), this._reset(n), this._strokeUpdate(t);
314
+ }
315
+ _strokeUpdate(t) {
316
+ if (!this._drawingStroke)
317
+ return;
318
+ if (this._data.length === 0) {
319
+ this._strokeBegin(t);
320
+ return;
321
+ }
322
+ this.dispatchEvent(
323
+ new CustomEvent("beforeUpdateStroke", { detail: t })
324
+ );
325
+ const e = this._createPoint(t.x, t.y, t.pressure), i = this._data[this._data.length - 1], n = i.points, s = n.length > 0 && n[n.length - 1], a = s ? e.distanceTo(s) <= this.minDistance : !1, d = this._getPointGroupOptions(i);
326
+ if (!s || !(s && a)) {
327
+ const h = this._addPoint(e, d);
328
+ s ? h && this._drawCurve(h, d) : this._drawDot(e, d), n.push({
329
+ time: e.time,
330
+ x: e.x,
331
+ y: e.y,
332
+ pressure: e.pressure
333
+ });
334
+ }
335
+ this.dispatchEvent(new CustomEvent("afterUpdateStroke", { detail: t }));
336
+ }
337
+ _strokeEnd(t, e = !0) {
338
+ this._removeMoveUpEventListeners(), this._drawingStroke && (e && this._strokeUpdate(t), this._drawingStroke = !1, this._strokePointerId = void 0, this.dispatchEvent(new CustomEvent("endStroke", { detail: t })));
339
+ }
340
+ _handlePointerEvents() {
341
+ this._drawingStroke = !1, this.canvas.addEventListener("pointerdown", this._handlePointerDown, {
342
+ passive: !1
343
+ });
344
+ }
345
+ _handleMouseEvents() {
346
+ this._drawingStroke = !1, this.canvas.addEventListener("mousedown", this._handleMouseDown, {
347
+ passive: !1
348
+ });
349
+ }
350
+ _handleTouchEvents() {
351
+ this.canvas.addEventListener("touchstart", this._handleTouchStart, {
352
+ passive: !1
353
+ });
354
+ }
355
+ // Called when a new line is started
356
+ _reset(t) {
357
+ this._lastPoints = [], this._lastVelocity = 0, this._lastWidth = (t.minWidth + t.maxWidth) / 2, this._ctx.fillStyle = t.penColor, this._ctx.globalCompositeOperation = t.compositeOperation;
358
+ }
359
+ _createPoint(t, e, i) {
360
+ const n = this.canvas.getBoundingClientRect();
361
+ return new E(
362
+ t - n.left,
363
+ e - n.top,
364
+ i,
365
+ (/* @__PURE__ */ new Date()).getTime()
366
+ );
367
+ }
368
+ // Add point to _lastPoints array and generate a new curve if there are enough points (i.e. 3)
369
+ _addPoint(t, e) {
370
+ const { _lastPoints: i } = this;
371
+ if (i.push(t), i.length > 2) {
372
+ i.length === 3 && i.unshift(i[0]);
373
+ const n = this._calculateCurveWidths(
374
+ i[1],
375
+ i[2],
376
+ e
377
+ ), s = L.fromPoints(i, n);
378
+ return i.shift(), s;
379
+ }
380
+ return null;
381
+ }
382
+ _calculateCurveWidths(t, e, i) {
383
+ const n = i.velocityFilterWeight * e.velocityFrom(t) + (1 - i.velocityFilterWeight) * this._lastVelocity, s = this._strokeWidth(n, i), a = {
384
+ end: s,
385
+ start: this._lastWidth
386
+ };
387
+ return this._lastVelocity = n, this._lastWidth = s, a;
388
+ }
389
+ _strokeWidth(t, e) {
390
+ return Math.max(e.maxWidth / (t + 1), e.minWidth);
391
+ }
392
+ _drawCurveSegment(t, e, i) {
393
+ const n = this._ctx;
394
+ n.moveTo(t, e), n.arc(t, e, i, 0, 2 * Math.PI, !1), this._isEmpty = !1;
395
+ }
396
+ _drawCurve(t, e) {
397
+ const i = this._ctx, n = t.endWidth - t.startWidth, s = Math.ceil(t.length()) * 2;
398
+ i.beginPath(), i.fillStyle = e.penColor;
399
+ for (let a = 0; a < s; a += 1) {
400
+ const d = a / s, h = d * d, l = h * d, o = 1 - d, c = o * o, _ = c * o;
401
+ let f = _ * t.startPoint.x;
402
+ f += 3 * c * d * t.control1.x, f += 3 * o * h * t.control2.x, f += l * t.endPoint.x;
403
+ let m = _ * t.startPoint.y;
404
+ m += 3 * c * d * t.control1.y, m += 3 * o * h * t.control2.y, m += l * t.endPoint.y;
405
+ const u = Math.min(
406
+ t.startWidth + l * n,
407
+ e.maxWidth
408
+ );
409
+ this._drawCurveSegment(f, m, u);
410
+ }
411
+ i.closePath(), i.fill();
412
+ }
413
+ _drawDot(t, e) {
414
+ const i = this._ctx, n = e.dotSize > 0 ? e.dotSize : (e.minWidth + e.maxWidth) / 2;
415
+ i.beginPath(), this._drawCurveSegment(t.x, t.y, n), i.closePath(), i.fillStyle = e.penColor, i.fill();
416
+ }
417
+ _fromData(t, e, i) {
418
+ for (const n of t) {
419
+ const { points: s } = n, a = this._getPointGroupOptions(n);
420
+ if (s.length > 1)
421
+ for (let d = 0; d < s.length; d += 1) {
422
+ const h = s[d], l = new E(
423
+ h.x,
424
+ h.y,
425
+ h.pressure,
426
+ h.time
427
+ );
428
+ d === 0 && this._reset(a);
429
+ const o = this._addPoint(l, a);
430
+ o && e(o, a);
431
+ }
432
+ else
433
+ this._reset(a), i(s[0], a);
434
+ }
435
+ }
436
+ toSVG({ includeBackgroundColor: t = !1, includeDataUrl: e = !1 } = {}) {
437
+ const i = this._data, n = Math.max(window.devicePixelRatio || 1, 1), s = 0, a = 0, d = this.canvas.width / n, h = this.canvas.height / n, l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
438
+ if (l.setAttribute("xmlns", "http://www.w3.org/2000/svg"), l.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), l.setAttribute("viewBox", `${s} ${a} ${d} ${h}`), l.setAttribute("width", d.toString()), l.setAttribute("height", h.toString()), t && this.backgroundColor) {
439
+ const o = document.createElement("rect");
440
+ o.setAttribute("width", "100%"), o.setAttribute("height", "100%"), o.setAttribute("fill", this.backgroundColor), l.appendChild(o);
441
+ }
442
+ if (e && this._dataUrl) {
443
+ const o = this._dataUrlOptions?.ratio || window.devicePixelRatio || 1, c = this._dataUrlOptions?.width || this.canvas.width / o, _ = this._dataUrlOptions?.height || this.canvas.height / o, f = this._dataUrlOptions?.xOffset || 0, m = this._dataUrlOptions?.yOffset || 0, u = document.createElement("image");
444
+ u.setAttribute("x", f.toString()), u.setAttribute("y", m.toString()), u.setAttribute("width", c.toString()), u.setAttribute("height", _.toString()), u.setAttribute("preserveAspectRatio", "none"), u.setAttribute("href", this._dataUrl), l.appendChild(u);
445
+ }
446
+ return this._fromData(
447
+ i,
448
+ (o, { penColor: c }) => {
449
+ const _ = document.createElement("path");
450
+ if (!isNaN(o.control1.x) && !isNaN(o.control1.y) && !isNaN(o.control2.x) && !isNaN(o.control2.y)) {
451
+ const f = `M ${o.startPoint.x.toFixed(3)},${o.startPoint.y.toFixed(
452
+ 3
453
+ )} C ${o.control1.x.toFixed(3)},${o.control1.y.toFixed(3)} ${o.control2.x.toFixed(3)},${o.control2.y.toFixed(3)} ${o.endPoint.x.toFixed(3)},${o.endPoint.y.toFixed(3)}`;
454
+ _.setAttribute("d", f), _.setAttribute("stroke-width", (o.endWidth * 2.25).toFixed(3)), _.setAttribute("stroke", c), _.setAttribute("fill", "none"), _.setAttribute("stroke-linecap", "round"), l.appendChild(_);
455
+ }
456
+ },
457
+ (o, { penColor: c, dotSize: _, minWidth: f, maxWidth: m }) => {
458
+ const u = document.createElement("circle"), p = _ > 0 ? _ : (f + m) / 2;
459
+ u.setAttribute("r", p.toString()), u.setAttribute("cx", o.x.toString()), u.setAttribute("cy", o.y.toString()), u.setAttribute("fill", c), l.appendChild(u);
460
+ }
461
+ ), l.outerHTML;
462
+ }
463
+ };
464
+ const O = "@layer formie-theme{[data-formie-field-type=signature] .formie-field-control{position:relative;transition:border-color .15s ease,box-shadow .15s ease,background-color .15s ease}[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{border-color:var(--formie-focus-ring-border-color);box-shadow:var(--formie-shadow-focus)}.formie-field-has-error[data-formie-field-type=signature] .formie-signature-canvas{border-color:var(--formie-color-danger)}.formie-field-has-error[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{box-shadow:var(--formie-shadow-danger-focus)}[data-formie-field-type=signature] .formie-signature-canvas{display:block;width:var(--formie-signature-width);height:var(--formie-signature-height);border:var(--formie-signature-border);background:var(--formie-signature-background);border-radius:var(--formie-signature-border-radius);touch-action:none;transition:border-color .15s ease,box-shadow .15s ease,background-color .15s ease}[data-formie-field-type=signature] .formie-signature-remove-button{position:absolute;top:var(--formie-signature-remove-button-top);right:var(--formie-signature-remove-button-right);transform:var(--formie-signature-remove-button-transform);font-size:0;line-height:0}}", A = "input[data-formie-signature-input]", P = "canvas[data-formie-signature-canvas]", F = "[data-formie-signature-clear]", b = "signature";
465
+ T(b, [O]);
466
+ function I(r) {
467
+ const t = r.getBoundingClientRect();
468
+ return {
469
+ width: Math.round(t.width),
470
+ height: Math.round(t.height)
471
+ };
472
+ }
473
+ function z(r, t) {
474
+ if (!t)
475
+ return;
476
+ const e = new Image();
477
+ e.src = t, e.onload = () => {
478
+ const i = Math.max(window.devicePixelRatio || 1, 1), n = r.getContext("2d");
479
+ n && n.drawImage(e, 0, 0, r.width / i, r.height / i);
480
+ };
481
+ }
482
+ function R(r, t, e, i, n, s) {
483
+ const a = parseFloat(s.penWeight || "2") || 2, d = i.parentElement instanceof HTMLElement ? i.parentElement : t, h = new D(i, {
484
+ backgroundColor: s.backgroundColor || "rgba(255, 255, 255, 0)",
485
+ penColor: s.penColor || "#000000",
486
+ dotSize: a,
487
+ minWidth: a,
488
+ maxWidth: a
489
+ }), l = () => {
490
+ const { width: g, height: v } = I(i);
491
+ if (!(g > 0) || !(v > 0))
492
+ return;
493
+ const w = Math.max(window.devicePixelRatio || 1, 1), y = i.getContext("2d");
494
+ if (!y)
495
+ return;
496
+ const k = e.value || (h.isEmpty() ? "" : h.toDataURL());
497
+ i.width = g * w, i.height = v * w, y.setTransform(1, 0, 0, 1, 0, 0), y.scale(w, w), h.clear(), z(i, k);
498
+ }, o = (g = 0) => {
499
+ window.setTimeout(() => {
500
+ window.requestAnimationFrame(() => {
501
+ l();
502
+ });
503
+ }, g);
504
+ }, c = () => {
505
+ o();
506
+ }, _ = () => {
507
+ o(100);
508
+ }, f = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
509
+ o();
510
+ }), m = (g) => {
511
+ const v = e.value !== g;
512
+ e.value = g, v && (e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 })));
513
+ }, u = () => {
514
+ m(h.isEmpty() ? "" : h.toDataURL());
515
+ }, p = () => {
516
+ h.clear(), m("");
517
+ };
518
+ return h.addEventListener("endStroke", u), window.addEventListener("resize", c), r.addEventListener("formie:page:navigate:after", _), f?.observe(d), o(), n && n.addEventListener("click", p), M(t, b, "init", {
519
+ signature: h
520
+ }), () => {
521
+ h.removeEventListener("endStroke", u), window.removeEventListener("resize", c), r.removeEventListener("formie:page:navigate:after", _), f?.disconnect(), n && n.removeEventListener("click", p), h.clear();
522
+ };
523
+ }
524
+ const $ = {
525
+ id: b,
526
+ kind: "field",
527
+ match: (r) => !!r.target.querySelector(P),
528
+ setup: async (r) => {
529
+ const t = r.options || {}, e = r.root instanceof HTMLElement ? r.root : r.target instanceof HTMLElement ? r.target : null;
530
+ if (!e)
531
+ return;
532
+ const n = C(r).map((s) => {
533
+ const a = s.querySelector(A), d = s.querySelector(P), h = s.querySelector(F);
534
+ return !(a instanceof HTMLInputElement) || !(d instanceof HTMLCanvasElement) ? () => {
535
+ } : R(e, s, a, d, h instanceof HTMLElement ? h : null, t);
536
+ });
537
+ return await r.emit("formie:module:signature:init", {
538
+ count: n.length
539
+ }), {
540
+ destroy: () => {
541
+ n.forEach((s) => {
542
+ s();
543
+ }), r.emit("formie:module:signature:destroy", {});
544
+ }
545
+ };
546
+ }
547
+ };
548
+ export {
549
+ $ as signatureModule
550
+ };
@@ -0,0 +1,8 @@
1
+ import { e as a } from "./index-C1ZOKiAi.js";
2
+ const t = a({
3
+ id: "snaptcha",
4
+ defaultPlaceholderSelector: "[data-snaptcha-captcha-placeholder]"
5
+ });
6
+ export {
7
+ t as snaptchaModule
8
+ };
@@ -0,0 +1,46 @@
1
+ import { u } from "./index-C1ZOKiAi.js";
2
+ import { l as c } from "./scripts-BkAAux0i.js";
3
+ const l = "FORMIE_SQUARE_SCRIPT", f = u({
4
+ id: "square",
5
+ defaultRequiredInputSuffixes: ["squarePaymentId"],
6
+ load: async (n) => {
7
+ const { provider: e } = n.options, r = e.applicationId, t = e.locationId;
8
+ if (!r?.trim() || !t?.trim())
9
+ return console.error("[formie] Missing applicationId or locationId for Square."), null;
10
+ const a = e.environment === "sandbox" ? "https://sandbox.web.squarecdn.com/v1/square.js" : "https://web.squarecdn.com/v1/square.js";
11
+ return await c("Square", {
12
+ id: l,
13
+ src: a
14
+ }), window.Square;
15
+ },
16
+ mount: async (n) => {
17
+ const { api: e, field: r, services: t, options: s } = n, a = s.provider, i = r.querySelector("[data-formie-square-button]");
18
+ if (!i || !e)
19
+ return null;
20
+ try {
21
+ const d = await e.payments(a.applicationId || "", a.locationId || "").card();
22
+ return await d.attach(i), d;
23
+ } catch (o) {
24
+ return t.addError(o instanceof Error ? o.message : "Unable to initialize payment."), null;
25
+ }
26
+ },
27
+ unmount: async () => {
28
+ },
29
+ onBeforeAuthorize: async (n) => {
30
+ const { widget: e, services: r } = n;
31
+ if (!e)
32
+ return r.addError("Square card is not ready."), !1;
33
+ try {
34
+ const t = await e.tokenize();
35
+ return t.status === "OK" && t.token ? (r.updateInputs("squarePaymentId", t.token), !0) : (r.addError(t.errors?.[0]?.message || "Tokenization failed."), !1);
36
+ } catch {
37
+ return r.addError("Payment tokenization failed. Please try again."), !1;
38
+ }
39
+ },
40
+ onAfterSubmit: async ({ services: n }) => {
41
+ n.updateInputs("squarePaymentId", "");
42
+ }
43
+ });
44
+ export {
45
+ f as squareModule
46
+ };