import{da as r,_ as i}from"./main-tangy-colts-beg.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,t){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,t),t)}};const u="https://my.demio.com/api/v1",d=async(e,t)=>r({headers:{Accept:"application/json","Api-Key":e,"Api-Secret":{encryption:"hmac_decrypt",value:t}},method:"GET",url:`${u}/events`}),h=async(e,t,a)=>r({headers:{Accept:"application/json","Api-Key":e,"Api-Secret":{encryption:"hmac_decrypt",value:t}},method:"GET",url:`${u}/event/${a}`});globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,t){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,t),t)}};const p=async e=>{e.setComponent("event-id",n=>{n.loading=!0});const t=await e.getConnection();if(!t)return;const{data:a,status:s}=await d(t.auth_details.key,t.auth_details.value);if(s!=="success"){e.setComponent("event-id",n=>{e.util.isSelectComponent(n)&&(n.loading=!1,n.status=s,n.invalidMessage=a)}),console.error("Failed to fetch list");return}e.setComponent("event-id",n=>{e.util.isSelectComponent(n)&&(n.options=a==null?void 0:a.map(o=>({label:o.name,value:o.id})),n.loading=!1)})},f=async e=>{var n;e.setComponent("session-id",o=>{o.loading=!0});const t=await e.getConnection();if(!t)return;const{data:a,status:s}=await h(t.auth_details.key,t.auth_details.value,(n=e.getComponent("event-id"))==null?void 0:n.value);if(s!=="success"){e.setComponent("session-id",o=>{e.util.isSelectComponent(o)&&(o.loading=!1,o.status=s,o.invalidMessage=a)}),console.error("Failed to fetch list");return}e.setComponent("session-id",o=>{var c;console.error(a),e.util.isSelectComponent(o)&&(o.options=(c=a==null?void 0:a.dates)==null?void 0:c.map(l=>({label:l.datetime,value:l.date_id})),o.loading=!1)})},g=async e=>{if(e.setComponent("row-data",s=>{s.loading=!0}),!await e.getConnection()){e.setComponent("row-data",s=>{s.loading=!1});return}const a=[{key:"name",label:i("Name"),required:!0},{key:"phone_number",label:i("Phone Number"),required:!1},{key:"company",label:i("Company"),required:!1},{key:"website",label:i("Website"),required:!1},{key:"gdpr",label:i("GDPR"),required:!1},{key:"ref_url",label:i("Event Registration page URL"),required:!1}];e.setComponent("row-data",s=>{if(!e.util.isRepeaterFieldComponent(s))return;const n=s.fieldsMetaData[0],o=a==null?void 0:a.map(l=>({label:l.label,value:l.key})),c=[{label:i("Email"),value:"Email"},...o];n.options=c,s.loading=!1})};export{g as a,f as b,p as f};
