hapi-recaptcha-html 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -40
- package/demo/contactus-success.html +14 -0
- package/demo/enquiry-forms.js +8 -12
- package/demo/index.html +14 -102
- package/dist/hapi.min.js +3 -3
- package/index.js +0 -2
- package/package.json +3 -2
- package/src/hapi.js +45 -13
package/README.md
CHANGED
|
@@ -2,62 +2,62 @@
|
|
|
2
2
|
Wrapper of Alpine JS plugin for HAPI Form, works on Laravel API endpoint.
|
|
3
3
|
## CDN
|
|
4
4
|
```html
|
|
5
|
-
<script src="https://unpkg.com/hapi-recaptcha-html@latest/dist/hapi.min.js"></script>
|
|
6
|
-
```
|
|
5
|
+
<script src="https://unpkg.com/hapi-recaptcha-html@latest/dist/hapi.min.js" defer></script>
|
|
7
6
|
|
|
7
|
+
<script src="enquiry-forms.js" defer></script>
|
|
8
|
+
```
|
|
8
9
|
## Usage
|
|
9
10
|
```html
|
|
11
|
+
enquiry-forms.js file:
|
|
10
12
|
|
|
11
13
|
<script>
|
|
12
|
-
Hapi.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
Hapi.forms([
|
|
15
|
+
// form 01
|
|
16
|
+
{
|
|
17
|
+
name: 'form01',
|
|
18
|
+
hapiformID: '<hapiform-id-number-1>',
|
|
19
|
+
redirectTo: '/contactus-success.html',
|
|
20
|
+
captchaId: 'captcha-01',
|
|
21
|
+
integrationScriptUrl: "", // optional, POST current DataForm to external URL (API).
|
|
22
|
+
},
|
|
23
|
+
// form 02
|
|
24
|
+
{
|
|
25
|
+
name: 'form02',
|
|
26
|
+
hapiformID: '<hapiform-id-number-2>',
|
|
27
|
+
redirectTo: '/contactus-success.html',
|
|
28
|
+
captchaId: 'captcha-02',
|
|
29
|
+
integrationScriptUrl: "", // optional, POST current DataForm to external URL (API).
|
|
30
|
+
}
|
|
31
|
+
...
|
|
32
|
+
]
|
|
33
|
+
);
|
|
34
|
+
|
|
27
35
|
</script>
|
|
28
36
|
```
|
|
37
|
+
please note that you must use `$store.<form-name>.fileds.<field-name>` to bind inputs.
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
// in form01
|
|
41
|
+
<input id="form01-name" x-model="$store.form01.fields.name">
|
|
42
|
+
...
|
|
43
|
+
|
|
44
|
+
// in form02
|
|
45
|
+
<input id="form02-name" x-model="$store.form02.fields.name">
|
|
46
|
+
...
|
|
47
|
+
|
|
29
48
|
|
|
49
|
+
```
|
|
30
50
|
- name – The name of the instance, to be matched with `x-data="name"`.
|
|
31
|
-
-
|
|
51
|
+
- hapiformID – hapiform id
|
|
32
52
|
- redirectTo – Location to be redirected after success. Eg: "/thank-you" or "https://example.com". (Optional)
|
|
33
|
-
-
|
|
34
|
-
- filepond – Filepond object. (Filepond plugin required)
|
|
35
|
-
- el – Select `input` element if you're using normal upload.
|
|
53
|
+
- integrationScriptUrl - optional, POST current DataForm to external URL (API).
|
|
36
54
|
- captchaId - Id of div element to render the google recaptcha, `null` means recaptcha is disabled.
|
|
37
55
|
- recaptchaTheme - `light` or `dark`.
|
|
38
56
|
- onSuccess() – On success event.
|
|
39
57
|
- onFailed() – On failed event.
|
|
40
58
|
- errors.recaptchaError - to display captcha verification errors.
|
|
41
59
|
|
|
42
|
-
## Array data
|
|
43
|
-
```js
|
|
44
|
-
Hapi.form({
|
|
45
|
-
fields: {
|
|
46
|
-
colors; [] // Example an empty array of colors
|
|
47
|
-
},
|
|
48
|
-
name: "",
|
|
49
|
-
endpoint: "",
|
|
50
|
-
});
|
|
51
|
-
```
|
|
52
60
|
|
|
53
|
-
## Alpine.js data
|
|
54
|
-
Sometimes you might need to set data for Alpine.js, I got your back.
|
|
55
|
-
```js
|
|
56
|
-
Hapi.form({
|
|
57
|
-
...
|
|
58
|
-
open: false,
|
|
59
|
-
});
|
|
60
|
-
```
|
|
61
61
|
## Events
|
|
62
62
|
|
|
63
63
|
### Success Event
|
|
@@ -65,4 +65,10 @@ When submission is success, Hapi will emit `hapi:success` event.
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
### Error Event
|
|
68
|
-
When submission has error, Hapi will emit `hapi:error` event.
|
|
68
|
+
When submission has error, Hapi will emit `hapi:error` event.
|
|
69
|
+
|
|
70
|
+
### Example
|
|
71
|
+
|
|
72
|
+
[index.html](https://unpkg.com/hapi-recaptcha-html@latest/demo/index.html)
|
|
73
|
+
|
|
74
|
+
[enquiry-forms.js](https://unpkg.com/hapi-recaptcha-html@latest/demo/enquiry-forms.js)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Demo Thank You Page</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
|
|
9
|
+
<div style="text-align: center; margin-top: 100px;">
|
|
10
|
+
<h1>Thank you!</h1>
|
|
11
|
+
<a href="index.html">Go Back Home</a>
|
|
12
|
+
</div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
package/demo/enquiry-forms.js
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
Hapi.forms([
|
|
2
2
|
// form 01
|
|
3
3
|
{
|
|
4
|
-
name: '
|
|
5
|
-
|
|
6
|
-
redirectTo: '
|
|
4
|
+
name: 'form01',
|
|
5
|
+
hapiformID: '5867eae1-c53d-4734-a50c-abd350eb79d9',
|
|
6
|
+
redirectTo: 'contactus-success.html',
|
|
7
7
|
captchaId: 'captcha-01',
|
|
8
|
-
|
|
9
|
-
console.error(err);
|
|
10
|
-
}
|
|
8
|
+
integrationScriptUrl: "https://gaapi.activamedia.com.sg/123form/webhook-json", // optional, POST current DataForm/Json to external URL (API).
|
|
11
9
|
},
|
|
12
10
|
// form 02
|
|
13
11
|
{
|
|
14
|
-
name: '
|
|
15
|
-
|
|
16
|
-
redirectTo: '
|
|
12
|
+
name: 'form02',
|
|
13
|
+
hapiformID: '5867eae1-c53d-4734-a50c-abd350eb79d9',
|
|
14
|
+
redirectTo: 'contactus-success.html',
|
|
17
15
|
captchaId: 'captcha-02',
|
|
18
|
-
|
|
19
|
-
console.error(err);
|
|
20
|
-
}
|
|
16
|
+
integrationScriptUrl: "https://gaapi.activamedia.com.sg/123form/webhook-formdata", // optional, POST current DataForm/Json to external URL (API).
|
|
21
17
|
}
|
|
22
18
|
]
|
|
23
19
|
);
|
package/demo/index.html
CHANGED
|
@@ -31,59 +31,30 @@
|
|
|
31
31
|
|
|
32
32
|
<div class="d-lg-flex">
|
|
33
33
|
|
|
34
|
-
<form x-on:submit.prevent="submit" x-data="
|
|
34
|
+
<form x-on:submit.prevent="submit" x-data="form01">
|
|
35
|
+
|
|
35
36
|
<template x-if="errors">
|
|
36
37
|
<div x-html="JSON.stringify(errors)" class="text-danger"></div>
|
|
37
38
|
</template>
|
|
39
|
+
|
|
40
|
+
<div x-text='JSON.stringify($store.form01.fields,null,2)' class="text-success"></div>
|
|
38
41
|
<div>
|
|
39
42
|
<div class="mb-3">
|
|
40
43
|
<div class="form-field">
|
|
41
44
|
<label for="form01-name" class="form-label">Name</label>
|
|
42
|
-
<input type="text" id="form01-name" x-model="fields.name" placeholder="Name" class="form-control">
|
|
45
|
+
<input type="text" id="form01-name" x-model="$store.form01.fields.name" placeholder="Name" class="form-control">
|
|
46
|
+
|
|
43
47
|
</div>
|
|
44
48
|
<template x-if="errors && errors.name">
|
|
45
49
|
<div x-text="errors.name" class="text-danger"></div>
|
|
46
50
|
</template>
|
|
47
|
-
|
|
48
|
-
<div class="mb-3">
|
|
49
|
-
<div class="form-field">
|
|
50
|
-
<label for="form01-contact_number" class="form-label">Contact Number</label>
|
|
51
|
-
<input type="tel" id="form01-contact_number" x-model="fields.contact_number"
|
|
52
|
-
placeholder="Contact Number" class="form-control">
|
|
51
|
+
<div x-text="$store.form01.fields.name"></div>
|
|
53
52
|
|
|
54
|
-
</div>
|
|
55
|
-
<template x-if="errors && errors.contact_number">
|
|
56
|
-
<div x-text="errors.contact_number" class="text-danger"></div>
|
|
57
|
-
</template>
|
|
58
|
-
</div>
|
|
59
|
-
<div class="mb-3">
|
|
60
|
-
<div class="form-field">
|
|
61
|
-
<label for="form01-email" class="form-label">Email</label>
|
|
62
|
-
<input type="email" id="form01-email" x-model="fields.email" placeholder="Email"
|
|
63
|
-
class="form-control">
|
|
64
|
-
</div>
|
|
65
|
-
<template x-if="errors && errors.email">
|
|
66
|
-
<div x-text="errors.email" class="text-danger"></div>
|
|
67
|
-
</template>
|
|
68
|
-
</div>
|
|
69
|
-
<div class="mb-3">
|
|
70
|
-
<div class="form-field">
|
|
71
|
-
<select class="form-select" id="form01-specialist" x-model="fields.specialist">
|
|
72
|
-
<option value="" selected>Preferred Specialist</option>
|
|
73
|
-
<option value="Dr Dennis Koh">Dr Dennis Koh</option>
|
|
74
|
-
<option value="Dr Sharon Koh">Dr Sharon Koh</option>
|
|
75
|
-
<option value="Dr Pauleon Tan">Dr Pauleon Tan</option>
|
|
76
|
-
<option value="No Preference">No Preference</option>
|
|
77
|
-
</select>
|
|
78
|
-
</div>
|
|
79
|
-
<template x-if="errors && errors.specialist">
|
|
80
|
-
<div x-text="errors.specialist" class="text-danger"></div>
|
|
81
|
-
</template>
|
|
82
53
|
</div>
|
|
83
54
|
<div class="mb-3">
|
|
84
55
|
<div class="form-field">
|
|
85
56
|
<label for="form01-message" class="form-label">Message</label>
|
|
86
|
-
<textarea id="form01-message" x-model="fields.message" rows="4" placeholder="Message"
|
|
57
|
+
<textarea id="form01-message" x-model="$store.form01.fields.message" rows="4" placeholder="Message"
|
|
87
58
|
class="form-control form-textarea"></textarea>
|
|
88
59
|
</div>
|
|
89
60
|
<template x-if="errors && errors.message">
|
|
@@ -104,61 +75,29 @@
|
|
|
104
75
|
</div>
|
|
105
76
|
</form>
|
|
106
77
|
|
|
107
|
-
|
|
78
|
+
|
|
79
|
+
<form x-on:submit.prevent="submit" x-data="form02">
|
|
108
80
|
|
|
109
81
|
<template x-if="errors">
|
|
110
82
|
<div x-text="JSON.stringify(errors)" class="text-danger"></div>
|
|
111
83
|
</template>
|
|
112
84
|
|
|
85
|
+
<div x-text='JSON.stringify($store.form02.fields,null,2)' class="text-success"></div>
|
|
113
86
|
<div>
|
|
114
87
|
<div class="mb-3">
|
|
115
88
|
<div class="form-field">
|
|
116
89
|
<label for="form02-name" class="form-label">Name</label>
|
|
117
|
-
<input type="text" id="form02-name" x-model="fields.name" placeholder="Name" class="form-control">
|
|
90
|
+
<input type="text" id="form02-name" x-model="$store.form02.fields.name" placeholder="Name" class="form-control">
|
|
118
91
|
</div>
|
|
119
92
|
<template x-if="errors && errors.name">
|
|
120
93
|
<div x-text="errors.name" class="text-danger"></div>
|
|
121
94
|
</template>
|
|
122
|
-
|
|
123
|
-
<div class="mb-3">
|
|
124
|
-
<div class="form-field">
|
|
125
|
-
<label for="form02-contact_number" class="form-label">Contact Number</label>
|
|
126
|
-
<input type="tel" id="form02-contact_number" x-model="fields.contact_number"
|
|
127
|
-
placeholder="Contact Number" class="form-control">
|
|
128
|
-
|
|
129
|
-
</div>
|
|
130
|
-
<template x-if="errors && errors.contact_number">
|
|
131
|
-
<div x-text="errors.contact_number" class="text-danger"></div>
|
|
132
|
-
</template>
|
|
133
|
-
</div>
|
|
134
|
-
<div class="mb-3">
|
|
135
|
-
<div class="form-field">
|
|
136
|
-
<label for="form02-email" class="form-label">Email</label>
|
|
137
|
-
<input type="email" id="form02-email" x-model="fields.email" placeholder="Email"
|
|
138
|
-
class="form-control">
|
|
139
|
-
</div>
|
|
140
|
-
<template x-if="errors && errors.email">
|
|
141
|
-
<div x-text="errors.email" class="text-danger"></div>
|
|
142
|
-
</template>
|
|
143
|
-
</div>
|
|
144
|
-
<div class="mb-3">
|
|
145
|
-
<div class="form-field">
|
|
146
|
-
<select class="form-select" id="form02-specialist" x-model="fields.specialist">
|
|
147
|
-
<option value="" selected>Preferred Specialist</option>
|
|
148
|
-
<option value="Dr Dennis Koh">Dr Dennis Koh</option>
|
|
149
|
-
<option value="Dr Sharon Koh">Dr Sharon Koh</option>
|
|
150
|
-
<option value="Dr Pauleon Tan">Dr Pauleon Tan</option>
|
|
151
|
-
<option value="No Preference">No Preference</option>
|
|
152
|
-
</select>
|
|
153
|
-
</div>
|
|
154
|
-
<template x-if="errors && errors.specialist">
|
|
155
|
-
<div x-text="errors.specialist" class="text-danger"></div>
|
|
156
|
-
</template>
|
|
95
|
+
<div x-text="$store.form02.fields.name"></div>
|
|
157
96
|
</div>
|
|
158
97
|
<div class="mb-3">
|
|
159
98
|
<div class="form-field">
|
|
160
99
|
<label for="form02-message" class="form-label">Message</label>
|
|
161
|
-
<textarea id="form02-message" x-model="fields.message" rows="4" placeholder="Message"
|
|
100
|
+
<textarea id="form02-message" x-model="$store.form02.fields.message" rows="4" placeholder="Message"
|
|
162
101
|
class="form-control form-textarea"></textarea>
|
|
163
102
|
</div>
|
|
164
103
|
<template x-if="errors && errors.message">
|
|
@@ -180,33 +119,6 @@
|
|
|
180
119
|
</form>
|
|
181
120
|
|
|
182
121
|
</div>
|
|
183
|
-
<!-- <script>-->
|
|
184
|
-
<!-- const sharedData = {-->
|
|
185
|
-
<!-- fields: {},-->
|
|
186
|
-
<!-- counter: 0,-->
|
|
187
|
-
<!-- increment() {-->
|
|
188
|
-
<!-- this.counter++;-->
|
|
189
|
-
<!-- },-->
|
|
190
|
-
<!-- decrement() {-->
|
|
191
|
-
<!-- this.counter--;-->
|
|
192
|
-
<!-- }-->
|
|
193
|
-
<!-- };-->
|
|
194
|
-
<!-- </script>-->
|
|
195
|
-
|
|
196
|
-
<!-- <div x-data="(() => ({ ...sharedData }))()">-->
|
|
197
|
-
<!-- <input type="text" x-model="fields.name">-->
|
|
198
|
-
<!-- <p>Value in first instance: <span x-text="fields.name"></span></p>-->
|
|
199
|
-
<!-- <br>-->
|
|
200
|
-
<!-- <input type="text" x-model="fields.email">-->
|
|
201
|
-
<!-- <p>Value in first instance: <span x-text="fields.email"></span></p>-->
|
|
202
|
-
<!-- </div>-->
|
|
203
|
-
|
|
204
|
-
<!-- <div x-data="{ data: { value: 'Second instance' } }">-->
|
|
205
|
-
<!-- <input type="text" x-model="data.value">-->
|
|
206
|
-
<!-- <p>Value in second instance: <span x-text="data.value"></span></p>-->
|
|
207
|
-
<!-- </div>-->
|
|
208
|
-
|
|
209
|
-
|
|
210
122
|
<!-- <script src="https://unpkg.com/hapi-recaptcha-html@latest/dist/hapi.min.js" defer></script>-->
|
|
211
123
|
|
|
212
124
|
<script src="../dist/hapi.min.js" defer></script>
|
package/dist/hapi.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(()=>{function B(e,t){return function(){return e.apply(t,arguments)}}var{toString:ft}=Object.prototype,{getPrototypeOf:ue}=Object,K=(e=>t=>{let r=ft.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),R=e=>(e=e.toLowerCase(),t=>K(t)===e),G=e=>t=>typeof t===e,{isArray:P}=Array,j=G("undefined");function dt(e){return e!==null&&!j(e)&&e.constructor!==null&&!j(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Fe=R("ArrayBuffer");function pt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Fe(e.buffer),t}var mt=G("string"),x=G("function"),Pe=G("number"),X=e=>e!==null&&typeof e=="object",ht=e=>e===!0||e===!1,W=e=>{if(K(e)!=="object")return!1;let t=ue(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},yt=R("Date"),Et=R("File"),wt=R("Blob"),bt=R("FileList"),St=e=>X(e)&&x(e.pipe),xt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||x(e.append)&&((t=K(e))==="formdata"||t==="object"&&x(e.toString)&&e.toString()==="[object FormData]"))},At=R("URLSearchParams"),Rt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function k(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),P(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{let i=r?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length,c;for(n=0;n<s;n++)c=i[n],t.call(null,e[c],c,e)}}function Ue(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}var _e=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),De=e=>!j(e)&&e!==_e;function le(){let{caseless:e}=De(this)&&this||{},t={},r=(n,o)=>{let i=e&&Ue(t,o)||o;W(t[i])&&W(n)?t[i]=le(t[i],n):W(n)?t[i]=le({},n):P(n)?t[i]=n.slice():t[i]=n};for(let n=0,o=arguments.length;n<o;n++)arguments[n]&&k(arguments[n],r);return t}var Ot=(e,t,r,{allOwnKeys:n}={})=>(k(t,(o,i)=>{r&&x(o)?e[i]=B(o,r):e[i]=o},{allOwnKeys:n}),e),gt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Tt=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Ct=(e,t,r,n)=>{let o,i,s,c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!n||n(s,e,t))&&!c[s]&&(t[s]=e[s],c[s]=!0);e=r!==!1&&ue(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Nt=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},Ft=e=>{if(!e)return null;if(P(e))return e;let t=e.length;if(!Pe(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Pt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ue(Uint8Array)),Ut=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),o;for(;(o=n.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},_t=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Dt=R("HTMLFormElement"),Lt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Ce=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Bt=R("RegExp"),Le=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};k(r,(o,i)=>{t(o,i,e)!==!1&&(n[i]=o)}),Object.defineProperties(e,n)},jt=e=>{Le(e,(t,r)=>{if(x(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(x(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},kt=(e,t)=>{let r={},n=o=>{o.forEach(i=>{r[i]=!0})};return P(e)?n(e):n(String(e).split(t)),r},It=()=>{},Ht=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ce="abcdefghijklmnopqrstuvwxyz",Ne="0123456789",Be={DIGIT:Ne,ALPHA:ce,ALPHA_DIGIT:ce+ce.toUpperCase()+Ne},qt=(e=16,t=Be.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function Mt(e){return!!(e&&x(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var Jt=e=>{let t=new Array(10),r=(n,o)=>{if(X(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[o]=n;let i=P(n)?[]:{};return k(n,(s,c)=>{let f=r(s,o+1);!j(f)&&(i[c]=f)}),t[o]=void 0,i}}return n};return r(e,0)},zt=R("AsyncFunction"),vt=e=>e&&(X(e)||x(e))&&x(e.then)&&x(e.catch),a={isArray:P,isArrayBuffer:Fe,isBuffer:dt,isFormData:xt,isArrayBufferView:pt,isString:mt,isNumber:Pe,isBoolean:ht,isObject:X,isPlainObject:W,isUndefined:j,isDate:yt,isFile:Et,isBlob:wt,isRegExp:Bt,isFunction:x,isStream:St,isURLSearchParams:At,isTypedArray:Pt,isFileList:bt,forEach:k,merge:le,extend:Ot,trim:Rt,stripBOM:gt,inherits:Tt,toFlatObject:Ct,kindOf:K,kindOfTest:R,endsWith:Nt,toArray:Ft,forEachEntry:Ut,matchAll:_t,isHTMLForm:Dt,hasOwnProperty:Ce,hasOwnProp:Ce,reduceDescriptors:Le,freezeMethods:jt,toObjectSet:kt,toCamelCase:Lt,noop:It,toFiniteNumber:Ht,findKey:Ue,global:_e,isContextDefined:De,ALPHABET:Be,generateString:qt,isSpecCompliantForm:Mt,toJSONObject:Jt,isAsyncFn:zt,isThenable:vt};function U(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}a.inherits(U,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var je=U.prototype,ke={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{ke[e]={value:e}});Object.defineProperties(U,ke);Object.defineProperty(je,"isAxiosError",{value:!0});U.from=(e,t,r,n,o,i)=>{let s=Object.create(je);return a.toFlatObject(e,s,function(f){return f!==Error.prototype},c=>c!=="isAxiosError"),U.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};var m=U;var Y=null;function fe(e){return a.isPlainObject(e)||a.isArray(e)}function He(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ie(e,t,r){return e?e.concat(t).map(function(o,i){return o=He(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function Vt(e){return a.isArray(e)&&!e.some(fe)}var $t=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function Wt(e,t,r){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new(Y||FormData),r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,O){return!a.isUndefined(O[h])});let n=r.metaTokens,o=r.visitor||u,i=r.dots,s=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(o))throw new TypeError("visitor must be a function");function l(d){if(d===null)return"";if(a.isDate(d))return d.toISOString();if(!f&&a.isBlob(d))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(d)||a.isTypedArray(d)?f&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function u(d,h,O){let A=d;if(d&&!O&&typeof d=="object"){if(a.endsWith(h,"{}"))h=n?h:h.slice(0,-2),d=JSON.stringify(d);else if(a.isArray(d)&&Vt(d)||(a.isFileList(d)||a.endsWith(h,"[]"))&&(A=a.toArray(d)))return h=He(h),A.forEach(function($,ut){!(a.isUndefined($)||$===null)&&t.append(s===!0?Ie([h],ut,i):s===null?h:h+"[]",l($))}),!1}return fe(d)?!0:(t.append(Ie(O,h,i),l(d)),!1)}let p=[],w=Object.assign($t,{defaultVisitor:u,convertValue:l,isVisitable:fe});function y(d,h){if(!a.isUndefined(d)){if(p.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(d),a.forEach(d,function(A,F){(!(a.isUndefined(A)||A===null)&&o.call(t,A,a.isString(F)?F.trim():F,h,w))===!0&&y(A,h?h.concat(F):[F])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return y(e),t}var T=Wt;function qe(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Me(e,t){this._pairs=[],e&&T(e,this,t)}var Je=Me.prototype;Je.append=function(t,r){this._pairs.push([t,r])};Je.toString=function(t){let r=t?function(n){return t.call(this,n,qe)}:qe;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var Q=Me;function Kt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function I(e,t,r){if(!t)return e;let n=r&&r.encode||Kt,o=r&&r.serialize,i;if(o?i=o(t,r):i=a.isURLSearchParams(t)?t.toString():new Q(t,r).toString(n),i){let s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}var de=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(n){n!==null&&t(n)})}},pe=de;var Z={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var ze=typeof URLSearchParams<"u"?URLSearchParams:Q;var ve=typeof FormData<"u"?FormData:null;var Ve=typeof Blob<"u"?Blob:null;var Gt=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Xt=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),b={isBrowser:!0,classes:{URLSearchParams:ze,FormData:ve,Blob:Ve},isStandardBrowserEnv:Gt,isStandardBrowserWebWorkerEnv:Xt,protocols:["http","https","file","blob","url","data"]};function me(e,t){return T(e,new b.classes.URLSearchParams,Object.assign({visitor:function(r,n,o,i){return b.isNode&&a.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function Yt(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Qt(e){let t={},r=Object.keys(e),n,o=r.length,i;for(n=0;n<o;n++)i=r[n],t[i]=e[i];return t}function Zt(e){function t(r,n,o,i){let s=r[i++],c=Number.isFinite(+s),f=i>=r.length;return s=!s&&a.isArray(o)?o.length:s,f?(a.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!c):((!o[s]||!a.isObject(o[s]))&&(o[s]=[]),t(r,n,o[s],i)&&a.isArray(o[s])&&(o[s]=Qt(o[s])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){let r={};return a.forEachEntry(e,(n,o)=>{t(Yt(n),o,r,0)}),r}return null}var ee=Zt;var er={"Content-Type":void 0};function tr(e,t,r){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var te={transitional:Z,adapter:["xhr","http"],transformRequest:[function(t,r){let n=r.getContentType()||"",o=n.indexOf("application/json")>-1,i=a.isObject(t);if(i&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return o&&o?JSON.stringify(ee(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return me(t,this.formSerializer).toString();if((c=a.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return T(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),tr(t)):t}],transformResponse:[function(t){let r=this.transitional||te.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(t&&a.isString(t)&&(n&&!this.responseType||o)){let s=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(c){if(s)throw c.name==="SyntaxError"?m.from(c,m.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:b.classes.FormData,Blob:b.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};a.forEach(["delete","get","head"],function(t){te.headers[t]={}});a.forEach(["post","put","patch"],function(t){te.headers[t]=a.merge(er)});var _=te;var rr=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$e=e=>{let t={},r,n,o;return e&&e.split(`
|
|
2
|
-
`).forEach(function(s){o=s.indexOf(":"),r=s.substring(0,o).trim().toLowerCase(),n=s.substring(o+1).trim(),!(!r||t[r]&&
|
|
3
|
-
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){let n=(this[We]=this[We]={accessors:{}}).accessors,o=this.prototype;function i(s){let c=H(s);n[c]||(ir(o,s),n[c]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.freezeMethods(D.prototype);a.freezeMethods(D);var S=D;function q(e,t){let r=this||_,n=t||r,o=S.from(n.headers),i=n.data;return a.forEach(e,function(c){i=c.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function M(e){return!!(e&&e.__CANCEL__)}function Ke(e,t,r){m.call(this,e??"canceled",m.ERR_CANCELED,t,r),this.name="CanceledError"}a.inherits(Ke,m,{__CANCEL__:!0});var C=Ke;function ye(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new m("Request failed with status code "+r.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}var Ge=b.isStandardBrowserEnv?function(){return{write:function(r,n,o,i,s,c){let f=[];f.push(r+"="+encodeURIComponent(n)),a.isNumber(o)&&f.push("expires="+new Date(o).toGMTString()),a.isString(i)&&f.push("path="+i),a.isString(s)&&f.push("domain="+s),c===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(r){let n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Ee(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function we(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function J(e,t){return e&&!Ee(t)?we(e,t):t}var Xe=b.isStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function o(i){let s=i;return t&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=o(window.location.href),function(s){let c=a.isString(s)?o(s):s;return c.protocol===n.protocol&&c.host===n.host}}():function(){return function(){return!0}}();function be(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function ar(e,t){e=e||10;let r=new Array(e),n=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(f){let l=Date.now(),u=n[i];s||(s=l),r[o]=f,n[o]=l;let p=i,w=0;for(;p!==o;)w+=r[p++],p=p%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),l-s<t)return;let y=u&&l-u;return y?Math.round(w*1e3/y):void 0}}var Ye=ar;function Qe(e,t){let r=0,n=Ye(50,250);return o=>{let i=o.loaded,s=o.lengthComputable?o.total:void 0,c=i-r,f=n(c),l=i<=s;r=i;let u={loaded:i,total:s,progress:s?i/s:void 0,bytes:c,rate:f||void 0,estimated:f&&s&&l?(s-i)/f:void 0,event:o};u[t?"download":"upload"]=!0,e(u)}}var cr=typeof XMLHttpRequest<"u",Ze=cr&&function(e){return new Promise(function(r,n){let o=e.data,i=S.from(e.headers).normalize(),s=e.responseType,c;function f(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}a.isFormData(o)&&(b.isStandardBrowserEnv||b.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let l=new XMLHttpRequest;if(e.auth){let y=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(y+":"+d))}let u=J(e.baseURL,e.url);l.open(e.method.toUpperCase(),I(u,e.params,e.paramsSerializer),!0),l.timeout=e.timeout;function p(){if(!l)return;let y=S.from("getAllResponseHeaders"in l&&l.getAllResponseHeaders()),h={data:!s||s==="text"||s==="json"?l.responseText:l.response,status:l.status,statusText:l.statusText,headers:y,config:e,request:l};ye(function(A){r(A),f()},function(A){n(A),f()},h),l=null}if("onloadend"in l?l.onloadend=p:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(p)},l.onabort=function(){l&&(n(new m("Request aborted",m.ECONNABORTED,e,l)),l=null)},l.onerror=function(){n(new m("Network Error",m.ERR_NETWORK,e,l)),l=null},l.ontimeout=function(){let d=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",h=e.transitional||Z;e.timeoutErrorMessage&&(d=e.timeoutErrorMessage),n(new m(d,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,l)),l=null},b.isStandardBrowserEnv){let y=(e.withCredentials||Xe(u))&&e.xsrfCookieName&&Ge.read(e.xsrfCookieName);y&&i.set(e.xsrfHeaderName,y)}o===void 0&&i.setContentType(null),"setRequestHeader"in l&&a.forEach(i.toJSON(),function(d,h){l.setRequestHeader(h,d)}),a.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),s&&s!=="json"&&(l.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&l.addEventListener("progress",Qe(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",Qe(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=y=>{l&&(n(!y||y.type?new C(null,e,l):y),l.abort(),l=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));let w=be(u);if(w&&b.protocols.indexOf(w)===-1){n(new m("Unsupported protocol "+w+":",m.ERR_BAD_REQUEST,e));return}l.send(o||null)})};var ne={http:Y,xhr:Ze};a.forEach(ne,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var et={getAdapter:e=>{e=a.isArray(e)?e:[e];let{length:t}=e,r,n;for(let o=0;o<t&&(r=e[o],!(n=a.isString(r)?ne[r.toLowerCase()]:r));o++);if(!n)throw n===!1?new m(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(a.hasOwnProp(ne,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!a.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:ne};function Se(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new C(null,e)}function oe(e){return Se(e),e.headers=S.from(e.headers),e.data=q.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),et.getAdapter(e.adapter||_.adapter)(e).then(function(n){return Se(e),n.data=q.call(e,e.transformResponse,n),n.headers=S.from(n.headers),n},function(n){return M(n)||(Se(e),n&&n.response&&(n.response.data=q.call(e,e.transformResponse,n.response),n.response.headers=S.from(n.response.headers))),Promise.reject(n)})}var tt=e=>e instanceof S?e.toJSON():e;function g(e,t){t=t||{};let r={};function n(l,u,p){return a.isPlainObject(l)&&a.isPlainObject(u)?a.merge.call({caseless:p},l,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function o(l,u,p){if(a.isUndefined(u)){if(!a.isUndefined(l))return n(void 0,l,p)}else return n(l,u,p)}function i(l,u){if(!a.isUndefined(u))return n(void 0,u)}function s(l,u){if(a.isUndefined(u)){if(!a.isUndefined(l))return n(void 0,l)}else return n(void 0,u)}function c(l,u,p){if(p in t)return n(l,u);if(p in e)return n(void 0,l)}let f={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:c,headers:(l,u)=>o(tt(l),tt(u),!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(u){let p=f[u]||o,w=p(e[u],t[u],u);a.isUndefined(w)&&p!==c||(r[u]=w)}),r}var se="1.4.0";var xe={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{xe[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var rt={};xe.transitional=function(t,r,n){function o(i,s){return"[Axios v"+se+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,c)=>{if(t===!1)throw new m(o(s," has been removed"+(r?" in "+r:"")),m.ERR_DEPRECATED);return r&&!rt[s]&&(rt[s]=!0,console.warn(o(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,s,c):!0}};function lr(e,t,r){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),o=n.length;for(;o-- >0;){let i=n[o],s=t[i];if(s){let c=e[i],f=c===void 0||s(c,i,e);if(f!==!0)throw new m("option "+i+" must be "+f,m.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}}var ie={assertOptions:lr,validators:xe};var N=ie.validators,L=class{constructor(t){this.defaults=t,this.interceptors={request:new pe,response:new pe}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=g(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&ie.assertOptions(n,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:ie.assertOptions(o,{encode:N.function,serialize:N.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s;s=i&&a.merge(i.common,i[r.method]),s&&a.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),r.headers=S.concat(s,i);let c=[],f=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(f=f&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});let l=[];this.interceptors.response.forEach(function(h){l.push(h.fulfilled,h.rejected)});let u,p=0,w;if(!f){let d=[oe.bind(this),void 0];for(d.unshift.apply(d,c),d.push.apply(d,l),w=d.length,u=Promise.resolve(r);p<w;)u=u.then(d[p++],d[p++]);return u}w=c.length;let y=r;for(p=0;p<w;){let d=c[p++],h=c[p++];try{y=d(y)}catch(O){h.call(this,O);break}}try{u=oe.call(this,y)}catch(d){return Promise.reject(d)}for(p=0,w=l.length;p<w;)u=u.then(l[p++],l[p++]);return u}getUri(t){t=g(this.defaults,t);let r=J(t.baseURL,t.url);return I(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){L.prototype[t]=function(r,n){return this.request(g(n||{},{method:t,url:r,data:(n||{}).data}))}});a.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,c){return this.request(g(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}L.prototype[t]=r(),L.prototype[t+"Form"]=r(!0)});var z=L;var v=class{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(c=>{n.subscribe(c),i=c}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},t(function(i,s,c){n.reason||(n.reason=new C(i,s,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new v(function(o){t=o}),cancel:t}}},nt=v;function Ae(e){return function(r){return e.apply(null,r)}}function Re(e){return a.isObject(e)&&e.isAxiosError===!0}var Oe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Oe).forEach(([e,t])=>{Oe[t]=e});var ot=Oe;function st(e){let t=new z(e),r=B(z.prototype.request,t);return a.extend(r,z.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return st(g(e,o))},r}var E=st(_);E.Axios=z;E.CanceledError=C;E.CancelToken=nt;E.isCancel=M;E.VERSION=se;E.toFormData=T;E.AxiosError=m;E.Cancel=E.CanceledError;E.all=function(t){return Promise.all(t)};E.spread=Ae;E.isAxiosError=Re;E.mergeConfig=g;E.AxiosHeaders=S;E.formToJSON=e=>ee(a.isHTMLForm(e)?new FormData(e):e);E.HttpStatusCode=ot;E.default=E;var ae=E;var{Axios:Xo,AxiosError:Yo,CanceledError:Qo,isCancel:Zo,CancelToken:es,VERSION:ts,all:rs,Cancel:ns,isAxiosError:os,spread:ss,toFormData:is,AxiosHeaders:as,HttpStatusCode:cs,formToJSON:ls,mergeConfig:us}=ae;var V=class{constructor({theme:t="light",render_element_or_id:r="recaptcha-el"}){this.gl_api_url="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit",this.captcha_sitekey="6LeRUzsjAAAAANUHNEY6VkUXmMo_wlrDK5SUoFUV",this.verify_url="https://internalapi.activamedia.com.sg/v1/recaptcha/verify",this.theme=t,this.render_element_or_id=r,this.defineOnloadCallBack(),this.loadJsFile()}defineOnloadCallBack(){window.onloadCallback=()=>{}}loadJsFile(){if(document.querySelectorAll(`script[src="${this.gl_api_url}"]`).length===0){var t=document.createElement("script");t.setAttribute("src",this.gl_api_url),t.setAttribute("type","text/javascript"),t.setAttribute("async",!0),t.setAttribute("defer",!0),document.body.appendChild(t)}}sleep(t){return new Promise(r=>setTimeout(r,t))}async render(){let t="";for(;;){if(await this.sleep(200),typeof grecaptcha<"u"&&grecaptcha!==void 0&&typeof grecaptcha.render=="function"){t=grecaptcha.render(this.render_element_or_id,{sitekey:this.captcha_sitekey,theme:this.theme});break}console.info("checking grecaptcha undefined")}return t}reset(t){grecaptcha.reset(t)}fetchResponse(t){try{return grecaptcha.getResponse(t)}catch(r){console.error(r)}}async verifyRecaptcha(t){return await fetch(this.verify_url,{method:"post",body:JSON.stringify({token:t}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(r=>r.json())}};var ge={config:{},fields:{},name:null,endpoint:null,redirectTo:null,fileUpload:{filepond:null,el:null},onSuccess(e){},onFailed(e){},captchaId:null,recaptchaTheme:"light"};function at(e){document.addEventListener("alpine:init",()=>{for(let t of e){let r=Object.assign({},ge,t);document.addEventListener("alpine:init",pr(r))}})}async function ur(e){if(e.captchaId){let t=document.getElementById(e.captchaId);if(t)e.amCaptcha=new V({theme:this.recaptchaTheme,render_element_or_id:t}),e.widgetId=await e.amCaptcha.render();else throw"Can't find recaptcha rendering element. by id: "+this.captchaId}}function fr(e){if(console.log("\u{1F4E2} Form name: "+e.name),typeof e.redirectTo!="function"&&e.redirectTo.length&&new URL(e.endpoint).host==="hapiform.sg"&&console.log("\u{1F680} "+window.location.origin+e.redirectTo),e.endpoint){let t=new URL(e.endpoint),r=e.endpoint.match(/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/);t.host==="hapiform.sg"&&console.log(`\u{1F680} ${t.origin}/${r}`)}}async function dr(e){let t=e.amCaptcha.fetchResponse(e.widgetId);if(t.length===0)throw{recaptchaError:"You can't leave Captcha Code empty"};return await e.amCaptcha.verifyRecaptcha(t).then(r=>{if(r.success===!1)throw{recaptchaError:"captcha invalid: timeout or duplicate."}})}function it(e,t){ae(e).then(r=>{t.redirectTo&&(window.location.href=t.redirectTo),t.fileUpload.filepond&&t.fileUpload.filepond.removeFiles(),mr(),t.resetFields(),t.onSuccess(r),Er()}).catch(r=>{t.errors=r.response.data.errors,t.busy=!1,t.onFailed(r.response),wr(),t.captchaId&&t.amCaptcha.reset(t.widgetId)})}async function pr(e){Alpine.data(e.name,()=>({...e,errors:{},busy:!1,amCaptcha:null,widgetId:null,async init(){this.$watch("busy",t=>{let r=this.$el.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');t?r.forEach(n=>{n.disabled=!0}):r.forEach(n=>{n.disabled=!1})}),this.$init&&this.$init(),ur(this).catch(t=>console.error(t)),fr(this)},async submit(){this.busy=!0,this.errors={};let t=new FormData;if(Object.keys(this.fields).forEach((s,c)=>{typeof this.fields[s]=="object"?this.fields[s].forEach((f,l)=>{t.append(`${s}[${l}]`,f)}):t.append(s,this.fields[s])}),e.fileUpload.filepond)e.fileUpload.filepond.getFiles().forEach((s,c)=>{t.append(`files[${c}]`,s.file,s.name)});else if(e.fileUpload.el){let c=document.querySelector(e.fileUpload.el).files;for(let f=0;f<c.length;f++)t.append(`files[${f}]`,c[f],c[f].name)}let n=new URL(window.top.location.href);t.append("x_origin",n.origin+n.pathname);let o={method:"POST",url:br(e.endpoint),data:t},i=Object.assign({},o,e.config);this.captchaId?await dr(this).then(()=>{it(i,this)}).catch(s=>{this.errors=s,e.onFailed(s),this.busy=!1}).finally(()=>{}):it(i,this)},resetFields(){this.errors={},this.fields=e.fields,this.busy=!1,this.captchaId&&this.amCaptcha.reset(this.widgetId)}}))}function mr(){hr(),yr()}function hr(){try{ge.fileUpload.filepond.removeFiles()}catch{}}function yr(){try{let e=document.querySelector(ge.fileUpload.el);e.value=""}catch{}}function Er(){ct("hapi:success")}function wr(){ct("hapi:error")}function ct(e){let t=new Event(e);document.dispatchEvent(t)}function br(e){let t=new URL(e);return(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1")&&(t.searchParams.set("test","1"),console.log("testing mode!")),t.href}function Te(){if(document.querySelectorAll('script[src="//unpkg.com/alpinejs"]').length===0){var e=document.createElement("script");e.setAttribute("src","//unpkg.com/alpinejs"),e.setAttribute("type","text/javascript"),e.setAttribute("defer",!0),document.body.appendChild(e)}}var lt={forms:at},ws=lt;window.Hapi=lt;Te();})();
|
|
1
|
+
(()=>{function B(e,t){return function(){return e.apply(t,arguments)}}var{toString:dt}=Object.prototype,{getPrototypeOf:le}=Object,K=(e=>t=>{let r=dt.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),x=e=>(e=e.toLowerCase(),t=>K(t)===e),G=e=>t=>typeof t===e,{isArray:P}=Array,j=G("undefined");function pt(e){return e!==null&&!j(e)&&e.constructor!==null&&!j(e.constructor)&&A(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Fe=x("ArrayBuffer");function mt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Fe(e.buffer),t}var ht=G("string"),A=G("function"),Pe=G("number"),X=e=>e!==null&&typeof e=="object",yt=e=>e===!0||e===!1,W=e=>{if(K(e)!=="object")return!1;let t=le(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},wt=x("Date"),Et=x("File"),bt=x("Blob"),St=x("FileList"),At=e=>X(e)&&A(e.pipe),gt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||A(e.append)&&((t=K(e))==="formdata"||t==="object"&&A(e.toString)&&e.toString()==="[object FormData]"))},xt=x("URLSearchParams"),Rt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function k(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),P(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{let i=r?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length,l;for(n=0;n<s;n++)l=i[n],t.call(null,e[l],l,e)}}function Ue(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}var _e=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),De=e=>!j(e)&&e!==_e;function ce(){let{caseless:e}=De(this)&&this||{},t={},r=(n,o)=>{let i=e&&Ue(t,o)||o;W(t[i])&&W(n)?t[i]=ce(t[i],n):W(n)?t[i]=ce({},n):P(n)?t[i]=n.slice():t[i]=n};for(let n=0,o=arguments.length;n<o;n++)arguments[n]&&k(arguments[n],r);return t}var Ot=(e,t,r,{allOwnKeys:n}={})=>(k(t,(o,i)=>{r&&A(o)?e[i]=B(o,r):e[i]=o},{allOwnKeys:n}),e),Tt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ct=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Nt=(e,t,r,n)=>{let o,i,s,l={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!n||n(s,e,t))&&!l[s]&&(t[s]=e[s],l[s]=!0);e=r!==!1&&le(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Ft=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},Pt=e=>{if(!e)return null;if(P(e))return e;let t=e.length;if(!Pe(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Ut=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&le(Uint8Array)),_t=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),o;for(;(o=n.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},Dt=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Lt=x("HTMLFormElement"),Bt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Ce=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),jt=x("RegExp"),Le=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};k(r,(o,i)=>{t(o,i,e)!==!1&&(n[i]=o)}),Object.defineProperties(e,n)},kt=e=>{Le(e,(t,r)=>{if(A(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(A(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},It=(e,t)=>{let r={},n=o=>{o.forEach(i=>{r[i]=!0})};return P(e)?n(e):n(String(e).split(t)),r},Ht=()=>{},qt=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ae="abcdefghijklmnopqrstuvwxyz",Ne="0123456789",Be={DIGIT:Ne,ALPHA:ae,ALPHA_DIGIT:ae+ae.toUpperCase()+Ne},Mt=(e=16,t=Be.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function Jt(e){return!!(e&&A(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var zt=e=>{let t=new Array(10),r=(n,o)=>{if(X(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[o]=n;let i=P(n)?[]:{};return k(n,(s,l)=>{let f=r(s,o+1);!j(f)&&(i[l]=f)}),t[o]=void 0,i}}return n};return r(e,0)},vt=x("AsyncFunction"),Vt=e=>e&&(X(e)||A(e))&&A(e.then)&&A(e.catch),a={isArray:P,isArrayBuffer:Fe,isBuffer:pt,isFormData:gt,isArrayBufferView:mt,isString:ht,isNumber:Pe,isBoolean:yt,isObject:X,isPlainObject:W,isUndefined:j,isDate:wt,isFile:Et,isBlob:bt,isRegExp:jt,isFunction:A,isStream:At,isURLSearchParams:xt,isTypedArray:Ut,isFileList:St,forEach:k,merge:ce,extend:Ot,trim:Rt,stripBOM:Tt,inherits:Ct,toFlatObject:Nt,kindOf:K,kindOfTest:x,endsWith:Ft,toArray:Pt,forEachEntry:_t,matchAll:Dt,isHTMLForm:Lt,hasOwnProperty:Ce,hasOwnProp:Ce,reduceDescriptors:Le,freezeMethods:kt,toObjectSet:It,toCamelCase:Bt,noop:Ht,toFiniteNumber:qt,findKey:Ue,global:_e,isContextDefined:De,ALPHABET:Be,generateString:Mt,isSpecCompliantForm:Jt,toJSONObject:zt,isAsyncFn:vt,isThenable:Vt};function U(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}a.inherits(U,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var je=U.prototype,ke={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{ke[e]={value:e}});Object.defineProperties(U,ke);Object.defineProperty(je,"isAxiosError",{value:!0});U.from=(e,t,r,n,o,i)=>{let s=Object.create(je);return a.toFlatObject(e,s,function(f){return f!==Error.prototype},l=>l!=="isAxiosError"),U.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};var m=U;var Y=null;function ue(e){return a.isPlainObject(e)||a.isArray(e)}function He(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ie(e,t,r){return e?e.concat(t).map(function(o,i){return o=He(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function $t(e){return a.isArray(e)&&!e.some(ue)}var Wt=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function Kt(e,t,r){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new(Y||FormData),r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,R){return!a.isUndefined(R[h])});let n=r.metaTokens,o=r.visitor||u,i=r.dots,s=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(o))throw new TypeError("visitor must be a function");function c(d){if(d===null)return"";if(a.isDate(d))return d.toISOString();if(!f&&a.isBlob(d))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(d)||a.isTypedArray(d)?f&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function u(d,h,R){let g=d;if(d&&!R&&typeof d=="object"){if(a.endsWith(h,"{}"))h=n?h:h.slice(0,-2),d=JSON.stringify(d);else if(a.isArray(d)&&$t(d)||(a.isFileList(d)||a.endsWith(h,"[]"))&&(g=a.toArray(d)))return h=He(h),g.forEach(function($,ft){!(a.isUndefined($)||$===null)&&t.append(s===!0?Ie([h],ft,i):s===null?h:h+"[]",c($))}),!1}return ue(d)?!0:(t.append(Ie(R,h,i),c(d)),!1)}let p=[],E=Object.assign(Wt,{defaultVisitor:u,convertValue:c,isVisitable:ue});function y(d,h){if(!a.isUndefined(d)){if(p.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(d),a.forEach(d,function(g,F){(!(a.isUndefined(g)||g===null)&&o.call(t,g,a.isString(F)?F.trim():F,h,E))===!0&&y(g,h?h.concat(F):[F])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return y(e),t}var T=Kt;function qe(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Me(e,t){this._pairs=[],e&&T(e,this,t)}var Je=Me.prototype;Je.append=function(t,r){this._pairs.push([t,r])};Je.toString=function(t){let r=t?function(n){return t.call(this,n,qe)}:qe;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var Q=Me;function Gt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function I(e,t,r){if(!t)return e;let n=r&&r.encode||Gt,o=r&&r.serialize,i;if(o?i=o(t,r):i=a.isURLSearchParams(t)?t.toString():new Q(t,r).toString(n),i){let s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}var fe=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(n){n!==null&&t(n)})}},de=fe;var Z={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var ze=typeof URLSearchParams<"u"?URLSearchParams:Q;var ve=typeof FormData<"u"?FormData:null;var Ve=typeof Blob<"u"?Blob:null;var Xt=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Yt=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),b={isBrowser:!0,classes:{URLSearchParams:ze,FormData:ve,Blob:Ve},isStandardBrowserEnv:Xt,isStandardBrowserWebWorkerEnv:Yt,protocols:["http","https","file","blob","url","data"]};function pe(e,t){return T(e,new b.classes.URLSearchParams,Object.assign({visitor:function(r,n,o,i){return b.isNode&&a.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function Qt(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Zt(e){let t={},r=Object.keys(e),n,o=r.length,i;for(n=0;n<o;n++)i=r[n],t[i]=e[i];return t}function er(e){function t(r,n,o,i){let s=r[i++],l=Number.isFinite(+s),f=i>=r.length;return s=!s&&a.isArray(o)?o.length:s,f?(a.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!l):((!o[s]||!a.isObject(o[s]))&&(o[s]=[]),t(r,n,o[s],i)&&a.isArray(o[s])&&(o[s]=Zt(o[s])),!l)}if(a.isFormData(e)&&a.isFunction(e.entries)){let r={};return a.forEachEntry(e,(n,o)=>{t(Qt(n),o,r,0)}),r}return null}var ee=er;var tr={"Content-Type":void 0};function rr(e,t,r){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var te={transitional:Z,adapter:["xhr","http"],transformRequest:[function(t,r){let n=r.getContentType()||"",o=n.indexOf("application/json")>-1,i=a.isObject(t);if(i&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return o&&o?JSON.stringify(ee(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return pe(t,this.formSerializer).toString();if((l=a.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return T(l?{"files[]":t}:t,f&&new f,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),rr(t)):t}],transformResponse:[function(t){let r=this.transitional||te.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(t&&a.isString(t)&&(n&&!this.responseType||o)){let s=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(l){if(s)throw l.name==="SyntaxError"?m.from(l,m.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:b.classes.FormData,Blob:b.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};a.forEach(["delete","get","head"],function(t){te.headers[t]={}});a.forEach(["post","put","patch"],function(t){te.headers[t]=a.merge(tr)});var _=te;var nr=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$e=e=>{let t={},r,n,o;return e&&e.split(`
|
|
2
|
+
`).forEach(function(s){o=s.indexOf(":"),r=s.substring(0,o).trim().toLowerCase(),n=s.substring(o+1).trim(),!(!r||t[r]&&nr[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var We=Symbol("internals");function H(e){return e&&String(e).trim().toLowerCase()}function re(e){return e===!1||e==null?e:a.isArray(e)?e.map(re):String(e)}function or(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var ir=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function me(e,t,r,n,o){if(a.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!a.isString(t)){if(a.isString(n))return t.indexOf(n)!==-1;if(a.isRegExp(n))return n.test(t)}}function sr(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function ar(e,t){let r=a.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,i,s){return this[n].call(this,t,o,i,s)},configurable:!0})})}var D=class{constructor(t){t&&this.set(t)}set(t,r,n){let o=this;function i(l,f,c){let u=H(f);if(!u)throw new Error("header name must be a non-empty string");let p=a.findKey(o,u);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||f]=re(l))}let s=(l,f)=>a.forEach(l,(c,u)=>i(c,u,f));return a.isPlainObject(t)||t instanceof this.constructor?s(t,r):a.isString(t)&&(t=t.trim())&&!ir(t)?s($e(t),r):t!=null&&i(r,t,n),this}get(t,r){if(t=H(t),t){let n=a.findKey(this,t);if(n){let o=this[n];if(!r)return o;if(r===!0)return or(o);if(a.isFunction(r))return r.call(this,o,n);if(a.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=H(t),t){let n=a.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||me(this,this[n],n,r)))}return!1}delete(t,r){let n=this,o=!1;function i(s){if(s=H(s),s){let l=a.findKey(n,s);l&&(!r||me(n,n[l],l,r))&&(delete n[l],o=!0)}}return a.isArray(t)?t.forEach(i):i(t),o}clear(t){let r=Object.keys(this),n=r.length,o=!1;for(;n--;){let i=r[n];(!t||me(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){let r=this,n={};return a.forEach(this,(o,i)=>{let s=a.findKey(n,i);if(s){r[s]=re(o),delete r[i];return}let l=t?sr(i):String(i).trim();l!==i&&delete r[i],r[l]=re(o),n[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return a.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&a.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
3
|
+
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){let n=(this[We]=this[We]={accessors:{}}).accessors,o=this.prototype;function i(s){let l=H(s);n[l]||(ar(o,s),n[l]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.freezeMethods(D.prototype);a.freezeMethods(D);var S=D;function q(e,t){let r=this||_,n=t||r,o=S.from(n.headers),i=n.data;return a.forEach(e,function(l){i=l.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function M(e){return!!(e&&e.__CANCEL__)}function Ke(e,t,r){m.call(this,e??"canceled",m.ERR_CANCELED,t,r),this.name="CanceledError"}a.inherits(Ke,m,{__CANCEL__:!0});var C=Ke;function he(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new m("Request failed with status code "+r.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}var Ge=b.isStandardBrowserEnv?function(){return{write:function(r,n,o,i,s,l){let f=[];f.push(r+"="+encodeURIComponent(n)),a.isNumber(o)&&f.push("expires="+new Date(o).toGMTString()),a.isString(i)&&f.push("path="+i),a.isString(s)&&f.push("domain="+s),l===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(r){let n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function ye(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function we(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function J(e,t){return e&&!ye(t)?we(e,t):t}var Xe=b.isStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function o(i){let s=i;return t&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=o(window.location.href),function(s){let l=a.isString(s)?o(s):s;return l.protocol===n.protocol&&l.host===n.host}}():function(){return function(){return!0}}();function Ee(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function cr(e,t){e=e||10;let r=new Array(e),n=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(f){let c=Date.now(),u=n[i];s||(s=c),r[o]=f,n[o]=c;let p=i,E=0;for(;p!==o;)E+=r[p++],p=p%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-s<t)return;let y=u&&c-u;return y?Math.round(E*1e3/y):void 0}}var Ye=cr;function Qe(e,t){let r=0,n=Ye(50,250);return o=>{let i=o.loaded,s=o.lengthComputable?o.total:void 0,l=i-r,f=n(l),c=i<=s;r=i;let u={loaded:i,total:s,progress:s?i/s:void 0,bytes:l,rate:f||void 0,estimated:f&&s&&c?(s-i)/f:void 0,event:o};u[t?"download":"upload"]=!0,e(u)}}var lr=typeof XMLHttpRequest<"u",Ze=lr&&function(e){return new Promise(function(r,n){let o=e.data,i=S.from(e.headers).normalize(),s=e.responseType,l;function f(){e.cancelToken&&e.cancelToken.unsubscribe(l),e.signal&&e.signal.removeEventListener("abort",l)}a.isFormData(o)&&(b.isStandardBrowserEnv||b.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){let y=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(y+":"+d))}let u=J(e.baseURL,e.url);c.open(e.method.toUpperCase(),I(u,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function p(){if(!c)return;let y=S.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),h={data:!s||s==="text"||s==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:y,config:e,request:c};he(function(g){r(g),f()},function(g){n(g),f()},h),c=null}if("onloadend"in c?c.onloadend=p:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(p)},c.onabort=function(){c&&(n(new m("Request aborted",m.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new m("Network Error",m.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let d=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",h=e.transitional||Z;e.timeoutErrorMessage&&(d=e.timeoutErrorMessage),n(new m(d,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,c)),c=null},b.isStandardBrowserEnv){let y=(e.withCredentials||Xe(u))&&e.xsrfCookieName&&Ge.read(e.xsrfCookieName);y&&i.set(e.xsrfHeaderName,y)}o===void 0&&i.setContentType(null),"setRequestHeader"in c&&a.forEach(i.toJSON(),function(d,h){c.setRequestHeader(h,d)}),a.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),s&&s!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",Qe(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",Qe(e.onUploadProgress)),(e.cancelToken||e.signal)&&(l=y=>{c&&(n(!y||y.type?new C(null,e,c):y),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(l),e.signal&&(e.signal.aborted?l():e.signal.addEventListener("abort",l)));let E=Ee(u);if(E&&b.protocols.indexOf(E)===-1){n(new m("Unsupported protocol "+E+":",m.ERR_BAD_REQUEST,e));return}c.send(o||null)})};var ne={http:Y,xhr:Ze};a.forEach(ne,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var et={getAdapter:e=>{e=a.isArray(e)?e:[e];let{length:t}=e,r,n;for(let o=0;o<t&&(r=e[o],!(n=a.isString(r)?ne[r.toLowerCase()]:r));o++);if(!n)throw n===!1?new m(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(a.hasOwnProp(ne,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!a.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:ne};function be(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new C(null,e)}function oe(e){return be(e),e.headers=S.from(e.headers),e.data=q.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),et.getAdapter(e.adapter||_.adapter)(e).then(function(n){return be(e),n.data=q.call(e,e.transformResponse,n),n.headers=S.from(n.headers),n},function(n){return M(n)||(be(e),n&&n.response&&(n.response.data=q.call(e,e.transformResponse,n.response),n.response.headers=S.from(n.response.headers))),Promise.reject(n)})}var tt=e=>e instanceof S?e.toJSON():e;function O(e,t){t=t||{};let r={};function n(c,u,p){return a.isPlainObject(c)&&a.isPlainObject(u)?a.merge.call({caseless:p},c,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function o(c,u,p){if(a.isUndefined(u)){if(!a.isUndefined(c))return n(void 0,c,p)}else return n(c,u,p)}function i(c,u){if(!a.isUndefined(u))return n(void 0,u)}function s(c,u){if(a.isUndefined(u)){if(!a.isUndefined(c))return n(void 0,c)}else return n(void 0,u)}function l(c,u,p){if(p in t)return n(c,u);if(p in e)return n(void 0,c)}let f={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l,headers:(c,u)=>o(tt(c),tt(u),!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(u){let p=f[u]||o,E=p(e[u],t[u],u);a.isUndefined(E)&&p!==l||(r[u]=E)}),r}var ie="1.4.0";var Se={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Se[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var rt={};Se.transitional=function(t,r,n){function o(i,s){return"[Axios v"+ie+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,l)=>{if(t===!1)throw new m(o(s," has been removed"+(r?" in "+r:"")),m.ERR_DEPRECATED);return r&&!rt[s]&&(rt[s]=!0,console.warn(o(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,s,l):!0}};function ur(e,t,r){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),o=n.length;for(;o-- >0;){let i=n[o],s=t[i];if(s){let l=e[i],f=l===void 0||s(l,i,e);if(f!==!0)throw new m("option "+i+" must be "+f,m.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}}var se={assertOptions:ur,validators:Se};var N=se.validators,L=class{constructor(t){this.defaults=t,this.interceptors={request:new de,response:new de}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=O(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&se.assertOptions(n,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:se.assertOptions(o,{encode:N.function,serialize:N.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s;s=i&&a.merge(i.common,i[r.method]),s&&a.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),r.headers=S.concat(s,i);let l=[],f=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(f=f&&h.synchronous,l.unshift(h.fulfilled,h.rejected))});let c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let u,p=0,E;if(!f){let d=[oe.bind(this),void 0];for(d.unshift.apply(d,l),d.push.apply(d,c),E=d.length,u=Promise.resolve(r);p<E;)u=u.then(d[p++],d[p++]);return u}E=l.length;let y=r;for(p=0;p<E;){let d=l[p++],h=l[p++];try{y=d(y)}catch(R){h.call(this,R);break}}try{u=oe.call(this,y)}catch(d){return Promise.reject(d)}for(p=0,E=c.length;p<E;)u=u.then(c[p++],c[p++]);return u}getUri(t){t=O(this.defaults,t);let r=J(t.baseURL,t.url);return I(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){L.prototype[t]=function(r,n){return this.request(O(n||{},{method:t,url:r,data:(n||{}).data}))}});a.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,l){return this.request(O(l||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}L.prototype[t]=r(),L.prototype[t+"Form"]=r(!0)});var z=L;var Ae=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(l=>{n.subscribe(l),i=l}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},t(function(i,s,l){n.reason||(n.reason=new C(i,s,l),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new e(function(o){t=o}),cancel:t}}},nt=Ae;function ge(e){return function(r){return e.apply(null,r)}}function xe(e){return a.isObject(e)&&e.isAxiosError===!0}var Re={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Re).forEach(([e,t])=>{Re[t]=e});var ot=Re;function it(e){let t=new z(e),r=B(z.prototype.request,t);return a.extend(r,z.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return it(O(e,o))},r}var w=it(_);w.Axios=z;w.CanceledError=C;w.CancelToken=nt;w.isCancel=M;w.VERSION=ie;w.toFormData=T;w.AxiosError=m;w.Cancel=w.CanceledError;w.all=function(t){return Promise.all(t)};w.spread=ge;w.isAxiosError=xe;w.mergeConfig=O;w.AxiosHeaders=S;w.formToJSON=e=>ee(a.isHTMLForm(e)?new FormData(e):e);w.HttpStatusCode=ot;w.default=w;var v=w;var{Axios:Qo,AxiosError:Zo,CanceledError:ei,isCancel:ti,CancelToken:ri,VERSION:ni,all:oi,Cancel:ii,isAxiosError:si,spread:ai,toFormData:ci,AxiosHeaders:li,HttpStatusCode:ui,formToJSON:fi,mergeConfig:di}=v;var V=class{constructor({theme:t="light",render_element_or_id:r="recaptcha-el"}){this.gl_api_url="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit",this.captcha_sitekey="6LeRUzsjAAAAANUHNEY6VkUXmMo_wlrDK5SUoFUV",this.verify_url="https://internalapi.activamedia.com.sg/v1/recaptcha/verify",this.theme=t,this.render_element_or_id=r,this.defineOnloadCallBack(),this.loadJsFile()}defineOnloadCallBack(){window.onloadCallback=()=>{}}loadJsFile(){if(document.querySelectorAll(`script[src="${this.gl_api_url}"]`).length===0){var t=document.createElement("script");t.setAttribute("src",this.gl_api_url),t.setAttribute("type","text/javascript"),t.setAttribute("async",!0),t.setAttribute("defer",!0),document.body.appendChild(t)}}sleep(t){return new Promise(r=>setTimeout(r,t))}async render(){let t="";for(;;){if(await this.sleep(200),typeof grecaptcha<"u"&&grecaptcha!==void 0&&typeof grecaptcha.render=="function"){t=grecaptcha.render(this.render_element_or_id,{sitekey:this.captcha_sitekey,theme:this.theme});break}console.info("checking grecaptcha undefined")}return t}reset(t){grecaptcha.reset(t)}fetchResponse(t){try{return grecaptcha.getResponse(t)}catch(r){console.error(r)}}async verifyRecaptcha(t){return await fetch(this.verify_url,{method:"post",body:JSON.stringify({token:t}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(r=>r.json())}};var Oe={config:{},name:null,hapiformID:null,redirectTo:null,integrationScriptUrl:"",fileUpload:{filepond:null,el:null},onSuccess(e){},onFailed(e){},captchaId:null,recaptchaTheme:"light"};function at(e){document.addEventListener("alpine:init",()=>{for(let t of e){let r=Object.assign({},Oe,t);document.addEventListener("alpine:init",hr(r))}})}async function fr(e){if(e.captchaId){let t=document.getElementById(e.captchaId);if(t)e.amCaptcha=new V({theme:this.recaptchaTheme,render_element_or_id:t}),e.widgetId=await e.amCaptcha.render();else throw"Can't find recaptcha rendering element. by id: "+this.captchaId}}function ct(e){if(e.hapiformID.length===0)throw console.error("No hapiform ID provided!"),new Error("No hapiform ID provided!");return`https://hapiform.sg/api/${e.hapiformID}`}function dr(e){console.log("\u{1F4E2} Form name: "+e.name);let t=ct(e);if(typeof e.redirectTo!="function"&&e.redirectTo.length&&new URL(t).host==="hapiform.sg"&&console.log("\u{1F680} "+window.location.origin+e.redirectTo),t){let r=new URL(t),n=t.match(/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/);r.host==="hapiform.sg"&&console.log(`\u{1F680} ${r.origin}/${n}`)}}async function pr(e){let t=e.amCaptcha.fetchResponse(e.widgetId);if(t.length===0)throw{recaptchaError:"You can't leave Captcha Code empty"};return await e.amCaptcha.verifyRecaptcha(t).then(r=>{if(r.success===!1)throw{recaptchaError:"captcha invalid: timeout or duplicate."}})}function mr(e){window.location.hostname!=="localhost"&&window.location.hostname!=="127.0.0.1"&&v(e).then(t=>{}).catch(t=>{console.error(t)})}function st(e,t){v(e).then(r=>{if(t.integrationScriptUrl.length>0){let n=Object.assign({},e);n.url=t.integrationScriptUrl,mr(n)}t.redirectTo&&(window.location.href=t.redirectTo),t.fileUpload.filepond&&t.fileUpload.filepond.removeFiles(),yr(),t.resetFields(),t.onSuccess(r),br()}).catch(r=>{t.errors=r.response.data.errors,t.busy=!1,t.onFailed(r.response),Sr(),t.captchaId&&t.amCaptcha.reset(t.widgetId)})}async function hr(e){Alpine.data(e.name,()=>({...e,errors:{},busy:!1,amCaptcha:null,widgetId:null,async init(){Alpine.store(e.name,{fields:{}}),this.$watch("busy",t=>{let r=this.$el.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');t?r.forEach(n=>{n.disabled=!0}):r.forEach(n=>{n.disabled=!1})}),this.$init&&this.$init(),fr(this).catch(t=>console.error(t)),dr(this)},async submit(){this.busy=!0,this.errors={};let t=new FormData,r=Alpine.store(this.name).fields;if(Object.keys(r).forEach((f,c)=>{typeof r[f]=="object"?r[f].forEach((u,p)=>{t.append(`${f}[${p}]`,u)}):t.append(f,r[f])}),e.fileUpload.filepond)e.fileUpload.filepond.getFiles().forEach((f,c)=>{t.append(`files[${c}]`,f.file,f.name)});else if(e.fileUpload.el){let c=document.querySelector(e.fileUpload.el).files;for(let u=0;u<c.length;u++)t.append(`files[${u}]`,c[u],c[u].name)}let o=new URL(window.top.location.href);t.append("x_origin",o.origin+o.pathname);let i=ct(e),s={method:"POST",url:Ar(i),data:t},l=Object.assign({},s,e.config);this.captchaId?await pr(this).then(()=>{st(l,this)}).catch(f=>{this.errors=f,e.onFailed(f),this.busy=!1}).finally(()=>{}):st(l,this)},resetFields(){this.errors={},Alpine.store(this.name).fields={},this.busy=!1,this.captchaId&&this.amCaptcha.reset(this.widgetId)}}))}function yr(){wr(),Er()}function wr(){try{Oe.fileUpload.filepond.removeFiles()}catch{}}function Er(){try{let e=document.querySelector(Oe.fileUpload.el);e.value=""}catch{}}function br(){lt("hapi:success")}function Sr(){lt("hapi:error")}function lt(e){let t=new Event(e);document.dispatchEvent(t)}function Ar(e){let t=new URL(e);return(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1")&&(t.searchParams.set("test","1"),console.log("testing mode!")),t.href}function Te(){if(document.querySelectorAll('script[src="//unpkg.com/alpinejs"]').length===0){var e=document.createElement("script");e.setAttribute("src","//unpkg.com/alpinejs"),e.setAttribute("type","text/javascript"),e.setAttribute("defer",!0),document.body.appendChild(e)}}var ut={forms:at},Si=ut;window.Hapi=ut;Te();})();
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
"bundleDependencies": false,
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"axios": "^1.4.0",
|
|
8
|
-
"esbuild": "0.
|
|
8
|
+
"esbuild": "0.18.16"
|
|
9
9
|
},
|
|
10
10
|
"deprecated": false,
|
|
11
11
|
"description": "hapiform html js library with google recaptcha",
|
|
12
12
|
"keywords": [
|
|
13
|
+
"hapi",
|
|
13
14
|
"hapiform"
|
|
14
15
|
],
|
|
15
16
|
"license": "MIT",
|
|
@@ -19,5 +20,5 @@
|
|
|
19
20
|
"build": "esbuild index.js --bundle --minify --outfile=./dist/hapi.min.js",
|
|
20
21
|
"watch": "esbuild index.js --watch --bundle --minify --outfile=./dist/hapi.min.js"
|
|
21
22
|
},
|
|
22
|
-
"version": "1.0.
|
|
23
|
+
"version": "1.0.3"
|
|
23
24
|
}
|
package/src/hapi.js
CHANGED
|
@@ -6,10 +6,10 @@ import AMCaptcha from './recaptcha';
|
|
|
6
6
|
|
|
7
7
|
let hapiOptions = {
|
|
8
8
|
config: {},
|
|
9
|
-
fields: {},
|
|
10
9
|
name: null,
|
|
11
|
-
|
|
10
|
+
hapiformID: null,
|
|
12
11
|
redirectTo: null,
|
|
12
|
+
integrationScriptUrl: '',
|
|
13
13
|
fileUpload: {
|
|
14
14
|
filepond: null,
|
|
15
15
|
el: null,
|
|
@@ -51,11 +51,20 @@ async function renderCaptcha(a) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
function orgEndpoint(a) {
|
|
55
|
+
if (a.hapiformID.length === 0) {
|
|
56
|
+
console.error("No hapiform ID provided!");
|
|
57
|
+
throw new Error("No hapiform ID provided!");
|
|
58
|
+
}
|
|
59
|
+
return `https://hapiform.sg/api/${a.hapiformID}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
54
62
|
function displayHapiformInformation(a) {
|
|
55
63
|
console.log("📢 Form name: " + a.name);
|
|
64
|
+
let org_endpoint = orgEndpoint(a);
|
|
56
65
|
// Display redirect path
|
|
57
66
|
if (typeof a.redirectTo !== "function" && a.redirectTo.length) {
|
|
58
|
-
let endpoint = new URL(
|
|
67
|
+
let endpoint = new URL(org_endpoint);
|
|
59
68
|
|
|
60
69
|
if (endpoint.host === "hapiform.sg") {
|
|
61
70
|
console.log("🚀 " + window.location.origin + a.redirectTo);
|
|
@@ -63,9 +72,9 @@ function displayHapiformInformation(a) {
|
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
// Display the endpoint
|
|
66
|
-
if (
|
|
67
|
-
let endpoint = new URL(
|
|
68
|
-
let uuid =
|
|
75
|
+
if (org_endpoint) {
|
|
76
|
+
let endpoint = new URL(org_endpoint);
|
|
77
|
+
let uuid = org_endpoint.match(/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/);
|
|
69
78
|
|
|
70
79
|
if (endpoint.host === "hapiform.sg") {
|
|
71
80
|
console.log(`🚀 ${endpoint.origin}/${uuid}`);
|
|
@@ -88,9 +97,26 @@ async function verifyCaptcha(a) {
|
|
|
88
97
|
});
|
|
89
98
|
}
|
|
90
99
|
|
|
100
|
+
function integrationWebhook(config) {
|
|
101
|
+
if (window.location.hostname !== "localhost" && window.location.hostname !== "127.0.0.1") {
|
|
102
|
+
axios(config).then((res) => {
|
|
103
|
+
}).catch((e) => {
|
|
104
|
+
console.error(e)
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
91
109
|
function onSubmission(config, a) {
|
|
92
110
|
axios(config)
|
|
93
111
|
.then((res) => {
|
|
112
|
+
// on success webhook begin
|
|
113
|
+
if (a.integrationScriptUrl.length > 0) {
|
|
114
|
+
let integration_config = Object.assign({}, config);
|
|
115
|
+
integration_config.url = a.integrationScriptUrl;
|
|
116
|
+
integrationWebhook(integration_config);
|
|
117
|
+
}
|
|
118
|
+
// on success webhook end
|
|
119
|
+
|
|
94
120
|
if (a.redirectTo) {
|
|
95
121
|
window.location.href = a.redirectTo;
|
|
96
122
|
}
|
|
@@ -122,6 +148,10 @@ async function alpineInitData(options) {
|
|
|
122
148
|
amCaptcha: null,
|
|
123
149
|
widgetId: null,
|
|
124
150
|
async init() {
|
|
151
|
+
|
|
152
|
+
// todo: remove special characters
|
|
153
|
+
Alpine.store(options.name, {fields: {}});
|
|
154
|
+
|
|
125
155
|
this.$watch("busy", (value) => {
|
|
126
156
|
let buttons = this.$el.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');
|
|
127
157
|
|
|
@@ -151,16 +181,17 @@ async function alpineInitData(options) {
|
|
|
151
181
|
// Get all form fields
|
|
152
182
|
let formData = new FormData();
|
|
153
183
|
|
|
154
|
-
let
|
|
184
|
+
let fieldsStore = Alpine.store(this.name).fields;
|
|
185
|
+
let fieldNames = Object.keys(fieldsStore);
|
|
155
186
|
|
|
156
187
|
// Append all fields to formData
|
|
157
188
|
fieldNames.forEach((field, i) => {
|
|
158
|
-
if (typeof
|
|
159
|
-
|
|
189
|
+
if (typeof fieldsStore[field] === "object") {
|
|
190
|
+
fieldsStore[field].forEach((item, index) => {
|
|
160
191
|
formData.append(`${field}[${index}]`, item);
|
|
161
192
|
});
|
|
162
193
|
} else {
|
|
163
|
-
formData.append(field,
|
|
194
|
+
formData.append(field, fieldsStore[field]);
|
|
164
195
|
}
|
|
165
196
|
});
|
|
166
197
|
|
|
@@ -185,10 +216,10 @@ async function alpineInitData(options) {
|
|
|
185
216
|
let currentUrl = new URL(window.top.location.href);
|
|
186
217
|
|
|
187
218
|
formData.append("x_origin", currentUrl.origin + currentUrl.pathname);
|
|
188
|
-
|
|
219
|
+
let org_endpoint = orgEndpoint(options);
|
|
189
220
|
const defaultConfig = {
|
|
190
221
|
method: "POST",
|
|
191
|
-
url: getEndpoint(
|
|
222
|
+
url: getEndpoint(org_endpoint),
|
|
192
223
|
data: formData,
|
|
193
224
|
};
|
|
194
225
|
|
|
@@ -215,7 +246,8 @@ async function alpineInitData(options) {
|
|
|
215
246
|
},
|
|
216
247
|
resetFields() {
|
|
217
248
|
this.errors = {};
|
|
218
|
-
this.fields = options.fields;
|
|
249
|
+
// this.fields = options.fields;
|
|
250
|
+
Alpine.store(this.name).fields = {};
|
|
219
251
|
this.busy = false;
|
|
220
252
|
if (this.captchaId) this.amCaptcha.reset(this.widgetId);
|
|
221
253
|
},
|