@joystick.js/ui-canary 0.0.0-canary.8 → 0.0.0-canary.9

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 +1 @@
1
- var i=(e="",o={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${o.message||o.reason||o}`)};var p=(e={})=>{try{return Object.entries(e).map(([o,n])=>{let[s,...t]=o.split(" ");return{type:s.toLowerCase(),selector:t.join(" "),handler:n}})}catch(o){i("component.events.serialize",o)}};var h=(e={},o={},n=[])=>{try{let s=Object.keys(e?.events||{})?.length>0?p(e?.events):[];for(let t=0;t<s?.length;t+=1){let r=s[t];n.push({...r,instance:e,elements:document.querySelectorAll(`body [js-i="${e.instanceId}"] ${r?.selector}`),handler:function(c){console.log("DOM EVENT",c),Object.defineProperty(c,"target",{value:c.composedPath()[0]}),r.handler(c,{...e||{},setState:e?.setState.bind(e),...o||{}})}})}if(e?.children){let t=Object.entries(e?.children)?.flatMap(([r,l])=>l);for(let r=0;r<t?.length;r+=1){let l=t[r];h(l,o,n)}}return n}catch(s){i("component.events.registerListenersFix.getListeners",s)}},d=(e={},o={})=>{try{let n=h(e,o,[]);console.log("GETTING CALLED",n);let s=n?.flatMap((t={})=>[].flatMap.call(t?.elements||[],r=>{let{elements:l=[],...c}=t||{};return{...c,element:r}}));for(let t=0;t<s?.length;t+=1){let{instance:r,element:l,elementSelector:c,type:a,handler:m}=s[t];console.log({element:l,type:a,handler:m}),l.addEventListener(a,m),r._eventListeners=[...r?._eventListeners||[],{instance:r,element:l,elementSelector:c,type:a,handler:m}]}}catch(n){i("component.events.registerListenersFix",n)}},L=d;export{L as default};
1
+ var i=(e="",o={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${o.message||o.reason||o}`)};var p=(e={})=>{try{return Object.entries(e).map(([o,n])=>{let[l,...t]=o.split(" ");return{type:l.toLowerCase(),selector:t.join(" "),handler:n}})}catch(o){i("component.events.serialize",o)}};var h=(e={},o={},n=[])=>{try{let l=Object.keys(e?.events||{})?.length>0?p(e?.events):[];for(let t=0;t<l?.length;t+=1){let r=l[t];n.push({...r,instance:e,elements:document.querySelectorAll(`body [js-i="${e.instanceId}"] ${r?.selector}`),handler:function(s){s?.target?.target&&(s.target=s?.target?.target),Object.defineProperty(s,"target",{value:s.composedPath()[0]}),r.handler(s,{...e||{},setState:e?.setState.bind(e),...o||{}})}})}if(e?.children){let t=Object.entries(e?.children)?.flatMap(([r,c])=>c);for(let r=0;r<t?.length;r+=1){let c=t[r];h(c,o,n)}}return n}catch(l){i("component.events.registerListenersFix.getListeners",l)}},d=(e={},o={})=>{try{let n=h(e,o,[]);console.log("GETTING CALLED",n);let l=n?.flatMap((t={})=>[].flatMap.call(t?.elements||[],r=>{let{elements:c=[],...s}=t||{};return{...s,element:r}}));for(let t=0;t<l?.length;t+=1){let{instance:r,element:c,elementSelector:s,type:a,handler:m}=l[t];console.log({element:c,type:a,handler:m}),c.addEventListener(a,m),r._eventListeners=[...r?._eventListeners||[],{instance:r,element:c,elementSelector:s,type:a,handler:m}]}}catch(n){i("component.events.registerListenersFix",n)}},L=d;export{L as default};
@@ -18,4 +18,4 @@ var Kt=Object.create;var oe=Object.defineProperty;var Wt=Object.getOwnPropertyDe
18
18
  @media screen and (max-height: ${v}px) {
19
19
  ${typeof f=="function"?f(e):f}
20
20
  }
