@joystick.js/ui-canary 0.0.0-canary.92 → 0.0.0-canary.93

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.
@@ -1,4 +1,4 @@
1
- var er=Object.create;var ie=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var rr=Object.getOwnPropertyNames;var or=Object.getPrototypeOf,ir=Object.prototype.hasOwnProperty;var nr=t=>ie(t,"__esModule",{value:!0});var sr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ar=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of rr(e))!ir.call(t,o)&&o!=="default"&&ie(t,o,{get:()=>e[o],enumerable:!(r=tr(e,o))||r.enumerable});return t},dr=t=>ar(nr(ie(t!=null?er(or(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var kt=sr(X=>{(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof X!="undefined")e(X);else{var r={exports:{}};e(r.exports),t.index=r.exports}})(X,function(t){"use strict";function e(p){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e(p)}function r(p,d){return d&&(e(d)==="object"||typeof d=="function")?d:o(p)}function o(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function i(p){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},i(p)}function s(p,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(d&&d.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),d&&c(p,d)}function c(p,d){return c=Object.setPrototypeOf||function(F,_){return F.__proto__=_,F},c(p,d)}function a(p,d){if(!(p instanceof d))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;var m=function p(d,F){a(this,p),this.type=d,this.path=F?F.toString():""},g=function(p){function d(F,_,h){var A;return a(this,d),A=r(this,i(d).call(this,"E",F)),A.lhs=_,A.rhs=h,A}return s(d,p),d}(m),y=function(p){function d(F,_,h,A){var k;return a(this,d),k=r(this,i(d).call(this,"M",F)),k.item=_,k.lhsIndex=h,k.rhsIndex=A,k}return s(d,p),d}(m),x=function(p){function d(F,_){var h;return a(this,d),h=r(this,i(d).call(this,"D",F)),h.lhs=_,h}return s(d,p),d}(m),j=function(p){function d(F,_){var h;return a(this,d),h=r(this,i(d).call(this,"A",F)),h.rhs=_,h}return s(d,p),d}(m),f=function(p,d){return p?"".concat(p,".").concat(d):d};t.diff=function(d,F){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},h=[],A=_.matchKey,k=_.types||["E","A","D","M"],Xt=function(E,$,M,D){E.forEach(function(L,S){var v=$.findIndex(function(T){return T[D]===L[D]});-1<v?(-1<k.indexOf("M")&&S!==v&&h.push(new y(M,L,S,v)),B(L,$[v],f(M,v))):-1<k.indexOf("D")&&h.push(new x(M,L))}),$.forEach(function(L,S){var v=E.findIndex(function(T){return L[D]===T[D]});-1<k.indexOf("A")&&v===-1&&h.push(new j(f(M,S),L))})},B=function(E,$,M){var D=Object.prototype.toString.call(E),L=Object.prototype.toString.call($);if(-1<k.indexOf("E")&&D!==L)return h.push(new g(M,E,$)),!1;if(D==="[object Object]")Object.getOwnPropertyNames(E).forEach(function(T){Object.prototype.hasOwnProperty.call($,T)?B(E[T],$[T],f(M,T)):-1<k.indexOf("D")&&h.push(new x(f(M,T),E[T]))}),Object.getOwnPropertyNames($).forEach(function(T){-1<k.indexOf("A")&&!Object.prototype.hasOwnProperty.call(E,T)&&h.push(new j(f(M,T),$[T]))});else if(D!=="[object Array]")-1<k.indexOf("E")&&E!==$&&h.push(new g(M,E,$));else if(A)Xt(E,$,M,A);else{var S=E.length-1,v=$.length-1;if(-1<k.indexOf("D"))for(;S>v;)h.push(new x(f(M,S),E[S--]));if(-1<k.indexOf("A"))for(;v>S;)h.push(new j(f(M,v),$[v--]));for(;0<=S;--S)B(E[S],$[S],f(M,S))}};return B(d,F),h}})});var n=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var fe=["render"];var he=(t={})=>{try{return fe.every(e=>Object.keys(t).includes(e))}catch(e){n("component.hasAllRequiredOptions",e)}};var we=["_componentId","_ssrId","api","dataFromSSR","existingProps","existingState","instanceId","parent","req","css","data","defaultProps","events","id","lifecycle","methods","name","props","render","state","test","translations","url","websockets","wrapper"];var ye=t=>{try{return typeof t=="undefined"}catch(e){n("types.isUndefined",e)}},ge=t=>{try{return t===null}catch(e){n("types.isNull",e)}};var P=t=>{try{return!!Array.isArray(t)}catch(e){n("types.isArray",e)}};var l=t=>{try{return typeof t=="function"}catch(e){n("types.isFunction",e)}};var u=t=>{try{return!!(t&&typeof t=="object"&&!Array.isArray(t))}catch(e){n("types.isObject",e)}};var O=t=>{try{return typeof t=="string"}catch(e){n("types.isString",e)}};var xe=(t=null)=>{try{!O(t)&&!l(t)&&!u(t)&&n("component.optionValidators.css","options.css must be a string, function returning a string, or an object returning breakpoints.")}catch(e){n("component.optionValidators.css",e)}};var be=["readystatechange","pointerlockchange","pointerlockerror","beforecopy","beforecut","beforepaste","freeze","resume","search","securitypolicyviolation","visibilitychange","fullscreenchange","fullscreenerror","webkitfullscreenchange","webkitfullscreenerror","beforexrselect","abort","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","formdata","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","pause","play","playing","progress","ratechange","reset","resize","scroll","seeked","seeking","select","stalled","submit","suspend","timeupdate","toggle","volumechange","waiting","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","wheel","auxclick","gotpointercapture","lostpointercapture","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerout","pointerenter","pointerleave","selectstart","selectionchange","animationend","animationiteration","animationstart","transitionrun","transitionstart","transitionend","transitioncancel","copy","cut","paste","pointerrawupdate"];var $e=(t=null)=>{try{u(t)||n("component.optionValidators.events","options.events must be an object.");for(let e of Object.keys(t)){let[r]=e.split(" ");be.includes(r)||n("component.optionValidators.events",`${r} is not a supported JavaScript event type.`)}for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.events",`options.events.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.events",e)}};var Fe=["onBeforeMount","onMount","onUpdateProps","onBeforeUnmount","onRefetchData"];var ke=(t=null)=>{try{u(t)||n("component.optionValidators.lifecycle","options.lifecycle must be an object.");for(let[e,r]of Object.entries(t))Fe.includes(e)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} is not supported.`),l(r)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.lifecycle",e)}};var Ee=(t=null)=>{try{u(t)||n("component.optionValidators.methods","options.methods must be an object.");for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.methods",`options.methods.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.methods",e)}};var Me=(t=null)=>{typeof t!="string"&&n("component.optionValidators.name","options.name must be a string.")};var Se=(t=null)=>{try{l(t)||n("component.optionValidators.render","options.render must be a function returning a string.")}catch(e){n("component.optionValidators.render",e)}};var Te=(t=null)=>{try{u(t)||n("component.optionValidators.test","options.test must be an object."),t?.name&&!O(t.name)&&n("component.optionValidators.test","options.test.name must be assigned a string.")}catch(e){n("component.optionValidators.test",e)}};var Oe=(t=null)=>{try{l(t)||n("component.optionValidators.websockets","options.websockets must be a function returning an object.")}catch(e){n("component.optionValidators.websockets",e)}};var Ce=(t=null)=>{try{u(t)||n("component.optionValidators.wrapper","options.wrapper must be an object.");for(let[e,r]of Object.entries(t))e==="id"&&!O(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned a string.`),e==="classList"&&!P(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned an array of strings.`)}catch(e){n("component.optionValidators.wrapper",e)}};var _e={css:xe,events:$e,lifecycle:ke,methods:Ee,name:Me,render:Se,test:Te,websockets:Oe,wrapper:Ce};var ve=(t={})=>{try{he(t)||n("component.validateOptions",`component options must include ${required.options.join(",")}.`);for(let[e,r]of Object.entries(t)){we.includes(e)||n("component.validateOptions",`${e} is not supported by joystick.component.`);let o=_e[e];o&&l(o)&&o(r)}}catch(e){n("component.validateOptions",e)}};var je="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),w=(t=16)=>{let e="",r=0;for(;r<t;)e+=je[Math.floor(Math.random()*(je.length-1))],r+=1;return e};var G=(t=[],e="")=>{try{return(P(t)&&t.find(o=>o?.componentId===e))?.data||{}}catch(r){n("findComponentDataFromSSR",r)}};var Re=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var I=t=>!!(t&&typeof t=="object"&&!Array.isArray(t));var Ae=t=>typeof t=="string";var Le=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,De=(t,e="")=>{if(!e)return!0;if(e&&!Ae(e))return!1;let r=e?e.replace(/[- ]+/g,""):"";return t===!0?r.match(new RegExp(Le)):!r.match(new RegExp(Le))};var Pe=(t="",e="")=>t(e);var Ie=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~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r.isChecked)return t===!0?e&&e.trim()!=="":e&&e.trim()==="";if(r.isChecked)return t===!0?e:!e};var Je=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,Qe=(t,e="")=>t===!0?!!e.match(Je):!e.match(Je);var Ye=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Xe=(t,e="")=>t===!0?!!e.match(Ye):!e.match(Ye);var et=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/,tt=(t,e="")=>t===!0?!!e.match(et):!e.match(et);var rt=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,ot=(t,e="")=>t===!0?!!e.match(rt):!e.match(rt);var it={AT:/^(AT)(U\d{8}$)/i,BE:/^(BE)(\d{10}$)/i,BG:/^(BG)(\d{9,10}$)/i,CY:/^(CY)([0-5|9]\d{7}[A-Z]$)/i,CZ:/^(CZ)(\d{8,10})?$/i,DE:/^(DE)([1-9]\d{8}$)/i,DK:/^(DK)(\d{8}$)/i,EE:/^(EE)(10\d{7}$)/i,EL:/^(EL)(\d{9}$)/i,ES:/^(ES)([0-9A-Z][0-9]{7}[0-9A-Z]$)/i,EU:/^(EU)(\d{9}$)/i,FI:/^(FI)(\d{8}$)/i,FR:/^(FR)([0-9A-Z]{2}[0-9]{9}$)/i,GB:/^(GB)((?:[0-9]{12}|[0-9]{9}|(?:GD|HA)[0-9]{3})$)/i,GR:/^(GR)(\d{8,9}$)/i,HR:/^(HR)(\d{11}$)/i,HU:/^(HU)(\d{8}$)/i,IE:/^(IE)([0-9A-Z\*\+]{7}[A-Z]{1,2}$)/i,IT:/^(IT)(\d{11}$)/i,LV:/^(LV)(\d{11}$)/i,LT:/^(LT)(\d{9}$|\d{12}$)/i,LU:/^(LU)(\d{8}$)/i,MT:/^(MT)([1-9]\d{7}$)/i,NL:/^(NL)(\d{9}B\d{2}$)/i,NO:/^(NO)(\d{9}$)/i,PL:/^(PL)(\d{10}$)/i,PT:/^(PT)(\d{9}$)/i,RO:/^(RO)([1-9]\d{1,9}$)/i,RU:/^(RU)(\d{10}$|\d{12}$)/i,RS:/^(RS)(\d{9}$)/i,SI:/^(SI)([1-9]\d{7}$)/i,SK:/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i,SE:/^(SE)(\d{10}01$)/i},nt=(t,e="")=>{let r=I(t)&&t.iso?it[t.iso||"EU"]:it.EU;return I(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var st={creditCard:De,custom:Pe,email:Ve,equals:Ne,matches:Ue,maxLength:qe,minLength:ze,phone:Ze,postalCode:Ge,regex:Ke,required:We,semVer:Qe,slug:Xe,strongPassword:tt,url:ot,vat:nt};var at=class{constructor(e,r={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={creditCard:()=>"Must be a valid credit card number.",custom:()=>"Must return true.",email:()=>"Must be a valid email.",equals:o=>`Value must equal ${o}.`,matches:o=>`Field must match ${o}.`,maxLength:o=>`Field value can be no greater than ${o}.`,minLength:o=>`Field value can be no less than ${o}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",regex:()=>"Must match regex.",required:()=>"This field is required.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},e||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=e,this.setOptions(r),this.attachEventListeners()}setOptions(e={}){this.rules=e.rules||{},this.messages=e.messages||{},this.onSubmit=e.onSubmit,this.onRenderError=e.onRenderError,this.fields=this.serialize()}updateOptions(e={}){this.setOptions(e)}serialize(){if(this.form)return Object.keys(this.rules).map(r=>{let o=this.form.querySelector(`[name="${r}"]`),i=o?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(i),type:i,name:r,element:o,validations:Object.entries(this.rules[r]).map(([c,a])=>({name:c,rule:a,valid:!1})).sort((c,a)=>c.name>a.name?1:-1),errorMessages:this.messages[r]?Object.keys(this.messages[r]):{}}})}attachEventListeners(){if(this.form){let e=r=>{r.stopPropagation(),r.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let r=0;r<this.form.listeners.length;r+=1){let o=this.form.listeners[r];this.form.removeEventListener("submit",o)}this.form.addEventListener("submit",e),this.form.listeners=[...this.form.listeners||[],e]}this.fields.forEach(e=>{if(e?.element&&e?.listenForChanges){let r=()=>{Re(()=>{this.validate(e.name)},100)};e.element.removeEventListener("input",r),e.element.addEventListener("input",r),e.element.removeEventListener("change",r),e.element.addEventListener("change",r)}})}validate(e=null){if(e){let r=this.fields.find(o=>o.name===e);return this.clearExistingError(e),this.validateField(r),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(r=>{this.validateField(r)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(r=>r.validations.some(o=>!o.valid)).includes(!0)}validateField(e){let r=this.form.querySelector(`[name="${e.name}"]`),o=["checkbox","radio"].includes(e.type),i=o?null:e?.element?.value?.trim(),s=o?e?.element?.checked:null;e.validations.forEach(a=>{if(!!r&&!this.isValidValue(o,o?s:i,a)){let m=this.messages[e.name]&&this.messages[e.name][a.name];this.markValidationAsInvalid(e,a.name),this.renderError(e.element,m||this.defaultValidationErrors[a.name](a.rule,i))}else this.markValidationAsValid(e,a.name)});let c=e.validations.some(a=>!a.valid);return c&&(r.classList.add("error"),r.focus()),c||(r.classList.remove("error"),this.clearExistingError(e.name)),!c}markValidationAsInvalid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!1}markValidationAsValid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!0}isValidValue(e,r,o){let i=st[o.name];return i?i(o.rule,r,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.parentNode.removeChild(e))}clearExistingError(e=""){let r=document.getElementById(`error-${e}`);r&&r.parentNode.removeChild(r)}renderError(e,r=""){if(e){if(this.clearExistingError(e.name),typeof this.onRenderError=="function")return this.onRenderError(e,r);let o=document.createElement("p");o.classList.add("input-hint"),o.classList.add("error"),o.setAttribute("id",`error-${e.name}`),o.innerText=r,e.after(o)}}},cr=(t,e)=>new Promise((r,o)=>{try{new at(t,e).validate()?r():o()}catch(i){console.warn(i)}}),dt=cr;var ct=(t={},e={})=>{try{return[...Object.keys(e),...Object.keys(t)].filter((o,i,s)=>s.indexOf(o)===i).reduce((o,i)=>{let s=e[i],c=t[i]||null,a=!ye(s)&&!ge(s);return o[i]=a?s:c,o},{})}catch(r){n("component.props.compile",r)}};var lt=(t="",e={})=>{try{let r="";if(t&&O(t))return r=t,r;if(t&&l(t))return r=t(e),r;if(t&&u(t)){let o=t?.print&&(O(t?.print)||l(t?.print)),i=t?.min&&u(t?.min),s=t?.min?.width&&u(t?.min?.width),c=t?.min?.height&&u(t?.min?.height),a=t?.max&&u(t?.max),m=t?.max?.width&&u(t?.max?.width),g=t?.max?.height&&u(t?.max?.height);if(o&&(r+=`
1
+ var er=Object.create;var ie=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var rr=Object.getOwnPropertyNames;var or=Object.getPrototypeOf,ir=Object.prototype.hasOwnProperty;var nr=t=>ie(t,"__esModule",{value:!0});var sr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ar=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of rr(e))!ir.call(t,o)&&o!=="default"&&ie(t,o,{get:()=>e[o],enumerable:!(r=tr(e,o))||r.enumerable});return t},dr=t=>ar(nr(ie(t!=null?er(or(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var kt=sr(X=>{(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof X!="undefined")e(X);else{var r={exports:{}};e(r.exports),t.index=r.exports}})(X,function(t){"use strict";function e(p){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e(p)}function r(p,d){return d&&(e(d)==="object"||typeof d=="function")?d:o(p)}function o(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function i(p){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},i(p)}function s(p,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(d&&d.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),d&&c(p,d)}function c(p,d){return c=Object.setPrototypeOf||function(F,_){return F.__proto__=_,F},c(p,d)}function a(p,d){if(!(p instanceof d))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;var m=function p(d,F){a(this,p),this.type=d,this.path=F?F.toString():""},g=function(p){function d(F,_,h){var A;return a(this,d),A=r(this,i(d).call(this,"E",F)),A.lhs=_,A.rhs=h,A}return s(d,p),d}(m),y=function(p){function d(F,_,h,A){var k;return a(this,d),k=r(this,i(d).call(this,"M",F)),k.item=_,k.lhsIndex=h,k.rhsIndex=A,k}return s(d,p),d}(m),x=function(p){function d(F,_){var h;return a(this,d),h=r(this,i(d).call(this,"D",F)),h.lhs=_,h}return s(d,p),d}(m),j=function(p){function d(F,_){var h;return a(this,d),h=r(this,i(d).call(this,"A",F)),h.rhs=_,h}return s(d,p),d}(m),f=function(p,d){return p?"".concat(p,".").concat(d):d};t.diff=function(d,F){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},h=[],A=_.matchKey,k=_.types||["E","A","D","M"],Xt=function(E,$,M,D){E.forEach(function(L,S){var v=$.findIndex(function(T){return T[D]===L[D]});-1<v?(-1<k.indexOf("M")&&S!==v&&h.push(new y(M,L,S,v)),B(L,$[v],f(M,v))):-1<k.indexOf("D")&&h.push(new x(M,L))}),$.forEach(function(L,S){var v=E.findIndex(function(T){return L[D]===T[D]});-1<k.indexOf("A")&&v===-1&&h.push(new j(f(M,S),L))})},B=function(E,$,M){var D=Object.prototype.toString.call(E),L=Object.prototype.toString.call($);if(-1<k.indexOf("E")&&D!==L)return h.push(new g(M,E,$)),!1;if(D==="[object Object]")Object.getOwnPropertyNames(E).forEach(function(T){Object.prototype.hasOwnProperty.call($,T)?B(E[T],$[T],f(M,T)):-1<k.indexOf("D")&&h.push(new x(f(M,T),E[T]))}),Object.getOwnPropertyNames($).forEach(function(T){-1<k.indexOf("A")&&!Object.prototype.hasOwnProperty.call(E,T)&&h.push(new j(f(M,T),$[T]))});else if(D!=="[object Array]")-1<k.indexOf("E")&&E!==$&&h.push(new g(M,E,$));else if(A)Xt(E,$,M,A);else{var S=E.length-1,v=$.length-1;if(-1<k.indexOf("D"))for(;S>v;)h.push(new x(f(M,S),E[S--]));if(-1<k.indexOf("A"))for(;v>S;)h.push(new j(f(M,v),$[v--]));for(;0<=S;--S)B(E[S],$[S],f(M,S))}};return B(d,F),h}})});var n=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var fe=["render"];var he=(t={})=>{try{return fe.every(e=>Object.keys(t).includes(e))}catch(e){n("component.hasAllRequiredOptions",e)}};var we=["_componentId","_ssrId","api","dataFromSSR","existingProps","existingState","instanceId","parent","req","css","data","defaultProps","events","id","lifecycle","methods","name","props","render","state","test","translations","url","websockets","wrapper"];var ye=t=>{try{return typeof t=="undefined"}catch(e){n("types.isUndefined",e)}},ge=t=>{try{return t===null}catch(e){n("types.isNull",e)}};var P=t=>{try{return!!Array.isArray(t)}catch(e){n("types.isArray",e)}};var l=t=>{try{return typeof t=="function"}catch(e){n("types.isFunction",e)}};var u=t=>{try{return!!(t&&typeof t=="object"&&!Array.isArray(t))}catch(e){n("types.isObject",e)}};var O=t=>{try{return typeof t=="string"}catch(e){n("types.isString",e)}};var xe=(t=null)=>{try{!O(t)&&!l(t)&&!u(t)&&n("component.optionValidators.css","options.css must be a string, function returning a string, or an object returning breakpoints.")}catch(e){n("component.optionValidators.css",e)}};var be=["readystatechange","pointerlockchange","pointerlockerror","beforecopy","beforecut","beforepaste","freeze","resume","search","securitypolicyviolation","visibilitychange","fullscreenchange","fullscreenerror","webkitfullscreenchange","webkitfullscreenerror","beforexrselect","abort","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","formdata","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","pause","play","playing","progress","ratechange","reset","resize","scroll","seeked","seeking","select","stalled","submit","suspend","timeupdate","toggle","volumechange","waiting","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","wheel","auxclick","gotpointercapture","lostpointercapture","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerout","pointerenter","pointerleave","selectstart","selectionchange","animationend","animationiteration","animationstart","transitionrun","transitionstart","transitionend","transitioncancel","copy","cut","paste","pointerrawupdate"];var $e=(t=null)=>{try{u(t)||n("component.optionValidators.events","options.events must be an object.");for(let e of Object.keys(t)){let[r]=e.split(" ");be.includes(r)||n("component.optionValidators.events",`${r} is not a supported JavaScript event type.`)}for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.events",`options.events.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.events",e)}};var Fe=["onBeforeMount","onMount","onUpdateProps","onBeforeUnmount","onRefetchData"];var ke=(t=null)=>{try{u(t)||n("component.optionValidators.lifecycle","options.lifecycle must be an object.");for(let[e,r]of Object.entries(t))Fe.includes(e)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} is not supported.`),l(r)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.lifecycle",e)}};var Ee=(t=null)=>{try{u(t)||n("component.optionValidators.methods","options.methods must be an object.");for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.methods",`options.methods.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.methods",e)}};var Me=(t=null)=>{typeof t!="string"&&n("component.optionValidators.name","options.name must be a string.")};var Se=(t=null)=>{try{l(t)||n("component.optionValidators.render","options.render must be a function returning a string.")}catch(e){n("component.optionValidators.render",e)}};var Te=(t=null)=>{try{u(t)||n("component.optionValidators.test","options.test must be an object."),t?.name&&!O(t.name)&&n("component.optionValidators.test","options.test.name must be assigned a string.")}catch(e){n("component.optionValidators.test",e)}};var Oe=(t=null)=>{try{l(t)||n("component.optionValidators.websockets","options.websockets must be a function returning an object.")}catch(e){n("component.optionValidators.websockets",e)}};var Ce=(t=null)=>{try{u(t)||n("component.optionValidators.wrapper","options.wrapper must be an object.");for(let[e,r]of Object.entries(t))e==="id"&&!O(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned a string.`),e==="classList"&&!P(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned an array of strings.`)}catch(e){n("component.optionValidators.wrapper",e)}};var _e={css:xe,events:$e,lifecycle:ke,methods:Ee,name:Me,render:Se,test:Te,websockets:Oe,wrapper:Ce};var ve=(t={})=>{try{he(t)||n("component.validateOptions",`component options must include ${required.options.join(",")}.`);for(let[e,r]of Object.entries(t)){we.includes(e)||n("component.validateOptions",`${e} is not supported by joystick.component.`);let o=_e[e];o&&l(o)&&o(r)}}catch(e){n("component.validateOptions",e)}};var je="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),w=(t=16)=>{let e="",r=0;for(;r<t;)e+=je[Math.floor(Math.random()*(je.length-1))],r+=1;return e};var G=(t=[],e="")=>{try{return(P(t)&&t.find(o=>o?.componentId===e))?.data||{}}catch(r){n("findComponentDataFromSSR",r)}};var Re=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var I=t=>!!(t&&typeof t=="object"&&!Array.isArray(t));var Ae=t=>typeof t=="string";var Le=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,De=(t,e="")=>{if(!e)return!0;if(e&&!Ae(e))return!1;let r=e?e.replace(/[- ]+/g,""):"";return t===!0?r.match(new RegExp(Le)):!r.match(new RegExp(Le))};var Pe=(t="",e="")=>t(e);var Ie=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))$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1}\d{4}$/,ZA:/^\d{4}$/,GS:/^[Ss][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,ES:/^\d{5}$/,LK:/^\d{5}$/,SD:/^\d{5}$/,SZ:/^[A-Za-z]\d{3}$/,SE:/^\d{3}\s*\d{2}$/,CH:/^\d{4}$/,SJ:/^\d{4}$/,TW:/^\d{5}$/,TJ:/^\d{6}$/,TH:/^\d{5}$/,TT:/^\d{6}$/,TN:/^\d{4}$/,TR:/^\d{5}$/,TM:/^\d{6}$/,TC:/^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,UA:/^\d{5}$/,GB:/^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,US:/^\b\d{5}\b(?:[- ]{1}\d{4})?$/,UY:/^\d{5}$/,VI:/^\d{5}$/,UZ:/^\d{3} \d{3}$/,VA:/^120$/,VE:/^\d{4}(\s[a-zA-Z]{1})?$/,VN:/^\d{6}$/,WF:/^986\d{2}$/,ZM:/^\d{5}$/},Ge=(t,e="")=>{let r=I(t)&&t.iso?Be[t.iso||"US"]:Be.US;return I(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var Ke=(t="",e="")=>(e?.match(t)||[])?.length>0;var We=(t,e="",r={isChecked:!1})=>{if(!r.isChecked)return t===!0?e&&e.trim()!=="":e&&e.trim()==="";if(r.isChecked)return t===!0?e:!e};var Je=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,Qe=(t,e="")=>t===!0?!!e.match(Je):!e.match(Je);var Ye=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Xe=(t,e="")=>t===!0?!!e.match(Ye):!e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[(2-4)|(6-9)]\d{7}$)/i,SE:/^(SE)(\d{10}01$)/i},nt=(t,e="")=>{let r=I(t)&&t.iso?it[t.iso||"EU"]:it.EU;return I(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var st={creditCard:De,custom:Pe,email:Ve,equals:Ne,matches:Ue,maxLength:qe,minLength:ze,phone:Ze,postalCode:Ge,regex:Ke,required:We,semVer:Qe,slug:Xe,strongPassword:tt,url:ot,vat:nt};var at=class{constructor(e,r={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={creditCard:()=>"Must be a valid credit card number.",custom:()=>"Must return true.",email:()=>"Must be a valid email.",equals:o=>`Value must equal ${o}.`,matches:o=>`Field must match ${o}.`,maxLength:o=>`Field value can be no greater than ${o}.`,minLength:o=>`Field value can be no less than ${o}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",regex:()=>"Must match regex.",required:()=>"This field is required.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},e||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=e,this.setOptions(r),this.attachEventListeners()}setOptions(e={}){this.rules=e.rules||{},this.messages=e.messages||{},this.onSubmit=e.onSubmit,this.onRenderError=e.onRenderError,this.fields=this.serialize()}updateOptions(e={}){this.setOptions(e)}serialize(){if(this.form)return Object.keys(this.rules).map(r=>{let o=this.form.querySelector(`[name="${r}"]`),i=o?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(i),type:i,name:r,element:o,validations:Object.entries(this.rules[r]).map(([c,a])=>({name:c,rule:a,valid:!1})).sort((c,a)=>c.name>a.name?1:-1),errorMessages:this.messages[r]?Object.keys(this.messages[r]):{}}})?.filter(r=>!!r?.element)}attachEventListeners(){if(this.form){let e=r=>{r.stopPropagation(),r.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let r=0;r<this.form.listeners.length;r+=1){let o=this.form.listeners[r];this.form.removeEventListener("submit",o)}this.form.addEventListener("submit",e),this.form.listeners=[...this.form.listeners||[],e]}this.fields.forEach(e=>{if(e?.element&&e?.listenForChanges){let r=()=>{Re(()=>{this.validate(e.name)},100)};e.element.removeEventListener("input",r),e.element.addEventListener("input",r),e.element.removeEventListener("change",r),e.element.addEventListener("change",r)}})}validate(e=null){if(e){let r=this.fields.find(o=>o.name===e);return this.clearExistingError(e),this.validateField(r),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(r=>{this.validateField(r)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(r=>r.validations.some(o=>!o.valid)).includes(!0)}validateField(e){let r=this.form.querySelector(`[name="${e.name}"]`),o=["checkbox","radio"].includes(e.type),i=o?null:e?.element?.value?.trim(),s=o?e?.element?.checked:null;e.validations.forEach(a=>{if(this.isValidValue(o,o?s:i,a))this.markValidationAsValid(e,a.name);else{let m=this.messages[e.name]&&this.messages[e.name][a.name];this.markValidationAsInvalid(e,a.name),this.renderError(e.element,m||this.defaultValidationErrors[a.name](a.rule,i))}});let c=e.validations.some(a=>!a.valid);return c&&(r.classList.add("error"),r.focus()),c||(r.classList.remove("error"),this.clearExistingError(e.name)),!c}markValidationAsInvalid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!1}markValidationAsValid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!0}isValidValue(e,r,o){let i=st[o.name];return i?i(o.rule,r,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.parentNode.removeChild(e))}clearExistingError(e=""){let r=document.getElementById(`error-${e}`);r&&r.parentNode.removeChild(r)}renderError(e,r=""){if(e){if(this.clearExistingError(e.name),typeof this.onRenderError=="function")return this.onRenderError(e,r);let o=document.createElement("p");o.classList.add("input-hint"),o.classList.add("error"),o.setAttribute("id",`error-${e.name}`),o.innerText=r,e.after(o)}}},cr=(t,e)=>new Promise((r,o)=>{try{new at(t,e).validate()?r():o()}catch(i){console.warn(i)}}),dt=cr;var ct=(t={},e={})=>{try{return[...Object.keys(e),...Object.keys(t)].filter((o,i,s)=>s.indexOf(o)===i).reduce((o,i)=>{let s=e[i],c=t[i]||null,a=!ye(s)&&!ge(s);return o[i]=a?s:c,o},{})}catch(r){n("component.props.compile",r)}};var lt=(t="",e={})=>{try{let r="";if(t&&O(t))return r=t,r;if(t&&l(t))return r=t(e),r;if(t&&u(t)){let o=t?.print&&(O(t?.print)||l(t?.print)),i=t?.min&&u(t?.min),s=t?.min?.width&&u(t?.min?.width),c=t?.min?.height&&u(t?.min?.height),a=t?.max&&u(t?.max),m=t?.max?.width&&u(t?.max?.width),g=t?.max?.height&&u(t?.max?.height);if(o&&(r+=`
2
2
  @media print {
3
3
  ${typeof t?.print=="function"?t?.print(e):t.print}
4
4
  }
@@ -1,4 +1,4 @@
1
- var k="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),f=(e=16)=>{let t="",r=0;for(;r<e;)t+=k[Math.floor(Math.random()*(k.length-1))],r+=1;return t};var d=(e="",t={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${t.message||t.reason||t}`)};var F=e=>{try{return typeof e=="undefined"}catch(t){d("types.isUndefined",t)}},M=e=>{try{return e===null}catch(t){d("types.isNull",t)}};var x=e=>{try{return!!Array.isArray(e)}catch(t){d("types.isArray",t)}};var h=e=>{try{return typeof e=="function"}catch(t){d("types.isFunction",t)}};var c=e=>{try{return!!(e&&typeof e=="object"&&!Array.isArray(e))}catch(t){d("types.isObject",t)}};var y=e=>{try{return typeof e=="string"}catch(t){d("types.isString",t)}};var C=(e=[],t="")=>{try{return(x(e)&&e.find(i=>i?.componentId===t))?.data||{}}catch(r){d("findComponentDataFromSSR",r)}};var L=(()=>{let e=0;return(t,r)=>{clearTimeout(e),e=setTimeout(t,r)}})();var w=e=>!!(e&&typeof e=="object"&&!Array.isArray(e));var R=e=>typeof e=="string";var Z=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,v=(e,t="")=>{if(!t)return!0;if(t&&!R(t))return!1;let r=t?t.replace(/[- ]+/g,""):"";return e===!0?r.match(new RegExp(Z)):!r.match(new RegExp(Z))};var z=(e="",t="")=>e(t);var V=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))$/,T=(e,t="")=>e===!0?!!t.match(V):!t.match(V);var D=(e,t="")=>e===t;var j=(e,t="")=>e===t;var N=(e,t="")=>t.length<=e;var O=(e,t="")=>t.length>=e;var U=/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/,_=(e,t="")=>e===!0?!!t.match(U):!t.match(U);var P={AF:/^\d{4}$/,A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}$/,TN:/^\d{4}$/,TR:/^\d{5}$/,TM:/^\d{6}$/,TC:/^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,UA:/^\d{5}$/,GB:/^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,US:/^\b\d{5}\b(?:[- ]{1}\d{4})?$/,UY:/^\d{5}$/,VI:/^\d{5}$/,UZ:/^\d{3} \d{3}$/,VA:/^120$/,VE:/^\d{4}(\s[a-zA-Z]{1})?$/,VN:/^\d{6}$/,WF:/^986\d{2}$/,ZM:/^\d{5}$/},B=(e,t="")=>{let r=w(e)&&e.iso?P[e.iso||"US"]:P.US;return w(e)?e.rule===!0?!!t.match(r):!t.match(r):e===!0?!!t.match(r):!t.match(r)};var G=(e="",t="")=>(t?.match(e)||[])?.length>0;var H=(e,t="",r={isChecked:!1})=>{if(!r.isChecked)return e===!0?t&&t.trim()!=="":t&&t.trim()==="";if(r.isChecked)return e===!0?t:!t};var q=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,I=(e,t="")=>e===!0?!!t.match(q):!t.match(q);var K=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,W=(e,t="")=>e===!0?!!t.match(K):!t.match(K);var Y=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/,J=(e,t="")=>e===!0?!!t.match(Y):!t.match(Y);var Q=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,X=(e,t="")=>e===!0?!!t.match(Q):!t.match(Q);var ee={AT:/^(AT)(U\d{8}$)/i,BE:/^(BE)(\d{10}$)/i,BG:/^(BG)(\d{9,10}$)/i,CY:/^(CY)([0-5|9]\d{7}[A-Z]$)/i,CZ:/^(CZ)(\d{8,10})?$/i,DE:/^(DE)([1-9]\d{8}$)/i,DK:/^(DK)(\d{8}$)/i,EE:/^(EE)(10\d{7}$)/i,EL:/^(EL)(\d{9}$)/i,ES:/^(ES)([0-9A-Z][0-9]{7}[0-9A-Z]$)/i,EU:/^(EU)(\d{9}$)/i,FI:/^(FI)(\d{8}$)/i,FR:/^(FR)([0-9A-Z]{2}[0-9]{9}$)/i,GB:/^(GB)((?:[0-9]{12}|[0-9]{9}|(?:GD|HA)[0-9]{3})$)/i,GR:/^(GR)(\d{8,9}$)/i,HR:/^(HR)(\d{11}$)/i,HU:/^(HU)(\d{8}$)/i,IE:/^(IE)([0-9A-Z\*\+]{7}[A-Z]{1,2}$)/i,IT:/^(IT)(\d{11}$)/i,LV:/^(LV)(\d{11}$)/i,LT:/^(LT)(\d{9}$|\d{12}$)/i,LU:/^(LU)(\d{8}$)/i,MT:/^(MT)([1-9]\d{7}$)/i,NL:/^(NL)(\d{9}B\d{2}$)/i,NO:/^(NO)(\d{9}$)/i,PL:/^(PL)(\d{10}$)/i,PT:/^(PT)(\d{9}$)/i,RO:/^(RO)([1-9]\d{1,9}$)/i,RU:/^(RU)(\d{10}$|\d{12}$)/i,RS:/^(RS)(\d{9}$)/i,SI:/^(SI)([1-9]\d{7}$)/i,SK:/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i,SE:/^(SE)(\d{10}01$)/i},te=(e,t="")=>{let r=w(e)&&e.iso?ee[e.iso||"EU"]:ee.EU;return w(e)?e.rule===!0?!!t.match(r):!t.match(r):e===!0?!!t.match(r):!t.match(r)};var re={creditCard:v,custom:z,email:T,equals:D,matches:j,maxLength:N,minLength:O,phone:_,postalCode:B,regex:G,required:H,semVer:I,slug:W,strongPassword:J,url:X,vat:te};var ie=class{constructor(t,r={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={creditCard:()=>"Must be a valid credit card number.",custom:()=>"Must return true.",email:()=>"Must be a valid email.",equals:i=>`Value must equal ${i}.`,matches:i=>`Field must match ${i}.`,maxLength:i=>`Field value can be no greater than ${i}.`,minLength:i=>`Field value can be no less than ${i}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",regex:()=>"Must match regex.",required:()=>"This field is required.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},t||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=t,this.setOptions(r),this.attachEventListeners()}setOptions(t={}){this.rules=t.rules||{},this.messages=t.messages||{},this.onSubmit=t.onSubmit,this.onRenderError=t.onRenderError,this.fields=this.serialize()}updateOptions(t={}){this.setOptions(t)}serialize(){if(this.form)return Object.keys(this.rules).map(r=>{let i=this.form.querySelector(`[name="${r}"]`),o=i?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(o),type:o,name:r,element:i,validations:Object.entries(this.rules[r]).map(([n,a])=>({name:n,rule:a,valid:!1})).sort((n,a)=>n.name>a.name?1:-1),errorMessages:this.messages[r]?Object.keys(this.messages[r]):{}}})}attachEventListeners(){if(this.form){let t=r=>{r.stopPropagation(),r.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let r=0;r<this.form.listeners.length;r+=1){let i=this.form.listeners[r];this.form.removeEventListener("submit",i)}this.form.addEventListener("submit",t),this.form.listeners=[...this.form.listeners||[],t]}this.fields.forEach(t=>{if(t?.element&&t?.listenForChanges){let r=()=>{L(()=>{this.validate(t.name)},100)};t.element.removeEventListener("input",r),t.element.addEventListener("input",r),t.element.removeEventListener("change",r),t.element.addEventListener("change",r)}})}validate(t=null){if(t){let r=this.fields.find(i=>i.name===t);return this.clearExistingError(t),this.validateField(r),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(r=>{this.validateField(r)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(r=>r.validations.some(i=>!i.valid)).includes(!0)}validateField(t){let r=this.form.querySelector(`[name="${t.name}"]`),i=["checkbox","radio"].includes(t.type),o=i?null:t?.element?.value?.trim(),s=i?t?.element?.checked:null;t.validations.forEach(a=>{if(!!r&&!this.isValidValue(i,i?s:o,a)){let b=this.messages[t.name]&&this.messages[t.name][a.name];this.markValidationAsInvalid(t,a.name),this.renderError(t.element,b||this.defaultValidationErrors[a.name](a.rule,o))}else this.markValidationAsValid(t,a.name)});let n=t.validations.some(a=>!a.valid);return n&&(r.classList.add("error"),r.focus()),n||(r.classList.remove("error"),this.clearExistingError(t.name)),!n}markValidationAsInvalid(t,r){let o=[...t.validations].find(s=>s.name===r);o.valid=!1}markValidationAsValid(t,r){let o=[...t.validations].find(s=>s.name===r);o.valid=!0}isValidValue(t,r,i){let o=re[i.name];return o?o(i.rule,r,{isChecked:t}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(t=>t.parentNode.removeChild(t))}clearExistingError(t=""){let r=document.getElementById(`error-${t}`);r&&r.parentNode.removeChild(r)}renderError(t,r=""){if(t){if(this.clearExistingError(t.name),typeof this.onRenderError=="function")return this.onRenderError(t,r);let i=document.createElement("p");i.classList.add("input-hint"),i.classList.add("error"),i.setAttribute("id",`error-${t.name}`),i.innerText=r,t.after(i)}}},$e=(e,t)=>new Promise((r,i)=>{try{new ie(e,t).validate()?r():i()}catch(o){console.warn(o)}}),oe=$e;var se=(e={},t={})=>{try{return[...Object.keys(t),...Object.keys(e)].filter((i,o,s)=>s.indexOf(i)===o).reduce((i,o)=>{let s=t[o],n=e[o]||null,a=!F(s)&&!M(s);return i[o]=a?s:n,i},{})}catch(r){d("component.props.compile",r)}};var de=(e="",t={})=>{try{let r="";if(e&&y(e))return r=e,r;if(e&&h(e))return r=e(t),r;if(e&&c(e)){let i=e?.print&&(y(e?.print)||h(e?.print)),o=e?.min&&c(e?.min),s=e?.min?.width&&c(e?.min?.width),n=e?.min?.height&&c(e?.min?.height),a=e?.max&&c(e?.max),b=e?.max?.width&&c(e?.max?.width),he=e?.max?.height&&c(e?.max?.height);if(i&&(r+=`
1
+ var k="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),f=(e=16)=>{let t="",r=0;for(;r<e;)t+=k[Math.floor(Math.random()*(k.length-1))],r+=1;return t};var d=(e="",t={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${t.message||t.reason||t}`)};var F=e=>{try{return typeof e=="undefined"}catch(t){d("types.isUndefined",t)}},M=e=>{try{return e===null}catch(t){d("types.isNull",t)}};var x=e=>{try{return!!Array.isArray(e)}catch(t){d("types.isArray",t)}};var h=e=>{try{return typeof e=="function"}catch(t){d("types.isFunction",t)}};var c=e=>{try{return!!(e&&typeof e=="object"&&!Array.isArray(e))}catch(t){d("types.isObject",t)}};var y=e=>{try{return typeof e=="string"}catch(t){d("types.isString",t)}};var C=(e=[],t="")=>{try{return(x(e)&&e.find(i=>i?.componentId===t))?.data||{}}catch(r){d("findComponentDataFromSSR",r)}};var L=(()=>{let e=0;return(t,r)=>{clearTimeout(e),e=setTimeout(t,r)}})();var w=e=>!!(e&&typeof e=="object"&&!Array.isArray(e));var R=e=>typeof e=="string";var Z=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,v=(e,t="")=>{if(!t)return!0;if(t&&!R(t))return!1;let r=t?t.replace(/[- ]+/g,""):"";return e===!0?r.match(new RegExp(Z)):!r.match(new RegExp(Z))};var z=(e="",t="")=>e(t);var V=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))$/,T=(e,t="")=>e===!0?!!t.match(V):!t.match(V);var D=(e,t="")=>e===t;var j=(e,t="")=>e===t;var N=(e,t="")=>t.length<=e;var O=(e,t="")=>t.length>=e;var U=/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/,_=(e,t="")=>e===!0?!!t.match(U):!t.match(U);var P={AF:/^\d{4}$/,AX:/^\d{5}$/,AL:/^\d{4}$/,DZ:/^\d{5}$/,AS:/^\d{5}(-{1}\d{4,6})$/,AD:/^[Aa][Dd]\d{3}$/,AI:/^[Aa][I][-][2][6][4][0]$/,AR:/^\d{4}|[A-Za-z]\d{4}[a-zA-Z]{3}$/,AM:/^\d{4}$/,AC:/^[Aa][Ss][Cc][Nn]\s{0,1}[1][Zz][Zz]$/,AU:/^\d{4}$/,AT:/^\d{4}$/,AZ:/^[Aa][Zz]\d{4}$/,BH:/^\d{3,4}$/,BD:/^\d{4}$/,BB:/^[Aa][Zz]\d{5}$/,BY:/^\d{6}$/,BE:/^\d{4}$/,BM:/^[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P[e.iso||"US"]:P.US;return w(e)?e.rule===!0?!!t.match(r):!t.match(r):e===!0?!!t.match(r):!t.match(r)};var G=(e="",t="")=>(t?.match(e)||[])?.length>0;var H=(e,t="",r={isChecked:!1})=>{if(!r.isChecked)return e===!0?t&&t.trim()!=="":t&&t.trim()==="";if(r.isChecked)return e===!0?t:!t};var q=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,I=(e,t="")=>e===!0?!!t.match(q):!t.match(q);var K=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,W=(e,t="")=>e===!0?!!t.match(K):!t.match(K);var Y=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/,J=(e,t="")=>e===!0?!!t.match(Y):!t.match(Y);var Q=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,X=(e,t="")=>e===!0?!!t.match(Q):!t.match(Q);var ee={AT:/^(AT)(U\d{8}$)/i,BE:/^(BE)(\d{10}$)/i,BG:/^(BG)(\d{9,10}$)/i,CY:/^(CY)([0-5|9]\d{7}[A-Z]$)/i,CZ:/^(CZ)(\d{8,10})?$/i,DE:/^(DE)([1-9]\d{8}$)/i,DK:/^(DK)(\d{8}$)/i,EE:/^(EE)(10\d{7}$)/i,EL:/^(EL)(\d{9}$)/i,ES:/^(ES)([0-9A-Z][0-9]{7}[0-9A-Z]$)/i,EU:/^(EU)(\d{9}$)/i,FI:/^(FI)(\d{8}$)/i,FR:/^(FR)([0-9A-Z]{2}[0-9]{9}$)/i,GB:/^(GB)((?:[0-9]{12}|[0-9]{9}|(?:GD|HA)[0-9]{3})$)/i,GR:/^(GR)(\d{8,9}$)/i,HR:/^(HR)(\d{11}$)/i,HU:/^(HU)(\d{8}$)/i,IE:/^(IE)([0-9A-Z\*\+]{7}[A-Z]{1,2}$)/i,IT:/^(IT)(\d{11}$)/i,LV:/^(LV)(\d{11}$)/i,LT:/^(LT)(\d{9}$|\d{12}$)/i,LU:/^(LU)(\d{8}$)/i,MT:/^(MT)([1-9]\d{7}$)/i,NL:/^(NL)(\d{9}B\d{2}$)/i,NO:/^(NO)(\d{9}$)/i,PL:/^(PL)(\d{10}$)/i,PT:/^(PT)(\d{9}$)/i,RO:/^(RO)([1-9]\d{1,9}$)/i,RU:/^(RU)(\d{10}$|\d{12}$)/i,RS:/^(RS)(\d{9}$)/i,SI:/^(SI)([1-9]\d{7}$)/i,SK:/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i,SE:/^(SE)(\d{10}01$)/i},te=(e,t="")=>{let r=w(e)&&e.iso?ee[e.iso||"EU"]:ee.EU;return w(e)?e.rule===!0?!!t.match(r):!t.match(r):e===!0?!!t.match(r):!t.match(r)};var re={creditCard:v,custom:z,email:T,equals:D,matches:j,maxLength:N,minLength:O,phone:_,postalCode:B,regex:G,required:H,semVer:I,slug:W,strongPassword:J,url:X,vat:te};var ie=class{constructor(t,r={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={creditCard:()=>"Must be a valid credit card number.",custom:()=>"Must return true.",email:()=>"Must be a valid email.",equals:i=>`Value must equal ${i}.`,matches:i=>`Field must match ${i}.`,maxLength:i=>`Field value can be no greater than ${i}.`,minLength:i=>`Field value can be no less than ${i}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",regex:()=>"Must match regex.",required:()=>"This field is required.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},t||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=t,this.setOptions(r),this.attachEventListeners()}setOptions(t={}){this.rules=t.rules||{},this.messages=t.messages||{},this.onSubmit=t.onSubmit,this.onRenderError=t.onRenderError,this.fields=this.serialize()}updateOptions(t={}){this.setOptions(t)}serialize(){if(this.form)return Object.keys(this.rules).map(r=>{let i=this.form.querySelector(`[name="${r}"]`),o=i?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(o),type:o,name:r,element:i,validations:Object.entries(this.rules[r]).map(([n,a])=>({name:n,rule:a,valid:!1})).sort((n,a)=>n.name>a.name?1:-1),errorMessages:this.messages[r]?Object.keys(this.messages[r]):{}}})?.filter(r=>!!r?.element)}attachEventListeners(){if(this.form){let t=r=>{r.stopPropagation(),r.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let r=0;r<this.form.listeners.length;r+=1){let i=this.form.listeners[r];this.form.removeEventListener("submit",i)}this.form.addEventListener("submit",t),this.form.listeners=[...this.form.listeners||[],t]}this.fields.forEach(t=>{if(t?.element&&t?.listenForChanges){let r=()=>{L(()=>{this.validate(t.name)},100)};t.element.removeEventListener("input",r),t.element.addEventListener("input",r),t.element.removeEventListener("change",r),t.element.addEventListener("change",r)}})}validate(t=null){if(t){let r=this.fields.find(i=>i.name===t);return this.clearExistingError(t),this.validateField(r),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(r=>{this.validateField(r)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(r=>r.validations.some(i=>!i.valid)).includes(!0)}validateField(t){let r=this.form.querySelector(`[name="${t.name}"]`),i=["checkbox","radio"].includes(t.type),o=i?null:t?.element?.value?.trim(),s=i?t?.element?.checked:null;t.validations.forEach(a=>{if(this.isValidValue(i,i?s:o,a))this.markValidationAsValid(t,a.name);else{let b=this.messages[t.name]&&this.messages[t.name][a.name];this.markValidationAsInvalid(t,a.name),this.renderError(t.element,b||this.defaultValidationErrors[a.name](a.rule,o))}});let n=t.validations.some(a=>!a.valid);return n&&(r.classList.add("error"),r.focus()),n||(r.classList.remove("error"),this.clearExistingError(t.name)),!n}markValidationAsInvalid(t,r){let o=[...t.validations].find(s=>s.name===r);o.valid=!1}markValidationAsValid(t,r){let o=[...t.validations].find(s=>s.name===r);o.valid=!0}isValidValue(t,r,i){let o=re[i.name];return o?o(i.rule,r,{isChecked:t}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(t=>t.parentNode.removeChild(t))}clearExistingError(t=""){let r=document.getElementById(`error-${t}`);r&&r.parentNode.removeChild(r)}renderError(t,r=""){if(t){if(this.clearExistingError(t.name),typeof this.onRenderError=="function")return this.onRenderError(t,r);let i=document.createElement("p");i.classList.add("input-hint"),i.classList.add("error"),i.setAttribute("id",`error-${t.name}`),i.innerText=r,t.after(i)}}},$e=(e,t)=>new Promise((r,i)=>{try{new ie(e,t).validate()?r():i()}catch(o){console.warn(o)}}),oe=$e;var se=(e={},t={})=>{try{return[...Object.keys(t),...Object.keys(e)].filter((i,o,s)=>s.indexOf(i)===o).reduce((i,o)=>{let s=t[o],n=e[o]||null,a=!F(s)&&!M(s);return i[o]=a?s:n,i},{})}catch(r){d("component.props.compile",r)}};var de=(e="",t={})=>{try{let r="";if(e&&y(e))return r=e,r;if(e&&h(e))return r=e(t),r;if(e&&c(e)){let i=e?.print&&(y(e?.print)||h(e?.print)),o=e?.min&&c(e?.min),s=e?.min?.width&&c(e?.min?.width),n=e?.min?.height&&c(e?.min?.height),a=e?.max&&c(e?.max),b=e?.max?.width&&c(e?.max?.width),he=e?.max?.height&&c(e?.max?.height);if(i&&(r+=`
2
2
  @media print {
3
3
  ${typeof e?.print=="function"?e?.print(t):e.print}
4
4
  }
@@ -1,4 +1,4 @@
1
- var tr=Object.create;var ie=Object.defineProperty;var rr=Object.getOwnPropertyDescriptor;var or=Object.getOwnPropertyNames;var ir=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty;var sr=t=>ie(t,"__esModule",{value:!0});var ar=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var dr=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of or(e))!nr.call(t,o)&&o!=="default"&&ie(t,o,{get:()=>e[o],enumerable:!(r=rr(e,o))||r.enumerable});return t},cr=t=>dr(sr(ie(t!=null?tr(ir(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var kt=ar(X=>{(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof X!="undefined")e(X);else{var r={exports:{}};e(r.exports),t.index=r.exports}})(X,function(t){"use strict";function e(p){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e(p)}function r(p,d){return d&&(e(d)==="object"||typeof d=="function")?d:o(p)}function o(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function i(p){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},i(p)}function s(p,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(d&&d.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),d&&c(p,d)}function c(p,d){return c=Object.setPrototypeOf||function(F,_){return F.__proto__=_,F},c(p,d)}function a(p,d){if(!(p instanceof d))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;var m=function p(d,F){a(this,p),this.type=d,this.path=F?F.toString():""},x=function(p){function d(F,_,h){var A;return a(this,d),A=r(this,i(d).call(this,"E",F)),A.lhs=_,A.rhs=h,A}return s(d,p),d}(m),y=function(p){function d(F,_,h,A){var k;return a(this,d),k=r(this,i(d).call(this,"M",F)),k.item=_,k.lhsIndex=h,k.rhsIndex=A,k}return s(d,p),d}(m),g=function(p){function d(F,_){var h;return a(this,d),h=r(this,i(d).call(this,"D",F)),h.lhs=_,h}return s(d,p),d}(m),j=function(p){function d(F,_){var h;return a(this,d),h=r(this,i(d).call(this,"A",F)),h.rhs=_,h}return s(d,p),d}(m),f=function(p,d){return p?"".concat(p,".").concat(d):d};t.diff=function(d,F){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},h=[],A=_.matchKey,k=_.types||["E","A","D","M"],er=function(E,$,M,D){E.forEach(function(L,S){var v=$.findIndex(function(T){return T[D]===L[D]});-1<v?(-1<k.indexOf("M")&&S!==v&&h.push(new y(M,L,S,v)),B(L,$[v],f(M,v))):-1<k.indexOf("D")&&h.push(new g(M,L))}),$.forEach(function(L,S){var v=E.findIndex(function(T){return L[D]===T[D]});-1<k.indexOf("A")&&v===-1&&h.push(new j(f(M,S),L))})},B=function(E,$,M){var D=Object.prototype.toString.call(E),L=Object.prototype.toString.call($);if(-1<k.indexOf("E")&&D!==L)return h.push(new x(M,E,$)),!1;if(D==="[object Object]")Object.getOwnPropertyNames(E).forEach(function(T){Object.prototype.hasOwnProperty.call($,T)?B(E[T],$[T],f(M,T)):-1<k.indexOf("D")&&h.push(new g(f(M,T),E[T]))}),Object.getOwnPropertyNames($).forEach(function(T){-1<k.indexOf("A")&&!Object.prototype.hasOwnProperty.call(E,T)&&h.push(new j(f(M,T),$[T]))});else if(D!=="[object Array]")-1<k.indexOf("E")&&E!==$&&h.push(new x(M,E,$));else if(A)er(E,$,M,A);else{var S=E.length-1,v=$.length-1;if(-1<k.indexOf("D"))for(;S>v;)h.push(new g(f(M,S),E[S--]));if(-1<k.indexOf("A"))for(;v>S;)h.push(new j(f(M,v),$[v--]));for(;0<=S;--S)B(E[S],$[S],f(M,S))}};return B(d,F),h}})});var n=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var fe=["render"];var he=(t={})=>{try{return fe.every(e=>Object.keys(t).includes(e))}catch(e){n("component.hasAllRequiredOptions",e)}};var we=["_componentId","_ssrId","api","dataFromSSR","existingProps","existingState","instanceId","parent","req","css","data","defaultProps","events","id","lifecycle","methods","name","props","render","state","test","translations","url","websockets","wrapper"];var ye=t=>{try{return typeof t=="undefined"}catch(e){n("types.isUndefined",e)}},xe=t=>{try{return t===null}catch(e){n("types.isNull",e)}};var P=t=>{try{return!!Array.isArray(t)}catch(e){n("types.isArray",e)}};var l=t=>{try{return typeof t=="function"}catch(e){n("types.isFunction",e)}};var u=t=>{try{return!!(t&&typeof t=="object"&&!Array.isArray(t))}catch(e){n("types.isObject",e)}};var O=t=>{try{return typeof t=="string"}catch(e){n("types.isString",e)}};var ge=(t=null)=>{try{!O(t)&&!l(t)&&!u(t)&&n("component.optionValidators.css","options.css must be a string, function returning a string, or an object returning breakpoints.")}catch(e){n("component.optionValidators.css",e)}};var be=["readystatechange","pointerlockchange","pointerlockerror","beforecopy","beforecut","beforepaste","freeze","resume","search","securitypolicyviolation","visibilitychange","fullscreenchange","fullscreenerror","webkitfullscreenchange","webkitfullscreenerror","beforexrselect","abort","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","formdata","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","pause","play","playing","progress","ratechange","reset","resize","scroll","seeked","seeking","select","stalled","submit","suspend","timeupdate","toggle","volumechange","waiting","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","wheel","auxclick","gotpointercapture","lostpointercapture","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerout","pointerenter","pointerleave","selectstart","selectionchange","animationend","animationiteration","animationstart","transitionrun","transitionstart","transitionend","transitioncancel","copy","cut","paste","pointerrawupdate"];var $e=(t=null)=>{try{u(t)||n("component.optionValidators.events","options.events must be an object.");for(let e of Object.keys(t)){let[r]=e.split(" ");be.includes(r)||n("component.optionValidators.events",`${r} is not a supported JavaScript event type.`)}for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.events",`options.events.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.events",e)}};var Fe=["onBeforeMount","onMount","onUpdateProps","onBeforeUnmount","onRefetchData"];var ke=(t=null)=>{try{u(t)||n("component.optionValidators.lifecycle","options.lifecycle must be an object.");for(let[e,r]of Object.entries(t))Fe.includes(e)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} is not supported.`),l(r)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.lifecycle",e)}};var Ee=(t=null)=>{try{u(t)||n("component.optionValidators.methods","options.methods must be an object.");for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.methods",`options.methods.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.methods",e)}};var Me=(t=null)=>{typeof t!="string"&&n("component.optionValidators.name","options.name must be a string.")};var Se=(t=null)=>{try{l(t)||n("component.optionValidators.render","options.render must be a function returning a string.")}catch(e){n("component.optionValidators.render",e)}};var Te=(t=null)=>{try{u(t)||n("component.optionValidators.test","options.test must be an object."),t?.name&&!O(t.name)&&n("component.optionValidators.test","options.test.name must be assigned a string.")}catch(e){n("component.optionValidators.test",e)}};var Oe=(t=null)=>{try{l(t)||n("component.optionValidators.websockets","options.websockets must be a function returning an object.")}catch(e){n("component.optionValidators.websockets",e)}};var Ce=(t=null)=>{try{u(t)||n("component.optionValidators.wrapper","options.wrapper must be an object.");for(let[e,r]of Object.entries(t))e==="id"&&!O(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned a string.`),e==="classList"&&!P(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned an array of strings.`)}catch(e){n("component.optionValidators.wrapper",e)}};var _e={css:ge,events:$e,lifecycle:ke,methods:Ee,name:Me,render:Se,test:Te,websockets:Oe,wrapper:Ce};var ve=(t={})=>{try{he(t)||n("component.validateOptions",`component options must include ${required.options.join(",")}.`);for(let[e,r]of Object.entries(t)){we.includes(e)||n("component.validateOptions",`${e} is not supported by joystick.component.`);let o=_e[e];o&&l(o)&&o(r)}}catch(e){n("component.validateOptions",e)}};var je="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),w=(t=16)=>{let e="",r=0;for(;r<t;)e+=je[Math.floor(Math.random()*(je.length-1))],r+=1;return e};var G=(t=[],e="")=>{try{return(P(t)&&t.find(o=>o?.componentId===e))?.data||{}}catch(r){n("findComponentDataFromSSR",r)}};var Re=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var I=t=>!!(t&&typeof t=="object"&&!Array.isArray(t));var Ae=t=>typeof t=="string";var Le=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,De=(t,e="")=>{if(!e)return!0;if(e&&!Ae(e))return!1;let r=e?e.replace(/[- ]+/g,""):"";return t===!0?r.match(new RegExp(Le)):!r.match(new RegExp(Le))};var Pe=(t="",e="")=>t(e);var Ie=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[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,VC:/^[Vv][Cc]\d{4}$/,SM:/^4789\d$/,SA:/^\d{5}(-{1}\d{4})?$/,SN:/^\d{5}$/,RS:/^\d{5}$/,SG:/^\d{2}$/,SK:/^\d{5}\s\(\d{3}\s\d{2}\)$/,SI:/^([Ss][Ii][- ]{0,1}){0,1}\d{4}$/,ZA:/^\d{4}$/,GS:/^[Ss][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,ES:/^\d{5}$/,LK:/^\d{5}$/,SD:/^\d{5}$/,SZ:/^[A-Za-z]\d{3}$/,SE:/^\d{3}\s*\d{2}$/,CH:/^\d{4}$/,SJ:/^\d{4}$/,TW:/^\d{5}$/,TJ:/^\d{6}$/,TH:/^\d{5}$/,TT:/^\d{6}$/,TN:/^\d{4}$/,TR:/^\d{5}$/,TM:/^\d{6}$/,TC:/^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,UA:/^\d{5}$/,GB:/^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,US:/^\b\d{5}\b(?:[- ]{1}\d{4})?$/,UY:/^\d{5}$/,VI:/^\d{5}$/,UZ:/^\d{3} \d{3}$/,VA:/^120$/,VE:/^\d{4}(\s[a-zA-Z]{1})?$/,VN:/^\d{6}$/,WF:/^986\d{2}$/,ZM:/^\d{5}$/},Ge=(t,e="")=>{let r=I(t)&&t.iso?Be[t.iso||"US"]:Be.US;return I(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var Ke=(t="",e="")=>(e?.match(t)||[])?.length>0;var We=(t,e="",r={isChecked:!1})=>{if(!r.isChecked)return t===!0?e&&e.trim()!=="":e&&e.trim()==="";if(r.isChecked)return t===!0?e:!e};var Je=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-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,PL:/^(PL)(\d{10}$)/i,PT:/^(PT)(\d{9}$)/i,RO:/^(RO)([1-9]\d{1,9}$)/i,RU:/^(RU)(\d{10}$|\d{12}$)/i,RS:/^(RS)(\d{9}$)/i,SI:/^(SI)([1-9]\d{7}$)/i,SK:/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i,SE:/^(SE)(\d{10}01$)/i},nt=(t,e="")=>{let r=I(t)&&t.iso?it[t.iso||"EU"]:it.EU;return I(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var st={creditCard:De,custom:Pe,email:Ve,equals:Ne,matches:Ue,maxLength:qe,minLength:ze,phone:Ze,postalCode:Ge,regex:Ke,required:We,semVer:Qe,slug:Xe,strongPassword:tt,url:ot,vat:nt};var at=class{constructor(e,r={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={creditCard:()=>"Must be a valid credit card number.",custom:()=>"Must return true.",email:()=>"Must be a valid email.",equals:o=>`Value must equal ${o}.`,matches:o=>`Field must match ${o}.`,maxLength:o=>`Field value can be no greater than ${o}.`,minLength:o=>`Field value can be no less than ${o}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",regex:()=>"Must match regex.",required:()=>"This field is required.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},e||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=e,this.setOptions(r),this.attachEventListeners()}setOptions(e={}){this.rules=e.rules||{},this.messages=e.messages||{},this.onSubmit=e.onSubmit,this.onRenderError=e.onRenderError,this.fields=this.serialize()}updateOptions(e={}){this.setOptions(e)}serialize(){if(this.form)return Object.keys(this.rules).map(r=>{let o=this.form.querySelector(`[name="${r}"]`),i=o?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(i),type:i,name:r,element:o,validations:Object.entries(this.rules[r]).map(([c,a])=>({name:c,rule:a,valid:!1})).sort((c,a)=>c.name>a.name?1:-1),errorMessages:this.messages[r]?Object.keys(this.messages[r]):{}}})}attachEventListeners(){if(this.form){let e=r=>{r.stopPropagation(),r.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let r=0;r<this.form.listeners.length;r+=1){let o=this.form.listeners[r];this.form.removeEventListener("submit",o)}this.form.addEventListener("submit",e),this.form.listeners=[...this.form.listeners||[],e]}this.fields.forEach(e=>{if(e?.element&&e?.listenForChanges){let r=()=>{Re(()=>{this.validate(e.name)},100)};e.element.removeEventListener("input",r),e.element.addEventListener("input",r),e.element.removeEventListener("change",r),e.element.addEventListener("change",r)}})}validate(e=null){if(e){let r=this.fields.find(o=>o.name===e);return this.clearExistingError(e),this.validateField(r),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(r=>{this.validateField(r)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(r=>r.validations.some(o=>!o.valid)).includes(!0)}validateField(e){let r=this.form.querySelector(`[name="${e.name}"]`),o=["checkbox","radio"].includes(e.type),i=o?null:e?.element?.value?.trim(),s=o?e?.element?.checked:null;e.validations.forEach(a=>{if(!!r&&!this.isValidValue(o,o?s:i,a)){let m=this.messages[e.name]&&this.messages[e.name][a.name];this.markValidationAsInvalid(e,a.name),this.renderError(e.element,m||this.defaultValidationErrors[a.name](a.rule,i))}else this.markValidationAsValid(e,a.name)});let c=e.validations.some(a=>!a.valid);return c&&(r.classList.add("error"),r.focus()),c||(r.classList.remove("error"),this.clearExistingError(e.name)),!c}markValidationAsInvalid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!1}markValidationAsValid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!0}isValidValue(e,r,o){let i=st[o.name];return i?i(o.rule,r,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.parentNode.removeChild(e))}clearExistingError(e=""){let r=document.getElementById(`error-${e}`);r&&r.parentNode.removeChild(r)}renderError(e,r=""){if(e){if(this.clearExistingError(e.name),typeof this.onRenderError=="function")return this.onRenderError(e,r);let o=document.createElement("p");o.classList.add("input-hint"),o.classList.add("error"),o.setAttribute("id",`error-${e.name}`),o.innerText=r,e.after(o)}}},lr=(t,e)=>new Promise((r,o)=>{try{new at(t,e).validate()?r():o()}catch(i){console.warn(i)}}),dt=lr;var ct=(t={},e={})=>{try{return[...Object.keys(e),...Object.keys(t)].filter((o,i,s)=>s.indexOf(o)===i).reduce((o,i)=>{let s=e[i],c=t[i]||null,a=!ye(s)&&!xe(s);return o[i]=a?s:c,o},{})}catch(r){n("component.props.compile",r)}};var lt=(t="",e={})=>{try{let r="";if(t&&O(t))return r=t,r;if(t&&l(t))return r=t(e),r;if(t&&u(t)){let o=t?.print&&(O(t?.print)||l(t?.print)),i=t?.min&&u(t?.min),s=t?.min?.width&&u(t?.min?.width),c=t?.min?.height&&u(t?.min?.height),a=t?.max&&u(t?.max),m=t?.max?.width&&u(t?.max?.width),x=t?.max?.height&&u(t?.max?.height);if(o&&(r+=`
1
+ var tr=Object.create;var ie=Object.defineProperty;var rr=Object.getOwnPropertyDescriptor;var or=Object.getOwnPropertyNames;var ir=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty;var sr=t=>ie(t,"__esModule",{value:!0});var ar=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var dr=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of or(e))!nr.call(t,o)&&o!=="default"&&ie(t,o,{get:()=>e[o],enumerable:!(r=rr(e,o))||r.enumerable});return t},cr=t=>dr(sr(ie(t!=null?tr(ir(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var kt=ar(X=>{(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof X!="undefined")e(X);else{var r={exports:{}};e(r.exports),t.index=r.exports}})(X,function(t){"use strict";function e(p){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e(p)}function r(p,d){return d&&(e(d)==="object"||typeof d=="function")?d:o(p)}function o(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function i(p){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},i(p)}function s(p,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(d&&d.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),d&&c(p,d)}function c(p,d){return c=Object.setPrototypeOf||function(F,_){return F.__proto__=_,F},c(p,d)}function a(p,d){if(!(p instanceof d))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;var m=function p(d,F){a(this,p),this.type=d,this.path=F?F.toString():""},x=function(p){function d(F,_,h){var A;return a(this,d),A=r(this,i(d).call(this,"E",F)),A.lhs=_,A.rhs=h,A}return s(d,p),d}(m),y=function(p){function d(F,_,h,A){var k;return a(this,d),k=r(this,i(d).call(this,"M",F)),k.item=_,k.lhsIndex=h,k.rhsIndex=A,k}return s(d,p),d}(m),g=function(p){function d(F,_){var h;return a(this,d),h=r(this,i(d).call(this,"D",F)),h.lhs=_,h}return s(d,p),d}(m),j=function(p){function d(F,_){var h;return a(this,d),h=r(this,i(d).call(this,"A",F)),h.rhs=_,h}return s(d,p),d}(m),f=function(p,d){return p?"".concat(p,".").concat(d):d};t.diff=function(d,F){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},h=[],A=_.matchKey,k=_.types||["E","A","D","M"],er=function(E,$,M,D){E.forEach(function(L,S){var v=$.findIndex(function(T){return T[D]===L[D]});-1<v?(-1<k.indexOf("M")&&S!==v&&h.push(new y(M,L,S,v)),B(L,$[v],f(M,v))):-1<k.indexOf("D")&&h.push(new g(M,L))}),$.forEach(function(L,S){var v=E.findIndex(function(T){return L[D]===T[D]});-1<k.indexOf("A")&&v===-1&&h.push(new j(f(M,S),L))})},B=function(E,$,M){var D=Object.prototype.toString.call(E),L=Object.prototype.toString.call($);if(-1<k.indexOf("E")&&D!==L)return h.push(new x(M,E,$)),!1;if(D==="[object Object]")Object.getOwnPropertyNames(E).forEach(function(T){Object.prototype.hasOwnProperty.call($,T)?B(E[T],$[T],f(M,T)):-1<k.indexOf("D")&&h.push(new g(f(M,T),E[T]))}),Object.getOwnPropertyNames($).forEach(function(T){-1<k.indexOf("A")&&!Object.prototype.hasOwnProperty.call(E,T)&&h.push(new j(f(M,T),$[T]))});else if(D!=="[object Array]")-1<k.indexOf("E")&&E!==$&&h.push(new x(M,E,$));else if(A)er(E,$,M,A);else{var S=E.length-1,v=$.length-1;if(-1<k.indexOf("D"))for(;S>v;)h.push(new g(f(M,S),E[S--]));if(-1<k.indexOf("A"))for(;v>S;)h.push(new j(f(M,v),$[v--]));for(;0<=S;--S)B(E[S],$[S],f(M,S))}};return B(d,F),h}})});var n=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var fe=["render"];var he=(t={})=>{try{return fe.every(e=>Object.keys(t).includes(e))}catch(e){n("component.hasAllRequiredOptions",e)}};var we=["_componentId","_ssrId","api","dataFromSSR","existingProps","existingState","instanceId","parent","req","css","data","defaultProps","events","id","lifecycle","methods","name","props","render","state","test","translations","url","websockets","wrapper"];var ye=t=>{try{return typeof t=="undefined"}catch(e){n("types.isUndefined",e)}},xe=t=>{try{return t===null}catch(e){n("types.isNull",e)}};var P=t=>{try{return!!Array.isArray(t)}catch(e){n("types.isArray",e)}};var l=t=>{try{return typeof t=="function"}catch(e){n("types.isFunction",e)}};var u=t=>{try{return!!(t&&typeof t=="object"&&!Array.isArray(t))}catch(e){n("types.isObject",e)}};var O=t=>{try{return typeof t=="string"}catch(e){n("types.isString",e)}};var ge=(t=null)=>{try{!O(t)&&!l(t)&&!u(t)&&n("component.optionValidators.css","options.css must be a string, function returning a string, or an object returning breakpoints.")}catch(e){n("component.optionValidators.css",e)}};var be=["readystatechange","pointerlockchange","pointerlockerror","beforecopy","beforecut","beforepaste","freeze","resume","search","securitypolicyviolation","visibilitychange","fullscreenchange","fullscreenerror","webkitfullscreenchange","webkitfullscreenerror","beforexrselect","abort","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","formdata","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","pause","play","playing","progress","ratechange","reset","resize","scroll","seeked","seeking","select","stalled","submit","suspend","timeupdate","toggle","volumechange","waiting","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","wheel","auxclick","gotpointercapture","lostpointercapture","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerout","pointerenter","pointerleave","selectstart","selectionchange","animationend","animationiteration","animationstart","transitionrun","transitionstart","transitionend","transitioncancel","copy","cut","paste","pointerrawupdate"];var $e=(t=null)=>{try{u(t)||n("component.optionValidators.events","options.events must be an object.");for(let e of Object.keys(t)){let[r]=e.split(" ");be.includes(r)||n("component.optionValidators.events",`${r} is not a supported JavaScript event type.`)}for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.events",`options.events.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.events",e)}};var Fe=["onBeforeMount","onMount","onUpdateProps","onBeforeUnmount","onRefetchData"];var ke=(t=null)=>{try{u(t)||n("component.optionValidators.lifecycle","options.lifecycle must be an object.");for(let[e,r]of Object.entries(t))Fe.includes(e)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} is not supported.`),l(r)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.lifecycle",e)}};var Ee=(t=null)=>{try{u(t)||n("component.optionValidators.methods","options.methods must be an object.");for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.methods",`options.methods.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.methods",e)}};var Me=(t=null)=>{typeof t!="string"&&n("component.optionValidators.name","options.name must be a string.")};var Se=(t=null)=>{try{l(t)||n("component.optionValidators.render","options.render must be a function returning a string.")}catch(e){n("component.optionValidators.render",e)}};var Te=(t=null)=>{try{u(t)||n("component.optionValidators.test","options.test must be an object."),t?.name&&!O(t.name)&&n("component.optionValidators.test","options.test.name must be assigned a string.")}catch(e){n("component.optionValidators.test",e)}};var Oe=(t=null)=>{try{l(t)||n("component.optionValidators.websockets","options.websockets must be a function returning an object.")}catch(e){n("component.optionValidators.websockets",e)}};var Ce=(t=null)=>{try{u(t)||n("component.optionValidators.wrapper","options.wrapper must be an object.");for(let[e,r]of Object.entries(t))e==="id"&&!O(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned a string.`),e==="classList"&&!P(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned an array of strings.`)}catch(e){n("component.optionValidators.wrapper",e)}};var _e={css:ge,events:$e,lifecycle:ke,methods:Ee,name:Me,render:Se,test:Te,websockets:Oe,wrapper:Ce};var ve=(t={})=>{try{he(t)||n("component.validateOptions",`component options must include ${required.options.join(",")}.`);for(let[e,r]of Object.entries(t)){we.includes(e)||n("component.validateOptions",`${e} is not supported by joystick.component.`);let o=_e[e];o&&l(o)&&o(r)}}catch(e){n("component.validateOptions",e)}};var je="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),w=(t=16)=>{let e="",r=0;for(;r<t;)e+=je[Math.floor(Math.random()*(je.length-1))],r+=1;return e};var G=(t=[],e="")=>{try{return(P(t)&&t.find(o=>o?.componentId===e))?.data||{}}catch(r){n("findComponentDataFromSSR",r)}};var Re=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var I=t=>!!(t&&typeof t=="object"&&!Array.isArray(t));var Ae=t=>typeof t=="string";var Le=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,De=(t,e="")=>{if(!e)return!0;if(e&&!Ae(e))return!1;let r=e?e.replace(/[- ]+/g,""):"";return t===!0?r.match(new RegExp(Le)):!r.match(new RegExp(Le))};var Pe=(t="",e="")=>t(e);var Ie=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))$/,Ve=(t,e="")=>t===!0?!!e.match(Ie):!e.match(Ie);var Ne=(t,e="")=>t===e;var Ue=(t,e="")=>t===e;var qe=(t,e="")=>e.length<=t;var ze=(t,e="")=>e.length>=t;var He=/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/,Ze=(t,e="")=>t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,TJ:/^\d{6}$/,TH:/^\d{5}$/,TT:/^\d{6}$/,TN:/^\d{4}$/,TR:/^\d{5}$/,TM:/^\d{6}$/,TC:/^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,UA:/^\d{5}$/,GB:/^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,US:/^\b\d{5}\b(?:[- ]{1}\d{4})?$/,UY:/^\d{5}$/,VI:/^\d{5}$/,UZ:/^\d{3} \d{3}$/,VA:/^120$/,VE:/^\d{4}(\s[a-zA-Z]{1})?$/,VN:/^\d{6}$/,WF:/^986\d{2}$/,ZM:/^\d{5}$/},Ge=(t,e="")=>{let r=I(t)&&t.iso?Be[t.iso||"US"]:Be.US;return I(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var Ke=(t="",e="")=>(e?.match(t)||[])?.length>0;var We=(t,e="",r={isChecked:!1})=>{if(!r.isChecked)return t===!0?e&&e.trim()!=="":e&&e.trim()==="";if(r.isChecked)return t===!0?e:!e};var Je=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,Qe=(t,e="")=>t===!0?!!e.match(Je):!e.match(Je);var Ye=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Xe=(t,e="")=>t===!0?!!e.match(Ye):!e.match(Ye);var et=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/,tt=(t,e="")=>t===!0?!!e.match(et):!e.match(et);var rt=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,ot=(t,e="")=>t===!0?!!e.match(rt):!e.match(rt);var it={AT:/^(AT)(U\d{8}$)/i,BE:/^(BE)(\d{10}$)/i,BG:/^(BG)(\d{9,10}$)/i,CY:/^(CY)([0-5|9]\d{7}[A-Z]$)/i,CZ:/^(CZ)(\d{8,10})?$/i,DE:/^(DE)([1-9]\d{8}$)/i,DK:/^(DK)(\d{8}$)/i,EE:/^(EE)(10\d{7}$)/i,EL:/^(EL)(\d{9}$)/i,ES:/^(ES)([0-9A-Z][0-9]{7}[0-9A-Z]$)/i,EU:/^(EU)(\d{9}$)/i,FI:/^(FI)(\d{8}$)/i,FR:/^(FR)([0-9A-Z]{2}[0-9]{9}$)/i,GB:/^(GB)((?:[0-9]{12}|[0-9]{9}|(?:GD|HA)[0-9]{3})$)/i,GR:/^(GR)(\d{8,9}$)/i,HR:/^(HR)(\d{11}$)/i,HU:/^(HU)(\d{8}$)/i,IE:/^(IE)([0-9A-Z\*\+]{7}[A-Z]{1,2}$)/i,IT:/^(IT)(\d{11}$)/i,LV:/^(LV)(\d{11}$)/i,LT:/^(LT)(\d{9}$|\d{12}$)/i,LU:/^(LU)(\d{8}$)/i,MT:/^(MT)([1-9]\d{7}$)/i,NL:/^(NL)(\d{9}B\d{2}$)/i,NO:/^(NO)(\d{9}$)/i,PL:/^(PL)(\d{10}$)/i,PT:/^(PT)(\d{9}$)/i,RO:/^(RO)([1-9]\d{1,9}$)/i,RU:/^(RU)(\d{10}$|\d{12}$)/i,RS:/^(RS)(\d{9}$)/i,SI:/^(SI)([1-9]\d{7}$)/i,SK:/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i,SE:/^(SE)(\d{10}01$)/i},nt=(t,e="")=>{let r=I(t)&&t.iso?it[t.iso||"EU"]:it.EU;return I(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var st={creditCard:De,custom:Pe,email:Ve,equals:Ne,matches:Ue,maxLength:qe,minLength:ze,phone:Ze,postalCode:Ge,regex:Ke,required:We,semVer:Qe,slug:Xe,strongPassword:tt,url:ot,vat:nt};var at=class{constructor(e,r={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={creditCard:()=>"Must be a valid credit card number.",custom:()=>"Must return true.",email:()=>"Must be a valid email.",equals:o=>`Value must equal ${o}.`,matches:o=>`Field must match ${o}.`,maxLength:o=>`Field value can be no greater than ${o}.`,minLength:o=>`Field value can be no less than ${o}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",regex:()=>"Must match regex.",required:()=>"This field is required.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},e||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=e,this.setOptions(r),this.attachEventListeners()}setOptions(e={}){this.rules=e.rules||{},this.messages=e.messages||{},this.onSubmit=e.onSubmit,this.onRenderError=e.onRenderError,this.fields=this.serialize()}updateOptions(e={}){this.setOptions(e)}serialize(){if(this.form)return Object.keys(this.rules).map(r=>{let o=this.form.querySelector(`[name="${r}"]`),i=o?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(i),type:i,name:r,element:o,validations:Object.entries(this.rules[r]).map(([c,a])=>({name:c,rule:a,valid:!1})).sort((c,a)=>c.name>a.name?1:-1),errorMessages:this.messages[r]?Object.keys(this.messages[r]):{}}})?.filter(r=>!!r?.element)}attachEventListeners(){if(this.form){let e=r=>{r.stopPropagation(),r.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let r=0;r<this.form.listeners.length;r+=1){let o=this.form.listeners[r];this.form.removeEventListener("submit",o)}this.form.addEventListener("submit",e),this.form.listeners=[...this.form.listeners||[],e]}this.fields.forEach(e=>{if(e?.element&&e?.listenForChanges){let r=()=>{Re(()=>{this.validate(e.name)},100)};e.element.removeEventListener("input",r),e.element.addEventListener("input",r),e.element.removeEventListener("change",r),e.element.addEventListener("change",r)}})}validate(e=null){if(e){let r=this.fields.find(o=>o.name===e);return this.clearExistingError(e),this.validateField(r),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(r=>{this.validateField(r)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(r=>r.validations.some(o=>!o.valid)).includes(!0)}validateField(e){let r=this.form.querySelector(`[name="${e.name}"]`),o=["checkbox","radio"].includes(e.type),i=o?null:e?.element?.value?.trim(),s=o?e?.element?.checked:null;e.validations.forEach(a=>{if(this.isValidValue(o,o?s:i,a))this.markValidationAsValid(e,a.name);else{let m=this.messages[e.name]&&this.messages[e.name][a.name];this.markValidationAsInvalid(e,a.name),this.renderError(e.element,m||this.defaultValidationErrors[a.name](a.rule,i))}});let c=e.validations.some(a=>!a.valid);return c&&(r.classList.add("error"),r.focus()),c||(r.classList.remove("error"),this.clearExistingError(e.name)),!c}markValidationAsInvalid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!1}markValidationAsValid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!0}isValidValue(e,r,o){let i=st[o.name];return i?i(o.rule,r,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.parentNode.removeChild(e))}clearExistingError(e=""){let r=document.getElementById(`error-${e}`);r&&r.parentNode.removeChild(r)}renderError(e,r=""){if(e){if(this.clearExistingError(e.name),typeof this.onRenderError=="function")return this.onRenderError(e,r);let o=document.createElement("p");o.classList.add("input-hint"),o.classList.add("error"),o.setAttribute("id",`error-${e.name}`),o.innerText=r,e.after(o)}}},lr=(t,e)=>new Promise((r,o)=>{try{new at(t,e).validate()?r():o()}catch(i){console.warn(i)}}),dt=lr;var ct=(t={},e={})=>{try{return[...Object.keys(e),...Object.keys(t)].filter((o,i,s)=>s.indexOf(o)===i).reduce((o,i)=>{let s=e[i],c=t[i]||null,a=!ye(s)&&!xe(s);return o[i]=a?s:c,o},{})}catch(r){n("component.props.compile",r)}};var lt=(t="",e={})=>{try{let r="";if(t&&O(t))return r=t,r;if(t&&l(t))return r=t(e),r;if(t&&u(t)){let o=t?.print&&(O(t?.print)||l(t?.print)),i=t?.min&&u(t?.min),s=t?.min?.width&&u(t?.min?.width),c=t?.min?.height&&u(t?.min?.height),a=t?.max&&u(t?.max),m=t?.max?.width&&u(t?.max?.width),x=t?.max?.height&&u(t?.max?.height);if(o&&(r+=`
2
2
  @media print {
3
3
  ${typeof t?.print=="function"?t?.print(e):t.print}
4
4
  }
@@ -1 +1 @@
1
- var $=(()=>{let r=0;return(e,t)=>{clearTimeout(r),r=setTimeout(e,t)}})();var n=r=>!!(r&&typeof r=="object"&&!Array.isArray(r));var m=r=>typeof r=="string";var l=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,c=(r,e="")=>{if(!e)return!0;if(e&&!m(e))return!1;let t=e?e.replace(/[- ]+/g,""):"";return r===!0?t.match(new RegExp(l)):!t.match(new RegExp(l))};var u=(r="",e="")=>r(e);var h=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0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}$/,SM:/^4789\d$/,SA:/^\d{5}(-{1}\d{4})?$/,SN:/^\d{5}$/,RS:/^\d{5}$/,SG:/^\d{2}$/,SK:/^\d{5}\s\(\d{3}\s\d{2}\)$/,SI:/^([Ss][Ii][- ]{0,1}){0,1}\d{4}$/,ZA:/^\d{4}$/,GS:/^[Ss][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,ES:/^\d{5}$/,LK:/^\d{5}$/,SD:/^\d{5}$/,SZ:/^[A-Za-z]\d{3}$/,SE:/^\d{3}\s*\d{2}$/,CH:/^\d{4}$/,SJ:/^\d{4}$/,TW:/^\d{5}$/,TJ:/^\d{6}$/,TH:/^\d{5}$/,TT:/^\d{6}$/,TN:/^\d{4}$/,TR:/^\d{5}$/,TM:/^\d{6}$/,TC:/^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,UA:/^\d{5}$/,GB:/^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,US:/^\b\d{5}\b(?:[- ]{1}\d{4})?$/,UY:/^\d{5}$/,VI:/^\d{5}$/,UZ:/^\d{3} \d{3}$/,VA:/^120$/,VE:/^\d{4}(\s[a-zA-Z]{1})?$/,VN:/^\d{6}$/,WF:/^986\d{2}$/,ZM:/^\d{5}$/},z=(r,e="")=>{let t=n(r)&&r.iso?L[r.iso||"US"]:L.US;return n(r)?r.rule===!0?!!e.match(t):!e.match(t):r===!0?!!e.match(t):!e.match(t)};var b=(r="",e="")=>(e?.match(r)||[])?.length>0;var C=(r,e="",t={isChecked:!1})=>{if(!t.isChecked)return r===!0?e&&e.trim()!=="":e&&e.trim()==="";if(t.isChecked)return r===!0?e:!e};var V=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-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:/^(RO)([1-9]\d{1,9}$)/i,RU:/^(RU)(\d{10}$|\d{12}$)/i,RS:/^(RS)(\d{9}$)/i,SI:/^(SI)([1-9]\d{7}$)/i,SK:/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i,SE:/^(SE)(\d{10}01$)/i},N=(r,e="")=>{let t=n(r)&&r.iso?G[r.iso||"EU"]:G.EU;return n(r)?r.rule===!0?!!e.match(t):!e.match(t):r===!0?!!e.match(t):!e.match(t)};var U={creditCard:c,custom:u,email:f,equals:p,matches:x,maxLength:A,minLength:E,phone:Z,postalCode:z,regex:b,required:C,semVer:M,slug:T,strongPassword:F,url:R,vat:N};var B=class{constructor(e,t={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={creditCard:()=>"Must be a valid credit card number.",custom:()=>"Must return true.",email:()=>"Must be a valid email.",equals:d=>`Value must equal ${d}.`,matches:d=>`Field must match ${d}.`,maxLength:d=>`Field value can be no greater than ${d}.`,minLength:d=>`Field value can be no less than ${d}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",regex:()=>"Must match regex.",required:()=>"This field is required.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},e||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=e,this.setOptions(t),this.attachEventListeners()}setOptions(e={}){this.rules=e.rules||{},this.messages=e.messages||{},this.onSubmit=e.onSubmit,this.onRenderError=e.onRenderError,this.fields=this.serialize()}updateOptions(e={}){this.setOptions(e)}serialize(){if(this.form)return Object.keys(this.rules).map(t=>{let d=this.form.querySelector(`[name="${t}"]`),s=d?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(s),type:s,name:t,element:d,validations:Object.entries(this.rules[t]).map(([o,i])=>({name:o,rule:i,valid:!1})).sort((o,i)=>o.name>i.name?1:-1),errorMessages:this.messages[t]?Object.keys(this.messages[t]):{}}})}attachEventListeners(){if(this.form){let e=t=>{t.stopPropagation(),t.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let t=0;t<this.form.listeners.length;t+=1){let d=this.form.listeners[t];this.form.removeEventListener("submit",d)}this.form.addEventListener("submit",e),this.form.listeners=[...this.form.listeners||[],e]}this.fields.forEach(e=>{if(e?.element&&e?.listenForChanges){let t=()=>{$(()=>{this.validate(e.name)},100)};e.element.removeEventListener("input",t),e.element.addEventListener("input",t),e.element.removeEventListener("change",t),e.element.addEventListener("change",t)}})}validate(e=null){if(e){let t=this.fields.find(d=>d.name===e);return this.clearExistingError(e),this.validateField(t),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(t=>{this.validateField(t)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(t=>t.validations.some(d=>!d.valid)).includes(!0)}validateField(e){let t=this.form.querySelector(`[name="${e.name}"]`),d=["checkbox","radio"].includes(e.type),s=d?null:e?.element?.value?.trim(),a=d?e?.element?.checked:null;e.validations.forEach(i=>{if(!!t&&!this.isValidValue(d,d?a:s,i)){let O=this.messages[e.name]&&this.messages[e.name][i.name];this.markValidationAsInvalid(e,i.name),this.renderError(e.element,O||this.defaultValidationErrors[i.name](i.rule,s))}else this.markValidationAsValid(e,i.name)});let o=e.validations.some(i=>!i.valid);return o&&(t.classList.add("error"),t.focus()),o||(t.classList.remove("error"),this.clearExistingError(e.name)),!o}markValidationAsInvalid(e,t){let s=[...e.validations].find(a=>a.name===t);s.valid=!1}markValidationAsValid(e,t){let s=[...e.validations].find(a=>a.name===t);s.valid=!0}isValidValue(e,t,d){let s=U[d.name];return s?s(d.rule,t,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.parentNode.removeChild(e))}clearExistingError(e=""){let t=document.getElementById(`error-${e}`);t&&t.parentNode.removeChild(t)}renderError(e,t=""){if(e){if(this.clearExistingError(e.name),typeof this.onRenderError=="function")return this.onRenderError(e,t);let d=document.createElement("p");d.classList.add("input-hint"),d.classList.add("error"),d.setAttribute("id",`error-${e.name}`),d.innerText=t,e.after(d)}}},P=(r,e)=>new Promise((t,d)=>{try{new B(r,e).validate()?t():d()}catch(s){console.warn(s)}}),Ve=P;export{Ve as default};
1
+ var $=(()=>{let r=0;return(e,t)=>{clearTimeout(r),r=setTimeout(e,t)}})();var n=r=>!!(r&&typeof r=="object"&&!Array.isArray(r));var m=r=>typeof r=="string";var l=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,c=(r,e="")=>{if(!e)return!0;if(e&&!m(e))return!1;let t=e?e.replace(/[- ]+/g,""):"";return r===!0?t.match(new RegExp(l)):!t.match(new RegExp(l))};var u=(r="",e="")=>r(e);var h=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x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4}$/,ZA:/^\d{4}$/,GS:/^[Ss][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,ES:/^\d{5}$/,LK:/^\d{5}$/,SD:/^\d{5}$/,SZ:/^[A-Za-z]\d{3}$/,SE:/^\d{3}\s*\d{2}$/,CH:/^\d{4}$/,SJ:/^\d{4}$/,TW:/^\d{5}$/,TJ:/^\d{6}$/,TH:/^\d{5}$/,TT:/^\d{6}$/,TN:/^\d{4}$/,TR:/^\d{5}$/,TM:/^\d{6}$/,TC:/^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,UA:/^\d{5}$/,GB:/^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,US:/^\b\d{5}\b(?:[- ]{1}\d{4})?$/,UY:/^\d{5}$/,VI:/^\d{5}$/,UZ:/^\d{3} \d{3}$/,VA:/^120$/,VE:/^\d{4}(\s[a-zA-Z]{1})?$/,VN:/^\d{6}$/,WF:/^986\d{2}$/,ZM:/^\d{5}$/},z=(r,e="")=>{let t=n(r)&&r.iso?L[r.iso||"US"]:L.US;return n(r)?r.rule===!0?!!e.match(t):!e.match(t):r===!0?!!e.match(t):!e.match(t)};var b=(r="",e="")=>(e?.match(r)||[])?.length>0;var C=(r,e="",t={isChecked:!1})=>{if(!t.isChecked)return r===!0?e&&e.trim()!=="":e&&e.trim()==="";if(t.isChecked)return r===!0?e:!e};var V=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,M=(r,e="")=>r===!0?!!e.match(V):!e.match(V);var S=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,T=(r,e="")=>r===!0?!!e.match(S):!e.match(S);var I=/^(?=.*?[A-Z])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SE)(\d{10}01$)/i},N=(r,e="")=>{let t=n(r)&&r.iso?G[r.iso||"EU"]:G.EU;return n(r)?r.rule===!0?!!e.match(t):!e.match(t):r===!0?!!e.match(t):!e.match(t)};var U={creditCard:c,custom:u,email:f,equals:p,matches:x,maxLength:A,minLength:E,phone:Z,postalCode:z,regex:b,required:C,semVer:M,slug:T,strongPassword:F,url:R,vat:N};var B=class{constructor(e,t={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={creditCard:()=>"Must be a valid credit card number.",custom:()=>"Must return true.",email:()=>"Must be a valid email.",equals:d=>`Value must equal ${d}.`,matches:d=>`Field must match ${d}.`,maxLength:d=>`Field value can be no greater than ${d}.`,minLength:d=>`Field value can be no less than ${d}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",regex:()=>"Must match regex.",required:()=>"This field is required.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},e||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=e,this.setOptions(t),this.attachEventListeners()}setOptions(e={}){this.rules=e.rules||{},this.messages=e.messages||{},this.onSubmit=e.onSubmit,this.onRenderError=e.onRenderError,this.fields=this.serialize()}updateOptions(e={}){this.setOptions(e)}serialize(){if(this.form)return Object.keys(this.rules).map(t=>{let d=this.form.querySelector(`[name="${t}"]`),s=d?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(s),type:s,name:t,element:d,validations:Object.entries(this.rules[t]).map(([o,i])=>({name:o,rule:i,valid:!1})).sort((o,i)=>o.name>i.name?1:-1),errorMessages:this.messages[t]?Object.keys(this.messages[t]):{}}})?.filter(t=>!!t?.element)}attachEventListeners(){if(this.form){let e=t=>{t.stopPropagation(),t.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let t=0;t<this.form.listeners.length;t+=1){let d=this.form.listeners[t];this.form.removeEventListener("submit",d)}this.form.addEventListener("submit",e),this.form.listeners=[...this.form.listeners||[],e]}this.fields.forEach(e=>{if(e?.element&&e?.listenForChanges){let t=()=>{$(()=>{this.validate(e.name)},100)};e.element.removeEventListener("input",t),e.element.addEventListener("input",t),e.element.removeEventListener("change",t),e.element.addEventListener("change",t)}})}validate(e=null){if(e){let t=this.fields.find(d=>d.name===e);return this.clearExistingError(e),this.validateField(t),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(t=>{this.validateField(t)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(t=>t.validations.some(d=>!d.valid)).includes(!0)}validateField(e){let t=this.form.querySelector(`[name="${e.name}"]`),d=["checkbox","radio"].includes(e.type),s=d?null:e?.element?.value?.trim(),a=d?e?.element?.checked:null;e.validations.forEach(i=>{if(this.isValidValue(d,d?a:s,i))this.markValidationAsValid(e,i.name);else{let O=this.messages[e.name]&&this.messages[e.name][i.name];this.markValidationAsInvalid(e,i.name),this.renderError(e.element,O||this.defaultValidationErrors[i.name](i.rule,s))}});let o=e.validations.some(i=>!i.valid);return o&&(t.classList.add("error"),t.focus()),o||(t.classList.remove("error"),this.clearExistingError(e.name)),!o}markValidationAsInvalid(e,t){let s=[...e.validations].find(a=>a.name===t);s.valid=!1}markValidationAsValid(e,t){let s=[...e.validations].find(a=>a.name===t);s.valid=!0}isValidValue(e,t,d){let s=U[d.name];return s?s(d.rule,t,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.parentNode.removeChild(e))}clearExistingError(e=""){let t=document.getElementById(`error-${e}`);t&&t.parentNode.removeChild(t)}renderError(e,t=""){if(e){if(this.clearExistingError(e.name),typeof this.onRenderError=="function")return this.onRenderError(e,t);let d=document.createElement("p");d.classList.add("input-hint"),d.classList.add("error"),d.setAttribute("id",`error-${e.name}`),d.innerText=t,e.after(d)}}},P=(r,e)=>new Promise((t,d)=>{try{new B(r,e).validate()?t():d()}catch(s){console.warn(s)}}),Ve=P;export{Ve as default};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Rr=Object.create;var le=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Dr=Object.getOwnPropertyNames;var Lr=Object.getPrototypeOf,Pr=Object.prototype.hasOwnProperty;var Ir=t=>le(t,"__esModule",{value:!0});var qr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Vr=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Dr(e))!Pr.call(t,o)&&o!=="default"&&le(t,o,{get:()=>e[o],enumerable:!(r=Ar(e,o))||r.enumerable});return t},Nr=t=>Vr(Ir(le(t!=null?Rr(Lr(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var Zt=qr(ne=>{(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof ne!="undefined")e(ne);else{var r={exports:{}};e(r.exports),t.index=r.exports}})(ne,function(t){"use strict";function e(p){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e(p)}function r(p,d){return d&&(e(d)==="object"||typeof d=="function")?d:o(p)}function o(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function n(p){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},n(p)}function s(p,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(d&&d.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),d&&c(p,d)}function c(p,d){return c=Object.setPrototypeOf||function(k,O){return k.__proto__=O,k},c(p,d)}function a(p,d){if(!(p instanceof d))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;var l=function p(d,k){a(this,p),this.type=d,this.path=k?k.toString():""},x=function(p){function d(k,O,w){var L;return a(this,d),L=r(this,n(d).call(this,"E",k)),L.lhs=O,L.rhs=w,L}return s(d,p),d}(l),g=function(p){function d(k,O,w,L){var E;return a(this,d),E=r(this,n(d).call(this,"M",k)),E.item=O,E.lhsIndex=w,E.rhsIndex=L,E}return s(d,p),d}(l),b=function(p){function d(k,O){var w;return a(this,d),w=r(this,n(d).call(this,"D",k)),w.lhs=O,w}return s(d,p),d}(l),R=function(p){function d(k,O){var w;return a(this,d),w=r(this,n(d).call(this,"A",k)),w.rhs=O,w}return s(d,p),d}(l),h=function(p,d){return p?"".concat(p,".").concat(d):d};t.diff=function(d,k){var O=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},w=[],L=O.matchKey,E=O.types||["E","A","D","M"],jr=function(F,$,T,I){F.forEach(function(P,_){var j=$.findIndex(function(C){return C[I]===P[I]});-1<j?(-1<E.indexOf("M")&&_!==j&&w.push(new g(T,P,_,j)),J(P,$[j],h(T,j))):-1<E.indexOf("D")&&w.push(new b(T,P))}),$.forEach(function(P,_){var j=F.findIndex(function(C){return P[I]===C[I]});-1<E.indexOf("A")&&j===-1&&w.push(new R(h(T,_),P))})},J=function(F,$,T){var I=Object.prototype.toString.call(F),P=Object.prototype.toString.call($);if(-1<E.indexOf("E")&&I!==P)return w.push(new x(T,F,$)),!1;if(I==="[object Object]")Object.getOwnPropertyNames(F).forEach(function(C){Object.prototype.hasOwnProperty.call($,C)?J(F[C],$[C],h(T,C)):-1<E.indexOf("D")&&w.push(new b(h(T,C),F[C]))}),Object.getOwnPropertyNames($).forEach(function(C){-1<E.indexOf("A")&&!Object.prototype.hasOwnProperty.call(F,C)&&w.push(new R(h(T,C),$[C]))});else if(I!=="[object Array]")-1<E.indexOf("E")&&F!==$&&w.push(new x(T,F,$));else if(L)jr(F,$,T,L);else{var _=F.length-1,j=$.length-1;if(-1<E.indexOf("D"))for(;_>j;)w.push(new b(h(T,_),F[_--]));if(-1<E.indexOf("A"))for(;j>_;)w.push(new R(h(T,j),$[j--]));for(;0<=_;--_)J(F[_],$[_],h(T,_))}};return J(d,k),w}})});var H=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var i=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var A=(t="",e=[])=>{try{console.error(`${t} failed with the following errors:`),e.forEach(r=>{console.log(r.message),r.stack&&console.log(r.stack)})}catch(r){i(t,r)}};var Hr=async(t={})=>{try{let e=await t.text();return H(e)}catch(e){i("accounts.request.handleParseResponse",e)}},Ur=(t="GET",e={})=>{try{return["POST"].includes(t)?JSON.stringify({...e,origin:window?.location?.origin}):null}catch(r){i("accounts.request.getBody",r)}},zr=(t=null)=>{try{switch(t){case"authenticated":case"user":return"GET";default:return"POST"}}catch(e){i("accounts.request.getHTTPMethod",e)}},v=(t="",e={})=>{try{if(typeof window.fetch!="undefined")return new Promise((r,o)=>{let n=`${window.location.origin}/api/_accounts/${t}`,s=zr(t),c=Ur(s,e);return fetch(n,{method:s,mode:"cors",headers:{"Content-Type":"application/json"},body:c,credentials:"include"}).then(async a=>{let l=await Hr(a);return l?.errors?(A(`accounts.${t}`,l.errors),o(l)):r(l)}).catch(a=>(A(`accounts.${t}`,[a]),o({errors:[a]})))})}catch(r){i(`accounts.request.${t}`,r)}};var $e=async(t={})=>{try{let e=await v("authenticated",t);return e?.status===200&&e?.authenticated}catch(e){i("accounts.authenticated",e)}};var ke=(t={})=>{try{return v("login",t)}catch(e){i("accounts.login",e)}};var Ee=()=>{try{return v("logout")}catch(t){i("accounts.logout",t)}};var Fe=(t={})=>{try{return v("recover-password",t)}catch(e){i("accounts.recoverPassword",e)}};var Me=(t={})=>{try{return v("reset-password",t)}catch(e){i("accounts.resetPassword",e)}};var Se=(t={})=>{try{return v("signup",t)}catch(e){i("accounts.signup",e)}};var Te=async(t={})=>{try{let e=await v("user",t);return e?.status===200&&e?.user}catch(e){i("accounts.user",e)}};var _e={authenticated:$e,login:ke,logout:Ee,recoverPassword:Fe,resetPassword:Me,signup:Se,user:Te};var Ce=t=>{try{return typeof t=="undefined"}catch(e){i("types.isUndefined",e)}},ve=t=>{try{return t===null}catch(e){i("types.isNull",e)}},Oe=t=>{try{return!0}catch(e){i("types.isDOM",e)}},q=t=>{try{return!!Array.isArray(t)}catch(e){i("types.isArray",e)}};var u=t=>{try{return typeof t=="function"}catch(e){i("types.isFunction",e)}};var m=t=>{try{return!!(t&&typeof t=="object"&&!Array.isArray(t))}catch(e){i("types.isObject",e)}};var M=t=>{try{return typeof t=="string"}catch(e){i("types.isString",e)}};var je=class{constructor(e="",r={}){this.name=e,this.value=r||{},this.listeners={change:[],set:[],unset:[]}}_getValueAtPath(e=""){return e?.split(".").reduce((r=null,o="")=>(r[o]&&(r=r[o]),r),this.value)}get(e=""){return e?.trim()===""?{...this.value||{}}:this._getValueAtPath(e)}set(e=null,r=""){if(!e||!u(e))throw new Error("First argument passed to set() must be a function.");let o=e(this.value);if(!m(o))throw new Error("Value to set must be an object representing the current cache state.");this.value=o,this._handleEvent(r,"set"),this._handleEvent(r,"change")}unset(e="",r=""){e?.trim()===""&&(this.value={});let o=e?.split("."),n=o?.length-1;o.reduce((s,c,a)=>(a===n&&delete s[c],s[c]),this.value),this._handleEvent(r,"unset"),this._handleEvent(r,"change")}on(e="",r=null){if(!["change","set","unset"].includes(e))throw new Error(`Event to listen for must be change, set, or unset. ${e} is not supported.`);if(!r||!u(r))throw new Error("Second argument passed to on("<e>") must be a function.");this.listeners={[e]:[...this.listeners[e]||[],r]}}_handleEvent(e="",r=""){let o=this.listeners[r]||[];for(let n=0;n<o?.length;n+=1){let s=o[n];u(s)&&s(this.value,e,r)}}},Re=je;var Ae=(t="",e={})=>{try{if(!t||t&&!M(t))throw new Error("Must pass a cache name as a string.");if(e&&!m(e))throw new Error("Default value for cache must be an object.");return new Re(t,e)}catch(r){i("cache",r)}};var De=(t="")=>joystick._external[t]?joystick._external[t]:null;var Le=(t="")=>t;var S=()=>typeof window=="undefined";var Pe=(t={},e={})=>{let r=t({props:e}),o=r.renderToHTML();return S()||r.appendCSSToHead(),o?.wrapped};var Ie=(t=128,e="test.txt",r="text/plain")=>{let o=t instanceof Blob;return new File(o?t:new Blob(new Uint8Array(t||128),{type:r}),e,{type:r})};var y=(t="",e=[])=>{typeof window!="undefined"&&!!window.__joystick_test__&&(window.test={...window.test||{},functionCalls:{...window?.test?.functionCalls||{},[t]:[...window?.test?.functionCalls&&window?.test?.functionCalls[t]||[],{calledAt:new Date().toISOString(),args:e}]}})};var qe={utils:{createFile:Ie,trackFunctionCall:y}};var ue=(t="",e={})=>{typeof window!="undefined"&&(joystick._external[t]={...joystick._external[t]||{},...e})};var Ve="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),f=(t=16)=>{let e="",r=0;for(;r<t;)e+=Ve[Math.floor(Math.random()*(Ve.length-1))],r+=1;return e};var U=null,Q=0,Ne=(t={},e=null)=>{try{if(window?.__joystick_test__)return e();let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);U&&(clearInterval(U),U=null);let n={client:o,send:(s={})=>(y(`ui.websockets.${t?.test?.name||f()}.send`,[s]),o.send(JSON.stringify(s)))};return o.addEventListener("open",()=>{t?.options?.logging&&console.log(`[joystick.websockets] Connected to ${t?.url}`),t?.events?.onOpen&&(t.events.onOpen(n),y(`ui.websockets.${t?.test?.name||f()}.onOpen`,[n])),Q=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&(t.events.onMessage(JSON.parse(s.data||{}),n),y(`ui.websockets.${t?.test?.name||f()}.onMessage`,[s.data||{},n]))}),o.addEventListener("close",s=>{t?.options?.logging&&console.log(`[joystick.websockets] Disconnected from ${t?.url}`),t?.events?.onClose&&(t.events.onClose(s?.code,s?.reason,n),y(`ui.websockets.${t?.test?.name||f()}.onClose`,[s.data||{},n])),o=null;let c=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!U&&!c&&(U=setInterval(()=>{o=null,Q<(t?.options?.reconnectAttempts||12)?(Ne(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${Q+1}/12)...`),Q+=1):clearInterval(U)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(n),n}catch(r){i("websockets.client",r)}},Y=Ne;var He=(t="",e={})=>{try{if(window?.__joystick_test__){y(`ui.upload.${t}`,[t,e]);return}return new Promise((r,o)=>{let n=f(),s=0;Y({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/uploaders`,options:{logging:!1,autoReconnect:!0,reconnectAttempts:12,reconnectDelayInSeconds:5},query:{id:n},events:{onMessage:(c={})=>{c?.type==="PROGRESS"&&e?.onProgress&&s<100&&s!==c?.progress&&(s=c?.progress,e.onProgress(c?.progress,c?.provider))}}},()=>{let c;e?.files?.length>0&&(c=new FormData,Array.from(e?.files).forEach(a=>{c.append("files",a,a.name)})),fetch(`${window.location.origin}/api/_uploaders/${t}`,{method:"POST",headers:{"x-joystick-upload-id":n,"x-joystick-upload-input":JSON.stringify(e?.input||{})},body:c}).then(async a=>{let l=await a.json();console.log(l),l&&l.errors?(A("upload",l.errors),o({errors:l.errors})):r(l?.uploads)})})})}catch(r){i("upload",r)}};var Ue=(t={})=>{try{let e=null;typeof window!="undefined"&&(e=window),typeof global!="undefined"&&(e=global),e&&(e.joystick={...e?.joystick||{},settings:e?.__joystick_settings__,...t})}catch(e){i("attachJoystickToWindow",e)}};var ze=(t={})=>Object.entries(t).map(([e,r])=>`${e}=${r}`)?.join("; ");var Br=async(t={})=>{try{let e=await t.text();return H(e)}catch(e){i("api.get.handleParseResponse",e)}},Be=(t="",e={})=>{try{return typeof window.fetch!="undefined"&&!e?.skip?new Promise((r,o)=>{let n=e.input?JSON.stringify(e.input):null,s=e.output?JSON.stringify(e.output):null,c=`${window.location.origin}/api/_getters/${t}?input=${n}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content"),l={...e?.headers||{},"x-joystick-csrf":a};return window?.__joystick_test__&&(l.Cookie=ze({joystickLoginToken:window.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expires_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(c,{method:"GET",mode:"cors",headers:l,credentials:"include"}).then(async x=>{let g=await Br(x);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),g?.errors?(A("get request",g.errors),o(g)):r(g)}).catch(x=>(A("get request",[x]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[x]})))}):Promise.resolve()}catch(r){i("get request",r)}};var Zr=async(t={})=>{try{let e=await t.text();return H(e)}catch(e){i("api.set.handleParseResponse",e)}},Gr=(t={})=>{try{let e={...t};return e?.loader&&delete e.loader,JSON.stringify(e)}catch(e){i("api.set.getBody",e)}},Ze=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let n=`${window.location.origin}/api/_setters/${t}`,s=Gr(e),c=document.querySelector('[name="csrf"]')?.getAttribute("content"),a={...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":c};return window?.__joystick_test__&&(a.Cookie=generateCookieHeader({joystickLoginToken:window?.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expirs_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(n,{method:"POST",mode:"cors",headers:a,body:s,credentials:"include"}).then(async l=>{let x=await Zr(l);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),x?.errors?(A("set request",x.errors),o(x)):r(x)}).catch(l=>(A("set request",[l]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[l]})))}):Promise.resolve()}catch(r){i("set request",r)}};var G={get:Be,set:Ze};var Ge=["render"];var We=(t={})=>{try{return Ge.every(e=>Object.keys(t).includes(e))}catch(e){i("component.hasAllRequiredOptions",e)}};var Ke=["_componentId","_ssrId","api","dataFromSSR","existingProps","existingState","instanceId","parent","req","css","data","defaultProps","events","id","lifecycle","methods","name","props","render","state","test","translations","url","websockets","wrapper"];var Je=(t=null)=>{try{!M(t)&&!u(t)&&!m(t)&&i("component.optionValidators.css","options.css must be a string, function returning a string, or an object returning breakpoints.")}catch(e){i("component.optionValidators.css",e)}};var Qe=["readystatechange","pointerlockchange","pointerlockerror","beforecopy","beforecut","beforepaste","freeze","resume","search","securitypolicyviolation","visibilitychange","fullscreenchange","fullscreenerror","webkitfullscreenchange","webkitfullscreenerror","beforexrselect","abort","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","formdata","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","pause","play","playing","progress","ratechange","reset","resize","scroll","seeked","seeking","select","stalled","submit","suspend","timeupdate","toggle","volumechange","waiting","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","wheel","auxclick","gotpointercapture","lostpointercapture","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerout","pointerenter","pointerleave","selectstart","selectionchange","animationend","animationiteration","animationstart","transitionrun","transitionstart","transitionend","transitioncancel","copy","cut","paste","pointerrawupdate"];var Ye=(t=null)=>{try{m(t)||i("component.optionValidators.events","options.events must be an object.");for(let e of Object.keys(t)){let[r]=e.split(" ");Qe.includes(r)||i("component.optionValidators.events",`${r} is not a supported JavaScript event type.`)}for(let[e,r]of Object.entries(t))u(r)||i("component.optionValidators.events",`options.events.${e} must be assigned a function.`)}catch(e){i("component.optionValidators.events",e)}};var Xe=["onBeforeMount","onMount","onUpdateProps","onBeforeUnmount","onRefetchData"];var et=(t=null)=>{try{m(t)||i("component.optionValidators.lifecycle","options.lifecycle must be an object.");for(let[e,r]of Object.entries(t))Xe.includes(e)||i("component.optionValidators.lifecycle",`options.lifecycle.${e} is not supported.`),u(r)||i("component.optionValidators.lifecycle",`options.lifecycle.${e} must be assigned a function.`)}catch(e){i("component.optionValidators.lifecycle",e)}};var tt=(t=null)=>{try{m(t)||i("component.optionValidators.methods","options.methods must be an object.");for(let[e,r]of Object.entries(t))u(r)||i("component.optionValidators.methods",`options.methods.${e} must be assigned a function.`)}catch(e){i("component.optionValidators.methods",e)}};var rt=(t=null)=>{typeof t!="string"&&i("component.optionValidators.name","options.name must be a string.")};var ot=(t=null)=>{try{u(t)||i("component.optionValidators.render","options.render must be a function returning a string.")}catch(e){i("component.optionValidators.render",e)}};var nt=(t=null)=>{try{m(t)||i("component.optionValidators.test","options.test must be an object."),t?.name&&!M(t.name)&&i("component.optionValidators.test","options.test.name must be assigned a string.")}catch(e){i("component.optionValidators.test",e)}};var it=(t=null)=>{try{u(t)||i("component.optionValidators.websockets","options.websockets must be a function returning an object.")}catch(e){i("component.optionValidators.websockets",e)}};var st=(t=null)=>{try{m(t)||i("component.optionValidators.wrapper","options.wrapper must be an object.");for(let[e,r]of Object.entries(t))e==="id"&&!M(r)&&i("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned a string.`),e==="classList"&&!q(r)&&i("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned an array of strings.`)}catch(e){i("component.optionValidators.wrapper",e)}};var at={css:Je,events:Ye,lifecycle:et,methods:tt,name:rt,render:ot,test:nt,websockets:it,wrapper:st};var ct=(t={})=>{try{We(t)||i("component.validateOptions",`component options must include ${required.options.join(",")}.`);for(let[e,r]of Object.entries(t)){Ke.includes(e)||i("component.validateOptions",`${e} is not supported by joystick.component.`);let o=at[e];o&&u(o)&&o(r)}}catch(e){i("component.validateOptions",e)}};var X=(t=[],e="")=>{try{return(q(t)&&t.find(o=>o?.componentId===e))?.data||{}}catch(r){i("findComponentDataFromSSR",r)}};var dt=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var z=t=>!!(t&&typeof t=="object"&&!Array.isArray(t));var lt=t=>typeof t=="string";var ut=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,mt=(t,e="")=>{if(!e)return!0;if(e&&!lt(e))return!1;let r=e?e.replace(/[- ]+/g,""):"";return t===!0?r.match(new RegExp(ut)):!r.match(new RegExp(ut))};var pt=(t="",e="")=>t(e);var ft=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))$/,ht=(t,e="")=>t===!0?!!e.match(ft):!e.match(ft);var wt=(t,e="")=>t===e;var yt=(t,e="")=>t===e;var gt=(t,e="")=>e.length<=t;var xt=(t,e="")=>e.length>=t;var bt=/^[\+]?[(]?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$/,SE:/^\d{3}\s*\d{2}$/,CH:/^\d{4}$/,SJ:/^\d{4}$/,TW:/^\d{5}$/,TJ:/^\d{6}$/,TH:/^\d{5}$/,TT:/^\d{6}$/,TN:/^\d{4}$/,TR:/^\d{5}$/,TM:/^\d{6}$/,TC:/^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,UA:/^\d{5}$/,GB:/^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,US:/^\b\d{5}\b(?:[- ]{1}\d{4})?$/,UY:/^\d{5}$/,VI:/^\d{5}$/,UZ:/^\d{3} \d{3}$/,VA:/^120$/,VE:/^\d{4}(\s[a-zA-Z]{1})?$/,VN:/^\d{6}$/,WF:/^986\d{2}$/,ZM:/^\d{5}$/},Et=(t,e="")=>{let r=z(t)&&t.iso?kt[t.iso||"US"]:kt.US;return z(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var Ft=(t="",e="")=>(e?.match(t)||[])?.length>0;var Mt=(t,e="",r={isChecked:!1})=>{if(!r.isChecked)return t===!0?e&&e.trim()!=="":e&&e.trim()==="";if(r.isChecked)return t===!0?e:!e};var St=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,Tt=(t,e="")=>t===!0?!!e.match(St):!e.match(St);var _t=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Ct=(t,e="")=>t===!0?!!e.match(_t):!e.match(_t);var vt=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/,Ot=(t,e="")=>t===!0?!!e.match(vt):!e.match(vt);var jt=/https?:\/\/(www\.)?[-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!!e.match(r):!e.match(r)};var Lt={creditCard:mt,custom:pt,email:ht,equals:wt,matches:yt,maxLength:gt,minLength:xt,phone:$t,postalCode:Et,regex:Ft,required:Mt,semVer:Tt,slug:Ct,strongPassword:Ot,url:Rt,vat:Dt};var Pt=class{constructor(e,r={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={creditCard:()=>"Must be a valid credit card number.",custom:()=>"Must return true.",email:()=>"Must be a valid email.",equals:o=>`Value must equal ${o}.`,matches:o=>`Field must match ${o}.`,maxLength:o=>`Field value can be no greater than ${o}.`,minLength:o=>`Field value can be no less than ${o}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",regex:()=>"Must match regex.",required:()=>"This field is required.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},e||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=e,this.setOptions(r),this.attachEventListeners()}setOptions(e={}){this.rules=e.rules||{},this.messages=e.messages||{},this.onSubmit=e.onSubmit,this.onRenderError=e.onRenderError,this.fields=this.serialize()}updateOptions(e={}){this.setOptions(e)}serialize(){if(this.form)return Object.keys(this.rules).map(r=>{let o=this.form.querySelector(`[name="${r}"]`),n=o?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(n),type:n,name:r,element:o,validations:Object.entries(this.rules[r]).map(([c,a])=>({name:c,rule:a,valid:!1})).sort((c,a)=>c.name>a.name?1:-1),errorMessages:this.messages[r]?Object.keys(this.messages[r]):{}}})}attachEventListeners(){if(this.form){let e=r=>{r.stopPropagation(),r.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let r=0;r<this.form.listeners.length;r+=1){let o=this.form.listeners[r];this.form.removeEventListener("submit",o)}this.form.addEventListener("submit",e),this.form.listeners=[...this.form.listeners||[],e]}this.fields.forEach(e=>{if(e?.element&&e?.listenForChanges){let r=()=>{dt(()=>{this.validate(e.name)},100)};e.element.removeEventListener("input",r),e.element.addEventListener("input",r),e.element.removeEventListener("change",r),e.element.addEventListener("change",r)}})}validate(e=null){if(e){let r=this.fields.find(o=>o.name===e);return this.clearExistingError(e),this.validateField(r),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(r=>{this.validateField(r)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(r=>r.validations.some(o=>!o.valid)).includes(!0)}validateField(e){let r=this.form.querySelector(`[name="${e.name}"]`),o=["checkbox","radio"].includes(e.type),n=o?null:e?.element?.value?.trim(),s=o?e?.element?.checked:null;e.validations.forEach(a=>{if(!!r&&!this.isValidValue(o,o?s:n,a)){let l=this.messages[e.name]&&this.messages[e.name][a.name];this.markValidationAsInvalid(e,a.name),this.renderError(e.element,l||this.defaultValidationErrors[a.name](a.rule,n))}else this.markValidationAsValid(e,a.name)});let c=e.validations.some(a=>!a.valid);return c&&(r.classList.add("error"),r.focus()),c||(r.classList.remove("error"),this.clearExistingError(e.name)),!c}markValidationAsInvalid(e,r){let n=[...e.validations].find(s=>s.name===r);n.valid=!1}markValidationAsValid(e,r){let n=[...e.validations].find(s=>s.name===r);n.valid=!0}isValidValue(e,r,o){let n=Lt[o.name];return n?n(o.rule,r,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.parentNode.removeChild(e))}clearExistingError(e=""){let r=document.getElementById(`error-${e}`);r&&r.parentNode.removeChild(r)}renderError(e,r=""){if(e){if(this.clearExistingError(e.name),typeof this.onRenderError=="function")return this.onRenderError(e,r);let o=document.createElement("p");o.classList.add("input-hint"),o.classList.add("error"),o.setAttribute("id",`error-${e.name}`),o.innerText=r,e.after(o)}}},Wr=(t,e)=>new Promise((r,o)=>{try{new Pt(t,e).validate()?r():o()}catch(n){console.warn(n)}}),It=Wr;var qt=(t={},e={})=>{try{return[...Object.keys(e),...Object.keys(t)].filter((o,n,s)=>s.indexOf(o)===n).reduce((o,n)=>{let s=e[n],c=t[n]||null,a=!Ce(s)&&!ve(s);return o[n]=a?s:c,o},{})}catch(r){i("component.props.compile",r)}};var ee=(t="",e={})=>{try{let r="";if(t&&M(t))return r=t,r;if(t&&u(t))return r=t(e),r;if(t&&m(t)){let o=t?.print&&(M(t?.print)||u(t?.print)),n=t?.min&&m(t?.min),s=t?.min?.width&&m(t?.min?.width),c=t?.min?.height&&m(t?.min?.height),a=t?.max&&m(t?.max),l=t?.max?.width&&m(t?.max?.width),x=t?.max?.height&&m(t?.max?.height);if(o&&(r+=`
1
+ var Rr=Object.create;var le=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Dr=Object.getOwnPropertyNames;var Lr=Object.getPrototypeOf,Pr=Object.prototype.hasOwnProperty;var Ir=t=>le(t,"__esModule",{value:!0});var qr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Vr=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Dr(e))!Pr.call(t,o)&&o!=="default"&&le(t,o,{get:()=>e[o],enumerable:!(r=Ar(e,o))||r.enumerable});return t},Nr=t=>Vr(Ir(le(t!=null?Rr(Lr(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var Zt=qr(ne=>{(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof ne!="undefined")e(ne);else{var r={exports:{}};e(r.exports),t.index=r.exports}})(ne,function(t){"use strict";function e(p){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e(p)}function r(p,d){return d&&(e(d)==="object"||typeof d=="function")?d:o(p)}function o(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function n(p){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},n(p)}function s(p,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(d&&d.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),d&&c(p,d)}function c(p,d){return c=Object.setPrototypeOf||function(k,O){return k.__proto__=O,k},c(p,d)}function a(p,d){if(!(p instanceof d))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;var l=function p(d,k){a(this,p),this.type=d,this.path=k?k.toString():""},x=function(p){function d(k,O,w){var L;return a(this,d),L=r(this,n(d).call(this,"E",k)),L.lhs=O,L.rhs=w,L}return s(d,p),d}(l),g=function(p){function d(k,O,w,L){var E;return a(this,d),E=r(this,n(d).call(this,"M",k)),E.item=O,E.lhsIndex=w,E.rhsIndex=L,E}return s(d,p),d}(l),b=function(p){function d(k,O){var w;return a(this,d),w=r(this,n(d).call(this,"D",k)),w.lhs=O,w}return s(d,p),d}(l),R=function(p){function d(k,O){var w;return a(this,d),w=r(this,n(d).call(this,"A",k)),w.rhs=O,w}return s(d,p),d}(l),h=function(p,d){return p?"".concat(p,".").concat(d):d};t.diff=function(d,k){var O=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},w=[],L=O.matchKey,E=O.types||["E","A","D","M"],jr=function(F,$,T,I){F.forEach(function(P,_){var j=$.findIndex(function(C){return C[I]===P[I]});-1<j?(-1<E.indexOf("M")&&_!==j&&w.push(new g(T,P,_,j)),J(P,$[j],h(T,j))):-1<E.indexOf("D")&&w.push(new b(T,P))}),$.forEach(function(P,_){var j=F.findIndex(function(C){return P[I]===C[I]});-1<E.indexOf("A")&&j===-1&&w.push(new R(h(T,_),P))})},J=function(F,$,T){var I=Object.prototype.toString.call(F),P=Object.prototype.toString.call($);if(-1<E.indexOf("E")&&I!==P)return w.push(new x(T,F,$)),!1;if(I==="[object Object]")Object.getOwnPropertyNames(F).forEach(function(C){Object.prototype.hasOwnProperty.call($,C)?J(F[C],$[C],h(T,C)):-1<E.indexOf("D")&&w.push(new b(h(T,C),F[C]))}),Object.getOwnPropertyNames($).forEach(function(C){-1<E.indexOf("A")&&!Object.prototype.hasOwnProperty.call(F,C)&&w.push(new R(h(T,C),$[C]))});else if(I!=="[object Array]")-1<E.indexOf("E")&&F!==$&&w.push(new x(T,F,$));else if(L)jr(F,$,T,L);else{var _=F.length-1,j=$.length-1;if(-1<E.indexOf("D"))for(;_>j;)w.push(new b(h(T,_),F[_--]));if(-1<E.indexOf("A"))for(;j>_;)w.push(new R(h(T,j),$[j--]));for(;0<=_;--_)J(F[_],$[_],h(T,_))}};return J(d,k),w}})});var H=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var i=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var A=(t="",e=[])=>{try{console.error(`${t} failed with the following errors:`),e.forEach(r=>{console.log(r.message),r.stack&&console.log(r.stack)})}catch(r){i(t,r)}};var Hr=async(t={})=>{try{let e=await t.text();return H(e)}catch(e){i("accounts.request.handleParseResponse",e)}},Ur=(t="GET",e={})=>{try{return["POST"].includes(t)?JSON.stringify({...e,origin:window?.location?.origin}):null}catch(r){i("accounts.request.getBody",r)}},zr=(t=null)=>{try{switch(t){case"authenticated":case"user":return"GET";default:return"POST"}}catch(e){i("accounts.request.getHTTPMethod",e)}},v=(t="",e={})=>{try{if(typeof window.fetch!="undefined")return new Promise((r,o)=>{let n=`${window.location.origin}/api/_accounts/${t}`,s=zr(t),c=Ur(s,e);return fetch(n,{method:s,mode:"cors",headers:{"Content-Type":"application/json"},body:c,credentials:"include"}).then(async a=>{let l=await Hr(a);return l?.errors?(A(`accounts.${t}`,l.errors),o(l)):r(l)}).catch(a=>(A(`accounts.${t}`,[a]),o({errors:[a]})))})}catch(r){i(`accounts.request.${t}`,r)}};var $e=async(t={})=>{try{let e=await v("authenticated",t);return e?.status===200&&e?.authenticated}catch(e){i("accounts.authenticated",e)}};var ke=(t={})=>{try{return v("login",t)}catch(e){i("accounts.login",e)}};var Ee=()=>{try{return v("logout")}catch(t){i("accounts.logout",t)}};var Fe=(t={})=>{try{return v("recover-password",t)}catch(e){i("accounts.recoverPassword",e)}};var Me=(t={})=>{try{return v("reset-password",t)}catch(e){i("accounts.resetPassword",e)}};var Se=(t={})=>{try{return v("signup",t)}catch(e){i("accounts.signup",e)}};var Te=async(t={})=>{try{let e=await v("user",t);return e?.status===200&&e?.user}catch(e){i("accounts.user",e)}};var _e={authenticated:$e,login:ke,logout:Ee,recoverPassword:Fe,resetPassword:Me,signup:Se,user:Te};var Ce=t=>{try{return typeof t=="undefined"}catch(e){i("types.isUndefined",e)}},ve=t=>{try{return t===null}catch(e){i("types.isNull",e)}},Oe=t=>{try{return!0}catch(e){i("types.isDOM",e)}},q=t=>{try{return!!Array.isArray(t)}catch(e){i("types.isArray",e)}};var u=t=>{try{return typeof t=="function"}catch(e){i("types.isFunction",e)}};var m=t=>{try{return!!(t&&typeof t=="object"&&!Array.isArray(t))}catch(e){i("types.isObject",e)}};var M=t=>{try{return typeof t=="string"}catch(e){i("types.isString",e)}};var je=class{constructor(e="",r={}){this.name=e,this.value=r||{},this.listeners={change:[],set:[],unset:[]}}_getValueAtPath(e=""){return e?.split(".").reduce((r=null,o="")=>(r[o]&&(r=r[o]),r),this.value)}get(e=""){return e?.trim()===""?{...this.value||{}}:this._getValueAtPath(e)}set(e=null,r=""){if(!e||!u(e))throw new Error("First argument passed to set() must be a function.");let o=e(this.value);if(!m(o))throw new Error("Value to set must be an object representing the current cache state.");this.value=o,this._handleEvent(r,"set"),this._handleEvent(r,"change")}unset(e="",r=""){e?.trim()===""&&(this.value={});let o=e?.split("."),n=o?.length-1;o.reduce((s,c,a)=>(a===n&&delete s[c],s[c]),this.value),this._handleEvent(r,"unset"),this._handleEvent(r,"change")}on(e="",r=null){if(!["change","set","unset"].includes(e))throw new Error(`Event to listen for must be change, set, or unset. ${e} is not supported.`);if(!r||!u(r))throw new Error("Second argument passed to on("<e>") must be a function.");this.listeners={[e]:[...this.listeners[e]||[],r]}}_handleEvent(e="",r=""){let o=this.listeners[r]||[];for(let n=0;n<o?.length;n+=1){let s=o[n];u(s)&&s(this.value,e,r)}}},Re=je;var Ae=(t="",e={})=>{try{if(!t||t&&!M(t))throw new Error("Must pass a cache name as a string.");if(e&&!m(e))throw new Error("Default value for cache must be an object.");return new Re(t,e)}catch(r){i("cache",r)}};var De=(t="")=>joystick._external[t]?joystick._external[t]:null;var Le=(t="")=>t;var S=()=>typeof window=="undefined";var Pe=(t={},e={})=>{let r=t({props:e}),o=r.renderToHTML();return S()||r.appendCSSToHead(),o?.wrapped};var Ie=(t=128,e="test.txt",r="text/plain")=>{let o=t instanceof Blob;return new File(o?t:new Blob(new Uint8Array(t||128),{type:r}),e,{type:r})};var y=(t="",e=[])=>{typeof window!="undefined"&&!!window.__joystick_test__&&(window.test={...window.test||{},functionCalls:{...window?.test?.functionCalls||{},[t]:[...window?.test?.functionCalls&&window?.test?.functionCalls[t]||[],{calledAt:new Date().toISOString(),args:e}]}})};var qe={utils:{createFile:Ie,trackFunctionCall:y}};var ue=(t="",e={})=>{typeof window!="undefined"&&(joystick._external[t]={...joystick._external[t]||{},...e})};var Ve="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),f=(t=16)=>{let e="",r=0;for(;r<t;)e+=Ve[Math.floor(Math.random()*(Ve.length-1))],r+=1;return e};var U=null,Q=0,Ne=(t={},e=null)=>{try{if(window?.__joystick_test__)return e();let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);U&&(clearInterval(U),U=null);let n={client:o,send:(s={})=>(y(`ui.websockets.${t?.test?.name||f()}.send`,[s]),o.send(JSON.stringify(s)))};return o.addEventListener("open",()=>{t?.options?.logging&&console.log(`[joystick.websockets] Connected to ${t?.url}`),t?.events?.onOpen&&(t.events.onOpen(n),y(`ui.websockets.${t?.test?.name||f()}.onOpen`,[n])),Q=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&(t.events.onMessage(JSON.parse(s.data||{}),n),y(`ui.websockets.${t?.test?.name||f()}.onMessage`,[s.data||{},n]))}),o.addEventListener("close",s=>{t?.options?.logging&&console.log(`[joystick.websockets] Disconnected from ${t?.url}`),t?.events?.onClose&&(t.events.onClose(s?.code,s?.reason,n),y(`ui.websockets.${t?.test?.name||f()}.onClose`,[s.data||{},n])),o=null;let c=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!U&&!c&&(U=setInterval(()=>{o=null,Q<(t?.options?.reconnectAttempts||12)?(Ne(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${Q+1}/12)...`),Q+=1):clearInterval(U)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(n),n}catch(r){i("websockets.client",r)}},Y=Ne;var He=(t="",e={})=>{try{if(window?.__joystick_test__){y(`ui.upload.${t}`,[t,e]);return}return new Promise((r,o)=>{let n=f(),s=0;Y({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/uploaders`,options:{logging:!1,autoReconnect:!0,reconnectAttempts:12,reconnectDelayInSeconds:5},query:{id:n},events:{onMessage:(c={})=>{c?.type==="PROGRESS"&&e?.onProgress&&s<100&&s!==c?.progress&&(s=c?.progress,e.onProgress(c?.progress,c?.provider))}}},()=>{let c;e?.files?.length>0&&(c=new FormData,Array.from(e?.files).forEach(a=>{c.append("files",a,a.name)})),fetch(`${window.location.origin}/api/_uploaders/${t}`,{method:"POST",headers:{"x-joystick-upload-id":n,"x-joystick-upload-input":JSON.stringify(e?.input||{})},body:c}).then(async a=>{let l=await a.json();console.log(l),l&&l.errors?(A("upload",l.errors),o({errors:l.errors})):r(l?.uploads)})})})}catch(r){i("upload",r)}};var Ue=(t={})=>{try{let e=null;typeof window!="undefined"&&(e=window),typeof global!="undefined"&&(e=global),e&&(e.joystick={...e?.joystick||{},settings:e?.__joystick_settings__,...t})}catch(e){i("attachJoystickToWindow",e)}};var ze=(t={})=>Object.entries(t).map(([e,r])=>`${e}=${r}`)?.join("; ");var Br=async(t={})=>{try{let e=await t.text();return H(e)}catch(e){i("api.get.handleParseResponse",e)}},Be=(t="",e={})=>{try{return typeof window.fetch!="undefined"&&!e?.skip?new Promise((r,o)=>{let n=e.input?JSON.stringify(e.input):null,s=e.output?JSON.stringify(e.output):null,c=`${window.location.origin}/api/_getters/${t}?input=${n}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content"),l={...e?.headers||{},"x-joystick-csrf":a};return window?.__joystick_test__&&(l.Cookie=ze({joystickLoginToken:window.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expires_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(c,{method:"GET",mode:"cors",headers:l,credentials:"include"}).then(async x=>{let g=await Br(x);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),g?.errors?(A("get request",g.errors),o(g)):r(g)}).catch(x=>(A("get request",[x]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[x]})))}):Promise.resolve()}catch(r){i("get request",r)}};var Zr=async(t={})=>{try{let e=await t.text();return H(e)}catch(e){i("api.set.handleParseResponse",e)}},Gr=(t={})=>{try{let e={...t};return e?.loader&&delete e.loader,JSON.stringify(e)}catch(e){i("api.set.getBody",e)}},Ze=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let n=`${window.location.origin}/api/_setters/${t}`,s=Gr(e),c=document.querySelector('[name="csrf"]')?.getAttribute("content"),a={...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":c};return window?.__joystick_test__&&(a.Cookie=generateCookieHeader({joystickLoginToken:window?.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expirs_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(n,{method:"POST",mode:"cors",headers:a,body:s,credentials:"include"}).then(async l=>{let x=await Zr(l);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),x?.errors?(A("set request",x.errors),o(x)):r(x)}).catch(l=>(A("set request",[l]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[l]})))}):Promise.resolve()}catch(r){i("set request",r)}};var G={get:Be,set:Ze};var Ge=["render"];var We=(t={})=>{try{return Ge.every(e=>Object.keys(t).includes(e))}catch(e){i("component.hasAllRequiredOptions",e)}};var Ke=["_componentId","_ssrId","api","dataFromSSR","existingProps","existingState","instanceId","parent","req","css","data","defaultProps","events","id","lifecycle","methods","name","props","render","state","test","translations","url","websockets","wrapper"];var Je=(t=null)=>{try{!M(t)&&!u(t)&&!m(t)&&i("component.optionValidators.css","options.css must be a string, function returning a string, or an object returning breakpoints.")}catch(e){i("component.optionValidators.css",e)}};var Qe=["readystatechange","pointerlockchange","pointerlockerror","beforecopy","beforecut","beforepaste","freeze","resume","search","securitypolicyviolation","visibilitychange","fullscreenchange","fullscreenerror","webkitfullscreenchange","webkitfullscreenerror","beforexrselect","abort","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","formdata","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","pause","play","playing","progress","ratechange","reset","resize","scroll","seeked","seeking","select","stalled","submit","suspend","timeupdate","toggle","volumechange","waiting","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","wheel","auxclick","gotpointercapture","lostpointercapture","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerout","pointerenter","pointerleave","selectstart","selectionchange","animationend","animationiteration","animationstart","transitionrun","transitionstart","transitionend","transitioncancel","copy","cut","paste","pointerrawupdate"];var Ye=(t=null)=>{try{m(t)||i("component.optionValidators.events","options.events must be an object.");for(let e of Object.keys(t)){let[r]=e.split(" ");Qe.includes(r)||i("component.optionValidators.events",`${r} is not a supported JavaScript event type.`)}for(let[e,r]of Object.entries(t))u(r)||i("component.optionValidators.events",`options.events.${e} must be assigned a function.`)}catch(e){i("component.optionValidators.events",e)}};var Xe=["onBeforeMount","onMount","onUpdateProps","onBeforeUnmount","onRefetchData"];var et=(t=null)=>{try{m(t)||i("component.optionValidators.lifecycle","options.lifecycle must be an object.");for(let[e,r]of Object.entries(t))Xe.includes(e)||i("component.optionValidators.lifecycle",`options.lifecycle.${e} is not supported.`),u(r)||i("component.optionValidators.lifecycle",`options.lifecycle.${e} must be assigned a function.`)}catch(e){i("component.optionValidators.lifecycle",e)}};var tt=(t=null)=>{try{m(t)||i("component.optionValidators.methods","options.methods must be an object.");for(let[e,r]of Object.entries(t))u(r)||i("component.optionValidators.methods",`options.methods.${e} must be assigned a function.`)}catch(e){i("component.optionValidators.methods",e)}};var rt=(t=null)=>{typeof t!="string"&&i("component.optionValidators.name","options.name must be a string.")};var ot=(t=null)=>{try{u(t)||i("component.optionValidators.render","options.render must be a function returning a string.")}catch(e){i("component.optionValidators.render",e)}};var nt=(t=null)=>{try{m(t)||i("component.optionValidators.test","options.test must be an object."),t?.name&&!M(t.name)&&i("component.optionValidators.test","options.test.name must be assigned a string.")}catch(e){i("component.optionValidators.test",e)}};var it=(t=null)=>{try{u(t)||i("component.optionValidators.websockets","options.websockets must be a function returning an object.")}catch(e){i("component.optionValidators.websockets",e)}};var st=(t=null)=>{try{m(t)||i("component.optionValidators.wrapper","options.wrapper must be an object.");for(let[e,r]of Object.entries(t))e==="id"&&!M(r)&&i("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned a string.`),e==="classList"&&!q(r)&&i("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned an array of strings.`)}catch(e){i("component.optionValidators.wrapper",e)}};var at={css:Je,events:Ye,lifecycle:et,methods:tt,name:rt,render:ot,test:nt,websockets:it,wrapper:st};var ct=(t={})=>{try{We(t)||i("component.validateOptions",`component options must include ${required.options.join(",")}.`);for(let[e,r]of Object.entries(t)){Ke.includes(e)||i("component.validateOptions",`${e} is not supported by joystick.component.`);let o=at[e];o&&u(o)&&o(r)}}catch(e){i("component.validateOptions",e)}};var X=(t=[],e="")=>{try{return(q(t)&&t.find(o=>o?.componentId===e))?.data||{}}catch(r){i("findComponentDataFromSSR",r)}};var dt=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var z=t=>!!(t&&typeof t=="object"&&!Array.isArray(t));var lt=t=>typeof t=="string";var ut=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,mt=(t,e="")=>{if(!e)return!0;if(e&&!lt(e))return!1;let r=e?e.replace(/[- ]+/g,""):"";return t===!0?r.match(new RegExp(ut)):!r.match(new RegExp(ut))};var pt=(t="",e="")=>t(e);var ft=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-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789\d$/,SA:/^\d{5}(-{1}\d{4})?$/,SN:/^\d{5}$/,RS:/^\d{5}$/,SG:/^\d{2}$/,SK:/^\d{5}\s\(\d{3}\s\d{2}\)$/,SI:/^([Ss][Ii][- ]{0,1}){0,1}\d{4}$/,ZA:/^\d{4}$/,GS:/^[Ss][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,ES:/^\d{5}$/,LK:/^\d{5}$/,SD:/^\d{5}$/,SZ:/^[A-Za-z]\d{3}$/,SE:/^\d{3}\s*\d{2}$/,CH:/^\d{4}$/,SJ:/^\d{4}$/,TW:/^\d{5}$/,TJ:/^\d{6}$/,TH:/^\d{5}$/,TT:/^\d{6}$/,TN:/^\d{4}$/,TR:/^\d{5}$/,TM:/^\d{6}$/,TC:/^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,UA:/^\d{5}$/,GB:/^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,US:/^\b\d{5}\b(?:[- ]{1}\d{4})?$/,UY:/^\d{5}$/,VI:/^\d{5}$/,UZ:/^\d{3} \d{3}$/,VA:/^120$/,VE:/^\d{4}(\s[a-zA-Z]{1})?$/,VN:/^\d{6}$/,WF:/^986\d{2}$/,ZM:/^\d{5}$/},Et=(t,e="")=>{let r=z(t)&&t.iso?kt[t.iso||"US"]:kt.US;return z(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var Ft=(t="",e="")=>(e?.match(t)||[])?.length>0;var Mt=(t,e="",r={isChecked:!1})=>{if(!r.isChecked)return t===!0?e&&e.trim()!=="":e&&e.trim()==="";if(r.isChecked)return t===!0?e:!e};var St=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-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)(\d{9}$)/i,RO:/^(RO)([1-9]\d{1,9}$)/i,RU:/^(RU)(\d{10}$|\d{12}$)/i,RS:/^(RS)(\d{9}$)/i,SI:/^(SI)([1-9]\d{7}$)/i,SK:/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i,SE:/^(SE)(\d{10}01$)/i},Dt=(t,e="")=>{let r=z(t)&&t.iso?At[t.iso||"EU"]:At.EU;return z(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var Lt={creditCard:mt,custom:pt,email:ht,equals:wt,matches:yt,maxLength:gt,minLength:xt,phone:$t,postalCode:Et,regex:Ft,required:Mt,semVer:Tt,slug:Ct,strongPassword:Ot,url:Rt,vat:Dt};var Pt=class{constructor(e,r={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={creditCard:()=>"Must be a valid credit card number.",custom:()=>"Must return true.",email:()=>"Must be a valid email.",equals:o=>`Value must equal ${o}.`,matches:o=>`Field must match ${o}.`,maxLength:o=>`Field value can be no greater than ${o}.`,minLength:o=>`Field value can be no less than ${o}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",regex:()=>"Must match regex.",required:()=>"This field is required.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},e||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=e,this.setOptions(r),this.attachEventListeners()}setOptions(e={}){this.rules=e.rules||{},this.messages=e.messages||{},this.onSubmit=e.onSubmit,this.onRenderError=e.onRenderError,this.fields=this.serialize()}updateOptions(e={}){this.setOptions(e)}serialize(){if(this.form)return Object.keys(this.rules).map(r=>{let o=this.form.querySelector(`[name="${r}"]`),n=o?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(n),type:n,name:r,element:o,validations:Object.entries(this.rules[r]).map(([c,a])=>({name:c,rule:a,valid:!1})).sort((c,a)=>c.name>a.name?1:-1),errorMessages:this.messages[r]?Object.keys(this.messages[r]):{}}})?.filter(r=>!!r?.element)}attachEventListeners(){if(this.form){let e=r=>{r.stopPropagation(),r.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let r=0;r<this.form.listeners.length;r+=1){let o=this.form.listeners[r];this.form.removeEventListener("submit",o)}this.form.addEventListener("submit",e),this.form.listeners=[...this.form.listeners||[],e]}this.fields.forEach(e=>{if(e?.element&&e?.listenForChanges){let r=()=>{dt(()=>{this.validate(e.name)},100)};e.element.removeEventListener("input",r),e.element.addEventListener("input",r),e.element.removeEventListener("change",r),e.element.addEventListener("change",r)}})}validate(e=null){if(e){let r=this.fields.find(o=>o.name===e);return this.clearExistingError(e),this.validateField(r),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(r=>{this.validateField(r)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(r=>r.validations.some(o=>!o.valid)).includes(!0)}validateField(e){let r=this.form.querySelector(`[name="${e.name}"]`),o=["checkbox","radio"].includes(e.type),n=o?null:e?.element?.value?.trim(),s=o?e?.element?.checked:null;e.validations.forEach(a=>{if(this.isValidValue(o,o?s:n,a))this.markValidationAsValid(e,a.name);else{let l=this.messages[e.name]&&this.messages[e.name][a.name];this.markValidationAsInvalid(e,a.name),this.renderError(e.element,l||this.defaultValidationErrors[a.name](a.rule,n))}});let c=e.validations.some(a=>!a.valid);return c&&(r.classList.add("error"),r.focus()),c||(r.classList.remove("error"),this.clearExistingError(e.name)),!c}markValidationAsInvalid(e,r){let n=[...e.validations].find(s=>s.name===r);n.valid=!1}markValidationAsValid(e,r){let n=[...e.validations].find(s=>s.name===r);n.valid=!0}isValidValue(e,r,o){let n=Lt[o.name];return n?n(o.rule,r,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.parentNode.removeChild(e))}clearExistingError(e=""){let r=document.getElementById(`error-${e}`);r&&r.parentNode.removeChild(r)}renderError(e,r=""){if(e){if(this.clearExistingError(e.name),typeof this.onRenderError=="function")return this.onRenderError(e,r);let o=document.createElement("p");o.classList.add("input-hint"),o.classList.add("error"),o.setAttribute("id",`error-${e.name}`),o.innerText=r,e.after(o)}}},Wr=(t,e)=>new Promise((r,o)=>{try{new Pt(t,e).validate()?r():o()}catch(n){console.warn(n)}}),It=Wr;var qt=(t={},e={})=>{try{return[...Object.keys(e),...Object.keys(t)].filter((o,n,s)=>s.indexOf(o)===n).reduce((o,n)=>{let s=e[n],c=t[n]||null,a=!Ce(s)&&!ve(s);return o[n]=a?s:c,o},{})}catch(r){i("component.props.compile",r)}};var ee=(t="",e={})=>{try{let r="";if(t&&M(t))return r=t,r;if(t&&u(t))return r=t(e),r;if(t&&m(t)){let o=t?.print&&(M(t?.print)||u(t?.print)),n=t?.min&&m(t?.min),s=t?.min?.width&&m(t?.min?.width),c=t?.min?.height&&m(t?.min?.height),a=t?.max&&m(t?.max),l=t?.max?.width&&m(t?.max?.width),x=t?.max?.height&&m(t?.max?.height);if(o&&(r+=`
2
2
  @media print {
3
3
  ${typeof t?.print=="function"?t?.print(e):t.print}
4
4
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/ui-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.92",
4
+ "version": "0.0.0-canary.93",
5
5
  "description": "A JavaScript framework for building user interfaces.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {