var r=Object.defineProperty,f=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var l=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable;var g=(e,a,i)=>a in e?r(e,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[a]=i,s=(e,a)=>{for(var i in a||(a={}))l.call(a,i)&&g(e,i,a[i]);if(F)for(var i of F(a))p.call(a,i)&&g(e,i,a[i]);return e},b=(e,a)=>f(e,k(a));import{u as m}from"./Note.DalStCGz.js";import{_ as n,b as _,z as o}from"./main.2.8.10.js";const z=(e,a,i)=>{const t=s({},a),{name:c}=e.target;e.target.value!==""?t[c]=e.target.value:delete t[c],i(s({},t))},u=e=>{const a=e.filter(i=>i.required===!0);return a.length>0?a.map(i=>({formField:"",bentoFormField:i.key})):[{formField:"",bentoFormField:""}]},A=e=>(e!=null&&e.field_map?e.field_map.filter(i=>!i.formField||!i.bentoFormField||i.formField==="custom"&&!i.customValue||e.action==="add_event"&&i.bentoFormField==="customFieldKey"&&!i.customFieldKey):[]).length<=0,h=(e,a={})=>b(s({},a),{publishable_key:e.publishable_key,secret_key:e.secret_key,site_uuid:e.site_uuid}),P=(e,a,i,t,c)=>{if(!e.publishable_key||!e.secret_key||!e.site_uuid){a({publishable_key:e.publishable_key?"":n("Publishable Key can't be empty","bit-integrations"),secret_key:e.secret_key?"":n("Secret Key can't be empty","bit-integrations"),site_uuid:e.site_uuid?"":n("Site UUID can't be empty","bit-integrations")});return}a({}),c(b(s({},t),{auth:!0})),_(h(e),"bento_authentication").then(d=>{if(c(b(s({},t),{auth:!1})),d&&d.success){i(!0),o.success(n("Authorized Successfully","bit-integrations"));return}o.error(d!=null&&d.data?d==null?void 0:d.data:n("Authorized failed, Please enter valid Publishable Key, Secret Key & Site UUID","bit-integrations"))})},U=(e,a,i,t)=>{t(!0),_(h(e,{action:i}),"bento_get_fields").then(c=>{if(t(!1),c!=null&&c.success&&(c!=null&&c.data)){a(d=>m(d,y=>{y.bentoFields=c.data,y.field_map=u(c.data)})),o.success(n("Fields fetched successfully","bit-integrations"));return}o.error(c!=null&&c.data?c==null?void 0:c.data:n("Fields fetching failed","bit-integrations"))})},q=(e,a,i)=>{i(b(s({},i),{tags:!0})),_(h(e),"bento_get_all_tags").then(t=>{if(i(b(s({},i),{tags:!1})),t!=null&&t.success&&(t!=null&&t.data)){a(c=>m(c,d=>{d.tags=t.data})),o.success(n("Fields fetched successfully","bit-integrations"));return}o.error(t!=null&&t.data?t==null?void 0:t.data:n("Fields fetching failed","bit-integrations"))})};export{U as a,P as b,A as c,q as g,z as h};