21
- `}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var ir=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!j(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},G=(t={},e={})=>{try{return m(e)?ir(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var ie={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var st=(t={},e={})=>{try{return e?Object.entries({...ie,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ie}catch(r){n("component.lifecycle.compile",r)}};var K=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{n("component.methods.compile")}};var ne=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>C(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){n("component.url.compile",e)}};var S=()=>typeof window=="undefined";var I=null,W=0,at=(t={},e=null)=>{try{let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);I&&(clearInterval(I),I=null);let i={client:o,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(i),W=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&t.events.onMessage(JSON.parse(s.data||{}),i)}),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,i),o=null;let d=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!I&&!d&&(I=setInterval(()=>{o=null,W<(t?.options?.reconnectAttempts||12)?(at(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${W+1}/12)...`),W+=1):clearInterval(I)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},dt=at;var nr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!j(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},ct=(t={},e={})=>{try{return m(e)?nr(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var lt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=U(8),t.ssrId=e?._ssrId||null,t.css=nt(),t.data=B(e?.dataFromSSR,e?._componentId),t.defaultProps=ct(t,e?.defaultProps),t.props=it(t?.defaultProps,e?.props),t.state=G(t,e?.state),t.events=e?.events||{},t.lifecycle=st(t,e?.lifecycle),t.methods=K(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=ot,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=ne(e?.url)),r&&window.__joystick_url__&&(t.url=ne(window.__joystick_url__)),r&&e?.websockets&&m(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[d,a]=i[s];dt({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${d}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(l={})=>{t.websockets={...t.websockets||{},[d]:l}})}}}catch(r){n("component.registerOptions",r)}};var _=(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){n(t,r)}};var J=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var sr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.get.handleParseResponse",e)}},mt=(t="",e={})=>{try{return typeof window.fetch!="undefined"&&!e?.skip?new Promise((r,o)=>{let i=e.input?JSON.stringify(e.input):null,s=e.output?JSON.stringify(e.output):null,d=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(d,{method:"GET",mode:"cors",headers:{...e?.headers||{},"x-joystick-csrf":a},credentials:"include"}).then(async l=>{let g=await sr(l);return g?.errors?(_("get request",g.errors),o(g)):r(g)}).catch(l=>(_("get request",[l]),o({errors:[l]})))}):Promise.resolve()}catch(r){n("get request",r)}};var ar=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.set.handleParseResponse",e)}},dr=(t={})=>{try{return JSON.stringify(t)}catch(e){n("api.set.getBody",e)}},pt=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=dr(e),d=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(i,{method:"POST",mode:"cors",headers:{...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":d},body:s,credentials:"include"}).then(async a=>{let l=await ar(a);return l?.errors?(_("set request",l.errors),o(l)):r(l)}).catch(a=>(_("set request",[a]),o({errors:[a]})))}):Promise.resolve()}catch(r){n("set request",r)}};var ut={get:mt,set:pt};var cr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("addToQueue.getQueue",e)}},q=(t="",e=null)=>{try{S()||(cr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Q=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&m(o.options.data)){let i=await o.options.data(t,e,r,o);return Promise.resolve(i)}return Promise.resolve()}catch(i){n("component.data.fetch",i)}};var ft=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let i=await Q(ut,e,o,r);return r.data=ft(i,e,r),window.__joystick_data__[r?.id]=i,r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),i}}}catch(o){n("component.data.compile",o)}},ht=ft;var wt=(t={})=>{try{if(!S()&&window.__joystick_data__&&window.__joystick_data__[t?.id]){let e=window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return ht(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var bt=rr(yt());var xt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(u(t)&&o){let i=Object.keys(t);for(let s=0;s<i.length;s+=1){let d=i[s],a=t[d];if(d===r&&a===e)return t;if(d==="children"&&Array.isArray(a))for(let l=0;l<a.length;l+=1){let g=a[l],y=xt(g,e,r);if(y!==null)return y}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},R=xt;var gt=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var lr=(t={},e={},r=null)=>{try{let o=N(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){n("component.renderMethods.component.renderForClient",o)}},mr=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){n("component.renderMethods.component.renderToHTMLForSSR",e)}},pr=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){n("component.renderMethods.component.collectDataFunctionsForSSR",e)}},ur=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};gt(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){n("component.renderMethods.component.handleAddComponentToParent",e)}},fr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&q("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&q("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},hr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,bt.diff)(e?.existingPropsMap,r)?.length>0&&q("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t)})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},wr=function(){return function(e=null,r={},o={}){let i=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[i.id]||{},d=o.children[i.id]||[],a=s[d?.length];return i.state=a?.state||i.state,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,hr(i,o,r),q("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),fr(this,i),i.parent&&ur(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?pr(i):i.parent&&i.parent.ssrTree?mr(i):lr(i,this,a?.children)}},yr=function(e,r){try{let o=this;return new wr().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},se=yr;var xr=function(e=[],r=null){try{return m(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},ae=xr;var gr=function(e="",r={}){try{let o=S()?this.translations:window.__joystick_i18n__;if(!o||!o[e])return"";let i=Object.entries(r);return i.length>0?i.reduce((s,[d,a])=>s.replace(`{{${d}}}`,a),o[e]):o[e]}catch(o){n("component.renderMethods.i18n",o)}},de=gr;var br=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},ce=br;var $t={c:se,component:se,e:ae,each:ae,i:de,i18n:de,w:ce,when:ce};var Ft=(t={},e={})=>{try{return Object.entries($t).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var Et=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,children:Et(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},Mt=(t={})=>{try{return Et(t)}catch(e){n("component.render.getExistingStateMap",e)}};var kt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),$r=new RegExp(/\n/g);var Fr=(t="")=>{try{return(t.match(kt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},St=(t="")=>{try{let e=`${t}`;return e=Fr(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var Ot=(t={},e="")=>{try{let{wrapper:r=null,ssrId:o=null,id:i=null,instanceId:s=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""}js-ssrId="${o}" js-c="${i}" js-i="${s}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Tt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,d]=o[i];for(let a=0;a<d?.length;a+=1){let l=d[a];Object.entries(l?.timers)?.length>0&&r.push(...Object.values(l?.timers)),Object.entries(l?.children)?.length>0&&Tt(l?.children,r)}}if(r?.length>0)for(let i=0;i<r?.length;i+=1)clearTimeout(r[i])}catch(r){n("component.render.clearTimersOnChildren",r)}},vt=Tt;var X=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=B(e.dataFromSSR,t.id)||{}),vt(t?.children);let r=Mt(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Ft({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=K(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=St(o),s=Ot(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Er=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},Ct=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Ct(e):le(e)):le(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},le=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Er(t.attributes),children:[].flatMap.call(t.childNodes,o=>Ct(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},z=le;var Mr=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},Rt=(t="")=>{try{let e=Mr(t);return z(e)}catch(e){n("component.virtualDOM.build",e)}};var At=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var kr=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[i,s]=r[o];At(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=Lt(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},Lt=(t=null)=>{try{return C(t)?document.createTextNode(t):kr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},V=Lt;var N=(t={},e={})=>{try{let r=X(t,{existingChildren:e?.existingChildren}),o=Rt(r.wrapped,t),i=e.includeActual&&o?V(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var Dt=(t={},e={})=>{try{let r=N(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Sr=(t={},e={})=>{let r=[];for(let[o,i]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,i),s));for(let o in t)o in e||r.push(i=>(i&&i.removeAttribute&&i.removeAttribute(o),i));return o=>{for(let i of r)i&&typeof i=="function"&&i(o)}},ee=Sr;var Or=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],d=e[i];r.push([s,d])}return r},jt=Or;var Tr=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},vr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Cr=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=d=>{let a=V(i);return d.appendChild(a),d};r.push(s)}),r},Rr=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=re(o,e[i]);r.push(s)}),r},Ar=(t=[],e=[])=>{let r=Rr(t,e),o=Cr(t,e);return i=>{if(i){let s=jt(r,i.childNodes);vr(s),Tr(o,i)}return i}},te=Ar;var Pt={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ee(t.attributes,e.attributes)(r),te([],e.children)(r);let i=r.querySelector(`option[value="${o}"]`);if(i&&(r.value=o),!i){let s=r.querySelector("option");r.value=s?.value||""}return r}};var me=(t,e)=>r=>{let o=t?V(t):null;return r&&r.replaceWith(o),o},Lr=()=>t=>{t&&t.remove()},Dr=(t=void 0,e=void 0)=>t===void 0||e===void 0?Lr():typeof t=="string"||typeof e=="string"?me(e,t):t.tagName!==e.tagName?me(e):e.tagName==="select"?Pt.select(t,e):["pre","code"].includes(e.tagName)?me(e,t):i=>(ee(t.attributes,e.attributes)(i),te(t.children,e.children)(i),i),re=Dr;var jr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("processQueue.getQueue",e)}},H=(t="",e=null)=>{try{S()||(jr(t)||{}).process(e)}catch(r){n("processQueue",r)}};var It=(t="",e=null)=>{let r=R(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var _t=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Nt=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(u(i)&&i.attributes&&i.attributes["js-i"]&&i.attributes["js-i"]===e){t.children[o]=r;break}u(i)&&Nt(i,e,r)}},Vt=Nt;var Ut=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...i]=e.split(" ");return{type:o.toLowerCase(),selector:i.join(" "),handler:r}})}catch(e){n("component.events.serialize",e)}};var qt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Ut(t?.events):[];for(let i=0;i<o?.length;i+=1){let s=o[i];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){console.log("DOM EVENT",a),Object.defineProperty(a,"target",{value:a.composedPath()[0]}),s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,d])=>d);for(let s=0;s<i?.length;s+=1){let d=i[s];qt(d,e,r)}}return r}catch(o){n("component.events.registerListenersFix.getListeners",o)}},Pr=(t={},e={})=>{try{let r=qt(t,e,[]);console.log("GETTING CALLED",r);let o=r?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:d=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:d,elementSelector:a,type:l,handler:g}=o[i];console.log({element:d,type:l,handler:g}),d.addEventListener(l,g),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:d,elementSelector:a,type:l,handler:g}]}}catch(r){n("component.events.registerListenersFix",r)}},zt=Pr;var Ht=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Ht(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},Ir=(t={})=>{try{let e=Ht(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:d}=e[r];i.removeEventListener(s,d),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Zt=Ir;var Bt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},Te(e),lt(this,e),this.data=wt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Q(e,r,o,i);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=z(this.DOMNode);this.dom.virtual=r}let e=this.parent?R(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!S())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return Dt(this,e);let r=this.onBeforeRender();Zt(this),It(this.instanceId);let o=N(this,{}),i=re(this.dom.virtual,o.virtual);i&&m(i)&&H("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,zt(this,this.renderMethods),this.setDOMNodeOnInstance(),H("domNodes",()=>{H("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return X(this,e)}onAfterRender(e={},r={}){S()||(_t(e.instanceId,this),window.joystick._internal.css.update(),H("lifecycle.onUpdateProps"),r?.afterSetStateRender&&m(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&m(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=G(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&m(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[U()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[U()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=R(window.joystick._internal.tree,this.instanceId,"instanceId"),i=R(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=z(i?.instance?.DOMNode);Vt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},Ja=Bt;export{Ja as default};
21
+ `}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var ir=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!j(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},G=(t={},e={})=>{try{return m(e)?ir(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var ie={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var st=(t={},e={})=>{try{return e?Object.entries({...ie,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ie}catch(r){n("component.lifecycle.compile",r)}};var K=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{n("component.methods.compile")}};var ne=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>C(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){n("component.url.compile",e)}};var S=()=>typeof window=="undefined";var I=null,W=0,at=(t={},e=null)=>{try{let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);I&&(clearInterval(I),I=null);let i={client:o,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(i),W=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&t.events.onMessage(JSON.parse(s.data||{}),i)}),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,i),o=null;let d=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!I&&!d&&(I=setInterval(()=>{o=null,W<(t?.options?.reconnectAttempts||12)?(at(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${W+1}/12)...`),W+=1):clearInterval(I)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},dt=at;var nr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!j(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},ct=(t={},e={})=>{try{return m(e)?nr(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var lt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=U(8),t.ssrId=e?._ssrId||null,t.css=nt(),t.data=B(e?.dataFromSSR,e?._componentId),t.defaultProps=ct(t,e?.defaultProps),t.props=it(t?.defaultProps,e?.props),t.state=G(t,e?.state),t.events=e?.events||{},t.lifecycle=st(t,e?.lifecycle),t.methods=K(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=ot,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=ne(e?.url)),r&&window.__joystick_url__&&(t.url=ne(window.__joystick_url__)),r&&e?.websockets&&m(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[d,a]=i[s];dt({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${d}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(l={})=>{t.websockets={...t.websockets||{},[d]:l}})}}}catch(r){n("component.registerOptions",r)}};var _=(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){n(t,r)}};var J=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var sr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.get.handleParseResponse",e)}},mt=(t="",e={})=>{try{return typeof window.fetch!="undefined"&&!e?.skip?new Promise((r,o)=>{let i=e.input?JSON.stringify(e.input):null,s=e.output?JSON.stringify(e.output):null,d=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(d,{method:"GET",mode:"cors",headers:{...e?.headers||{},"x-joystick-csrf":a},credentials:"include"}).then(async l=>{let g=await sr(l);return g?.errors?(_("get request",g.errors),o(g)):r(g)}).catch(l=>(_("get request",[l]),o({errors:[l]})))}):Promise.resolve()}catch(r){n("get request",r)}};var ar=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.set.handleParseResponse",e)}},dr=(t={})=>{try{return JSON.stringify(t)}catch(e){n("api.set.getBody",e)}},pt=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=dr(e),d=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(i,{method:"POST",mode:"cors",headers:{...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":d},body:s,credentials:"include"}).then(async a=>{let l=await ar(a);return l?.errors?(_("set request",l.errors),o(l)):r(l)}).catch(a=>(_("set request",[a]),o({errors:[a]})))}):Promise.resolve()}catch(r){n("set request",r)}};var ut={get:mt,set:pt};var cr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("addToQueue.getQueue",e)}},q=(t="",e=null)=>{try{S()||(cr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Q=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&m(o.options.data)){let i=await o.options.data(t,e,r,o);return Promise.resolve(i)}return Promise.resolve()}catch(i){n("component.data.fetch",i)}};var ft=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let i=await Q(ut,e,o,r);return r.data=ft(i,e,r),window.__joystick_data__[r?.id]=i,r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),i}}}catch(o){n("component.data.compile",o)}},ht=ft;var wt=(t={})=>{try{if(!S()&&window.__joystick_data__&&window.__joystick_data__[t?.id]){let e=window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return ht(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var bt=rr(yt());var xt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(u(t)&&o){let i=Object.keys(t);for(let s=0;s<i.length;s+=1){let d=i[s],a=t[d];if(d===r&&a===e)return t;if(d==="children"&&Array.isArray(a))for(let l=0;l<a.length;l+=1){let g=a[l],y=xt(g,e,r);if(y!==null)return y}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},R=xt;var gt=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var lr=(t={},e={},r=null)=>{try{let o=N(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){n("component.renderMethods.component.renderForClient",o)}},mr=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){n("component.renderMethods.component.renderToHTMLForSSR",e)}},pr=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){n("component.renderMethods.component.collectDataFunctionsForSSR",e)}},ur=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};gt(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){n("component.renderMethods.component.handleAddComponentToParent",e)}},fr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&q("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&q("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},hr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,bt.diff)(e?.existingPropsMap,r)?.length>0&&q("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t)})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},wr=function(){return function(e=null,r={},o={}){let i=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[i.id]||{},d=o.children[i.id]||[],a=s[d?.length];return i.state=a?.state||i.state,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,hr(i,o,r),q("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),fr(this,i),i.parent&&ur(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?pr(i):i.parent&&i.parent.ssrTree?mr(i):lr(i,this,a?.children)}},yr=function(e,r){try{let o=this;return new wr().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},se=yr;var xr=function(e=[],r=null){try{return m(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},ae=xr;var gr=function(e="",r={}){try{let o=S()?this.translations:window.__joystick_i18n__;if(!o||!o[e])return"";let i=Object.entries(r);return i.length>0?i.reduce((s,[d,a])=>s.replace(`{{${d}}}`,a),o[e]):o[e]}catch(o){n("component.renderMethods.i18n",o)}},de=gr;var br=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},ce=br;var $t={c:se,component:se,e:ae,each:ae,i:de,i18n:de,w:ce,when:ce};var Ft=(t={},e={})=>{try{return Object.entries($t).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var Et=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,children:Et(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},Mt=(t={})=>{try{return Et(t)}catch(e){n("component.render.getExistingStateMap",e)}};var kt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),$r=new RegExp(/\n/g);var Fr=(t="")=>{try{return(t.match(kt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},St=(t="")=>{try{let e=`${t}`;return e=Fr(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var Ot=(t={},e="")=>{try{let{wrapper:r=null,ssrId:o=null,id:i=null,instanceId:s=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""}js-ssrId="${o}" js-c="${i}" js-i="${s}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Tt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,d]=o[i];for(let a=0;a<d?.length;a+=1){let l=d[a];Object.entries(l?.timers)?.length>0&&r.push(...Object.values(l?.timers)),Object.entries(l?.children)?.length>0&&Tt(l?.children,r)}}if(r?.length>0)for(let i=0;i<r?.length;i+=1)clearTimeout(r[i])}catch(r){n("component.render.clearTimersOnChildren",r)}},vt=Tt;var X=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=B(e.dataFromSSR,t.id)||{}),vt(t?.children);let r=Mt(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Ft({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=K(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=St(o),s=Ot(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Er=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},Ct=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Ct(e):le(e)):le(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},le=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Er(t.attributes),children:[].flatMap.call(t.childNodes,o=>Ct(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},z=le;var Mr=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},Rt=(t="")=>{try{let e=Mr(t);return z(e)}catch(e){n("component.virtualDOM.build",e)}};var At=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var kr=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[i,s]=r[o];At(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=Lt(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},Lt=(t=null)=>{try{return C(t)?document.createTextNode(t):kr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},V=Lt;var N=(t={},e={})=>{try{let r=X(t,{existingChildren:e?.existingChildren}),o=Rt(r.wrapped,t),i=e.includeActual&&o?V(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var Dt=(t={},e={})=>{try{let r=N(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Sr=(t={},e={})=>{let r=[];for(let[o,i]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,i),s));for(let o in t)o in e||r.push(i=>(i&&i.removeAttribute&&i.removeAttribute(o),i));return o=>{for(let i of r)i&&typeof i=="function"&&i(o)}},ee=Sr;var Or=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],d=e[i];r.push([s,d])}return r},jt=Or;var Tr=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},vr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Cr=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=d=>{let a=V(i);return d.appendChild(a),d};r.push(s)}),r},Rr=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=re(o,e[i]);r.push(s)}),r},Ar=(t=[],e=[])=>{let r=Rr(t,e),o=Cr(t,e);return i=>{if(i){let s=jt(r,i.childNodes);vr(s),Tr(o,i)}return i}},te=Ar;var Pt={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ee(t.attributes,e.attributes)(r),te([],e.children)(r);let i=r.querySelector(`option[value="${o}"]`);if(i&&(r.value=o),!i){let s=r.querySelector("option");r.value=s?.value||""}return r}};var me=(t,e)=>r=>{let o=t?V(t):null;return r&&r.replaceWith(o),o},Lr=()=>t=>{t&&t.remove()},Dr=(t=void 0,e=void 0)=>t===void 0||e===void 0?Lr():typeof t=="string"||typeof e=="string"?me(e,t):t.tagName!==e.tagName?me(e):e.tagName==="select"?Pt.select(t,e):["pre","code"].includes(e.tagName)?me(e,t):i=>(ee(t.attributes,e.attributes)(i),te(t.children,e.children)(i),i),re=Dr;var jr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("processQueue.getQueue",e)}},H=(t="",e=null)=>{try{S()||(jr(t)||{}).process(e)}catch(r){n("processQueue",r)}};var It=(t="",e=null)=>{let r=R(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var _t=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Nt=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(u(i)&&i.attributes&&i.attributes["js-i"]&&i.attributes["js-i"]===e){t.children[o]=r;break}u(i)&&Nt(i,e,r)}},Vt=Nt;var Ut=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...i]=e.split(" ");return{type:o.toLowerCase(),selector:i.join(" "),handler:r}})}catch(e){n("component.events.serialize",e)}};var qt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Ut(t?.events):[];for(let i=0;i<o?.length;i+=1){let s=o[i];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){a?.target?.target&&(a.target=a?.target?.target),Object.defineProperty(a,"target",{value:a.composedPath()[0]}),s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,d])=>d);for(let s=0;s<i?.length;s+=1){let d=i[s];qt(d,e,r)}}return r}catch(o){n("component.events.registerListenersFix.getListeners",o)}},Pr=(t={},e={})=>{try{let r=qt(t,e,[]);console.log("GETTING CALLED",r);let o=r?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:d=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:d,elementSelector:a,type:l,handler:g}=o[i];console.log({element:d,type:l,handler:g}),d.addEventListener(l,g),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:d,elementSelector:a,type:l,handler:g}]}}catch(r){n("component.events.registerListenersFix",r)}},zt=Pr;var Ht=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Ht(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},Ir=(t={})=>{try{let e=Ht(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:d}=e[r];i.removeEventListener(s,d),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Zt=Ir;var Bt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},Te(e),lt(this,e),this.data=wt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Q(e,r,o,i);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=z(this.DOMNode);this.dom.virtual=r}let e=this.parent?R(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!S())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return Dt(this,e);let r=this.onBeforeRender();Zt(this),It(this.instanceId);let o=N(this,{}),i=re(this.dom.virtual,o.virtual);i&&m(i)&&H("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,zt(this,this.renderMethods),this.setDOMNodeOnInstance(),H("domNodes",()=>{H("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return X(this,e)}onAfterRender(e={},r={}){S()||(_t(e.instanceId,this),window.joystick._internal.css.update(),H("lifecycle.onUpdateProps"),r?.afterSetStateRender&&m(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&m(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=G(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&m(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[U()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[U()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=R(window.joystick._internal.tree,this.instanceId,"instanceId"),i=R(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=z(i?.instance?.DOMNode);Vt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},Ja=Bt;export{Ja as default};
@@ -1,4 +1,4 @@
1
- var Wt=Object.create;var oe=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Yt=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty;var er=t=>oe(t,"__esModule",{value:!0});var tr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var rr=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qt(e))!Xt.call(t,o)&&o!=="default"&&oe(t,o,{get:()=>e[o],enumerable:!(r=Jt(e,o))||r.enumerable});return t},or=t=>rr(er(oe(t!=null?Wt(Yt(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var yt=tr(Y=>{(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof Y!="undefined")e(Y);else{var r={exports:{}};e(r.exports),t.index=r.exports}})(Y,function(t){"use strict";function e(p){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},e(p)}function r(p,c){return c&&(e(c)==="object"||typeof c=="function")?c: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(c){return c.__proto__||Object.getPrototypeOf(c)},i(p)}function s(p,c){if(typeof c!="function"&&c!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(c&&c.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),c&&d(p,c)}function d(p,c){return d=Object.setPrototypeOf||function(b,O){return b.__proto__=O,b},d(p,c)}function a(p,c){if(!(p instanceof c))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;var l=function p(c,b){a(this,p),this.type=c,this.path=b?b.toString():""},g=function(p){function c(b,O,h){var A;return a(this,c),A=r(this,i(c).call(this,"E",b)),A.lhs=O,A.rhs=h,A}return s(c,p),c}(l),y=function(p){function c(b,O,h,A){var $;return a(this,c),$=r(this,i(c).call(this,"M",b)),$.item=O,$.lhsIndex=h,$.rhsIndex=A,$}return s(c,p),c}(l),w=function(p){function c(b,O){var h;return a(this,c),h=r(this,i(c).call(this,"D",b)),h.lhs=O,h}return s(c,p),c}(l),v=function(p){function c(b,O){var h;return a(this,c),h=r(this,i(c).call(this,"A",b)),h.rhs=O,h}return s(c,p),c}(l),f=function(p,c){return p?"".concat(p,".").concat(c):c};t.diff=function(c,b){var O=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},h=[],A=O.matchKey,$=O.types||["E","A","D","M"],Kt=function(F,x,E,D){F.forEach(function(L,M){var T=x.findIndex(function(k){return k[D]===L[D]});-1<T?(-1<$.indexOf("M")&&M!==T&&h.push(new y(E,L,M,T)),Z(L,x[T],f(E,T))):-1<$.indexOf("D")&&h.push(new w(E,L))}),x.forEach(function(L,M){var T=F.findIndex(function(k){return L[D]===k[D]});-1<$.indexOf("A")&&T===-1&&h.push(new v(f(E,M),L))})},Z=function(F,x,E){var D=Object.prototype.toString.call(F),L=Object.prototype.toString.call(x);if(-1<$.indexOf("E")&&D!==L)return h.push(new g(E,F,x)),!1;if(D==="[object Object]")Object.getOwnPropertyNames(F).forEach(function(k){Object.prototype.hasOwnProperty.call(x,k)?Z(F[k],x[k],f(E,k)):-1<$.indexOf("D")&&h.push(new w(f(E,k),F[k]))}),Object.getOwnPropertyNames(x).forEach(function(k){-1<$.indexOf("A")&&!Object.prototype.hasOwnProperty.call(F,k)&&h.push(new v(f(E,k),x[k]))});else if(D!=="[object Array]")-1<$.indexOf("E")&&F!==x&&h.push(new g(E,F,x));else if(A)Kt(F,x,E,A);else{var M=F.length-1,T=x.length-1;if(-1<$.indexOf("D"))for(;M>T;)h.push(new w(f(E,M),F[M--]));if(-1<$.indexOf("A"))for(;T>M;)h.push(new v(f(E,T),x[T--]));for(;0<=M;--M)Z(F[M],x[M],f(E,M))}};return Z(c,b),h}})});var n=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var pe=["render"];var ue=(t={})=>{try{return pe.every(e=>Object.keys(t).includes(e))}catch(e){n("component.hasAllRequiredOptions",e)}};var fe=["_componentId","_ssrId","api","dataFromSSR","existingProps","existingState","instanceId","parent","req","css","data","defaultProps","events","id","lifecycle","methods","name","props","render","state","translations","url","websockets","wrapper"];var he=t=>{try{return typeof t=="undefined"}catch(e){n("types.isUndefined",e)}},we=t=>{try{return t===null}catch(e){n("types.isNull",e)}};var j=t=>{try{return!!Array.isArray(t)}catch(e){n("types.isArray",e)}};var m=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 C=t=>{try{return typeof t=="string"}catch(e){n("types.isString",e)}};var ye=(t=null)=>{try{!C(t)&&!m(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 xe=["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 ge=(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(" ");xe.includes(r)||n("component.optionValidators.events",`${r} is not a supported JavaScript event type.`)}for(let[e,r]of Object.entries(t))m(r)||n("component.optionValidators.events",`options.events.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.events",e)}};var be=["onBeforeMount","onMount","onUpdateProps","onBeforeUnmount","onRefetchData"];var $e=(t=null)=>{try{u(t)||n("component.optionValidators.lifecycle","options.lifecycle must be an object.");for(let[e,r]of Object.entries(t))be.includes(e)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} is not supported.`),m(r)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.lifecycle",e)}};var Fe=(t=null)=>{try{u(t)||n("component.optionValidators.methods","options.methods must be an object.");for(let[e,r]of Object.entries(t))m(r)||n("component.optionValidators.methods",`options.methods.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.methods",e)}};var Ee=(t=null)=>{typeof t!="string"&&n("component.optionValidators.name","options.name must be a string.")};var Me=(t=null)=>{try{m(t)||n("component.optionValidators.render","options.render must be a function returning a string.")}catch(e){n("component.optionValidators.render",e)}};var ke=(t=null)=>{try{m(t)||n("component.optionValidators.websockets","options.websockets must be a function returning an object.")}catch(e){n("component.optionValidators.websockets",e)}};var Se=(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"&&!C(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned a string.`),e==="classList"&&!j(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned an array of strings.`)}catch(e){n("component.optionValidators.wrapper",e)}};var Oe={css:ye,events:ge,lifecycle:$e,methods:Fe,name:Ee,render:Me,websockets:ke,wrapper:Se};var Te=(t={})=>{try{ue(t)||n("component.validateOptions",`component options must include ${required.options.join(",")}.`);for(let[e,r]of Object.entries(t)){fe.includes(e)||n("component.validateOptions",`${e} is not supported by joystick.component.`);let o=Oe[e];o&&m(o)&&o(r)}}catch(e){n("component.validateOptions",e)}};var ve="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),U=(t=16)=>{let e="",r=0;for(;r<t;)e+=ve[Math.floor(Math.random()*(ve.length-1))],r+=1;return e};var B=(t=[],e="")=>{try{return(j(t)&&t.find(o=>o?.componentId===e))?.data||{}}catch(r){n("findComponentDataFromSSR",r)}};var Ce=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var P=t=>!!(t&&typeof t=="object"&&!Array.isArray(t));var Re=t=>typeof t=="string";var Ae=/^(?: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}))$/,Le=(t,e="")=>{if(!e)return!0;if(e&&!Re(e))return!1;let r=e?e.replace(/[- ]+/g,""):"";return t===!0?r.match(new RegExp(Ae)):!r.match(new RegExp(Ae))};var De=/^((?:[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])+)\]))$/,je=(t,e="")=>t===!0?!!e.match(De):!e.match(De);var Pe=(t,e="")=>t===e;var Ie=(t,e="")=>t===e;var _e=(t,e="")=>e.length<=t;var Ne=(t,e="")=>e.length>=t;var Ve=/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/,Ue=(t,e="")=>t===!0?!!e.match(Ve):!e.match(Ve);var qe={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:/^[A-Za-z]{2}\s([A-Za-z]{2}|\d{2})$/,BT:/^\d{5}$/,BO:/^\d{4}$/,BA:/^\d{5}$/,BR:/^\d{5}-\d{3}$/,"":/^[Bb][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,IO:/^[Bb]{2}[Nn][Dd]\s{0,1}[1][Zz]{2}$/,VG:/^[Vv][Gg]\d{4}$/,BN:/^[A-Za-z]{2}\d{4}$/,BG:/^\d{4}$/,KH:/^\d{5}$/,CA:/^(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\d(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\s{0,1}\d(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\d$/,CV:/^\d{4}$/,KY:/^[Kk][Yy]\d[-\s]{0,1}\d{4}$/,TD:/^\d{5}$/,CL:/^\d{7}\s\(\d{3}-\d{4}\)$/,CN:/^\d{6}$/,CX:/^\d{4}$/,CC:/^\d{4}$/,CO:/^\d{6}$/,CD:/^[Cc][Dd]$/,CR:/^\d{4,5}$/,HR:/^\d{5}$/,CU:/^\d{5}$/,CY:/^\d{4}$/,CZ:/^\d{5}\s\(\d{3}\s\d{2}\)$/,DK:/^\d{4}$/,DO:/^\d{5}$/,EC:/^\d{6}$/,SV:/^1101$/,EG:/^\d{5}$/,EE:/^\d{5}$/,ET:/^\d{4}$/,FK:/^[Ff][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,FO:/^\d{3}$/,FI:/^\d{5}$/,FR:/^\d{5}$/,GF:/^973\d{2}$/,PF:/^987\d{2}$/,GA:/^\d{2}\s[a-zA-Z-_ ]\s\d{2}$/,GE:/^\d{4}$/,DE:/^\d{2}$/,GI:/^[Gg][Xx][1]{2}\s{0,1}[1][Aa]{2}$/,GR:/^\d{3}\s{0,1}\d{2}$/,GL:/^\d{4}$/,GP:/^971\d{2}$/,GU:/^\d{5}$/,GT:/^\d{5}$/,GG:/^[A-Za-z]{2}\d\s{0,1}\d[A-Za-z]{2}$/,GW:/^\d{4}$/,HT:/^\d{4}$/,HM:/^\d{4}$/,HN:/^\d{5}$/,HU:/^\d{4}$/,IS:/^\d{3}$/,IN:/^\d{6}$/,ID:/^\d{5}$/,IR:/^\d{5}-\d{5}$/,IQ:/^\d{5}$/,IM:/^[Ii[Mm]\d{1,2}\s\d\[A-Z]{2}$/,IL:/^\b\d{5}(\d{2})?$/,IT:/^\d{5}$/,JM:/^\d{2}$/,JP:/^\d{7}\s\(\d{3}-\d{4}\)$/,JE:/^[Jj][Ee]\d\s{0,1}\d[A-Za-z]{2}$/,JO:/^\d{5}$/,KZ:/^\d{6}$/,KE:/^\d{5}$/,KR:/^\d{6}\s\(\d{3}-\d{3}\)$/,XK:/^\d{5}$/,KW:/^\d{5}$/,KG:/^\d{6}$/,LV:/^[Ll][Vv][- ]{0,1}\d{4}$/,LA:/^\d{5}$/,LB:/^\d{4}\s{0,1}\d{4}$/,LS:/^\d{3}$/,LR:/^\d{4}$/,LY:/^\d{5}$/,LI:/^\d{4}$/,LT:/^[Ll][Tt][- ]{0,1}\d{5}$/,LU:/^\d{4}$/,MK:/^\d{4}$/,MG:/^\d{3}$/,MV:/^\d{4,5}$/,MY:/^\d{5}$/,MT:/^[A-Za-z]{3}\s{0,1}\d{4}$/,MH:/^\d{5}$/,MQ:/^972\d{2}$/,YT:/^976\d{2}$/,FM:/^\d{5}(-{1}\d{4})$/,MX:/^\d{5}$/,MD:/^[Mm][Dd][- ]{0,1}\d{4}$/,MC:/^980\d{2}$/,MN:/^\d{5}$/,ME:/^\d{5}$/,MS:/^[Mm][Ss][Rr]\s{0,1}\d{4}$/,MA:/^\d{5}$/,MZ:/^\d{4}$/,MM:/^\d{5}$/,NA:/^\d{5}$/,NP:/^\d{5}$/,NL:/^\d{4}\s{0,1}[A-Za-z]{2}$/,NC:/^988\d{2}$/,NZ:/^\d{4}$/,NI:/^\d{5}$/,NE:/^\d{4}$/,NG:/^\d{6}$/,NF:/^\d{4}$/,MP:/^\d{5}$/,NO:/^\d{4}$/,OM:/^\d{3}$/,PK:/^\d{5}$/,PW:/^\d{5}$/,PA:/^\d{6}$/,PG:/^\d{3}$/,PY:/^\d{4}$/,PE:/^\d{5}$/,PH:/^\d{4}$/,PN:/^[Pp][Cc][Rr][Nn]\s{0,1}[1][Zz]{2}$/,PL:/^\d{2}[- ]{0,1}\d{3}$/,PT:/^\d{4}$/,PR:/^\d{5}$/,RE:/^974\d{2}$/,RO:/^\d{6}$/,RU:/^\d{6}$/,BL:/^97133$/,SH:/^[Ss][Tt][Hh][Ll]\s{0,1}[1][Zz]{2}$/,MF:/^97150$/,PM:/^97500$/,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}$/},ze=(t,e="")=>{let r=P(t)&&t.iso?qe[t.iso||"US"]:qe.US;return P(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var He=(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 Ze=/^(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-]+)*))?$/,Be=(t,e="")=>t===!0?!!e.match(Ze):!e.match(Ze);var Ge=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Ke=(t,e="")=>t===!0?!!e.match(Ge):!e.match(Ge);var We=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/,Je=(t,e="")=>t===!0?!!e.match(We):!e.match(We);var Qe=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,Ye=(t,e="")=>t===!0?!!e.match(Qe):!e.match(Qe);var Xe={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},et=(t,e="")=>{let r=P(t)&&t.iso?Xe[t.iso||"EU"]:Xe.EU;return P(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var tt={creditCard:Le,email:je,equals:Pe,matches:Ie,maxLength:_e,minLength:Ne,phone:Ue,postalCode:ze,required:He,semVer:Be,slug:Ke,strongPassword:Je,url:Ye,vat:et};var rt=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={required:()=>"This field is required.",email:()=>"Must be a valid email.",creditCard:()=>"Must be a valid credit card number.",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.",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.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(([d,a])=>({name:d,rule:a,valid:!1})).sort((d,a)=>d.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=()=>{Ce(()=>{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){this.clearExistingErrors();let r=this.fields.find(o=>o.name===e);return 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 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,i))}});let d=e.validations.some(a=>!a.valid);return d&&(r.classList.add("error"),r.focus()),d||(r.classList.remove("error"),this.clearExistingError(e.name)),!d}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=tt[o.name];return i?i(o.rule,r,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.remove())}clearExistingError(e=""){let r=document.getElementById(`error-${e}`);r&&r.remove()}renderError(e,r=""){if(e){this.clearExistingError(e.name);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)}}},ir=(t,e)=>new Promise((r,o)=>{try{new rt(t,e).validate()?r():o()}catch(i){console.warn(i)}}),ot=ir;var it=(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],d=t[i]||null,a=!he(s)&&!we(s);return o[i]=a?s:d,o},{})}catch(r){n("component.props.compile",r)}};var nt=(t="",e={})=>{try{let r="";if(t&&C(t))return r=t,r;if(t&&m(t))return r=t(e),r;if(t&&u(t)){let o=t?.print&&(C(t?.print)||m(t?.print)),i=t?.min&&u(t?.min),s=t?.min?.width&&u(t?.min?.width),d=t?.min?.height&&u(t?.min?.height),a=t?.max&&u(t?.max),l=t?.max?.width&&u(t?.max?.width),g=t?.max?.height&&u(t?.max?.height);if(o&&(r+=`
1
+ var Wt=Object.create;var oe=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Yt=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty;var er=t=>oe(t,"__esModule",{value:!0});var tr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var rr=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qt(e))!Xt.call(t,o)&&o!=="default"&&oe(t,o,{get:()=>e[o],enumerable:!(r=Jt(e,o))||r.enumerable});return t},or=t=>rr(er(oe(t!=null?Wt(Yt(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var yt=tr(Y=>{(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof Y!="undefined")e(Y);else{var r={exports:{}};e(r.exports),t.index=r.exports}})(Y,function(t){"use strict";function e(p){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},e(p)}function r(p,c){return c&&(e(c)==="object"||typeof c=="function")?c: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(c){return c.__proto__||Object.getPrototypeOf(c)},i(p)}function s(p,c){if(typeof c!="function"&&c!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(c&&c.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),c&&d(p,c)}function d(p,c){return d=Object.setPrototypeOf||function(b,T){return b.__proto__=T,b},d(p,c)}function a(p,c){if(!(p instanceof c))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;var l=function p(c,b){a(this,p),this.type=c,this.path=b?b.toString():""},g=function(p){function c(b,T,h){var A;return a(this,c),A=r(this,i(c).call(this,"E",b)),A.lhs=T,A.rhs=h,A}return s(c,p),c}(l),y=function(p){function c(b,T,h,A){var $;return a(this,c),$=r(this,i(c).call(this,"M",b)),$.item=T,$.lhsIndex=h,$.rhsIndex=A,$}return s(c,p),c}(l),w=function(p){function c(b,T){var h;return a(this,c),h=r(this,i(c).call(this,"D",b)),h.lhs=T,h}return s(c,p),c}(l),v=function(p){function c(b,T){var h;return a(this,c),h=r(this,i(c).call(this,"A",b)),h.rhs=T,h}return s(c,p),c}(l),f=function(p,c){return p?"".concat(p,".").concat(c):c};t.diff=function(c,b){var T=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},h=[],A=T.matchKey,$=T.types||["E","A","D","M"],Kt=function(F,x,E,D){F.forEach(function(L,M){var O=x.findIndex(function(k){return k[D]===L[D]});-1<O?(-1<$.indexOf("M")&&M!==O&&h.push(new y(E,L,M,O)),Z(L,x[O],f(E,O))):-1<$.indexOf("D")&&h.push(new w(E,L))}),x.forEach(function(L,M){var O=F.findIndex(function(k){return L[D]===k[D]});-1<$.indexOf("A")&&O===-1&&h.push(new v(f(E,M),L))})},Z=function(F,x,E){var D=Object.prototype.toString.call(F),L=Object.prototype.toString.call(x);if(-1<$.indexOf("E")&&D!==L)return h.push(new g(E,F,x)),!1;if(D==="[object Object]")Object.getOwnPropertyNames(F).forEach(function(k){Object.prototype.hasOwnProperty.call(x,k)?Z(F[k],x[k],f(E,k)):-1<$.indexOf("D")&&h.push(new w(f(E,k),F[k]))}),Object.getOwnPropertyNames(x).forEach(function(k){-1<$.indexOf("A")&&!Object.prototype.hasOwnProperty.call(F,k)&&h.push(new v(f(E,k),x[k]))});else if(D!=="[object Array]")-1<$.indexOf("E")&&F!==x&&h.push(new g(E,F,x));else if(A)Kt(F,x,E,A);else{var M=F.length-1,O=x.length-1;if(-1<$.indexOf("D"))for(;M>O;)h.push(new w(f(E,M),F[M--]));if(-1<$.indexOf("A"))for(;O>M;)h.push(new v(f(E,O),x[O--]));for(;0<=M;--M)Z(F[M],x[M],f(E,M))}};return Z(c,b),h}})});var n=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var pe=["render"];var ue=(t={})=>{try{return pe.every(e=>Object.keys(t).includes(e))}catch(e){n("component.hasAllRequiredOptions",e)}};var fe=["_componentId","_ssrId","api","dataFromSSR","existingProps","existingState","instanceId","parent","req","css","data","defaultProps","events","id","lifecycle","methods","name","props","render","state","translations","url","websockets","wrapper"];var he=t=>{try{return typeof t=="undefined"}catch(e){n("types.isUndefined",e)}},we=t=>{try{return t===null}catch(e){n("types.isNull",e)}};var j=t=>{try{return!!Array.isArray(t)}catch(e){n("types.isArray",e)}};var m=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 C=t=>{try{return typeof t=="string"}catch(e){n("types.isString",e)}};var ye=(t=null)=>{try{!C(t)&&!m(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 xe=["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 ge=(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(" ");xe.includes(r)||n("component.optionValidators.events",`${r} is not a supported JavaScript event type.`)}for(let[e,r]of Object.entries(t))m(r)||n("component.optionValidators.events",`options.events.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.events",e)}};var be=["onBeforeMount","onMount","onUpdateProps","onBeforeUnmount","onRefetchData"];var $e=(t=null)=>{try{u(t)||n("component.optionValidators.lifecycle","options.lifecycle must be an object.");for(let[e,r]of Object.entries(t))be.includes(e)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} is not supported.`),m(r)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.lifecycle",e)}};var Fe=(t=null)=>{try{u(t)||n("component.optionValidators.methods","options.methods must be an object.");for(let[e,r]of Object.entries(t))m(r)||n("component.optionValidators.methods",`options.methods.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.methods",e)}};var Ee=(t=null)=>{typeof t!="string"&&n("component.optionValidators.name","options.name must be a string.")};var Me=(t=null)=>{try{m(t)||n("component.optionValidators.render","options.render must be a function returning a string.")}catch(e){n("component.optionValidators.render",e)}};var ke=(t=null)=>{try{m(t)||n("component.optionValidators.websockets","options.websockets must be a function returning an object.")}catch(e){n("component.optionValidators.websockets",e)}};var Se=(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"&&!C(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned a string.`),e==="classList"&&!j(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned an array of strings.`)}catch(e){n("component.optionValidators.wrapper",e)}};var Te={css:ye,events:ge,lifecycle:$e,methods:Fe,name:Ee,render:Me,websockets:ke,wrapper:Se};var Oe=(t={})=>{try{ue(t)||n("component.validateOptions",`component options must include ${required.options.join(",")}.`);for(let[e,r]of Object.entries(t)){fe.includes(e)||n("component.validateOptions",`${e} is not supported by joystick.component.`);let o=Te[e];o&&m(o)&&o(r)}}catch(e){n("component.validateOptions",e)}};var ve="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),U=(t=16)=>{let e="",r=0;for(;r<t;)e+=ve[Math.floor(Math.random()*(ve.length-1))],r+=1;return e};var B=(t=[],e="")=>{try{return(j(t)&&t.find(o=>o?.componentId===e))?.data||{}}catch(r){n("findComponentDataFromSSR",r)}};var Ce=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var P=t=>!!(t&&typeof t=="object"&&!Array.isArray(t));var Re=t=>typeof t=="string";var Ae=/^(?: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}))$/,Le=(t,e="")=>{if(!e)return!0;if(e&&!Re(e))return!1;let r=e?e.replace(/[- ]+/g,""):"";return t===!0?r.match(new RegExp(Ae)):!r.match(new RegExp(Ae))};var De=/^((?:[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])+)\]))$/,je=(t,e="")=>t===!0?!!e.match(De):!e.match(De);var Pe=(t,e="")=>t===e;var Ie=(t,e="")=>t===e;var _e=(t,e="")=>e.length<=t;var Ne=(t,e="")=>e.length>=t;var Ve=/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/,Ue=(t,e="")=>t===!0?!!e.match(Ve):!e.match(Ve);var qe={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:/^[A-Za-z]{2}\s([A-Za-z]{2}|\d{2})$/,BT:/^\d{5}$/,BO:/^\d{4}$/,BA:/^\d{5}$/,BR:/^\d{5}-\d{3}$/,"":/^[Bb][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,IO:/^[Bb]{2}[Nn][Dd]\s{0,1}[1][Zz]{2}$/,VG:/^[Vv][Gg]\d{4}$/,BN:/^[A-Za-z]{2}\d{4}$/,BG:/^\d{4}$/,KH:/^\d{5}$/,CA:/^(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\d(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\s{0,1}\d(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\d$/,CV:/^\d{4}$/,KY:/^[Kk][Yy]\d[-\s]{0,1}\d{4}$/,TD:/^\d{5}$/,CL:/^\d{7}\s\(\d{3}-\d{4}\)$/,CN:/^\d{6}$/,CX:/^\d{4}$/,CC:/^\d{4}$/,CO:/^\d{6}$/,CD:/^[Cc][Dd]$/,CR:/^\d{4,5}$/,HR:/^\d{5}$/,CU:/^\d{5}$/,CY:/^\d{4}$/,CZ:/^\d{5}\s\(\d{3}\s\d{2}\)$/,DK:/^\d{4}$/,DO:/^\d{5}$/,EC:/^\d{6}$/,SV:/^1101$/,EG:/^\d{5}$/,EE:/^\d{5}$/,ET:/^\d{4}$/,FK:/^[Ff][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,FO:/^\d{3}$/,FI:/^\d{5}$/,FR:/^\d{5}$/,GF:/^973\d{2}$/,PF:/^987\d{2}$/,GA:/^\d{2}\s[a-zA-Z-_ ]\s\d{2}$/,GE:/^\d{4}$/,DE:/^\d{2}$/,GI:/^[Gg][Xx][1]{2}\s{0,1}[1][Aa]{2}$/,GR:/^\d{3}\s{0,1}\d{2}$/,GL:/^\d{4}$/,GP:/^971\d{2}$/,GU:/^\d{5}$/,GT:/^\d{5}$/,GG:/^[A-Za-z]{2}\d\s{0,1}\d[A-Za-z]{2}$/,GW:/^\d{4}$/,HT:/^\d{4}$/,HM:/^\d{4}$/,HN:/^\d{5}$/,HU:/^\d{4}$/,IS:/^\d{3}$/,IN:/^\d{6}$/,ID:/^\d{5}$/,IR:/^\d{5}-\d{5}$/,IQ:/^\d{5}$/,IM:/^[Ii[Mm]\d{1,2}\s\d\[A-Z]{2}$/,IL:/^\b\d{5}(\d{2})?$/,IT:/^\d{5}$/,JM:/^\d{2}$/,JP:/^\d{7}\s\(\d{3}-\d{4}\)$/,JE:/^[Jj][Ee]\d\s{0,1}\d[A-Za-z]{2}$/,JO:/^\d{5}$/,KZ:/^\d{6}$/,KE:/^\d{5}$/,KR:/^\d{6}\s\(\d{3}-\d{3}\)$/,XK:/^\d{5}$/,KW:/^\d{5}$/,KG:/^\d{6}$/,LV:/^[Ll][Vv][- ]{0,1}\d{4}$/,LA:/^\d{5}$/,LB:/^\d{4}\s{0,1}\d{4}$/,LS:/^\d{3}$/,LR:/^\d{4}$/,LY:/^\d{5}$/,LI:/^\d{4}$/,LT:/^[Ll][Tt][- ]{0,1}\d{5}$/,LU:/^\d{4}$/,MK:/^\d{4}$/,MG:/^\d{3}$/,MV:/^\d{4,5}$/,MY:/^\d{5}$/,MT:/^[A-Za-z]{3}\s{0,1}\d{4}$/,MH:/^\d{5}$/,MQ:/^972\d{2}$/,YT:/^976\d{2}$/,FM:/^\d{5}(-{1}\d{4})$/,MX:/^\d{5}$/,MD:/^[Mm][Dd][- ]{0,1}\d{4}$/,MC:/^980\d{2}$/,MN:/^\d{5}$/,ME:/^\d{5}$/,MS:/^[Mm][Ss][Rr]\s{0,1}\d{4}$/,MA:/^\d{5}$/,MZ:/^\d{4}$/,MM:/^\d{5}$/,NA:/^\d{5}$/,NP:/^\d{5}$/,NL:/^\d{4}\s{0,1}[A-Za-z]{2}$/,NC:/^988\d{2}$/,NZ:/^\d{4}$/,NI:/^\d{5}$/,NE:/^\d{4}$/,NG:/^\d{6}$/,NF:/^\d{4}$/,MP:/^\d{5}$/,NO:/^\d{4}$/,OM:/^\d{3}$/,PK:/^\d{5}$/,PW:/^\d{5}$/,PA:/^\d{6}$/,PG:/^\d{3}$/,PY:/^\d{4}$/,PE:/^\d{5}$/,PH:/^\d{4}$/,PN:/^[Pp][Cc][Rr][Nn]\s{0,1}[1][Zz]{2}$/,PL:/^\d{2}[- ]{0,1}\d{3}$/,PT:/^\d{4}$/,PR:/^\d{5}$/,RE:/^974\d{2}$/,RO:/^\d{6}$/,RU:/^\d{6}$/,BL:/^97133$/,SH:/^[Ss][Tt][Hh][Ll]\s{0,1}[1][Zz]{2}$/,MF:/^97150$/,PM:/^97500$/,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}$/},ze=(t,e="")=>{let r=P(t)&&t.iso?qe[t.iso||"US"]:qe.US;return P(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var He=(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 Ze=/^(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-]+)*))?$/,Be=(t,e="")=>t===!0?!!e.match(Ze):!e.match(Ze);var Ge=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Ke=(t,e="")=>t===!0?!!e.match(Ge):!e.match(Ge);var We=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/,Je=(t,e="")=>t===!0?!!e.match(We):!e.match(We);var Qe=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,Ye=(t,e="")=>t===!0?!!e.match(Qe):!e.match(Qe);var Xe={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},et=(t,e="")=>{let r=P(t)&&t.iso?Xe[t.iso||"EU"]:Xe.EU;return P(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var tt={creditCard:Le,email:je,equals:Pe,matches:Ie,maxLength:_e,minLength:Ne,phone:Ue,postalCode:ze,required:He,semVer:Be,slug:Ke,strongPassword:Je,url:Ye,vat:et};var rt=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={required:()=>"This field is required.",email:()=>"Must be a valid email.",creditCard:()=>"Must be a valid credit card number.",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.",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.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(([d,a])=>({name:d,rule:a,valid:!1})).sort((d,a)=>d.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=()=>{Ce(()=>{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){this.clearExistingErrors();let r=this.fields.find(o=>o.name===e);return 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 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,i))}});let d=e.validations.some(a=>!a.valid);return d&&(r.classList.add("error"),r.focus()),d||(r.classList.remove("error"),this.clearExistingError(e.name)),!d}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=tt[o.name];return i?i(o.rule,r,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.remove())}clearExistingError(e=""){let r=document.getElementById(`error-${e}`);r&&r.remove()}renderError(e,r=""){if(e){this.clearExistingError(e.name);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)}}},ir=(t,e)=>new Promise((r,o)=>{try{new rt(t,e).validate()?r():o()}catch(i){console.warn(i)}}),ot=ir;var it=(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],d=t[i]||null,a=!he(s)&&!we(s);return o[i]=a?s:d,o},{})}catch(r){n("component.props.compile",r)}};var nt=(t="",e={})=>{try{let r="";if(t&&C(t))return r=t,r;if(t&&m(t))return r=t(e),r;if(t&&u(t)){let o=t?.print&&(C(t?.print)||m(t?.print)),i=t?.min&&u(t?.min),s=t?.min?.width&&u(t?.min?.width),d=t?.min?.height&&u(t?.min?.height),a=t?.max&&u(t?.max),l=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
  }
@@ -18,4 +18,4 @@ var Wt=Object.create;var oe=Object.defineProperty;var Jt=Object.getOwnPropertyDe
18
18
  @media screen and (max-height: ${v}px) {
19
19
  ${typeof f=="function"?f(e):f}
20
20
  }
21
- `}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var nr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!j(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},G=(t={},e={})=>{try{return m(e)?nr(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var ie={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var st=(t={},e={})=>{try{return e?Object.entries({...ie,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ie}catch(r){n("component.lifecycle.compile",r)}};var K=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{n("component.methods.compile")}};var ne=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>C(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){n("component.url.compile",e)}};var S=()=>typeof window=="undefined";var I=null,W=0,at=(t={},e=null)=>{try{let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);I&&(clearInterval(I),I=null);let i={client:o,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(i),W=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&t.events.onMessage(JSON.parse(s.data||{}),i)}),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,i),o=null;let d=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!I&&!d&&(I=setInterval(()=>{o=null,W<(t?.options?.reconnectAttempts||12)?(at(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${W+1}/12)...`),W+=1):clearInterval(I)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},dt=at;var sr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!j(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},ct=(t={},e={})=>{try{return m(e)?sr(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var lt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=U(8),t.ssrId=e?._ssrId||null,t.css=nt(),t.data=B(e?.dataFromSSR,e?._componentId),t.defaultProps=ct(t,e?.defaultProps),t.props=it(t?.defaultProps,e?.props),t.state=G(t,e?.state),t.events=e?.events||{},t.lifecycle=st(t,e?.lifecycle),t.methods=K(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=ot,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=ne(e?.url)),r&&window.__joystick_url__&&(t.url=ne(window.__joystick_url__)),r&&e?.websockets&&m(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[d,a]=i[s];dt({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${d}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(l={})=>{t.websockets={...t.websockets||{},[d]:l}})}}}catch(r){n("component.registerOptions",r)}};var _=(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){n(t,r)}};var J=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var ar=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.get.handleParseResponse",e)}},mt=(t="",e={})=>{try{return typeof window.fetch!="undefined"&&!e?.skip?new Promise((r,o)=>{let i=e.input?JSON.stringify(e.input):null,s=e.output?JSON.stringify(e.output):null,d=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(d,{method:"GET",mode:"cors",headers:{...e?.headers||{},"x-joystick-csrf":a},credentials:"include"}).then(async l=>{let g=await ar(l);return g?.errors?(_("get request",g.errors),o(g)):r(g)}).catch(l=>(_("get request",[l]),o({errors:[l]})))}):Promise.resolve()}catch(r){n("get request",r)}};var dr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.set.handleParseResponse",e)}},cr=(t={})=>{try{return JSON.stringify(t)}catch(e){n("api.set.getBody",e)}},pt=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=cr(e),d=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(i,{method:"POST",mode:"cors",headers:{...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":d},body:s,credentials:"include"}).then(async a=>{let l=await dr(a);return l?.errors?(_("set request",l.errors),o(l)):r(l)}).catch(a=>(_("set request",[a]),o({errors:[a]})))}):Promise.resolve()}catch(r){n("set request",r)}};var ut={get:mt,set:pt};var lr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("addToQueue.getQueue",e)}},q=(t="",e=null)=>{try{S()||(lr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Q=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&m(o.options.data)){let i=await o.options.data(t,e,r,o);return Promise.resolve(i)}return Promise.resolve()}catch(i){n("component.data.fetch",i)}};var ft=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let i=await Q(ut,e,o,r);return r.data=ft(i,e,r),window.__joystick_data__[r?.id]=i,r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),i}}}catch(o){n("component.data.compile",o)}},ht=ft;var wt=(t={})=>{try{if(!S()&&window.__joystick_data__&&window.__joystick_data__[t?.id]){let e=window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return ht(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var bt=or(yt());var xt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(u(t)&&o){let i=Object.keys(t);for(let s=0;s<i.length;s+=1){let d=i[s],a=t[d];if(d===r&&a===e)return t;if(d==="children"&&Array.isArray(a))for(let l=0;l<a.length;l+=1){let g=a[l],y=xt(g,e,r);if(y!==null)return y}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},R=xt;var gt=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var mr=(t={},e={},r=null)=>{try{let o=N(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){n("component.renderMethods.component.renderForClient",o)}},pr=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){n("component.renderMethods.component.renderToHTMLForSSR",e)}},ur=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){n("component.renderMethods.component.collectDataFunctionsForSSR",e)}},fr=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};gt(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){n("component.renderMethods.component.handleAddComponentToParent",e)}},hr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&q("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&q("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},wr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,bt.diff)(e?.existingPropsMap,r)?.length>0&&q("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t)})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},yr=function(){return function(e=null,r={},o={}){let i=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[i.id]||{},d=o.children[i.id]||[],a=s[d?.length];return i.state=a?.state||i.state,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,wr(i,o,r),q("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),hr(this,i),i.parent&&fr(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?ur(i):i.parent&&i.parent.ssrTree?pr(i):mr(i,this,a?.children)}},xr=function(e,r){try{let o=this;return new yr().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},se=xr;var gr=function(e=[],r=null){try{return m(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},ae=gr;var br=function(e="",r={}){try{let o=S()?this.translations:window.__joystick_i18n__;if(!o||!o[e])return"";let i=Object.entries(r);return i.length>0?i.reduce((s,[d,a])=>s.replace(`{{${d}}}`,a),o[e]):o[e]}catch(o){n("component.renderMethods.i18n",o)}},de=br;var $r=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},ce=$r;var $t={c:se,component:se,e:ae,each:ae,i:de,i18n:de,w:ce,when:ce};var Ft=(t={},e={})=>{try{return Object.entries($t).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var Et=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,children:Et(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},Mt=(t={})=>{try{return Et(t)}catch(e){n("component.render.getExistingStateMap",e)}};var kt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),Fr=new RegExp(/\n/g);var Er=(t="")=>{try{return(t.match(kt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},St=(t="")=>{try{let e=`${t}`;return e=Er(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var Ot=(t={},e="")=>{try{let{wrapper:r=null,ssrId:o=null,id:i=null,instanceId:s=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""}js-ssrId="${o}" js-c="${i}" js-i="${s}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Tt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,d]=o[i];for(let a=0;a<d?.length;a+=1){let l=d[a];Object.entries(l?.timers)?.length>0&&r.push(...Object.values(l?.timers)),Object.entries(l?.children)?.length>0&&Tt(l?.children,r)}}if(r?.length>0)for(let i=0;i<r?.length;i+=1)clearTimeout(r[i])}catch(r){n("component.render.clearTimersOnChildren",r)}},vt=Tt;var X=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=B(e.dataFromSSR,t.id)||{}),vt(t?.children);let r=Mt(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Ft({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=K(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=St(o),s=Ot(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Mr=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},Ct=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Ct(e):le(e)):le(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},le=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Mr(t.attributes),children:[].flatMap.call(t.childNodes,o=>Ct(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},z=le;var kr=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},Rt=(t="")=>{try{let e=kr(t);return z(e)}catch(e){n("component.virtualDOM.build",e)}};var At=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var Sr=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[i,s]=r[o];At(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=Lt(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},Lt=(t=null)=>{try{return C(t)?document.createTextNode(t):Sr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},V=Lt;var N=(t={},e={})=>{try{let r=X(t,{existingChildren:e?.existingChildren}),o=Rt(r.wrapped,t),i=e.includeActual&&o?V(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var Dt=(t={},e={})=>{try{let r=N(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Or=(t={},e={})=>{let r=[];for(let[o,i]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,i),s));for(let o in t)o in e||r.push(i=>(i&&i.removeAttribute&&i.removeAttribute(o),i));return o=>{for(let i of r)i&&typeof i=="function"&&i(o)}},ee=Or;var Tr=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],d=e[i];r.push([s,d])}return r},jt=Tr;var vr=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Cr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Rr=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=d=>{let a=V(i);return d.appendChild(a),d};r.push(s)}),r},Ar=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=re(o,e[i]);r.push(s)}),r},Lr=(t=[],e=[])=>{let r=Ar(t,e),o=Rr(t,e);return i=>{if(i){let s=jt(r,i.childNodes);Cr(s),vr(o,i)}return i}},te=Lr;var Pt={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ee(t.attributes,e.attributes)(r),te([],e.children)(r);let i=r.querySelector(`option[value="${o}"]`);if(i&&(r.value=o),!i){let s=r.querySelector("option");r.value=s?.value||""}return r}};var me=(t,e)=>r=>{let o=t?V(t):null;return r&&r.replaceWith(o),o},Dr=()=>t=>{t&&t.remove()},jr=(t=void 0,e=void 0)=>t===void 0||e===void 0?Dr():typeof t=="string"||typeof e=="string"?me(e,t):t.tagName!==e.tagName?me(e):e.tagName==="select"?Pt.select(t,e):["pre","code"].includes(e.tagName)?me(e,t):i=>(ee(t.attributes,e.attributes)(i),te(t.children,e.children)(i),i),re=jr;var Pr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("processQueue.getQueue",e)}},H=(t="",e=null)=>{try{S()||(Pr(t)||{}).process(e)}catch(r){n("processQueue",r)}};var It=(t="",e=null)=>{let r=R(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var _t=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Nt=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(u(i)&&i.attributes&&i.attributes["js-i"]&&i.attributes["js-i"]===e){t.children[o]=r;break}u(i)&&Nt(i,e,r)}},Vt=Nt;var Ut=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...i]=e.split(" ");return{type:o.toLowerCase(),selector:i.join(" "),handler:r}})}catch(e){n("component.events.serialize",e)}};var qt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Ut(t?.events):[];for(let i=0;i<o?.length;i+=1){let s=o[i];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){console.log("DOM EVENT",a),Object.defineProperty(a,"target",{value:a.composedPath()[0]}),s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,d])=>d);for(let s=0;s<i?.length;s+=1){let d=i[s];qt(d,e,r)}}return r}catch(o){n("component.events.registerListenersFix.getListeners",o)}},Ir=(t={},e={})=>{try{let r=qt(t,e,[]);console.log("GETTING CALLED",r);let o=r?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:d=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:d,elementSelector:a,type:l,handler:g}=o[i];console.log({element:d,type:l,handler:g}),d.addEventListener(l,g),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:d,elementSelector:a,type:l,handler:g}]}}catch(r){n("component.events.registerListenersFix",r)}},zt=Ir;var Ht=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Ht(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},_r=(t={})=>{try{let e=Ht(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:d}=e[r];i.removeEventListener(s,d),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Zt=_r;var Bt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},Te(e),lt(this,e),this.data=wt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Q(e,r,o,i);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=z(this.DOMNode);this.dom.virtual=r}let e=this.parent?R(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!S())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return Dt(this,e);let r=this.onBeforeRender();Zt(this),It(this.instanceId);let o=N(this,{}),i=re(this.dom.virtual,o.virtual);i&&m(i)&&H("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,zt(this,this.renderMethods),this.setDOMNodeOnInstance(),H("domNodes",()=>{H("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return X(this,e)}onAfterRender(e={},r={}){S()||(_t(e.instanceId,this),window.joystick._internal.css.update(),H("lifecycle.onUpdateProps"),r?.afterSetStateRender&&m(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&m(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=G(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&m(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[U()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[U()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=R(window.joystick._internal.tree,this.instanceId,"instanceId"),i=R(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=z(i?.instance?.DOMNode);Vt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},Gt=Bt;var ed=(t={})=>{try{return(e={})=>new Gt({...t,props:e?.props,url:e?.url,translations:e?.translations,api:e?.api,req:e?.req,parent:e?.parent})}catch(e){n("component",e)}};export{ed as default};
21
+ `}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var nr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!j(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},G=(t={},e={})=>{try{return m(e)?nr(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var ie={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var st=(t={},e={})=>{try{return e?Object.entries({...ie,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ie}catch(r){n("component.lifecycle.compile",r)}};var K=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{n("component.methods.compile")}};var ne=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>C(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){n("component.url.compile",e)}};var S=()=>typeof window=="undefined";var I=null,W=0,at=(t={},e=null)=>{try{let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);I&&(clearInterval(I),I=null);let i={client:o,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(i),W=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&t.events.onMessage(JSON.parse(s.data||{}),i)}),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,i),o=null;let d=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!I&&!d&&(I=setInterval(()=>{o=null,W<(t?.options?.reconnectAttempts||12)?(at(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${W+1}/12)...`),W+=1):clearInterval(I)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},dt=at;var sr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!j(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},ct=(t={},e={})=>{try{return m(e)?sr(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var lt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=U(8),t.ssrId=e?._ssrId||null,t.css=nt(),t.data=B(e?.dataFromSSR,e?._componentId),t.defaultProps=ct(t,e?.defaultProps),t.props=it(t?.defaultProps,e?.props),t.state=G(t,e?.state),t.events=e?.events||{},t.lifecycle=st(t,e?.lifecycle),t.methods=K(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=ot,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=ne(e?.url)),r&&window.__joystick_url__&&(t.url=ne(window.__joystick_url__)),r&&e?.websockets&&m(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[d,a]=i[s];dt({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${d}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(l={})=>{t.websockets={...t.websockets||{},[d]:l}})}}}catch(r){n("component.registerOptions",r)}};var _=(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){n(t,r)}};var J=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var ar=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.get.handleParseResponse",e)}},mt=(t="",e={})=>{try{return typeof window.fetch!="undefined"&&!e?.skip?new Promise((r,o)=>{let i=e.input?JSON.stringify(e.input):null,s=e.output?JSON.stringify(e.output):null,d=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(d,{method:"GET",mode:"cors",headers:{...e?.headers||{},"x-joystick-csrf":a},credentials:"include"}).then(async l=>{let g=await ar(l);return g?.errors?(_("get request",g.errors),o(g)):r(g)}).catch(l=>(_("get request",[l]),o({errors:[l]})))}):Promise.resolve()}catch(r){n("get request",r)}};var dr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.set.handleParseResponse",e)}},cr=(t={})=>{try{return JSON.stringify(t)}catch(e){n("api.set.getBody",e)}},pt=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=cr(e),d=document.querySelector('[name="csrf"]')?.getAttribute("content");return fetch(i,{method:"POST",mode:"cors",headers:{...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":d},body:s,credentials:"include"}).then(async a=>{let l=await dr(a);return l?.errors?(_("set request",l.errors),o(l)):r(l)}).catch(a=>(_("set request",[a]),o({errors:[a]})))}):Promise.resolve()}catch(r){n("set request",r)}};var ut={get:mt,set:pt};var lr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("addToQueue.getQueue",e)}},q=(t="",e=null)=>{try{S()||(lr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Q=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&m(o.options.data)){let i=await o.options.data(t,e,r,o);return Promise.resolve(i)}return Promise.resolve()}catch(i){n("component.data.fetch",i)}};var ft=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let i=await Q(ut,e,o,r);return r.data=ft(i,e,r),window.__joystick_data__[r?.id]=i,r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),i}}}catch(o){n("component.data.compile",o)}},ht=ft;var wt=(t={})=>{try{if(!S()&&window.__joystick_data__&&window.__joystick_data__[t?.id]){let e=window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return ht(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var bt=or(yt());var xt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(u(t)&&o){let i=Object.keys(t);for(let s=0;s<i.length;s+=1){let d=i[s],a=t[d];if(d===r&&a===e)return t;if(d==="children"&&Array.isArray(a))for(let l=0;l<a.length;l+=1){let g=a[l],y=xt(g,e,r);if(y!==null)return y}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},R=xt;var gt=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var mr=(t={},e={},r=null)=>{try{let o=N(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){n("component.renderMethods.component.renderForClient",o)}},pr=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){n("component.renderMethods.component.renderToHTMLForSSR",e)}},ur=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){n("component.renderMethods.component.collectDataFunctionsForSSR",e)}},fr=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};gt(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){n("component.renderMethods.component.handleAddComponentToParent",e)}},hr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&q("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&q("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},wr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,bt.diff)(e?.existingPropsMap,r)?.length>0&&q("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t)})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},yr=function(){return function(e=null,r={},o={}){let i=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[i.id]||{},d=o.children[i.id]||[],a=s[d?.length];return i.state=a?.state||i.state,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,wr(i,o,r),q("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),hr(this,i),i.parent&&fr(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?ur(i):i.parent&&i.parent.ssrTree?pr(i):mr(i,this,a?.children)}},xr=function(e,r){try{let o=this;return new yr().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},se=xr;var gr=function(e=[],r=null){try{return m(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},ae=gr;var br=function(e="",r={}){try{let o=S()?this.translations:window.__joystick_i18n__;if(!o||!o[e])return"";let i=Object.entries(r);return i.length>0?i.reduce((s,[d,a])=>s.replace(`{{${d}}}`,a),o[e]):o[e]}catch(o){n("component.renderMethods.i18n",o)}},de=br;var $r=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},ce=$r;var $t={c:se,component:se,e:ae,each:ae,i:de,i18n:de,w:ce,when:ce};var Ft=(t={},e={})=>{try{return Object.entries($t).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var Et=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,children:Et(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},Mt=(t={})=>{try{return Et(t)}catch(e){n("component.render.getExistingStateMap",e)}};var kt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),Fr=new RegExp(/\n/g);var Er=(t="")=>{try{return(t.match(kt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},St=(t="")=>{try{let e=`${t}`;return e=Er(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var Tt=(t={},e="")=>{try{let{wrapper:r=null,ssrId:o=null,id:i=null,instanceId:s=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""}js-ssrId="${o}" js-c="${i}" js-i="${s}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Ot=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,d]=o[i];for(let a=0;a<d?.length;a+=1){let l=d[a];Object.entries(l?.timers)?.length>0&&r.push(...Object.values(l?.timers)),Object.entries(l?.children)?.length>0&&Ot(l?.children,r)}}if(r?.length>0)for(let i=0;i<r?.length;i+=1)clearTimeout(r[i])}catch(r){n("component.render.clearTimersOnChildren",r)}},vt=Ot;var X=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=B(e.dataFromSSR,t.id)||{}),vt(t?.children);let r=Mt(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Ft({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=K(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=St(o),s=Tt(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Mr=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},Ct=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Ct(e):le(e)):le(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},le=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Mr(t.attributes),children:[].flatMap.call(t.childNodes,o=>Ct(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},z=le;var kr=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},Rt=(t="")=>{try{let e=kr(t);return z(e)}catch(e){n("component.virtualDOM.build",e)}};var At=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var Sr=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[i,s]=r[o];At(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=Lt(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},Lt=(t=null)=>{try{return C(t)?document.createTextNode(t):Sr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},V=Lt;var N=(t={},e={})=>{try{let r=X(t,{existingChildren:e?.existingChildren}),o=Rt(r.wrapped,t),i=e.includeActual&&o?V(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var Dt=(t={},e={})=>{try{let r=N(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Tr=(t={},e={})=>{let r=[];for(let[o,i]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,i),s));for(let o in t)o in e||r.push(i=>(i&&i.removeAttribute&&i.removeAttribute(o),i));return o=>{for(let i of r)i&&typeof i=="function"&&i(o)}},ee=Tr;var Or=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],d=e[i];r.push([s,d])}return r},jt=Or;var vr=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Cr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Rr=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=d=>{let a=V(i);return d.appendChild(a),d};r.push(s)}),r},Ar=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=re(o,e[i]);r.push(s)}),r},Lr=(t=[],e=[])=>{let r=Ar(t,e),o=Rr(t,e);return i=>{if(i){let s=jt(r,i.childNodes);Cr(s),vr(o,i)}return i}},te=Lr;var Pt={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ee(t.attributes,e.attributes)(r),te([],e.children)(r);let i=r.querySelector(`option[value="${o}"]`);if(i&&(r.value=o),!i){let s=r.querySelector("option");r.value=s?.value||""}return r}};var me=(t,e)=>r=>{let o=t?V(t):null;return r&&r.replaceWith(o),o},Dr=()=>t=>{t&&t.remove()},jr=(t=void 0,e=void 0)=>t===void 0||e===void 0?Dr():typeof t=="string"||typeof e=="string"?me(e,t):t.tagName!==e.tagName?me(e):e.tagName==="select"?Pt.select(t,e):["pre","code"].includes(e.tagName)?me(e,t):i=>(ee(t.attributes,e.attributes)(i),te(t.children,e.children)(i),i),re=jr;var Pr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("processQueue.getQueue",e)}},H=(t="",e=null)=>{try{S()||(Pr(t)||{}).process(e)}catch(r){n("processQueue",r)}};var It=(t="",e=null)=>{let r=R(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var _t=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Nt=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(u(i)&&i.attributes&&i.attributes["js-i"]&&i.attributes["js-i"]===e){t.children[o]=r;break}u(i)&&Nt(i,e,r)}},Vt=Nt;var Ut=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...i]=e.split(" ");return{type:o.toLowerCase(),selector:i.join(" "),handler:r}})}catch(e){n("component.events.serialize",e)}};var qt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Ut(t?.events):[];for(let i=0;i<o?.length;i+=1){let s=o[i];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){a?.target?.target&&(a.target=a?.target?.target),Object.defineProperty(a,"target",{value:a.composedPath()[0]}),s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,d])=>d);for(let s=0;s<i?.length;s+=1){let d=i[s];qt(d,e,r)}}return r}catch(o){n("component.events.registerListenersFix.getListeners",o)}},Ir=(t={},e={})=>{try{let r=qt(t,e,[]);console.log("GETTING CALLED",r);let o=r?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:d=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:d,elementSelector:a,type:l,handler:g}=o[i];console.log({element:d,type:l,handler:g}),d.addEventListener(l,g),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:d,elementSelector:a,type:l,handler:g}]}}catch(r){n("component.events.registerListenersFix",r)}},zt=Ir;var Ht=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Ht(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},_r=(t={})=>{try{let e=Ht(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:d}=e[r];i.removeEventListener(s,d),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Zt=_r;var Bt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},Oe(e),lt(this,e),this.data=wt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Q(e,r,o,i);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=z(this.DOMNode);this.dom.virtual=r}let e=this.parent?R(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!S())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return Dt(this,e);let r=this.onBeforeRender();Zt(this),It(this.instanceId);let o=N(this,{}),i=re(this.dom.virtual,o.virtual);i&&m(i)&&H("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,zt(this,this.renderMethods),this.setDOMNodeOnInstance(),H("domNodes",()=>{H("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return X(this,e)}onAfterRender(e={},r={}){S()||(_t(e.instanceId,this),window.joystick._internal.css.update(),H("lifecycle.onUpdateProps"),r?.afterSetStateRender&&m(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&m(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=G(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&m(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[U()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[U()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=R(window.joystick._internal.tree,this.instanceId,"instanceId"),i=R(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=z(i?.instance?.DOMNode);Vt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},Gt=Bt;var ed=(t={})=>{try{return(e={})=>new Gt({...t,props:e?.props,url:e?.url,translations:e?.translations,api:e?.api,req:e?.req,parent:e?.parent})}catch(e){n("component",e)}};export{ed as default};
package/dist/index.js CHANGED
@@ -18,4 +18,4 @@ var Er=Object.create;var de=Object.defineProperty;var Fr=Object.getOwnPropertyDe
18
18
  @media screen and (max-height: ${R}px) {
19
19
  ${typeof f=="function"?f(e):f}
20
20
  }
21
- `}}return r}return""}catch(r){i("component.css.compileCSS",r)}};var Ir=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!I(r)?Object.assign({},r):{}}catch(r){i("component.state.compile.compileState",r)}},ee=(t={},e={})=>{try{return m(e)?Ir(t,e):Object.assign({},e)}catch(r){i("component.state.compile",r)}};var le={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var Ct=(t={},e={})=>{try{return e?Object.entries({...le,...e||{}}).reduce((r={},[o,n])=>(r[o]=()=>n({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):le}catch(r){i("component.lifecycle.compile",r)}};var te=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,n])=>(r[o]=(...s)=>n(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{i("component.methods.compile")}};var me=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>O(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){i("component.url.compile",e)}};var qr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!I(r)?Object.assign({},r):{}}catch(r){i("component.props.compileDefaultProps.compile",r)}},Rt=(t={},e={})=>{try{return m(e)?qr(t,e):Object.assign({},e)}catch(r){i("component.props.compileDefaultProps",r)}};var At=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=_(8),t.ssrId=e?._ssrId||null,t.css=X(),t.data=Y(e?.dataFromSSR,e?._componentId),t.defaultProps=Rt(t,e?.defaultProps),t.props=vt(t?.defaultProps,e?.props),t.state=ee(t,e?.state),t.events=e?.events||{},t.lifecycle=Ct(t,e?.lifecycle),t.methods=te(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=Ot,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!F();if(r||(t.url=me(e?.url)),r&&window.__joystick_url__&&(t.url=me(window.__joystick_url__)),r&&e?.websockets&&m(e?.websockets)){let o=e.websockets(t),n=u(o)&&Object.entries(o);for(let s=0;s<n?.length;s+=1){let[c,a]=n[s];Q({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(l={})=>{t.websockets={...t.websockets||{},[c]:l}})}}}catch(r){i("component.registerOptions",r)}};var Nr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("addToQueue.getQueue",e)}},G=(t="",e=null)=>{try{F()||(Nr(t)||{}).array.push({callback:e})}catch(r){i("addToQueue",r)}};var re=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&m(o.options.data)){let n=await o.options.data(t,e,r,o);return Promise.resolve(n)}return Promise.resolve()}catch(n){i("component.data.fetch",n)}};var Lt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let n=await re(Z,e,o,r);return r.data=Lt(n,e,r),window.__joystick_data__[r?.id]=n,r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),n}}}catch(o){i("component.data.compile",o)}},jt=Lt;var Dt=(t={})=>{try{if(!F()&&window.__joystick_data__&&window.__joystick_data__[t?.id]){let e=window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return jt(e,r,t)}return t?.data||{}}catch(e){i("component.loadDataFromWindow",e)}};var qt=Cr(_t());var Pt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(u(t)&&o){let n=Object.keys(t);for(let s=0;s<n.length;s+=1){let c=n[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let l=0;l<a.length;l+=1){let x=a[l],y=Pt(x,e,r);if(y!==null)return y}}}return null}catch(o){i("component.findComponentInTreeByField",o)}},L=Pt;var It=(t="",e={},r=null)=>{let o=L(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var Vr=(t={},e={},r=null)=>{try{let o=z(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){i("component.renderMethods.component.renderForClient",o)}},Ur=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){i("component.renderMethods.component.renderToHTMLForSSR",e)}},Hr=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){i("component.renderMethods.component.collectDataFunctionsForSSR",e)}},zr=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};It(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){i("component.renderMethods.component.handleAddComponentToParent",e)}},Br=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&G("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&G("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){i("component.renderMethods.component.handleLifecycle",r)}},Zr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,qt.diff)(e?.existingPropsMap,r)?.length>0&&G("lifecycle.onUpdateProps",()=>{let n=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(n||{},r,t)})}catch(o){i("component.renderMethods.component.handleOnChangeProps",o)}},Gr=function(){return function(e=null,r={},o={}){let n=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[n.id]||{},c=o.children[n.id]||[],a=s[c?.length];return n.state=a?.state||n.state,o.children[n.id]=[...o.children[n.id]||[],n],n.parent=o,Zr(n,o,r),G("lifecycle.onMount",()=>{n.setDOMNodeOnInstance()}),Br(this,n),n.parent&&zr(n),n.options.data&&n.parent.walkingTreeForSSR&&n.parent.ssrTree.dataFunctions?Hr(n):n.parent&&n.parent.ssrTree?Ur(n):Vr(n,this,a?.children)}},Wr=function(e,r){try{let o=this;return new Gr().bind({})(e,r,o)}catch(o){i("component.renderMethods.component",o)}},ue=Wr;var Kr=function(e=[],r=null){try{return m(r)&&e&&Array.isArray(e)?e.map((o,n)=>r(o,n)).join(""):""}catch(o){i("component.renderMethods.each",o)}},pe=Kr;var Jr=function(e="",r={}){try{let o=F()?this.translations:window.__joystick_i18n__;if(!o||!o[e])return"";let n=Object.entries(r);return n.length>0?n.reduce((s,[c,a])=>s.replace(`{{${c}}}`,a),o[e]):o[e]}catch(o){i("component.renderMethods.i18n",o)}},fe=Jr;var Qr=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){i("component.renderMethods.when",o)}},he=Qr;var Nt={c:ue,component:ue,e:pe,each:pe,i:fe,i18n:fe,w:he,when:he};var Vt=(t={},e={})=>{try{return Object.entries(Nt).reduce((r,[o,n])=>(r[o]=n.bind({...t,...e}),r),{})}catch(r){i("component.renderMethods.compile",r)}};var Ut=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((n={})=>({state:n?.state,children:Ut(n?.children)})),e),{})}catch(e){i("component.render.getExistingStateMap.buildMapForChildren",e)}},Ht=(t={})=>{try{return Ut(t)}catch(e){i("component.render.getExistingStateMap",e)}};var zt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),Yr=new RegExp(/\n/g);var Xr=(t="")=>{try{return(t.match(zt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){i("component.render.sanitizeHTML.removeCommentedCode",e)}},Bt=(t="")=>{try{let e=`${t}`;return e=Xr(e),e}catch(e){i("component.render.sanitizeHTML",e)}};var Zt=(t={},e="")=>{try{let{wrapper:r=null,ssrId:o=null,id:n=null,instanceId:s=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""}js-ssrId="${o}" js-c="${n}" js-i="${s}">${e}</div>`}catch(r){i("component.render.wrapHTML",r)}};var Gt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let n=0;n<o?.length;n+=1){let[s,c]=o[n];for(let a=0;a<c?.length;a+=1){let l=c[a];Object.entries(l?.timers)?.length>0&&r.push(...Object.values(l?.timers)),Object.entries(l?.children)?.length>0&&Gt(l?.children,r)}}if(r?.length>0)for(let n=0;n<r?.length;n+=1)clearTimeout(r[n])}catch(r){i("component.render.clearTimersOnChildren",r)}},Wt=Gt;var ne=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=Y(e.dataFromSSR,t.id)||{}),Wt(t?.children);let r=Ht(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Vt({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=te(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),n=Bt(o),s=Zt(t,n);return{unwrapped:n,wrapped:s}}catch(r){i("component.render.toHTML",r)}};var eo=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){i("component.virtualDOM.build.parseAttributeMap",e)}},Kt=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Kt(e):we(e)):we(t)}catch(e){i("component.virtualDOM.build.flattenWhenTags",e)}},we=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:eo(t.attributes),children:[].flatMap.call(t.childNodes,o=>Kt(o))};return e==="text"&&(r=t.textContent),r}catch(e){i("component.virtualDOM.build",e)}},W=we;var to=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){i("component.virtualDOM.build.convertHTMLToDOM",e)}},Jt=(t="")=>{try{let e=to(t);return W(e)}catch(e){i("component.virtualDOM.build",e)}};var Qt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var ro=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[n,s]=r[o];Qt(n)&&e.setAttribute(n,s)}for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(n){let s=Yt(n);e.appendChild(s)}}return e}catch(e){i("component.virtualDOM.renderTreeToDOM.renderElement",e)}},Yt=(t=null)=>{try{return O(t)?document.createTextNode(t):ro(t)}catch(e){i("component.virtualDOM.renderTreeToDOM",e)}},B=Yt;var z=(t={},e={})=>{try{let r=ne(t,{existingChildren:e?.existingChildren}),o=Jt(r.wrapped,t),n=e.includeActual&&o?B(o):null;return{html:r,virtual:o,actual:n}}catch(r){i("component.render.getUpdatedDOM",r)}};var Xt=(t={},e={})=>{try{let r=z(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){i("component.render.forMount",r)}};var oo=(t={},e={})=>{let r=[];for(let[o,n]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,n),s));for(let o in t)o in e||r.push(n=>(n&&n.removeAttribute&&n.removeAttribute(o),n));return o=>{for(let n of r)n&&typeof n=="function"&&n(o)}},ie=oo;var no=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let n=0;n<o;n+=1){let s=t[n],c=e[n];r.push([s,c])}return r},er=no;var io=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},so=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},ao=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(n=>{let s=c=>{let a=B(n);return c.appendChild(a),c};r.push(s)}),r},co=(t=[],e=[])=>{let r=[];return t.forEach((o,n)=>{let s=ae(o,e[n]);r.push(s)}),r},lo=(t=[],e=[])=>{let r=co(t,e),o=ao(t,e);return n=>{if(n){let s=er(r,n.childNodes);so(s),io(o,n)}return n}},se=lo;var tr={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ie(t.attributes,e.attributes)(r),se([],e.children)(r);let n=r.querySelector(`option[value="${o}"]`);if(n&&(r.value=o),!n){let s=r.querySelector("option");r.value=s?.value||""}return r}};var ye=(t,e)=>r=>{let o=t?B(t):null;return r&&r.replaceWith(o),o},mo=()=>t=>{t&&t.remove()},uo=(t=void 0,e=void 0)=>t===void 0||e===void 0?mo():typeof t=="string"||typeof e=="string"?ye(e,t):t.tagName!==e.tagName?ye(e):e.tagName==="select"?tr.select(t,e):["pre","code"].includes(e.tagName)?ye(e,t):n=>(ie(t.attributes,e.attributes)(n),se(t.children,e.children)(n),n),ae=uo;var po=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("processQueue.getQueue",e)}},q=(t="",e=null)=>{try{F()||(po(t)||{}).process(e)}catch(r){i("processQueue",r)}};var rr=(t="",e=null)=>{let r=L(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var or=(t="",e={},r=null)=>{let o=L(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var nr=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(u(n)&&n.attributes&&n.attributes["js-i"]&&n.attributes["js-i"]===e){t.children[o]=r;break}u(n)&&nr(n,e,r)}},ir=nr;var sr=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...n]=e.split(" ");return{type:o.toLowerCase(),selector:n.join(" "),handler:r}})}catch(e){i("component.events.serialize",e)}};var ar=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?sr(t?.events):[];for(let n=0;n<o?.length;n+=1){let s=o[n];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){console.log("DOM EVENT",a),Object.defineProperty(a,"target",{value:a.composedPath()[0]}),s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let n=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<n?.length;s+=1){let c=n[s];ar(c,e,r)}}return r}catch(o){i("component.events.registerListenersFix.getListeners",o)}},fo=(t={},e={})=>{try{let r=ar(t,e,[]);console.log("GETTING CALLED",r);let o=r?.flatMap((n={})=>[].flatMap.call(n?.elements||[],s=>{let{elements:c=[],...a}=n||{};return{...a,element:s}}));for(let n=0;n<o?.length;n+=1){let{instance:s,element:c,elementSelector:a,type:l,handler:x}=o[n];console.log({element:c,type:l,handler:x}),c.addEventListener(l,x),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:l,handler:x}]}}catch(r){i("component.events.registerListenersFix",r)}},ce=fo;var cr=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((n=[],s=[])=>[...n,...s],[])).flatMap((n={})=>cr(n));e=[...e,...o]}return e}catch(e){i("component.events.unregisterListenersFix.getListeners",e)}},ho=(t={})=>{try{let e=cr(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:n,type:s,handler:c}=e[r];n.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){i("component.events.unregisterListenersFix",e)}},dr=ho;var lr=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},et(e),At(this,e),this.data=Dt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},n=this){let s=await re(e,r,o,n);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=W(this.DOMNode);this.dom.virtual=r}let e=this.parent?L(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!F())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return Xt(this,e);let r=this.onBeforeRender();dr(this),rr(this.instanceId);let o=z(this,{}),n=ae(this.dom.virtual,o.virtual);n&&m(n)&&q("lifecycle.onBeforeMount",()=>{let s=n(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,ce(this,this.renderMethods),this.setDOMNodeOnInstance(),q("domNodes",()=>{q("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ne(this,e)}onAfterRender(e={},r={}){F()||(or(e.instanceId,this),window.joystick._internal.css.update(),q("lifecycle.onUpdateProps"),r?.afterSetStateRender&&m(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&m(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=ee(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&m(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[_()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[_()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=L(window.joystick._internal.tree,this.instanceId,"instanceId"),n=L(window.joystick._internal.tree,r,"instanceId");if(n?.instance?.DOMNode){let s=W(n?.instance?.DOMNode);ir(o?.instance?.dom?.virtual,n?.instanceId,s)}}},mr=lr;var ur=(t={})=>{try{return(e={})=>new mr({...t,props:e?.props,url:e?.url,translations:e?.translations,api:e?.api,req:e?.req,parent:e?.parent})}catch(e){i("component",e)}};var pr=(t={})=>{try{window.joystick._internal.tree={id:t?.id||null,instanceId:t?.instanceId||null,instance:t,children:[]}}catch(e){i("mount.initializeJoystickComponentTree",e)}};var fr=(t={},e=null)=>{try{return t.innerHTML="",t.appendChild(e),e}catch(r){i("mount.appendToDOM",r)}};var hr=(t=null,e={},r=null)=>{try{m(t)||i("mount","Component to mount must be a function."),u(e)||i("mount","props must be an object."),Oe(r)||i("mount","target must be a DOM node.");let o=t({props:e});pr(o);let n=o.render({mounting:!0,existingChildren:window.__joystick_childrenBeforeHMRUpdate__||null});n&&(n.setAttribute("js-ssrId",o.ssrId),n.setAttribute("js-c",o.id),n.setAttribute("js-i",o.instanceId)),o.lifecycle.onBeforeMount(),q("lifecycle.onBeforeMount"),fr(r,n),o.setDOMNodeOnInstance(),window.joystick._internal.css.update(),ce(o,o.renderMethods),o.lifecycle.onMount(),q("lifecycle.onMount")}catch(o){i("mount",o)}};var wr=class{constructor(e=[]){this.array=[...e],this.array.push=function(){Array.prototype.push.apply(this,arguments)}}async process(e=null){if(this.array.length>0){let r=this.array.shift();r&&r.callback&&(await r.callback(),this.process(e))}else e&&e()}},N=wr;var wo=new RegExp(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g),yo=new RegExp(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g),go=(t,e)=>(e||"").replace(wo,()=>"").replace(yo,r=>["@",": "].some(o=>r?.includes(o))?r:`[js-c="${t}"] ${r.trim()}`)?.trim(),yr=(t={},e=[])=>{if(t.instance&&t.instance.options&&t.instance.options.css){let r=t.instance.id,o=t.instance.options.css,n=X(o,t.instance),s=go(r,n);e.push(s)}if(t.children&&t.children.length>0){let r=t?.children?.length||0;for(;r--;)yr(t.children[r],e)}return e},gr=yr;var xr=()=>{try{let t=document.head.querySelector("style[js-styles]"),r=gr(window.joystick?._internal?.tree).reverse().join("").trim();if(t?.innerText===r)return;if(t&&(t.innerHTML=r),!t){let o=document.createElement("style");o.setAttribute("js-styles",""),o.innerHTML=r,document.head.appendChild(o)}}catch(t){i("css.update",t)}};var xo=Me,bo=Re,$o=Z.get,Eo=Ae,Fo=Le,ko=Z.set,Mo=_e,br={_external:{},_internal:{css:{update:xr},queues:{domNodes:new N([]),eventListeners:new N([]),lifecycle:{onBeforeMount:new N([]),onMount:new N([]),onUpdateProps:new N([])},render:new N([])},tree:{},eventListeners:[]},accounts:xo,cache:bo,component:ur,get:$o,html:Eo,id:_,mount:hr,renderComponentToHTML:Fo,set:ko,upload:Mo,timers:{}};Pe(br);var ml=br;export{xo as accounts,bo as cache,ml as default,$o as get,Eo as html,Fo as renderComponentToHTML,ko as set,Mo as upload};
21
+ `}}return r}return""}catch(r){i("component.css.compileCSS",r)}};var Ir=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!I(r)?Object.assign({},r):{}}catch(r){i("component.state.compile.compileState",r)}},ee=(t={},e={})=>{try{return m(e)?Ir(t,e):Object.assign({},e)}catch(r){i("component.state.compile",r)}};var le={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var Ct=(t={},e={})=>{try{return e?Object.entries({...le,...e||{}}).reduce((r={},[o,n])=>(r[o]=()=>n({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):le}catch(r){i("component.lifecycle.compile",r)}};var te=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,n])=>(r[o]=(...s)=>n(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{i("component.methods.compile")}};var me=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>O(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){i("component.url.compile",e)}};var qr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!I(r)?Object.assign({},r):{}}catch(r){i("component.props.compileDefaultProps.compile",r)}},Rt=(t={},e={})=>{try{return m(e)?qr(t,e):Object.assign({},e)}catch(r){i("component.props.compileDefaultProps",r)}};var At=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=_(8),t.ssrId=e?._ssrId||null,t.css=X(),t.data=Y(e?.dataFromSSR,e?._componentId),t.defaultProps=Rt(t,e?.defaultProps),t.props=vt(t?.defaultProps,e?.props),t.state=ee(t,e?.state),t.events=e?.events||{},t.lifecycle=Ct(t,e?.lifecycle),t.methods=te(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=Ot,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!F();if(r||(t.url=me(e?.url)),r&&window.__joystick_url__&&(t.url=me(window.__joystick_url__)),r&&e?.websockets&&m(e?.websockets)){let o=e.websockets(t),n=u(o)&&Object.entries(o);for(let s=0;s<n?.length;s+=1){let[c,a]=n[s];Q({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(l={})=>{t.websockets={...t.websockets||{},[c]:l}})}}}catch(r){i("component.registerOptions",r)}};var Nr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("addToQueue.getQueue",e)}},G=(t="",e=null)=>{try{F()||(Nr(t)||{}).array.push({callback:e})}catch(r){i("addToQueue",r)}};var re=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&m(o.options.data)){let n=await o.options.data(t,e,r,o);return Promise.resolve(n)}return Promise.resolve()}catch(n){i("component.data.fetch",n)}};var Lt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let n=await re(Z,e,o,r);return r.data=Lt(n,e,r),window.__joystick_data__[r?.id]=n,r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),n}}}catch(o){i("component.data.compile",o)}},jt=Lt;var Dt=(t={})=>{try{if(!F()&&window.__joystick_data__&&window.__joystick_data__[t?.id]){let e=window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return jt(e,r,t)}return t?.data||{}}catch(e){i("component.loadDataFromWindow",e)}};var qt=Cr(_t());var Pt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(u(t)&&o){let n=Object.keys(t);for(let s=0;s<n.length;s+=1){let c=n[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let l=0;l<a.length;l+=1){let x=a[l],y=Pt(x,e,r);if(y!==null)return y}}}return null}catch(o){i("component.findComponentInTreeByField",o)}},L=Pt;var It=(t="",e={},r=null)=>{let o=L(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var Vr=(t={},e={},r=null)=>{try{let o=z(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){i("component.renderMethods.component.renderForClient",o)}},Ur=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){i("component.renderMethods.component.renderToHTMLForSSR",e)}},Hr=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){i("component.renderMethods.component.collectDataFunctionsForSSR",e)}},zr=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};It(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){i("component.renderMethods.component.handleAddComponentToParent",e)}},Br=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&G("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&G("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){i("component.renderMethods.component.handleLifecycle",r)}},Zr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,qt.diff)(e?.existingPropsMap,r)?.length>0&&G("lifecycle.onUpdateProps",()=>{let n=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(n||{},r,t)})}catch(o){i("component.renderMethods.component.handleOnChangeProps",o)}},Gr=function(){return function(e=null,r={},o={}){let n=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[n.id]||{},c=o.children[n.id]||[],a=s[c?.length];return n.state=a?.state||n.state,o.children[n.id]=[...o.children[n.id]||[],n],n.parent=o,Zr(n,o,r),G("lifecycle.onMount",()=>{n.setDOMNodeOnInstance()}),Br(this,n),n.parent&&zr(n),n.options.data&&n.parent.walkingTreeForSSR&&n.parent.ssrTree.dataFunctions?Hr(n):n.parent&&n.parent.ssrTree?Ur(n):Vr(n,this,a?.children)}},Wr=function(e,r){try{let o=this;return new Gr().bind({})(e,r,o)}catch(o){i("component.renderMethods.component",o)}},ue=Wr;var Kr=function(e=[],r=null){try{return m(r)&&e&&Array.isArray(e)?e.map((o,n)=>r(o,n)).join(""):""}catch(o){i("component.renderMethods.each",o)}},pe=Kr;var Jr=function(e="",r={}){try{let o=F()?this.translations:window.__joystick_i18n__;if(!o||!o[e])return"";let n=Object.entries(r);return n.length>0?n.reduce((s,[c,a])=>s.replace(`{{${c}}}`,a),o[e]):o[e]}catch(o){i("component.renderMethods.i18n",o)}},fe=Jr;var Qr=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){i("component.renderMethods.when",o)}},he=Qr;var Nt={c:ue,component:ue,e:pe,each:pe,i:fe,i18n:fe,w:he,when:he};var Vt=(t={},e={})=>{try{return Object.entries(Nt).reduce((r,[o,n])=>(r[o]=n.bind({...t,...e}),r),{})}catch(r){i("component.renderMethods.compile",r)}};var Ut=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((n={})=>({state:n?.state,children:Ut(n?.children)})),e),{})}catch(e){i("component.render.getExistingStateMap.buildMapForChildren",e)}},Ht=(t={})=>{try{return Ut(t)}catch(e){i("component.render.getExistingStateMap",e)}};var zt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),Yr=new RegExp(/\n/g);var Xr=(t="")=>{try{return(t.match(zt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){i("component.render.sanitizeHTML.removeCommentedCode",e)}},Bt=(t="")=>{try{let e=`${t}`;return e=Xr(e),e}catch(e){i("component.render.sanitizeHTML",e)}};var Zt=(t={},e="")=>{try{let{wrapper:r=null,ssrId:o=null,id:n=null,instanceId:s=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""}js-ssrId="${o}" js-c="${n}" js-i="${s}">${e}</div>`}catch(r){i("component.render.wrapHTML",r)}};var Gt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let n=0;n<o?.length;n+=1){let[s,c]=o[n];for(let a=0;a<c?.length;a+=1){let l=c[a];Object.entries(l?.timers)?.length>0&&r.push(...Object.values(l?.timers)),Object.entries(l?.children)?.length>0&&Gt(l?.children,r)}}if(r?.length>0)for(let n=0;n<r?.length;n+=1)clearTimeout(r[n])}catch(r){i("component.render.clearTimersOnChildren",r)}},Wt=Gt;var ne=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=Y(e.dataFromSSR,t.id)||{}),Wt(t?.children);let r=Ht(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Vt({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=te(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),n=Bt(o),s=Zt(t,n);return{unwrapped:n,wrapped:s}}catch(r){i("component.render.toHTML",r)}};var eo=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){i("component.virtualDOM.build.parseAttributeMap",e)}},Kt=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Kt(e):we(e)):we(t)}catch(e){i("component.virtualDOM.build.flattenWhenTags",e)}},we=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:eo(t.attributes),children:[].flatMap.call(t.childNodes,o=>Kt(o))};return e==="text"&&(r=t.textContent),r}catch(e){i("component.virtualDOM.build",e)}},W=we;var to=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){i("component.virtualDOM.build.convertHTMLToDOM",e)}},Jt=(t="")=>{try{let e=to(t);return W(e)}catch(e){i("component.virtualDOM.build",e)}};var Qt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var ro=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[n,s]=r[o];Qt(n)&&e.setAttribute(n,s)}for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(n){let s=Yt(n);e.appendChild(s)}}return e}catch(e){i("component.virtualDOM.renderTreeToDOM.renderElement",e)}},Yt=(t=null)=>{try{return O(t)?document.createTextNode(t):ro(t)}catch(e){i("component.virtualDOM.renderTreeToDOM",e)}},B=Yt;var z=(t={},e={})=>{try{let r=ne(t,{existingChildren:e?.existingChildren}),o=Jt(r.wrapped,t),n=e.includeActual&&o?B(o):null;return{html:r,virtual:o,actual:n}}catch(r){i("component.render.getUpdatedDOM",r)}};var Xt=(t={},e={})=>{try{let r=z(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){i("component.render.forMount",r)}};var oo=(t={},e={})=>{let r=[];for(let[o,n]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,n),s));for(let o in t)o in e||r.push(n=>(n&&n.removeAttribute&&n.removeAttribute(o),n));return o=>{for(let n of r)n&&typeof n=="function"&&n(o)}},ie=oo;var no=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let n=0;n<o;n+=1){let s=t[n],c=e[n];r.push([s,c])}return r},er=no;var io=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},so=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},ao=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(n=>{let s=c=>{let a=B(n);return c.appendChild(a),c};r.push(s)}),r},co=(t=[],e=[])=>{let r=[];return t.forEach((o,n)=>{let s=ae(o,e[n]);r.push(s)}),r},lo=(t=[],e=[])=>{let r=co(t,e),o=ao(t,e);return n=>{if(n){let s=er(r,n.childNodes);so(s),io(o,n)}return n}},se=lo;var tr={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ie(t.attributes,e.attributes)(r),se([],e.children)(r);let n=r.querySelector(`option[value="${o}"]`);if(n&&(r.value=o),!n){let s=r.querySelector("option");r.value=s?.value||""}return r}};var ye=(t,e)=>r=>{let o=t?B(t):null;return r&&r.replaceWith(o),o},mo=()=>t=>{t&&t.remove()},uo=(t=void 0,e=void 0)=>t===void 0||e===void 0?mo():typeof t=="string"||typeof e=="string"?ye(e,t):t.tagName!==e.tagName?ye(e):e.tagName==="select"?tr.select(t,e):["pre","code"].includes(e.tagName)?ye(e,t):n=>(ie(t.attributes,e.attributes)(n),se(t.children,e.children)(n),n),ae=uo;var po=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("processQueue.getQueue",e)}},q=(t="",e=null)=>{try{F()||(po(t)||{}).process(e)}catch(r){i("processQueue",r)}};var rr=(t="",e=null)=>{let r=L(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var or=(t="",e={},r=null)=>{let o=L(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var nr=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(u(n)&&n.attributes&&n.attributes["js-i"]&&n.attributes["js-i"]===e){t.children[o]=r;break}u(n)&&nr(n,e,r)}},ir=nr;var sr=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...n]=e.split(" ");return{type:o.toLowerCase(),selector:n.join(" "),handler:r}})}catch(e){i("component.events.serialize",e)}};var ar=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?sr(t?.events):[];for(let n=0;n<o?.length;n+=1){let s=o[n];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){a?.target?.target&&(a.target=a?.target?.target),Object.defineProperty(a,"target",{value:a.composedPath()[0]}),s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let n=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<n?.length;s+=1){let c=n[s];ar(c,e,r)}}return r}catch(o){i("component.events.registerListenersFix.getListeners",o)}},fo=(t={},e={})=>{try{let r=ar(t,e,[]);console.log("GETTING CALLED",r);let o=r?.flatMap((n={})=>[].flatMap.call(n?.elements||[],s=>{let{elements:c=[],...a}=n||{};return{...a,element:s}}));for(let n=0;n<o?.length;n+=1){let{instance:s,element:c,elementSelector:a,type:l,handler:x}=o[n];console.log({element:c,type:l,handler:x}),c.addEventListener(l,x),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:l,handler:x}]}}catch(r){i("component.events.registerListenersFix",r)}},ce=fo;var cr=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((n=[],s=[])=>[...n,...s],[])).flatMap((n={})=>cr(n));e=[...e,...o]}return e}catch(e){i("component.events.unregisterListenersFix.getListeners",e)}},ho=(t={})=>{try{let e=cr(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:n,type:s,handler:c}=e[r];n.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){i("component.events.unregisterListenersFix",e)}},dr=ho;var lr=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},et(e),At(this,e),this.data=Dt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},n=this){let s=await re(e,r,o,n);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=W(this.DOMNode);this.dom.virtual=r}let e=this.parent?L(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!F())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return Xt(this,e);let r=this.onBeforeRender();dr(this),rr(this.instanceId);let o=z(this,{}),n=ae(this.dom.virtual,o.virtual);n&&m(n)&&q("lifecycle.onBeforeMount",()=>{let s=n(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,ce(this,this.renderMethods),this.setDOMNodeOnInstance(),q("domNodes",()=>{q("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ne(this,e)}onAfterRender(e={},r={}){F()||(or(e.instanceId,this),window.joystick._internal.css.update(),q("lifecycle.onUpdateProps"),r?.afterSetStateRender&&m(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&m(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=ee(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&m(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[_()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[_()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=L(window.joystick._internal.tree,this.instanceId,"instanceId"),n=L(window.joystick._internal.tree,r,"instanceId");if(n?.instance?.DOMNode){let s=W(n?.instance?.DOMNode);ir(o?.instance?.dom?.virtual,n?.instanceId,s)}}},mr=lr;var ur=(t={})=>{try{return(e={})=>new mr({...t,props:e?.props,url:e?.url,translations:e?.translations,api:e?.api,req:e?.req,parent:e?.parent})}catch(e){i("component",e)}};var pr=(t={})=>{try{window.joystick._internal.tree={id:t?.id||null,instanceId:t?.instanceId||null,instance:t,children:[]}}catch(e){i("mount.initializeJoystickComponentTree",e)}};var fr=(t={},e=null)=>{try{return t.innerHTML="",t.appendChild(e),e}catch(r){i("mount.appendToDOM",r)}};var hr=(t=null,e={},r=null)=>{try{m(t)||i("mount","Component to mount must be a function."),u(e)||i("mount","props must be an object."),Oe(r)||i("mount","target must be a DOM node.");let o=t({props:e});pr(o);let n=o.render({mounting:!0,existingChildren:window.__joystick_childrenBeforeHMRUpdate__||null});n&&(n.setAttribute("js-ssrId",o.ssrId),n.setAttribute("js-c",o.id),n.setAttribute("js-i",o.instanceId)),o.lifecycle.onBeforeMount(),q("lifecycle.onBeforeMount"),fr(r,n),o.setDOMNodeOnInstance(),window.joystick._internal.css.update(),ce(o,o.renderMethods),o.lifecycle.onMount(),q("lifecycle.onMount")}catch(o){i("mount",o)}};var wr=class{constructor(e=[]){this.array=[...e],this.array.push=function(){Array.prototype.push.apply(this,arguments)}}async process(e=null){if(this.array.length>0){let r=this.array.shift();r&&r.callback&&(await r.callback(),this.process(e))}else e&&e()}},N=wr;var wo=new RegExp(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g),yo=new RegExp(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g),go=(t,e)=>(e||"").replace(wo,()=>"").replace(yo,r=>["@",": "].some(o=>r?.includes(o))?r:`[js-c="${t}"] ${r.trim()}`)?.trim(),yr=(t={},e=[])=>{if(t.instance&&t.instance.options&&t.instance.options.css){let r=t.instance.id,o=t.instance.options.css,n=X(o,t.instance),s=go(r,n);e.push(s)}if(t.children&&t.children.length>0){let r=t?.children?.length||0;for(;r--;)yr(t.children[r],e)}return e},gr=yr;var xr=()=>{try{let t=document.head.querySelector("style[js-styles]"),r=gr(window.joystick?._internal?.tree).reverse().join("").trim();if(t?.innerText===r)return;if(t&&(t.innerHTML=r),!t){let o=document.createElement("style");o.setAttribute("js-styles",""),o.innerHTML=r,document.head.appendChild(o)}}catch(t){i("css.update",t)}};var xo=Me,bo=Re,$o=Z.get,Eo=Ae,Fo=Le,ko=Z.set,Mo=_e,br={_external:{},_internal:{css:{update:xr},queues:{domNodes:new N([]),eventListeners:new N([]),lifecycle:{onBeforeMount:new N([]),onMount:new N([]),onUpdateProps:new N([])},render:new N([])},tree:{},eventListeners:[]},accounts:xo,cache:bo,component:ur,get:$o,html:Eo,id:_,mount:hr,renderComponentToHTML:Fo,set:ko,upload:Mo,timers:{}};Pe(br);var ml=br;export{xo as accounts,bo as cache,ml as default,$o as get,Eo as html,Fo as renderComponentToHTML,ko as set,Mo as upload};
@@ -1 +1 @@
1
- var i=(e="",t={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${t.message||t.reason||t}`)};var m=e=>{try{return!0}catch(t){i("types.isDOM",t)}};var d=e=>{try{return typeof e=="function"}catch(t){i("types.isFunction",t)}};var y=e=>{try{return!!(e&&typeof e=="object"&&!Array.isArray(e))}catch(t){i("types.isObject",t)}};var f=(e={})=>{try{window.joystick._internal.tree={id:e?.id||null,instanceId:e?.instanceId||null,instance:e,children:[]}}catch(t){i("mount.initializeJoystickComponentTree",t)}};var h=()=>typeof window=="undefined";var k=(e="")=>{try{let[t,o]=e?.split(".");return o?window?.joystick?._internal?.queues[t][o]:window?.joystick?._internal?.queues[t]}catch(t){i("processQueue.getQueue",t)}},a=(e="",t=null)=>{try{h()||(k(e)||{}).process(t)}catch(o){i("processQueue",o)}};var w=(e={},t=null)=>{try{return e.innerHTML="",e.appendChild(t),t}catch(o){i("mount.appendToDOM",o)}};var x=(e={})=>{try{return Object.entries(e).map(([t,o])=>{let[r,...n]=t.split(" ");return{type:r.toLowerCase(),selector:n.join(" "),handler:o}})}catch(t){i("component.events.serialize",t)}};var b=(e={},t={},o=[])=>{try{let r=Object.keys(e?.events||{})?.length>0?x(e?.events):[];for(let n=0;n<r?.length;n+=1){let s=r[n];o.push({...s,instance:e,elements:document.querySelectorAll(`body [js-i="${e.instanceId}"] ${s?.selector}`),handler:function(p){console.log("DOM EVENT",p),Object.defineProperty(p,"target",{value:p.composedPath()[0]}),s.handler(p,{...e||{},setState:e?.setState.bind(e),...t||{}})}})}if(e?.children){let n=Object.entries(e?.children)?.flatMap(([s,c])=>c);for(let s=0;s<n?.length;s+=1){let c=n[s];b(c,t,o)}}return o}catch(r){i("component.events.registerListenersFix.getListeners",r)}},F=(e={},t={})=>{try{let o=b(e,t,[]);console.log("GETTING CALLED",o);let r=o?.flatMap((n={})=>[].flatMap.call(n?.elements||[],s=>{let{elements:c=[],...p}=n||{};return{...p,element:s}}));for(let n=0;n<r?.length;n+=1){let{instance:s,element:c,elementSelector:p,type:u,handler:l}=r[n];console.log({element:c,type:u,handler:l}),c.addEventListener(u,l),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:p,type:u,handler:l}]}}catch(o){i("component.events.registerListenersFix",o)}},g=F;var J=(e=null,t={},o=null)=>{try{d(e)||i("mount","Component to mount must be a function."),y(t)||i("mount","props must be an object."),m(o)||i("mount","target must be a DOM node.");let r=e({props:t});f(r);let n=r.render({mounting:!0,existingChildren:window.__joystick_childrenBeforeHMRUpdate__||null});n&&(n.setAttribute("js-ssrId",r.ssrId),n.setAttribute("js-c",r.id),n.setAttribute("js-i",r.instanceId)),r.lifecycle.onBeforeMount(),a("lifecycle.onBeforeMount"),w(o,n),r.setDOMNodeOnInstance(),window.joystick._internal.css.update(),g(r,r.renderMethods),r.lifecycle.onMount(),a("lifecycle.onMount")}catch(r){i("mount",r)}};export{J as default};
1
+ var i=(e="",t={})=>{throw new Error(`[joystick${e?`.${e}`:""}] ${t.message||t.reason||t}`)};var m=e=>{try{return!0}catch(t){i("types.isDOM",t)}};var d=e=>{try{return typeof e=="function"}catch(t){i("types.isFunction",t)}};var y=e=>{try{return!!(e&&typeof e=="object"&&!Array.isArray(e))}catch(t){i("types.isObject",t)}};var f=(e={})=>{try{window.joystick._internal.tree={id:e?.id||null,instanceId:e?.instanceId||null,instance:e,children:[]}}catch(t){i("mount.initializeJoystickComponentTree",t)}};var h=()=>typeof window=="undefined";var k=(e="")=>{try{let[t,o]=e?.split(".");return o?window?.joystick?._internal?.queues[t][o]:window?.joystick?._internal?.queues[t]}catch(t){i("processQueue.getQueue",t)}},l=(e="",t=null)=>{try{h()||(k(e)||{}).process(t)}catch(o){i("processQueue",o)}};var w=(e={},t=null)=>{try{return e.innerHTML="",e.appendChild(t),t}catch(o){i("mount.appendToDOM",o)}};var x=(e={})=>{try{return Object.entries(e).map(([t,o])=>{let[r,...n]=t.split(" ");return{type:r.toLowerCase(),selector:n.join(" "),handler:o}})}catch(t){i("component.events.serialize",t)}};var g=(e={},t={},o=[])=>{try{let r=Object.keys(e?.events||{})?.length>0?x(e?.events):[];for(let n=0;n<r?.length;n+=1){let s=r[n];o.push({...s,instance:e,elements:document.querySelectorAll(`body [js-i="${e.instanceId}"] ${s?.selector}`),handler:function(c){c?.target?.target&&(c.target=c?.target?.target),Object.defineProperty(c,"target",{value:c.composedPath()[0]}),s.handler(c,{...e||{},setState:e?.setState.bind(e),...t||{}})}})}if(e?.children){let n=Object.entries(e?.children)?.flatMap(([s,p])=>p);for(let s=0;s<n?.length;s+=1){let p=n[s];g(p,t,o)}}return o}catch(r){i("component.events.registerListenersFix.getListeners",r)}},F=(e={},t={})=>{try{let o=g(e,t,[]);console.log("GETTING CALLED",o);let r=o?.flatMap((n={})=>[].flatMap.call(n?.elements||[],s=>{let{elements:p=[],...c}=n||{};return{...c,element:s}}));for(let n=0;n<r?.length;n+=1){let{instance:s,element:p,elementSelector:c,type:u,handler:a}=r[n];console.log({element:p,type:u,handler:a}),p.addEventListener(u,a),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:p,elementSelector:c,type:u,handler:a}]}}catch(o){i("component.events.registerListenersFix",o)}},b=F;var v=(e=null,t={},o=null)=>{try{d(e)||i("mount","Component to mount must be a function."),y(t)||i("mount","props must be an object."),m(o)||i("mount","target must be a DOM node.");let r=e({props:t});f(r);let n=r.render({mounting:!0,existingChildren:window.__joystick_childrenBeforeHMRUpdate__||null});n&&(n.setAttribute("js-ssrId",r.ssrId),n.setAttribute("js-c",r.id),n.setAttribute("js-i",r.instanceId)),r.lifecycle.onBeforeMount(),l("lifecycle.onBeforeMount"),w(o,n),r.setDOMNodeOnInstance(),window.joystick._internal.css.update(),b(r,r.renderMethods),r.lifecycle.onMount(),l("lifecycle.onMount")}catch(r){i("mount",r)}};export{v as default};
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.8",
4
+ "version": "0.0.0-canary.9",
5
5
  "description": "A JavaScript framework for building user interfaces.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {