hapi-recaptcha-html 1.0.4 → 1.0.6
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/dist/hapi.min.js +1 -1
- package/package.json +1 -1
- package/src/hapi.js +4 -4
package/dist/hapi.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
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
2
|
`).forEach(function(s){o=s.indexOf(":"),r=s.substring(0,o).trim().toLowerCase(),n=s.substring(o+1).trim(),!(!r||t[r]&&nr[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var We=Symbol("internals");function H(e){return e&&String(e).trim().toLowerCase()}function re(e){return e===!1||e==null?e:a.isArray(e)?e.map(re):String(e)}function or(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var ir=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function me(e,t,r,n,o){if(a.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!a.isString(t)){if(a.isString(n))return t.indexOf(n)!==-1;if(a.isRegExp(n))return n.test(t)}}function sr(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function ar(e,t){let r=a.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,i,s){return this[n].call(this,t,o,i,s)},configurable:!0})})}var D=class{constructor(t){t&&this.set(t)}set(t,r,n){let o=this;function i(l,f,c){let u=H(f);if(!u)throw new Error("header name must be a non-empty string");let p=a.findKey(o,u);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||f]=re(l))}let s=(l,f)=>a.forEach(l,(c,u)=>i(c,u,f));return a.isPlainObject(t)||t instanceof this.constructor?s(t,r):a.isString(t)&&(t=t.trim())&&!ir(t)?s($e(t),r):t!=null&&i(r,t,n),this}get(t,r){if(t=H(t),t){let n=a.findKey(this,t);if(n){let o=this[n];if(!r)return o;if(r===!0)return or(o);if(a.isFunction(r))return r.call(this,o,n);if(a.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=H(t),t){let n=a.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||me(this,this[n],n,r)))}return!1}delete(t,r){let n=this,o=!1;function i(s){if(s=H(s),s){let l=a.findKey(n,s);l&&(!r||me(n,n[l],l,r))&&(delete n[l],o=!0)}}return a.isArray(t)?t.forEach(i):i(t),o}clear(t){let r=Object.keys(this),n=r.length,o=!1;for(;n--;){let i=r[n];(!t||me(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){let r=this,n={};return a.forEach(this,(o,i)=>{let s=a.findKey(n,i);if(s){r[s]=re(o),delete r[i];return}let l=t?sr(i):String(i).trim();l!==i&&delete r[i],r[l]=re(o),n[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return a.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&a.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
3
|
-
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){let n=(this[We]=this[We]={accessors:{}}).accessors,o=this.prototype;function i(s){let l=H(s);n[l]||(ar(o,s),n[l]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.freezeMethods(D.prototype);a.freezeMethods(D);var S=D;function q(e,t){let r=this||_,n=t||r,o=S.from(n.headers),i=n.data;return a.forEach(e,function(l){i=l.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function M(e){return!!(e&&e.__CANCEL__)}function Ke(e,t,r){m.call(this,e??"canceled",m.ERR_CANCELED,t,r),this.name="CanceledError"}a.inherits(Ke,m,{__CANCEL__:!0});var C=Ke;function he(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new m("Request failed with status code "+r.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}var Ge=b.isStandardBrowserEnv?function(){return{write:function(r,n,o,i,s,l){let f=[];f.push(r+"="+encodeURIComponent(n)),a.isNumber(o)&&f.push("expires="+new Date(o).toGMTString()),a.isString(i)&&f.push("path="+i),a.isString(s)&&f.push("domain="+s),l===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(r){let n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function ye(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function we(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function J(e,t){return e&&!ye(t)?we(e,t):t}var Xe=b.isStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function o(i){let s=i;return t&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=o(window.location.href),function(s){let l=a.isString(s)?o(s):s;return l.protocol===n.protocol&&l.host===n.host}}():function(){return function(){return!0}}();function Ee(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function cr(e,t){e=e||10;let r=new Array(e),n=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(f){let c=Date.now(),u=n[i];s||(s=c),r[o]=f,n[o]=c;let p=i,E=0;for(;p!==o;)E+=r[p++],p=p%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-s<t)return;let y=u&&c-u;return y?Math.round(E*1e3/y):void 0}}var Ye=cr;function Qe(e,t){let r=0,n=Ye(50,250);return o=>{let i=o.loaded,s=o.lengthComputable?o.total:void 0,l=i-r,f=n(l),c=i<=s;r=i;let u={loaded:i,total:s,progress:s?i/s:void 0,bytes:l,rate:f||void 0,estimated:f&&s&&c?(s-i)/f:void 0,event:o};u[t?"download":"upload"]=!0,e(u)}}var lr=typeof XMLHttpRequest<"u",Ze=lr&&function(e){return new Promise(function(r,n){let o=e.data,i=S.from(e.headers).normalize(),s=e.responseType,l;function f(){e.cancelToken&&e.cancelToken.unsubscribe(l),e.signal&&e.signal.removeEventListener("abort",l)}a.isFormData(o)&&(b.isStandardBrowserEnv||b.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){let y=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(y+":"+d))}let u=J(e.baseURL,e.url);c.open(e.method.toUpperCase(),I(u,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function p(){if(!c)return;let y=S.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),h={data:!s||s==="text"||s==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:y,config:e,request:c};he(function(g){r(g),f()},function(g){n(g),f()},h),c=null}if("onloadend"in c?c.onloadend=p:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(p)},c.onabort=function(){c&&(n(new m("Request aborted",m.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new m("Network Error",m.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let d=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",h=e.transitional||Z;e.timeoutErrorMessage&&(d=e.timeoutErrorMessage),n(new m(d,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,c)),c=null},b.isStandardBrowserEnv){let y=(e.withCredentials||Xe(u))&&e.xsrfCookieName&&Ge.read(e.xsrfCookieName);y&&i.set(e.xsrfHeaderName,y)}o===void 0&&i.setContentType(null),"setRequestHeader"in c&&a.forEach(i.toJSON(),function(d,h){c.setRequestHeader(h,d)}),a.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),s&&s!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",Qe(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",Qe(e.onUploadProgress)),(e.cancelToken||e.signal)&&(l=y=>{c&&(n(!y||y.type?new C(null,e,c):y),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(l),e.signal&&(e.signal.aborted?l():e.signal.addEventListener("abort",l)));let E=Ee(u);if(E&&b.protocols.indexOf(E)===-1){n(new m("Unsupported protocol "+E+":",m.ERR_BAD_REQUEST,e));return}c.send(o||null)})};var ne={http:Y,xhr:Ze};a.forEach(ne,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var et={getAdapter:e=>{e=a.isArray(e)?e:[e];let{length:t}=e,r,n;for(let o=0;o<t&&(r=e[o],!(n=a.isString(r)?ne[r.toLowerCase()]:r));o++);if(!n)throw n===!1?new m(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(a.hasOwnProp(ne,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!a.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:ne};function be(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new C(null,e)}function oe(e){return be(e),e.headers=S.from(e.headers),e.data=q.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),et.getAdapter(e.adapter||_.adapter)(e).then(function(n){return be(e),n.data=q.call(e,e.transformResponse,n),n.headers=S.from(n.headers),n},function(n){return M(n)||(be(e),n&&n.response&&(n.response.data=q.call(e,e.transformResponse,n.response),n.response.headers=S.from(n.response.headers))),Promise.reject(n)})}var tt=e=>e instanceof S?e.toJSON():e;function O(e,t){t=t||{};let r={};function n(c,u,p){return a.isPlainObject(c)&&a.isPlainObject(u)?a.merge.call({caseless:p},c,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function o(c,u,p){if(a.isUndefined(u)){if(!a.isUndefined(c))return n(void 0,c,p)}else return n(c,u,p)}function i(c,u){if(!a.isUndefined(u))return n(void 0,u)}function s(c,u){if(a.isUndefined(u)){if(!a.isUndefined(c))return n(void 0,c)}else return n(void 0,u)}function l(c,u,p){if(p in t)return n(c,u);if(p in e)return n(void 0,c)}let f={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l,headers:(c,u)=>o(tt(c),tt(u),!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(u){let p=f[u]||o,E=p(e[u],t[u],u);a.isUndefined(E)&&p!==l||(r[u]=E)}),r}var ie="1.4.0";var Se={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Se[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var rt={};Se.transitional=function(t,r,n){function o(i,s){return"[Axios v"+ie+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,l)=>{if(t===!1)throw new m(o(s," has been removed"+(r?" in "+r:"")),m.ERR_DEPRECATED);return r&&!rt[s]&&(rt[s]=!0,console.warn(o(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,s,l):!0}};function ur(e,t,r){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),o=n.length;for(;o-- >0;){let i=n[o],s=t[i];if(s){let l=e[i],f=l===void 0||s(l,i,e);if(f!==!0)throw new m("option "+i+" must be "+f,m.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}}var se={assertOptions:ur,validators:Se};var N=se.validators,L=class{constructor(t){this.defaults=t,this.interceptors={request:new de,response:new de}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=O(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&se.assertOptions(n,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:se.assertOptions(o,{encode:N.function,serialize:N.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s;s=i&&a.merge(i.common,i[r.method]),s&&a.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),r.headers=S.concat(s,i);let l=[],f=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(f=f&&h.synchronous,l.unshift(h.fulfilled,h.rejected))});let c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let u,p=0,E;if(!f){let d=[oe.bind(this),void 0];for(d.unshift.apply(d,l),d.push.apply(d,c),E=d.length,u=Promise.resolve(r);p<E;)u=u.then(d[p++],d[p++]);return u}E=l.length;let y=r;for(p=0;p<E;){let d=l[p++],h=l[p++];try{y=d(y)}catch(R){h.call(this,R);break}}try{u=oe.call(this,y)}catch(d){return Promise.reject(d)}for(p=0,E=c.length;p<E;)u=u.then(c[p++],c[p++]);return u}getUri(t){t=O(this.defaults,t);let r=J(t.baseURL,t.url);return I(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){L.prototype[t]=function(r,n){return this.request(O(n||{},{method:t,url:r,data:(n||{}).data}))}});a.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,l){return this.request(O(l||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}L.prototype[t]=r(),L.prototype[t+"Form"]=r(!0)});var z=L;var Ae=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(l=>{n.subscribe(l),i=l}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},t(function(i,s,l){n.reason||(n.reason=new C(i,s,l),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new e(function(o){t=o}),cancel:t}}},nt=Ae;function ge(e){return function(r){return e.apply(null,r)}}function xe(e){return a.isObject(e)&&e.isAxiosError===!0}var Re={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Re).forEach(([e,t])=>{Re[t]=e});var ot=Re;function it(e){let t=new z(e),r=B(z.prototype.request,t);return a.extend(r,z.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return it(O(e,o))},r}var w=it(_);w.Axios=z;w.CanceledError=C;w.CancelToken=nt;w.isCancel=M;w.VERSION=ie;w.toFormData=T;w.AxiosError=m;w.Cancel=w.CanceledError;w.all=function(t){return Promise.all(t)};w.spread=ge;w.isAxiosError=xe;w.mergeConfig=O;w.AxiosHeaders=S;w.formToJSON=e=>ee(a.isHTMLForm(e)?new FormData(e):e);w.HttpStatusCode=ot;w.default=w;var v=w;var{Axios:Qo,AxiosError:Zo,CanceledError:ei,isCancel:ti,CancelToken:ri,VERSION:ni,all:oi,Cancel:ii,isAxiosError:si,spread:ai,toFormData:ci,AxiosHeaders:li,HttpStatusCode:ui,formToJSON:fi,mergeConfig:di}=v;var V=class{constructor({theme:t="light",render_element_or_id:r="recaptcha-el"}){this.gl_api_url="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit",this.captcha_sitekey="6LeRUzsjAAAAANUHNEY6VkUXmMo_wlrDK5SUoFUV",this.verify_url="https://internalapi.activamedia.com.sg/v1/recaptcha/verify",this.theme=t,this.render_element_or_id=r,this.defineOnloadCallBack(),this.loadJsFile()}defineOnloadCallBack(){window.onloadCallback=()=>{}}loadJsFile(){if(document.querySelectorAll(`script[src="${this.gl_api_url}"]`).length===0){var t=document.createElement("script");t.setAttribute("src",this.gl_api_url),t.setAttribute("type","text/javascript"),t.setAttribute("async",!0),t.setAttribute("defer",!0),document.body.appendChild(t)}}sleep(t){return new Promise(r=>setTimeout(r,t))}async render(){let t="";for(;;){if(await this.sleep(200),typeof grecaptcha<"u"&&grecaptcha!==void 0&&typeof grecaptcha.render=="function"){t=grecaptcha.render(this.render_element_or_id,{sitekey:this.captcha_sitekey,theme:this.theme});break}console.info("checking grecaptcha undefined")}return t}reset(t){grecaptcha.reset(t)}fetchResponse(t){try{return grecaptcha.getResponse(t)}catch(r){console.error(r)}}async verifyRecaptcha(t){return await fetch(this.verify_url,{method:"post",body:JSON.stringify({token:t}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(r=>r.json())}};var Oe={config:{},name:null,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();})();
|
|
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.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 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.top.location.hostname!=="localhost"&&window.top.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.top.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.top.location.hostname==="localhost"||window.top.location.hostname==="127.0.0.1")&&(t.searchParams.set("test","1"),console.log("testing mode!")),t.href}function Te(){if(document.querySelectorAll('script[src="//unpkg.com/alpinejs"]').length===0){var e=document.createElement("script");e.setAttribute("src","//unpkg.com/alpinejs"),e.setAttribute("type","text/javascript"),e.setAttribute("defer",!0),document.body.appendChild(e)}}var ut={forms:at},Si=ut;window.Hapi=ut;Te();})();
|
package/package.json
CHANGED
package/src/hapi.js
CHANGED
|
@@ -72,7 +72,7 @@ function displayHapiformInformation(a) {
|
|
|
72
72
|
let endpoint = new URL(org_endpoint);
|
|
73
73
|
|
|
74
74
|
if (endpoint.host === "hapiform.sg") {
|
|
75
|
-
console.log("🚀 " + window.location.origin + a.redirectTo);
|
|
75
|
+
console.log("🚀 " + window.top.location.origin + a.redirectTo);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -103,7 +103,7 @@ async function verifyCaptcha(a) {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function integrationWebhook(config) {
|
|
106
|
-
if (window.location.hostname !== "localhost" && window.location.hostname !== "127.0.0.1") {
|
|
106
|
+
if (window.top.location.hostname !== "localhost" && window.top.location.hostname !== "127.0.0.1") {
|
|
107
107
|
axios(config).then((res) => {
|
|
108
108
|
}).catch((e) => {
|
|
109
109
|
console.error(e)
|
|
@@ -123,7 +123,7 @@ function onSubmission(config, a) {
|
|
|
123
123
|
// on success webhook end
|
|
124
124
|
|
|
125
125
|
if (a.redirectTo) {
|
|
126
|
-
window.location.href = a.redirectTo;
|
|
126
|
+
window.top.location.href = a.redirectTo;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
// Remove files from filepond
|
|
@@ -297,7 +297,7 @@ function dispatchEvent(eventName) {
|
|
|
297
297
|
function getEndpoint(endpoint) {
|
|
298
298
|
let url = new URL(endpoint);
|
|
299
299
|
|
|
300
|
-
if (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") {
|
|
300
|
+
if (window.top.location.hostname === "localhost" || window.top.location.hostname === "127.0.0.1") {
|
|
301
301
|
url.searchParams.set("test", '1');
|
|
302
302
|
console.log('testing mode!')
|
|
303
303
|
}
|