hapi-recaptcha-html 1.0.5 → 1.0.7
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 +34 -3
- package/dist/hapi.min.js +9 -3
- package/package.json +33 -22
- package/demo/contactus-success.html +0 -14
- package/demo/enquiry-forms.js +0 -19
- package/demo/index.html +0 -128
- package/demo/loading.svg +0 -31
- package/index.js +0 -13
- package/src/alpineloader.js +0 -10
- package/src/hapi.js +0 -308
- package/src/recaptcha.js +0 -84
package/README.md
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
# HAPI Form Plugin
|
|
2
|
+
|
|
2
3
|
Wrapper of Alpine JS plugin for HAPI Form, works on Laravel API endpoint.
|
|
4
|
+
|
|
3
5
|
## CDN
|
|
6
|
+
|
|
4
7
|
```html
|
|
5
8
|
<script src="https://unpkg.com/hapi-recaptcha-html@latest/dist/hapi.min.js" defer></script>
|
|
6
9
|
|
|
7
10
|
<script src="enquiry-forms.js" defer></script>
|
|
8
11
|
```
|
|
12
|
+
|
|
13
|
+
## DataLayer
|
|
14
|
+
|
|
15
|
+
> **DataLayer Integration**
|
|
16
|
+
>
|
|
17
|
+
> This library automatically pushes a `form_submission` event to the global `window.dataLayer` when a form is successfully submitted.
|
|
18
|
+
>
|
|
19
|
+
> The event payload includes all form field values under the property `enhanced_conversion_data`.
|
|
20
|
+
>
|
|
21
|
+
> Example pushed object:
|
|
22
|
+
> ```js
|
|
23
|
+
> {
|
|
24
|
+
> event: "form_submission",
|
|
25
|
+
> enhanced_conversion_data: {
|
|
26
|
+
> name: "John Doe",
|
|
27
|
+
> email: "john@example.com"
|
|
28
|
+
> // ...other fields
|
|
29
|
+
> }
|
|
30
|
+
> }
|
|
31
|
+
> ```
|
|
32
|
+
> You do not need to add any extra integration code for DataLayer support; it works out of the box.
|
|
33
|
+
|
|
34
|
+
|
|
9
35
|
## Usage
|
|
36
|
+
|
|
10
37
|
```html
|
|
11
38
|
enquiry-forms.js file:
|
|
12
39
|
|
|
@@ -19,6 +46,7 @@ enquiry-forms.js file:
|
|
|
19
46
|
redirectTo: '/contactus-success.html',
|
|
20
47
|
captchaId: 'captcha-01',
|
|
21
48
|
integrationScriptUrl: "", // optional, POST current DataForm to external URL (API).
|
|
49
|
+
recaptchaSize: "normal", // normal or compact
|
|
22
50
|
},
|
|
23
51
|
// form 02
|
|
24
52
|
{
|
|
@@ -27,6 +55,7 @@ enquiry-forms.js file:
|
|
|
27
55
|
redirectTo: '/contactus-success.html',
|
|
28
56
|
captchaId: 'captcha-02',
|
|
29
57
|
integrationScriptUrl: "", // optional, POST current DataForm to external URL (API).
|
|
58
|
+
recaptchaSize: "normal", // normal or compact
|
|
30
59
|
}
|
|
31
60
|
...
|
|
32
61
|
]
|
|
@@ -34,6 +63,7 @@ enquiry-forms.js file:
|
|
|
34
63
|
|
|
35
64
|
</script>
|
|
36
65
|
```
|
|
66
|
+
|
|
37
67
|
please note that you must use `$store.<form-name>.fileds.<field-name>` to bind inputs.
|
|
38
68
|
|
|
39
69
|
```html
|
|
@@ -47,9 +77,10 @@ please note that you must use `$store.<form-name>.fileds.<field-name>` to bind i
|
|
|
47
77
|
|
|
48
78
|
|
|
49
79
|
```
|
|
80
|
+
|
|
50
81
|
- name – The name of the instance, to be matched with `x-data="name"`.
|
|
51
82
|
- hapiformID – hapiform ID. (old version `endpoint` is still accepted.)
|
|
52
|
-
- redirectTo – Location to be redirected after success. Eg: "/thank-you" or "https://example.com". (Optional)
|
|
83
|
+
- redirectTo – Location to be redirected after success. Eg: "/thank-you" or "[https://example.com](https://example.com)". (Optional)
|
|
53
84
|
- integrationScriptUrl - optional, POST current DataForm to external URL (API).
|
|
54
85
|
- captchaId - Id of div element to render the google recaptcha, `null` means recaptcha is disabled.
|
|
55
86
|
- recaptchaTheme - `light` or `dark`.
|
|
@@ -57,14 +88,14 @@ please note that you must use `$store.<form-name>.fileds.<field-name>` to bind i
|
|
|
57
88
|
- onFailed() – On failed event.
|
|
58
89
|
- errors.recaptchaError - to display captcha verification errors.
|
|
59
90
|
|
|
60
|
-
|
|
61
91
|
## Events
|
|
62
92
|
|
|
63
93
|
### Success Event
|
|
64
|
-
When submission is success, Hapi will emit `hapi:success` event.
|
|
65
94
|
|
|
95
|
+
When submission is success, Hapi will emit `hapi:success` event.
|
|
66
96
|
|
|
67
97
|
### Error Event
|
|
98
|
+
|
|
68
99
|
When submission has error, Hapi will emit `hapi:error` event.
|
|
69
100
|
|
|
70
101
|
### Example
|
package/dist/hapi.min.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
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]&&
|
|
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,endpoint: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.endpoint)return e.endpoint;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();})();
|
|
1
|
+
var Hapi=(()=>{var Ne=Object.defineProperty;var er=Object.getOwnPropertyDescriptor;var tr=Object.getOwnPropertyNames;var rr=Object.prototype.hasOwnProperty;var ft=(e,t)=>{for(var r in t)Ne(e,r,{get:t[r],enumerable:!0})},nr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of tr(t))!rr.call(e,o)&&o!==r&&Ne(e,o,{get:()=>t[o],enumerable:!(n=er(t,o))||n.enumerable});return e};var or=e=>nr(Ne({},"__esModule",{value:!0}),e);var kn={};ft(kn,{forms:()=>Gt});function G(e,t){return function(){return e.apply(t,arguments)}}var{toString:sr}=Object.prototype,{getPrototypeOf:Ue}=Object,{iterator:me,toStringTag:ht}=Symbol,he=(e=>t=>{let r=sr.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>he(t)===e),ye=e=>t=>typeof t===e,{isArray:z}=Array,v=ye("undefined");function Q(e){return e!==null&&!v(e)&&e.constructor!==null&&!v(e.constructor)&&C(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var yt=P("ArrayBuffer");function ir(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&yt(e.buffer),t}var ar=ye("string"),C=ye("function"),wt=ye("number"),Y=e=>e!==null&&typeof e=="object",cr=e=>e===!0||e===!1,pe=e=>{if(he(e)!=="object")return!1;let t=Ue(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ht in e)&&!(me in e)},lr=e=>{if(!Y(e)||Q(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},ur=P("Date"),fr=P("File"),dr=e=>!!(e&&typeof e.uri<"u"),pr=e=>e&&typeof e.getParts<"u",mr=P("Blob"),hr=P("FileList"),yr=e=>Y(e)&&C(e.pipe);function wr(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}var dt=wr(),pt=typeof dt.FormData<"u"?dt.FormData:void 0,br=e=>{let t;return e&&(pt&&e instanceof pt||C(e.append)&&((t=he(e))==="formdata"||t==="object"&&C(e.toString)&&e.toString()==="[object FormData]"))},gr=P("URLSearchParams"),[Er,Rr,Sr,xr]=["ReadableStream","Request","Response","Headers"].map(P),Or=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Z(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),z(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(Q(e))return;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 bt(e,t){if(Q(e))return null;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 H=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),gt=e=>!v(e)&&e!==H;function Fe(){let{caseless:e,skipUndefined:t}=gt(this)&&this||{},r={},n=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;let s=e&&bt(r,i)||i;pe(r[s])&&pe(o)?r[s]=Fe(r[s],o):pe(o)?r[s]=Fe({},o):z(o)?r[s]=o.slice():(!t||!v(o))&&(r[s]=o)};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&Z(arguments[o],n);return r}var Ar=(e,t,r,{allOwnKeys:n}={})=>(Z(t,(o,i)=>{r&&C(o)?Object.defineProperty(e,i,{value:G(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),Tr=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Cr=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},_r=(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},Nr=(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},Fr=e=>{if(!e)return null;if(z(e))return e;let t=e.length;if(!wt(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Ur=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ue(Uint8Array)),Pr=(e,t)=>{let n=(e&&e[me]).call(e),o;for(;(o=n.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},Dr=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Lr=P("HTMLFormElement"),Ir=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),mt=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Br=P("RegExp"),Et=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};Z(r,(o,i)=>{let s;(s=t(o,i,e))!==!1&&(n[i]=s||o)}),Object.defineProperties(e,n)},kr=e=>{Et(e,(t,r)=>{if(C(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(C(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+"'")})}})},jr=(e,t)=>{let r={},n=o=>{o.forEach(i=>{r[i]=!0})};return z(e)?n(e):n(String(e).split(t)),r},qr=()=>{},Hr=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Mr(e){return!!(e&&C(e.append)&&e[ht]==="FormData"&&e[me])}var vr=e=>{let t=new Array(10),r=(n,o)=>{if(Y(n)){if(t.indexOf(n)>=0)return;if(Q(n))return n;if(!("toJSON"in n)){t[o]=n;let i=z(n)?[]:{};return Z(n,(s,c)=>{let d=r(s,o+1);!v(d)&&(i[c]=d)}),t[o]=void 0,i}}return n};return r(e,0)},zr=P("AsyncFunction"),Jr=e=>e&&(Y(e)||C(e))&&C(e.then)&&C(e.catch),Rt=((e,t)=>e?setImmediate:t?((r,n)=>(H.addEventListener("message",({source:o,data:i})=>{o===H&&i===r&&n.length&&n.shift()()},!1),o=>{n.push(o),H.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",C(H.postMessage)),Vr=typeof queueMicrotask<"u"?queueMicrotask.bind(H):typeof process<"u"&&process.nextTick||Rt,$r=e=>e!=null&&C(e[me]),a={isArray:z,isArrayBuffer:yt,isBuffer:Q,isFormData:br,isArrayBufferView:ir,isString:ar,isNumber:wt,isBoolean:cr,isObject:Y,isPlainObject:pe,isEmptyObject:lr,isReadableStream:Er,isRequest:Rr,isResponse:Sr,isHeaders:xr,isUndefined:v,isDate:ur,isFile:fr,isReactNativeBlob:dr,isReactNative:pr,isBlob:mr,isRegExp:Br,isFunction:C,isStream:yr,isURLSearchParams:gr,isTypedArray:Ur,isFileList:hr,forEach:Z,merge:Fe,extend:Ar,trim:Or,stripBOM:Tr,inherits:Cr,toFlatObject:_r,kindOf:he,kindOfTest:P,endsWith:Nr,toArray:Fr,forEachEntry:Pr,matchAll:Dr,isHTMLForm:Lr,hasOwnProperty:mt,hasOwnProp:mt,reduceDescriptors:Et,freezeMethods:kr,toObjectSet:jr,toCamelCase:Ir,noop:qr,toFiniteNumber:Hr,findKey:bt,global:H,isContextDefined:gt,isSpecCompliantForm:Mr,toJSONObject:vr,isAsyncFn:zr,isThenable:Jr,setImmediate:Rt,asap:Vr,isIterable:$r};var O=class e extends Error{static from(t,r,n,o,i,s){let c=new e(t.message,r||t.code,n,o,i);return c.cause=t,c.name=t.name,t.status!=null&&c.status==null&&(c.status=t.status),s&&Object.assign(c,s),c}constructor(t,r,n,o,i){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){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.status}}};O.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";O.ERR_BAD_OPTION="ERR_BAD_OPTION";O.ECONNABORTED="ECONNABORTED";O.ETIMEDOUT="ETIMEDOUT";O.ERR_NETWORK="ERR_NETWORK";O.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";O.ERR_DEPRECATED="ERR_DEPRECATED";O.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";O.ERR_BAD_REQUEST="ERR_BAD_REQUEST";O.ERR_CANCELED="ERR_CANCELED";O.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";O.ERR_INVALID_URL="ERR_INVALID_URL";var y=O;var we=null;function De(e){return a.isPlainObject(e)||a.isArray(e)}function St(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Pe(e,t,r){return e?e.concat(t).map(function(o,i){return o=St(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function Wr(e){return a.isArray(e)&&!e.some(De)}var Kr=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function Xr(e,t,r){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new(we||FormData),r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,p){return!a.isUndefined(p[h])});let n=r.metaTokens,o=r.visitor||l,i=r.dots,s=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(o))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!d&&a.isBlob(f))throw new y("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,h,p){let g=f;if(a.isReactNative(t)&&a.isReactNativeBlob(f))return t.append(Pe(p,h,i),u(f)),!1;if(f&&!p&&typeof f=="object"){if(a.endsWith(h,"{}"))h=n?h:h.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Wr(f)||(a.isFileList(f)||a.endsWith(h,"[]"))&&(g=a.toArray(f)))return h=St(h),g.forEach(function(S,A){!(a.isUndefined(S)||S===null)&&t.append(s===!0?Pe([h],A,i):s===null?h:h+"[]",u(S))}),!1}return De(f)?!0:(t.append(Pe(p,h,i),u(f)),!1)}let m=[],w=Object.assign(Kr,{defaultVisitor:l,convertValue:u,isVisitable:De});function x(f,h){if(!a.isUndefined(f)){if(m.indexOf(f)!==-1)throw Error("Circular reference detected in "+h.join("."));m.push(f),a.forEach(f,function(g,_){(!(a.isUndefined(g)||g===null)&&o.call(t,g,a.isString(_)?_.trim():_,h,w))===!0&&x(g,h?h.concat(_):[_])}),m.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return x(e),t}var k=Xr;function xt(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Ot(e,t){this._pairs=[],e&&k(e,this,t)}var At=Ot.prototype;At.append=function(t,r){this._pairs.push([t,r])};At.toString=function(t){let r=t?function(n){return t.call(this,n,xt)}:xt;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var be=Ot;function Gr(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ee(e,t,r){if(!t)return e;let n=r&&r.encode||Gr,o=a.isFunction(r)?{serialize:r}:r,i=o&&o.serialize,s;if(i?s=i(t,o):s=a.isURLSearchParams(t)?t.toString():new be(t,o).toString(n),s){let c=e.indexOf("#");c!==-1&&(e=e.slice(0,c)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}var Le=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)})}},Ie=Le;var J={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0};var Tt=typeof URLSearchParams<"u"?URLSearchParams:be;var Ct=typeof FormData<"u"?FormData:null;var _t=typeof Blob<"u"?Blob:null;var Nt={isBrowser:!0,classes:{URLSearchParams:Tt,FormData:Ct,Blob:_t},protocols:["http","https","file","blob","url","data"]};var je={};ft(je,{hasBrowserEnv:()=>ke,hasStandardBrowserEnv:()=>Qr,hasStandardBrowserWebWorkerEnv:()=>Yr,navigator:()=>Be,origin:()=>Zr});var ke=typeof window<"u"&&typeof document<"u",Be=typeof navigator=="object"&&navigator||void 0,Qr=ke&&(!Be||["ReactNative","NativeScript","NS"].indexOf(Be.product)<0),Yr=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),Zr=ke&&window.location.href||"http://localhost";var b={...je,...Nt};function qe(e,t){return k(e,new b.classes.URLSearchParams,{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 en(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function tn(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 rn(e){function t(r,n,o,i){let s=r[i++];if(s==="__proto__")return!0;let c=Number.isFinite(+s),d=i>=r.length;return s=!s&&a.isArray(o)?o.length:s,d?(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]=tn(o[s])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){let r={};return a.forEachEntry(e,(n,o)=>{t(en(n),o,r,0)}),r}return null}var ge=rn;function nn(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 He={transitional:J,adapter:["xhr","http","fetch"],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?JSON.stringify(ge(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(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 qe(t,this.formSerializer).toString();if((c=a.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return k(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),nn(t)):t}],transformResponse:[function(t){let r=this.transitional||He.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(n&&!this.responseType||o)){let s=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(c){if(s)throw c.name==="SyntaxError"?y.from(c,y.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, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{He.headers[e]={}});var V=He;var on=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"]),Ft=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]&&on[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var Ut=Symbol("internals"),sn=e=>!/[\r\n]/.test(e);function Pt(e,t){if(!(e===!1||e==null)){if(a.isArray(e)){e.forEach(r=>Pt(r,t));return}if(!sn(String(e)))throw new Error(`Invalid character in header content ["${t}"]`)}}function te(e){return e&&String(e).trim().toLowerCase()}function an(e){let t=e.length;for(;t>0;){let r=e.charCodeAt(t-1);if(r!==10&&r!==13)break;t-=1}return t===e.length?e:e.slice(0,t)}function Ee(e){return e===!1||e==null?e:a.isArray(e)?e.map(Ee):an(String(e))}function cn(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 ln=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 un(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function fn(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 $=class{constructor(t){t&&this.set(t)}set(t,r,n){let o=this;function i(c,d,u){let l=te(d);if(!l)throw new Error("header name must be a non-empty string");let m=a.findKey(o,l);(!m||o[m]===void 0||u===!0||u===void 0&&o[m]!==!1)&&(Pt(c,d),o[m||d]=Ee(c))}let s=(c,d)=>a.forEach(c,(u,l)=>i(u,l,d));if(a.isPlainObject(t)||t instanceof this.constructor)s(t,r);else if(a.isString(t)&&(t=t.trim())&&!ln(t))s(Ft(t),r);else if(a.isObject(t)&&a.isIterable(t)){let c={},d,u;for(let l of t){if(!a.isArray(l))throw TypeError("Object iterator must return a key-value pair");c[u=l[0]]=(d=c[u])?a.isArray(d)?[...d,l[1]]:[d,l[1]]:l[1]}s(c,r)}else t!=null&&i(r,t,n);return this}get(t,r){if(t=te(t),t){let n=a.findKey(this,t);if(n){let o=this[n];if(!r)return o;if(r===!0)return cn(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=te(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=te(s),s){let c=a.findKey(n,s);c&&(!r||Me(n,n[c],c,r))&&(delete n[c],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]=Ee(o),delete r[i];return}let c=t?un(i):String(i).trim();c!==i&&delete r[i],r[c]=Ee(o),n[c]=!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
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}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[Ut]=this[Ut]={accessors:{}}).accessors,o=this.prototype;function i(s){let c=te(s);n[c]||(fn(o,s),n[c]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};$.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.reduceDescriptors($.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});a.freezeMethods($);var R=$;function re(e,t){let r=this||V,n=t||r,o=R.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 ne(e){return!!(e&&e.__CANCEL__)}var ve=class extends y{constructor(t,r,n){super(t??"canceled",y.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}},L=ve;function oe(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new y("Request failed with status code "+r.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function ze(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function dn(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(d){let u=Date.now(),l=n[i];s||(s=u),r[o]=d,n[o]=u;let m=i,w=0;for(;m!==o;)w+=r[m++],m=m%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),u-s<t)return;let x=l&&u-l;return x?Math.round(w*1e3/x):void 0}}var Dt=dn;function pn(e,t){let r=0,n=1e3/t,o,i,s=(u,l=Date.now())=>{r=l,o=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{let l=Date.now(),m=l-r;m>=n?s(u,l):(o=u,i||(i=setTimeout(()=>{i=null,s(o)},n-m)))},()=>o&&s(o)]}var Lt=pn;var W=(e,t,r=3)=>{let n=0,o=Dt(50,250);return Lt(i=>{let s=i.loaded,c=i.lengthComputable?i.total:void 0,d=s-n,u=o(d),l=s<=c;n=s;let m={loaded:s,total:c,progress:c?s/c:void 0,bytes:d,rate:u||void 0,estimated:u&&c&&l?(c-s)/u:void 0,event:i,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(m)},r)},Je=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Ve=e=>(...t)=>a.asap(()=>e(...t));var It=b.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,b.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(b.origin),b.navigator&&/(msie|trident)/i.test(b.navigator.userAgent)):()=>!0;var Bt=b.hasStandardBrowserEnv?{write(e,t,r,n,o,i,s){if(typeof document>"u")return;let c=[`${e}=${encodeURIComponent(t)}`];a.isNumber(r)&&c.push(`expires=${new Date(r).toUTCString()}`),a.isString(n)&&c.push(`path=${n}`),a.isString(o)&&c.push(`domain=${o}`),i===!0&&c.push("secure"),a.isString(s)&&c.push(`SameSite=${s}`),document.cookie=c.join("; ")},read(e){if(typeof document>"u")return null;let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function $e(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function We(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function se(e,t,r){let n=!$e(t);return e&&(n||r==!1)?We(e,t):t}var kt=e=>e instanceof R?{...e}:e;function D(e,t){t=t||{};let r={};function n(u,l,m,w){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:w},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function o(u,l,m,w){if(a.isUndefined(l)){if(!a.isUndefined(u))return n(void 0,u,m,w)}else return n(u,l,m,w)}function i(u,l){if(!a.isUndefined(l))return n(void 0,l)}function s(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function c(u,l,m){if(m in t)return n(u,l);if(m in e)return n(void 0,u)}let d={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken: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:(u,l,m)=>o(kt(u),kt(l),m,!0)};return a.forEach(Object.keys({...e,...t}),function(l){if(l==="__proto__"||l==="constructor"||l==="prototype")return;let m=a.hasOwnProp(d,l)?d[l]:o,w=m(e[l],t[l],l);a.isUndefined(w)&&m!==c||(r[l]=w)}),r}var Re=e=>{let t=D({},e),{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:c}=t;if(t.headers=s=R.from(s),t.url=ee(se(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&s.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(r)){if(b.hasStandardBrowserEnv||b.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(a.isFunction(r.getHeaders)){let d=r.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,m])=>{u.includes(l.toLowerCase())&&s.set(l,m)})}}if(b.hasStandardBrowserEnv&&(n&&a.isFunction(n)&&(n=n(t)),n||n!==!1&&It(t.url))){let d=o&&i&&Bt.read(i);d&&s.set(o,d)}return t};var mn=typeof XMLHttpRequest<"u",jt=mn&&function(e){return new Promise(function(r,n){let o=Re(e),i=o.data,s=R.from(o.headers).normalize(),{responseType:c,onUploadProgress:d,onDownloadProgress:u}=o,l,m,w,x,f;function h(){x&&x(),f&&f(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let p=new XMLHttpRequest;p.open(o.method.toUpperCase(),o.url,!0),p.timeout=o.timeout;function g(){if(!p)return;let S=R.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),U={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:S,config:e,request:p};oe(function(N){r(N),h()},function(N){n(N),h()},U),p=null}"onloadend"in p?p.onloadend=g:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(g)},p.onabort=function(){p&&(n(new y("Request aborted",y.ECONNABORTED,e,p)),p=null)},p.onerror=function(A){let U=A&&A.message?A.message:"Network Error",j=new y(U,y.ERR_NETWORK,e,p);j.event=A||null,n(j),p=null},p.ontimeout=function(){let A=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",U=o.transitional||J;o.timeoutErrorMessage&&(A=o.timeoutErrorMessage),n(new y(A,U.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,p)),p=null},i===void 0&&s.setContentType(null),"setRequestHeader"in p&&a.forEach(s.toJSON(),function(A,U){p.setRequestHeader(U,A)}),a.isUndefined(o.withCredentials)||(p.withCredentials=!!o.withCredentials),c&&c!=="json"&&(p.responseType=o.responseType),u&&([w,f]=W(u,!0),p.addEventListener("progress",w)),d&&p.upload&&([m,x]=W(d),p.upload.addEventListener("progress",m),p.upload.addEventListener("loadend",x)),(o.cancelToken||o.signal)&&(l=S=>{p&&(n(!S||S.type?new L(null,e,p):S),p.abort(),p=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));let _=ze(o.url);if(_&&b.protocols.indexOf(_)===-1){n(new y("Unsupported protocol "+_+":",y.ERR_BAD_REQUEST,e));return}p.send(i||null)})};var hn=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o,i=function(u){if(!o){o=!0,c();let l=u instanceof Error?u:this.reason;n.abort(l instanceof y?l:new L(l instanceof Error?l.message:l))}},s=t&&setTimeout(()=>{s=null,i(new y(`timeout of ${t}ms exceeded`,y.ETIMEDOUT))},t),c=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));let{signal:d}=n;return d.unsubscribe=()=>a.asap(c),d}},qt=hn;var yn=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,o;for(;n<r;)o=n+t,yield e.slice(n,o),n=o},wn=async function*(e,t){for await(let r of bn(e))yield*yn(r,t)},bn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},Ke=(e,t,r,n)=>{let o=wn(e,t),i=0,s,c=d=>{s||(s=!0,n&&n(d))};return new ReadableStream({async pull(d){try{let{done:u,value:l}=await o.next();if(u){c(),d.close();return}let m=l.byteLength;if(r){let w=i+=m;r(w)}d.enqueue(new Uint8Array(l))}catch(u){throw c(u),u}},cancel(d){return c(d),o.return()}},{highWaterMark:2})};var Ht=64*1024,{isFunction:Se}=a,gn=(({Request:e,Response:t})=>({Request:e,Response:t}))(a.global),{ReadableStream:Mt,TextEncoder:vt}=a.global,zt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},En=e=>{e=a.merge.call({skipUndefined:!0},gn,e);let{fetch:t,Request:r,Response:n}=e,o=t?Se(t):typeof fetch=="function",i=Se(r),s=Se(n);if(!o)return!1;let c=o&&Se(Mt),d=o&&(typeof vt=="function"?(f=>h=>f.encode(h))(new vt):async f=>new Uint8Array(await new r(f).arrayBuffer())),u=i&&c&&zt(()=>{let f=!1,h=new Mt,p=new r(b.origin,{body:h,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return h.cancel(),f&&!p}),l=s&&c&&zt(()=>a.isReadableStream(new n("").body)),m={stream:l&&(f=>f.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!m[f]&&(m[f]=(h,p)=>{let g=h&&h[f];if(g)return g.call(h);throw new y(`Response type '${f}' is not supported`,y.ERR_NOT_SUPPORT,p)})});let w=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new r(b.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await d(f)).byteLength},x=async(f,h)=>{let p=a.toFiniteNumber(f.getContentLength());return p??w(h)};return async f=>{let{url:h,method:p,data:g,signal:_,cancelToken:S,timeout:A,onDownloadProgress:U,onUploadProgress:j,responseType:N,headers:Ce,withCredentials:ue="same-origin",fetchOptions:st}=Re(f),it=t||fetch;N=N?(N+"").toLowerCase():"text";let fe=qt([_,S&&S.toAbortSignal()],A),X=null,q=fe&&fe.unsubscribe&&(()=>{fe.unsubscribe()}),at;try{if(j&&u&&p!=="get"&&p!=="head"&&(at=await x(Ce,g))!==0){let B=new r(h,{method:"POST",body:g,duplex:"half"}),M;if(a.isFormData(g)&&(M=B.headers.get("content-type"))&&Ce.setContentType(M),B.body){let[_e,de]=Je(at,W(Ve(j)));g=Ke(B.body,Ht,_e,de)}}a.isString(ue)||(ue=ue?"include":"omit");let T=i&&"credentials"in r.prototype,ct={...st,signal:fe,method:p.toUpperCase(),headers:Ce.normalize().toJSON(),body:g,duplex:"half",credentials:T?ue:void 0};X=i&&new r(h,ct);let I=await(i?it(X,st):it(h,ct)),lt=l&&(N==="stream"||N==="response");if(l&&(U||lt&&q)){let B={};["status","statusText","headers"].forEach(ut=>{B[ut]=I[ut]});let M=a.toFiniteNumber(I.headers.get("content-length")),[_e,de]=U&&Je(M,W(Ve(U),!0))||[];I=new n(Ke(I.body,Ht,_e,()=>{de&&de(),q&&q()}),B)}N=N||"text";let Zt=await m[a.findKey(m,N)||"text"](I,f);return!lt&&q&&q(),await new Promise((B,M)=>{oe(B,M,{data:Zt,headers:R.from(I.headers),status:I.status,statusText:I.statusText,config:f,request:X})})}catch(T){throw q&&q(),T&&T.name==="TypeError"&&/Load failed|fetch/i.test(T.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,f,X,T&&T.response),{cause:T.cause||T}):y.from(T,T&&T.code,f,X,T&&T.response)}}},Rn=new Map,Xe=e=>{let t=e&&e.env||{},{fetch:r,Request:n,Response:o}=t,i=[n,o,r],s=i.length,c=s,d,u,l=Rn;for(;c--;)d=i[c],u=l.get(d),u===void 0&&l.set(d,u=c?new Map:En(t)),l=u;return u},vs=Xe();var Ge={http:we,xhr:jt,fetch:{get:Xe}};a.forEach(Ge,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var Jt=e=>`- ${e}`,xn=e=>a.isFunction(e)||e===null||e===!1;function On(e,t){e=a.isArray(e)?e:[e];let{length:r}=e,n,o,i={};for(let s=0;s<r;s++){n=e[s];let c;if(o=n,!xn(n)&&(o=Ge[(c=String(n)).toLowerCase()],o===void 0))throw new y(`Unknown adapter '${c}'`);if(o&&(a.isFunction(o)||(o=o.get(t))))break;i[c||"#"+s]=o}if(!o){let s=Object.entries(i).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build")),c=r?s.length>1?`since :
|
|
4
|
+
`+s.map(Jt).join(`
|
|
5
|
+
`):" "+Jt(s[0]):"as no adapter specified";throw new y("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o}var xe={getAdapter:On,adapters:Ge};function Qe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new L(null,e)}function Oe(e){return Qe(e),e.headers=R.from(e.headers),e.data=re.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),xe.getAdapter(e.adapter||V.adapter,e)(e).then(function(n){return Qe(e),n.data=re.call(e,e.transformResponse,n),n.headers=R.from(n.headers),n},function(n){return ne(n)||(Qe(e),n&&n.response&&(n.response.data=re.call(e,e.transformResponse,n.response),n.response.headers=R.from(n.response.headers))),Promise.reject(n)})}var Ae="1.15.0";var Te={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Te[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var Vt={};Te.transitional=function(t,r,n){function o(i,s){return"[Axios v"+Ae+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,c)=>{if(t===!1)throw new y(o(s," has been removed"+(r?" in "+r:"")),y.ERR_DEPRECATED);return r&&!Vt[s]&&(Vt[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}};Te.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function An(e,t,r){if(typeof e!="object")throw new y("options must be an object",y.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],d=c===void 0||s(c,i,e);if(d!==!0)throw new y("option "+i+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new y("Unknown option "+i,y.ERR_BAD_OPTION)}}var ie={assertOptions:An,validators:Te};var F=ie.validators,K=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ie,response:new Ie}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;let i=(()=>{if(!o.stack)return"";let s=o.stack.indexOf(`
|
|
6
|
+
`);return s===-1?"":o.stack.slice(s+1)})();try{if(!n.stack)n.stack=i;else if(i){let s=i.indexOf(`
|
|
7
|
+
`),c=s===-1?-1:i.indexOf(`
|
|
8
|
+
`,s+1),d=c===-1?"":i.slice(c+1);String(n.stack).endsWith(d)||(n.stack+=`
|
|
9
|
+
`+i)}}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=D(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&ie.assertOptions(n,{silentJSONParsing:F.transitional(F.boolean),forcedJSONParsing:F.transitional(F.boolean),clarifyTimeoutError:F.transitional(F.boolean),legacyInterceptorReqResOrdering:F.transitional(F.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:ie.assertOptions(o,{encode:F.function,serialize:F.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),ie.assertOptions(r,{baseUrl:F.spelling("baseURL"),withXsrfToken:F.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=i&&a.merge(i.common,i[r.method]);i&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),r.headers=R.concat(s,i);let c=[],d=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;d=d&&h.synchronous;let p=r.transitional||J;p&&p.legacyInterceptorReqResOrdering?c.unshift(h.fulfilled,h.rejected):c.push(h.fulfilled,h.rejected)});let u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let l,m=0,w;if(!d){let f=[Oe.bind(this),void 0];for(f.unshift(...c),f.push(...u),w=f.length,l=Promise.resolve(r);m<w;)l=l.then(f[m++],f[m++]);return l}w=c.length;let x=r;for(;m<w;){let f=c[m++],h=c[m++];try{x=f(x)}catch(p){h.call(this,p);break}}try{l=Oe.call(this,x)}catch(f){return Promise.reject(f)}for(m=0,w=u.length;m<w;)l=l.then(u[m++],u[m++]);return l}getUri(t){t=D(this.defaults,t);let r=se(t.baseURL,t.url,t.allowAbsoluteUrls);return ee(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){K.prototype[t]=function(r,n){return this.request(D(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(D(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}K.prototype[t]=r(),K.prototype[t+"Form"]=r(!0)});var ae=K;var Ye=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(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 L(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)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(o){t=o}),cancel:t}}},$t=Ye;function Ze(e){return function(r){return e.apply(null,r)}}function et(e){return a.isObject(e)&&e.isAxiosError===!0}var tt={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(tt).forEach(([e,t])=>{tt[t]=e});var Wt=tt;function Kt(e){let t=new ae(e),r=G(ae.prototype.request,t);return a.extend(r,ae.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Kt(D(e,o))},r}var E=Kt(V);E.Axios=ae;E.CanceledError=L;E.CancelToken=$t;E.isCancel=ne;E.VERSION=Ae;E.toFormData=k;E.AxiosError=y;E.Cancel=E.CanceledError;E.all=function(t){return Promise.all(t)};E.spread=Ze;E.isAxiosError=et;E.mergeConfig=D;E.AxiosHeaders=R;E.formToJSON=e=>ge(a.isHTMLForm(e)?new FormData(e):e);E.getAdapter=xe.getAdapter;E.HttpStatusCode=Wt;E.default=E;var ce=E;var{Axios:Hi,AxiosError:Mi,CanceledError:vi,isCancel:zi,CancelToken:Ji,VERSION:Vi,all:$i,Cancel:Wi,isAxiosError:Ki,spread:Xi,toFormData:Gi,AxiosHeaders:Qi,HttpStatusCode:Yi,formToJSON:Zi,getAdapter:ea,mergeConfig:ta}=ce;var le=class{constructor({theme:t="light",captchaSize:r="normal",render_element_or_id:n="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.captchaSize=r,this.render_element_or_id=n,this.loadJsFile()}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="",r=Date.now()+15e3;for(;Date.now()<r;){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,size:this.captchaSize,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){return 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())}};function rt(e){window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"form_submission",enhanced_conversion_data:Object.fromEntries(Object.entries(e))})}var nt={config:{},name:null,endpoint:null,hapiformID:null,redirectTo:null,integrationScriptUrl:"",fileUpload:{filepond:null,el:null},onSuccess(e){},onFailed(e){},captchaId:null,recaptchaTheme:"light",recaptchaSize:"normal"};function Gt(e){document.addEventListener("alpine:init",()=>{for(let t of e)Fn(Object.assign({},nt,t))})}async function Tn(e){if(e.captchaId){let t=document.getElementById(e.captchaId);if(t)e.amCaptcha=new le({theme:e.recaptchaTheme,captchaSize:e.recaptchaSize,render_element_or_id:t}),e.widgetId=await e.amCaptcha.render();else throw"Can't find recaptcha rendering element. by id: "+e.captchaId}}function Qt(e){if(e.endpoint)return e.endpoint;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 Cn(e){console.log("\u{1F4E2} Form name: "+e.name);let t=Qt(e);if(typeof e.redirectTo!="function"&&e.redirectTo.length&&new URL(t).host==="hapiform.sg"&&console.log("\u{1F680} "+window.top.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 _n(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 Nn(e){window.top.location.hostname!=="localhost"&&window.top.location.hostname!=="127.0.0.1"&&ce(e).then(t=>{}).catch(t=>{console.error(t)})}function Xt(e,t){ce(e).then(r=>{if(t.integrationScriptUrl.length>0){let o=Object.assign({},e);o.url=t.integrationScriptUrl,Nn(o)}let n=Alpine.store(t.name).fields||{};rt(n),t.redirectTo&&(window.top.location.href=t.redirectTo),t.fileUpload.filepond&&t.fileUpload.filepond.removeFiles(),Un(),t.resetFields(),t.onSuccess(r),Ln()}).catch(r=>{t.errors=r.response.data.errors,t.busy=!1,t.onFailed(r.response),In(),t.captchaId&&t.amCaptcha.reset(t.widgetId)})}async function Fn(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(),Tn(this).catch(t=>console.error(t)),Cn(this)},async submit(){this.busy=!0,this.errors={};let t=new FormData,r=Alpine.store(this.name).fields;if(Object.keys(r).forEach((d,u)=>{typeof r[d]=="object"?r[d].forEach((l,m)=>{t.append(`${d}[${m}]`,l)}):t.append(d,r[d])}),e.fileUpload.filepond)e.fileUpload.filepond.getFiles().forEach((d,u)=>{t.append(`files[${u}]`,d.file,d.name)});else if(e.fileUpload.el){let u=document.querySelector(e.fileUpload.el).files;for(let l=0;l<u.length;l++)t.append(`files[${l}]`,u[l],u[l].name)}let o=new URL(window.top.location.href);t.append("x_origin",o.origin+o.pathname);let i=Qt(e),s={method:"POST",url:Bn(i),data:t},c=Object.assign({},s,e.config);this.captchaId?await _n(this).then(()=>{Xt(c,this)}).catch(d=>{this.errors=d,e.onFailed(d),this.busy=!1}).finally(()=>{}):Xt(c,this)},resetFields(){this.errors={},Alpine.store(this.name).fields={},this.busy=!1,this.captchaId&&this.amCaptcha.reset(this.widgetId)}}))}function Un(){Pn(),Dn()}function Pn(){try{nt.fileUpload.filepond.removeFiles()}catch{}}function Dn(){try{let e=document.querySelector(nt.fileUpload.el);e.value=""}catch{}}function Ln(){Yt("hapi:success")}function In(){Yt("hapi:error")}function Yt(e){let t=new Event(e);document.dispatchEvent(t)}function Bn(e){let t=new URL(e);return(window.top.location.hostname==="localhost"||window.top.location.hostname==="127.0.0.1")&&(t.searchParams.set("test","1"),console.log("testing mode!")),t.href}function ot(){let e="https://unpkg.com/alpinejs";if(document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,t.type="text/javascript",t.defer=!0,(document.body??document.documentElement).appendChild(t)}ot();return or(kn);})();
|
package/package.json
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"hapi",
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
"name": "hapi-recaptcha-html",
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "hapiform html js library with google recaptcha",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"hapi",
|
|
8
|
+
"hapiform"
|
|
9
|
+
],
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "chenghuichao"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/hapi.min.js",
|
|
14
|
+
"unpkg": "./dist/hapi.min.js",
|
|
15
|
+
"jsdelivr": "./dist/hapi.min.js",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"default": "./dist/hapi.min.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "esbuild src/index.js --bundle --minify --format=iife --global-name=Hapi --outfile=./dist/hapi.min.js",
|
|
27
|
+
"watch": "esbuild src/index.js --watch --bundle --minify --format=iife --global-name=Hapi --outfile=./dist/hapi.min.js"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"axios": "~1.15.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"esbuild": "~0.28.0"
|
|
34
|
+
}
|
|
24
35
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Hapi.forms([
|
|
2
|
-
// form 01
|
|
3
|
-
{
|
|
4
|
-
name: 'form01',
|
|
5
|
-
hapiformID: '5867eae1-c53d-4734-a50c-abd350eb79d9',
|
|
6
|
-
redirectTo: 'contactus-success.html',
|
|
7
|
-
captchaId: 'captcha-01',
|
|
8
|
-
integrationScriptUrl: "", // optional, POST current DataForm/Json to external URL (API).
|
|
9
|
-
},
|
|
10
|
-
// form 02
|
|
11
|
-
{
|
|
12
|
-
name: 'form02',
|
|
13
|
-
hapiformID: '5867eae1-c53d-4734-a50c-abd350eb79d9',
|
|
14
|
-
redirectTo: 'contactus-success.html',
|
|
15
|
-
captchaId: 'captcha-02',
|
|
16
|
-
integrationScriptUrl: "", // optional, POST current DataForm/Json to external URL (API).
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
);
|
package/demo/index.html
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport"
|
|
6
|
-
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
|
7
|
-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
8
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
|
|
9
|
-
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
|
10
|
-
<title>Demo Forms</title>
|
|
11
|
-
<style>
|
|
12
|
-
h1 {
|
|
13
|
-
font-size: 20px;
|
|
14
|
-
text-align: center;
|
|
15
|
-
margin: 20px auto;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
form {
|
|
19
|
-
width: 100%;
|
|
20
|
-
max-width: 550px;
|
|
21
|
-
margin: 10px auto;
|
|
22
|
-
border: 1px solid #dedede;
|
|
23
|
-
border-radius: 5px;
|
|
24
|
-
padding: 10px;
|
|
25
|
-
}
|
|
26
|
-
</style>
|
|
27
|
-
</head>
|
|
28
|
-
<body>
|
|
29
|
-
<div class="container">
|
|
30
|
-
<h1>Demo Forms</h1>
|
|
31
|
-
|
|
32
|
-
<div class="d-lg-flex">
|
|
33
|
-
|
|
34
|
-
<form x-on:submit.prevent="submit" x-data="form01">
|
|
35
|
-
|
|
36
|
-
<template x-if="errors">
|
|
37
|
-
<div x-html="JSON.stringify(errors)" class="text-danger"></div>
|
|
38
|
-
</template>
|
|
39
|
-
|
|
40
|
-
<div x-text='JSON.stringify($store.form01.fields,null,2)' class="text-success"></div>
|
|
41
|
-
<div>
|
|
42
|
-
<div class="mb-3">
|
|
43
|
-
<div class="form-field">
|
|
44
|
-
<label for="form01-name" class="form-label">Name</label>
|
|
45
|
-
<input type="text" id="form01-name" x-model="$store.form01.fields.name" placeholder="Name" class="form-control">
|
|
46
|
-
|
|
47
|
-
</div>
|
|
48
|
-
<template x-if="errors && errors.name">
|
|
49
|
-
<div x-text="errors.name" class="text-danger"></div>
|
|
50
|
-
</template>
|
|
51
|
-
<div x-text="$store.form01.fields.name"></div>
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<div class="mb-3">
|
|
55
|
-
<div class="form-field">
|
|
56
|
-
<label for="form01-message" class="form-label">Message</label>
|
|
57
|
-
<textarea id="form01-message" x-model="$store.form01.fields.message" rows="4" placeholder="Message"
|
|
58
|
-
class="form-control form-textarea"></textarea>
|
|
59
|
-
</div>
|
|
60
|
-
<template x-if="errors && errors.message">
|
|
61
|
-
<div x-text="errors.message" class="text-danger"></div>
|
|
62
|
-
</template>
|
|
63
|
-
</div>
|
|
64
|
-
<div class="mb-3">
|
|
65
|
-
<div id="captcha-01"></div>
|
|
66
|
-
<template x-if="errors && errors.recaptchaError">
|
|
67
|
-
<div x-text="errors.recaptchaError" class="text-danger"></div>
|
|
68
|
-
</template>
|
|
69
|
-
</div>
|
|
70
|
-
<div class="mb-3">
|
|
71
|
-
<button type="submit" class="btn btn-primary">
|
|
72
|
-
Submit Form 1 <img x-show="busy" src="loading.svg">
|
|
73
|
-
</button>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
</form>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<form x-on:submit.prevent="submit" x-data="form02">
|
|
80
|
-
|
|
81
|
-
<template x-if="errors">
|
|
82
|
-
<div x-text="JSON.stringify(errors)" class="text-danger"></div>
|
|
83
|
-
</template>
|
|
84
|
-
|
|
85
|
-
<div x-text='JSON.stringify($store.form02.fields,null,2)' class="text-success"></div>
|
|
86
|
-
<div>
|
|
87
|
-
<div class="mb-3">
|
|
88
|
-
<div class="form-field">
|
|
89
|
-
<label for="form02-name" class="form-label">Name</label>
|
|
90
|
-
<input type="text" id="form02-name" x-model="$store.form02.fields.name" placeholder="Name" class="form-control">
|
|
91
|
-
</div>
|
|
92
|
-
<template x-if="errors && errors.name">
|
|
93
|
-
<div x-text="errors.name" class="text-danger"></div>
|
|
94
|
-
</template>
|
|
95
|
-
<div x-text="$store.form02.fields.name"></div>
|
|
96
|
-
</div>
|
|
97
|
-
<div class="mb-3">
|
|
98
|
-
<div class="form-field">
|
|
99
|
-
<label for="form02-message" class="form-label">Message</label>
|
|
100
|
-
<textarea id="form02-message" x-model="$store.form02.fields.message" rows="4" placeholder="Message"
|
|
101
|
-
class="form-control form-textarea"></textarea>
|
|
102
|
-
</div>
|
|
103
|
-
<template x-if="errors && errors.message">
|
|
104
|
-
<div x-text="errors.message" class="text-danger"></div>
|
|
105
|
-
</template>
|
|
106
|
-
</div>
|
|
107
|
-
<div class="mb-3">
|
|
108
|
-
<div id="captcha-02"></div>
|
|
109
|
-
<template x-if="errors && errors.recaptchaError">
|
|
110
|
-
<div x-text="errors.recaptchaError" class="text-danger"></div>
|
|
111
|
-
</template>
|
|
112
|
-
</div>
|
|
113
|
-
<div class="mb-3">
|
|
114
|
-
<button type="submit" class="btn btn-success">
|
|
115
|
-
Submit Form 2 <img x-show="busy" src="loading.svg">
|
|
116
|
-
</button>
|
|
117
|
-
</div>
|
|
118
|
-
</div>
|
|
119
|
-
</form>
|
|
120
|
-
|
|
121
|
-
</div>
|
|
122
|
-
<!-- <script src="https://unpkg.com/hapi-recaptcha-html@latest/dist/hapi.min.js" defer></script>-->
|
|
123
|
-
|
|
124
|
-
<script src="../dist/hapi.min.js" defer></script>
|
|
125
|
-
<script src="enquiry-forms.js" defer></script>
|
|
126
|
-
</div>
|
|
127
|
-
</body>
|
|
128
|
-
</html>
|
package/demo/loading.svg
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<svg viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<defs>
|
|
3
|
-
<linearGradient x1="8.042%" y1="0%" x2="65.682%" y2="23.865%" id="a">
|
|
4
|
-
<stop stop-color="#fff" stop-opacity="0" offset="0%"/>
|
|
5
|
-
<stop stop-color="#fff" stop-opacity=".631" offset="63.146%"/>
|
|
6
|
-
<stop stop-color="#fff" offset="100%"/>
|
|
7
|
-
</linearGradient>
|
|
8
|
-
</defs>
|
|
9
|
-
<g fill="none" fill-rule="evenodd">
|
|
10
|
-
<g transform="translate(1 1)">
|
|
11
|
-
<path d="M36 18c0-9.94-8.06-18-18-18" id="Oval-2" stroke="url(#a)" stroke-width="2">
|
|
12
|
-
<animateTransform
|
|
13
|
-
attributeName="transform"
|
|
14
|
-
type="rotate"
|
|
15
|
-
from="0 18 18"
|
|
16
|
-
to="360 18 18"
|
|
17
|
-
dur="0.9s"
|
|
18
|
-
repeatCount="indefinite"/>
|
|
19
|
-
</path>
|
|
20
|
-
<circle fill="#fff" cx="36" cy="18" r="1">
|
|
21
|
-
<animateTransform
|
|
22
|
-
attributeName="transform"
|
|
23
|
-
type="rotate"
|
|
24
|
-
from="0 18 18"
|
|
25
|
-
to="360 18 18"
|
|
26
|
-
dur="0.9s"
|
|
27
|
-
repeatCount="indefinite"/>
|
|
28
|
-
</circle>
|
|
29
|
-
</g>
|
|
30
|
-
</g>
|
|
31
|
-
</svg>
|
package/index.js
DELETED
package/src/alpineloader.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default function loadAlpineJsFile() {
|
|
2
|
-
// global js file, load one time
|
|
3
|
-
if (document.querySelectorAll(`script[src="//unpkg.com/alpinejs"]`).length === 0) {
|
|
4
|
-
var scriptEl = document.createElement('script');
|
|
5
|
-
scriptEl.setAttribute("src", "//unpkg.com/alpinejs");
|
|
6
|
-
scriptEl.setAttribute("type", "text/javascript");
|
|
7
|
-
scriptEl.setAttribute("defer", true);
|
|
8
|
-
document.body.appendChild(scriptEl);
|
|
9
|
-
}
|
|
10
|
-
}
|
package/src/hapi.js
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import axios from "axios";
|
|
4
|
-
import AMCaptcha from './recaptcha';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let hapiOptions = {
|
|
8
|
-
config: {},
|
|
9
|
-
name: null,
|
|
10
|
-
endpoint: null,
|
|
11
|
-
hapiformID: null,
|
|
12
|
-
redirectTo: null,
|
|
13
|
-
integrationScriptUrl: '',
|
|
14
|
-
fileUpload: {
|
|
15
|
-
filepond: null,
|
|
16
|
-
el: null,
|
|
17
|
-
},
|
|
18
|
-
onSuccess(res) {
|
|
19
|
-
res;
|
|
20
|
-
},
|
|
21
|
-
onFailed(res) {
|
|
22
|
-
res;
|
|
23
|
-
},
|
|
24
|
-
captchaId: null,
|
|
25
|
-
recaptchaTheme: 'light', // light, dark
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
function forms(formsOption) {
|
|
29
|
-
document.addEventListener("alpine:init", () => {
|
|
30
|
-
for (const options of formsOption) {
|
|
31
|
-
let mergedOptions = Object.assign({}, hapiOptions, options);
|
|
32
|
-
document.addEventListener("alpine:init", alpineInitData(mergedOptions));
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async function renderCaptcha(a) {
|
|
38
|
-
if (a.captchaId) {
|
|
39
|
-
// find the rending element
|
|
40
|
-
let recaptcha_el = document.getElementById(a.captchaId);
|
|
41
|
-
if (recaptcha_el) {
|
|
42
|
-
a.amCaptcha = new AMCaptcha({
|
|
43
|
-
theme: this.recaptchaTheme,
|
|
44
|
-
render_element_or_id: recaptcha_el
|
|
45
|
-
});
|
|
46
|
-
a.widgetId = await a.amCaptcha.render();
|
|
47
|
-
|
|
48
|
-
} else {
|
|
49
|
-
// console.error( "Can't find recaptcha rendering element. by id: " + a.captchaId);
|
|
50
|
-
throw "Can't find recaptcha rendering element. by id: " + this.captchaId;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function orgEndpoint(a) {
|
|
56
|
-
if (a.endpoint) {
|
|
57
|
-
return a.endpoint;
|
|
58
|
-
} else {
|
|
59
|
-
if (a.hapiformID.length === 0) {
|
|
60
|
-
console.error("No hapiform ID provided!");
|
|
61
|
-
throw new Error("No hapiform ID provided!");
|
|
62
|
-
}
|
|
63
|
-
return `https://hapiform.sg/api/${a.hapiformID}`;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function displayHapiformInformation(a) {
|
|
68
|
-
console.log("📢 Form name: " + a.name);
|
|
69
|
-
let org_endpoint = orgEndpoint(a);
|
|
70
|
-
// Display redirect path
|
|
71
|
-
if (typeof a.redirectTo !== "function" && a.redirectTo.length) {
|
|
72
|
-
let endpoint = new URL(org_endpoint);
|
|
73
|
-
|
|
74
|
-
if (endpoint.host === "hapiform.sg") {
|
|
75
|
-
console.log("🚀 " + window.top.location.origin + a.redirectTo);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Display the endpoint
|
|
80
|
-
if (org_endpoint) {
|
|
81
|
-
let endpoint = new URL(org_endpoint);
|
|
82
|
-
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}/);
|
|
83
|
-
|
|
84
|
-
if (endpoint.host === "hapiform.sg") {
|
|
85
|
-
console.log(`🚀 ${endpoint.origin}/${uuid}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async function verifyCaptcha(a) {
|
|
91
|
-
// 1. get response of recaptcha
|
|
92
|
-
const token = a.amCaptcha.fetchResponse(a.widgetId);
|
|
93
|
-
if (token.length === 0) {
|
|
94
|
-
throw {recaptchaError: "You can't leave Captcha Code empty"};
|
|
95
|
-
}
|
|
96
|
-
// 2. verify recaptcha
|
|
97
|
-
return await a.amCaptcha.verifyRecaptcha(token)
|
|
98
|
-
.then((data) => {
|
|
99
|
-
if (data.success === false) {
|
|
100
|
-
throw {recaptchaError: "captcha invalid: timeout or duplicate."};
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function integrationWebhook(config) {
|
|
106
|
-
if (window.top.location.hostname !== "localhost" && window.top.location.hostname !== "127.0.0.1") {
|
|
107
|
-
axios(config).then((res) => {
|
|
108
|
-
}).catch((e) => {
|
|
109
|
-
console.error(e)
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function onSubmission(config, a) {
|
|
115
|
-
axios(config)
|
|
116
|
-
.then((res) => {
|
|
117
|
-
// on success webhook begin
|
|
118
|
-
if (a.integrationScriptUrl.length > 0) {
|
|
119
|
-
let integration_config = Object.assign({}, config);
|
|
120
|
-
integration_config.url = a.integrationScriptUrl;
|
|
121
|
-
integrationWebhook(integration_config);
|
|
122
|
-
}
|
|
123
|
-
// on success webhook end
|
|
124
|
-
|
|
125
|
-
if (a.redirectTo) {
|
|
126
|
-
window.top.location.href = a.redirectTo;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Remove files from filepond
|
|
130
|
-
if (a.fileUpload.filepond) {
|
|
131
|
-
a.fileUpload.filepond.removeFiles();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
clearFiles();
|
|
135
|
-
a.resetFields();
|
|
136
|
-
a.onSuccess(res);
|
|
137
|
-
successEvent();
|
|
138
|
-
})
|
|
139
|
-
.catch((err) => {
|
|
140
|
-
a.errors = err.response.data.errors;
|
|
141
|
-
a.busy = false;
|
|
142
|
-
a.onFailed(err.response);
|
|
143
|
-
errorEvent();
|
|
144
|
-
if (a.captchaId) a.amCaptcha.reset(a.widgetId);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async function alpineInitData(options) {
|
|
149
|
-
Alpine.data(options.name, () => ({
|
|
150
|
-
...options,
|
|
151
|
-
errors: {},
|
|
152
|
-
busy: false,
|
|
153
|
-
amCaptcha: null,
|
|
154
|
-
widgetId: null,
|
|
155
|
-
async init() {
|
|
156
|
-
|
|
157
|
-
// todo: remove special characters
|
|
158
|
-
Alpine.store(options.name, {fields: {}});
|
|
159
|
-
|
|
160
|
-
this.$watch("busy", (value) => {
|
|
161
|
-
let buttons = this.$el.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');
|
|
162
|
-
|
|
163
|
-
if (value) {
|
|
164
|
-
buttons.forEach((button) => {
|
|
165
|
-
button.disabled = true;
|
|
166
|
-
});
|
|
167
|
-
} else {
|
|
168
|
-
buttons.forEach((button) => {
|
|
169
|
-
button.disabled = false;
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
this.$init ? this.$init() : null;
|
|
175
|
-
|
|
176
|
-
renderCaptcha(this).catch((err) => console.error(err));
|
|
177
|
-
|
|
178
|
-
displayHapiformInformation(this);
|
|
179
|
-
|
|
180
|
-
},
|
|
181
|
-
async submit() {
|
|
182
|
-
// Set busy to true and reset error validations
|
|
183
|
-
this.busy = true;
|
|
184
|
-
this.errors = {};
|
|
185
|
-
|
|
186
|
-
// Get all form fields
|
|
187
|
-
let formData = new FormData();
|
|
188
|
-
|
|
189
|
-
let fieldsStore = Alpine.store(this.name).fields;
|
|
190
|
-
let fieldNames = Object.keys(fieldsStore);
|
|
191
|
-
|
|
192
|
-
// Append all fields to formData
|
|
193
|
-
fieldNames.forEach((field, i) => {
|
|
194
|
-
if (typeof fieldsStore[field] === "object") {
|
|
195
|
-
fieldsStore[field].forEach((item, index) => {
|
|
196
|
-
formData.append(`${field}[${index}]`, item);
|
|
197
|
-
});
|
|
198
|
-
} else {
|
|
199
|
-
formData.append(field, fieldsStore[field]);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// Check if filepond is enabled
|
|
204
|
-
if (options.fileUpload.filepond) {
|
|
205
|
-
options.fileUpload.filepond.getFiles().forEach((file, i) => {
|
|
206
|
-
formData.append(`files[${i}]`, file.file, file.name);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
// Check if normal file upload is enabled
|
|
210
|
-
else if (options.fileUpload.el) {
|
|
211
|
-
let inputElement = document.querySelector(options.fileUpload.el);
|
|
212
|
-
|
|
213
|
-
let fileList = inputElement.files;
|
|
214
|
-
|
|
215
|
-
for (let i = 0; i < fileList.length; i++) {
|
|
216
|
-
formData.append(`files[${i}]`, fileList[i], fileList[i].name);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Append x_origin to formData
|
|
221
|
-
let currentUrl = new URL(window.top.location.href);
|
|
222
|
-
|
|
223
|
-
formData.append("x_origin", currentUrl.origin + currentUrl.pathname);
|
|
224
|
-
let org_endpoint = orgEndpoint(options);
|
|
225
|
-
const defaultConfig = {
|
|
226
|
-
method: "POST",
|
|
227
|
-
url: getEndpoint(org_endpoint),
|
|
228
|
-
data: formData,
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
const config = Object.assign({}, defaultConfig, options.config);
|
|
232
|
-
|
|
233
|
-
if (this.captchaId) { // with captcha
|
|
234
|
-
await verifyCaptcha(this)
|
|
235
|
-
.then(() => {
|
|
236
|
-
// do submission
|
|
237
|
-
onSubmission(config, this);
|
|
238
|
-
})
|
|
239
|
-
.catch((error) => {
|
|
240
|
-
this.errors = error;
|
|
241
|
-
// failed method
|
|
242
|
-
options.onFailed(error);
|
|
243
|
-
this.busy = false;
|
|
244
|
-
})
|
|
245
|
-
.finally(() => {
|
|
246
|
-
// this.amCaptcha.reset(this.widgetId);
|
|
247
|
-
});
|
|
248
|
-
} else { // without captcha
|
|
249
|
-
onSubmission(config, this);
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
resetFields() {
|
|
253
|
-
this.errors = {};
|
|
254
|
-
// this.fields = options.fields;
|
|
255
|
-
Alpine.store(this.name).fields = {};
|
|
256
|
-
this.busy = false;
|
|
257
|
-
if (this.captchaId) this.amCaptcha.reset(this.widgetId);
|
|
258
|
-
},
|
|
259
|
-
}));
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
function clearFiles() {
|
|
264
|
-
clearFilepondFiles();
|
|
265
|
-
clearUploads();
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function clearFilepondFiles() {
|
|
269
|
-
try {
|
|
270
|
-
hapiOptions.fileUpload.filepond.removeFiles();
|
|
271
|
-
} catch (e) {
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function clearUploads() {
|
|
276
|
-
try {
|
|
277
|
-
let inputElement = document.querySelector(hapiOptions.fileUpload.el);
|
|
278
|
-
inputElement.value = "";
|
|
279
|
-
} catch (e) {
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function successEvent() {
|
|
284
|
-
dispatchEvent("hapi:success");
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function errorEvent() {
|
|
288
|
-
dispatchEvent("hapi:error");
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function dispatchEvent(eventName) {
|
|
292
|
-
const event = new Event(eventName);
|
|
293
|
-
|
|
294
|
-
document.dispatchEvent(event);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function getEndpoint(endpoint) {
|
|
298
|
-
let url = new URL(endpoint);
|
|
299
|
-
|
|
300
|
-
if (window.top.location.hostname === "localhost" || window.top.location.hostname === "127.0.0.1") {
|
|
301
|
-
url.searchParams.set("test", '1');
|
|
302
|
-
console.log('testing mode!')
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return url.href;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export {forms};
|
package/src/recaptcha.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
export default class AMCaptcha {
|
|
2
|
-
constructor({theme = 'light', render_element_or_id = 'recaptcha-el'}) {
|
|
3
|
-
//
|
|
4
|
-
this.gl_api_url = "https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit";
|
|
5
|
-
this.captcha_sitekey = "6LeRUzsjAAAAANUHNEY6VkUXmMo_wlrDK5SUoFUV";
|
|
6
|
-
this.verify_url = "https://internalapi.activamedia.com.sg/v1/recaptcha/verify";
|
|
7
|
-
this.theme = theme;
|
|
8
|
-
this.render_element_or_id = render_element_or_id;
|
|
9
|
-
|
|
10
|
-
this.defineOnloadCallBack();
|
|
11
|
-
this.loadJsFile();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
defineOnloadCallBack() {
|
|
15
|
-
window.onloadCallback = () => {
|
|
16
|
-
// console.log('api loaded');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* insert and load the google api js file
|
|
22
|
-
*/
|
|
23
|
-
loadJsFile() {
|
|
24
|
-
// global js file, load one time
|
|
25
|
-
if (document.querySelectorAll(`script[src="${this.gl_api_url}"]`).length === 0) {
|
|
26
|
-
var scriptEl = document.createElement('script');
|
|
27
|
-
scriptEl.setAttribute("src", this.gl_api_url);
|
|
28
|
-
scriptEl.setAttribute("type", "text/javascript");
|
|
29
|
-
scriptEl.setAttribute("async", true);
|
|
30
|
-
scriptEl.setAttribute("defer", true);
|
|
31
|
-
document.body.appendChild(scriptEl);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
sleep(ms) {
|
|
36
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* rendering google captcha
|
|
41
|
-
*/
|
|
42
|
-
async render() {
|
|
43
|
-
let widgetId = '';
|
|
44
|
-
while (true) {
|
|
45
|
-
await this.sleep(200);
|
|
46
|
-
if (typeof grecaptcha !== 'undefined' && grecaptcha !== undefined
|
|
47
|
-
&& typeof grecaptcha.render === "function") {
|
|
48
|
-
widgetId = grecaptcha.render(
|
|
49
|
-
this.render_element_or_id,
|
|
50
|
-
{
|
|
51
|
-
sitekey: this.captcha_sitekey,
|
|
52
|
-
theme: this.theme
|
|
53
|
-
});
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
console.info("checking grecaptcha undefined");
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return widgetId
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* reset google captcha
|
|
64
|
-
*/
|
|
65
|
-
reset(widgetId) {
|
|
66
|
-
grecaptcha.reset(widgetId);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
fetchResponse(widgetId) {
|
|
70
|
-
try {
|
|
71
|
-
return grecaptcha.getResponse(widgetId);
|
|
72
|
-
} catch (e) {console.error(e);}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async verifyRecaptcha(token) {
|
|
76
|
-
return await fetch(this.verify_url, {
|
|
77
|
-
method: 'post', body: JSON.stringify({"token": token}),
|
|
78
|
-
headers: {'Accept': 'application/json', 'Content-Type': 'application/json'},
|
|
79
|
-
}).then((response) => response.json());
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|