@joystick.js/ui-canary 0.0.0-canary.98 → 0.0.0-canary.99

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.
@@ -18,4 +18,4 @@ var tr=Object.create;var ie=Object.defineProperty;var rr=Object.getOwnPropertyDe
18
18
  @media screen and (max-height: ${j}px) {
19
19
  ${typeof f=="function"?f(e):f}
20
20
  }
21
- `}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var ur=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},z=(t={},e={})=>{try{return l(e)?ur(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var mr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.values.compile.compileValues",r)}},ut=(t={},e={})=>{try{return l(e)?mr(t,e):Object.assign({},e)}catch(r){n("component.values.compile",r)}};var ne={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var mt=(t={},e={})=>{try{return e?Object.entries({...ne,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ne}catch(r){n("component.lifecycle.compile",r)}};var b=(t="",e=[])=>{typeof window!="undefined"&&!!window.__joystick_test__&&(window.test={...window.test||{},functionCalls:{...window?.test?.functionCalls||{},[t]:[...window?.test?.functionCalls&&window?.test?.functionCalls[t]||[],{calledAt:new Date().toISOString(),args:e}]}})};var W=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>(b(`ui.${t?.options?.test?.name||h()}.methods.${o}`,[...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}]),i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}})),r),{})}catch{n("component.methods.compile")}};var se=(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){n("component.url.compile",e)}};var v=()=>typeof window=="undefined";var V=null,J=0,pt=(t={},e=null)=>{try{if(window?.__joystick_test__)return e();let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);V&&(clearInterval(V),V=null);let i={client:o,send:(s={})=>(b(`ui.websockets.${t?.test?.name||h()}.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),b(`ui.websockets.${t?.test?.name||h()}.onOpen`,[i])),J=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&(t.events.onMessage(JSON.parse(s.data||{}),i),b(`ui.websockets.${t?.test?.name||h()}.onMessage`,[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),b(`ui.websockets.${t?.test?.name||h()}.onClose`,[s.data||{},i])),o=null;let c=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!V&&!c&&(V=setInterval(()=>{o=null,J<(t?.options?.reconnectAttempts||12)?(pt(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${J+1}/12)...`),J+=1):clearInterval(V)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},ft=pt;var pr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},ht=(t={},e={})=>{try{return l(e)?pr(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var wt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=h(8),t.ssrId=e?._ssrId||null,t.css=lt(),t.data=K(e?.dataFromSSR,e?._componentId),t.defaultProps=ht(t,e?.defaultProps),t.props=ct(t?.defaultProps,e?.props),t.state=z(t,e?.state),t.values=ut(t,e?.values),t.events=e?.events||{},t.lifecycle=mt(t,e?.lifecycle),t.methods=W(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=dt,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!v();if(r||(t.url=se(e?.url)),r&&window.__joystick_url__&&(t.url=se(window.__joystick_url__)),r&&window.__joystick_user__&&(t.user=window.__joystick_user__),r&&e?.websockets&&l(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[c,a]=i[s];ft({test:t?.test,url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(m={})=>{t.websockets={...t.websockets||{},[c]:m}})}}}catch(r){n("component.registerOptions",r)}};var N=(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 Q=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var yt=(t={})=>Object.entries(t).map(([e,r])=>`${e}=${r}`)?.join("; ");var fr=async(t={})=>{try{let e=await t.text();return Q(e)}catch(e){n("api.get.handleParseResponse",e)}},gt=(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,c=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content"),m={...e?.headers||{},"x-joystick-csrf":a};return window?.__joystick_test__&&(m.Cookie=yt({joystickLoginToken:window.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expires_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(c,{method:"GET",mode:"cors",headers:m,credentials:"include"}).then(async g=>{let y=await fr(g);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),y?.errors?(N("get request",y.errors),o(y)):r(y)}).catch(g=>(N("get request",[g]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[g]})))}):Promise.resolve()}catch(r){n("get request",r)}};var hr=async(t={})=>{try{let e=await t.text();return Q(e)}catch(e){n("api.set.handleParseResponse",e)}},wr=(t={})=>{try{let e={...t};return e?.loader&&delete e.loader,JSON.stringify(e)}catch(e){n("api.set.getBody",e)}},xt=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=wr(e),c=document.querySelector('[name="csrf"]')?.getAttribute("content"),a={...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":c};return window?.__joystick_test__&&(a.Cookie=generateCookieHeader({joystickLoginToken:window?.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expirs_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(i,{method:"POST",mode:"cors",headers:a,body:s,credentials:"include"}).then(async m=>{let g=await hr(m);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),g?.errors?(N("set request",g.errors),o(g)):r(g)}).catch(m=>(N("set request",[m]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[m]})))}):Promise.resolve()}catch(r){n("set request",r)}};var bt={get:gt,set:xt};var yr=(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)}},H=(t="",e=null)=>{try{v()||(yr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Y=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&l(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 $t=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{b(`ui.${r?.options?.test?.name||h()}.data.refetch`,[o]);let i=await Y(bt,e,o,r);return r.data=$t(i,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=i),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){n("component.data.compile",o)}},Ft=$t;var kt=(t={})=>{try{if(!v()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return Ft(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var Tt=cr(Et());var Mt=(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 c=i[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let m=0;m<a.length;m+=1){let g=a[m],y=Mt(g,e,r);if(y!==null)return y}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},A=Mt;var St=(t="",e={},r=null)=>{let o=A(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var gr=(t={},e={},r=null)=>{try{let o=U(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)}},xr=(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)}},br=(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)}},$r=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};St(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&&H("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e),b(`ui.${e?.options?.test?.name||h()}.lifecycle.onBeforeMount`,[e])}),!t.renderedComponent&&e.options.lifecycle.onMount&&H("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e),b(`ui.${e?.options?.test?.name||h()}.lifecycle.onMount`,[e])}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},kr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Tt.diff)(e?.existingPropsMap,r)?.length>0&&H("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t),b(`ui.${t?.options?.test?.name||h()}.lifecycle.onBeforeMount`,[i||{},r,t])})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},Er=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]||{},c=o.children[i.id]||[],a=s[c?.length];return i.state=a?.state||i.state,i.values=a?.values||i.values,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,kr(i,o,r),H("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),Fr(this,i),i.parent&&$r(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?br(i):i.parent&&i.parent.ssrTree?xr(i):gr(i,this,a?.children)}},Mr=function(e,r){try{let o=this;return new Er().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},ae=Mr;var Sr=function(e=[],r=null){try{return l(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},de=Sr;var Tr=(t="",e=[])=>{try{return e.reduce((r,[o,i])=>r.replace(`{{${o}}}`,i),t)}catch(r){n("component.renderMethods.i18n.replacePlaceholdersInString",r)}},ce=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),i=typeof t=="object"&&!o;if(r)return Tr(t,e);if(o)return t?.map(s=>ce(s,e));if(i)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=ce(a,e),s),{})}catch(r){n("component.renderMethods.i18n.handleTranslationReplacement",r)}},Or=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>r[o],e)}catch(r){n("component.renderMethods.i18n.getTranslationAtPath",r)}},vr=function(t="",e={}){try{let r=v()?this.translations:window.__joystick_i18n__,i=t?.includes(".")?Or(t,r):r[t];if(!r||!i)return"";let s=Object.entries(e);return ce(i,s)}catch(r){n("component.renderMethods.i18n",r)}},le=vr;var Cr=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},ue=Cr;var Ot={c:ae,component:ae,e:de,each:de,i:le,i18n:le,w:ue,when:ue};var vt=(t={},e={})=>{try{return Object.entries(Ot).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var Ct=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,values:i?.values,children:Ct(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},_t=(t={})=>{try{return Ct(t)}catch(e){n("component.render.getExistingStateMap",e)}};var jt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),_r=new RegExp(/\n/g);var jr=(t="")=>{try{return(t.match(jt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},Rt=(t="")=>{try{let e=`${t}`;return e=jr(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var At=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:i=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${i}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Lt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,c]=o[i];for(let a=0;a<c?.length;a+=1){let m=c[a];Object.entries(m?.timers)?.length>0&&r.push(...Object.values(m?.timers)),Object.entries(m?.children)?.length>0&&Lt(m?.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)}},Dt=Lt;var ee=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=K(e.dataFromSSR,t.id)||{}),Dt(t?.children);let r=_t(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=W(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=Rt(o),s=At(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Rr=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},Pt=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Pt(e):me(e)):me(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},me=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Rr(t.attributes),children:[].flatMap.call(t.childNodes,o=>Pt(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},Z=me;var Ar=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},It=(t="")=>{try{let e=Ar(t);return Z(e)}catch(e){n("component.virtualDOM.build",e)}};var Vt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var Lr=(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];Vt(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=Nt(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},Nt=(t=null)=>{try{return O(t)?document.createTextNode(t):Lr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},q=Nt;var U=(t={},e={})=>{try{let r=ee(t,{existingChildren:e?.existingChildren}),o=It(r.wrapped,t),i=e.includeActual&&o?q(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var Ut=(t={},e={})=>{try{let r=U(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Dr=(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)}},te=Dr;var Pr=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],c=e[i];r.push([s,c])}return r},qt=Pr;var Ir=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Vr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Nr=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=c=>{let a=q(i);return c.appendChild(a),c};r.push(s)}),r},Ur=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=oe(o,e[i]);r.push(s)}),r},qr=(t=[],e=[])=>{let r=Ur(t,e),o=Nr(t,e);return i=>{if(i){let s=qt(r,i.childNodes);Vr(s),Ir(o,i)}return i}},re=qr;var zt={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),te(t.attributes,e.attributes)(r),re([],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 pe=(t,e)=>r=>{let o=t?q(t):null;return r&&r.replaceWith(o),o},zr=()=>t=>{t&&t.remove()},Hr=(t=void 0,e=void 0)=>t===void 0||e===void 0?zr():typeof t=="string"||typeof e=="string"?pe(e,t):t.tagName!==e.tagName?pe(e):e.tagName==="select"?zt.select(t,e):["pre","code"].includes(e.tagName)?pe(e,t):i=>(te(t.attributes,e.attributes)(i),re(t.children,e.children)(i),i),oe=Hr;var Zr=(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)}},B=(t="",e=null)=>{try{v()||(Zr(t)||{}).process(e)}catch(r){n("processQueue",r)}};var Ht=(t="",e=null)=>{let r=A(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var Zt=(t="",e={},r=null)=>{let o=A(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Bt=(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)&&Bt(i,e,r)}},Gt=Bt;var Kt=(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 Wt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Kt(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){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}}),b(`ui.${t?.options?.test?.name||h()}.events.${s.type}.selector_${s?.selector}`,[a,{...t||{},setState:t?.setState.bind(t),...e||{}}])}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<i?.length;s+=1){let c=i[s];Wt(c,e,r)}}return r}catch(o){n("component.eve!nts.registerListenersFix.getListeners",o)}},Br=(t={},e={})=>{try{let o=Wt(t,e,[])?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:c=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:c,elementSelector:a,type:m,handler:g}=o[i];c.addEventListener(m,g),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:m,handler:g}]}}catch(r){n("component.events.registerListenersFix",r)}},Jt=Br;var Qt=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Qt(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},Gr=(t={})=>{try{let e=Qt(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:c}=e[r];i.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Yt=Gr;var Xt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},_e(e),wt(this,e),this.data=kt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Y(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?A(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!v())return{instanceId:this.instanceId}}render(e={}){if(b(`ui.${this?.options?.test?.name||h()}.render`,[e]),e?.mounting)return Ut(this,e);let r=this.onBeforeRender();Yt(this),Ht(this.instanceId);let o=U(this,{}),i=oe(this.dom.virtual,o.virtual);i&&l(i)&&B("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,Jt(this,this.renderMethods),this.setDOMNodeOnInstance(),B("domNodes",()=>{B("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ee(this,e)}onAfterRender(e={},r={}){v()||(Zt(e.instanceId,this),window.joystick._internal.css.update(),B("lifecycle.onUpdateProps"),r?.afterSetStateRender&&l(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&l(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){b(`ui.${this?.options?.test?.name||h()}.setState`,[e,r]),this.state=z(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&l(r)&&r()}})}setValue(e={},r=null){b(`ui.${this?.options?.test?.name||h()}.setValue`,[e,r]),this.values=z(this,{...this.values||{},...e})}setTimeout(e=null,r=0){e&&(this.timers[h()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[h()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=A(window.joystick._internal.tree,this.instanceId,"instanceId"),i=A(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=Z(i?.instance?.DOMNode);Gt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},jd=Xt;export{jd as default};
21
+ `}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var ur=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},z=(t={},e={})=>{try{return l(e)?ur(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var mr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.values.compile.compileValues",r)}},ut=(t={},e={})=>{try{return l(e)?mr(t,e):Object.assign({},e)}catch(r){n("component.values.compile",r)}};var ne={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var mt=(t={},e={})=>{try{return e?Object.entries({...ne,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ne}catch(r){n("component.lifecycle.compile",r)}};var b=(t="",e=[])=>{typeof window!="undefined"&&!!window.__joystick_test__&&(window.test={...window.test||{},functionCalls:{...window?.test?.functionCalls||{},[t]:[...window?.test?.functionCalls&&window?.test?.functionCalls[t]||[],{calledAt:new Date().toISOString(),args:e}]}})};var W=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>(b(`ui.${t?.options?.test?.name||h()}.methods.${o}`,[...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}]),i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}})),r),{})}catch{n("component.methods.compile")}};var se=(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){n("component.url.compile",e)}};var v=()=>typeof window=="undefined";var V=null,J=0,pt=(t={},e=null)=>{try{if(window?.__joystick_test__)return e();let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);V&&(clearInterval(V),V=null);let i={client:o,send:(s={})=>(b(`ui.websockets.${t?.test?.name||h()}.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),b(`ui.websockets.${t?.test?.name||h()}.onOpen`,[i])),J=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&(t.events.onMessage(JSON.parse(s.data||{}),i),b(`ui.websockets.${t?.test?.name||h()}.onMessage`,[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),b(`ui.websockets.${t?.test?.name||h()}.onClose`,[s.data||{},i])),o=null;let c=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!V&&!c&&(V=setInterval(()=>{o=null,J<(t?.options?.reconnectAttempts||12)?(pt(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${J+1}/12)...`),J+=1):clearInterval(V)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},ft=pt;var pr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},ht=(t={},e={})=>{try{return l(e)?pr(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var wt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=h(8),t.ssrId=e?._ssrId||null,t.css=lt(),t.data=K(e?.dataFromSSR,e?._componentId),t.defaultProps=ht(t,e?.defaultProps),t.props=ct(t?.defaultProps,e?.props),t.state=z(t,e?.state),t.values=ut(t,e?.values),t.events=e?.events||{},t.lifecycle=mt(t,e?.lifecycle),t.methods=W(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=dt,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!v();if(r||(t.url=se(e?.url)),r&&window.__joystick_url__&&(t.url=se(window.__joystick_url__)),r&&window.__joystick_user__&&(t.user=window.__joystick_user__),r&&e?.websockets&&l(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[c,a]=i[s];ft({test:t?.test,url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(m={})=>{t.websockets={...t.websockets||{},[c]:m}})}}}catch(r){n("component.registerOptions",r)}};var N=(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 Q=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var yt=(t={})=>Object.entries(t).map(([e,r])=>`${e}=${r}`)?.join("; ");var fr=async(t={})=>{try{let e=await t.text();return Q(e)}catch(e){n("api.get.handleParseResponse",e)}},gt=(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,c=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content"),m={...e?.headers||{},"x-joystick-csrf":a};return window?.__joystick_test__&&(m.Cookie=yt({joystickLoginToken:window.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expires_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(c,{method:"GET",mode:"cors",headers:m,credentials:"include"}).then(async g=>{let y=await fr(g);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),y?.errors?(N("get request",y.errors),o(y)):r(y)}).catch(g=>(N("get request",[g]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[g]})))}):Promise.resolve()}catch(r){n("get request",r)}};var hr=async(t={})=>{try{let e=await t.text();return Q(e)}catch(e){n("api.set.handleParseResponse",e)}},wr=(t={})=>{try{let e={...t};return e?.loader&&delete e.loader,JSON.stringify(e)}catch(e){n("api.set.getBody",e)}},xt=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=wr(e),c=document.querySelector('[name="csrf"]')?.getAttribute("content"),a={...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":c};return window?.__joystick_test__&&(a.Cookie=generateCookieHeader({joystickLoginToken:window?.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expirs_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(i,{method:"POST",mode:"cors",headers:a,body:s,credentials:"include"}).then(async m=>{let g=await hr(m);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),g?.errors?(N("set request",g.errors),o(g)):r(g)}).catch(m=>(N("set request",[m]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[m]})))}):Promise.resolve()}catch(r){n("set request",r)}};var bt={get:gt,set:xt};var yr=(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)}},H=(t="",e=null)=>{try{v()||(yr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Y=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&l(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 $t=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{b(`ui.${r?.options?.test?.name||h()}.data.refetch`,[o]);let i=await Y(bt,e,o,r);return r.data=$t(i,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=i),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){n("component.data.compile",o)}},Ft=$t;var kt=(t={})=>{try{if(!v()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return Ft(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var Tt=cr(Et());var Mt=(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 c=i[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let m=0;m<a.length;m+=1){let g=a[m],y=Mt(g,e,r);if(y!==null)return y}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},A=Mt;var St=(t="",e={},r=null)=>{let o=A(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var gr=(t={},e={},r=null)=>{try{let o=U(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)}},xr=(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)}},br=(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)}},$r=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};St(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&&H("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e),b(`ui.${e?.options?.test?.name||h()}.lifecycle.onBeforeMount`,[e])}),!t.renderedComponent&&e.options.lifecycle.onMount&&H("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e),b(`ui.${e?.options?.test?.name||h()}.lifecycle.onMount`,[e])}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},kr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Tt.diff)(e?.existingPropsMap,r)?.length>0&&H("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t),b(`ui.${t?.options?.test?.name||h()}.lifecycle.onBeforeMount`,[i||{},r,t])})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},Er=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]||{},c=o.children[i.id]||[],a=s[c?.length];return i.state=a?.state||i.state,i.values=a?.values||i.values,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,kr(i,o,r),H("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),Fr(this,i),i.parent&&$r(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?br(i):i.parent&&i.parent.ssrTree?xr(i):gr(i,this,a?.children)}},Mr=function(e,r){try{let o=this;return new Er().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},ae=Mr;var Sr=function(e=[],r=null){try{return l(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},de=Sr;var Tr=(t="",e=[])=>{try{return e.reduce((r,[o,i])=>r.replace(`{{${o}}}`,i),t)}catch(r){n("component.renderMethods.i18n.replacePlaceholdersInString",r)}},ce=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),i=typeof t=="object"&&!o;if(r)return Tr(t,e);if(o)return t?.map(s=>ce(s,e));if(i)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=ce(a,e),s),{})}catch(r){n("component.renderMethods.i18n.handleTranslationReplacement",r)}},Or=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>r[o],e)}catch(r){n("component.renderMethods.i18n.getTranslationAtPath",r)}},vr=function(t="",e={}){try{let r=v()?this.translations:window.__joystick_i18n__,i=t?.includes(".")?Or(t,r):r[t];if(!r||!i)return"";let s=Object.entries(e);return ce(i,s)}catch(r){n("component.renderMethods.i18n",r)}},le=vr;var Cr=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},ue=Cr;var Ot={c:ae,component:ae,e:de,each:de,i:le,i18n:le,w:ue,when:ue};var vt=(t={},e={})=>{try{return Object.entries(Ot).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var Ct=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,values:i?.values,children:Ct(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},_t=(t={})=>{try{return Ct(t)}catch(e){n("component.render.getExistingStateMap",e)}};var jt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),_r=new RegExp(/\n/g);var jr=(t="")=>{try{return(t.match(jt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},Rt=(t="")=>{try{let e=`${t}`;return e=jr(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var At=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:i=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${i}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Lt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,c]=o[i];for(let a=0;a<c?.length;a+=1){let m=c[a];Object.entries(m?.timers)?.length>0&&r.push(...Object.values(m?.timers)),Object.entries(m?.children)?.length>0&&Lt(m?.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)}},Dt=Lt;var ee=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=K(e.dataFromSSR,t.id)||{}),Dt(t?.children);let r=_t(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=W(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=Rt(o),s=At(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Rr=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},Pt=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Pt(e):me(e)):me(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},me=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Rr(t.attributes),children:[].flatMap.call(t.childNodes,o=>Pt(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},Z=me;var Ar=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},It=(t="")=>{try{let e=Ar(t);return Z(e)}catch(e){n("component.virtualDOM.build",e)}};var Vt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var Lr=(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];Vt(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=Nt(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},Nt=(t=null)=>{try{return O(t)?document.createTextNode(t):Lr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},q=Nt;var U=(t={},e={})=>{try{let r=ee(t,{existingChildren:e?.existingChildren}),o=It(r.wrapped,t),i=e.includeActual&&o?q(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var Ut=(t={},e={})=>{try{let r=U(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Dr=(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)}},te=Dr;var Pr=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],c=e[i];r.push([s,c])}return r},qt=Pr;var Ir=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Vr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Nr=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=c=>{let a=q(i);return c.appendChild(a),c};r.push(s)}),r},Ur=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=oe(o,e[i]);r.push(s)}),r},qr=(t=[],e=[])=>{let r=Ur(t,e),o=Nr(t,e);return i=>{if(i){let s=qt(r,i.childNodes);Vr(s),Ir(o,i)}return i}},re=qr;var zt={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),te(t.attributes,e.attributes)(r),re([],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 pe=(t,e)=>r=>{let o=t?q(t):null;return r&&r.replaceWith(o),o},zr=()=>t=>{t&&t.remove()},Hr=(t=void 0,e=void 0)=>t===void 0||e===void 0?zr():typeof t=="string"||typeof e=="string"?pe(e,t):t.tagName!==e.tagName?pe(e):e.tagName==="select"?zt.select(t,e):["pre","code"].includes(e.tagName)?pe(e,t):i=>(te(t.attributes,e.attributes)(i),re(t.children,e.children)(i),i),oe=Hr;var Zr=(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)}},B=(t="",e=null)=>{try{v()||(Zr(t)||{}).process(e)}catch(r){n("processQueue",r)}};var Ht=(t="",e=null)=>{let r=A(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var Zt=(t="",e={},r=null)=>{let o=A(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Bt=(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)&&Bt(i,e,r)}},Gt=Bt;var Kt=(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 Wt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Kt(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){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}}),b(`ui.${t?.options?.test?.name||h()}.events.${s.type}.selector_${s?.selector}`,[a,{...t||{},setState:t?.setState.bind(t),...e||{}}])}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<i?.length;s+=1){let c=i[s];Wt(c,e,r)}}return r}catch(o){n("component.eve!nts.registerListenersFix.getListeners",o)}},Br=(t={},e={})=>{try{let o=Wt(t,e,[])?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:c=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:c,elementSelector:a,type:m,handler:g}=o[i];c.addEventListener(m,g),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:m,handler:g}]}}catch(r){n("component.events.registerListenersFix",r)}},Jt=Br;var Qt=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Qt(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},Gr=(t={})=>{try{let e=Qt(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:c}=e[r];i.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Yt=Gr;var Xt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},_e(e),wt(this,e),this.data=kt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Y(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?A(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!v())return{instanceId:this.instanceId}}render(e={}){if(b(`ui.${this?.options?.test?.name||h()}.render`,[e]),e?.mounting)return Ut(this,e);let r=this.onBeforeRender();Yt(this),Ht(this.instanceId);let o=U(this,{}),i=oe(this.dom.virtual,o.virtual);i&&l(i)&&B("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,Jt(this,this.renderMethods),this.setDOMNodeOnInstance(),B("domNodes",()=>{B("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ee(this,e)}onAfterRender(e={},r={}){v()||(Zt(e.instanceId,this),window.joystick._internal.css.update(),B("lifecycle.onUpdateProps"),r?.afterSetStateRender&&l(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&l(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){b(`ui.${this?.options?.test?.name||h()}.setState`,[e,r]),this.state=z(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&l(r)&&r()}})}setValues(e={},r=null){b(`ui.${this?.options?.test?.name||h()}.setValue`,[e,r]),this.values=z(this,{...this.values||{},...e})}setTimeout(e=null,r=0){e&&(this.timers[h()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[h()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=A(window.joystick._internal.tree,this.instanceId,"instanceId"),i=A(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=Z(i?.instance?.DOMNode);Gt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},jd=Xt;export{jd as default};
@@ -18,4 +18,4 @@ var rr=Object.create;var ie=Object.defineProperty;var or=Object.getOwnPropertyDe
18
18
  @media screen and (max-height: ${j}px) {
19
19
  ${typeof f=="function"?f(e):f}
20
20
  }
21
- `}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var mr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},z=(t={},e={})=>{try{return l(e)?mr(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var pr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.values.compile.compileValues",r)}},ut=(t={},e={})=>{try{return l(e)?pr(t,e):Object.assign({},e)}catch(r){n("component.values.compile",r)}};var ne={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var mt=(t={},e={})=>{try{return e?Object.entries({...ne,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ne}catch(r){n("component.lifecycle.compile",r)}};var b=(t="",e=[])=>{typeof window!="undefined"&&!!window.__joystick_test__&&(window.test={...window.test||{},functionCalls:{...window?.test?.functionCalls||{},[t]:[...window?.test?.functionCalls&&window?.test?.functionCalls[t]||[],{calledAt:new Date().toISOString(),args:e}]}})};var W=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>(b(`ui.${t?.options?.test?.name||h()}.methods.${o}`,[...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}]),i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}})),r),{})}catch{n("component.methods.compile")}};var se=(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){n("component.url.compile",e)}};var v=()=>typeof window=="undefined";var V=null,J=0,pt=(t={},e=null)=>{try{if(window?.__joystick_test__)return e();let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);V&&(clearInterval(V),V=null);let i={client:o,send:(s={})=>(b(`ui.websockets.${t?.test?.name||h()}.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),b(`ui.websockets.${t?.test?.name||h()}.onOpen`,[i])),J=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&(t.events.onMessage(JSON.parse(s.data||{}),i),b(`ui.websockets.${t?.test?.name||h()}.onMessage`,[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),b(`ui.websockets.${t?.test?.name||h()}.onClose`,[s.data||{},i])),o=null;let c=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!V&&!c&&(V=setInterval(()=>{o=null,J<(t?.options?.reconnectAttempts||12)?(pt(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${J+1}/12)...`),J+=1):clearInterval(V)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},ft=pt;var fr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},ht=(t={},e={})=>{try{return l(e)?fr(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var wt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=h(8),t.ssrId=e?._ssrId||null,t.css=lt(),t.data=K(e?.dataFromSSR,e?._componentId),t.defaultProps=ht(t,e?.defaultProps),t.props=ct(t?.defaultProps,e?.props),t.state=z(t,e?.state),t.values=ut(t,e?.values),t.events=e?.events||{},t.lifecycle=mt(t,e?.lifecycle),t.methods=W(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=dt,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!v();if(r||(t.url=se(e?.url)),r&&window.__joystick_url__&&(t.url=se(window.__joystick_url__)),r&&window.__joystick_user__&&(t.user=window.__joystick_user__),r&&e?.websockets&&l(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[c,a]=i[s];ft({test:t?.test,url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(m={})=>{t.websockets={...t.websockets||{},[c]:m}})}}}catch(r){n("component.registerOptions",r)}};var N=(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 Q=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var yt=(t={})=>Object.entries(t).map(([e,r])=>`${e}=${r}`)?.join("; ");var hr=async(t={})=>{try{let e=await t.text();return Q(e)}catch(e){n("api.get.handleParseResponse",e)}},xt=(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,c=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content"),m={...e?.headers||{},"x-joystick-csrf":a};return window?.__joystick_test__&&(m.Cookie=yt({joystickLoginToken:window.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expires_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(c,{method:"GET",mode:"cors",headers:m,credentials:"include"}).then(async x=>{let y=await hr(x);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),y?.errors?(N("get request",y.errors),o(y)):r(y)}).catch(x=>(N("get request",[x]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[x]})))}):Promise.resolve()}catch(r){n("get request",r)}};var wr=async(t={})=>{try{let e=await t.text();return Q(e)}catch(e){n("api.set.handleParseResponse",e)}},yr=(t={})=>{try{let e={...t};return e?.loader&&delete e.loader,JSON.stringify(e)}catch(e){n("api.set.getBody",e)}},gt=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=yr(e),c=document.querySelector('[name="csrf"]')?.getAttribute("content"),a={...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":c};return window?.__joystick_test__&&(a.Cookie=generateCookieHeader({joystickLoginToken:window?.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expirs_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(i,{method:"POST",mode:"cors",headers:a,body:s,credentials:"include"}).then(async m=>{let x=await wr(m);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),x?.errors?(N("set request",x.errors),o(x)):r(x)}).catch(m=>(N("set request",[m]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[m]})))}):Promise.resolve()}catch(r){n("set request",r)}};var bt={get:xt,set:gt};var xr=(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)}},H=(t="",e=null)=>{try{v()||(xr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Y=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&l(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 $t=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{b(`ui.${r?.options?.test?.name||h()}.data.refetch`,[o]);let i=await Y(bt,e,o,r);return r.data=$t(i,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=i),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){n("component.data.compile",o)}},Ft=$t;var kt=(t={})=>{try{if(!v()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return Ft(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var Tt=lr(Et());var Mt=(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 c=i[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let m=0;m<a.length;m+=1){let x=a[m],y=Mt(x,e,r);if(y!==null)return y}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},A=Mt;var St=(t="",e={},r=null)=>{let o=A(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var gr=(t={},e={},r=null)=>{try{let o=U(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)}},br=(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)}},$r=(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:[]};St(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){n("component.renderMethods.component.handleAddComponentToParent",e)}},kr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&H("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e),b(`ui.${e?.options?.test?.name||h()}.lifecycle.onBeforeMount`,[e])}),!t.renderedComponent&&e.options.lifecycle.onMount&&H("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e),b(`ui.${e?.options?.test?.name||h()}.lifecycle.onMount`,[e])}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},Er=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Tt.diff)(e?.existingPropsMap,r)?.length>0&&H("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t),b(`ui.${t?.options?.test?.name||h()}.lifecycle.onBeforeMount`,[i||{},r,t])})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},Mr=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]||{},c=o.children[i.id]||[],a=s[c?.length];return i.state=a?.state||i.state,i.values=a?.values||i.values,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,Er(i,o,r),H("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),kr(this,i),i.parent&&Fr(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?$r(i):i.parent&&i.parent.ssrTree?br(i):gr(i,this,a?.children)}},Sr=function(e,r){try{let o=this;return new Mr().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},ae=Sr;var Tr=function(e=[],r=null){try{return l(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},de=Tr;var Or=(t="",e=[])=>{try{return e.reduce((r,[o,i])=>r.replace(`{{${o}}}`,i),t)}catch(r){n("component.renderMethods.i18n.replacePlaceholdersInString",r)}},ce=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),i=typeof t=="object"&&!o;if(r)return Or(t,e);if(o)return t?.map(s=>ce(s,e));if(i)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=ce(a,e),s),{})}catch(r){n("component.renderMethods.i18n.handleTranslationReplacement",r)}},vr=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>r[o],e)}catch(r){n("component.renderMethods.i18n.getTranslationAtPath",r)}},Cr=function(t="",e={}){try{let r=v()?this.translations:window.__joystick_i18n__,i=t?.includes(".")?vr(t,r):r[t];if(!r||!i)return"";let s=Object.entries(e);return ce(i,s)}catch(r){n("component.renderMethods.i18n",r)}},le=Cr;var _r=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},ue=_r;var Ot={c:ae,component:ae,e:de,each:de,i:le,i18n:le,w:ue,when:ue};var vt=(t={},e={})=>{try{return Object.entries(Ot).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var Ct=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,values:i?.values,children:Ct(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},_t=(t={})=>{try{return Ct(t)}catch(e){n("component.render.getExistingStateMap",e)}};var jt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),jr=new RegExp(/\n/g);var Rr=(t="")=>{try{return(t.match(jt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},Rt=(t="")=>{try{let e=`${t}`;return e=Rr(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var At=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:i=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${i}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Lt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,c]=o[i];for(let a=0;a<c?.length;a+=1){let m=c[a];Object.entries(m?.timers)?.length>0&&r.push(...Object.values(m?.timers)),Object.entries(m?.children)?.length>0&&Lt(m?.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)}},Dt=Lt;var ee=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=K(e.dataFromSSR,t.id)||{}),Dt(t?.children);let r=_t(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=W(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=Rt(o),s=At(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Ar=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},Pt=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Pt(e):me(e)):me(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},me=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Ar(t.attributes),children:[].flatMap.call(t.childNodes,o=>Pt(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},Z=me;var Lr=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},It=(t="")=>{try{let e=Lr(t);return Z(e)}catch(e){n("component.virtualDOM.build",e)}};var Vt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var Dr=(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];Vt(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=Nt(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},Nt=(t=null)=>{try{return O(t)?document.createTextNode(t):Dr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},q=Nt;var U=(t={},e={})=>{try{let r=ee(t,{existingChildren:e?.existingChildren}),o=It(r.wrapped,t),i=e.includeActual&&o?q(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var Ut=(t={},e={})=>{try{let r=U(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Pr=(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)}},te=Pr;var Ir=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],c=e[i];r.push([s,c])}return r},qt=Ir;var Vr=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Nr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Ur=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=c=>{let a=q(i);return c.appendChild(a),c};r.push(s)}),r},qr=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=oe(o,e[i]);r.push(s)}),r},zr=(t=[],e=[])=>{let r=qr(t,e),o=Ur(t,e);return i=>{if(i){let s=qt(r,i.childNodes);Nr(s),Vr(o,i)}return i}},re=zr;var zt={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),te(t.attributes,e.attributes)(r),re([],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 pe=(t,e)=>r=>{let o=t?q(t):null;return r&&r.replaceWith(o),o},Hr=()=>t=>{t&&t.remove()},Zr=(t=void 0,e=void 0)=>t===void 0||e===void 0?Hr():typeof t=="string"||typeof e=="string"?pe(e,t):t.tagName!==e.tagName?pe(e):e.tagName==="select"?zt.select(t,e):["pre","code"].includes(e.tagName)?pe(e,t):i=>(te(t.attributes,e.attributes)(i),re(t.children,e.children)(i),i),oe=Zr;var Br=(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)}},B=(t="",e=null)=>{try{v()||(Br(t)||{}).process(e)}catch(r){n("processQueue",r)}};var Ht=(t="",e=null)=>{let r=A(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var Zt=(t="",e={},r=null)=>{let o=A(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Bt=(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)&&Bt(i,e,r)}},Gt=Bt;var Kt=(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 Wt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Kt(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){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}}),b(`ui.${t?.options?.test?.name||h()}.events.${s.type}.selector_${s?.selector}`,[a,{...t||{},setState:t?.setState.bind(t),...e||{}}])}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<i?.length;s+=1){let c=i[s];Wt(c,e,r)}}return r}catch(o){n("component.eve!nts.registerListenersFix.getListeners",o)}},Gr=(t={},e={})=>{try{let o=Wt(t,e,[])?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:c=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:c,elementSelector:a,type:m,handler:x}=o[i];c.addEventListener(m,x),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:m,handler:x}]}}catch(r){n("component.events.registerListenersFix",r)}},Jt=Gr;var Qt=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Qt(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},Kr=(t={})=>{try{let e=Qt(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:c}=e[r];i.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Yt=Kr;var Xt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},_e(e),wt(this,e),this.data=kt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Y(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?A(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!v())return{instanceId:this.instanceId}}render(e={}){if(b(`ui.${this?.options?.test?.name||h()}.render`,[e]),e?.mounting)return Ut(this,e);let r=this.onBeforeRender();Yt(this),Ht(this.instanceId);let o=U(this,{}),i=oe(this.dom.virtual,o.virtual);i&&l(i)&&B("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,Jt(this,this.renderMethods),this.setDOMNodeOnInstance(),B("domNodes",()=>{B("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ee(this,e)}onAfterRender(e={},r={}){v()||(Zt(e.instanceId,this),window.joystick._internal.css.update(),B("lifecycle.onUpdateProps"),r?.afterSetStateRender&&l(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&l(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){b(`ui.${this?.options?.test?.name||h()}.setState`,[e,r]),this.state=z(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&l(r)&&r()}})}setValue(e={},r=null){b(`ui.${this?.options?.test?.name||h()}.setValue`,[e,r]),this.values=z(this,{...this.values||{},...e})}setTimeout(e=null,r=0){e&&(this.timers[h()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[h()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=A(window.joystick._internal.tree,this.instanceId,"instanceId"),i=A(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=Z(i?.instance?.DOMNode);Gt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},er=Xt;var Dd=(t={})=>{try{return(e={})=>new er({...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{Dd as default};
21
+ `}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var mr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},z=(t={},e={})=>{try{return l(e)?mr(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var pr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.values.compile.compileValues",r)}},ut=(t={},e={})=>{try{return l(e)?pr(t,e):Object.assign({},e)}catch(r){n("component.values.compile",r)}};var ne={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var mt=(t={},e={})=>{try{return e?Object.entries({...ne,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ne}catch(r){n("component.lifecycle.compile",r)}};var b=(t="",e=[])=>{typeof window!="undefined"&&!!window.__joystick_test__&&(window.test={...window.test||{},functionCalls:{...window?.test?.functionCalls||{},[t]:[...window?.test?.functionCalls&&window?.test?.functionCalls[t]||[],{calledAt:new Date().toISOString(),args:e}]}})};var W=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>(b(`ui.${t?.options?.test?.name||h()}.methods.${o}`,[...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}]),i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}})),r),{})}catch{n("component.methods.compile")}};var se=(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){n("component.url.compile",e)}};var v=()=>typeof window=="undefined";var V=null,J=0,pt=(t={},e=null)=>{try{if(window?.__joystick_test__)return e();let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);V&&(clearInterval(V),V=null);let i={client:o,send:(s={})=>(b(`ui.websockets.${t?.test?.name||h()}.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),b(`ui.websockets.${t?.test?.name||h()}.onOpen`,[i])),J=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&(t.events.onMessage(JSON.parse(s.data||{}),i),b(`ui.websockets.${t?.test?.name||h()}.onMessage`,[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),b(`ui.websockets.${t?.test?.name||h()}.onClose`,[s.data||{},i])),o=null;let c=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!V&&!c&&(V=setInterval(()=>{o=null,J<(t?.options?.reconnectAttempts||12)?(pt(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${J+1}/12)...`),J+=1):clearInterval(V)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},ft=pt;var fr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!R(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},ht=(t={},e={})=>{try{return l(e)?fr(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var wt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=h(8),t.ssrId=e?._ssrId||null,t.css=lt(),t.data=K(e?.dataFromSSR,e?._componentId),t.defaultProps=ht(t,e?.defaultProps),t.props=ct(t?.defaultProps,e?.props),t.state=z(t,e?.state),t.values=ut(t,e?.values),t.events=e?.events||{},t.lifecycle=mt(t,e?.lifecycle),t.methods=W(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=dt,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!v();if(r||(t.url=se(e?.url)),r&&window.__joystick_url__&&(t.url=se(window.__joystick_url__)),r&&window.__joystick_user__&&(t.user=window.__joystick_user__),r&&e?.websockets&&l(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[c,a]=i[s];ft({test:t?.test,url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(m={})=>{t.websockets={...t.websockets||{},[c]:m}})}}}catch(r){n("component.registerOptions",r)}};var N=(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 Q=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var yt=(t={})=>Object.entries(t).map(([e,r])=>`${e}=${r}`)?.join("; ");var hr=async(t={})=>{try{let e=await t.text();return Q(e)}catch(e){n("api.get.handleParseResponse",e)}},xt=(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,c=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content"),m={...e?.headers||{},"x-joystick-csrf":a};return window?.__joystick_test__&&(m.Cookie=yt({joystickLoginToken:window.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expires_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(c,{method:"GET",mode:"cors",headers:m,credentials:"include"}).then(async x=>{let y=await hr(x);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),y?.errors?(N("get request",y.errors),o(y)):r(y)}).catch(x=>(N("get request",[x]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[x]})))}):Promise.resolve()}catch(r){n("get request",r)}};var wr=async(t={})=>{try{let e=await t.text();return Q(e)}catch(e){n("api.set.handleParseResponse",e)}},yr=(t={})=>{try{let e={...t};return e?.loader&&delete e.loader,JSON.stringify(e)}catch(e){n("api.set.getBody",e)}},gt=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=yr(e),c=document.querySelector('[name="csrf"]')?.getAttribute("content"),a={...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":c};return window?.__joystick_test__&&(a.Cookie=generateCookieHeader({joystickLoginToken:window?.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expirs_at__})),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!0}),fetch(i,{method:"POST",mode:"cors",headers:a,body:s,credentials:"include"}).then(async m=>{let x=await wr(m);return e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),x?.errors?(N("set request",x.errors),o(x)):r(x)}).catch(m=>(N("set request",[m]),e?.loader?.instance&&e?.loader?.instance?.setState({[e?.loader?.state||`${t}_loading`]:!1}),o({errors:[m]})))}):Promise.resolve()}catch(r){n("set request",r)}};var bt={get:xt,set:gt};var xr=(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)}},H=(t="",e=null)=>{try{v()||(xr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Y=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&l(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 $t=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{b(`ui.${r?.options?.test?.name||h()}.data.refetch`,[o]);let i=await Y(bt,e,o,r);return r.data=$t(i,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=i),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){n("component.data.compile",o)}},Ft=$t;var kt=(t={})=>{try{if(!v()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return Ft(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var Tt=lr(Et());var Mt=(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 c=i[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let m=0;m<a.length;m+=1){let x=a[m],y=Mt(x,e,r);if(y!==null)return y}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},A=Mt;var St=(t="",e={},r=null)=>{let o=A(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var gr=(t={},e={},r=null)=>{try{let o=U(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)}},br=(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)}},$r=(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:[]};St(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){n("component.renderMethods.component.handleAddComponentToParent",e)}},kr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&H("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e),b(`ui.${e?.options?.test?.name||h()}.lifecycle.onBeforeMount`,[e])}),!t.renderedComponent&&e.options.lifecycle.onMount&&H("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e),b(`ui.${e?.options?.test?.name||h()}.lifecycle.onMount`,[e])}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},Er=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Tt.diff)(e?.existingPropsMap,r)?.length>0&&H("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t),b(`ui.${t?.options?.test?.name||h()}.lifecycle.onBeforeMount`,[i||{},r,t])})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},Mr=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]||{},c=o.children[i.id]||[],a=s[c?.length];return i.state=a?.state||i.state,i.values=a?.values||i.values,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,Er(i,o,r),H("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),kr(this,i),i.parent&&Fr(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?$r(i):i.parent&&i.parent.ssrTree?br(i):gr(i,this,a?.children)}},Sr=function(e,r){try{let o=this;return new Mr().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},ae=Sr;var Tr=function(e=[],r=null){try{return l(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},de=Tr;var Or=(t="",e=[])=>{try{return e.reduce((r,[o,i])=>r.replace(`{{${o}}}`,i),t)}catch(r){n("component.renderMethods.i18n.replacePlaceholdersInString",r)}},ce=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),i=typeof t=="object"&&!o;if(r)return Or(t,e);if(o)return t?.map(s=>ce(s,e));if(i)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=ce(a,e),s),{})}catch(r){n("component.renderMethods.i18n.handleTranslationReplacement",r)}},vr=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>r[o],e)}catch(r){n("component.renderMethods.i18n.getTranslationAtPath",r)}},Cr=function(t="",e={}){try{let r=v()?this.translations:window.__joystick_i18n__,i=t?.includes(".")?vr(t,r):r[t];if(!r||!i)return"";let s=Object.entries(e);return ce(i,s)}catch(r){n("component.renderMethods.i18n",r)}},le=Cr;var _r=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},ue=_r;var Ot={c:ae,component:ae,e:de,each:de,i:le,i18n:le,w:ue,when:ue};var vt=(t={},e={})=>{try{return Object.entries(Ot).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var Ct=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,values:i?.values,children:Ct(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},_t=(t={})=>{try{return Ct(t)}catch(e){n("component.render.getExistingStateMap",e)}};var jt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),jr=new RegExp(/\n/g);var Rr=(t="")=>{try{return(t.match(jt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},Rt=(t="")=>{try{let e=`${t}`;return e=Rr(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var At=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:i=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${i}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Lt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,c]=o[i];for(let a=0;a<c?.length;a+=1){let m=c[a];Object.entries(m?.timers)?.length>0&&r.push(...Object.values(m?.timers)),Object.entries(m?.children)?.length>0&&Lt(m?.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)}},Dt=Lt;var ee=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=K(e.dataFromSSR,t.id)||{}),Dt(t?.children);let r=_t(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=W(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=Rt(o),s=At(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Ar=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},Pt=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Pt(e):me(e)):me(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},me=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Ar(t.attributes),children:[].flatMap.call(t.childNodes,o=>Pt(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},Z=me;var Lr=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},It=(t="")=>{try{let e=Lr(t);return Z(e)}catch(e){n("component.virtualDOM.build",e)}};var Vt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var Dr=(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];Vt(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=Nt(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},Nt=(t=null)=>{try{return O(t)?document.createTextNode(t):Dr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},q=Nt;var U=(t={},e={})=>{try{let r=ee(t,{existingChildren:e?.existingChildren}),o=It(r.wrapped,t),i=e.includeActual&&o?q(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var Ut=(t={},e={})=>{try{let r=U(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Pr=(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)}},te=Pr;var Ir=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],c=e[i];r.push([s,c])}return r},qt=Ir;var Vr=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Nr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Ur=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=c=>{let a=q(i);return c.appendChild(a),c};r.push(s)}),r},qr=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=oe(o,e[i]);r.push(s)}),r},zr=(t=[],e=[])=>{let r=qr(t,e),o=Ur(t,e);return i=>{if(i){let s=qt(r,i.childNodes);Nr(s),Vr(o,i)}return i}},re=zr;var zt={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),te(t.attributes,e.attributes)(r),re([],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 pe=(t,e)=>r=>{let o=t?q(t):null;return r&&r.replaceWith(o),o},Hr=()=>t=>{t&&t.remove()},Zr=(t=void 0,e=void 0)=>t===void 0||e===void 0?Hr():typeof t=="string"||typeof e=="string"?pe(e,t):t.tagName!==e.tagName?pe(e):e.tagName==="select"?zt.select(t,e):["pre","code"].includes(e.tagName)?pe(e,t):i=>(te(t.attributes,e.attributes)(i),re(t.children,e.children)(i),i),oe=Zr;var Br=(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)}},B=(t="",e=null)=>{try{v()||(Br(t)||{}).process(e)}catch(r){n("processQueue",r)}};var Ht=(t="",e=null)=>{let r=A(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var Zt=(t="",e={},r=null)=>{let o=A(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Bt=(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)&&Bt(i,e,r)}},Gt=Bt;var Kt=(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 Wt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Kt(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){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}}),b(`ui.${t?.options?.test?.name||h()}.events.${s.type}.selector_${s?.selector}`,[a,{...t||{},setState:t?.setState.bind(t),...e||{}}])}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<i?.length;s+=1){let c=i[s];Wt(c,e,r)}}return r}catch(o){n("component.eve!nts.registerListenersFix.getListeners",o)}},Gr=(t={},e={})=>{try{let o=Wt(t,e,[])?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:c=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:c,elementSelector:a,type:m,handler:x}=o[i];c.addEventListener(m,x),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:m,handler:x}]}}catch(r){n("component.events.registerListenersFix",r)}},Jt=Gr;var Qt=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Qt(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},Kr=(t={})=>{try{let e=Qt(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:c}=e[r];i.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Yt=Kr;var Xt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},_e(e),wt(this,e),this.data=kt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Y(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?A(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!v())return{instanceId:this.instanceId}}render(e={}){if(b(`ui.${this?.options?.test?.name||h()}.render`,[e]),e?.mounting)return Ut(this,e);let r=this.onBeforeRender();Yt(this),Ht(this.instanceId);let o=U(this,{}),i=oe(this.dom.virtual,o.virtual);i&&l(i)&&B("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,Jt(this,this.renderMethods),this.setDOMNodeOnInstance(),B("domNodes",()=>{B("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ee(this,e)}onAfterRender(e={},r={}){v()||(Zt(e.instanceId,this),window.joystick._internal.css.update(),B("lifecycle.onUpdateProps"),r?.afterSetStateRender&&l(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&l(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){b(`ui.${this?.options?.test?.name||h()}.setState`,[e,r]),this.state=z(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&l(r)&&r()}})}setValues(e={},r=null){b(`ui.${this?.options?.test?.name||h()}.setValue`,[e,r]),this.values=z(this,{...this.values||{},...e})}setTimeout(e=null,r=0){e&&(this.timers[h()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[h()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=A(window.joystick._internal.tree,this.instanceId,"instanceId"),i=A(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=Z(i?.instance?.DOMNode);Gt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},er=Xt;var Dd=(t={})=>{try{return(e={})=>new er({...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{Dd as default};
package/dist/index.js CHANGED
@@ -18,4 +18,4 @@ var Dr=Object.create;var ue=Object.defineProperty;var Lr=Object.getOwnPropertyDe
18
18
  @media screen and (max-height: ${R}px) {
19
19
  ${typeof h=="function"?h(e):h}
20
20
  }
21
- `}}return r}return""}catch(r){i("component.css.compileCSS",r)}};var Qr=(t={},e=null)=>{try{let r=e(t);return r&&m(r)&&!D(r)?Object.assign({},r):{}}catch(r){i("component.state.compile.compileState",r)}},W=(t={},e={})=>{try{return u(e)?Qr(t,e):Object.assign({},e)}catch(r){i("component.state.compile",r)}};var Yr=(t={},e=null)=>{try{let r=e(t);return r&&m(r)&&!D(r)?Object.assign({},r):{}}catch(r){i("component.values.compile.compileValues",r)}},Ht=(t={},e={})=>{try{return u(e)?Yr(t,e):Object.assign({},e)}catch(r){i("component.values.compile",r)}};var pe={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var Ut=(t={},e={})=>{try{return e?Object.entries({...pe,...e||{}}).reduce((r={},[o,n])=>(r[o]=()=>n({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):pe}catch(r){i("component.lifecycle.compile",r)}};var re=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,n])=>(r[o]=(...s)=>(w(`ui.${t?.options?.test?.name||f()}.methods.${o}`,[...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}]),n(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}})),r),{})}catch{i("component.methods.compile")}};var fe=(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="")=>M(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){i("component.url.compile",e)}};var Xr=(t={},e=null)=>{try{let r=e(t);return r&&m(r)&&!D(r)?Object.assign({},r):{}}catch(r){i("component.props.compileDefaultProps.compile",r)}},zt=(t={},e={})=>{try{return u(e)?Xr(t,e):Object.assign({},e)}catch(r){i("component.props.compileDefaultProps",r)}};var Bt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=f(8),t.ssrId=e?._ssrId||null,t.css=te(),t.data=ee(e?.dataFromSSR,e?._componentId),t.defaultProps=zt(t,e?.defaultProps),t.props=Nt(t?.defaultProps,e?.props),t.state=W(t,e?.state),t.values=Ht(t,e?.values),t.events=e?.events||{},t.lifecycle=Ut(t,e?.lifecycle),t.methods=re(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=Vt,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=fe(e?.url)),r&&window.__joystick_url__&&(t.url=fe(window.__joystick_url__)),r&&window.__joystick_user__&&(t.user=window.__joystick_user__),r&&e?.websockets&&u(e?.websockets)){let o=e.websockets(t),n=m(o)&&Object.entries(o);for(let s=0;s<n?.length;s+=1){let[c,a]=n[s];X({test:t?.test,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 eo=(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)}},K=(t="",e=null)=>{try{S()||(eo(t)||{}).array.push({callback:e})}catch(r){i("addToQueue",r)}};var oe=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&u(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 Zt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{w(`ui.${r?.options?.test?.name||f()}.data.refetch`,[o]);let n=await oe(G,e,o,r);return r.data=Zt(n,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=n),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){i("component.data.compile",o)}},Gt=Zt;var Wt=(t={})=>{try{if(!S()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return Gt(e,r,t)}return t?.data||{}}catch(e){i("component.loadDataFromWindow",e)}};var Yt=Ur(Kt());var Jt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(m(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],g=Jt(x,e,r);if(g!==null)return g}}}return null}catch(o){i("component.findComponentInTreeByField",o)}},L=Jt;var Qt=(t="",e={},r=null)=>{let o=L(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var to=(t={},e={},r=null)=>{try{let o=B(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)}},ro=(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)}},oo=(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)}},no=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};Qt(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){i("component.renderMethods.component.handleAddComponentToParent",e)}},io=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&K("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e),w(`ui.${e?.options?.test?.name||f()}.lifecycle.onBeforeMount`,[e])}),!t.renderedComponent&&e.options.lifecycle.onMount&&K("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e),w(`ui.${e?.options?.test?.name||f()}.lifecycle.onMount`,[e])}))}catch(r){i("component.renderMethods.component.handleLifecycle",r)}},so=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Yt.diff)(e?.existingPropsMap,r)?.length>0&&K("lifecycle.onUpdateProps",()=>{let n=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(n||{},r,t),w(`ui.${t?.options?.test?.name||f()}.lifecycle.onBeforeMount`,[n||{},r,t])})}catch(o){i("component.renderMethods.component.handleOnChangeProps",o)}},ao=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,n.values=a?.values||n.values,o.children[n.id]=[...o.children[n.id]||[],n],n.parent=o,so(n,o,r),K("lifecycle.onMount",()=>{n.setDOMNodeOnInstance()}),io(this,n),n.parent&&no(n),n.options.data&&n.parent.walkingTreeForSSR&&n.parent.ssrTree.dataFunctions?oo(n):n.parent&&n.parent.ssrTree?ro(n):to(n,this,a?.children)}},co=function(e,r){try{let o=this;return new ao().bind({})(e,r,o)}catch(o){i("component.renderMethods.component",o)}},he=co;var lo=function(e=[],r=null){try{return u(r)&&e&&Array.isArray(e)?e.map((o,n)=>r(o,n)).join(""):""}catch(o){i("component.renderMethods.each",o)}},we=lo;var uo=(t="",e=[])=>{try{return e.reduce((r,[o,n])=>r.replace(`{{${o}}}`,n),t)}catch(r){i("component.renderMethods.i18n.replacePlaceholdersInString",r)}},ye=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),n=typeof t=="object"&&!o;if(r)return uo(t,e);if(o)return t?.map(s=>ye(s,e));if(n)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=ye(a,e),s),{})}catch(r){i("component.renderMethods.i18n.handleTranslationReplacement",r)}},mo=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>r[o],e)}catch(r){i("component.renderMethods.i18n.getTranslationAtPath",r)}},po=function(t="",e={}){try{let r=S()?this.translations:window.__joystick_i18n__,n=t?.includes(".")?mo(t,r):r[t];if(!r||!n)return"";let s=Object.entries(e);return ye(n,s)}catch(r){i("component.renderMethods.i18n",r)}},ge=po;var fo=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){i("component.renderMethods.when",o)}},xe=fo;var Xt={c:he,component:he,e:we,each:we,i:ge,i18n:ge,w:xe,when:xe};var er=(t={},e={})=>{try{return Object.entries(Xt).reduce((r,[o,n])=>(r[o]=n.bind({...t,...e}),r),{})}catch(r){i("component.renderMethods.compile",r)}};var tr=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((n={})=>({state:n?.state,values:n?.values,children:tr(n?.children)})),e),{})}catch(e){i("component.render.getExistingStateMap.buildMapForChildren",e)}},rr=(t={})=>{try{return tr(t)}catch(e){i("component.render.getExistingStateMap",e)}};var or=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),ho=new RegExp(/\n/g);var wo=(t="")=>{try{return(t.match(or)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){i("component.render.sanitizeHTML.removeCommentedCode",e)}},nr=(t="")=>{try{let e=`${t}`;return e=wo(e),e}catch(e){i("component.render.sanitizeHTML",e)}};var ir=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:n=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${n}">${e}</div>`}catch(r){i("component.render.wrapHTML",r)}};var sr=(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&&sr(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)}},ar=sr;var ie=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=ee(e.dataFromSSR,t.id)||{}),ar(t?.children);let r=rr(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=er({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=re(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),n=nr(o),s=ir(t,n);return{unwrapped:n,wrapped:s}}catch(r){i("component.render.toHTML",r)}};var yo=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){i("component.virtualDOM.build.parseAttributeMap",e)}},cr=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?cr(e):be(e)):be(t)}catch(e){i("component.virtualDOM.build.flattenWhenTags",e)}},be=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:yo(t.attributes),children:[].flatMap.call(t.childNodes,o=>cr(o))};return e==="text"&&(r=t.textContent),r}catch(e){i("component.virtualDOM.build",e)}},J=be;var go=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){i("component.virtualDOM.build.convertHTMLToDOM",e)}},dr=(t="")=>{try{let e=go(t);return J(e)}catch(e){i("component.virtualDOM.build",e)}};var lr=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var xo=(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];lr(n)&&e.setAttribute(n,s)}for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(n){let s=ur(n);e.appendChild(s)}}return e}catch(e){i("component.virtualDOM.renderTreeToDOM.renderElement",e)}},ur=(t=null)=>{try{return M(t)?document.createTextNode(t):xo(t)}catch(e){i("component.virtualDOM.renderTreeToDOM",e)}},Z=ur;var B=(t={},e={})=>{try{let r=ie(t,{existingChildren:e?.existingChildren}),o=dr(r.wrapped,t),n=e.includeActual&&o?Z(o):null;return{html:r,virtual:o,actual:n}}catch(r){i("component.render.getUpdatedDOM",r)}};var mr=(t={},e={})=>{try{let r=B(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){i("component.render.forMount",r)}};var bo=(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)}},se=bo;var $o=(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},pr=$o;var ko=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Eo=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Fo=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(n=>{let s=c=>{let a=Z(n);return c.appendChild(a),c};r.push(s)}),r},Mo=(t=[],e=[])=>{let r=[];return t.forEach((o,n)=>{let s=ce(o,e[n]);r.push(s)}),r},So=(t=[],e=[])=>{let r=Mo(t,e),o=Fo(t,e);return n=>{if(n){let s=pr(r,n.childNodes);Eo(s),ko(o,n)}return n}},ae=So;var fr={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),se(t.attributes,e.attributes)(r),ae([],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 $e=(t,e)=>r=>{let o=t?Z(t):null;return r&&r.replaceWith(o),o},To=()=>t=>{t&&t.remove()},_o=(t=void 0,e=void 0)=>t===void 0||e===void 0?To():typeof t=="string"||typeof e=="string"?$e(e,t):t.tagName!==e.tagName?$e(e):e.tagName==="select"?fr.select(t,e):["pre","code"].includes(e.tagName)?$e(e,t):n=>(se(t.attributes,e.attributes)(n),ae(t.children,e.children)(n),n),ce=_o;var vo=(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)}},V=(t="",e=null)=>{try{S()||(vo(t)||{}).process(e)}catch(r){i("processQueue",r)}};var hr=(t="",e=null)=>{let r=L(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var wr=(t="",e={},r=null)=>{let o=L(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var yr=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(m(n)&&n.attributes&&n.attributes["js-i"]&&n.attributes["js-i"]===e){t.children[o]=r;break}m(n)&&yr(n,e,r)}},gr=yr;var xr=(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 br=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?xr(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){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}}),w(`ui.${t?.options?.test?.name||f()}.events.${s.type}.selector_${s?.selector}`,[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];br(c,e,r)}}return r}catch(o){i("component.eve!nts.registerListenersFix.getListeners",o)}},Co=(t={},e={})=>{try{let o=br(t,e,[])?.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];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)}},de=Co;var $r=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((n=[],s=[])=>[...n,...s],[])).flatMap((n={})=>$r(n));e=[...e,...o]}return e}catch(e){i("component.events.unregisterListenersFix.getListeners",e)}},Oo=(t={})=>{try{let e=$r(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)}},kr=Oo;var Er=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},lt(e),Bt(this,e),this.data=Wt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},n=this){let s=await oe(e,r,o,n);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=J(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(!S())return{instanceId:this.instanceId}}render(e={}){if(w(`ui.${this?.options?.test?.name||f()}.render`,[e]),e?.mounting)return mr(this,e);let r=this.onBeforeRender();kr(this),hr(this.instanceId);let o=B(this,{}),n=ce(this.dom.virtual,o.virtual);n&&u(n)&&V("lifecycle.onBeforeMount",()=>{let s=n(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,de(this,this.renderMethods),this.setDOMNodeOnInstance(),V("domNodes",()=>{V("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ie(this,e)}onAfterRender(e={},r={}){S()||(wr(e.instanceId,this),window.joystick._internal.css.update(),V("lifecycle.onUpdateProps"),r?.afterSetStateRender&&u(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&u(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){w(`ui.${this?.options?.test?.name||f()}.setState`,[e,r]),this.state=W(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&u(r)&&r()}})}setValue(e={},r=null){w(`ui.${this?.options?.test?.name||f()}.setValue`,[e,r]),this.values=W(this,{...this.values||{},...e})}setTimeout(e=null,r=0){e&&(this.timers[f()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[f()]=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=J(n?.instance?.DOMNode);gr(o?.instance?.dom?.virtual,n?.instanceId,s)}}},Fr=Er;var Mr=(t={})=>{try{return(e={})=>new Fr({...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 Sr=(t={})=>{try{window.joystick._internal.tree={id:t?.id||null,instanceId:t?.instanceId||null,instance:t,children:[]}}catch(e){i("mount.initializeJoystickComponentTree",e)}};var Tr=(t={},e=null)=>{try{return t.innerHTML="",t.appendChild(e),e}catch(r){i("mount.appendToDOM",r)}};var _r=(t=null,e={},r=null)=>{try{u(t)||i("mount","Component to mount must be a function."),m(e)||i("mount","props must be an object."),Re(r)||i("mount","target must be a DOM node.");let o=t({props:e});Sr(o);let n=o.render({mounting:!0,existingChildren:window.__joystick_childrenBeforeHMRUpdate__||null});return n&&(n.setAttribute("js-c",o.id),n.setAttribute("js-i",o.instanceId)),o.lifecycle.onBeforeMount(),V("lifecycle.onBeforeMount"),Tr(r,n),o.setDOMNodeOnInstance(),window.joystick._internal.css.update(),de(o,o.renderMethods),o.lifecycle.onMount(),V("lifecycle.onMount"),o}catch(o){i("mount",o)}};var vr=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=vr;var jo=new RegExp(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g),Ro=new RegExp(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g),Ao=(t,e)=>(e||"").replace(jo,()=>"").replace(Ro,r=>["@",": "].some(o=>r?.includes(o))?r:`[js-c="${t}"] ${r.trim()}`)?.trim(),Cr=(t={},e=[])=>{if(t.instance&&t.instance.options&&t.instance.options.css){let r=t.instance.id,o=t.instance.options.css,n=te(o,t.instance),s=Ao(r,n);e.push(s)}if(t.children&&t.children.length>0){let r=t?.children?.length||0;for(;r--;)Cr(t.children[r],e)}return e},Or=Cr;var jr=()=>{try{let t=document.head.querySelector("style[js-styles]"),r=Or(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 Rr=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var Do=Ce,Lo=Le,Po=G.get,Io={get:Pe,track:me},qo=Ie,Vo=qe,No=G.set,mu=Ne,pu=me,Ho=ze,ke=()=>typeof window!="undefined"?window.__joystick_env__:typeof process!="undefined"?"production":null,le={_external:{},_internal:{last_interaction:null,css:{update:jr},queues:{domNodes:new N([]),eventListeners:new N([]),lifecycle:{onBeforeMount:new N([]),onMount:new N([]),onUpdateProps:new N([])},render:new N([])},tree:{},eventListeners:[]},accounts:Do,cache:Lo,component:Mr,env:{development:ke()==="development",test:ke()==="test"},external:Io,get:Po,html:qo,id:f,mount:_r,renderComponentToHTML:Vo,set:No,upload:Ho,timers:{}};typeof window!="undefined"&&ke()!=="test"&&(document.body.addEventListener("mouseover",()=>{Rr(()=>{le._internal.last_interaction=new Date().toISOString()},1e3)}),setInterval(()=>{let t=new Date;t.setMinutes(t.getMinutes()-30),le._internal.last_interaction<=t.toISOString()&&location.reload()},30*1e3));Be(le);var fu=le;export{Do as accounts,Lo as cache,fu as default,Io as external,Po as get,qo as html,Vo as renderComponentToHTML,No as set,mu as test,pu as trackExternal,Ho as upload};
21
+ `}}return r}return""}catch(r){i("component.css.compileCSS",r)}};var Qr=(t={},e=null)=>{try{let r=e(t);return r&&m(r)&&!D(r)?Object.assign({},r):{}}catch(r){i("component.state.compile.compileState",r)}},W=(t={},e={})=>{try{return u(e)?Qr(t,e):Object.assign({},e)}catch(r){i("component.state.compile",r)}};var Yr=(t={},e=null)=>{try{let r=e(t);return r&&m(r)&&!D(r)?Object.assign({},r):{}}catch(r){i("component.values.compile.compileValues",r)}},Ht=(t={},e={})=>{try{return u(e)?Yr(t,e):Object.assign({},e)}catch(r){i("component.values.compile",r)}};var pe={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var Ut=(t={},e={})=>{try{return e?Object.entries({...pe,...e||{}}).reduce((r={},[o,n])=>(r[o]=()=>n({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):pe}catch(r){i("component.lifecycle.compile",r)}};var re=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,n])=>(r[o]=(...s)=>(w(`ui.${t?.options?.test?.name||f()}.methods.${o}`,[...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}]),n(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}})),r),{})}catch{i("component.methods.compile")}};var fe=(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="")=>M(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){i("component.url.compile",e)}};var Xr=(t={},e=null)=>{try{let r=e(t);return r&&m(r)&&!D(r)?Object.assign({},r):{}}catch(r){i("component.props.compileDefaultProps.compile",r)}},zt=(t={},e={})=>{try{return u(e)?Xr(t,e):Object.assign({},e)}catch(r){i("component.props.compileDefaultProps",r)}};var Bt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=f(8),t.ssrId=e?._ssrId||null,t.css=te(),t.data=ee(e?.dataFromSSR,e?._componentId),t.defaultProps=zt(t,e?.defaultProps),t.props=Nt(t?.defaultProps,e?.props),t.state=W(t,e?.state),t.values=Ht(t,e?.values),t.events=e?.events||{},t.lifecycle=Ut(t,e?.lifecycle),t.methods=re(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=Vt,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=fe(e?.url)),r&&window.__joystick_url__&&(t.url=fe(window.__joystick_url__)),r&&window.__joystick_user__&&(t.user=window.__joystick_user__),r&&e?.websockets&&u(e?.websockets)){let o=e.websockets(t),n=m(o)&&Object.entries(o);for(let s=0;s<n?.length;s+=1){let[c,a]=n[s];X({test:t?.test,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 eo=(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)}},K=(t="",e=null)=>{try{S()||(eo(t)||{}).array.push({callback:e})}catch(r){i("addToQueue",r)}};var oe=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&u(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 Zt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{w(`ui.${r?.options?.test?.name||f()}.data.refetch`,[o]);let n=await oe(G,e,o,r);return r.data=Zt(n,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=n),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){i("component.data.compile",o)}},Gt=Zt;var Wt=(t={})=>{try{if(!S()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return Gt(e,r,t)}return t?.data||{}}catch(e){i("component.loadDataFromWindow",e)}};var Yt=Ur(Kt());var Jt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(m(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],g=Jt(x,e,r);if(g!==null)return g}}}return null}catch(o){i("component.findComponentInTreeByField",o)}},L=Jt;var Qt=(t="",e={},r=null)=>{let o=L(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var to=(t={},e={},r=null)=>{try{let o=B(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)}},ro=(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)}},oo=(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)}},no=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};Qt(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){i("component.renderMethods.component.handleAddComponentToParent",e)}},io=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&K("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e),w(`ui.${e?.options?.test?.name||f()}.lifecycle.onBeforeMount`,[e])}),!t.renderedComponent&&e.options.lifecycle.onMount&&K("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e),w(`ui.${e?.options?.test?.name||f()}.lifecycle.onMount`,[e])}))}catch(r){i("component.renderMethods.component.handleLifecycle",r)}},so=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Yt.diff)(e?.existingPropsMap,r)?.length>0&&K("lifecycle.onUpdateProps",()=>{let n=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(n||{},r,t),w(`ui.${t?.options?.test?.name||f()}.lifecycle.onBeforeMount`,[n||{},r,t])})}catch(o){i("component.renderMethods.component.handleOnChangeProps",o)}},ao=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,n.values=a?.values||n.values,o.children[n.id]=[...o.children[n.id]||[],n],n.parent=o,so(n,o,r),K("lifecycle.onMount",()=>{n.setDOMNodeOnInstance()}),io(this,n),n.parent&&no(n),n.options.data&&n.parent.walkingTreeForSSR&&n.parent.ssrTree.dataFunctions?oo(n):n.parent&&n.parent.ssrTree?ro(n):to(n,this,a?.children)}},co=function(e,r){try{let o=this;return new ao().bind({})(e,r,o)}catch(o){i("component.renderMethods.component",o)}},he=co;var lo=function(e=[],r=null){try{return u(r)&&e&&Array.isArray(e)?e.map((o,n)=>r(o,n)).join(""):""}catch(o){i("component.renderMethods.each",o)}},we=lo;var uo=(t="",e=[])=>{try{return e.reduce((r,[o,n])=>r.replace(`{{${o}}}`,n),t)}catch(r){i("component.renderMethods.i18n.replacePlaceholdersInString",r)}},ye=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),n=typeof t=="object"&&!o;if(r)return uo(t,e);if(o)return t?.map(s=>ye(s,e));if(n)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=ye(a,e),s),{})}catch(r){i("component.renderMethods.i18n.handleTranslationReplacement",r)}},mo=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>r[o],e)}catch(r){i("component.renderMethods.i18n.getTranslationAtPath",r)}},po=function(t="",e={}){try{let r=S()?this.translations:window.__joystick_i18n__,n=t?.includes(".")?mo(t,r):r[t];if(!r||!n)return"";let s=Object.entries(e);return ye(n,s)}catch(r){i("component.renderMethods.i18n",r)}},ge=po;var fo=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){i("component.renderMethods.when",o)}},xe=fo;var Xt={c:he,component:he,e:we,each:we,i:ge,i18n:ge,w:xe,when:xe};var er=(t={},e={})=>{try{return Object.entries(Xt).reduce((r,[o,n])=>(r[o]=n.bind({...t,...e}),r),{})}catch(r){i("component.renderMethods.compile",r)}};var tr=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((n={})=>({state:n?.state,values:n?.values,children:tr(n?.children)})),e),{})}catch(e){i("component.render.getExistingStateMap.buildMapForChildren",e)}},rr=(t={})=>{try{return tr(t)}catch(e){i("component.render.getExistingStateMap",e)}};var or=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),ho=new RegExp(/\n/g);var wo=(t="")=>{try{return(t.match(or)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){i("component.render.sanitizeHTML.removeCommentedCode",e)}},nr=(t="")=>{try{let e=`${t}`;return e=wo(e),e}catch(e){i("component.render.sanitizeHTML",e)}};var ir=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:n=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${n}">${e}</div>`}catch(r){i("component.render.wrapHTML",r)}};var sr=(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&&sr(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)}},ar=sr;var ie=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=ee(e.dataFromSSR,t.id)||{}),ar(t?.children);let r=rr(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=er({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=re(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),n=nr(o),s=ir(t,n);return{unwrapped:n,wrapped:s}}catch(r){i("component.render.toHTML",r)}};var yo=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){i("component.virtualDOM.build.parseAttributeMap",e)}},cr=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?cr(e):be(e)):be(t)}catch(e){i("component.virtualDOM.build.flattenWhenTags",e)}},be=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:yo(t.attributes),children:[].flatMap.call(t.childNodes,o=>cr(o))};return e==="text"&&(r=t.textContent),r}catch(e){i("component.virtualDOM.build",e)}},J=be;var go=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){i("component.virtualDOM.build.convertHTMLToDOM",e)}},dr=(t="")=>{try{let e=go(t);return J(e)}catch(e){i("component.virtualDOM.build",e)}};var lr=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var xo=(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];lr(n)&&e.setAttribute(n,s)}for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(n){let s=ur(n);e.appendChild(s)}}return e}catch(e){i("component.virtualDOM.renderTreeToDOM.renderElement",e)}},ur=(t=null)=>{try{return M(t)?document.createTextNode(t):xo(t)}catch(e){i("component.virtualDOM.renderTreeToDOM",e)}},Z=ur;var B=(t={},e={})=>{try{let r=ie(t,{existingChildren:e?.existingChildren}),o=dr(r.wrapped,t),n=e.includeActual&&o?Z(o):null;return{html:r,virtual:o,actual:n}}catch(r){i("component.render.getUpdatedDOM",r)}};var mr=(t={},e={})=>{try{let r=B(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){i("component.render.forMount",r)}};var bo=(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)}},se=bo;var $o=(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},pr=$o;var ko=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Eo=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Fo=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(n=>{let s=c=>{let a=Z(n);return c.appendChild(a),c};r.push(s)}),r},Mo=(t=[],e=[])=>{let r=[];return t.forEach((o,n)=>{let s=ce(o,e[n]);r.push(s)}),r},So=(t=[],e=[])=>{let r=Mo(t,e),o=Fo(t,e);return n=>{if(n){let s=pr(r,n.childNodes);Eo(s),ko(o,n)}return n}},ae=So;var fr={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),se(t.attributes,e.attributes)(r),ae([],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 $e=(t,e)=>r=>{let o=t?Z(t):null;return r&&r.replaceWith(o),o},To=()=>t=>{t&&t.remove()},_o=(t=void 0,e=void 0)=>t===void 0||e===void 0?To():typeof t=="string"||typeof e=="string"?$e(e,t):t.tagName!==e.tagName?$e(e):e.tagName==="select"?fr.select(t,e):["pre","code"].includes(e.tagName)?$e(e,t):n=>(se(t.attributes,e.attributes)(n),ae(t.children,e.children)(n),n),ce=_o;var vo=(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)}},V=(t="",e=null)=>{try{S()||(vo(t)||{}).process(e)}catch(r){i("processQueue",r)}};var hr=(t="",e=null)=>{let r=L(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var wr=(t="",e={},r=null)=>{let o=L(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var yr=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(m(n)&&n.attributes&&n.attributes["js-i"]&&n.attributes["js-i"]===e){t.children[o]=r;break}m(n)&&yr(n,e,r)}},gr=yr;var xr=(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 br=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?xr(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){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}}),w(`ui.${t?.options?.test?.name||f()}.events.${s.type}.selector_${s?.selector}`,[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];br(c,e,r)}}return r}catch(o){i("component.eve!nts.registerListenersFix.getListeners",o)}},Co=(t={},e={})=>{try{let o=br(t,e,[])?.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];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)}},de=Co;var $r=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((n=[],s=[])=>[...n,...s],[])).flatMap((n={})=>$r(n));e=[...e,...o]}return e}catch(e){i("component.events.unregisterListenersFix.getListeners",e)}},Oo=(t={})=>{try{let e=$r(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)}},kr=Oo;var Er=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},lt(e),Bt(this,e),this.data=Wt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},n=this){let s=await oe(e,r,o,n);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=J(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(!S())return{instanceId:this.instanceId}}render(e={}){if(w(`ui.${this?.options?.test?.name||f()}.render`,[e]),e?.mounting)return mr(this,e);let r=this.onBeforeRender();kr(this),hr(this.instanceId);let o=B(this,{}),n=ce(this.dom.virtual,o.virtual);n&&u(n)&&V("lifecycle.onBeforeMount",()=>{let s=n(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,de(this,this.renderMethods),this.setDOMNodeOnInstance(),V("domNodes",()=>{V("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ie(this,e)}onAfterRender(e={},r={}){S()||(wr(e.instanceId,this),window.joystick._internal.css.update(),V("lifecycle.onUpdateProps"),r?.afterSetStateRender&&u(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&u(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){w(`ui.${this?.options?.test?.name||f()}.setState`,[e,r]),this.state=W(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&u(r)&&r()}})}setValues(e={},r=null){w(`ui.${this?.options?.test?.name||f()}.setValue`,[e,r]),this.values=W(this,{...this.values||{},...e})}setTimeout(e=null,r=0){e&&(this.timers[f()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[f()]=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=J(n?.instance?.DOMNode);gr(o?.instance?.dom?.virtual,n?.instanceId,s)}}},Fr=Er;var Mr=(t={})=>{try{return(e={})=>new Fr({...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 Sr=(t={})=>{try{window.joystick._internal.tree={id:t?.id||null,instanceId:t?.instanceId||null,instance:t,children:[]}}catch(e){i("mount.initializeJoystickComponentTree",e)}};var Tr=(t={},e=null)=>{try{return t.innerHTML="",t.appendChild(e),e}catch(r){i("mount.appendToDOM",r)}};var _r=(t=null,e={},r=null)=>{try{u(t)||i("mount","Component to mount must be a function."),m(e)||i("mount","props must be an object."),Re(r)||i("mount","target must be a DOM node.");let o=t({props:e});Sr(o);let n=o.render({mounting:!0,existingChildren:window.__joystick_childrenBeforeHMRUpdate__||null});return n&&(n.setAttribute("js-c",o.id),n.setAttribute("js-i",o.instanceId)),o.lifecycle.onBeforeMount(),V("lifecycle.onBeforeMount"),Tr(r,n),o.setDOMNodeOnInstance(),window.joystick._internal.css.update(),de(o,o.renderMethods),o.lifecycle.onMount(),V("lifecycle.onMount"),o}catch(o){i("mount",o)}};var vr=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=vr;var jo=new RegExp(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g),Ro=new RegExp(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g),Ao=(t,e)=>(e||"").replace(jo,()=>"").replace(Ro,r=>["@",": "].some(o=>r?.includes(o))?r:`[js-c="${t}"] ${r.trim()}`)?.trim(),Cr=(t={},e=[])=>{if(t.instance&&t.instance.options&&t.instance.options.css){let r=t.instance.id,o=t.instance.options.css,n=te(o,t.instance),s=Ao(r,n);e.push(s)}if(t.children&&t.children.length>0){let r=t?.children?.length||0;for(;r--;)Cr(t.children[r],e)}return e},Or=Cr;var jr=()=>{try{let t=document.head.querySelector("style[js-styles]"),r=Or(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 Rr=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var Do=Ce,Lo=Le,Po=G.get,Io={get:Pe,track:me},qo=Ie,Vo=qe,No=G.set,mu=Ne,pu=me,Ho=ze,ke=()=>typeof window!="undefined"?window.__joystick_env__:typeof process!="undefined"?"production":null,le={_external:{},_internal:{last_interaction:null,css:{update:jr},queues:{domNodes:new N([]),eventListeners:new N([]),lifecycle:{onBeforeMount:new N([]),onMount:new N([]),onUpdateProps:new N([])},render:new N([])},tree:{},eventListeners:[]},accounts:Do,cache:Lo,component:Mr,env:{development:ke()==="development",test:ke()==="test"},external:Io,get:Po,html:qo,id:f,mount:_r,renderComponentToHTML:Vo,set:No,upload:Ho,timers:{}};typeof window!="undefined"&&ke()!=="test"&&(document.body.addEventListener("mouseover",()=>{Rr(()=>{le._internal.last_interaction=new Date().toISOString()},1e3)}),setInterval(()=>{let t=new Date;t.setMinutes(t.getMinutes()-30),le._internal.last_interaction<=t.toISOString()&&location.reload()},30*1e3));Be(le);var fu=le;export{Do as accounts,Lo as cache,fu as default,Io as external,Po as get,qo as html,Vo as renderComponentToHTML,No as set,mu as test,pu as trackExternal,Ho as upload};
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.98",
4
+ "version": "0.0.0-canary.99",
5
5
  "description": "A JavaScript framework for building user interfaces.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {