import{aa as n,ab as c}from"./_applist-tangy-colts-beg-36.js";import{aR as r,_ as s}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(o,e){return this.cache.has(o)?this.cache.get(o):(this.cache.set(o,e),e)}};const l=async()=>r("pro_wsform/get-forms",void 0,void 0,"GET");globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(o,e){return this.cache.has(o)?this.cache.get(o):(this.cache.set(o,e),e)}};const i=async o=>{o.setComponent("form-id",t=>{t.loading=!0});const{data:e,status:a}=await l();if(a==="error"){o.setComponent("form-id",t=>{o.util.isSelectComponent(t)&&(t.status=a,t.loading=!1,t.invalidMessage=e)}),console.error("Failed to fetch form");return}o.setComponent("form-id",t=>{o.util.isSelectComponent(t)&&(t.options=e,t.loading=!1,t.status=void 0)})};globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(o,e){return this.cache.has(o)?this.cache.get(o):(this.cache.set(o,e),e)}};const g=n(({helpers:o})=>({actions:{ON_MACHINE_LOAD:async({$:e})=>{h(e,[{db:"formId",id:"form-id"}]),await i(e)},REFETCH_FORMS:async({$:e})=>i(e),SELECT_FORM:async({$:e,e:a})=>{e.setThisComponent(t=>{t.value=a}),e.setDb({formId:a})}},states:{components:[{componentName:o.componentName.select,fieldType:"config",helperText:s('Note: navigate to the WS Form settings, select "Run WordPress Hook" as the action type, and enter the Hook Tag: bit_pi_do_action.'),id:"form-id",label:s("Forms"),onChange:"SELECT_FORM",onRefetch:"REFETCH_FORMS",options:[],placeholder:s("Select a form"),render:!0,value:void 0},{componentName:o.componentName.hookListener,fieldType:"config",id:"hook-listener",label:s("Listen Hook"),render:({$:e})=>{var a;return c((a=e.getComponent("form-id"))==null?void 0:a.value)}}]}}));export{g as default};
