import{aa as n,ab as c}from"./_applist-tangy-colts-beg-36.js";import{aR as r,_ as i}from"./main-tangy-colts-beg.js";import{s as h}from"./machine.-tangy-colts-beg-869.js";import"./lodash-tangy-colts-beg-516.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,e){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,e),e)}};const l=async()=>r("pro_tripetto/get",void 0,void 0,"GET");globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,e){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,e),e)}};const s=async t=>{t.setComponent("form-id",o=>{o.loading=!0});const{data:e,status:a}=await l();if(a==="error"){t.setComponent("form-id",o=>{t.util.isSelectComponent(o)&&(o.status=a,o.loading=!1,o.invalidMessage=e)}),console.error("Failed to fetch form");return}t.setComponent("form-id",o=>{t.util.isSelectComponent(o)&&(o.options=e,o.loading=!1,o.status=void 0)})};globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,e){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,e),e)}};const p=n(({helpers:t})=>({actions:{ON_MACHINE_LOAD:async({$:e})=>{h(e,[{db:"formId",id:"form-id"}]),await s(e)},REFETCH_FORMS:async({$:e})=>s(e),SELECT_FORM:async({$:e,e:a})=>{e.setThisComponent(o=>{o.value=a}),e.setDb({formId:a})}},states:{components:[{componentName:t.componentName.select,fieldType:"config",id:"form-id",label:i("Forms"),onChange:"SELECT_FORM",onRefetch:"REFETCH_FORMS",options:[],placeholder:i("Select a form"),render:!0,value:void 0},{componentName:t.componentName.hookListener,fieldType:"config",id:"hook-listener",label:i("Listen Hook"),render:({$:e})=>{var a;return c((a=e.getComponent("form-id"))==null?void 0:a.value)}}]}}));export{p as default};
